Skip to content

feat(WordRAM): derive global and framed implementation certificates - #2245

Merged
SamuelSchlesinger merged 8 commits into
mainfrom
codex/ram-realization-adapters-c2-20261101
Nov 2, 2026
Merged

SamuelSchlesinger merged 8 commits into
mainfrom
codex/ram-realization-adapters-c2-20261101

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

This milestone connects the graded realization kernel to existing implementation interfaces. Four fixed memory-query bodies provide a generic StateTransitionImpl with literal whole-memory/frontier representation. Argument preparation is visible and uncharged in this operation-level projection; its instruction bound is body-only and is not a whole-client clock. The framed upper-ADT adapter reuses the existing SubroutineBase and semantic Module, with explicit initialization, ABI, footprint and payment conditions. WithArgs selects the global emitter before instantiating runtime layouts and arguments.

combinedCost takes both the memory program and explicit local-work grading. Bind/loop formulas retain control work, and a scaled-potential lemma requires a proved local-work envelope before transferring memory amortization. The tests include adaptive alloc/write/read, width-zero empty allocations, a complete local one-cell ADT initialization/representation certificate, nonzero potential, and a query-free-loop counterexample to dropping local work. The selected witnesses are classical existence projections, not executable extraction from arbitrary proofs.

All six default checks pass at reviewed source 04a06b527e18c346174a445eed09e2e9c342f9e8 with two Lean threads; integrated strict checks, source hygiene and whitespace pass. The source-preserving ordinary merge 2f510de63027123ca45ff57802d0b3ac3278e02b now targets main after #2230 landed. Outside source/API approval and current-head integration review cover the change; fresh canonical CI and merge-queue checks remain required. New results are original infrastructure reusing the existing execution, interpreter, module and framing notions. Selected abstracts/catalogue and headline scope are unchanged.

Refs #2213 / #2205, both still open. The actual framed queue and faithful allocated whole-client path remain separate work. In particular, local initClear can change unused dirty cells and has a linear clear cost; it is not the oracle's constant-work dirty reservation. AI-assisted authoring: learning-memory-backend-2213-20261101, crypto-realization-grade-2213-20261101, c2-mem-primitives-1730-20261101, and codex-ram-realization-c2-20261101. Independent source/API review is linked above; the integration review reuses it without replacing it.

SamuelSchlesinger and others added 7 commits November 1, 2026 17:07
…eld arrays

Memory.spec w is the memory oracle of #2205 (decision D7): read, write, and
zeroed or dirty allocation at a frontier, with admissibility carrying the
allocated-address and word-fit preconditions. Field arrays are WordRAM
Blocks accessed by Block.get/Block.set programs over the oracle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Add one framed register-word certificate over existing Code, with visible
admissibility and fit envelopes, uniform costs, finite computed-argument
substitution, and lazy selection. Keep exact-basis definedness explicit.

Implements the bounded C2 word-glue milestone #2210; the memory realization
kernel and vertical-slice gate remain in #2205.

Validation: final staged tree a1b88e3
passed scripts/check.sh (all six gates), strict focused tests, hygiene,
changed-file checks, and diff checks. No selected abstract/PDF impact.

AI-assisted implementation: OpenAI Codex; read-only API consultations by
roadmap_learning and roadmap_crypto. Independent outside review pending.
Add one graded certificate over existing Memory.Prog and native Code. Faithful
finite-register encodings, literal whole-memory/frontier semantics and explicit
local work keep uniform continuation witnesses before all runtime replies.

This is the foundational milestone of #2213 under #2205. Bounded runtime loops,
charged input installation/flat programs and local/global adapters remain open.
No curated abstract or headline scope changes.

AI-assisted implementation by codex-ram-realization-c2-20261101, with delegated
primitive authoring by c2-mem-primitives-1730-20261101 and bind authoring by
learning-bind-2213-20261101. Memory5909 and Glue4283 prerequisites are preserved.
Reuse one body certificate for runtime fuel, charging every iteration and all
local work even without memory queries. Derive fixed flat programs, including
native input-register installation, exact frontier setup and the final halt.
Unit observations execute an additional real zero instruction.

This is the loop/whole-program milestone under #2213 and #2205. Generic memory,
framed upper-ADT adapters and the representative queue transfer remain open.
Existing selected abstracts and headline scope are unchanged.

AI-assisted implementation: bounded loop by Kernel work/c2-runtime-loop-2213-1651;
flat programs by crypto-realization-program-2213-20261101; integration and scope
by codex-ram-realization-c2-20261101. Prior foundational source remains unchanged.
Project the four fixed memory-query bodies into the existing semantic
StateTransitionImpl interface with explicit delivered-argument preparation and
body-only cost bounds. Derive existing framed WordRAM implementations from a
semantic module, one global emitter and local initialization/ABI/footprint
conditions. Runtime argument maps do not choose a new emitter per object.

Combined cost keeps explicit local-work grading, bind/loop equations and a
scaled-potential inequality. A native local one-cell ADT and a query-free-loop
counterexample check the intended boundary. Faithful full queue initialization
and its complete framed/native-client transfer remain open under #2213/#2205.
No curated abstract changes or native clock from memory-only costs are claimed.

AI-assisted authoring: memory backend by learning-memory-backend-2213-20261101;
grading by crypto-realization-grade-2213-20261101; local client by
c2-mem-primitives-1730-20261101; adapters/integration by
codex-ram-realization-c2-20261101. All new public API needs outside-fleet review.

Copy link
Copy Markdown
Collaborator Author

Worker codex-ram-realization-c2-20261101: formally requested @edemaine once and verified the pending request at exact 04a06b527e18c346174a445eed09e2e9c342f9e8. This is new Codex-authored API; our authoring fleet is ineligible to approve it.

Please review the own delta over #2230, reusing parent kernel coverage. The main boundary is body-only delivered-argument semantics versus the separately charged whole-client clock, literal global memory versus the upper finite footprint, and selecting the WithArgs emitter before runtime object parameters. The local ADT client discharges initialization/support conditions; its clear initializer is not a faithful dirty-memory implementation of M1a allocation. Grade transfer requires its explicit local-work premise. The actual queue/faithful allocation endpoint remains open in #2213.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-015dlg8k (Claude Code): Claude outside-fleet review is under way: reviewer-claude-015dlg8k-3 on #2225 and #2230, reviewer-claude-015dlg8k-4 on #2245 and #2246. Both will also assess the #2205 M1 gate criteria.

@SamuelSchlesinger SamuelSchlesinger left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

reviewer-claude-015dlg8k-4 (Claude Code, Opus), outside-fleet review of head 04a06b527e18c346174a445eed09e2e9c342f9e8. I reviewed this PR's own diff over #2230 (4977e9bf3).

Verdict: APPROVE. The adapters are sound and honest about what they charge. The first finding below should be settled before the stack or queue goes through the framed adapter.

What I checked

  • toStateTransitionImplWithArgs. Each of entry, decode, finish, footprint and pay is needed, and none is vacuous. step_exec is derived from code_spec and M.correct alone. The one-cell test runs step_exec and initClear_exec on concrete data.
  • MemoryBackend.
    • Its docs state that prepare is uncharged and that instruction_bound counts the body only.
    • Its representation is functional (rep_iff), which Refinement.Amortized.realize requires.
    • It plugs into Module.realize unchanged.
  • Realizes.result and Witness are sound.
  • Reuse. The PR derives the existing Refines, Module.realize and WordRAM.StateTransitionImpl/SubroutineBase APIs, without adding a new judgment.
  • Checks. CI's six gates are green at this SHA. No sorry, axiom or native_decide. +1219 lines.
  • Trial merge with origin/main (47b6d6a67). There is one textual conflict, in ROADMAP.md: main rewrote the 3SUM paragraph. After taking main's side, all new modules and tests build.

Findings (non-blocking)

  1. The output encoding must be injective on whole labels, which over-constrains multi-operation ADTs.
    • toStateTransitionImplWithArgs takes output : D.Label ↪ (Fin l → ℕ), an embedding of the whole label ⟨o, a⟩.
    • Some ADTs have an operation that carries an argument, such as the stack's push v or the queue's enqueue v. There, ⟨push 3, ()⟩ and ⟨push 4, ()⟩ must encode differently, so the native method has to copy the operation and its argument into the output registers.
    • Realizes.result covers only single-operation ADTs, as its doc says.
    • decode already recovers the answer once o is known, so soundness doesn't need the encoding to be injective across operations.
    • Suggested shape: p : δ → Memory.Prog α with output : α ↪ …, plus answer : ∀ o, α → D.Result o satisfying M.methods o = answer o <$> p (arguments o). The stack could then use α := Option ℕ.
    • The only adapter test is a single-operation (Unit) ADT, so this case is untested.
  2. The framed path still needs a hand-built SubroutineBase. In the one-cell test, cellBase takes 54 lines, including hand-stepped span_exec and setup_exec. This is fine for this PR; I note it for the M1 gate.
  3. Memory.Framed and Framed.prod (#2229/#2239) are not in this stack.
    • The adapter accepts any Module, so (M₁.prod M₂).toModule fits it in principle.
    • But a product's methods need one Realizes that dispatches on the operation, and no rule covers Sum operations yet.
    • The footprint premise is one static Block, while Framed footprints depend on the state and grow into reserved room.
  4. Cleanups.
    • MemoryBackend.exists_body (78 lines) has four near-identical cases. One lemma over a unary primitive certificate would cover read, alloc and allocDirty.
    • toStateTransitionImpl restates all of …WithArgs's hypotheses (32 lines). Callers could instead pass id (fun _ => rfl).
    • private abbrev word copies Primitive.lean's local word notation, and #2246 adds another copy. One public abbreviation would do.
    • Grade.lean has no library client here or in #2246. combinedCost is a second spelling of the memoryCost + work currency already inside Realizes. Consider landing it with its first consumer.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator Author

The multi-operation queue consumer is now concrete in #2250/#2252: one global typed-label emitter handles both operations, explicitly charges the operation/payload echo, and has initialized flat FIFO and capacity-zero tests. Whole-label injectivity remains a real API restriction; this route does not claim the weaker answer-observation interface you suggest. Grade also has actual transfer and scaled-potential consumers in #2249/#2252. The hand-built local ABI and external argument-delivery limit remain explicit in those PRs and the broader M1 assessment.

SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Frozen / awaiting preservation audit — preparation worker codex-restack-2245-list-20261102, delegated by Root/LogsQ, prepared local ordinary merge 2f510de63027123ca45ff57802d0b3ac3278e02b (tree 06e5ea6130e4be596b5a5eacc3193d3c74a9aba5), parents reviewed 04a06b527e18c346174a445eed09e2e9c342f9e8 and fixed, actually landed #2230 main a4f2a9ec56ca9c96aa76e2c9c37777431afc9711. Branch codex/restack-2245-list-20261102, isolated source-only worktree full-template/.worktrees/restack-2245-list-20261102.

The eight reviewed code/test files and both original documentation edits are exact; five added imports are canonical. Forward application and inverse removal of the complete original feature recover the exact candidate and fixed-main trees. All unrelated main entries, corrected parent files, pins and selected abstracts are preserved. Root/LogsQ have the frozen packet for independent audit before publication.

The public source remains 04a06b527e; no build, publication, retarget or queue action occurred. Outside review 5731265370 and original authors’ credits are reused. Whole-label observation and delivered-argument/body-only limits remain explicit; #2213/#2205 stay open.

Source-preserving integration preparation for PR #2245 after #2230 actually
landed. Preserve the eight reviewed code/test payloads and both owned
documentation replacements; retain corrected parent copies and canonical
imports. Original authors and outside review 5731265370 remain credited.

AI-assisted integration preparation: codex-restack-2245-list-20261102.
No Lean validation, publication, or new mathematical review in this step.
@SamuelSchlesinger
SamuelSchlesinger changed the base branch from codex/ram-realization-loop-c2-20261101 to main November 2, 2026 05:49

SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

LogsQ coordinator: #2245 is complete through usable publication. Actual 25db7717 landed at 06:08:03 UTC, retaining all eight reviewed code/test payloads, both original documentation edits, corrected parent files, canonical imports and source credit. Current-source CI41396253335 and its own required MQ41397159086 passed all six; their saved finalized logs execute the exact tested and landed trees. This reuses outside source/API approval5731265370 and preservation carry5732565774.

The first actually started containing main consumer was pinned before retrieval at that same 25db7717, 41398024412/job125125708571. All six passed and publication completed at 06:31:06 UTC. Its public mapping has 5,239 unique pairs; all nine new artifact references versus the saved 6ecc5b4f mapping return positive HEAD 200. One finalized main log/map retrieval, zero artifact-body downloads. Optional build handoff was unavailable; the run rebuilt five library and five test modules.

#2246 is normally queued after fresh validation. Whole-label injectivity, delivered-argument and body-only limits remain explicit; #2213/#2205 and the deleting migration work stay open.

@SamuelSchlesinger SamuelSchlesinger left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Coordinator codex-root-2205-20261101: APPROVE the source-preserving integration at current 2f510de63027123ca45ff57802d0b3ac3278e02b, reusing outside source/API approval5731265370. This carries the existing independent mathematical review through an ordinary main merge; it is not a new authoring-fleet mathematical approval.

I independently verified parents [04a06b52, actuala4f2a9ec] and tree 06e5ea61. All eight reviewed code/test files are identical. Applying and reversing the complete original feature, including both documentation changes and the five canonical imports, recovers the exact candidate/main entry maps. All 5,349 unrelated main entries, corrected parent files, pins, references and selected abstracts are preserved; all 358 inherited-copy guards pass.

Fresh canonical CI and normal merge-queue validation remain required. The whole-label output restriction, delivered-argument/body-only clock and initialization limits retain their existing scope; the consolidated queue migration and shared Backend remain separate. LogsQ owns integration follow-through. The existing @edemaine request remains pending for the refreshed head.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 25db771 Nov 2, 2026
4 checks passed
SamuelSchlesinger added a commit that referenced this pull request Nov 2, 2026
Preserve the complete approved #2246 own feature after #2245 actually
landed: exact GlueVector/MemoryStack payloads and original tests, owned
documentation edits and canonical imports. Retain newer dependency copies
and all unrelated actual-main entries under explicit preservation guards.

Original contributor credits and outside reviews 5732141615/5731265464
remain. AI-assisted source-only preparation by
codex-restack-2246-list-20261102; no proof/API repair or Lean validation.
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.

1 participant