Add mtlrun --input constructed-stack decoder to close the negative-integer input gap#93
Merged
Conversation
Before: the mtlrun TEXT harness supplied inputs only by prepending unsigned literals to the program string, run against an empty stack. Because the frozen Option-A lexer (spec §2.3) lexes `-` as the Sub primitive, a negative scalar (`-24`) or a list with negative elements (`[-5 -2 ...]`) faulted before the solution ran. This blocked 7 sealed tasks that have committed, algorithmically- correct solutions (they only ran under the Rust-only constructed-stack path). After: add a harness-level signed input decoder `parse_input_stack` in bench/validate and wire an `--input <spec>` / `--input=<spec>` flag into mtlrun. The spec accepts signed scalars, signed lists, and whitespace-separated top-level items (bottom..top), constructing the initial stack directly — flat lists decode byte-identically to the `int_list` helper used by tests/sealed.rs. The program text is still parsed by the frozen unsigned lexer; only the input value flows through the new decoder. No `--input` => identical old empty-stack behavior. The lexer, primitives, glyphs, interpreter semantics, and all frozen sealed artifacts/manifests are unchanged. All 7 encoding-blocked sealed tasks now execute end-to-end through the fixed text path and pass every vector (positive and negative). The 8th blocked task seal_running_max is a genuine algorithmic bug (seed = 0) with no committed solution and is NOT resolved by this encoding fix; that remains the isolated gap. Demonstration recorded in bench/POSTFIX-NEGINT-INPUT.md; bench/BASELINE-SEALED.md remains the frozen baseline. Docs: mtl-quickref.md documents the `0 N -` in-program idiom and the --input convention; mtl-quickref-min.md gets one terse wrapper line (frozen primitive block left byte-identical). Tests: 11 new decoder unit tests. cargo test --workspace 321 passed / 0 failed (baseline 310 + 11); contamination gates still pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ANTmGML7M6khvHFtiASeGG
madmax983
marked this pull request as ready for review
July 15, 2026 19:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: the text harness (
mtlrun) could only seed inputs by prepending unsigned literals to the program, run against an empty stack. A negative input like-24lexed asSub 24and faultedUnderflowbefore the solution ran; a negative list element like[-5 -2]lexed to a quote whose head isSuband faultedTypeMismatch. This blocked 8 of 15 sealed tasks in the text harness (PR #91 post-mortem,bench/BASELINE-SEALED.md§7-i,bench/sealed/GAPS.md).After:
mtlrun --input '<spec>'decodes a signed input spec into a constructed initial stack, then runs the (unchanged, unsigned-lexed) program text against it.mtlrun --input '-24' <prog>→HALT: 8;mtlrun --input '0 [-5 -5 20 -100]' <prog>→HALT: -90. Inputs are data, not program text — only the input decoder accepts signs; the frozen lexer is untouched. Absent--input, behavior is byte-identical to before.How: new
parse_input_stack(&str) -> Result<Vec<Value>, String>inbench/validate/src/lib.rs(whitespace-separated top-level items pushed bottom→top; each item a signed scalar or a bracketed, nestable list; flat int lists buildValue::Quote([PushInt..])byte-identical to theint_listtest helper, so the text path and the Rust constructed-stack path agree by construction).bench/validate/src/bin/mtlrun.rsgains--input/--input=wiring over the existingrun_programseed path;--engineunchanged. Docs:docs/mtl-quickref.mddocuments0 N -for in-program negative constants and--inputfor negative/list inputs;docs/mtl-quickref-min.mdgets one line in its non-frozen wrapper (frozen primitive block byte-identical). Demonstration in the newbench/POSTFIX-NEGINT-INPUT.md(the frozenBASELINE-SEALED.mdis untouched).Scope guardrails: no change to the lexer, primitives, glyphs, interpreter semantics, spec §2.3, or the frozen sealed corpus/manifest — verified by
cargo test -p mtl-dataset(manifest_matches_sealed_tasks,sealed_disjoint_from_devpass).Verification:
bench/POSTFIX-NEGINT-INPUT.md.seal_running_max, is NOT resolved and not fudged: it has no committed solution because its authored candidate is algorithmically wrong (seeds the running max at 0). That is an algorithm bug independent of input encoding and remains the single genuine gap, still pinned bytests/sealed.rs::running_max_candidate_is_algorithmically_wrong.cargo test --workspace: 321 passed / 0 failed (baseline 310 + 11 new decoder unit tests).Closes #92.
Generated by Claude Code