# internal/adapters/jsonstore

Package jsonstore persists session ledgers as atomic JSON files.

## ErrSessionNotFound

```go
var ErrSessionNotFound = errors.New("session not found")
```

ErrSessionNotFound is returned when a task has no session ledger.

## SessionStore

```go
type SessionStore struct {
	Root         string
	TrustChecker session.ReceiptTrustChecker
}
```

SessionStore persists session ledgers below .scafld/runs.

- `Root: string`: 
- `TrustChecker: session.ReceiptTrustChecker`: 

## Append

```go
func (s SessionStore) Append(ctx context.Context, taskID string, entry session.Entry, now string) (session.Session, error)
```

Append appends one evidence entry and atomically writes the replayed ledger.

## AppendTransaction

```go
func (s SessionStore) AppendTransaction(ctx context.Context, taskID string, now string, derive func(session.Session) ([]session.Entry, error)) (session.Session, error)
```

AppendTransaction derives and appends zero or more entries while holding the session file lock. Use it when the decision to append depends on the current ledger head and must not race another scafld process.

## List

```go
func (s SessionStore) List(ctx context.Context) ([]session.Session, error)
```

List reads all session ledgers under .scafld/runs.

## Load

```go
func (s SessionStore) Load(ctx context.Context, taskID string) (session.Session, error)
```

Load reads and replays the session ledger for taskID.

## Save

```go
func (s SessionStore) Save(ctx context.Context, ledger session.Session) error
```

Save atomically replaces the session ledger.
