wasi-context
The groupant beside wasi-host/src/lib.rs in the Mova repository: what the code computes, what it never does, how to go back from its outputs, its invariants, cost and checks.
Facts
Implementation material. A Mova code model describes this code at one source revision: partial models, finite checks and their stated scope. It is not a reviewed general exposition, and its labels are shown as written, never raised.
Components
| component | label | where |
|---|---|---|
| approximant | partial | approximant |
| ast | partial | ../syntax.json |
| cost | symbolic source derived | invariant |
| descriptant | present | descriptant |
| invariant | partial | invariant |
| tests | executed bounded checks | tests |
Obernants
The typed relations around the forward model: the behaviour complement (what the code never does), the reverse reconstruction (every input compatible with an output) and specialised views.
| id | type | label | where |
|---|---|---|---|
behavior_complement | behavior_complement | partial source derived model | behavior_complement |
reverse_reconstruction | reverse_reconstruction | partial source derived model | reverse_reconstruction |
descriptor_reuse | descriptor_reuse | partial source derived model | descriptor_reuse |
seed_transition | seed_transition | partial source derived model | seed_transition |
capture_routing | capture_routing | partial source derived model | capture_routing |
path_precedence | path_precedence | partial source derived model | path_precedence |
Model text
descriptant
wasi-context
Ctx starts stdio0..2 and preopen root3, empty env/input/output, fixed seed, 1000ns step and1024 fd cap. alloc_fd fills the first hole at index>=3 before checking vector length. at validates string then directory, rejects empty/absolute, otherwise joins base and relative path.
Epoch 2026-10-31
Prospective review recorded before edits. Source review found late output FAULT effects and weaker-than-capability rights metadata; these are modeled as current behavior rather than silently repaired. Only bounded new test blocks were added; production code remains unchanged. Actual finite results and exact restoration receipts live under $MOVA_DATA/runs/octopus-wave31-wasi-2026-10-31. No full mlab guest, frozen suite, GPU or corpus run. This node retains its scoped observations for future refinement.
approximant
Forward relation
Ctx starts stdio0..2 and preopen root3, empty env/input/output, fixed seed, 1000ns step and1024 fd cap. alloc_fd fills the first hole at index>=3 before checking vector length. at validates string then directory, rejects empty/absolute, otherwise joins base and relative path.
Scope: wasi-context. State and transitions follow the authoritative source, including partial effects before errors. No executable approximate replacement is attached: categorical errno/effects and module execution lack a useful validated percentage metric; future numerical profiles may only use1/2/5/10% caps after domain/reference evidence.
invariant
Invariant and cost
Ctx starts stdio0..2 and preopen root3, empty env/input/output, fixed seed, 1000ns step and1024 fd cap. alloc_fd fills the first hole at index>=3 before checking vector length. at validates string then directory, rejects empty/absolute, otherwise joins base and relative path.
The invariant is conditional on the admitted transition: alloc_fd cannot choose a later hole while an earlier eligible hole exists; absolute at cannot return a Vfs path. Emission does not promise successful host echo.
Cost: alloc_fd O(F), path clone/join O(path bytes), splitmix O(1), emit O(bytes) plus optional blocking host IO.
No wall-time gain, universal resource bound or atomic rollback is inferred. External Vfs/wasmi/native-mlab work remains separately charged.
models
Typed model catalog
behavior_complement
Subject: wasi-host/src/lib.rs at SHA-256 91213ce9038107912c2dd707c3a6639a2d723cdfceb02981a166a6853800248e, scope wasi-context. Domain: the source transition and bounded fixtures described in approximant.md; readable valid host resources where required. Observation: returned values, byte coordinates, state/effect order, not total-system semantics. Operator/relation: alloc_fd cannot choose a later hole while an earlier eligible hole exists; absolute at cannot return a Vfs path. Emission does not promise successful host echo.
Status: partial source-derived relation; complement is a scoped exclusion hypothesis, reverse preserves all compatible antecedents described rather than a chosen inverse. Assumptions: production branch order, declared coordinate/resource premises; no completeness claim for untested inputs. Evidence: tests.md distinguishes actual execution from source review; finite observations can falsify but not prove the relation.
reverse_reconstruction
Subject: wasi-host/src/lib.rs at SHA-256 91213ce9038107912c2dd707c3a6639a2d723cdfceb02981a166a6853800248e, scope wasi-context. Domain: the source transition and bounded fixtures described in approximant.md; readable valid host resources where required. Observation: returned values, byte coordinates, state/effect order, not total-system semantics. Operator/relation: A given allocated descriptor fixes the first eligible vacant slot or prior vector length, not earlier close history. Captured stdout alone admits merged or unmerged histories when stderr was empty.
Status: partial source-derived relation; complement is a scoped exclusion hypothesis, reverse preserves all compatible antecedents described rather than a chosen inverse. Assumptions: production branch order, declared coordinate/resource premises; no completeness claim for untested inputs. Evidence: tests.md distinguishes actual execution from source review; finite observations can falsify but not prove the relation.
descriptor_reuse
Subject: wasi-host/src/lib.rs at SHA-256 91213ce9038107912c2dd707c3a6639a2d723cdfceb02981a166a6853800248e, scope wasi-context. Domain: the source transition and bounded fixtures described in approximant.md; readable valid host resources where required. Observation: returned values, byte coordinates, state/effect order, not total-system semantics. Operator/relation: With max_fds=4 and live root, allocation returns MFILE; clearing slot3 permits reuse even at cap.
Status: partial source-derived relation; complement is a scoped exclusion hypothesis, reverse preserves all compatible antecedents described rather than a chosen inverse. Assumptions: production branch order, declared coordinate/resource premises; no completeness claim for untested inputs. Evidence: tests.md distinguishes actual execution from source review; finite observations can falsify but not prove the relation.
seed_transition
Subject: wasi-host/src/lib.rs at SHA-256 91213ce9038107912c2dd707c3a6639a2d723cdfceb02981a166a6853800248e, scope wasi-context. Domain: the source transition and bounded fixtures described in approximant.md; readable valid host resources where required. Observation: returned values, byte coordinates, state/effect order, not total-system semantics. Operator/relation: splitmix state advances by wrapping additive constant, then two xor-shift wrapping multiplications; same state gives same next64 bits.
Status: partial source-derived relation; complement is a scoped exclusion hypothesis, reverse preserves all compatible antecedents described rather than a chosen inverse. Assumptions: production branch order, declared coordinate/resource premises; no completeness claim for untested inputs. Evidence: tests.md distinguishes actual execution from source review; finite observations can falsify but not prove the relation.
capture_routing
Subject: wasi-host/src/lib.rs at SHA-256 91213ce9038107912c2dd707c3a6639a2d723cdfceb02981a166a6853800248e, scope wasi-context. Domain: the source transition and bounded fixtures described in approximant.md; readable valid host resources where required. Observation: returned values, byte coordinates, state/effect order, not total-system semantics. Operator/relation: err && !merge_stderr appends stderr, otherwise stdout; echo writes host stderr for err even if captured streams merge.
Status: partial source-derived relation; complement is a scoped exclusion hypothesis, reverse preserves all compatible antecedents described rather than a chosen inverse. Assumptions: production branch order, declared coordinate/resource premises; no completeness claim for untested inputs. Evidence: tests.md distinguishes actual execution from source review; finite observations can falsify but not prove the relation.
path_precedence
Subject: wasi-host/src/lib.rs at SHA-256 91213ce9038107912c2dd707c3a6639a2d723cdfceb02981a166a6853800248e, scope wasi-context. Domain: the source transition and bounded fixtures described in approximant.md; readable valid host resources where required. Observation: returned values, byte coordinates, state/effect order, not total-system semantics. Operator/relation: Malformed UTF8 precedes BADF; non-directory precedes empty path; absolute path records denied Open before NOTCAPABLE.
Status: partial source-derived relation; complement is a scoped exclusion hypothesis, reverse preserves all compatible antecedents described rather than a chosen inverse. Assumptions: production branch order, declared coordinate/resource premises; no completeness claim for untested inputs. Evidence: tests.md distinguishes actual execution from source review; finite observations can falsify but not prove the relation.
tests
Checks and limits
Named actual-source tests run twice per debug/release; exact commands and numeric statuses retained externally. Test success is finite evidence only.
Exact names: tests::wave31_memory_poll_and_descriptor_boundaries, tests::escape_and_absolute_paths_are_not_capable.
Memory tests bypass linker ABI; tiny empty/unreachable guests exercise engine outcomes only. The CLI test uses isolated import/export/journal fixtures.
Five compiled production/helper-source controls: append offset, virtual clock advance, trap status, CLI export gate and newest-mtime max. Each compiles, fails its selected assertion, restores exact original bytes and passes again. These controls cover their target relations, not every node. No assertion-only mutants. See external source-test-map.json, native-commands.json, verify.rs and numeric/raw receipts in $MOVA_DATA/runs/octopus-wave31-wasi-2026-10-31. The example main and frozen mlab paths are never executed.
This page in Markdown โ https://md.groupants.elamur.ai/free/en/mova/wasi-host/src/lib.rs.groupant/wasi-context.groupant/