Skip to content

Commit 73777b9

Browse files
[instructions] Split experimental ledger docs out of memory.md
memory.md had grown to 407 lines, over the 400-line instruction-file cap, after recent repo-memory JSON-schema-validation changes (#67439). Extract the self-contained "standalone ledger (experimental)" section into a new ledger.md, replacing it with a short pointer. Update the cross-reference in memory-stateful-patterns.md to link directly to ledger.md instead of an anchor inside memory.md. debug-agentic-workflow.md is also over the cap (432 lines) after recent model/engine-misconfiguration diagnostics (#67488), but its checklist content is pinned inline by a regression test (.github/skills/agentic-workflows/tests/test_guidance.py) that also requires it mirrored in root debug.md, so it is left as a documented exception rather than split. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 6b97fe9 commit 73777b9

3 files changed

Lines changed: 74 additions & 54 deletions

File tree

‎.github/aw/ledger.md‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
description: Experimental tools.ledger — structured, immutable, append-only event history with built-in state-model projections.
3+
---
4+
5+
# Ledger (Experimental)
6+
7+
Use the ledger for immutable, structured events when each run should add records
8+
and later runs need to query them. For example, a low-volume audit can append
9+
one result per scan and query prior results by a stable application-level key.
10+
Configure `tools.ledger` independently of repo-memory. The legacy
11+
`tools.repo-memory.ledger` declaration is unsupported. Each ledger has a
12+
`ledgers/<name>` branch and a disposable read-only SQLite projection rebuilt
13+
from persisted JSONL shards.
14+
15+
```yaml
16+
tools:
17+
ledger:
18+
audit-history:
19+
type: log
20+
compaction:
21+
min-segments: 32
22+
max-segments: 32
23+
```
24+
25+
Declare `type: log`, `set`, `map`, `table`, `counter`, or `notes` for built-in state
26+
models. Schemas validate operation values, not envelopes; tables require a
27+
string primary-key field through `key`. Maps expose `ledger_map_put` and
28+
`ledger_map_delete`; notes expose `ledger_note_add` and `ledger_note_vote`.
29+
Other types use typed `ledger_append` operations.
30+
31+
Query `state` for current state or `records` for immutable history at
32+
`/tmp/gh-aw/ledgers/<name>/ledger.db`. For a log, submit `ledger_append` with
33+
`operation: append` and the event in `value`. Requests are deferred and become
34+
durable only when the trusted `push_ledger_changes` job succeeds; queued writes
35+
are not immediately visible in the run's projection. Never edit SQLite or
36+
canonical ledger files.
37+
38+
Each record is limited to 32 KiB, each shard defaults to 100 KiB, and each run
39+
defaults to a 10 KiB append budget. Configure per-ledger limits with
40+
`max-segment-kb`, `max-record-kb`, and `max-patch-kb`. Projection preparation
41+
inspects at most 1024 canonical files and 100 MiB of history.
42+
Each writing workflow invocation creates a shard, so a frequently running
43+
workflow can exhaust the shard limit. Use ordinary repo-memory files for
44+
replaceable snapshots, pruned baselines, or histories that need more than 1024
45+
writer shards. Compaction belongs to Agentic Maintenance, never the agent or
46+
persistence job. Use per-ledger `compaction` settings (`schedule`,
47+
`min-segments`, `max-segments`) or disable it with `compaction: false`.
48+
Custom `replay.script`, `replay.config`, and `compaction.script` settings are
49+
rejected. Ordinary repo-memory `validation.script` remains a separate supported
50+
file-storage validator.
51+
52+
Removing custom replay does not rewrite history. Existing raw-record ledgers
53+
can omit `type` and query `records.payload` with SQLite JSON functions. Do not
54+
add a built-in type to raw history unless every payload already matches that
55+
type's operation format. Use a new ledger name for a new typed state model.
56+
See the [ledger replay reference](https://github.com/github/gh-aw/blob/main/docs/src/content/docs/experimental/ledger-replay.md)
57+
and [compaction guide](https://github.com/github/gh-aw/blob/main/docs/src/content/docs/experimental/ledger-compaction.md).
58+
59+
## Tradeoffs
60+
61+
| ✅ Pros | ❌ Cons |
62+
|---|---|
63+
| Persists indefinitely (no expiry) | Produces Git commits — repository noise |
64+
| Auditable: Git history shows every change | Slower: requires Git clone + push |
65+
| Survives cache invalidation | Not available for Copilot engine (requires GitHub tools) |
66+
| Human-readable via GitHub branch UI | More complex setup |
67+
| Can target a different repository | |
68+
| Provides immutable structured records and queries | Experimental, append-only, and limited to 1024 shard files by default |

‎.github/aw/memory-stateful-patterns.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ after `push_ledger_changes` succeeds. Never modify SQLite or ledger shards
138138
directly. Use stable application keys to identify duplicate events.
139139

140140
For built-in types, script restrictions, and persistence behavior, see
141-
[memory.md](memory.md#structured-event-history-standalone-ledger-experimental).
141+
[ledger.md](ledger.md).

‎.github/aw/memory.md‎

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For workflows that **persist state across runs** — deduplication, incremental
2020
| Track a numeric metric and compare current vs. baseline (runs at least every 7 days) | `cache-memory` ✅ first choice |
2121
| Long-lived knowledge base visible in PRs and code reviews | `repo-memory` |
2222
| Baselines that must survive cache expiry (e.g. security findings, dedup lists) | `repo-memory` |
23-
| Bounded append-only structured event history and built-in current-state projections | Experimental `tools.ledger` |
23+
| Bounded append-only structured event history and built-in current-state projections | Experimental `tools.ledger` — see [ledger.md](ledger.md) |
2424
| Human-readable wiki pages for knowledge accumulation | `repo-memory` with `wiki: true` |
2525
| Persist notes/state inline on the triggering issue or PR | `comment-memory` |
2626
| Private-preview GitHub Drives backend (enrolled repos only) | `drive-memory` — see [drive-memory.md](drive-memory.md) |
@@ -221,57 +221,10 @@ Compiler creates a separate `push_repo_memory` job with `contents: write`; main
221221

222222
### Structured event history: standalone ledger (experimental)
223223

224-
Use the ledger for immutable, structured events when each run should add records
225-
and later runs need to query them. For example, a low-volume audit can append
226-
one result per scan and query prior results by a stable application-level key.
227-
Configure `tools.ledger` independently of repo-memory. The legacy
228-
`tools.repo-memory.ledger` declaration is unsupported. Each ledger has a
229-
`ledgers/<name>` branch and a disposable read-only SQLite projection rebuilt
230-
from persisted JSONL shards.
231-
232-
```yaml
233-
tools:
234-
ledger:
235-
audit-history:
236-
type: log
237-
compaction:
238-
min-segments: 32
239-
max-segments: 32
240-
```
241-
242-
Declare `type: log`, `set`, `map`, `table`, `counter`, or `notes` for built-in state
243-
models. Schemas validate operation values, not envelopes; tables require a
244-
string primary-key field through `key`. Maps expose `ledger_map_put` and
245-
`ledger_map_delete`; notes expose `ledger_note_add` and `ledger_note_vote`.
246-
Other types use typed `ledger_append` operations.
247-
248-
Query `state` for current state or `records` for immutable history at
249-
`/tmp/gh-aw/ledgers/<name>/ledger.db`. For a log, submit `ledger_append` with
250-
`operation: append` and the event in `value`. Requests are deferred and become
251-
durable only when the trusted `push_ledger_changes` job succeeds; queued writes
252-
are not immediately visible in the run's projection. Never edit SQLite or
253-
canonical ledger files.
254-
255-
Each record is limited to 32 KiB, each shard defaults to 100 KiB, and each run
256-
defaults to a 10 KiB append budget. Configure per-ledger limits with
257-
`max-segment-kb`, `max-record-kb`, and `max-patch-kb`. Projection preparation
258-
inspects at most 1024 canonical files and 100 MiB of history.
259-
Each writing workflow invocation creates a shard, so a frequently running
260-
workflow can exhaust the shard limit. Use ordinary repo-memory files for
261-
replaceable snapshots, pruned baselines, or histories that need more than 1024
262-
writer shards. Compaction belongs to Agentic Maintenance, never the agent or
263-
persistence job. Use per-ledger `compaction` settings (`schedule`,
264-
`min-segments`, `max-segments`) or disable it with `compaction: false`.
265-
Custom `replay.script`, `replay.config`, and `compaction.script` settings are
266-
rejected. Ordinary repo-memory `validation.script` remains a separate supported
267-
file-storage validator.
268-
269-
Removing custom replay does not rewrite history. Existing raw-record ledgers
270-
can omit `type` and query `records.payload` with SQLite JSON functions. Do not
271-
add a built-in type to raw history unless every payload already matches that
272-
type's operation format. Use a new ledger name for a new typed state model.
273-
See the [ledger replay reference](https://github.com/github/gh-aw/blob/main/docs/src/content/docs/experimental/ledger-replay.md)
274-
and [compaction guide](https://github.com/github/gh-aw/blob/main/docs/src/content/docs/experimental/ledger-compaction.md).
224+
For immutable, structured events where each run appends records and later runs
225+
query them by a stable key, use experimental `tools.ledger` instead — configured
226+
independently of repo-memory. See [ledger.md](ledger.md) for configuration,
227+
state-model types, limits, and compaction.
275228

276229
### Tradeoffs
277230

@@ -282,7 +235,6 @@ and [compaction guide](https://github.com/github/gh-aw/blob/main/docs/src/conten
282235
| Survives cache invalidation | Not available for Copilot engine (requires GitHub tools) |
283236
| Human-readable via GitHub branch UI | More complex setup |
284237
| Can target a different repository | |
285-
| Ledger mode provides immutable structured records and queries | Experimental, append-only, and limited to 1024 shard files by default |
286238

287239
---
288240

0 commit comments

Comments
 (0)