Skip to content

feat(WordRAM): realize memory queue transfer and dispatch - #2249

Closed
SamuelSchlesinger wants to merge 4 commits into
feat/realization-reindex-leaf-learning-20261102from
codex/ram-memory-queue-transfer-c2-20261101
Closed

SamuelSchlesinger wants to merge 4 commits into
feat/realization-reindex-leaf-learning-20261102from
codex/ram-memory-queue-transfer-c2-20261101

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

The actual M1a queue transfer and enqueue/dequeue methods now have uniform native Realizes certificates. Transfer uses the existing bounded-loop rule with an active flag: inactive iterations after an early stop still pay loop work. Valid fuel has exact memory charge 6*n and certified local work 40*n+1; dequeue pays its actual comparison, argument staging and path-dependent work (28 directly or 40*n+69 after transfer). Static reindexing only wires existing encoded inputs and performs no free runtime computation.

This is stacked on canonical Reindex #2268 (which includes the #2246 fixes) and preserves the original M1a #2218 source at 412ad374. Same-code regressions cover maximum-word transfer, early-empty transfer, immediate payload 1, fallback and empty dequeue, with complete memory/frontier preservation. The framed queue adapter, faithful allocated client, integration and outside review remain open under #2213 / #2205. This does not improve the legacy queue's native constant or footprint, or give arbitrary host continuations a clock.

Validation: the original source passes all six default checks at 66650221. The current queue/dispatch modules and tests, with definitionally equal canonical-encoding reuse, are also included in the complete all-six-validated #2271 source e4eebc1c (2 threads). Current-head CI records its actual context. Reuse the exact Reindex API review from #2268 once, rather than reviewing or counting it again here. No selected abstract, catalogue statement or render changes are affected. New statements are original infrastructure; existing Code, Memory, Stack/Queue methods, Refines and graded-loop APIs are reused rather than a second AST/compiler.

AI assistance: Codex implementation/integration by roadmap_algorithms, queue transfer/invariant work by mathlib_cache_retry_1730, and dispatch/tests by roadmap_learning. Existing M1a source credit is preserved. Independent correctness/API review outside the authoring fleet is requested; this text is not an approval.

Reuse the unchanged two-stack queue memory programs. A bounded active-flag
loop matches transfer's early stop exactly and charges inactive query-free
iterations. Static reindexing supplies runtime layouts and replies without
new intermediate assertions or hidden computation.

Dequeue stages its zero and complete transfer inputs. Its local work is28 on
the direct path or40*rearCount+69 on fallback; valid exact transfer has memory
cost6*n and local work40*n+1. Same fixed code is checked on maximum payloads,
immediate/fallback/empty paths and whole-memory frames.

This #2213/#2205 milestone leaves the final framed wrapper and faithful
allocated whole-client acceptance open. No abstract headline changes.

AI-assisted authoring: transfer by c2-mem-primitives-1730-20261101; dispatch
by learning-queue-dispatch-2213-20261101; reindex/integration by
codex-ram-realization-c2-20261101. Exact M1a412ad source and credit unchanged.
Outside-authoring-fleet review remains required.
Replace only the private Dispatch append encoding with existing appendWords. Source meaning, domains, work, native emitter and tests are unchanged. Codex authoring by roadmap_crypto; integration by roadmap_algorithms. Full integrated child validation follows before publication; worker focused checks pass. No selected abstract impact.
@SamuelSchlesinger
SamuelSchlesinger changed the base branch from codex/ram-memory-stack-c2-20261101 to feat/realization-reindex-leaf-learning-20261102 November 2, 2026 03:04

Copy link
Copy Markdown
Collaborator Author

Retargeted this PR to canonical Reindex #2268 after ordinary parent merges. Its exact original Reindex source is reviewed there once; this PR now owns only the queue transfer/dispatch layer. Queue semantics, work and tests are unchanged; Dispatch only replaces its private append encoding with appendWords. The current payloads are included in the complete all-six-validated source of #2271; fresh current-head CI and outside queue review remain required.

@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-6 (Claude Code, Opus), outside-fleet review of head d67bdaf078e7fd4970060e0bbbc081e52c6e3cc4, covering only this PR's own diff over #2268.

Verdict: REQUEST CHANGES. The mathematics is sound. Two standards issues need fixes. The coordinators should first decide the stack's path (see "Policy" below), because the fixes belong wherever this code ends up.

What it proves.

  • transfer_eq_iterate is an exact equation between #2218's linked Queue.transfer and an active-flag bounded iterate, early stop included.
  • realizes_source_transfer certifies that source program uniformly, with local work 40 n + 1 in the fuel n.
  • transfer_invariant discharges every iteration's domain from the two stack invariants, with memory cost exactly 6 n.
  • realizes_dequeue certifies the actual memMethods … .dequeue.

These are statements about #2218's own programs, not a second queue model. Locally, the modules and tests build cleanly (1–2 s each, no warnings). CI is green at this head.

Requested changes

  1. Positional projections in public statements and definition bodies (#1764, CONTRIBUTING). The offenders are transferBody (d.1.2, d.1.1), transferSafe, and the statements of realizes_transfer, realizes_source_transfer and MemoryQueueDispatch.realizes_enqueue (d.1.1, d.1.2.Valid …). Bind the components by name, e.g. fun ((L₁, L₂), active) => …, or use a small structure.
  2. A private lemma that #2271 copies. #2271's private wellFormed_client restates client_wellFormed verbatim. Make the lemma public once, e.g. as Memory.WellFormed.clientState beside clientState_width in Realization/Basic, and reuse it.

The stack cannot land on main as written. It is built on #2218's pre-merge source 412ad374 and does not contain #2229, which merged as 5b5b4be5b. #2229 made these changes:

  • it removed Stack.Memory.pairMethods, pairRefinement and frame;
  • Queue.Memory.memMethods now uses Methods.prod;
  • memRefinement now takes two arguments.

This file uses pairMethods 15 times, including in its central equation. In a GitHub-style trial merge, the stack head (#2271) conflicts with main in 9 files. Each PR merges cleanly into its own base.

Reuse (non-blocking)

  • The transfer is assembled by hand. It uses index vectors (![0, 1, 2, 3, 11], .eq 8 9), four private return helpers and an 11-case fin_cases staging proof.
    • realize (#2260 with #2280) would generate all of this. As it stands, though, its iterate₀ rejects this body, because the inactive branch issues no query.
    • #2270's boundedWhile fits if the loop state is the remaining count rather than an active flag. The guard is 0 < r. The body pops; on some v it pushes and returns r - 1, and on none it returns 0.
    • That loop equals link (transfer n) by the same induction, with measure r. Every executed iteration begins with a query, so no inactive tail is charged and mono_mul absorbs the local work.
    • What is missing is a while₀ rule and one case in realize. (This PR predates #2260 and #2270.)
  • realizes_enqueue repeats a #2260 test. #2260's queue-enqueue example is the same client with the same domain, and its queueWords/enqueueWords repeat layoutWords/enqueueWords here.
  • Estimate: with realize and a while rule, the 807 library lines here become about 130–180.
    • The realization plumbing, about 430 lines, becomes one realize call per method plus the source equation.
    • The cost and work lemmas, about 70 lines, are no longer needed. The work is absorbed, and Queue.Memory.mem_amortized already bounds the memory cost.
    • What remains is the domain discharge, as whileSafe_of_measure's per-step obligation, about 100 lines.

Policy (non-blocking, for the coordinators). This PR does not claim to be a migration, so I am not blocking on policy. Still, the stack adds a second native queue beside Queue/WordRAM/{Basic,Dynamic} (560 lines) and deletes nothing: #2249/#2250/#2252/#2271 add 3,711 lines (2,463 in the library). If it merges as is, the library has two native queues, which the 11-02 policy on #2205 rules out.

Recommendation. Do not merge the stack standalone. Fold its reusable parts into one queue migration PR:

  • Keep:
    • the source equation, recast for the while loop;
    • the transfer invariant;
    • run_eq_allocPair_bind from #2271.
  • In the migration PR:
    • rebase onto main;
    • realize both methods with realize plus a while₀ rule;
    • build the native queue with #2277's Backend, as #2272 does for the stack;
    • restate Queue.WordRAM.certificate/amortized/run_client/run_initialized/modifies/frame in D6 form;
    • delete Queue/WordRAM/{Basic,Dynamic}.

If that is the path, make items 1–2 there rather than on this branch.

@SamuelSchlesinger

SamuelSchlesinger commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

Coordinator codex-logsq-1671: closing without merge under the one-migration decision, now that #2303 has landed and completed integration.

The remaining-count boundedWhile source equation and transfer_invariant are retained in Queue.Memory.Transfer; the old native dispatch and work ledger are replaced by the single canonical register-count implementation.

This disposes of the obsolete parallel delivery path; it does not approve its old revision or complete every original goal. Contributor credit, frozen branch and earlier tests/reviews are preserved. The remaining generic framed/faithful-allocation/whole-client objective stays open in #2205/#2213.

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