{"_id":"@caputchin/replay-selfcheck","name":"@caputchin/replay-selfcheck","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@caputchin/replay-selfcheck","version":"0.2.0","description":"The shared replay determinism + smoke check: replays a run under a hostile isolate-equivalent environment and flags ambient non-determinism, native-trig divergence, and run-to-run drift. Used by the author CLI and the platform replay isolate alike.","keywords":["caputchin","deterministic","determinism","replay","self-check","conformance"],"homepage":"https://github.com/Caputchin/caputchin-sdk#readme","repository":{"type":"git","url":"git+https://github.com/Caputchin/caputchin-sdk.git","directory":"kits/replay-selfcheck"},"bugs":{"url":"https://github.com/Caputchin/caputchin-sdk/issues"},"license":"Apache-2.0","type":"module","publishConfig":{"access":"public"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./isolate":{"types":"./dist/isolate.d.ts","import":"./dist/isolate.js","require":"./dist/isolate.cjs"}},"sideEffects":false,"dependencies":{"@caputchin/determinism":"0.2.0","@caputchin/replay-contract":"0.3.0"},"devDependencies":{"@types/node":"^22.0.0","typescript":"^5.4.0","tsup":"^8.0.0","typedoc":"^0.28.19","typedoc-plugin-markdown":"^4.11.0","vitest":"^2.0.0"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","docs":"typedoc && node ../../scripts/normalize-docs.mjs docs"},"_id":"@caputchin/replay-selfcheck@0.2.0","_integrity":"sha512-m4Nu4YN+WxvEImgrLehWpUHBlhXrsfUL2IRvQEnC7a2Xnw6ZNj/P4zRV4qYlSQeox7xi/VuGWAJUg2esNi3TOw==","_resolved":"/tmp/159d41b974c00c773e4c1f2ec775b0f2/caputchin-replay-selfcheck-0.2.0.tgz","_from":"file:caputchin-replay-selfcheck-0.2.0.tgz","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-m4Nu4YN+WxvEImgrLehWpUHBlhXrsfUL2IRvQEnC7a2Xnw6ZNj/P4zRV4qYlSQeox7xi/VuGWAJUg2esNi3TOw==","shasum":"042dc76d0c7600327949e2c9600069cc8d29b301","tarball":"https://registry.npmjs.org/@caputchin/replay-selfcheck/-/replay-selfcheck-0.2.0.tgz","fileCount":12,"unpackedSize":47818,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHhX5zI4ylZhNmp5zL5qwL8hzJscH8UqqfAi0sOTZQDkAiEAk6VdGRQUUDMQI51c4YnRiE1QuMk7dbIa3vRDeYyHYQI="}]},"_npmUser":{"name":"caputchiner","email":"info@caputchin.com"},"directories":{},"maintainers":[{"name":"caputchiner","email":"info@caputchin.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/replay-selfcheck_0.2.0_1780536355827_0.12962327805859553"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-04T01:25:55.594Z","0.2.0":"2026-06-04T01:25:55.995Z","modified":"2026-06-04T01:25:56.244Z"},"maintainers":[{"name":"caputchiner","email":"info@caputchin.com"}],"description":"The shared replay determinism + smoke check: replays a run under a hostile isolate-equivalent environment and flags ambient non-determinism, native-trig divergence, and run-to-run drift. Used by the author CLI and the platform replay isolate alike.","homepage":"https://github.com/Caputchin/caputchin-sdk#readme","keywords":["caputchin","deterministic","determinism","replay","self-check","conformance"],"repository":{"type":"git","url":"git+https://github.com/Caputchin/caputchin-sdk.git","directory":"kits/replay-selfcheck"},"bugs":{"url":"https://github.com/Caputchin/caputchin-sdk/issues"},"license":"Apache-2.0","readme":"# @caputchin/replay-selfcheck\n\nThe shared **replay determinism check**. Point it at a `run(seed, config, trace)\n-> verdict` (the `@caputchin/replay-contract` surface) and it replays the run\nunder a hostile, isolate-equivalent environment, then reports any reason the run\ncould reject an honest player on the server.\n\nIt is the ONE check used in both places:\n\n- the author / CI CLI `caputchin-selfcheck` (re-exported by\n  [`@caputchin/engine-kit`](../engine-kit)),\n- the platform's replay isolate at vendor / upload / index time (via the\n  `./isolate` entry).\n\nThe non-deterministic-surface set and the divergent-trig keys come from\n[`@caputchin/determinism`](../determinism) - the same registry the runtime ban\nshim projects from - so the check and the enforcement can never drift apart.\n\n## What it catches\n\n- **Ambient access** - the run reads `Date` / `performance` (wall-clock),\n  `Math.random` / `crypto` (entropy), or `fetch` / timers / `Intl` / `navigator`\n  (environment-dependent IO). Each is replaced by a loud thrower; touching one is\n  flagged with the surface name.\n- **Native transcendental divergence** - the verdict changes when `Math.sin` /\n  `cos` / `pow` / ... are swapped to `capMath`, meaning the run depends on\n  libm-approximated math that differs between a player's ARM device and an x86-64\n  server. Use `capMath` instead.\n- **Run-to-run drift** - identical re-runs of the same seed + trace produce\n  different verdicts.\n- **Crash or bad output** - the run throws, or returns a value that is not a\n  `Verdict`.\n\nEvery check includes a **smoke case**: seed `[0,0,0,0]` over an empty trace must\nreturn a `Verdict`, not crash (a garbage trace is a failed round, never an error).\n\n## Usage\n\n```ts\nimport { selfCheck, selfCheckRun } from '@caputchin/replay-selfcheck';\n\n// With recorded traces (the author CLI path):\nconst report = await selfCheck(run, [{ seed, trace, label: 'play-1' }]);\n\n// With synthetic seeds + the empty trace (no recorded play available):\nconst quick = await selfCheckRun(run, { repeats: 8 });\n\nif (!quick.ok) {\n  for (const c of quick.cases.filter((c) => !c.deterministic))\n    console.error(c.label, c.violations);\n}\n```\n\nInside a sealed replay isolate, the host imports the bundled `./isolate` entry:\n\n```ts\nimport { runSelfCheck } from '@caputchin/replay-selfcheck/isolate';\nconst report = await runSelfCheck(run); // report.ok is the gate signal\n```\n\n## Scope\n\nThis is a confidence + gate mechanism, not the trust anchor. The server's\nper-verify replay remains authoritative. It sees only the `run` reference, so it\ncatches ambient access at run time; a value captured at module-load time is\ncovered by the runtime ban shim and the real-isolate diff, not here.\n","readmeFilename":"README.md","_rev":"1-b64c5ee97c743934d175aa325c68b8e6"}