fix(trace): args rides the tape as a nondeterminism source (#471)#522
Merged
Conversation
builtin_args returned argv directly, unwrapped — the last un-taped nondeterminism source reachable by a pure script, and a hole in the closed-world invariant behind deterministic replay. A program that branched on `args` recorded a tape under one invocation and silently diverged when replayed under a different argv — the exact class the #408 task layer's chaos-mode `--seed N` scheduling would hit. The recorded argument list now rides the tape as one N record and replay serves it regardless of the live argv. Because `args` builds its list before returning, it uses the TRACE_NONDET_TAKE / TRACE_NONDET_RECORD pair (not TRACE_NONDET_RET): under replay the early TAKE short-circuits before the list is built, so the live construction is neither run nor leaked. The tape already round-trips a list of strings (parse_value_p), so no serialization work was needed. Regression: tests/test_replay.sh records under `A B`, then replays the same script under `X Y Z` and asserts the recorded args win (and that a live run under `X Y Z` differs, proving the tape actually overrides). docs/TRACE.md gains a Process category and the TAKE/RECORD-for-builders note; CHANGELOG under Unreleased. Full suite green release + ASan (leaks on), 2689/2689, no leak-tally increase. Closes #471 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
builtin_argsreturnedargvdirectly, unwrapped — the last un-taped nondeterminism source reachable by a pure script, and a hole in the closed-world invariant behind deterministic replay. A program that branches onargsrecorded a tape under one invocation and silently diverged when replayed under a different argv. This is the exact class the #408 task layer's chaos-mode--seed Nscheduling would hit (seeds arrive via CLI, liferaft's--seed Npattern).Fix
The recorded argument list now rides the tape as one
Nrecord; replay serves it regardless of the live argv.Because
argsbuilds its list before returning, it uses theTRACE_NONDET_TAKE/TRACE_NONDET_RECORDpair rather thanTRACE_NONDET_RET— under replay the earlyTAKEshort-circuits before the list is built, so the live construction is neither run nor leaked (the abandoned-value trap the extend-vm checklist warns about). The tape already round-trips a list of strings (parse_value_p,src/trace.c:868), so no serialization work was needed.Verification
tests/test_replay.sh: record underA B, replay the same script underX Y Z, assert the recorded args win — plus a live (no-replay) run underX Y Zthat prints["X", "Y", "Z"], proving the tape actually overrides rather than coincidentally matching.EIGS_TRACE→N args=["A", "B"];EIGS_REPLAYunderX Y Z→["A", "B"].detect_leaks=1): 2689/2689, 0 failed, no leak-tally increase.Docs
docs/TRACE.md: new Process category listingargs, and a note that value-building builtins use theTAKE/RECORDpair.CHANGELOG.md: entry under[Unreleased] → Fixed.Closes #471
🤖 Generated with Claude Code