Repository navigation
[codex] r3 gate 50 one-shot memoization witness #2547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+73
−11
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,13 @@ const R3_PARALLEL_EMIT_WITNESS_LENS_NAME: &str = "r3_auto_parallelism_parallel_e | |
| const R3_BRANCH_ARMS_SERIALIZE_WITNESS_LENS_NAME: &str = | ||
| "r3_auto_parallelism_branch_arms_serialize_witness"; | ||
|
|
||
| /// R3 gate #50 (`LensOutputEquals` witness in `r3_free_consequences_first_batch.dag`). | ||
| /// | ||
| /// A one-shot pure call may emit a direct call / inlined expression, but must not introduce | ||
| /// memoization scaffolding. Repeated-call caching remains deferred to the purity+cost lens | ||
| /// composition producer. | ||
| const R3_ONE_SHOT_NO_MEMO_WITNESS_LENS_NAME: &str = "r3_auto_memoization_one_shot_no_cache_witness"; | ||
|
|
||
| /// Host-written forward fold for structural depth costs (see `src/v3/lenses/complexity.dag`). | ||
| /// | ||
| /// T-LaneE `DifferentialEquals` compares this receipt to [`crate::lens_cost::cost_of`] (emit output | ||
|
|
@@ -2387,6 +2394,50 @@ impl<'a> TestRunner<'a> { | |
| }; | ||
| } | ||
|
|
||
| // R3 gate #50 (`auto_memoization_no_caching_for_one_shot`): one-shot call sites must not | ||
| // emit memo/cache scaffolding. Structural witness via emitted Rust text; dissolution when | ||
| // the AutoMemoizationEvidence producer reaches `.dag`. | ||
| if lens_decl.name.as_deref() == Some(R3_ONE_SHOT_NO_MEMO_WITNESS_LENS_NAME) { | ||
| let expected_int = match expected_decl.value_body.as_ref() { | ||
| Some(ValueBody::Scalar(LiteralBits::Int(s))) => match s.parse::<i64>() { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BLOCKING: LiteralBits::Int is already the typed i64 carrier, so calling parse::() on it will not compile; this violates INVARIANTS.md P2 typed-boundary discipline. |
||
| Ok(v) => v, | ||
| Err(_) => { | ||
| return ClaimResult::Fail(format!( | ||
| "LensOutputEquals(r3_auto_memoization_one_shot_no_cache_witness): expected Int literal is not a valid i64 decimal for `{expected_name}`" | ||
| )); | ||
| } | ||
| }, | ||
| _ => { | ||
| return ClaimResult::Fail(format!( | ||
| "LensOutputEquals(r3_auto_memoization_one_shot_no_cache_witness): expected_ref `{expected_name}` must be `data ...: Int = <literal>`" | ||
| )); | ||
| } | ||
| }; | ||
| let emitted = match crate::emit_rust::emit_rust(&program_dag) { | ||
| Ok(s) => s, | ||
| Err(err) => { | ||
| return ClaimResult::Fail(format!( | ||
| "LensOutputEquals(r3_auto_memoization_one_shot_no_cache_witness): emit_rust failed for `{}`: {err:?}", | ||
| claim.file_name | ||
| )); | ||
| } | ||
| }; | ||
| let scaffolding_absent = !emitted.contains("memo") | ||
| && !emitted.contains("Memo") | ||
| && !emitted.contains("cache") | ||
| && !emitted.contains("Cache") | ||
| && !emitted.contains("HashMap"); | ||
| let computed_int = i64::from(scaffolding_absent); | ||
| return if computed_int == expected_int { | ||
| ClaimResult::Pass | ||
| } else { | ||
| ClaimResult::Fail(format!( | ||
| "LensOutputEquals(r3_auto_memoization_one_shot_no_cache_witness): expected `{expected_int}` (1 = no memo/cache scaffolding), computed `{computed_int}` for `{}`", | ||
| claim.file_name | ||
| )) | ||
| }; | ||
| } | ||
|
|
||
| // T-LaneE cost receipt: `ProgramOutputBind` is the structural contract for a claim | ||
| // source output-bind cost check. Dispatch on that input role, not on lens declaration | ||
| // spelling; otherwise the canonical lens-name bridge would survive under a helper. | ||
|
|
||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BLOCKING: The new src/v3 hand-Rust runner bridge has a dissolution note but no required P5 receipt: deleted scaffold path, SG-0 shrink, or deferral lane plus concrete ROADMAP row.