Skip to content

psi: support target-dependent constant array extents - #6317

Merged
Smotto merged 1 commit into
mainfrom
work/psi-const-array-extents
Nov 27, 2026
Merged

Smotto merged 1 commit into
mainfrom
work/psi-const-array-extents

Conversation

@Smotto

@Smotto Smotto commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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

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
@Smotto
Smotto merged commit fbfa9a8 into main Nov 27, 2026
1 check passed
@Smotto
Smotto deleted the work/psi-const-array-extents branch November 27, 2026 02:35
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.

1 participant