# internal/adapters/markdown

Package markdown parses, renders, and stores living Markdown task specs.

## ErrSpecNotFound

```go
var (
	// ErrSpecNotFound is returned when taskID cannot be found in spec directories.
	ErrSpecNotFound = errors.New("spec not found")
	// ErrSpecExists is returned when a write would overwrite another task spec.
	ErrSpecExists = errors.New("spec already exists")
	// ErrMalformedMarkdown wraps spec Markdown grammar failures.
	ErrMalformedMarkdown = errors.New("malformed markdown spec")
)
```

## ErrSpecExists

```go
var (
	// ErrSpecNotFound is returned when taskID cannot be found in spec directories.
	ErrSpecNotFound = errors.New("spec not found")
	// ErrSpecExists is returned when a write would overwrite another task spec.
	ErrSpecExists = errors.New("spec already exists")
	// ErrMalformedMarkdown wraps spec Markdown grammar failures.
	ErrMalformedMarkdown = errors.New("malformed markdown spec")
)
```

## ErrMalformedMarkdown

```go
var (
	// ErrSpecNotFound is returned when taskID cannot be found in spec directories.
	ErrSpecNotFound = errors.New("spec not found")
	// ErrSpecExists is returned when a write would overwrite another task spec.
	ErrSpecExists = errors.New("spec already exists")
	// ErrMalformedMarkdown wraps spec Markdown grammar failures.
	ErrMalformedMarkdown = errors.New("malformed markdown spec")
)
```

## Parse

```go
func Parse(data []byte) (spec.Model, error)
```

Parse converts living Markdown spec bytes into a normalized model.

## Render

```go
func Render(model spec.Model) []byte
```

Render converts a normalized model into canonical living Markdown.

## Store

```go
type Store struct {
	Root string
}
```

Store reads and writes Markdown task specs under a workspace root.

- `Root: string`: 

## CreateDraft

```go
func (s Store) CreateDraft(ctx context.Context, model spec.Model) (string, error)
```

CreateDraft writes model as a new draft spec and returns its path.

## Find

```go
func (s Store) Find(taskID string) (string, error)
```

Find returns the path for taskID across active spec directories.

## List

```go
func (s Store) List(ctx context.Context) ([]spec.Record, error)
```

List returns summaries for current non-archived task specs.

## ListAll

```go
func (s Store) ListAll(ctx context.Context) ([]spec.Record, error)
```

ListAll returns summaries for current and archived task specs.

## Load

```go
func (s Store) Load(ctx context.Context, taskID string) (spec.Model, string, error)
```

Load finds, parses, and returns a spec by task ID. Loading is read-only: lifecycle projections are derived from the session ledger, and only explicit save/create commands may move or rewrite the canonical Markdown contract.

## LoadSource

```go
func (s Store) LoadSource(ctx context.Context, taskID string) (spec.Source, error)
```

LoadSource finds, parses, and returns a spec together with the exact Markdown bytes read from disk. Loading is read-only and returns the path actually read.

## Save

```go
func (s Store) Save(ctx context.Context, path string, model spec.Model) error
```

Save writes model to an existing spec path.
