Add built-in log, set, map, table, and counter ledgers - #64721
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot review usage of ledgers in agentic workflows in the repo and migrate to builtin types where appropriate. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Typed writes are not propagated to the handler configuration, and oversized table state can be persisted but not projected.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Adds declarative built-in ledger reducers with trusted validation, replay, persistence, and SQLite state projections.
Changes:
- Adds
log,set,map,table, andcounterdeclarations and operations. - Implements deterministic reducers, concurrency checks, projections, and tests.
- Updates documentation, schemas, safe-output contracts, and generated workflows.
| File | Description |
|---|---|
pkg/workflow/safe_outputs_validation_config.go |
Adds typed ledger fields and null preservation. |
pkg/workflow/maintenance_workflow_ledger_compaction.go |
Includes built-in metadata in compaction configuration. |
pkg/workflow/ledger.go |
Parses, validates, and prompts for built-in ledgers. |
pkg/workflow/ledger_test.go |
Tests built-in declarations. |
pkg/workflow/js/safe_outputs_tools.json |
Extends the ledger safe-output schema. |
pkg/parser/tools_merger.go |
Recognizes concise built-in declarations. |
pkg/parser/schemas/main_workflow_schema.json |
Documents and validates built-in fields. |
docs/src/content/docs/experimental/ledger-replay.md |
Documents reducers, operations, and projections. |
actions/setup/js/safe_outputs_tools.json |
Updates the runtime tool contract. |
actions/setup/js/safe_output_type_validator.test.cjs |
Tests explicit null preservation. |
actions/setup/js/safe_output_type_validator.cjs |
Preserves permitted null values. |
actions/setup/js/push_signed_commits.test.cjs |
Tests stale-head rejection. |
actions/setup/js/push_signed_commits.cjs |
Adds atomic base-reference checks. |
actions/setup/js/push_repo_memory.cjs |
Revalidates typed ledgers during retries. |
actions/setup/js/push_ledger_changes.test.cjs |
Tests redacted transaction reporting. |
actions/setup/js/push_ledger_changes.cjs |
Validates transitions and reports metadata. |
actions/setup/js/ledger_transactions.cjs |
Normalizes typed ledger operations. |
actions/setup/js/ledger_replay.cjs |
Makes replay row limits configurable. |
actions/setup/js/ledger_builtin.test.cjs |
Tests all built-in reducers. |
actions/setup/js/ledger_builtin.cjs |
Implements built-in validation and reduction. |
actions/setup/js/create_ledger_projection.test.cjs |
Tests projections and compaction equivalence. |
actions/setup/js/create_ledger_projection.cjs |
Materializes built-in state tables. |
.github/workflows/smoke-repo-memory-ledger.lock.yml |
Regenerates ledger validation configuration. |
.github/workflows/daily-mcp-concurrency-analysis.lock.yml |
Regenerates ledger validation configuration. |
.github/workflows/daily-caveman-optimizer.lock.yml |
Regenerates ledger validation configuration. |
.github/workflows/daily-awf-spec-compiler-surfacing.lock.yml |
Regenerates ledger validation configuration. |
.github/workflows/copilot-centralization-optimizer.lock.yml |
Regenerates ledger validation configuration. |
.github/workflows/audit-workflows.lock.yml |
Regenerates ledger validation configuration. |
| const row = operation === "update" ? { ...state.get(primary), ...record.patch } : value; | ||
| checkSchema(row, config.schema); | ||
| state.set(primary, row); |
There was a problem hiding this comment.
Fixed in d3eee47: table reducer transitions reject merged rows that exceed the replay cell size limit.
| Type string `json:"type,omitempty"` | ||
| Key string `json:"key,omitempty"` |
There was a problem hiding this comment.
Fixed in d3eee47: generated ledger_append config now includes the typed ledger type and key, with a config-generation test.
| "properties": { | ||
| "type": { "type": "string", "enum": ["log", "set", "map", "table", "counter"], "description": "Built-in ledger reducer type." }, | ||
| "key": { "type": "string", "pattern": "^[A-Za-z][A-Za-z0-9_]{0,63}$", "description": "Table primary-key field (only for type: table)." } | ||
| }, |
There was a problem hiding this comment.
Fixed in d3eee47: the type and key schema properties now also accept object-valued named ledger declarations.
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Migrated the simple run/snapshot ledgers in |
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
| "ledger": "smoke", | ||
| "operation": "upsert", | ||
| "key": "${{ github.run_id }}", | ||
| "value": { | ||
| "record_type": "repo_memory_ledger_smoke", | ||
| "workflow_run_id": "${{ github.run_id }}", | ||
| "result": "passed" | ||
| } |
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Completed the PR-finisher pass. Local lint, tests, workflow recompilation, and final impacted tests pass; |
|
@copilot add a integration test workflow file that declares all supported builtin ledgers |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added |
|
|
Great work on the ledger types — well-focused with solid test coverage. Looks ready for review. 🎉
|
|
@copilot resolve the merge conflicts on this branch. |
The built-in ledger integration workflow is already present in |
…ledger-types # Conflicts: # .github/workflows/agentics-maintenance.yml Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Merged |


Common ledger state should be declarative and deterministic without custom replay scripts. This PR introduces five generic reducers while retaining custom replay for other use cases.
Declarations and writes
type: log | set | map | table | counterto existingtools.ledgerdeclarations; tables require a primary-keykey.ledger_appendsafe output with type-specific operations. Reject unsupported operations and conflicting custom replay configurations.A write uses
{"ledger":"findings","operation":"upsert","value":{"id":"F123"}}.Trusted replay and persistence
statetables alongside immutable records.Compaction boundary