feat(cli): determinism guard — reframe lint enforces scene purity (0.6.42)#72
Merged
Conversation
…6.42) Scenes must be pure functions of time, but nothing enforced it: a scene using Math.random()/Date compiled to a different IR each time, silently breaking reproducibility (goldens only cover IR→render, not source→IR). This is the floor reframe-studio's "the agent generates it and it reproduces" promise stands on. `reframe lint` now verifies purity for .ts sources: bundle once, evaluate twice, emit a `non-deterministic-render` finding pinned to the first IR address that differs (e.g. nodes[0].props.x: 0.42 → 0.97) plus a source-scan hint. Same --strict gate as the addressability checks. New in-process `checkDeterminism(path)` exported via reframe-video/compile so an embedder can verify a fresh scene before trusting it. The two evals use distinct cache-busting comments to defeat Node's data:-URL ESM module cache (without which the second eval returns the cached module and misses module-level nondeterminism). Additive — pure scenes report clean; only runs on source inputs (.json is the IR itself). Goldens byte-identical (adds a check, no IR/eval-path change). Co-Authored-By: Claude Opus 4.8 <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
OSS floor hardening for reframe-studio. Two audits this session (a fundamentals review + an agent-surface audit) converged on one confirmed crack in the determinism floor: scenes must be pure functions of time, but nothing enforced it. A scene using
Math.random()/Datecompiles and renders fine yet yields a different IR each compile, silently breaking the reproducibility the product's whole pitch rests on. The golden tests only cover IR→render; the source→IR step was unguarded.How
reframe lintnow verifies purity for.tssources (the studio-readiness gate, alongside addressability):non-deterministic-renderfinding pinned to the first differing address (e.g.nodes[0].props.x changed 0.42 → 0.97) plus a source-scan hint at the culprit construct--strictexit-code gateNew in-process
checkDeterminism(path)exported viareframe-video/compileso an embedder can verify a freshly generated scene before trusting it.Load-bearing detail:
loadSceneimports adata:…base64URL, and Node caches ESM by URL — so a naive double-load returns the same cached module and misses module-level nondeterminism. The two evals append distinct cache-busting comments so the module re-evaluates fresh. The test asserts the impure scene IS caught, guarding this.Verification
reframe-videobuild bundlescheckDeterminismintodist/compile-api.jsreframe lint examples/scenes/photo-montage.ts→ no determinism finding (pure); a temp scene withMath.random()→ flagged withnodes[0].props.x,--strictexits 1Scope
Focused on the one confirmed floor crack. Ranked follow-ups noted in the plan (not built): addressing-density lint, structured validation errors,
renderFrameAtexport, timing-walk unification. Version → 0.6.42.🤖 Generated with Claude Code