Skip to content

Add built-in log, set, map, table, and counter ledgers - #64721

Merged
pelikhan merged 9 commits into
mainfrom
copilot/add-built-in-ledger-types
Oct 1, 2026
Merged

pelikhan merged 9 commits into
mainfrom
copilot/add-built-in-ledger-types

Conversation

Copilot AI commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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

    • Add type: log | set | map | table | counter to existing tools.ledger declarations; tables require a primary-key key.
    • Use the existing ledger_append safe output with type-specific operations. Reject unsupported operations and conflicting custom replay configurations.
    tools:
      ledger:
        findings:
          type: table
          key: id
          schema:
            type: object
            required: [id]
            properties:
              id: { type: string }

    A write uses {"ledger":"findings","operation":"upsert","value":{"id":"F123"}}.

  • Trusted replay and persistence

    • Centralize operation validation and reduction; materialize read-only SQLite state tables alongside immutable records.
    • Validate transitions before branch mutation and reject concurrent writes against a changed branch head. Report transaction metadata without echoing values.
    • Preserve JSON-null values and canonical JSON equality for set membership.
  • Compaction boundary

    • Existing lossless compaction preserves transaction identities and produces equivalent built-in replay state. Folding redundant set, map, or counter transactions into fewer records is not included; it requires an extension to the current integrity and provenance contract.

Copilot AI and others added 3 commits October 1, 2026 07:10
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 AI changed the title Add built-in log, set, map, table, and counter ledger reducers Add built-in log, set, map, table, and counter ledgers Oct 1, 2026
Copilot AI requested a review from pelikhan October 1, 2026 07:36
@pelikhan
pelikhan marked this pull request as ready for review October 1, 2026 11:17
Copilot AI balanced review requested due to automatic review settings October 1, 2026 11:17
@pelikhan

pelikhan commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot review usage of ledgers in agentic workflows in the repo and migrate to builtin types where appropriate.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 High severity · 1 Medium severity

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, and counter declarations 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.

Comment on lines +88 to +90
const row = operation === "update" ? { ...state.get(primary), ...record.patch } : value;
checkSchema(row, config.schema);
state.set(primary, row);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d3eee47: table reducer transitions reject merged rows that exceed the replay cell size limit.

Comment thread pkg/workflow/ledger.go
Comment on lines +45 to +46
Type string `json:"type,omitempty"`
Key string `json:"key,omitempty"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d3eee47: generated ledger_append config now includes the typed ledger type and key, with a config-generation test.

Comment on lines +5491 to +5494
"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)." }
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d3eee47: the type and key schema properties now also accept object-valued named ledger declarations.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef
@copilot this PR still needs forward progress before a maintainer can investigate efficiently.
...

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 12.3 AIC · ⌖ 9.94 AIC · ⊞ 9.4K · ◷
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review usage of ledgers in agentic workflows in the repo and migrate to builtin types where appropriate.

Migrated the simple run/snapshot ledgers in daily-caveman-optimizer, smoke-repo-memory-ledger, copilot-centralization-optimizer, and audit-workflows to built-in table ledgers with upsert writes and state queries. Kept custom replay for workflows that derive multiple projections. Regenerated locks and committed as a07de24.

Copilot AI and others added 2 commits October 1, 2026 11:47
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>
Copilot AI requested a review from gh-aw-bot October 1, 2026 12:01
Comment on lines +75 to +82
"ledger": "smoke",
"operation": "upsert",
"key": "${{ github.run_id }}",
"value": {
"record_type": "repo_memory_ledger_smoke",
"workflow_run_id": "${{ github.run_id }}",
"result": "passed"
}
@pelikhan

pelikhan commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Completed the PR-finisher pass. Local lint, tests, workflow recompilation, and final impacted tests pass; aa10ae0 fixes the CJS packaging/schema failures. The three Copilot review comments have replies, but the available GitHub tools do not support resolving review threads. The PR remains blocked pending review, and CI must be re-triggered by a maintainer after this agent push.

@pelikhan

pelikhan commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot add a integration test workflow file that declares all supported builtin ledgers

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add a integration test workflow file that declares all supported builtin ledgers

Added .github/workflows/smoke-builtin-ledgers.md and its compiled lock, covering all five built-in ledger types and their operations. Recompile and impacted tests pass; commit: 4343687.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef
@copilot this PR still needs forward progress before a maintainer can investigate efficiently.

  • Please address the latest request from @pelikhan to add an integration test workflow file that declares all supported built-in ledgers.
  • After updating the branch, run the pr-finisher skill again so the PR is ready for maintainer review.
  • If CI needs another pass after your changes, include the relevant results in your follow-up.

Generated by 👨🍳 PR Sous Chef

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 21.7 AIC · ⌖ 8.68 AIC · ⊞ 9.7K · ◷
Comment /souschef to run again

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Great work on the ledger types — well-focused with solid test coverage. Looks ready for review. 🎉

Generated by ✅ Contribution Check · copilot · auto · 32.4 AIC · ⌖ 6.56 AIC · ⊞ 9.1K · ◷

@pelikhan

pelikhan commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts on this branch.

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

pr-sous-chef
@copilot this PR still needs forward progress before a maintainer can investigate efficiently.
...

The built-in ledger integration workflow is already present in 4343687 and covers all five types. Re-ran local make fmt, make lint, make test-unit, make test, and make recompile; all passed, and the worktree remains clean. Current PR status is pending: the Copilot run is still in progress and its logs are unavailable; the completed Advanced Security check passed. Three Copilot review threads have prior substantive replies but remain unresolved, and this toolset cannot resolve them. CI on this HEAD still needs a maintainer-triggered run.

…ledger-types

# Conflicts:
#	.github/workflows/agentics-maintenance.yml

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts on this branch.

Merged main and resolved the generated maintenance workflow conflict by rebuilding and recompiling it from the merged sources. Also corrected the merge-exposed config fixtures and documented the two missing ESLint rules. The merge is committed and pushed as 047d309; formatting, lint, workflow tests, and the final impacted validation gate passed.

@pelikhan
pelikhan merged commit 631b36d into main Oct 1, 2026
6 checks passed
@pelikhan
pelikhan deleted the copilot/add-built-in-ledger-types branch October 1, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants