Repository navigation
feat(WordRAM): realize memory queue transfer and dispatch - #2249
SamuelSchlesinger wants to merge 4 commits into
Conversation
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.
…m-memory-queue-transfer-c2-20261101
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.
…m-memory-queue-transfer-c2-20261101
|
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 |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
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_iterateis an exact equation between #2218's linkedQueue.transferand an active-flag boundediterate, early stop included.realizes_source_transfercertifies that source program uniformly, with local work40 n + 1in the fueln.transfer_invariantdischarges every iteration's domain from the two stack invariants, with memory cost exactly6 n.realizes_dequeuecertifies the actualmemMethods … .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
- Positional projections in public statements and definition bodies (#1764, CONTRIBUTING). The offenders are
transferBody(d.1.2,d.1.1),transferSafe, and the statements ofrealizes_transfer,realizes_source_transferandMemoryQueueDispatch.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. - A private lemma that #2271 copies. #2271's private
wellFormed_clientrestatesclient_wellFormedverbatim. Make the lemma public once, e.g. asMemory.WellFormed.clientStatebesideclientState_widthinRealization/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,pairRefinementandframe; Queue.Memory.memMethodsnow usesMethods.prod;memRefinementnow 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-casefin_casesstaging proof.realize(#2260 with #2280) would generate all of this. As it stands, though, itsiterate₀rejects this body, because the inactive branch issues no query.- #2270's
boundedWhilefits if the loop state is the remaining count rather than an active flag. The guard is0 < r. The body pops; onsome vit pushes and returnsr - 1, and onnoneit returns0. - That loop equals
link (transfer n)by the same induction, with measurer. Every executed iteration begins with a query, so no inactive tail is charged andmono_mulabsorbs the local work. - What is missing is a
while₀rule and one case inrealize. (This PR predates #2260 and #2270.)
realizes_enqueuerepeats a #2260 test. #2260's queue-enqueue example is the same client with the same domain, and itsqueueWords/enqueueWordsrepeatlayoutWords/enqueueWordshere.- Estimate: with
realizeand a while rule, the 807 library lines here become about 130–180.- The realization plumbing, about 430 lines, becomes one
realizecall 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_amortizedalready bounds the memory cost. - What remains is the domain discharge, as
whileSafe_of_measure's per-step obligation, about 100 lines.
- The realization plumbing, about 430 lines, becomes one
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_bindfrom #2271.
- In the migration PR:
If that is the path, make items 1–2 there rather than on this branch.
|
Coordinator 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. |
The actual M1a queue transfer and enqueue/dequeue methods now have uniform native
Realizescertificates. 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 charge6*nand certified local work40*n+1; dequeue pays its actual comparison, argument staging and path-dependent work (28directly or40*n+69after 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 payload1, 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 sourcee4eebc1c(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 bymathlib_cache_retry_1730, and dispatch/tests byroadmap_learning. Existing M1a source credit is preserved. Independent correctness/API review outside the authoring fleet is requested; this text is not an approval.