Documentation
¶
Overview ¶
Package jsonlstore provides an append-only, JSONL-file checkpoint.Store for local development. Each Save/Delete appends one JSON record; the live state is the last record seen per key. On open the file is replayed to rebuild the in-memory index and the CAS counter, so state survives process restarts.
The store is safe for concurrent use within a single process, but the log file must not be shared between processes. Conformance with the Store contract is asserted by the shared storetest suite.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an append-only JSONL-backed checkpoint.Store. Create with New; safe for concurrent use within a single process.
func New ¶
New opens (creating if absent) the JSONL log at path and replays it to rebuild live state.
Example ¶
ExampleNew demonstrates that a parked envelope survives a process restart: a fresh open of the same JSONL log replays it and serves the same state.
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"path/filepath"
"chainguard.dev/driftlessaf/agents/checkpoint"
"chainguard.dev/driftlessaf/agents/checkpoint/jsonlstore"
)
func main() {
dir, err := os.MkdirTemp("", "jsonlstore-example")
if err != nil {
fmt.Println("error:", err)
return
}
defer os.RemoveAll(dir)
path := filepath.Join(dir, "checkpoints.jsonl")
ctx := context.Background()
first, err := jsonlstore.New(path)
if err != nil {
fmt.Println("error:", err)
return
}
env := &checkpoint.Envelope{
Version: checkpoint.EnvelopeVersion,
Provider: checkpoint.ProviderAnthropic,
ReconcilerKey: "org/repo#7",
RunID: "run-7",
ProviderState: json.RawMessage(`{"model":"claude-fable-5"}`),
}
if err := first.Save(ctx, env.ReconcilerKey, env); err != nil {
fmt.Println("error:", err)
return
}
// A second open (a "restarted process") replays the log.
second, err := jsonlstore.New(path)
if err != nil {
fmt.Println("error:", err)
return
}
loaded, _, ok, err := second.Load(ctx, env.ReconcilerKey)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println("survived reopen:", ok, loaded.RunID)
}
Output: survived reopen: true run-7