Skip to content

impl(031): increment 3, the changelog generator and the crates' SBOMs - #144

Merged
bartekus merged 1 commit into
mainfrom
impl/031-changelog
Oct 21, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/031-changelog

Conversation

@bartekus

@bartekus bartekus commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Spec 031 increment 3: the release changelog generated from the governed corpus (3.10, R-4), and the crates' SBOMs in the candidate (3.9.1).

  • tools/rustev-release/src/changelog.rs (new): render(&Inputs) is a pure function of the specs at the previous release and now (spec-spine registry list --json), the decision rows that ratified or approved each spec, the commits since the previous release that touched it, and the compatibility facts of 3.6 and 3.7. A spec is listed when new, when its status or implementation state changed, or when its approved text changed (every section digest except the implementation record's). Compatibility comes first: MSRV and edition, each reference plan's PlanId (a change stated as breaking under 3.6.4), superseded versions with end dates. Unit tests: what is listed and in what order, order independence of the inputs, a changed PlanId, an implementation-record-only change, decision-row parsing.
  • rustev-release changelog <out> [<previous tag>] (make changelog, PREVIOUS=<tag>): gathers those inputs at a clean commit (the previous corpus from the tag's tree via git archive, never from .statecraft/derived/ directly) and prints the changelog's digest.
  • candidate.sh: requires cargo-cyclonedx 0.5.9 exactly; run a's clean tree writes one CycloneDX 1.5 SBOM per crate member (all targets' dependencies) at the source date; the changelog of the candidate commit is generated as a step.
  • release-manifest.json's evidence map now carries each sbom-<member>.cdx.json and changelog.md digest; a missing one fails the candidate.
  • Spec 031: implementation record.

#143 has merged; this PR is rebased onto main.

Local verification (macOS arm64): cargo test -p rustev-release (all pass, changelog 5 unit tests), cargo clippy -p rustev-release --all-targets -D warnings, cargo fmt --check, sh -n candidate.sh; rustev-release changelog at one commit twice gives byte-identical output (47 specs for the first release, both reference PlanIds listed). cargo cyclonedx 0.5.9 run on the workspace writes <member>.cdx.json files with no serial number and the SOURCE_DATE_EPOCH timestamp. The full candidate with SBOMs runs at the release-candidate step; make gate, bash scripts/check-authored-content.sh.

Review round 1 (2 findings, fixed):

  1. A missing changelog.md was reported under "031 3.9"; each evidence file now carries its own clause (SBOMs 3.9.1, changelog 3.10).
  2. The SBOM lookup's first search (git ls-files --others --ignored) could never match, since the generated files are untracked but not ignored; it is removed, and the lookup is the find (outside target/) that always did the work.

Rebased onto #143's review rounds.

Review round 2 (2 findings, fixed):

  1. The changelog's temporary tree was left behind when git archive or tar failed (? returned first); the three steps are now chained and their result taken after the directory is removed.
  2. The SBOM lookup took the first find match. It now requires exactly one <member>.cdx.json outside target/ and fails naming the count and paths otherwise (cargo cyclonedx without --target-in-filename writes one per member, which the local run showed).

Rebased onto #143's round 4.

Review round 3 (3 findings, fixed):

  1. MSRV and edition came from the first member alone. The release policy already refuses a member that differs, and the changelog now also checks every member and refuses to state an MSRV the members disagree on.
  2. A failing cargo cyclonedx stopped the candidate with its output only in sbom.log; the log is now printed to stderr first.
  3. The implementation-record exclusion matched by substring, which would have excluded spec 031's own section 3-10-changelog-from-implementation-records from approved-text detection. It now matches implementation-record or a numbered <n>-implementation-record exactly; a unit test covers both anchors and the 3.10 section counting as text.

Review round 4 (2 findings: 1 fixed, 1 answered in the diff):

  1. "The commit may carry a trailing newline into the Markdown." command_line returns stdout.trim(), so it cannot; the generated changelog's first line showed the bare hash. A comment at the call now says so.
  2. Only one leading section number was stripped. is_implementation_record now drops every leading <digits>- group, so 3-2-implementation-record counts as the record too; the unit test covers it.

Review round 5 (3 findings, fixed):

  1. make changelog passed $(PREVIOUS) unquoted; it is now quoted when given and omitted when not (make -n shows both forms).
  2. The SBOM count counted lines of the path list; it now counts files (one character per file found), so no path content can change it (checked on a scratch tree with two matches: 2).
  3. The changelog's temporary tree used a PID-named path and removed it first; it now comes from mktemp -d (fresh, private), with nothing removed beforehand.

Rebased onto #143's round 5. Local note: the run of changelog against a previous ref after this change is waiting on this Mac's syspolicyd, which has held the freshly built binary in _dyld_start for 30 minutes; the first-release path ran earlier.

Review round 6 (3 findings, fixed):

  1. The SBOM was located by find (twice); each member's SBOM path now comes from its manifest directory in cargo metadata, so there is no search to race or miscount.
  2. Any git show failure for a previous PlanId read as "unchanged"; a golden absent at the previous release is None, and one present but unreadable (or without a plan_id) is an error.
  3. A spec whose only change was its amendment edges was omitted; a change of amends is now listed, with a unit test.

Rebased onto #143's round 6. Locally against origin/main as the previous ref (after round 5): 3 specs listed as changed, both PlanIds unchanged, and the temporary tree removed.

Review round 7 (2 findings, fixed):

  1. A removed spec was listed without its title; it now prints ### <id>: <title> from the previous registry, with a unit test.
  2. The candidate reads SBOM paths with Node; it now checks node is on PATH first and says so, rather than reporting a missing SBOM.

Local note: this Mac's syspolicyd currently holds new build scripts and test binaries in _dyld_start for 30 minutes or more, so the new unit test is verified by CI on this push.

Review round 8 (1 finding, answered in the diff): "render(&inputs()) compared with a is a tautology." It is the repeatability check 3.10 asks for (a second run on the same inputs gives identical bytes); the next assertion is the order-independence one. Both now carry a comment and an assertion message saying which is which.

Review round 9 (1 finding, fixed): a plan check golden at HEAD without a plan_id was skipped silently while the same condition at the previous release was an error; both are errors now (every plan check golden carries one).

Review round 10 (1 finding, mistaken, answered in the diff): "cargo cyclonedx needs --workspace in a virtual workspace." The pinned cargo-cyclonedx 0.5.9 has no such flag: cargo cyclonedx --workspace exits with "unexpected argument '--workspace' found". Run at the root of this virtual workspace, it writes <name>.cdx.json beside every member's manifest (the local run did, for every member). The candidate then requires each release member's file by its cargo metadata path and fails if one is missing. A comment at the call now says so.

Rebased onto #143's rebase onto main.

Review round 11 (2 findings, fixed):

  1. make changelog ran cargo run ... field target twice in one line; it now resolves the target directory once into a shell variable and uses it for both the binary and the output path.
  2. A cargo metadata failure in the SBOM step surfaced as "no SBOM generated": the metadata is now read once before the loop with an explicit failure message, and a failed path lookup for a member says so.

Rebased onto #143's round 8.

Review round 12 (1 finding, mistaken, answered in the diff): "${PREVIOUS:-} passes "" when unset." Unquoted, an empty expansion is removed by field splitting and passes no argument: sh -c 'set -- ${PREVIOUS:-}; echo $#' prints 0. So the first-release form (changelog <out>) runs. A comment at the call now says this is deliberate.

Rebased onto #143's round 9.

Rebased onto #143 after #146 (profile revision 17, spec-spine 0.31.0): derived shards regenerated with 0.31.0.

Review round 13 (1 finding, fixed): a member absent from cargo metadata gave an empty directory and the message "expected /.cdx.json"; the lookup now fails, and the candidate says "cargo metadata lists no package ".

Rebased onto #143's round 12.

Rebased onto main after #143 merged (derived shards only).

Review round 14 (2 findings, fixed):

  1. make changelog spliced $(PREVIOUS) into the recipe's text; the recipe now reads it from the environment (${PREVIOUS:+"$PREVIOUS"}; make exports command-line variables), so its contents are never shell syntax. Checked with a scratch Makefile: PREVIOUS='a"b; echo pwned' arrives as one literal argument.
  2. SPEC_SPINE could point the changelog at any binary; the generator now accepts a spec-spine only when --version equals the exact pin in spec-spine.toml (=0.31.0), whichever path supplies it.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff across the six changed files.


1. Misleading error label in manifest for missing changelog.md

tools/rustev-release/src/main.rs (added block inside manifest):

for name in sboms.chain(["changelog.md".to_string()]) {
    let bytes =
        std::fs::read(dir.join(&name)).map_err(|e| format!("031 3.9: {name}: {e}"))?;

The comment above the block says "3.9.1 and 3.10", but the error prefix is hard-coded as "031 3.9" for every item in the loop, including changelog.md. When changelog.md is missing the emitted error will say "031 3.9: changelog.md: …" instead of "031 3.10: …". That makes triage confusing because 3.10 is the changelog spec, not 3.9.


2. SBOM primary search uses a depth-1 glob that will miss workspace-layout paths

tools/rustev-release/candidate.sh (new block for run a):

f=$(git ls-files --others --ignored --exclude-standard -- "*/$p.cdx.json" | head -n 1)

cargo-cyclonedx writes each SBOM adjacent to its crate's Cargo.toml, e.g. crates/rustev-core/rustev-core.cdx.json (two path components deep). In git pathspec syntax * does not cross a directory separator, so */$p.cdx.json only matches one level deep and will never match these paths. The search returns nothing, falls through to the find fallback, and only then locates the file correctly. The find call does work (cargo-cyclonedx does not place files under target/), so the fallback saves the build, but the primary search is always a no-op for the actual directory layout and the log line it produces is misleading.


No other material bugs found. The exit 1 inside the run-a subshell is safe because set -e (evident from trap cleanup EXIT and the existing package-step pattern that already relies on the same propagation) causes the outer script to abort on a non-zero subshell exit. The approvals parsing, render determinism, cleanup of the temp tree on error paths, and the Makefile $(PREVIOUS) expansion are all correct.

{"head": "8732d3cb7e5082a2ff92b2b91aafb9189865809e", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/main.rs", "line": 647, "summary": "Error label for a missing changelog.md says '031 3.9' but changelog is spec 3.10, making failure messages misleading during debugging."}, {"path": "tools/rustev-release/candidate.sh", "line": 98, "summary": "SBOM primary search uses the depth-1 glob '*/$p.cdx.json' which never matches the actual two-level workspace paths (e.g. crates/foo/foo.cdx.json), so the search always silently falls through to the find fallback."}]}

Subject: b959ac9...8732d3c, diff digest 69f4e0ab5070e3bf455c6d8a8353b212c14cc41f731ee487f76b2cf6e469497e, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 13:37 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Looking at the changed files for bugs, security issues, and inconsistencies.

Makefile -- $(PREVIOUS) expands to empty string when unset, and because it is unquoted the shell drops it entirely, so no spurious empty-string argument reaches the binary. Correct behavior, no issue.

changelog.rs -- approvals(): s.id.split('-').next() extracts only the leading number (031) and the substring check text.contains("ratified spec \031`") is terminated by the closing backtick, so a decision text like "approved spec \0310`" cannot match 031. Logic is sound.

main.rs, changelog() -- temp-dir leak on early return (line ~503-516 in the new block):

command_line("git", &["archive", "--output", &archive, tag])?;  // early return here …
command_line("tar", &["-xf", &archive, "-C", &dir_s])?;        // … or here
let r = registry(&dir_s);
let _ = std::fs::remove_dir_all(&dir);   // never reached on the two ? above
r?

If either shell command fails, ? returns before remove_dir_all is called. The directory at $TMPDIR/rustev-changelog-<pid> is left behind. For a long-running CI environment this accumulates; for a release tool that may be retried on a network hiccup it is confusing. A scopeguard-style drop or restructuring the control flow would fix it.

candidate.sh -- find | head -n 1 silently picks an arbitrary file when multiple SBOMs match (line ~97):

SOURCE_DATE_EPOCH=$epoch cargo cyclonedx --format json --spec-version 1.5 --target all \
  >"$out/sbom.log" 2>&1
for p in $packages; do
    f=$(find . -name "$p.cdx.json" -not -path './target/*' | head -n 1)

--target all asks cargo-cyclonedx to enumerate every target triple; depending on workspace layout and the tool's output convention the command may write multiple <crate>.cdx.json files (one per target, in per-target subdirectories). head -n 1 would silently select whichever find returns first (filesystem-order), producing a non-reproducible, potentially incomplete SBOM evidence entry. The error branch (-z "$f") only triggers when no file was generated; multiple-file cases go undetected. At minimum the result should be verified to be exactly one file and its path deterministic; alternatively, expect a single canonical location and error if it is absent.

{"head": "5261a656063a2248169e03771daba0eb292a5191", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/main.rs", "line": null, "summary": "Temp directory created for git-archive extraction is not cleaned up when git-archive or tar fails because the early-return via ? runs before the remove_dir_all call."}, {"path": "tools/rustev-release/candidate.sh", "line": 97, "summary": "find | head -n 1 silently selects an arbitrary SBOM when cargo-cyclonedx --target all emits multiple files per crate, making the SBOM evidence entry non-reproducible and potentially wrong without any error."}]}

Subject: 5c58688...5261a65, diff digest 2e8ace7cba20900f725c14c522a1ca1f2288d899d1bc8a522c05ec1fdb1a48c4, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 13:41 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the six changed files for bugs, security problems, and spec inconsistencies.

tools/rustev-release/src/main.rs

The changelog() function reads MSRV and edition from only the first upload-order member:

let first = meta.packages.iter()
    .find(|p| Some(&p.name) == set.upload_order.first())...;
...
msrv: first.rust_version.clone().unwrap_or_else(|| "unknown".into()),
edition: first.edition.clone(),

The spec text says "MSRV and edition from the members' manifests" (plural). If any non-first member specifies a stricter rust-version, the changelog silently reports the first member's MSRV and could understate the true minimum requirement for the release.

tools/rustev-release/candidate.sh

The cargo cyclonedx invocation redirects both stdout and stderr to $out/sbom.log. If the tool fails and set -e is active (as implied by the trap cleanup EXIT pattern), the script exits at that line without surfacing the error to stderr; the operator must open the log to learn why. The count-check safety net ($count -ne 1) is never reached in that case. The error message to the user (031 3.9.1: ...) refers to count, not the upstream cargo failure, making diagnosis harder.

tools/rustev-release/src/changelog.rs

The approvals parser splits table rows on | and takes columns by index. This works correctly for the current table format, but any row containing a literal pipe inside a cell would silently misparse. The existing test corpus exercises the happy path and the 0310 false-positive case, but the parser would give wrong results for such rows without any diagnostic. This is a known limitation inherent to naive pipe-splitting of Markdown tables.

The text_digests filter uses .contains("implementation-record") rather than exact-key equality. Any future section whose anchor coincidentally contains that substring would be excluded from change detection. Minor, but fragile.

Makefile

The changelog target invokes cargo run --quiet --locked -p rustev-release -- field target twice (once for the binary path, once for the output path). Both executions re-enter cargo (even if already built), but more importantly they produce independent outputs; if the target directory somehow changed between the two subshells (e.g., parallel cargo invocations), the binary and the output path would disagree. In normal sequential use this is benign, but the pattern is unnecessary: the target directory could be captured once into a variable.

tools/rustev-release/src/lib.rs / specs/031-public-api-and-release-family/spec.md

No issues found.

{"head": "2e95b4d7215e89e02a445843bd56e1c4d95cc4d4", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/main.rs", "line": null, "summary": "MSRV and edition are read from only the first upload-order member; if any other member specifies a stricter rust-version, the changelog silently reports a lower MSRV than the release actually requires."}, {"path": "tools/rustev-release/candidate.sh", "line": null, "summary": "cargo cyclonedx output is captured entirely to sbom.log; a build failure exits the script (via set -e) without printing the underlying error to stderr, making the failure cause opaque without examining the log."}, {"path": "tools/rustev-release/src/changelog.rs", "line": 44, "summary": "text_digests filters sections using .contains(\"implementation-record\") rather than exact key matching, so any future section anchor that happens to include that substring would be silently excluded from approved-text change detection."}]}

Subject: f6a22ef...2e95b4d, diff digest 72f25f41c515443c5befdb11d4dcc3a2054cdecbbf6698878f857c102e07d79b, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 13:49 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Review

tools/rustev-release/src/main.rs — commit SHA trailing newline

In changelog(), the commit SHA is captured via:

let commit = command_line("git", &["rev-parse", "HEAD"])?;

git rev-parse HEAD terminates its output with a newline. If command_line does not trim stdout (it is used elsewhere for JSON parsing where trailing whitespace is silently ignored by serde_json, so trimming is not forced by existing callers), then i.commit contains a trailing \n. The Markdown rendered by render() would be:

Generated from the governed corpus at commit `136f760627...e006
`, since `v0.1.0` (spec 031, 3.10).

This breaks the inline code span. The unit test in changelog.rs uses the hard-coded value "abc", so it would not catch this. The two-runs-same-bytes property still holds (both runs produce the same broken text), so neither the determinism check nor the digest comparison would surface it.

tools/rustev-release/src/changelog.rs — is_implementation_record misclassifies multi-level section numbers

is_implementation_record strips only the leading digit run and one dash:

let rest = anchor.trim_start_matches(|c: char| c.is_ascii_digit());
let rest = if rest.len() < anchor.len() {
    rest.strip_prefix('-').unwrap_or(rest)
} else {
    rest
};
rest == "implementation-record"

For an anchor like "3-10-implementation-record":

  • trim_start_matches(digits) yields "-10-implementation-record" (stops at the first -)
  • strip_prefix('-') yields "10-implementation-record"
  • "10-implementation-record" != "implementation-record" → returns false

The function therefore treats "3-10-implementation-record" as approved text rather than an implementation-record section, so a change to that section would incorrectly be flagged as an approved-text change. The doc comment and tests only cover the single-prefix form ("<n>-implementation-record"), so this is a latent correctness bug if specs ever use two-level section numbers for implementation records.


{"head": "136f760627feb905b87fab3492ae7a89d7b1e006", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/main.rs", "line": 498, "summary": "git rev-parse HEAD output includes a trailing newline; if command_line does not trim stdout, i.commit embeds a newline in the backtick code span of the generated Markdown, corrupting every changelog produced."}, {"path": "tools/rustev-release/src/changelog.rs", "line": 56, "summary": "is_implementation_record strips only one leading digit-run and one dash, so anchors of the form \"<n>-<m>-implementation-record\" return false and are incorrectly treated as approved text, causing spurious approved-text-changed entries in the changelog."}]}

Subject: f6a22ef...136f760, diff digest bd94d166e9347e8cec66011eed212de83fece9a8118f489b250233489020b6b4, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 14:03 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Looking at the six changed files for bugs, security problems, and inconsistencies:

Makefile – changelog target

The target invokes cargo run --quiet --locked -p rustev-release -- field target twice in a single shell line to derive the binary path and the output path. Both calls are unguarded; if the first succeeds and the second fails (unlikely, but possible under disk pressure), the recipe silently exits with a non-zero status but no error message explaining which substitution failed. The bigger practical issue is that $(PREVIOUS) is expanded without shell quoting:

"$$(cargo run --quiet --locked -p rustev-release -- field target)/debug/rustev-release" \
  changelog "..." $(PREVIOUS)

A PREVIOUS value with embedded spaces would be word-split by the shell and reach rustev-release as two arguments rather than one, causing an "unknown command" exit. Git tags never contain spaces in practice, but the target should quote the expansion ("$(PREVIOUS)") for robustness.

candidate.sh – SBOM count using grep -c .

found=$(find . -name "$p.cdx.json" -not -path './target/*')
count=$(printf '%s' "$found" | grep -c . || true)

grep -c . counts non-empty lines, not files. If cargo-cyclonedx ever emits a path that contains a literal newline (impossible for real package names, but not guarded against), count would be inflated by 1 per embedded newline, causing a false "not exactly one" failure. A more robust check would use wc -l or a loop. Low risk given the crate-naming constraints, but fragile.

main.rs – predictable temp directory in changelog()

let dir = std::env::temp_dir()
    .join(format!("rustev-changelog-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir)…

The directory name is derived from the PID, which is predictable. A concurrent second invocation of rustev-release changelog (e.g., triggered by a CI retry) will share the same path, and the leading remove_dir_all of one run will silently destroy the other's in-progress archive extraction. For a sequential release tool this is low-risk, but the race window between remove_dir_all and create_dir_all also enables a symlink-based path-traversal on a shared machine (though git archive output itself is safe). Using tempfile::TempDir or a nonce suffix would eliminate both concerns.

changelog.rs – approvals matching is conservative but correct

The pattern `031` vs `0310` is correctly distinct because the backtick delimiter prevents prefix matches. No false-positive risk found.

render() – determinism

Removed specs come from before.keys() (a BTreeMap), which iterates in sorted order. The test rendering_is_deterministic_and_order_independent doesn't exercise removals, but the implementation is still correct.

changelog.rs is_implementation_record – correct

Traced all four test anchors; the stripping loop correctly handles numbered prefixes and doesn't strip non-numeric components.

{"head": "576b3907acdb2b5af5bb6fb03d1d63f8150ad895", "verdict": "findings", "findings": [{"path": "Makefile", "line": 78, "summary": "$(PREVIOUS) is unquoted in the shell recipe, so a value with spaces would be word-split into multiple arguments; use \"$(PREVIOUS)\" for safety."}, {"path": "tools/rustev-release/candidate.sh", "line": 101, "summary": "SBOM count uses `grep -c .` (line count) rather than a file count, so a path containing an embedded newline would inflate count and trigger a false failure."}, {"path": "tools/rustev-release/src/main.rs", "line": 502, "summary": "The temp directory for git-archive extraction is named by PID alone; concurrent invocations race on the same path, and the leading remove_dir_all creates a symlink-attack window on shared machines."}]}

Subject: f6a22ef...576b390, diff digest a1efcf8fecf54a7d577a8f18e949c56e0cbd97115fb99a339d128b72adccad1c, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 14:20 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/031-checks branch 2 times, most recently from 37f0d57 to 8840641 Compare October 21, 2026 14:46
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff across all five changed files for bugs, security issues, and inconsistencies.


tools/rustev-release/candidate.sh — TOCTOU in SBOM file discovery

Lines ~109-114: found and count come from two separate find invocations with no atomic guarantee between them. If a .cdx.json file is created or deleted in the worktree window between the two calls, count could be 1 while found holds zero or two paths (or vice versa). When count passes the guard but found is empty, cp "$f" … silently attempts cp "" …; when found has two paths, the trailing newline causes cp to fail with a confusing path-not-found error rather than the "not exactly one" diagnostic.

tools/rustev-release/src/main.rs — silent swallow of git show errors for plan IDs

Around the plan-identity loop (approx. line 580 in the diff):

let before = previous
    .and_then(|p| command_line("git", &["show", &format!("{p}:{path}")]).ok())
    .and_then(|t| plan_id(&t));

.ok() is appropriate for the "file didn't exist in the previous release" case, but it also swallows real git errors (bad ref, corrupt object, permission problem). In those cases before becomes None, the changed vec stays empty, and render outputs "no reference plan's PlanId changed" even if the identity actually changed — silently masking a breaking-change flag under 3.6.4.

tools/rustev-release/src/changelog.rs — change() does not detect amends edge differences

change() checks status, implementation, and text_digests(), but not amends. A spec whose only change is gaining or losing an amendment edge produces change(…) = None and is dropped from the changelog entirely, even though amends is rendered in the entry for any spec that does appear. Per the spec prose the trigger list is exhaustive (new | status | implementation | approved text), so this may be intentional, but it means the output can list stale amendment edges without warning.


{"head": "3f31e07725d38d46ce27d716782058562972fa48", "verdict": "findings", "findings": [{"path": "tools/rustev-release/candidate.sh", "line": 109, "summary": "Two separate `find` invocations for `found` and `count` introduce a TOCTOU race: if a file appears or disappears between the two calls, `count` can be 1 while `found` holds an inconsistent (empty or multi-path) result, causing a wrong copy or a misleading error message."},{"path": "tools/rustev-release/src/main.rs", "line": null, "summary": "`.ok()` on the `git show` call that reads a plan's previous `plan_id` silently converts any git error into `before: None`, which causes the changelog to report no plan-identity change even when the PlanId actually changed, masking a breaking-change flag."},{"path": "tools/rustev-release/src/changelog.rs", "line": 134, "summary": "`change()` does not compare the `amends` field, so a spec whose only diff is gaining or losing amendment edges is omitted from the changelog entirely, even though `amends` is rendered in entries that do appear."}]}

Subject: 8840641...3f31e07, diff digest f20334726392e87f5e41b747096c37ff242ca2de7a7c7868564f942944efa5b5, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 15:03 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the six changed files for bugs, security problems, and inconsistencies.


Makefile – changelog target

$(if $(PREVIOUS),"$(PREVIOUS)")

When PREVIOUS is set, this produces the shell word "v0.1.0" (with quotes), which the shell interprets correctly. When unset it produces nothing. No issue.


candidate.sh – SBOM resolution via inline Node

dir=$(cargo metadata --format-version 1 --no-deps --locked | P="$p" node -e '...')

node is never checked for presence before use. If it is absent, dir evaluates to empty string and the subsequent error message says "no SBOM was generated for $p (expected /$p.cdx.json)", which is misleading – the actual cause is a missing runtime, not a missing SBOM. The cyclonedx_pin pre-check is well-guarded, but this dependency is not.


changelog.rs – render: removed-spec section header

Lines ~235-239 (inside render):

for id in &removed {
    any = true;
    out += &format!("### {id}\n\n- removed from the corpus.\n\n");
}

New and changed specs emit ### {id}: {title}, but removed specs emit only ### {id} with no title. The before map (BTreeMap<&str, &Spec>) holds the full Spec struct (including title) for every ID in that loop, so the title is available. The inconsistency means removed-spec sections look structurally different from all other sections and the human-readable title is silently dropped.


changelog.rs – approvals: spec-number matching

let number = s.id.split('-').next().unwrap_or("");
let named = [format!("ratified spec `{number}`"), ...];

Because the closing backtick is part of the pattern, the match cannot fire on "approved spec \0310`"when the spec number is031` – verified by both the test and manual analysis. No false-positive risk with the current three-digit scheme.


changelog.rs – is_implementation_record and rendering_is_deterministic_and_order_independent

Both are correct. The first assertion in the determinism test (assert_eq!(a, render(&inputs()))) re-constructs fresh original inputs, testing that two calls on identical inputs agree; the second (assert_eq!(a, render(&i))) tests order-independence. No issue.


main.rs – changelog function

git status --porcelain --untracked-files=no correctly limits the dirty-tree check to tracked files. The mktemp -d call uses XXXXXX entropy. Arguments to git archive and tar are passed as &[&str], not through a shell, so no injection path. Logic is consistent with the spec.

{"head": "f89344ab726591d833eb842a1df0180f72771761", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/changelog.rs", "line": 237, "summary": "Removed-spec entries in render() emit '### {id}' with no title, inconsistent with new/changed entries that emit '### {id}: {title}'; the full Spec (including title) is available in the `before` BTreeMap and should be used."}, {"path": "tools/rustev-release/candidate.sh", "line": 99, "summary": "The SBOM directory is resolved by piping cargo metadata to an inline Node.js script with no prior check that `node` is in PATH; if node is absent the failure message blames a missing SBOM file rather than the missing runtime."}]}

Subject: 3451a98...f89344a, diff digest f17290d2d7327b4c0309137f198c31d404b2f4a2368712d6914f9a43d034c02e, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 15:30 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the changelog generation feature across the five changed files.

Makefile

The changelog target invokes cargo run ... -- field target twice (once for the binary path, once for the output path), each time rebuilding if needed; redundant but not incorrect. The $(if $(PREVIOUS),"$(PREVIOUS)") construct correctly passes no argument when PREVIOUS is unset and passes the tag (quotes stripped by the shell) when set.

candidate.sh

  • Version pin check correctly handles "not installed" (empty stdout vs. expected string).
  • The P="$p" node -e '...' pattern safely passes the package name via the environment, avoiding injection.
  • [ -z "$dir" ] catches cases where Node.js produces no output (package not found or cargo metadata fails), though the error message would say "no SBOM" rather than "metadata failed" — a diagnostic quality issue.
  • SBOM generation is scoped to run=a subshell with cd "$wt", and cargo metadata runs in the same worktree, so the manifest path is correct.
  • step changelog.txt runs before step manifest.txt, so the changelog is present when the manifest hashes it.

changelog.rs

  • is_implementation_record: correctly strips leading \d+- segments then tests the remainder; edge cases (3-10-changelog-from-implementation-records) are validated by the unit test.
  • approvals: pattern "ratified spec \{number}`"includes the closing backtick, so031does **not** false-match0310` — the test at line 390 confirms this.
  • render: before.values() on a BTreeMap iterates in key (ID) order, so removed specs are emitted sorted without an explicit sort call — correct but implicit.
  • after is explicitly sorted before iteration — good for determinism.

test rendering_is_deterministic_and_order_independent (changelog.rs line ~325)

assert_eq!(a, render(&inputs()));   // calls inputs() not i
assert_eq!(a, render(&i));

The first assertion compares render(inputs()) with render(inputs()) — a tautology (same pristine input, not the mutated i). This is effectively dead coverage for the "deterministic on different-but-equivalent inputs" claim; the order-independence property is only tested by the second assertion. Not a runtime bug, but the test does not actually verify what its name says for the first assertion.

main.rs — changelog function

  • registry(".") then extraction into a mktemp -d temp dir and registry(&dir_s) for the previous tag is sound; remove_dir_all is called before r? so cleanup happens on both success and error paths.
  • The filter .filter(|n| n.ends_with(".check.json") && !n.contains("refus")) is a naming-convention dependency; fragile if a plan were named with "refus" in it, but acceptable for this codebase.
  • For the first release, git range is "HEAD" — correct per spec (all history).
{"head": "707b01522206d895241f5de0385c2775a177e479", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/changelog.rs", "line": 325, "summary": "The first assertion in `rendering_is_deterministic_and_order_independent` calls `render(&inputs())` instead of `render(&i)`, making it a tautology that tests nothing about determinism across equivalent-but-differently-ordered inputs."}]}

Subject: 4bb19af...707b015, diff digest 1f75a6688eec333bc7cc6fd0c91bf833784b5d6d7f669322a4dc10d6577351b1, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 16:00 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/031-checks branch 3 times, most recently from f98ebd1 to 8ba58f9 Compare October 21, 2026 18:11
@github-actions

Copy link
Copy Markdown

AI review (findings)

Looking at the diff, I'll examine each changed file for bugs, security issues, and inconsistencies.

tools/rustev-release/src/changelog.rs

  • is_implementation_record: correctly strips leading <digits>- prefixes and checks the remainder against "implementation-record". Tests cover edge cases including "3-10-changelog-from-implementation-records". Logic is sound.
  • approvals: extracts the numeric prefix with s.id.split('-').next().unwrap_or("") — safe because split on any string yields at least one element. Pattern matching is exact (backtick-delimited number), preventing cross-spec false positives.
  • render: removed specs iterate over BTreeMap::values() which is sorted, so output is deterministic even for removals. The ordering (changed/new before removed) is a policy choice and is not ambiguous.
  • No shell injection risk: all external commands go through Command::new with argument slices, bypassing the shell.
  • Temp-dir handling: mktemp -d creates a mode-0700 private directory with a randomized suffix; cleanup runs before propagating errors.

tools/rustev-release/candidate.sh

A concrete bug in the Node.js script used to locate each package's manifest directory:

dir=$(printf '%s' "$meta" | P="$p" node -e '
  ...
  if (m) process.stdout.write(require("path").dirname(m.manifest_path));
  ') || { echo "031 3.9.1: could not read $p's manifest path from cargo metadata" >&2; exit 1; }
f="$dir/$p.cdx.json"
if [ -z "$dir" ] || [ ! -f "$f" ]; then
  echo "031 3.9.1: no SBOM was generated for $p (expected $f)" >&2
  exit 1
fi

When the package name is not found in the metadata JSON, the Node script exits 0 (success) and writes nothing to stdout. The || branch does not fire. dir becomes the empty string, so f becomes "/$p.cdx.json" (an absolute path at the filesystem root). The [ -z "$dir" ] guard then correctly exits 1, but the error message reports "expected /$p.cdx.json" — a nonsensical path that obscures the real cause (package absent from workspace metadata). The script exits correctly, but the diagnostic is misleading.

tools/rustev-release/src/main.rs

  • changelog_cmd: digest is computed from the in-memory String bytes and printed, consistent with how manifest will later read the written file.
  • manifest addition: reads SBOM and changelog bytes from disk with sha256_hex, correctly chaining SBOM entries for all upload_order members plus changelog.md; a missing file produces an error, meeting spec 031 3.9.1/3.10.

Makefile

  • $(if $(PREVIOUS),"$(PREVIOUS)"): when PREVIOUS is unset or empty, Make's if treats it as false and emits nothing; when set, emits "v0.1.0" which the shell strips to v0.1.0. Correct.
  • Double cargo build + cargo run is redundant but harmless and consistent with patterns elsewhere.

specs/031-public-api-and-release-family/spec.md

Increment 3 text accurately describes the implemented behavior (pure function, two-run digest identity, SBOM per member from run a, manifest evidence requirements).


{"head": "87f71247bbf398efce35a1ac834a527ae4034390", "verdict": "findings", "findings": [{"path": "tools/rustev-release/candidate.sh", "line": 115, "summary": "When a package name is absent from cargo metadata, the Node.js script exits 0 and writes nothing, so `dir` becomes empty and the subsequent error message reports a nonsensical expected path (`/$p.cdx.json`) instead of the package's actual manifest directory."}]}

Subject: 8ba58f9...87f7124, diff digest 731de1ddd6dc6ac8c5c39df268dd71d114af97858c8eb9bda629170ad903457f, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 21, 2026 18:15 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR, which adds rustev-release changelog subcommand, SBOM generation in make release-candidate, and supporting spec text in spec 031.

changelog.rs — is_implementation_record: Logic correctly strips leading digit-dash prefixes before comparing to "implementation-record". All documented edge cases (6-implementation-record, 3-10-changelog-from-implementation-records, etc.) are handled correctly.

changelog.rs — approvals: The backtick-delimited pattern "approved spec \{number}`"prevents prefix false-positives (e.g., spec03 does not match on the string "approved spec \031`" because the backtick after 03 is the discriminator). The test confirms 0310 does not match 031.

changelog.rs — render: Output is deterministic: BTreeMap for before gives sorted iteration for removed specs; the plans Vec is explicitly sorted before emission; after is sorted before iteration. The any flag prevents an empty Specifications section.

main.rs — changelog: The temp directory is created with mktemp -d (mode 0700, unpredictable path). remove_dir_all runs unconditionally (success and error), leaving no residue. The GIT_* variable clearing in command_line is correctly applied to all git invocations, including the --repo <temp_dir> spec-spine call.

candidate.sh — SBOM flow: cargo cyclonedx runs inside the worktree subshell before cargo metadata; the Node script obtains absolute manifest paths from metadata, then derives the per-member .cdx.json path, with an explicit error when metadata omits a package. The $out variable is in scope through the subshell. SBOMs are copied to $out before step manifest.txt, so the manifest step can hash them.

Makefile — changelog target: $(if $(PREVIOUS),"$(PREVIOUS)") correctly produces no argument when PREVIOUS is unset. The generated file lands in $t/changelog.md (cargo target dir); this is an unusual output location for a standalone make target but does not affect correctness and is distinct from the make release-candidate path where $out/changelog.md is used.

Redundant filter: !n.contains("refus") in the plan-id discovery loop is dead code because the *.check.json suffix filter already excludes all refusal-NN.json files. Not a correctness defect.

No concrete bugs, security problems, or governance inconsistencies found.

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

Subject: 2434e49...8eafab3, diff digest f9e5f1000ad0a3e86eb73ca122803615a2cdd5eb92b7b8f3107b6ae3ba9c4aff, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/031-checks branch 2 times, most recently from da2933e to 8ff8e80 Compare October 21, 2026 18:38
Base automatically changed from impl/031-checks to main October 21, 2026 18:58
@github-actions

Copy link
Copy Markdown

AI review (findings)

Review

Finding 1 — Makefile: shell injection via PREVIOUS

In the new changelog target:

t="$$(cargo run --quiet --locked -p rustev-release -- field target)" && "$$t/debug/rustev-release" changelog "$$t/changelog.md" $(if $(PREVIOUS),"$(PREVIOUS)")

Make expands $(PREVIOUS) textually before the shell sees the line, so a value containing a double-quote escapes the shell quoting context. For example:

make changelog PREVIOUS='v0.1.0" && evil_cmd #'

expands to:

… changelog "…/changelog.md" "v0.1.0" && evil_cmd #"

Compare candidate.sh line 176, which handles the same variable safely with unquoted word-expansion:

step changelog.txt "$release" changelog "$out/changelog.md" ${PREVIOUS:-}

The Makefile should follow the same pattern or pass through a shell variable instead of interpolating Make text directly into the quoting context.

Finding 2 — main.rs: SPEC_SPINE env-var overrides the pinned binary

The new function:

fn spec_spine() -> String {
    std::env::var("SPEC_SPINE").unwrap_or_else(|_| ".bin/spec-spine".to_string())
}

allows any binary on the runner to be substituted for the workspace-pinned .bin/spec-spine. AGENTS.md is explicit: "A different version on PATH proves nothing." The same requirement applies here — a SPEC_SPINE override in a CI environment variable can supply a crafted binary that produces a fraudulent registry listing, undermining the integrity guarantee of the generated changelog artifact (031 3.10: "a pure function of those inputs"). The function should use the pin unconditionally.


{"head": "b77a39f051ae918b78e566c60b4d4d90b8c67aa1", "verdict": "findings", "findings": [{"path": "Makefile", "line": 78, "summary": "PREVIOUS is interpolated directly into shell quoting context via Make text expansion, allowing shell injection when the value contains a double-quote character."}, {"path": "tools/rustev-release/src/main.rs", "line": 447, "summary": "spec_spine() honours a SPEC_SPINE environment variable, letting any binary substitute for the workspace-pinned spec-spine and undermining the changelog's integrity guarantee."}]}

Subject: 7d65c1b...b77a39f, diff digest 1c79b99bb6e7519ac92a21174e562502447e2150a5dd219d2c642f7d32e0a5e6, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception October 21, 2026 19:02 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the six changed files for concrete defects.


tools/rustev-release/src/changelog.rs — render: removed specs appended after changed specs, not merged in ID order

render sorts the after slice by spec ID before emitting changed/new entries (around line ~225 of the new file). Removed specs are then appended from before.values() (BTreeMap order, also sorted by ID), but as a separate trailing block rather than merged into the sorted output. A removed 001-* spec will appear after a changed 048-* spec. The test only_changed_specs_are_listed_in_id_order only asserts relative order among the changed entries; it does not cover the combined ordering of changed and removed entries. The claim "two runs at one commit produce identical bytes" holds (both BTreeMap traversals are deterministic), but the ordering diverges from the implied unified-by-ID presentation.

specs/031-public-api-and-release-family/spec.md — incorrect spec count in increment 3

The new text reads: "For the first release it lists all 47 specs." The repo context at the base commit lists spec-registry shards for 000-bootstrap through 048-statecraft-profile-17-and-spec-spine-0-31 — that is, 49 entries total, 48 non-bootstrap (001–048). Neither 47 nor 49; the count is off by one relative to the corpus at this commit.


No security issues found. The mktemp-based temp directory, the P="$p" node -e env-variable injection pattern, and the command_line GIT_* variable clearing are all handled correctly. The is_implementation_record anchor logic and the approvals substring matching (backtick-bounded IDs prevent false matches like 031 ⊂ 0310) are correct.

{"head": "b77a39f051ae918b78e566c60b4d4d90b8c67aa1", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/changelog.rs", "line": 244, "summary": "Removed specs are appended after all changed/new specs rather than merged in combined ID order, so a low-numbered removed spec appears after higher-numbered changed specs in the generated markdown."}, {"path": "specs/031-public-api-and-release-family/spec.md", "line": 724, "summary": "Increment 3 states 'all 47 specs' for the first release, but the corpus at this commit contains 48 non-bootstrap specs (001–048), making the count incorrect by one."}]}

Subject: 7d65c1b...b77a39f, diff digest 1c79b99bb6e7519ac92a21174e562502447e2150a5dd219d2c642f7d32e0a5e6, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception October 21, 2026 19:04 — with GitHub Actions Inactive
rustev-release changelog generates the release changelog from spec-spine registry queries at HEAD and at the previous tag, with the compatibility facts of 3.6 and 3.7; deterministic over fixed inputs.
@bartekus
bartekus enabled auto-merge (squash) October 21, 2026 19:10
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing each changed file in turn.

Makefile

The $${PREVIOUS:+"$$PREVIOUS"} expansion is correct: in the recipe shell, ${PREVIOUS:+"$PREVIOUS"} passes the tag as a properly-quoted argument when set, and nothing (not an empty string) when absent. The double-build (cargo build then cargo run -- field target) is redundant but harmless.

specs/031-public-api-and-release-family/spec.md

Increment text is internally consistent with the implementation. The claim "For the first release it lists all 47 specs" is documentation, not a code path — not flagging it.

tools/rustev-release/candidate.sh

The Node inline script passes the package name via process.env.P (not interpolated), so no injection. cargo metadata is run inside the worktree subshell, giving absolute paths. The ${PREVIOUS:-} unquoted expansion for the step changelog.txt call is intentional (the SC2086 disable is correct: an empty expansion disappears entirely, invoking the first-release form). The SBOM-only-in-run-a guard is spec-correct. Cleanup: the EXIT trap plus set -e (standard in this script style) covers the worktree on SBOM failure.

tools/rustev-release/src/changelog.rs

is_implementation_record: Strips leading <digits>- prefixes and compares the tail to "implementation-record". All four test cases (implementation-record, 6-implementation-record, 3-2-implementation-record, 3-10-changelog-from-implementation-records) resolve correctly.

change: checks status, implementation, text digests (with implementation-record excluded), and amends (sorted before compare). The what.join("; ") is in a fixed order, so the output is deterministic.

render: plans sorted by name, specs sorted by id, superseded sorted, removed specs iterated from a BTreeMap (sorted by key). Two-runs test covers byte-identical output.

approvals: The pattern `031` (backtick-delimited) correctly rejects `0310` — the backtick after 031 prevents the substring match. The A- prefix filter correctly excludes R- rows.

tools/rustev-release/src/main.rs

spec_spine(): reads pinned version from spec-spine.toml, compares against --version output. Rejects mismatched binary. Called each time registry is called (twice if there is a previous tag), which re-reads the toml — redundant but correct.

changelog(): mktemp -d with a non-predictable suffix, mode 0700, cleaned up unconditionally before r? propagates. git archive / tar / registry all run on the extracted tree. command_line (existing function) clears GIT_* variables, preventing environment injection. Plan-id extraction uses git cat-file -e to test existence before git show; absent-at-previous-release → None, present-but-missing-field → error. The superseded: Vec::new() matches the spec's "none so far."

No defect found.

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

Subject: 7d65c1b...7484476, diff digest 268e8fbff620fb41e236ef642829606bd1309e2ac88a3ca46eb590052967ef1f, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit 2d6a1f2 into main Oct 21, 2026
7 checks passed
@bartekus
bartekus deleted the impl/031-changelog branch October 21, 2026 19:29
bartekus added a commit that referenced this pull request Oct 21, 2026
Spec 026, increments 1 and 2: live re-execution of a recorded decision
shape as a new decision, behind a host authorization seam, and its
comparison with the verified historical case.

- `crates/rustev-contract` (`src/live.rs`, new): the
`rustev.live-reexecution/1` document (`LiveReexecution`): the new
decision, plan and computed snapshot identities, evaluation time, opaque
subject and scope, the historical case as a `HistoricalLink`
(identities, evaluation time and the bundle's record digest, never
content) or explicit `none`, admission, the new run record's digest,
termination and cost summary, one `LiveEffect` per proposed external
attempt (with the host's `AuthorizationReference` or the typed refusal,
and the dispatch observation), unreconciled attempts, delivery, capture
and retention posture, and the comparison section. `check` bounds every
list and free text and refuses an effect or liability not attributable
to the new decision, or a new decision id equal to the historical one.
`AuthorizationRequest` and its tagged digest
(`rustev.live-authorization/1`) bind an answer to exactly one attempt;
refusals are `missing`, `expired`, `mismatched`, `errored` and
`refused`.
  - `tests/live.rs`: bounds, refusals, digest binding and round trips.
- `crates/rustev-runtime` (`src/live.rs`, new; `src/driver.rs`):
`Runtime::reexecute_live(plan, LiveRequest, &dyn LiveAuthorizer,
cancel)`, the only function that takes an authorizer. Before admission
it refuses a reused historical decision id, a snapshot whose computed
`SnapshotId` differs from the stated one, an invalid capture
configuration, an out-of-range historical decision id, and a plan whose
worst-case attempts exceed the document bound. It then runs an ordinary
spec 003 decision; in the attempt driver, after the full worst-case
reservation and the deadline and cancellation re-check, the host is
asked about that exact attempt (a panic is contained as `errored`). An
allow counts only if it names the presented digest and is still valid by
the runtime clock. A refusal releases the reservation, sends nothing and
stops the request; retries and fallbacks are each authorized again.
- `tests/live.rs`: section 5 rows 2 to 6 and 9; allow, refusal,
mismatch, error, panic, expiry, retry, fallback, cancellation, unknown
charge, possibly continuing work and sink failure with exact attempt
attribution; exact steps still judge when the host refuses all external
work; cache and batch bypass; capture. Compile-fail examples show
`decide` and `decide_with_capture` take no authorizer.
- `crates/rustev-eval` (`src/live.rs`, new): `compare_live(LiveCase)`, a
pure function over host-supplied documents. It refuses a document that
does not check, an unbound run record, a plan that is not the
document's, and a bundle other than the linked one; verifies the
historical case by spec 004 reproduction (an unavailable item makes the
comparison `unavailable`, nothing restored); then reports `agreement`,
`live-diverged` (`proposal_changed` or `unresolved_category_changed`) or
incomparable, with snapshot, plan, evaluation-time, artifact, backend,
definition, policy, calibration, runtime count, cost, termination,
cancellation, remote-state, retention and delivery differences reported
apart. `with_comparison` returns a copy; no source is modified.
- `tests/live.rs`: section 5 rows 1, 7 and 8; byte-identical sources
after a live run and its comparison; a source scan showing eval names no
runtime, backend or authorizer.
- Mutation seeds: eight `live:` seeds in
`crates/rustev-runtime/mutation/seeds.py` and two `live-comparison`
seeds in `crates/rustev-eval/mutation/seeds.py`; all ten detected.
- `Makefile`: 026 joins `VERIFIED_SPECS`.
`tools/rustev-release/archive-policy.json`: the new source files in the
contract, runtime and eval archives.
- Spec 026: implementation record. Derived shards regenerated.

What remains: the comparison reports the first unavailable item
reproduction meets, not every item; served identity stays `unknown`
until a run record carries it; the live document's later members (spec
043 3.9) are not part of this implementation.

Owner decisions (engineering choices made within the spec, open to
review; see the implementation record):
- E-26-1: an authorization refusal is typed in the live document, and
the core is supplied `backend_unavailable` with detail
`authorization_refused: <refusal>` (the spec 003 3.6.4 form). Spec 002's
four runtime reasons, `rustev.run/1` and the core are unchanged.
- E-26-2: the authorizer is synchronous and lives in `rustev-runtime`,
not in the core seams; its answer is neither serializable nor clonable,
and only its reference is kept. Validity is a duration judged by the
runtime's clock.
- E-26-3: live runs bypass the memory cache and general batching (a
diagnostic says so when the plan enables either); each attempt is fresh
work, authorized on its own.
- E-26-4: no JSON Schema yet: the live document is not added to spec
027's emitted schemas, since that would regenerate the committed
TypeScript declarations. A spec 027 follow-up.

Local verification (macOS arm64): `make gate`, `make code` (build, test,
clippy `-D warnings`, fmt, boundaries), `.bin/spec-spine verify 026` (10
commands, 10/10 seeds detected), `bash
scripts/check-authored-content.sh`.

Review round 1 (1 finding, fixed): `LiveReexecution::check` refused a
historical decision id longer than 256 bytes but not an empty one, so a
parsed document linking an empty historical id passed `check` although
`reexecute_live` refuses it. `check` now refuses it too;
`the_historical_decision_id_is_one_to_256_bytes` checks 0 and 257 bytes
(refused) and 256 bytes (accepted).

Rebased onto `main` after #143, #144 and #145 merged (derived shards
regenerated).

Review round 2 (0 findings).

Review round 3 (0 findings), after the rebase onto #144.
bartekus added a commit that referenced this pull request Oct 21, 2026
Spec 020: remote protocol refinements, increments 1 to 6 (phase
ceilings, the host-endpoint principal reference and `rustev.remote/2`,
bounded connection reuse, `rustev.run/2`, runtime-planned remote
batches, Jev and verification). Every refinement is disabled by default,
and a binding with every refinement disabled keeps its spec 009 bytes,
artifact and `PlanId`.

**Awaiting the owner.** Spec 020 stays `implementation: pending`, and so
stays out of `make verify`, because two acceptance items are not
verifiable as written (recorded in the spec's implementation record):

1. Multiplex cancellation (pool acceptance). The HTTP binding speaks
HTTP/1.1 only, so a pool policy must declare one stream per connection;
nothing is multiplexed and there is no multiplexed cancellation to test.
Covering it needs an HTTP/2 binding, a new dependency that spec 021's
audit would have to admit.
2. "New qualification evidence for every enabled refinement" (Jev). No
refinement is enabled on the Jev adapter, so there is none to produce;
enabling one would need a new mapping version and a newly authorized
qualification, which this spec does not authorize (3.7).

The ruling on these two decides whether 020 can be marked implemented.

## Per increment

- **1, phase ceilings (3.4, 3.1).** `rustev-remote-http/src/phases.rs`
(new): `PhasePolicy` (a positive ceiling per phase; zero refused at
construction), `TransportPhases` (disabled by default), `PhaseClock`
(each phase's allowance is the lesser of its ceiling and the budget left
when it starts; phases only move forward) and `phased`.
`HttpTransport::with_phases` enters resolution, connect, TLS handshake,
request write, first response byte and response body on the real
connection; `TransportError::PhaseExpired`. An expiry before request
bytes is `transport_unsent`, after them `transport_interrupted`; no
retry is added. The cancellation acknowledgement ceiling bounds every
cancel exchange. `rustev.remote-exchange/1` gains an optional
`phase_expiry`; `AdapterBinding::transport_phases` is not written when
disabled.
- **2, principal reference and `rustev.remote/2` (3.6, 3.7).**
`rustev-contract`: `PROTOCOL_V2`, `InferRequest::principal`
(`WirePrincipal`, omitted when absent, refused in version 1 or when not
canonical) and its domain-separated evidence digest; the exchange
record's optional `principal` holds only that digest.
`rustev-remote-http/src/principal.rs` (new): `EndpointOperator`,
`PrincipalSource`, `HandleAsReference`, `PrincipalPosture`,
`PrincipalWire`. The client negotiates exactly `protocol_major` (1 by
default) and refuses a principal for a third-party endpoint, over
version 1, or with a bad label. The server serves
`ServerConfig::versions` (`[1]` by default) and includes the principal
in idempotency content. Redirects stay unfollowed.
- **3, bounded connection reuse (3.5).**
`rustev-remote-http/src/pool.rs` (new): `PoolPolicy`, host-owned
`ConnectionPool`, `KeyMaterial` (every isolation member; credential and
principal only as digests; unknown material never reuses).
`HttpTransport::post_observed` swaps stream hooks per exchange, so the
tracker and phase clock are always the current exchange's. A stale
connection is never replaced mid-exchange; exhaustion is
`transport_unsent` with `observed{0}`. The exchange record gains an
optional `connection`; the binding gains `connection_pool`, not written
when disabled.
- **4, `rustev.run/2` (3.2, I-4).** `rustev-contract`: `RUN_V2`,
`RunRecord::remote_evidence` and `remote_evidence_truncated` (absent in
every other version, so version 1 and 3 bytes are unchanged), bounded
`RemoteEvidence`, `check_version_members`, `project_v1`. `rustev-core`:
`EvidenceSink::run_schema` and `DecisionBackend::take_remote_evidence`,
both defaulted. `rustev-runtime`: version 2 exactly when the sink
selects it; one entry per remote attempt in order; a rejected version 2
record is never retried as version 1. `rustev-remote-http`:
`ClientConfig::run_evidence`, `ExchangeSink::deliver_located`, and
`Exchanges::deliver` now returns the record digest and delivery result.
`rustev-eval`: bundles hold the version 1 projection, so replay is
unchanged and offline; `remote_evidence::availability` checks references
against a host store, apart from judgment parity.
- **5, runtime-planned remote batches (3.3).** `RemoteClient` offers
spec 017's `batch_capability` only when `ClientConfig::batch_dispatch`
and the negotiated terms both allow shared-state batching (bound is the
lesser). `infer_batch` refuses an oversized or mixed batch before any
byte, checks each member as an independent attempt, sends one exchange
in the runtime's order bounded by the earliest member budget, and
answers each member from its own answer. New exchange attribution
`runtime_planned`.
- **6, Jev, drift, verification.** A negotiated endpoint answering
another protocol version is `identity_mismatch`.
`rustev-jev/tests/refinements.rs`: Jev offers no general batch seam, its
adapter-scoped batch stays shared-state, and no spec 020 member or
remote evidence appears; its binding and mapping are unchanged. Spec
020: acceptance mapped item by item and a declared `verify:cli` block.

Amended specs whose shared APIs change: 003 (runtime run/2 delivery),
004 (eval bundles and availability), 009 (binding members, exchange
record, `TransportError`, `Exchanges::deliver`), 012 (Jev), 017 (the
batch seam's remote side). Their verify passes.

## Interpretations recorded in the implementation record

- 3.1's explicit `disabled` values are explicit in the configuration
types but not written into the binding document, so every existing
adapter's artifact and `PlanId` stay byte-identical (section 2).
- The request-write phase ends at the first completed flush after the
connection took the request body; the response-body phase includes the
response head.
- The cancellation acknowledgement ceiling bounds the whole cancel
exchange, whose own transport phases also apply.
- `rustev.remote/2` keeps the HTTP paths `/rustev/remote/1/...` and the
schema strings; the `version` member distinguishes it. A version 1
server refuses a version 2 describe with 400, reported at construction
as a negotiation failure.
- The isolation key's authority is the configured scheme, host and port,
not the resolved address.
- Replay never consults an exchange store; "without a transport or store
call" is read as that, and availability is a separate, explicit check.
- A plan 3 decision's record stays `rustev.run/3` without remote
evidence even for a sink that selected version 2.
- Spec 017's batch report has one cancellation answer and one remote
state, so one possibly continuing member makes every member of its batch
possibly continuing with charge unknown: never understated, possibly
overstated until the host reconciles.
- A host-operated server hands a version 2 request's reference to the
hosted backend as `CallContext::principal_handle`; version 1 keeps spec
009's empty handle.

## Local verification (macOS arm64)

Rebased onto `main` at df053f6 (4cecab0 dropped as already applied as
#146), then onto 2d6a1f2 after #143 and #144 merged, then onto c58c52e
after #150 (spec 026) merged; no conflicts and no call sites to fix.
`.bin/spec-spine verify 026` also passes. `make gate`, `make code`
(build, test, clippy `-D warnings`, fmt, boundaries), `.bin/spec-spine
verify` for 020, 003, 004, 009, 012 and 017 (spec-spine 0.31.0), `bash
scripts/check-authored-content.sh`.

Review round 1 (1 finding, reported by two groups, fixed): the
`RustevRun1` and `RustevRun3` declarations (both packages) carried
`remote_evidence` and `remote_evidence_truncated`, which spec 020 says
are `rustev.run/2` only. The declarations were faithful to the schemas,
and the schemas to the parser: the run record's parser read every
version with one type and did not refuse those members outside version
2. Fixed at the source: `versioned_document!` takes an optional `check =
f` rule, and the run record's parser applies `check_version_members`
(refusing either member in version 1 or 3, and a version 2 record
without the list or beyond its bounds, as `ParseError::Schema`). The run
schemas now state that rule: `rustev.run-1` and `rustev.run-3` drop both
members and their now-unreferenced `$defs` (byte-identical to `main`
again), and `rustev.run-2` requires a non-null list. Declarations
regenerated with `gen-types.mjs`.
`crates/rustev-contract/tests/run_v2.rs`
(`the_parser_and_the_schemas_hold_the_version_rule`) checks parser and
schemas agree for each case; the implementation record says so.

Review round 2 (1 finding, fixed): an attempt that passed `prepare`
(which records its evidence as `pending`) and was then withdrawn from a
coalescing exchange before it sent kept `pending`: `finish` completes
only the members in the exchange record, and `note_unexchanged` leaves
an existing entry alone. Both "stopped before sending" paths of
`cancel_member` (withdrawn while collecting, and a lone member that
stops the send) now go through `stopped_unsent`, which turns a
still-pending entry into `no_exchange` with code `cancelled` and charge
provenance `nothing_sent`. `tests/batching.rs`
(`a_member_withdrawn_before_sending_has_no_exchange_in_its_evidence`)
fails without the fix and passes with it; the implementation record says
so. Round 2's review job reached its 15-minute limit right after posting
its comment, so that run recorded no evidence artifact; this push runs a
fresh review.

Review round 3 (0 findings), after the rebase onto #150. The first
attempt of this round reached the review job's 15-minute limit without a
verdict; the rerun returned no findings in both groups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant