#!/usr/bin/env node const assert = require("assert"); const fs = require("fs"); const path = require("path"); const repo = path.resolve(__dirname, ".."); function read(relativePath) { return fs.readFileSync(path.join(repo, relativePath), "utf8"); } function expect(source, name, pattern) { assert.match(source, pattern, `missing public-story evidence: ${name}`); } const readme = read("README.md"); const publicAcceptance = read("scripts/acceptance-public.sh"); const publicSplit = read("scripts/verify-public-split.sh"); const cliLocalRunSmoke = read("scripts/cli-local-run-smoke.js"); const dapSmoke = read("scripts/dap-smoke.js"); const wasmtimeAssignmentSmoke = read("scripts/wasmtime-assignment-smoke.js"); const debuggerEvidence = `${dapSmoke}\n${wasmtimeAssignmentSmoke}`; const flagshipDemoSmoke = read("scripts/flagship-demo-smoke.js"); const artifactDownloadSmoke = read("scripts/artifact-download-smoke.js"); const artifactExportSmoke = read("scripts/artifact-export-smoke.js"); for (const [scriptName, script] of [ ["public acceptance", publicAcceptance], ["public split", publicSplit], ]) { assert( script.includes("node scripts/public-story-contract-smoke.js"), `${scriptName} must run public-story-contract-smoke.js` ); } for (const [name, pattern] of [ [ "README states public story", /one virtual process, many virtual threads\/tasks, ordinary debugger controls, attached user nodes, and explicit artifact handling/, ], [ "README states local-first bytes policy", /local source checkouts and large outputs stay node-local unless user code or policy explicitly moves bytes/, ], [ "README states normal debugger controls", /ordinary debugger\s+controls for breakpoints, continue, pause, and restart/, ], ]) { expect(readme, name, pattern); } for (const [name, pattern] of [ ["CLI local run starts a node process", /cli_process_started_node_process/], ["CLI local run checks node is separate from CLI", /assert\.notStrictEqual\(report\.boundary\.spawned_node_process_id, cliPid\)/], ["CLI local run checks node is separate from coordinator", /assert\.notStrictEqual\(report\.boundary\.spawned_node_process_id, coordinator\.pid\)/], ["CLI local run records the real virtual task tree", /events\.events\.length >= 4[\s\S]*prepare_source[\s\S]*compile_linux[\s\S]*package_release/], ["CLI local run records real artifact metadata", /events\.events\.some\(\(event\) => event\.artifact_path\)/], ["CLI local-only run starts coordinator", /cli_process_started_coordinator_process[\s\S]*true/], ["CLI local-only run hides coordinator address requirement", /\["run"[\s\S]*"--local"[\s\S]*"--project"[\s\S]*project/], ]) { expect(cliLocalRunSmoke, name, pattern); } for (const [name, pattern] of [ ["DAP smoke uses local-services runtime", /runtimeBackend: "local-services"/], ["DAP smoke exposes dynamic entry and child virtual threads", /mainThread[\s\S]*build virtual process[\s\S]*childThread[\s\S]*notStrictEqual\(childThread\.id, failThread\.id\)/], ["DAP smoke binds the real entrypoint breakpoint", /stack\[0\]\.line, buildMainLine[\s\S]*stack\[0\]\.name, \/build_main::wasm\//], ["DAP smoke binds the real child task breakpoint", /childStack\[0\]\.line, taskTrapLine[\s\S]*childStack\[0\]\.name, \/task_trap::wasm\//], ["DAP smoke all-stops on breakpoint", /assert\.strictEqual\(stopped\.body\.allThreadsStopped, true\)/], ["runtime smoke proves acknowledged pause all-stop", /fully_frozen[\s\S]*resume_debug_epoch[\s\S]*fully_resumed/], ["DAP smoke refuses active-task restart without a clean boundary", /restartFailure[\s\S]*checkpoint boundary\|still active/], ["DAP smoke supports rebuilt terminal main restart", /restartFrame[\s\S]*Restarted main from the rebuilt bundle/], ["DAP smoke avoids native child debugger claims", /doesNotMatch\(stack\[0\]\.name, \/podman\|cmd\\\.exe\|powershell\|pid\|native child\/i\)/], ["DAP smoke crosses coordinator-node boundary without fabricating terminal state", /runtime_backend[\s\S]*LocalServices[\s\S]*coordinator_task_events[\s\S]*0/], ]) { expect(debuggerEvidence, name, pattern); } for (const [name, pattern] of [ ["flagship source does not need coordinator checkout", /coordinator_requires_checkout_access[\s\S]*false/], ["flagship source bytes remain node-local", /local_source_bytes_remain_node_local[\s\S]*true/], ["flagship avoids default source upload", /coordinator_receives_source_bytes_by_default[\s\S]*false/], ["flagship avoids default repo tarball", /default_full_repo_tarball[\s\S]*false/], ]) { expect(flagshipDemoSmoke, name, pattern); } for (const [name, source, pattern] of [ ["artifact download creates scoped link", artifactDownloadSmoke, /create_artifact_download_link/], ["artifact download records retained-node source", artifactDownloadSmoke, /assert\.deepStrictEqual\(link\.link\.source, \{ RetainedNode: "node-download" \}\)/], ["artifact download opens scoped stream", artifactDownloadSmoke, /open_artifact_download_stream/], ["artifact export targets attached receiver node", artifactExportSmoke, /export_artifact_to_node[\s\S]*node-export-receiver/], ["artifact export disables coordinator bulk relay", artifactExportSmoke, /coordinator_bulk_relay_allowed[\s\S]*false/], ]) { expect(source, name, pattern); } console.log("Public story contract smoke passed");