Skip to content

impl(067): resume, rerun, shutdown during a run, native live conformance and closure (increments 3 and 4) - #563

Merged
bartekus merged 1 commit into
mainfrom
impl/067-inc3a
Nov 8, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/067-inc3a

Conversation

@bartekus

@bartekus bartekus commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Spec 067 increments 3 and 4: the last 067 code and the spec's closure in one pull request.

Based on main after #550, #551 and #564; reviewed earlier while stacked on them (no findings at the same diff).

Increment 3 (3.6.4, 3.7.2, 3.7.3, 3.8.2)

  • Resume. resume: true with a checkpoint whose LiveConfigId differs is code 4, checkpoint-mismatch, before the journal is opened (live_run.rs). Completed items are never re-sent, the run spend is read from the journal, a replaced journal is refused by its journal_id (043 3.10.2, through rustev-live).
  • rerunInterrupted. Without it an interrupted item is incomparable (live-interrupted); with it the item is re-sent as <id>/rerun-1 under a new reservation, the old one kept as liability.
  • Shutdown during a run. engine.shutdown({ drainMs }) raises cancellation for every running liveRun at once, waits up to drainMs, keeps the existing bounded settle wait, and reports abandonedPending from every seam's own count (backend seams now count abandoned host calls as source and scorer seams do; a late settlement is discarded and counted, never both). Decisions keep drain-then-cancel.
  • Live conformance, native. js/run.mjs runs the six live cases over engine.liveRun with the cases' scripted host backends and an AbortSignal; both runners snapshot every run's documents and journal under run-<n>/, so the interrupted run of live.resume is compared byte for byte, not only its status (I-3). Surfaces rust-api and native; expected bytes re-blessed (layout only).
  • Tests (test/live.test.mjs): resume over completed and interrupted items, rerunInterrupted, another configuration, a replaced journal, a reached cap, shutdown with drainMs 0 and 10,000 then resume on a new engine, a second liveRun on a held journal (code 3, journal-locked, nothing sent), a fresh journal after deleting the first (this_run, new id, spendBefore 0).

Increment 4 (closure)

  • Host-seam cases left (3.3, 3.8.3): a SeamFailure charge settles its ticket without liability; cost_unit: none reserves zero and is recorded declared_no_spend; an estimated bound is reserved in full before the host observes the call; a retry reserves anew; a full seam queue sends nothing and spends nothing; a run over a replay bundle with an admission record.
  • Verification declared; 067 in VERIFIED_SPECS and alone in a new node-live acceptance group (the groups beside 027 and 043 are near the 45-minute limit); extends edges on Makefile and scripts/acceptance/ (001, additive, as 2 Territory states) and on integrations/rustev-bedrock/ (030, whose live example constructs the RunOptions impl(067): live runs bind the journal identity: checkpoint digest, journal member, --require-existing-journal, new_journal (increment 1a, run binding) #550 changes); the full implementation record (every 067 PR's paragraph, held for this PR so 067's derived shards did not collide in the queue); implementation: complete.
  • Audit. Every Acceptance item and section 5 row was checked against the merged code; each has a test. One deviation is recorded in the record, not hidden: a full seam queue's ticket ends in a zero settle, not a release (3.3.5), because the seam reports observed 0 and 043 3.6.6 settles by charge; totals are identical and changing it needs rustev-runtime, outside 067's territory. Two readings are recorded: a refusal's status is the CLI's (invalid_input, io_error) with journal: null, and an already-aborted signal rejects with the existing CancelledBeforeAdmission.

scripts/acceptance/verify.py changes, so this needs the review-exception approval (preapproved for 0.6.0).

Checks (on the combined tree: main + #550 + #551 + #564 + this)

spec-spine verify 067 (passed, 6 commands), cargo test -p rustev-node, -p rustev-conformance, -p rustev-live, -p rustev-cli --test eval_live, -p rustev-surface --all-features, the native addon build, node --test integrations/rustev-node/test/*.test.mjs (all pass except six telemetry tests blocked by the sandbox's listen EPERM, which pass in CI), node tools/rustev-conformance/js/run.mjs native integrations/rustev-node (all 244 cases, exact bytes), make bindings (pass, including every node --test file and the native conformance runner), make semver (pass: 13 crates and both npm packages against 0.5.0), rustev-boundaries, workspace clippy -D warnings, fmt, make gate. No live or paid call (R-1).

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (findings)

Looking at the four changed files, I'll examine the shutdown logic, seams accounting, and the checkpoint validation.

index.js — abandonedPending metric for backend seams

The shutdown() return value uses s.queueDepth for seams whose name starts with "backend:", but s.abandonedPending for everything else:

// index.js ~875
const abandonedPending = this.gauges().seams.reduce((n, s) => n +
  (s.name.startsWith('backend:') ? s.queueDepth : (s.abandonedPending ?? 0)), 0);

The Rust changes in seams.rs specifically add correct abandoned_pending tracking to backend seams (via callbacks: true on HostBackend's SeamStats). queueDepth measures items queued but not yet dispatched — these never had a JS Promise created, so they are not "abandoned pending" callbacks. Using queueDepth overestimates the count relative to the new Rust-tracked abandonedPending value and is inconsistent with the purpose of the metric. The seams gauge test (f.e.gauges().seams.every(g => !g.abandonedPending)) validates the Rust counter after settling, but the shutdown() return value takes a different, incompatible path for backend seams.

index.js — settlement loop condition mixes scales

// index.js ~866
while (remaining > 0 && (running.get(this).size > liveRuns.get(this).size || remaining > liveRuns.get(this).size) && Date.now() < settleBy) {

remaining is the native runtime's count of active items; liveRuns.get(this).size is the JS-side count of live-run cancel handles. A single live-run handle can correspond to multiple native items (e.g., backend calls dispatched in parallel within that run). When a live run has spawned more than one native task, remaining > liveRuns.size will be true even after all regular decisions have settled, causing the settlement loop to run unnecessarily. Conversely, if live runs complete their native work quickly (reducing remaining) but their JS handles are still alive (keeping liveRuns.size elevated), the condition can exit the loop prematurely for a remaining regular decision. The comparison between a native count and a JS-object count is not a reliable proxy.

No findings in src/live_run.rs or src/seams.rs; the atomic ordering in Reply::drop is correct (increment before close(), so any subsequent failing send can safely decrement without underflow).

{"head": "0ee6097facbbcbd3906a61f0ffe6f8a87ddfe6a2", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/index.js", "line": 875, "severity": "medium", "category": "correctness", "summary": "abandonedPending for backend seams is computed from s.queueDepth (queued-but-unstarted items, never backed by a JS Promise) instead of s.abandonedPending, which seams.rs now tracks correctly via the new callbacks flag; this overestimates the returned count and contradicts the Rust changes in the same PR."}, {"path": "integrations/rustev-node/index.js", "line": 866, "severity": "low", "category": "correctness", "summary": "The settlement-loop exit condition compares the native runtime's remaining count against the JS-side liveRuns handle count; because one live-run handle can correspond to multiple native tasks, the comparison is unreliable and can keep the loop running unnecessarily or exit it before a regular decision has settled."}]}

Subject: 601fd89...0ee6097, diff digest 73f0f6fcfc9e2de2676a360e813526591fe708d4c8b815e976e48c19ee50a6e2, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 7, 2026 23:21 — with GitHub Actions Inactive
@bartekus
bartekus changed the base branch from impl/067-inc2b to impl/067-inc2b-run November 7, 2026 23:24
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the four changed files for bugs, security problems, and correctness issues.

index.js — shutdown changes

The cancelledRuns snapshot and union-based cancelled count are correct. The snapshot is taken synchronously after natives.get(this).shutdown() stops admission, so no live run can be started between the two operations in a single-threaded JS event loop. Live runs that complete during the drain are still counted as cancelled (they were raised before the drain), which is the intended semantics.

live_run.rs — checkpoint pre-validation

Reading with LiveCheckpoint::LIMITS.max_bytes + 1 is the standard budget probe: an over-budget file returns ReadFail::Budget, which maps to Done::io. An oversized checkpoint surfacing as an I/O error rather than checkpoint-mismatch is a minor framing inconsistency but not a correctness defect. The case where no checkpoint exists (None from read_classified) correctly skips the check; prepare then validates the journal header as normal.

seams.rs — abandoned_pending accounting

The increment/decrement invariants for Reply::drop:

  • Increment before rx.close() (guarded by self.stats.callbacks)
  • Decrement in try_recv().is_ok() branch (guarded by self.stats.callbacks)

Corresponding path in HostBackend::infer when tx.send fails:

  • Decrement abandoned_pending — not guarded by stats.callbacks

Currently safe because HostBackend constructs stats with callbacks: true, so the increment always fires before this decrement. However the asymmetry is a concrete defect: if callbacks were ever false on a HostBackend-equivalent stats object, the unguarded fetch_sub would underflow (wrap to usize::MAX in release, panic in debug) with no corresponding fetch_add. The mirror operations in Reply::drop are both guarded; the backend-side decrement is not.

test/live.test.mjs

The decisionId.split('/')[1] lookup for the journals map is correct for the naming scheme live/{runId}/.... Assertions about abandonedPending converging to 0 after backends settle correctly test the new accounting round-trip.

{"head": "7917113ffdb7a89a5b05ca8272ee26305e19dd5d", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/seams.rs", "line": 439, "severity": "low", "category": "correctness", "summary": "The new `abandoned_pending.fetch_sub(1)` in HostBackend::infer is not guarded by `stats.callbacks`, while both the corresponding increment and the try_recv-branch decrement in Reply::drop are guarded; if callbacks were ever false on a HostBackend stats object the counter would underflow."}]}

Subject: dfbb4e9...7917113, diff digest dbb41541d954d3800d9229a7f5955b57ff3cc4cd082d42e7417c15571d2366ec, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 7, 2026 23:31 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the four changed files: index.js, src/live_run.rs, src/seams.rs, and test/live.test.mjs.

index.js — shutdown logic

The new flow snapshots liveRuns into cancelledRuns, immediately raises each, then after the drain window raises everything still in running. Live runs that survive the drain receive raise() twice (once in the cancelledRuns loop, once in the final for (const c of live) sweep). The cancelled count uses new Set([...cancelledRuns, ...live]).size for correct deduplication. The logic is consistent and the drainMs=0 and drainMs=10000 test cases validate that double-raise is handled safely. The semantics of cancelled now include early-cancelled live runs that finished during drain, which is intentional per spec 067.

src/live_run.rs — early checkpoint validation

The read uses LiveCheckpoint::LIMITS.max_bytes + 1 as the budget. Under the typical "one-past" convention, a file of exactly max_bytes + 1 bytes would be returned as Ok(bytes) and fed directly to parse() without a length check. If parse() does not enforce its own size bound, an oversized-by-one file would pass the early gate. The Budget path maps to io_error rather than checkpoint-mismatch, which is a distinct status code and observable via the test surface. Neither case affects correctness for well-formed or clearly malformed inputs; impact is limited to the exact boundary.

src/seams.rs — abandoned_pending accounting

The increment-before-close pattern is correct. For every Reply that is dropped before resolution, one of two paths decrements: either Reply::drop (if try_recv succeeds, meaning the backend sent before the close) or the backend task (if tx.send fails, meaning close beat the send). The SeqCst ordering prevents reordering across the rx.close() fence. No scenario produces a double-decrement or a failure to decrement. The late_resolutions_discarded invariant from the old comment is preserved.

test/live.test.mjs

Covers the main new paths: resume with changed config, resume after journal replacement, shutdown-writes-checkpoint, concurrent lock contention, and the drainMs variants. The assert.ok(stopped.abandonedPending >= 2) assertion assumes both stalled backend calls land on the same seam; with a single-backend fixture and parallel: 1 this holds.

No concrete defects found.

{"head": "ad0e7341d3953c5d968efc3f329340bfb0d12430", "verdict": "no-findings", "findings": []}

Subject: e4a1b8d...ad0e734, diff digest 82f1156db86015725ee874a465f6c58a78316921bfcca43cb8de2756de455ad1, 1 call(s). An AI comment is not an approval.

@bartekus bartekus changed the title impl(067): liveRun resume, rerun-interrupted and shutdown during a run (increment 3, part A) impl(067): resume, rerun, shutdown during a run, native live conformance and closure (increments 3 and 4) Nov 8, 2026
@bartekus
bartekus changed the base branch from impl/067-inc2b-run to stack/067-inc3-base November 8, 2026 01:27
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (findings)

Review

integrations/rustev-node/src/live_run.rs — ReadFail::Budget mapping

The early checkpoint read (spec 3.7.2) maps both ReadFail::File and ReadFail::Budget to Done::io (code 3, io_error):

.map_err(|e| match e {
    rustev_surface::host::ReadFail::File(e)
    | rustev_surface::host::ReadFail::Budget(e) => Done::io(COMMAND, e),
})?

A parse error on checkpoint.json correctly becomes checkpoint-mismatch (invalid_input, code 4). But if checkpoint.json exceeds LIMITS.max_bytes, ReadFail::Budget returns code 3 instead of code 4. The spec 3.7.2 characterizes this gate as a configuration rejection, so callers expecting invalid_input for all document-level failures would receive a misclassified io_error. The case is unlikely in practice (checkpoints are small), but it is a concrete behavioural difference from a parse error on the same file.

Remaining observations (no findings)

  • Shutdown cancelled count (new Set([...cancelledRuns, ...live]).size): correctly deduplicates live-run tokens that may appear in both the early snapshot and the residual running set. No issue.
  • Double-raise for live runs: live-run cancel tokens are raised before the drain window and again in the final raise loop. This is consistent with the existing abort-signal pattern and the test validates correct behaviour under both drainMs = 0 and drainMs = 10 000.
  • abandoned_pending counter (seams.rs): the add-before-close / subtract-on-receive sequence is race-safe under SeqCst ordering for all relevant interleavings (normal drop, host send before close, host send after close).
  • liveCase path validation (js/run.mjs): the contained check blocks .., absolute paths, empty segments and trailing slashes; adequate for the Linux target.
  • process.chdir restore: the finally block runs unconditionally whether engine.create throws or not, restoring cwd correctly in all paths.
  • Spec lifecycle transition (pending → complete) and the new extends edges (Makefile, scripts/acceptance/, integrations/rustev-bedrock/) are consistent with the described increments and the constitution's ownership rules.
{"head": "576d7b0e7b06e495946c3c13b95a6c02a9a83a4f", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/live_run.rs", "line": 383, "severity": "low", "category": "correctness", "summary": "ReadFail::Budget for the early checkpoint read maps to Done::io (code 3) rather than checkpoint-mismatch (code 4); an oversized checkpoint.json returns io_error where callers expecting document-level rejection would expect invalid_input."}]}

Subject: fc2980b...576d7b0, diff digest 78b37b34db326238d17f74a69169a431319b08361a9cc671acd8f498733890ea, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 8, 2026 01:38 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for correctness, security, and consistency against the governance context.

integrations/rustev-node/src/seams.rs — abandoned_pending counter atomics

The new logic increments abandoned_pending before closing the receiver, then decrements in whichever of the two paths fires (drop's try_recv success, or sender's send error). The key invariant is that tx.send(r).is_err() can only be true after rx.close() has been called, which happens inside Reply::drop after the increment. So the decrement in the sender always happens-after the increment in drop. The two decrement paths are mutually exclusive (either the value was buffered before close, in which case try_recv sees it; or it arrives after close, in which case the send fails). The SeqCst ordering is sufficient. This is correct.

integrations/rustev-node/index.js — shutdown live-cancellation ordering

cancelledRuns is captured as a snapshot of liveRuns at shutdown time. Signals are raised before the drain loop, so live runs do not need to wait for the drain window to receive their signal. After the drain, for (const c of live) c.raise() re-raises any handles still in running (idempotent for the already-raised live ones). The cancelled count uses a set union of cancelledRuns and live, which correctly deduplicates handles that appear in both and counts live runs that completed during drain (present in cancelledRuns, absent from live). This matches spec 3.6.4.

integrations/rustev-node/src/live_run.rs — early checkpoint mismatch check

Reading max_bytes + 1 bytes is the standard probe for oversized files; if the parse fails (truncated, malformed, absent), saved becomes None and the check is skipped, leaving prepare to handle those cases as the spec requires (3.7.2). Correct.

tools/rustev-conformance/js/run.mjs — path validation

The contained validator checks for absolute paths, .. segments, and empty segments. The process.chdir(dir) call is global state, but the comment and structure confirm sequential execution with cwd restored in finally. This is a conformance test tool and the risk is bounded.

specs/067-node-live-repeat-runs/spec.md lifecycle change

implementation: pending → implementation: complete with status: approved is the correct terminal state per the contract (approved + complete = settled). The extends edges on integrations/rustev-bedrock/, Makefile, and scripts/acceptance/ use nature: additive, which is appropriate — they acknowledge those units belong to the named owning specs. The ratification paragraph (A-86) was already present and is not changed in this PR.

Conformance output snapshotting

The Rust runner now prefixes outputs under run-{n}/ per run. The mirrors function extracts the last run's snapshot (run-2/ for live.resume, run-1/ otherwise) for the rustev-live assertions, while also verifying run-1's intermediate state for the resume case. The expected fixture files are consistent with this structure.

No concrete defects found.

{"head": "3dc49b430d1040976a8a1db07419d8aa00f4a72f", "verdict": "no-findings", "findings": []}

Subject: fc2980b...3dc49b4, diff digest de5c31cc36b91647fa5d94b40d6a3bd98756ab251d3accb8b47fb8f21af1ac10, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for spec 067's implementation closure: the integrations/rustev-node/ changes (index.js, live_run.rs, seams.rs), the conformance runner additions in tools/rustev-conformance/, the new test suite, the Makefile and scripts/acceptance/verify.py updates, and the spec lifecycle transition.

seams.rs — abandonedPending counter correctness

The new logic increments abandoned_pending in Reply::drop before closing the receiver, then decrements it in two paths: try_recv().is_ok() (value already in channel) and tx.send(r).is_err() (send fails after close). All four interleavings are safe — no double-count or permanent over-count — because one of the two paths always fires for a given reply, and the decrement in the settler task is gated on the same callbacks flag as the increment. The 30-second post-drain settle window in shutdown gives pending JavaScript callbacks time to resolve and trigger the decrement.

live_run.rs — checkpoint mismatch guard

Reading max_bytes + 1 bytes correctly passes oversized files and malformed checkpoints through to prepare (they produce None after parse fails), while valid checkpoints within the limit are checked for config-ID equality before prepare acquires the journal lock. The spec requirement (3.7.2) is satisfied.

index.js — shutdown cancellation ordering

cancelledRuns is a snapshot of liveRuns taken at shutdown entry; cancels are raised before the drain loop. After drain, cancelled = new Set([...cancelledRuns, ...live]).size correctly deduplicates live runs that appear in both sets. The test's 2-second window for signal propagation is feasible given the synchronous cancellation.

js/run.mjs — liveCase

Path containment validation (contained) correctly rejects .., absolute, and empty-component paths. After process.chdir(dir), relative options in run.options resolve under the temp directory as intended. The scripted backend function is reused for live backends: live runs use the same host-infer protocol as decisions, so the call format is compatible. process.chdir(cwd) is in the finally block after engine.shutdown().

tools/rustev-conformance/src/live.rs — per-run snapshot collection

Each run's output tree and journal are now prefixed run-N/ before insertion into outputs, matching the expected fixture layout and the native JS runner's output map keys.

tests/live.rs — mirrors function

The prefix selection (run-2/ for live.resume, run-1/ for all others) correctly isolates the last run's documents. The added assertions on the run-1 interrupted state (liability=1, counts.interrupted=1, checkpoint has an interrupted item) are consistent with the expected fixture bytes.

Spec lifecycle transition

implementation: pending → implementation: complete is a lifecycle change (now settled; unresolved units become errors). This is enforced by the gate elsewhere per the reviewer's contract and is consistent with the owner's prior ratification (A-86).

No concrete defects are supported by the supplied evidence.

{"head": "affbb99a71eda71affda704321f78b8b78d749ab", "verdict": "no-findings", "findings": []}

Subject: ebafa69...affbb99, diff digest de5c31cc36b91647fa5d94b40d6a3bd98756ab251d3accb8b47fb8f21af1ac10, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus changed the base branch from stack/067-inc3-base to main November 8, 2026 03:18
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR which closes spec 067 (node live repeat runs) by adding the native runner, shutdown cancellation of live runs, checkpoint-mismatch detection, and abandonedPending accounting.

Makefile / scripts/acceptance/verify.py: 067 added to VERIFIED_SPECS and given its own node-live acceptance group. The extends edges in the spec correctly claim 001 ownership over both changed files.

index.js shutdown cancellation: liveRuns WeakMap is populated on each liveRun call and cleared in finally. Shutdown snapshots it, raises each cancel before the drain window, then computes cancelled as the union of cancelledRuns and remaining live to avoid double-counting the same cancel object. Union semantics are correct since the same object is in both sets.

live_run.rs checkpoint-mismatch: The early check reads the checkpoint with LiveCheckpoint::LIMITS.max_bytes + 1 as the limit — absent, unreadable, oversized, or unparseable checkpoints silently fall through to prepare, matching the stated behaviour. The check runs before any journal I/O, satisfying spec 3.7.2.

seams.rs abandonedPending counting: The increment-before-close / subtract-on-resolution pattern is sound. tx.send() can only fail after rx.close(), so the increment in drop always precedes any decrement in the settling task. If try_recv() succeeds (value already in channel), drop decrements and the task never reaches is_err(). No path produces a double-decrement or a permanent increment.

tools/rustev-conformance: The Rust runner now prefixes outputs with run-N/ and the mirrors helper strips the appropriate prefix; status.json remains flat. The native JS runner mirrors this layout. The live.resume assertions correctly check the intermediate run-1 state before examining run-2.

Spec lifecycle: implementation: pending → complete with status: approved is the correct settled state per the contract table. The extends additions for 030 (integrations/rustev-bedrock/) and 001 (Makefile, scripts/acceptance/) match the actual changed paths. The 3.3.5 deviation (zero settlement instead of ticket release) is explicitly recorded in the implementation record.

No concrete defects found.

{"head": "010e8284ad07643deb17ac21ce44fe9d8ad9f9ee", "verdict": "no-findings", "findings": []}

Subject: a26ec07...010e828, diff digest b1c2c2b6466152c35d39f1c7e984b9d752e5580e5695d3f2ad23479912b19772, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 8, 2026
@bartekus bartekus added the statecraft:stacked-ci Run the full CI matrix on a stacked pull request label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across the seven primary code paths plus the spec and conformance artifacts.

crates/rustev-live/src/documents.rs — The sync_directory refactoring is correct. On Unix, it opens the directory and calls sync_all(); on non-Unix targets it returns Ok(()) immediately. The comment correctly notes that NTFS journals the rename, so the last-step rename satisfies spec 043 3.10.1 on Windows. No issue.

integrations/rustev-node/index.js — The liveRuns WeakMap is added alongside running, and both are populated/depopulated symmetrically in liveRun. Shutdown raises cancellation on cancelledRuns before the drain window, then computes cancelled = new Set([...cancelledRuns, ...live]).size to avoid double-counting live runs (which are a subset of running). The semantics correctly count all live runs that were targeted, including those that might complete during drain. No issue.

integrations/rustev-node/src/seams.rs — The abandonedPending logic: fetch_add happens before rx.close(), so by the time tx.send(r).is_err() can return true the increment is already committed. The two branches that decrement (try_recv().is_ok() and tx.send.is_err()) are mutually exclusive because once rx.close() is called, tx.send will fail and the value cannot be retrieved. The callbacks flag gates both increment and decrement symmetrically. No underflow is possible. No issue.

integrations/rustev-node/src/live_run.rs — The checkpoint-mismatch guard reads options.out/checkpoint.json (the output directory), not the journal, so it precedes the journal lock. If the saved checkpoint is readable and its live_config_id differs from the current config's ID, it refuses before prepare opens anything. Absent or malformed checkpoints fall through to prepare unchanged. No issue.

scripts/acceptance/verify.py — The node-live group isolates 067, consistent with the rationale (capacity on existing groups, as noted). No issue.

specs/067-node-live-repeat-runs/spec.md — implementation: pending → complete. The spec's status is approved; approved + complete → settled, which is correct now that the implementation is merged. The three new extends edges cover Makefile and scripts/acceptance/ (owned by 001) and integrations/rustev-bedrock/ (owned by 030, whose live example constructs the now-changed RunOptions). No issue.

tools/rustev-conformance/src/live.rs — The snapshot-per-run change correctly prefixes each run's outputs under run-{n}/. The mirrors function in the test is updated to strip that prefix before the per-case assertions and also adds assertions on the first run's interrupted state for live.resume. No issue.

tools/rustev-conformance/js/run.mjs — liveCase — Path validation in contained blocks absolute paths, .. components and empty components. The process.chdir / restore pattern is acknowledged to require sequential case execution; the comment documents this assumption. No concrete defect is shown by the evidence at hand.

{"head": "a1d4cb13f7f9bdca0bac7e889d2c6b0da4cca18e", "verdict": "no-findings", "findings": []}

Subject: a26ec07...a1d4cb1, diff digest 32f87c2dd9d203d75971096afc616de10411a8f36020e7634f90cd03ea90a982, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (findings)

Review

The PR implements and closes spec 067 (Node binding live repeat runs). It adds the native conformance runner, shutdown cancellation of live runs, abandonedPending tracking, and two Windows fixes (directory sync and label path separator). I reviewed each changed file for correctness, security, and consistency with the governance documents and spec text.

Finding

integrations/rustev-node/src/live_fs.rs, lines 184–186: join emits a backslash separator on Windows when dir ends with \

} else if dir.ends_with('/') || dir.ends_with(std::path::MAIN_SEPARATOR) {
    format!("{dir}{name}")   // preserves trailing '\' on Windows
} else {
    format!("{dir}/{name}")
}

On Windows, std::path::MAIN_SEPARATOR is \. If dir ends with \ (e.g. "out\subdir\"), the matching branch executes format!("{dir}{name}"), producing "out\subdir\{name}". The resulting label still contains a backslash separator rather than /, contradicting the stated invariant in the implementation record ("The separator is always /", I-3: "writes the same bytes on every native platform"). The test covers join("candidates/", "a") → "candidates/a" and join("candidates", "a") → "candidates/a" but not join("candidates\\", "a"), which on Windows would yield "candidates\\a". The fix would be to strip the trailing separator and emit / regardless of kind:

} else if dir.ends_with('/') || dir.ends_with(std::path::MAIN_SEPARATOR) {
    let dir = dir.trim_end_matches(['/', std::path::MAIN_SEPARATOR]);
    format!("{dir}/{name}")

No other concrete defects were found. The abandonedPending counter logic in seams.rs is correct (increment before rx.close(), exclusive decrement paths via try_recv and tx.send failure, guarded by the same callbacks flag). The checkpoint mismatch check in live_run.rs correctly gates on a readable, parseable checkpoint with a differing live_config_id and leaves all other cases to prepare. The lifecycle transition (implementation: pending → complete, status: approved) and the new extends edges in the spec are consistent with the governance rules. The sync_directory refactor correctly restricts directory sync to Unix targets.

{"head": "551243546f7785caf2a59ccd15f55159d4877348", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/src/live_fs.rs", "line": 184, "severity": "medium", "category": "correctness", "summary": "The `join` branch for `dir.ends_with(std::path::MAIN_SEPARATOR)` on Windows emits `format!(\"{dir}{name}\")` which preserves the trailing backslash in the label rather than normalizing to `/`, contradicting the stated cross-platform byte-identical output invariant (I-3)."}]}

Subject: a26ec07...5512435, diff digest 3bff2ee9307d7f6c73eafc1c748ed4804b721552087a63e2287b536cfd7b87bf, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 8, 2026 04:40 — with GitHub Actions Inactive
…nce and closure (increments 3 and 4)

Increment 3: resume with another live configuration is checkpoint-mismatch
before the journal is opened; shutdown raises cancellation for running
live runs at once, waits up to drainMs, and counts unsettled host backend
calls in abandonedPending. The live conformance cases gain the native
runner over engine.liveRun and per-run snapshots, so every run's
documents, including the interrupted run before a resume, compare byte
for byte on rust-api and native.

Increment 4: the host-seam cases left (SeamFailure charge, no-spend
binding, estimated exposure in full, retry reserves anew, full seam queue,
replay bundle with admission), 067 in VERIFIED_SPECS and its own
node-live acceptance group, the 001 and 030 extends edges, declared
verification, the full implementation record and implementation complete.
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (findings)

Review

The PR implements the closure increment of spec 067, adding the native conformance runner over engine.liveRun, resume/rerun/shutdown behaviour, and Windows compatibility fixes. The spec advances implementation from pending to complete.

Code correctness

crates/rustev-live/src/documents.rs — sync_directory correctly skips the directory entry sync on non-Unix targets where a directory cannot be opened as a file, while still honouring the fsync-then-rename rule on Unix. No issue.

integrations/rustev-node/src/seams.rs — The reordered Reply::drop (increment before close, decrement-on-found after try_recv) is sound: tx.send() can only return Err after rx.close(), which occurs after the fetch_add, so the decrement path in the backend task always observes a positive counter. SeqCst enforces this across threads. late_resolutions_discarded cannot be double-counted because the channel is one-shot. No issue.

integrations/rustev-node/index.js — cancelledRuns is snapshotted synchronously (single-threaded event loop) before the drain loop, so no live run can enter or leave the set between the snapshot and the first round of c.raise(). The Set union correctly de-duplicates live runs that appear in both cancelledRuns and the later running snapshot. The double-raise on live runs is safe (idempotent). No issue.

integrations/rustev-node/src/live_run.rs — Reading checkpoint.json with max_bytes + 1 before touching the journal correctly makes an oversized or absent checkpoint fall through to prepare, keeping those error paths in the library. No issue.

integrations/rustev-node/src/live_fs.rs — join now always uses / as separator, with an explicit test documenting that a trailing backslash in dir is preserved as written. This is consistent with the stated invariant (I-3: same bytes on every native platform). No issue.

tools/rustev-conformance/js/run.mjs — liveCase uses process.chdir() to run with relative input paths. The comment notes sequential execution and the finally block restores the cwd after engine.shutdown(). Because the conformance runner calls cases sequentially and the engine is fully stopped before restoration, global state is safe. No issue.

Spec / governance

specs/067-node-live-repeat-runs/spec.md, lines 48–50 — The PR adds an extends edge:

- { spec: "030-bedrock-backend", unit: { kind: directory, path: "integrations/rustev-bedrock/" }, nature: additive }

The spec text explains the Bedrock live example constructs RunOptions, which 3.4.6 changes (increment 1a, #550). integrations/rustev-bedrock/ is not among this PR's changed paths. The edge is claimed retroactively: the ownership declaration was absent from spec 067 when increment 1a merged, so the coupling gate for PR #550 could not have seen it. Whether #550 carried a Spec-Drift-Waiver or some other coverage is not visible in the supplied diff; the gap is real as stated.

The Makefile and scripts/acceptance/ edges are for files that are changed in this PR, so those are unproblematic.

Verification section

The verify:cli block is internally consistent: spec 067 is added to VERIFIED_SPECS, its node-live acceptance group is registered in verify.py, and the commands match the crates changed.

Conformance expected files

The per-run snapshot structure (run-N/) is consistent between src/live.rs, tests/live.rs, and the new expected directories. The mirrors function's hardcoded "run-2/" for live.resume correctly picks the final resumed run.


{"head": "d899c03ed77bc50f136e02b63f18c477e32f3185", "verdict": "findings", "findings": [{"path": "specs/067-node-live-repeat-runs/spec.md", "line": 49, "severity": "medium", "category": "authority", "summary": "The extends edge claiming additive ownership of integrations/rustev-bedrock/ is added retroactively: the directory is not changed in this PR and the spec text locates the actual change in increment 1a (PR #550), meaning spec 067 did not own that unit when it was modified and the coupling gate for #550 could not have validated this claim."}]}

Subject: a26ec07...d899c03, diff digest ba3f0eb488b97fb6c2d691c9fb35310a09788558584121718d0a00c22c4d5b99, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 8, 2026 04:51 — with GitHub Actions Inactive
@bartekus

bartekus commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Review note: the integrations/rustev-bedrock/ edge (030, additive) is added here on purpose, after the fact, and says so. #550 changed the Bedrock live_run example only to follow the RunOptions fields 3.4.6 adds; it landed under a Spec-Drift-Waiver that names this closure pull request as the place for the edge ("The implementation record paragraph and the extends edge for integrations/rustev-bedrock/ are held for the increment 4 closure pull request"), the coordinated 0.6.0 rule that kept 067 spec and shard edits out of parallel code PRs because they ejected each other from the merge queue. The edge records the dependency for future changes; it claims no authority #550 lacked (additive, not amending), and the implementation record names #550 as the change. No code change follows from this finding.

@bartekus
bartekus added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 8e9599a Nov 8, 2026
48 of 49 checks passed
@bartekus
bartekus deleted the impl/067-inc3a branch November 8, 2026 05:56

This branch was previously deployed

1 inactive deployment
statecraft-review-exception — d899c03e Deployed Nov 8, 2026 by bartekus via review-exception #3830
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

statecraft:stacked-ci Run the full CI matrix on a stacked pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant