Repository navigation
psi: support target-dependent constant array extents - #6317
Merged
Merged
Conversation
Programs can now use a constant initialized from a target layout query, such as `const SIZE: u64 = size_of::<u64>()`, as a fixed-array length across signatures, indexing, `.length` queries, array literals, and `requires` clauses. Previously, the source compiler deferred evaluating such constants until target closure, but the array-extent reader refused any named constant without an already-evaluated integer value. When a fixed-array extent names a constant marked `pending_target_observation`, stage 05 now lowers that extent to `ArrayExtent::Application` using the constant's retained scalar evaluation and carries the application through `CollectionExtent::Application`. Indexing, `.length` reads, zero-initialized locals, and contract clauses treat the application extent as a symbolic `ScalarTerm::Application`, so the lowered-form checker enforces bounds like `i < SIZE` without weakening any check. Array literals targeting an application-sized array retain a pending `ScalarPredicateCondition` asserting that the literal count equals the closed target extent, which deployment closure verifies before handing the closed literal geometry to Psi and native code. The Psi interpreter also now preserves `scalar_geometry` when a module has scalar applications without authored `target_layouts`. Added focused positive and negative twin tests in `source-rust/application/tests/computed_array_extent.rs` covering pass-through, default initialization, `.length`, guarded indexing, array literals, unproved indexing, out-of-bounds access, and mismatched literal length on both Psi and native `windows_x86_64`, and removed the completed bullet from `TASKS.md`. Gate: RC-SOURCE-SEMANTICS | target-dependent layout constants work as fixed-array extents through checking, Psi, and native execution Spec: wiki/spec/language/evaluation.md#target-dependent-applications Proof: mbx test -p omega --test computed_array_extent (7 passed, native/Psi agreement on windows_x86_64), mbx test -p lowered-program-to-checked-program --lib array_lengths (31 passed), mbx test -p terminal-wire --lib obligation_evidence (23 passed), mbx xtask check-boundary, mbx xtask check-rules, mbx clippy --no-deps on touched crates | clean (pre-existing unrelated clippy lint in untouched terminal-interpreter/instructions/execution.rs and test compile error in untouched build_dependency_provider_layouts.rs) Agent: Antigravity | Model: unknown | Effort: high | Tokens: 20.25M in (19.72M cached), 66.3k out | Steps: 88 | Time: 42m24s | Steers: 0
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.
Programs can now use a constant initialized from a target layout query, such as
const SIZE: u64 = size_of::<u64>(), as a fixed-array length across signatures, indexing,.lengthqueries, array literals, andrequiresclauses. Previously, the source compiler deferred evaluating such constants until target closure, but the array-extent reader refused any named constant without an already-evaluated integer value.When a fixed-array extent names a constant marked
pending_target_observation, stage 05 now lowers that extent toArrayExtent::Applicationusing the constant's retained scalar evaluation and carries the application throughCollectionExtent::Application. Indexing,.lengthreads, zero-initialized locals, and contract clauses treat the application extent as a symbolicScalarTerm::Application, so the lowered-form checker enforces bounds likei < SIZEwithout weakening any check. Array literals targeting an application-sized array retain a pendingScalarPredicateConditionasserting that the literal count equals the closed target extent, which deployment closure verifies before handing the closed literal geometry to Psi and native code. The Psi interpreter also now preservesscalar_geometrywhen a module has scalar applications without authoredtarget_layouts.Added focused positive and negative twin tests in
source-rust/application/tests/computed_array_extent.rscovering pass-through, default initialization,.length, guarded indexing, array literals, unproved indexing, out-of-bounds access, and mismatched literal length on both Psi and nativewindows_x86_64, and removed the completed bullet fromTASKS.md.Gate: RC-SOURCE-SEMANTICS | target-dependent layout constants work as fixed-array extents through checking, Psi, and native execution
Spec: wiki/spec/language/evaluation.md#target-dependent-applications
Proof: mbx test -p omega --test computed_array_extent (7 passed, native/Psi agreement on windows_x86_64), mbx test -p lowered-program-to-checked-program --lib array_lengths (31 passed), mbx test -p terminal-wire --lib obligation_evidence (23 passed), mbx xtask check-boundary, mbx xtask check-rules, mbx clippy --no-deps on touched crates | clean (pre-existing unrelated clippy lint in untouched terminal-interpreter/instructions/execution.rs and test compile error in untouched build_dependency_provider_layouts.rs)
Agent: Antigravity | Model: unknown | Effort: high | Tokens: 20.25M in (19.72M cached), 66.3k out | Steps: 88 | Time: 42m24s | Steers: 0