Skip to content

feat: add cross-run accumulation ledger#1

Open
dopexthrone wants to merge 1 commit into
ada/bootstrapfrom
claude/add-accumulation-ledger-6CXYW
Open

feat: add cross-run accumulation ledger#1
dopexthrone wants to merge 1 commit into
ada/bootstrapfrom
claude/add-accumulation-ledger-6CXYW

Conversation

@dopexthrone
Copy link
Copy Markdown
Collaborator

Summary

  • Closes Ada's open self-referential loop: the compiler now reads AND writes its own compile state across runs
  • Governor Write Hook: on ACCEPT, writes a CompileRecord to the accumulation ledger with intent hash, gate deltas, per-stage entropy readings, and blueprint postcode (PostcodeAddress: ML.ACC.{hash}/v1)
  • Intent Read Hook: on next compile, reads recent ledger entries and injects them as auxiliary context into the Intent stage, surfacing prior bottlenecks and high-entropy stages

No new agents. No new pipeline stages. Two hooks, one new artifact type.

Files changed

Package File Change
@ada/provenance postcode.ts Add ACC stage code
@ada/compiler types.ts Add CompileRecord, GateDelta, AccumulationContext types
@ada/compiler engine.ts accumulationContext option + buildCompileRecord() / buildAccumulationContext() static methods
@ada/compiler index.ts Export new types
@ada/storage index.ts compile_ledger table + recordCompile() / getRecentCompileRecords() / getRecordsByIntentHash()
@ada/cli init.ts Read ledger before compile, write ledger after ACCEPT
@ada/cli compile.ts Same read/write hooks for standalone compile command

What this closes

  • The self-referential loop is now fully closed — Ada reads AND writes its own state
  • PostcodeAddress on ML.ACC.{hash}/v{n} — provenance system already handles this
  • The SSOT remains hand-managed (frozen, authoritative) — the ledger is a separate, live artifact

What this does NOT do (deferred)

  • Governor criteria evolution — still fixed. The ledger enables evidence accumulation but does not change the gate
  • Domain transfer weighting — the ledger captures domain-agnostic patterns, but routing based on them is a future epoch

Test plan

  • Build all modified packages: pnpm --filter @ada/provenance --filter @ada/storage --filter @ada/compiler build
  • Verify compile_ledger table is created on first AdaStorage instantiation
  • Run ada init "test" → confirm CompileRecord written to ledger on ACCEPT
  • Run ada init "test" again → confirm accumulation context injected into intent
  • Verify ledger entries carry valid ML.ACC.{hash}/v1 postcodes

https://claude.ai/code/session_012aDqyuDBYMws5ZF2DuHeKs

… hooks)

Closes the open self-referential loop: Ada now reads AND writes its own
compile state across runs. On Governor ACCEPT, a CompileRecord is written
to the accumulation ledger with intent hash, gate deltas, entropy readings,
and blueprint postcode. On the next compile, the Intent stage reads recent
ledger entries as auxiliary context, surfacing prior bottlenecks and
high-entropy stages.

Implementation:
- ACC stage code in provenance postcode system
- CompileRecord, GateDelta, AccumulationContext types in compiler
- compile_ledger table + recordCompile/getRecentCompileRecords in AdaStorage
- MotherCompiler.buildCompileRecord (Governor Write Hook)
- MotherCompiler.buildAccumulationContext (Intent Read Hook)
- Both ada init and ada compile wired to read/write the ledger

No new agents. No new pipeline stages. Two hooks, one artifact type.

https://claude.ai/code/session_012aDqyuDBYMws5ZF2DuHeKs
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying motherlabs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1cb7805
Status: ✅  Deploy successful!
Preview URL: https://c80c0cb5.motherlabs.pages.dev
Branch Preview URL: https://claude-add-accumulation-ledg.motherlabs.pages.dev

View logs

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1cb78051e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +42 to +46
// ─── Governor Write Hook: write CompileRecord to accumulation ledger ─────
try {
const storage = new AdaStorage();
const compileRecord = MotherCompiler.buildCompileRecord(result, runId);
storage.recordCompile({
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Write compile ledger entries only after ACCEPT

This hook persists a CompileRecord unconditionally before the command checks gov.decision, so REJECT/ITERATE runs (including --strict failures) still enter the accumulation ledger and are then fed back into later intent context. That contradicts the accept-only contract used elsewhere (e.g., init path) and can pollute cross-run memory with runs that were explicitly rejected by governance.

Useful? React with 👍 / 👎.

Comment on lines +274 to +276
`INSERT OR REPLACE INTO compile_ledger
(run_id, project_path, intent_hash, blueprint_postcode, gate_deltas, entropy_readings, timestamp, decision, postcode_raw)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid replacing ledger rows by non-unique run IDs

Using INSERT OR REPLACE on compile_ledger keyed by run_id can silently overwrite prior records when two compiles share the same generated run ID (callers use second-level timestamps like ML-${Math.floor(Date.now()/1000)}). That loses historical accumulation data and skews the context read hook toward fewer/incorrect prior runs.

Useful? React with 👍 / 👎.

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.

2 participants