Skip to content

Add delimited continuation primitive with a complete local tape bill - #5364

Merged
Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
mihir-s-05:research/segment-continuation-stack
Oct 24, 2026
Merged

Mister-Meeseeks merged 2 commits into
CrocSwap:mainfrom
mihir-s-05:research/segment-continuation-stack

Conversation

@mihir-s-05

Copy link
Copy Markdown
Contributor

Change and mathematical scope

PR5329's local tape boundary uses a Python frame stack to recover origins, parent objects and descriptor lengths. This adds an isolated constructive primitive and written all-size proof: a delimited control tape restores sixteen parent payload heads, their bytes, the role mask and an opaque binary descriptor by sequential reads, writes and unit moves.

The changed encoding records each head-to-end distance in unary while parking that head. Nineteen fixed tapes and a nine-symbol alphabet suffice at every finite nesting depth. For descriptor length d, total return distance H and child payload-plus-descriptor length W, the complete matched boundary costs at most 24d + 12H + 576 + 8W tape actions, including child cleanup. The live frame is exactly d + H + 35 symbols. Sharper exact action formulas and the nesting induction are in PROOF.md.

This completes the stated primitive, not the full source caller. The retained-source calibration still uses Python logical sizes and weak-reference handle allocation. Recursive C, actual child-output delivery, production dispatch/recipe semantics, complete caller space/stock/precision and supplier admission remain open. No paid-profile or kappa improvement is claimed. Only eight files in research/segment-continuation-stack/ are added.

Task and overlap

  • Base: current canonical main 7c472563474e60185e6ca101a17622133d047e56, priority revision 7. The pre-submission fetch retained that head and unchanged guidance/inputs.
  • Task: uniform-transfer-audit, refined to the local continuation primitive requested by the released physical-local-continuation handoff. Canonical claim.
  • Scientific predecessor: PR5329, 08456995d5e520a4f9e0501c9b2ea9b03dbae87a, retained unchanged on main. PR5041 supplies the locality motivation. The central ledger marks both predecessors partially reviewed.
  • The existing fixed-bank recursive-row caller has a one-bit dyadic continuation grammar; the PR3385 parent-return audit covers dense parking. This package supplies a different concrete descriptor/head contract and complete local bill, not a claim to invent stacks.
  • Submission overlap: 310 open PR bodies and 4,641 Discussion records with complete reported pagination at 19:20/19:21 UTC. Sparse local-note omissions are disclosed. A supplementary Git-tree search of all top-level package READMEs checked physical/continuation-stack and unary-distance terms. Arbitrary diffs and unpublished work are outside coverage.

Validation

CPython 3.12.0, 64-bit Windows 11; standard library only.

python3.12 -B scripts/research_package.py --package research/segment-continuation-stack --check-only
python3.12 -B scripts/research_package.py --package research/segment-continuation-stack
python3.12 -B scripts/check_research_commit.py --package research/segment-continuation-stack

All pass locally. Evidence:

  • 1,935 complete small single-role payload/head/descriptor cases and 20 empty-mask cases; every measured boundary matches the independently written exact action formula.
  • Seven nested unequal frames at ancestor lengths 16, 257 and 4096, with identical local action counts and complete state restoration.
  • Six unchanged compact.execute calibrations on complete reduced 128-record rectangles, both field orders, two nested levels and all sixteen enclosing roles. Each inner boundary costs exactly 16,672 actions, including cleanup, at every ancestor length.
  • The exact retained event8814/family65689 BOUNDARY and RIGHT-RECIPE bytes round-trip as a long opaque descriptor; this is byte preservation, not production recipe execution.
  • Nine rejecting controls: malformed top/row/descriptor delimiters, excess return distance, absent nonempty role, nonbinary descriptor, omitted head return, wrong descriptor data and unpaid moves.
  • Official 18-file export/integrity checks pass. Normal and optimized Git-free replay with empty PATH reproduce RESULT.json and preserve all exported bytes (6.30/6.22 s). A corrupted exported source is rejected before predecessor execution. The repository's frozen inputs were never edited.
  • Scientific code/receipt at a032168509338cbe5b5213acbdef81719e33b0a9; final head fd74da128f0e5ab702a8fe7b2b00e1a316bb22ad only adds validation prose and clarifies a fixture sentence. Final committed-byte and export checks pass.

The all-size claim rests on the written proof; these finite checks corroborate it. No selected cold replay, full selected-source closure, Lean/Docker build, independent human review or formal-kernel acceptance is claimed. Full source-history preflight was unavailable in the shallow checkout. Hosted CI is separate from these local results.

Credit

JoyboyBrian: PR5329 segment refinement and handoff, PR5041 locality invoice and fixed-bank recursive-row precedent. Jose Manuel/jmbarrancoml: PR2250 sequential compact/monomial source. Douglas Colkitt: compact identity, guard and repair construction. Cinna Davis: #4100/#4088 framework. Matarener: cover/stock work. Sagar Thakrar: PR3385 parent-return audit. The fixed-bank precedent credits commdata2338 and retained Lean push/pop authors. Full source notices and the carry/guard/native lineage remain pinned and unchanged.

Prepared by Mihir Srivastava (mihir-s-05) with substantial OpenAI Codex assistance. Apache-2.0. Author-checked evidence awaiting independent review.

Open next questions

Bind one repair/stable_radix maximum-live cut and nested call to explicit source counter/slot operations, replacing the calibration facade. Separately, name and price one actual child-output transfer before destructive pop. Those are prerequisites for composing the complete production caller invoice; the primitive alone does not justify another construction search. README.md and TASK.json give concrete first steps and blockers.

Prove and replay sequential restoration of sixteen payload heads, role occupancy and an opaque descriptor with a complete linear tape-action invoice. Preserve the PR5329 source and keep logical handle compilation, recursive C and child-output delivery explicit.

Prepared with substantial OpenAI Codex assistance; predecessor attribution is retained in the package.
@jwr404

jwr404 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Independent review (James Reed, with Claude Code). Head fd74da128f0e5ab702a8fe7b2b00e1a316bb22ad.

Verdict: the primitive restores exactly, and the exact action formulas hold, under an independent randomized nested harness. There is a duplicate-work note for maintainers at the end.

Proof check

  • Frame grammar. [ desc : b₀ u^H₀ ; … ; ] has length d + H + 35, and the delimiters are disjoint from the binary alphabet. Unary H_i with the empty run for zero avoids any ambiguous zero-width header.
  • Pop invariants. pop reverses each role's parking walk exactly (s_i − H_i = h_i), and the double reversal through reverse recovers the descriptor, including empty and non-palindromic ones. Nesting follows by induction on the call tree. ✓
  • Invoice arithmetic.
    • Exact total: push + pop = 22d + 10H + 18k + 29 + Σ(2g_i + 5t_i + 7) + 2g_D + 5e + 7.
    • With 2g + 5t ≤ 7t, this is at most 22d + 10H + 25k + 36 + 7W, and with k = 16 at most 24d + 12H + 576 + 8W, matching the README. ✓

Independent harness

I imported only Tape, Meter, Controller and action_bound from this PR's stack.py; the driver and expectations are my own. Over 400 random top-level scenarios:

  • States. Random 16-bit presence masks, arbitrary ancestor prefixes, parent words of length 0–6 with random heads (including h = s and empty present roles), and descriptors of length 0–6.
  • Child work. Each child writes random words on present roles and the descriptor, then parks heads at random offsets. With probability 0.6 it makes a properly nested inner push/pop, up to depth 4.
  • Checks. Every frame at every depth must restore all 19 tape snapshots (cells and head) and the mask exactly. For each top-level pair, the measured push and pop actions must equal 8d + 5H + 9k + 13 and 14d + 5H + 9k + 16 + Σ(2g_i + 5t_i + 7) + (2g_D + 5e + 7) exactly, and lie within action_bound.

Result: 1,286 checks, 0 failures. The contract that absent child roles be empty is enforced by push (my first harness draft violated it and was correctly rejected).

The registered replay passes locally (outcome=completed).

Overlap note for maintainers

#5356 (aliromman, "Implement a local continuation stack with exact linear cost", opened six minutes earlier) addresses the same PR5329 saved-frame-oracle question. It uses a delimited control tape restoring the sixteen payload heads, presence bits and descriptors, in an eighteen-tape, seven-symbol construction. This PR uses nineteen tapes and nine symbols, with unary parked distances. The two look like independent solutions to one handoff. A maintainer may want to pick one as canonical, or keep both with a cross-reference comparing constants and tape counts.

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.

3 participants