Repository navigation
Add C-377, C-378 and C-379: net tcp on native, the embedded lane and the stock WASI 0.3 component - #134
Merged
Conversation
…edded and stock wasm legs Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…able, and guest-enforced timeouts and tcp_available on every leg Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…sting rows and short hashes Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This was referenced Oct 12, 2026
Merged
Closed
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.
Step 0 of the net/tcp-on-wasm plan (almide/almide#3620): the contracts land in the judge before any implementation, per the owner's rulings of 2026-10-12. All three are requirements-first:
since = "0.68.0",status = "active"(the C-375 precedent; the provenance gate classes themrequirements-first).What each contract promises
net.tcp_*family (13 fns, incl. the newnet.tcp_local_port(listener) -> Result[Int, String], ruling 5) answers byte-identically on native, the embedded lane (almide run --target wasm) and the stock WASI 0.3 component. Handles: two tables (streams, listeners), each from 0, lowest free slot; unclosed handles live to the end of the run. Loopback in one sequential program;tcp_readanswers 1..=n bytes, empty without waiting for n = 0 and at EOF (every time);tcp_read_exactexactly n; closing twice is ok on both tables;tcp_is_openfalse after own close and for never-issued handles, true after a peer close; a port-0 listener reports its OS-assigned port. IPv6 sockets are V6ONLY on every leg (ruling 6). Name resolution: addresses tried in resolver order, first success, else last failure.<fn>(<host>:<port>): <class text>for connect/listen,<fn>: <class text>otherwise; the 13wasi:socketsclass texts plusnetwork error, the two DNS texts; the Almide-local texts (handle texts kept from native,<fn>: negative length N,tcp_read_timeout: timeout must be positive (got N ms),tcp_read_exact: connection closed after K of N bytes,<fn>(<host>:<port>): port out of range 0..=65535). A stock run without the network grant loads, and bind/connect fail aspermission denied(ruling 7).tcp_availableare guest-enforced on p3 and answer what native and embedded answer.tcp_set_timeoutbounds each underlying read/write;tcp_read_timeoutrestores the earliertcp_set_timeoutvalue (ruling 3);tcp_availablecounts bytes readable now without consuming, at most 65536, 0 when none/EOF, served on p3 by a lazily allocated ≤64 KiB lookahead buffer that reads drain first (ruling 4).NOT covered (in the statements, C-367 style)
wasmtime run -S inherit-network [-S allow-ip-name-lookup]) as host configuration.other(some(m))texts, equal only between native and embedded; which names resolve; the stock grant.ALS-R5 gains the matching paragraph (Japanese, with its テスト line), and its validation row is re-stamped.
Evidence
Three in-program loopback fixtures (127.0.0.1, port 0 +
tcp_local_port, no fixed ports, payloads well under 8 KiB, the OS port masked or printed as predicates):spec/embedded_cross/net_tcp_loopback.almd→ C-377spec/embedded_cross/net_tcp_errors.almd→ C-378spec/embedded_cross/net_tcp_timeouts.almd→ C-379Why
spec/embedded_cross, notspec/wasm_cross: both the alscrossleg and almide'swasm_cross_target_specbuild the stock artifact and runwasmtime --dir=/ -S inherit-env=ywith no network grant. Today the stock build of a net program is E081 (almide's harness panics on a failed wasm build), and after the p3 routing lands every bind/connect on that leg readspermission denied, so awasm_crossfixture would be a permanent, untrue divergence (an@xt-allowthat can never go stale) plus three new ref abstains above the ceiling.spec/embedded_crossis the established home for native ⇄ embedded host-op fixtures (C-328, C-374); the stock leg with-S inherit-networkand the no-grantpermission deniedcase are the implementation's three-leg driver, which the statements name but do not cite as evidence until that unit exists (CLAUDE.md: no citation without the implementation-side unit).Measured on v0.67.1 (
tcp_local_portshimmed to a fixed port, since it does not exist yet): all three fixtures type-check exceptE002 undefined function 'net.tcp_local_port', run deterministically (three identical runs), and print the transcript these contracts pin except exactly where the contracts change native: errno texts (Address already in use (os error 48),Connection refused (os error 61),Resource temporarily unavailable (os error 35),invalid port value,failed to fill whole buffer,cannot set a 0 duration timeout), the negative-length panic (capacity overflow, exit 101), and the wiped timeout (the read aftertcp_read_timeoutblocks forever).almide fmt --checkis clean on all three.Reference evaluator:
als-ref runabstains on all three (stdlib:net.tcp_readfor the errors fixture,stdlib:net.tcp_listenfor the other two).spec/embedded_crossis outside the ref corpora, so the abstain ledger is unchanged (ceiling 18, 18 abstained).Gates passed locally
check-contracts.sh,check-contract-provenance.py,check-als-element-coverage.sh,check-als-style.sh,check-als-validation.sh,check-links.sh,check-gate-verification.sh,check-ratchet-separation.sh --stagedand--range origin/main..HEAD,selftest-conformance.py,check-runner-coverage.py,check-ref-totality.pyandcheck-ref-kernel.py(ref built withcargo build --release),check-workflows.sh; README / conformance / ALS README regenerated. No ratchet moved.After this merges: advance
proofs/als-pin.txtin almide/almide in its own commit, then the implementation PRs (design §7 steps 1–4) copy the fixtures.🤖 Generated with Claude Code