Skip to content

impl(027): increment 2, JSON Schema emission - #126

Merged
bartekus merged 1 commit into
mainfrom
impl/027-schema
Oct 20, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/027-schema

Conversation

@bartekus

@bartekus bartekus commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Spec 027, increment 2 of 7: JSON Schema emission (3.2.2). Stacked on #124 (it covers 033's document types); independent of #125.

  • rustev_contract::schema_emit::document_schemas(): a draft 2020-12 schema per public document type and version (28 files), derived via schemars (=1.2.3, pure) from the serde definitions the bounded parser uses; hand-written schemas for identities/digests, decimals and scope handles; schema fixed by const; ParseLimits recorded as x-rustev-parse-limits. Canonical JSON, committed under crates/rustev-contract/schema/.
  • crates/rustev-contract/tests/schemas.rs: committed bytes and file set equal emission (RUSTEV_BLESS=1 rewrites); emission deterministic and canonical; every committed test-directory JSON document naming an emitted version validates against it (jsonschema =0.59.0, dev-only, no HTTP/file resolution); a schema refuses an unknown member and another version.
  • No document, parse bound or canonical byte changes. schema_emit.rs joins archive-policy.json (hence 027's new extends on tools/rustev-release/); the release audit (bans, licenses, sources) passes with the new dependency.

Review round 1 (2 findings): (1) zmij is already in the lock file ([[package]] name = "zmij", a dependency of serde_json on main); the diff shows only changed entries. (2) The parser reads judgment 1 and 2 (and the other #76 pairs) with one wire type and does not refuse a later version's members under the earlier schema string, so the version schemas share that type's schema except schema; a stricter version 1 schema would describe something the parser does not enforce (3.2.2: the schema is descriptive). schema_emit documents this.

Review round 2 (1 finding): as in round 1, now shown by a test: a committed judgment 2 golden relabelled rustev.judgment/1 is accepted by Judgment::parse and by the version 1 schema alike; the schema describes the parser and is never stricter (3.2.2).

Review round 3 (7 findings): fixed: Timestamp's schema states the range its parser enforces (0 to 9999-12-31T23:59:59.999Z); a schema without properties is a defect (expect), never silently skipped; the test reads files fallibly; a needless clone removed. Answered: RankEntry.position is a u64 the parser accepts from 0, so its schema says so (the "1-based" comment states what the core produces, not what the parser refuses); Handle's byte bound is the parser's and a character bound is looser, never stricter, as the code says; zmij is in the lock file (a serde_json dependency on main).

Review round 4 (3 findings, same class as before): plan 2, evidence 1 and judgment 1 schemas admit the later version's members because the bounded parser reads both versions with one wire type and accepts them; a schema stricter than the parser would describe validity the parser does not enforce (3.2.2). The parity test now shows it for all three pairs: a later-version document relabelled with the earlier version is accepted by the parser and by the earlier schema. Rebased on main.

Review round 5 (1 finding, fixed): a derived schema without properties panics naming the document; the committed-bytes test emits every document, so such a defect fails CI before any schema is committed or shipped, and is never skipped.

Review round 6 (2 findings, same class as before): spec 033 writes every version 2 notice with its action, but the bounded parser does not refuse a notice without one, so the version 2 judgment and evidence schemas do not either (3.2.2: the schema describes the parser, never stricter). The parity test now shows it: a version 2 notice without action is accepted by the parser and by both version 2 schemas.

Review round 7 (4 findings): (1-3) The execution policy's ranges (max_attempts in 1..=8, at most four fallbacks, standalone and embedded) are checked when a plan is compiled against the policy (rustev_core::execution), not by the bounded parser; the schema describes the parser (3.2.2) and the field descriptions state the compile rule. The parity test now shows it: an out-of-range policy is accepted by the parser and the schema. (4) fixed: the extends comment names both: the archive list follows spec 021 3.5's rule in the directory spec 031 owns, which is why the edge names 031.

Review round 8 (3 findings): (1) Repeated and wrong: Cargo.lock has [[package]] name = "zmij" version = "1.0.23" from crates.io; cargo build --locked and CI resolve it. (2) fixed: the private test struct in bounded.rs no longer derives JsonSchema. (3) fixed: the committed-document sweep includes integrations/.

Review round 9 (2 findings): (1) Repeated: judgment 1's schema admits refused and needs_input because the parser reads both judgment versions with one wire type and accepts them under version 1; the parity test (the_version_schemas_describe_what_the_parser_accepts) relabels a version 2 refusal as version 1 and shows both the parser and the version 1 schema accept it (3.2.2: the schema describes the parser, never stricter). (2) fixed: ContinuationInputs no longer derives JsonSchema.

Review round 10 (4 findings, the same class as earlier rounds): version 1 schemas admitting version 2 members, and a character length standing for a byte bound. Both follow from 3.2.2: a schema is derived from the types the bounded parser reads and is descriptive, the parser being the only authority on validity; the parser reads both versions with one type, and JSON Schema cannot express a UTF-8 byte length. To make every schema say this itself, each now carries a root $comment stating it (admits what the shared type admits, including later-version members; byte, depth and count bounds in x-rustev-parse-limits, string lengths counting characters; compile rules in descriptions, not enforced). The parity test shows the parser accepting each such document. Rebased on main.

Review round 11 (1 finding, fixed): the file-set comparison sorts both lists, so it never depends on emission order.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 2

Reviewing this group: dependency additions in Cargo.lock/Cargo.toml/crates/rustev-contract/Cargo.toml and the new JSON Schema files (rustev.backend-1 through rustev.plan-2).

Cargo / dependency layer

  • The ring entry's getrandom dependency is correctly renamed to getrandom 0.2.17 to disambiguate now that getrandom 0.3.4 is also present. This is proper Cargo lock-file behavior.
  • schemars = "=1.2.3" is exact-pinned as a production (non-dev) dependency of rustev-contract. The comment in Cargo.toml says this is intentional for byte-identical schema emission (spec 027, 3.2.2). Design choice, not a bug.
  • jsonschema = "=0.59.0" is correctly placed in [dev-dependencies]; its heavy transitive tree (fancy-regex, fraction/num-bigint, wasm-bindgen, etc.) stays out of production builds.
  • jsonschema-value 0.59.0 lists zmij as a dependency in its lock-file entry, but no zmij entry appears anywhere in the diff. Since jsonschema-value is brand-new in this PR, zmij would need to be newly added too. It is most likely gated behind an optional feature that is not activated (Cargo omits unused optional deps from the lock file), but the absence is worth confirming locally via cargo tree -e features.

Schema files

  • Version discriminants ("schema": {"const": "rustev.xxx/N"}) are consistently set on each top-level schema; embedded sub-schemas that can span versions (e.g., Judgment inside Evidence, Definition inside Plan/2) correctly use {"type": "string"} instead of a const.
  • "additionalProperties": false and "required" lists look consistent across all schemas; optional fields (e.g., address on refuse, action on Notice in judgment/1) are correctly omitted from required.
  • "x-rustev-parse-limits" extension objects are present on every top-level schema.
  • allow_fractional_numbers is true on schemas that carry float scores/distributions (backend-output, evidence, judgment, eval-report) and false on structural/config schemas (backend, calibration, definition, execution). Consistent.
  • rustev.plan-2.schema.json uses the open "schema": {"type": "string"} inside Definition (plan/2 can embed definition/1 or definition/2), and the PlanActionability type correctly captures static analysis results rather than reusing the definition's Actionability type. No inconsistency found.

No bugs or security issues identified.

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

Group 2 of 2

Reviewing the PR, which adds JSON Schema emission (schema_emit.rs), schemars::JsonSchema derives across all public contract types, committed schema files, and a schema-validation test.

Finding 1 — Silent skip of schema const injection (schema_emit.rs:52)

if let Some(props) = v.get_mut("properties").and_then(|p| p.as_object_mut()) {
    props.insert(
        "schema".into(),
        serde_json::json!({ "type": "string", "const": version }),
    );
}

If schemars ever generates a root schema without a top-level "properties" object (e.g., because it emits a $ref at root, or the type is restructured), the schema: { const: <version> } constraint is silently dropped and the emitted file becomes version-agnostic. There is no panic, no log, and no test that specifically checks whether the const constraint is present in the emitted JSON. The test schemas_close_objects_and_fix_the_version verifies this for one specific file (rustev.snapshot-2.schema.json) but not for the other 27 emitted schemas. A future document type that causes schemars to produce a root-level $ref would produce a committed schema that accepts any version string.

Finding 2 — Versioned documents sharing a single Rust type produce overly-permissive older-version schemas

document_schemas() calls e.g. emit::<Plan>(schema::PLAN, None) and emit::<Plan>(schema::PLAN_V3, None). The Plan struct carries actionability, grades, and sources (plan-3 additions) as Option<…> fields. So the schema emitted for rustev.plan/2 also shows those fields as optional properties — permitting documents that the plan-2 bounded parser would silently accept (since they are known struct fields, not unknown fields) or silently ignore. The test only validates that committed plan-2 golden documents pass; it does not verify that plan-3-only fields are absent from the plan-2 schema. This makes the "descriptive" claim in the module doc inconsistent: a schema that accepts plan-3 fields when labeled rustev.plan/2 is not a faithful description of plan-2 documents.

Minor: unnecessary clone (schema_emit.rs:48)

v["title"] = title.clone().into();

title is not used after this line; .clone() is dead work. Use title.into() directly.

No security issues found. The jsonschema validator is used only on local files, remote reference resolution is not involved, and path traversal in the test walker is compile-time-resolved.

{"head": "69c81a9159d1aab7fbd18453ac81639238cab409", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/schema_emit.rs", "line": 52, "summary": "The `schema` const injection is silently skipped if schemars generates a root schema without a top-level `properties` object; no diagnostic or test catches this failure for 27 of the 28 emitted schemas."}, {"path": "crates/rustev-contract/src/schema_emit.rs", "line": 77, "summary": "Multiple document versions share one Rust type (Plan 2/3, Definition 1/2, Run 1/3, etc.), so older-version schemas include newer-version optional fields, contradicting the stated descriptive accuracy."}]}

Subject: f0c1aaf...69c81a9, diff digest ac505b5240b24a96882ddd074e637bbe3ca345cd6c5ca5cee4233264cb2fe0d2, 2 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 2

Reviewing the group-1 changes: Cargo dependency additions, rustev-contract manifest, and the first batch of generated schema files.

Cargo.lock — zmij listed as dependency of jsonschema-value 0.59.0 but absent from the lock file

The added jsonschema-value 0.59.0 entry contains "zmij" in its dependencies list, but no [[package]] name = "zmij" entry exists anywhere in the shown diff. In Cargo.lock v4, the dependencies section of a resolved package only contains packages that are actually in the build graph; their package entry must also exist. zmij sorts after zerocopy-derive (new) and after zeroize (existing, unchanged), exactly where the diff ends — yet nothing is there. A missing transitive-dependency entry produces an inconsistent lock file that cargo build would reject.

rustev.judgment-1.schema.json — version-2 outcome variants present in version-1 schema

The Outcome oneOf in the judgment/1 schema includes refused and needs_input variants, and UnresolvedWire includes ActionableUnresolved with an action block — all explicitly annotated in the same schema as "version 2" additions (spec 033). The judgment/1 and judgment/2 schemas are structurally identical except for the schema const. That means the judgment/1 schema will pass validation for documents that should only be valid as judgment/2, defeating the versioned contract. The same over-permissiveness propagates into rustev.evidence-1.schema.json, which embeds Judgment with the same unconstrained Outcome.

{
  "head": "536fe52ff904f9e6fb438fd606cca09bebcc6fb0",
  "verdict": "findings",
  "findings": [
    {
      "path": "Cargo.lock",
      "line": null,
      "summary": "`jsonschema-value 0.59.0` lists `zmij` as a resolved dependency but no `[[package]]` entry for `zmij` appears in the lock file, making the lock file inconsistent and likely breaking the build."
    },
    {
      "path": "crates/rustev-contract/schema/rustev.judgment-1.schema.json",
      "line": 1,
      "summary": "The judgment/1 schema accepts `refused`, `needs_input`, and `ActionableUnresolved` outcomes that are explicitly documented as version-2 additions, making the schema over-permissive and unable to distinguish judgment/1 from judgment/2 documents."
    }
  ]
}

Group 2 of 2

I reviewed all changed files in group 2 carefully, focusing on the JSON Schema emitter (schema_emit.rs), the committed schemas, the test suite, and the Rust type annotations.

schema_emit.rs – emit function
The emit<T> function generates a schema, injects schema as a const-valued property, and records parse limits. The conditional inject (if let Some(props) = v.get_mut("properties")) is safe because all document types in the codebase are structs with a schema: String field. The file name construction from version.replace('/', "-") matches the committed file names. ✓

Version duplication (emit::<Plan>(PLAN, None) and emit::<Plan>(PLAN_V3, None))
Both calls use Plan::LIMITS, which is the same regardless of schema version. This is intentional: the version const discriminates the wire version; the structural difference (optional grades, sources, actionability) is encoded as optional fields in the single Plan struct. ✓

Outcome / OutcomeWire schemars delegation
Outcome carries #[serde(from = "OutcomeWire", into = "OutcomeWire")]. In schemars 1.x, this causes the schema to delegate to OutcomeWire's schema, which has deny_unknown_fields and rename_all = "snake_case". The committed run-1 and run-3 schemas show the correct OutcomeWire structure including UnresolvedWire as anyOf[ActionableUnresolved, Unresolved]. ✓

Hand-written JsonSchema impls
Handle (string with minLength/maxLength), Decimal (pattern-validated string), and all ID types (sha256 pattern) are correctly hand-written. Each ID type gets its own named $defs entry via stringify!($name). ✓

Test suite

  • committed_schemas_equal_emitted_bytes: correctly handles the trailing newline convention and uses RUSTEV_BLESS=1 to regenerate.
  • every_committed_document_validates_against_its_schema: correctly skips documents without a schema field or with an unrecognised version, and uses the title (= version string for non-part schemas) as the lookup key.
  • The minimum-count assert (checked >= 30) acts as a reasonable sanity guard.

archive-policy.json correctly adds src/schema_emit.rs to the reviewed source list. ✓

No bugs, security issues, or inconsistencies found.

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

Subject: 569ef74...536fe52, diff digest ac505b5240b24a96882ddd074e637bbe3ca345cd6c5ca5cee4233264cb2fe0d2, 2 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Group 1 of 2

Reviewing the dependency additions and new schema files.

Cargo.lock / Cargo.toml / crates/rustev-contract/Cargo.toml

  • schemars pinned at exact version =1.2.3 as a production dependency of rustev-contract. The intent (schema emission per spec 027, 3.2.2) is documented; without the Rust source changes (group 2) it can't be confirmed whether runtime schema generation is exposed as a public API, but the pin comment is consistent with that intent.
  • jsonschema = "=0.59.0" is correctly placed in [dev-dependencies] only; its large transitive closure (regex, parking_lot, fraction/num-bigint, fancy-regex, etc.) does not affect production binaries.
  • The getrandom split (0.2.17 for ring, 0.3.4 for ahash/jsonschema/referencing) is handled correctly by Cargo's resolver; the ring entry is updated to the disambiguated form getrandom 0.2.17.

Schema files

  • x-rustev-parse-limits values are internally consistent: allow_fractional_numbers: true on documents that carry floats (backend-output, judgment, evidence, eval-report), false on structural/config documents (backend, calibration, definition, execution, plan).
  • definition-1 and definition-2 schemas are byte-identical except for the schema const value. This means a definition/1 document containing corroborate steps or nullable/map types would pass schema validation; version enforcement relies on the application, not the schema. This is a deliberate lenient-schema design choice consistent with how schemars generates from shared types.
  • judgment-1 and judgment-2 schemas are identical except for the schema const. The Notice.action field is present-but-optional in both, matching the description "Judgment 2: who can act on it; omitted in version 1" — the schema itself cannot enforce omission in v1, again a known trade-off.
  • The Definition type embedded in rustev.plan-2.schema.json uses "schema":{"type":"string"} (no const) — correct, since the plan must accept both definition/1 and definition/2 documents.
  • No pattern, cardinality, or reference inconsistencies found across the 15 schema files.

No actionable bugs or security issues found in this group.

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

Group 2 of 2

Reviewing the JSON Schema emission increment: schema_emit.rs, the derive additions, and the schema tests.

Finding 1 — Silent omission of schema: const in emit

schema_emit.rs line ~50:

if let Some(props) = v.get_mut("properties").and_then(|p| p.as_object_mut()) {
    props.insert("schema".into(), serde_json::json!({ "type": "string", "const": version }));
}

The if let Some silently does nothing when properties is absent from the generated schema. All current document types have a schema: String field so schemars always produces a properties entry, but there is no assertion guarding this assumption. If properties were absent the committed schema would lack the const constraint that fixes the version, violating the spec guarantee ("the schema cannot express…") while passing CI. The test schemas_close_objects_and_fix_the_version only spot-checks snapshot-2; a schema without the const for another type would not be caught there.

Finding 2 — jsonschema::validator_for without remote-resolution guard

tests/schemas.rs line ~110:

(version, jsonschema::validator_for(&v).unwrap())

The spec comment ("without HTTP or file resolution") is not enforced in code. If any future schema inadvertently carries an absolute $ref, the test harness could attempt outbound HTTP in a network-restricted CI environment, or silently validate against a stale remote schema. The current emitted schemas use only local #/$defs/… refs so this is latent, but the configuration gap is real.

Finding 3 — unwrap() on file reads inside committed_documents

tests/schemas.rs line ~85:

&& let Ok(v) = serde_json::from_slice::<serde_json::Value>(&std::fs::read(&p).unwrap())

A read failure on any JSON file under a test directory panics with no indication of which path failed. Compared with the adjacent let Ok(v) guard this is inconsistent and produces cryptic failures.

No issues with the crypto patterns (^sha256:[0-9a-f]{64}$), the serde(from = "OutcomeWire") schema delegation (schemars correctly uses the wire type), the canonical-then-emit ordering, or the Handle/Decimal/Timestamp hand-written schemas.

{"head": "404e1436a3b342fa1d0e2067d3c53c171a3c3065", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/schema_emit.rs", "line": 50, "summary": "The `schema: const` version constraint is silently omitted when schemars produces no `properties` key; an assertion is needed to ensure every emitted schema carries the version discriminator."},{"path": "crates/rustev-contract/tests/schemas.rs", "line": 110, "summary": "`jsonschema::validator_for` is called without disabling HTTP/file `$ref` resolution, contradicting the documented intent of local-only schema validation."},{"path": "crates/rustev-contract/tests/schemas.rs", "line": 85, "summary": "`std::fs::read(&p).unwrap()` panics on unreadable files with no path context, producing cryptic test failures."}]}

Subject: 569ef74...404e143, diff digest 61851e0dd820320df67183e6cf0a1cda0e619b220eee31fb463a27403f3c73b1, 2 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 2

Looking at the schema files and dependency changes in this group.

Cargo.lock / Cargo.toml

The lock file correctly handles two coexisting getrandom versions: 0.2.17 (kept for ring) and 0.3.4 (pulled in by jsonschema's dependencies). The disambiguation in the ring block ("getrandom 0.2.17") is correct. schemars is exact-pinned (=1.2.3) per the stated intent, and jsonschema is exact-pinned in dev-dependencies — both consistent with the comments.

Schema files

rustev.backend-1.schema.json, rustev.backend-output-1.schema.json, rustev.calibration-1.schema.json, rustev.eval-report-1.schema.json, rustev.execution-1.schema.json — these look structurally correct and internally consistent.

rustev.definition-1.schema.json vs rustev.definition-2.schema.json — differ only in the schema const value (rustev.definition/1 vs rustev.definition/2), as expected.

Finding: rustev.judgment-1.schema.json — Outcome is identical to judgment-2

The Outcome definition in rustev.judgment-1.schema.json includes refused and needs_input variants. The schema's own description states: "Version 1 uses Propose, Escalate and Unresolved; version 2 (spec 033, 3.5.1) … adds Refused and NeedsInput." Because the v1 and v2 schemas share the same Outcome type (likely generated from the same Rust enum), a judgment/1 document with a refused or needs_input outcome passes schema validation even though that outcome type is a v2 addition. The test suite (schemas.rs, reviewed in group 2) would catch this only if a v1-tagged document with a v2 outcome is in the test fixtures — otherwise the over-permissiveness is silent.

rustev.plan-2.schema.json — optional grades, sources, actionability fields (plan 3 features) are correctly absent from required. The plan-2 const and title are consistent.

{"head": "be2a979ccff98a8e0205615ac0f3bcbf7baf69e8", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/schema/rustev.judgment-1.schema.json", "line": 1, "summary": "The Outcome type in judgment/1 schema includes `refused` and `needs_input` variants that the schema's own description identifies as version-2-only additions, making the v1 schema overly permissive and unable to reject v2-only outcomes in documents claiming to be judgment/1."}]}

Group 2 of 2

Looking at the changed files in group 2: new JSON schema files, all Rust source changes in rustev-contract, the new schema_emit.rs module, the new tests/schemas.rs, and the updated spec and archive policy.

schema_emit.rs — emit function

The function patches properties.schema to add a const constraint, but does so with a silent no-op if v.get_mut("properties") returns None:

if let Some(props) = v.get_mut("properties").and_then(|p| p.as_object_mut()) {
    props.insert("schema".into(), ...);
}

For every struct type used in document_schemas(), schemars will always produce a properties key, so in practice this is not reachable. It's a latent risk but not an active bug given the current callers.

tests/schemas.rs — committed_documents / bless path

The bless path calls std::fs::remove_dir_all(dir()) without checking that the computed path is non-empty or within the workspace; however, dir() is computed from the compile-time CARGO_MANIFEST_DIR, so there is no practical risk of an unexpected path.

The assert!(checked >= 30) sanity floor is reasonable but fragile — a future reduction in test fixtures would not update this count and would give false confidence.

tests/schemas.rs — committed_schemas_equal_emitted_bytes

read_dir is not filtered to exclude dotfiles. On macOS developer machines (.DS_Store) or with other hidden entries, the sorted committed list would diverge from names. This is a common test fragility but not a correctness issue.

judgment.rs — Outcome / OutcomeWire interaction

Outcome uses #[serde(from = "OutcomeWire", into = "OutcomeWire")] alongside schemars::JsonSchema. In schemars 1.x, from causes the schema for Outcome to delegate to OutcomeWire::json_schema, which correctly exposes UnresolvedWire (an anyOf[ActionableUnresolved, Unresolved]) rather than the plain Unresolved that Outcome's own variant carries. The committed schema confirms UnresolvedWire appears in $defs. No bug, but worth noting the dependency on schemars honoring from.

schema_emit.rs — request/response schema const

For emit::<remote::DescribeRequest>(schema::REMOTE_DESCRIBE, Some("request")), the const on the schema property is "rustev.remote-describe/1" (the version arg), not "rustev.remote-describe/1 request". Both the request and response schemas carry the same const. This is correct because the wire field is "rustev.remote-describe/1" in both documents; the distinction is structural, not a schema-const distinction.

No bugs or security problems found in this group.

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

Subject: 59c9a9c...be2a979, diff digest 61851e0dd820320df67183e6cf0a1cda0e619b220eee31fb463a27403f3c73b1, 2 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Reviewing the diff for group 1: Cargo.lock, Cargo.toml, crates/rustev-contract/Cargo.toml, and the 12 new schema files (rustev.backend-1 through rustev.plan-2).

Cargo / dependency hygiene

  • schemars = "=1.2.3" is pinned exactly in the workspace and added as a production dependency of rustev-contract. Its transitive closure is small (dyn-clone, ref-cast, schemars_derive, serde, serde_json) and all pure/no-I/O, consistent with spec 001's ban on tokio in the contract crate.
  • jsonschema = "=0.59.0" is dev-only and also exactly pinned. Both pins are correct for the stated goal of byte-stable schema emission.
  • default-features = false on jsonschema disables HTTP/file $ref resolution — correct for a test validator that must not make network calls.
  • Two getrandom versions now coexist (0.2.17 for ring, 0.3.4 for the new dependency tree). Cargo disambiguates these correctly in the lock file.
  • The jsonschema dev dependency pulls in a heavy transitive tree (fraction, num, num-bigint, fancy-regex, parking_lot, …) but all of this is test-only and doesn't affect production binaries.

Schema files

  • All schemas use "$schema":"https://json-schema.org/draft/2020-12/schema" and are internally consistent with $ref targets present in $defs.
  • Version pairs (evidence/1 vs evidence/2, judgment/1 vs judgment/2, definition/1 vs definition/2) differ only in the schema const value; the $defs structures are identical, which is correct for wire-compatible versions.
  • The x-rustev-parse-limits extension keywords are non-standard but application-defined; validators that don't recognise them will correctly ignore them (JSON Schema 2020-12 behaviour).
  • address being optional (not in required) in the refuse consequence is intentional — it defaults to "computed" per the spec.
  • The plan-2 schema correctly includes StaticGrade, Normalization, PlanActionability, etc., which are absent from narrower schemas like execution-1.

No bugs, security problems, or inconsistencies found.

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

Group 2 of 3

Reviewing the schema emission machinery, the Rust source changes, and the committed schemas.

schema_emit.rs — silent no-op when properties is absent

In emit():

if let Some(props) = v.get_mut("properties").and_then(|p| p.as_object_mut()) {
    props.insert("schema".into(), serde_json::json!({ "type": "string", "const": version }));
}

If the generator ever produces a root schema without a properties key (e.g., for a future enum-rooted document type), the schema const override is silently dropped. The emitted schema would validate documents with any or no schema string, breaking the version-lock guarantee. No assertion or error fires. All current document types are structs so this is not triggered today, but the pattern has no guard.

tests/schemas.rs — panic vs graceful skip inconsistency in committed_documents

Around the file-walk loop (~line 111):

&std::fs::read(&p).unwrap()  // panics on unreadable file

The JSON parse error is gracefully handled (let Ok(v) = serde_json::from_slice(...)), but a read failure panics rather than skipping the file. This is inconsistent and would cause the entire test to abort rather than skip the problematic entry.

scope.rs — maxLength counts codepoints, not bytes

Handle::json_schema emits "maxLength": 256, but JSON Schema's maxLength keyword counts Unicode code points, not UTF-8 bytes. A handle composed of 256 two-byte characters (512 bytes) satisfies the schema but is rejected by the bounded parser. The code comment acknowledges this, and the spec states the bounded parser is the authority, so this is a known inaccuracy rather than a bug — but it means the schema over-permits inputs for non-ASCII handles.

{"verdict": "findings", "head": "825c89a9399e86ac4e58d1e59df4c38dbab1fc88", "findings": [{"path": "crates/rustev-contract/src/schema_emit.rs", "line": 57, "summary": "Silent no-op if the generated root schema has no `properties` key: the `schema` const override is skipped without error, so any future enum-rooted document type would emit a schema that does not version-lock the `schema` field."}, {"path": "crates/rustev-contract/tests/schemas.rs", "line": 111, "summary": "`.unwrap()` on `std::fs::read` panics the test on any unreadable file while JSON parse errors are gracefully handled via `let Ok(v)`, creating inconsistent error handling in `committed_documents`."}]}

Group 3 of 3

The diff adds src/schema_emit.rs to the archive policy's file list for rustev-contract, which matches the new crates/rustev-contract/src/schema_emit.rs file introduced in this PR. This is a straightforward and correct update -- the new source file is being registered in the archive policy alongside its sibling source files in alphabetical order.

No issues found.

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

Subject: 59c9a9c...825c89a, diff digest 6292d019787feec51295647e3b66b8dcb5177578bc349e1cc22b4f641a2d1bf2, 3 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 20, 2026 15:15 — with GitHub Actions Error
Base automatically changed from impl/033-final to main October 20, 2026 15:17
@bartekus
bartekus enabled auto-merge (squash) October 20, 2026 15:24
@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Reviewing the Cargo.lock, Cargo.toml dependency additions, and the first batch of emitted JSON Schema files.

Finding 1 — RankEntry.position allows 0 despite "1-based" description

In every schema that includes RankEntry (evidence-1, evidence-2, judgment-1, judgment-2 — and plan-2 in a later group), the position field is described as "1-based" but carries "minimum":0, so a position value of 0 would pass schema validation against the stated invariant:

"position":{"description":"1-based.","format":"uint64","minimum":0,"type":"integer"}

"minimum":1 is needed to match the semantic contract.

Finding 2 — zmij not present in Cargo.lock despite being a transitive dependency

The newly added jsonschema-value 0.59.0 package declares zmij as a dependency:

dependencies = [
 ...
 "zmij",
]

Alphabetically, a zmij [[package]] entry would appear after zeroize in Cargo.lock. The diff shows additions through zerocopy and zerocopy-derive, then leaves zeroize unchanged and ends — with no zmij entry added. If zmij was not already in the lock file (it has no other apparent prior consumers), the lock file is incomplete and cargo build --locked would fail.

{"head": "942223682254e35002b3eeb9ad60a5a53555d7db", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/schema/rustev.evidence-1.schema.json", "line": 1, "summary": "RankEntry.position has minimum:0 but is described as 1-based; 0 would pass schema validation against the stated invariant — minimum should be 1."}, {"path": "Cargo.lock", "line": null, "summary": "jsonschema-value 0.59.0 lists zmij as a dependency but no [[package]] entry for zmij is added to the lock file, leaving it potentially incomplete."}]}

Group 2 of 3

Reviewing the schema emission infrastructure in this diff: new JSON Schema files, schemars::JsonSchema derives wired across all contract types, a new schema_emit.rs, and the tests/schemas.rs test harness.

1. Silent version-const failure in emit (schema_emit.rs:46–50)

if let Some(props) = v.get_mut("properties").and_then(|p| p.as_object_mut()) {
    props.insert("schema".into(), serde_json::json!({ "type": "string", "const": version }));
}

If schemars ever generates a schema without a top-level properties object (impossible for the current document types, but no assertion guards this), the schema field is silently left unconstrained — the emitted schema would accept any version string instead of just the one that was requested. A debug_assert!(props.contains_key("schema"), ...) would catch this early.

2. Panic inside filter predicate (tests/schemas.rs:95)

&& let Ok(v) =
    serde_json::from_slice::<serde_json::Value>(&std::fs::read(&p).unwrap())

The inner std::fs::read(&p).unwrap() will panic — not skip — when a file cannot be read (e.g. a symlink gone stale or a permission problem). The outer if let Ok(v) only catches a JSON-parse failure. A file-read error produces an opaque called unwrap() on an Err panic instead of a clear test message. The read should be propagated via ? or surfaced with a descriptive expect.

3. Handle::json_schema bounds characters, not bytes (scope.rs:63–73)

schemars::json_schema!({
    "type": "string",
    "minLength": 1,
    "maxLength": MAX_HANDLE_BYTES  // 256
})

JSON Schema maxLength counts Unicode code points, not bytes. A string of 256 Tibetan characters satisfies maxLength: 256 but occupies 768 UTF-8 bytes, exceeding the parser's byte limit. The comment acknowledges "a schema bounds characters, so the byte bound is the parser's," which is the stated design intent — but the mismatch means the schema is materially more permissive for multibyte input than the parser, potentially misleading downstream validators. Worth a more prominent note or a doc-comment on the generated schema property.

4. Timestamp JsonSchema admits negative values (time.rs:12)

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, schemars::JsonSchema)]
#[serde(transparent)]
pub struct Timestamp(i64);

i64 generates {"format": "int64", "type": "integer"} with no minimum. Valid timestamps are constrained to 0..=MAX_TIMESTAMP_MS by the parser; the schema admits any signed 64-bit integer. DurationMs (a u64 newtype in the same file) correctly gets "minimum": 0 from schemars. By contrast Timestamp does not, even though a negative timestamp is never valid. Since the spec says schemas are descriptive and the parser is the authority this is intentional, but it is an inconsistency worth documenting.

5. Unnecessary .clone() in emit (schema_emit.rs:42)

v["title"] = title.clone().into();

title is a String that is never used again after this line; it can be moved directly: v["title"] = title.into();. The clone is dead allocation.

{"head": "942223682254e35002b3eeb9ad60a5a53555d7db", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/schema_emit.rs", "line": 46, "summary": "If schemars generates a schema without a top-level `properties` object the version-const override is silently skipped, leaving `schema` unconstrained with no error or assertion."}, {"path": "crates/rustev-contract/tests/schemas.rs", "line": 95, "summary": "`std::fs::read(&p).unwrap()` inside the filter predicate panics with an opaque message on any file-read failure; only the JSON-parse failure is caught by the surrounding `if let Ok(v)`."}, {"path": "crates/rustev-contract/src/scope.rs", "line": 63, "summary": "`Handle::json_schema` uses JSON Schema `maxLength` (code points) for a limit that the parser enforces in bytes, so multibyte strings that exceed the byte limit pass schema validation."}, {"path": "crates/rustev-contract/src/time.rs", "line": 12, "summary": "`Timestamp` derives `JsonSchema` from `i64` with no `minimum: 0`, admitting negative timestamps that the parser rejects, inconsistently with `DurationMs` which correctly gets `minimum: 0`."}, {"path": "crates/rustev-contract/src/schema_emit.rs", "line": 42, "summary": "`title.clone().into()` clones a `String` that is never used again; should be `title.into()`."}]}

Group 3 of 3

The change adds src/schema_emit.rs to the archive policy's file list for rustev-contract, which is consistent with the new file introduced in this PR.

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

Subject: 355db90...9422236, diff digest 6292d019787feec51295647e3b66b8dcb5177578bc349e1cc22b4f641a2d1bf2, 3 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 2

Reviewing the diff for the schema emission additions in rustev-contract.

Dependency changes (Cargo.lock, Cargo.toml, crates/rustev-contract/Cargo.toml)
These look clean. schemars is a compile-time schema emitter with no I/O; the exact-pin strategy is appropriate for byte-identical schema stability. jsonschema is correctly dev-only. The split between getrandom 0.2.17 (kept by ring) and the new getrandom 0.3.4 (pulled in by jsonschema transitive deps) is a normal semver-dual situation in Cargo and causes no conflict.

Schema files

rustev.plan-2.schema.json: The root object lists grades, sources, and actionability as properties — but inline comments explicitly label them "Plan 3:". With "additionalProperties": false on the root object these fields are permitted by the schema. A plan/2 document that erroneously carries plan/3 fields would pass validation. The schema version discriminator ("schema": {"const": "rustev.plan/2"}) only rejects wrong-version documents; it does not reject documents that incorrectly carry plan/3-only fields under a plan/2 header. Since the plan/3 schema file is a distinct file in this PR, the intent is clearly for each schema to be version-specific, making this a validation gap.

rustev.evidence-1.schema.json and rustev.judgment-1.schema.json: Both embed an Outcome definition that includes the refused and needs_input variants. The schema's own comment states those two variants are version-2 additions ("version 2…adds Refused and NeedsInput"). A v1 evidence or judgment document carrying refused or needs_input would pass schema validation even though those outcomes are not valid in version 1. The evidence-2 and judgment-2 schemas are correct here; only the v1 schemas are over-permissive.

{"head": "d066d92ba617c34e557d863cceb997498135b8aa", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/schema/rustev.plan-2.schema.json", "line": 1, "summary": "Plan/2 schema permits optional plan/3-only fields (`grades`, `sources`, `actionability`) with `additionalProperties:false`, so a plan/2 document carrying those fields passes validation."}, {"path": "crates/rustev-contract/schema/rustev.evidence-1.schema.json", "line": 1, "summary": "Evidence/1 schema includes the `refused` and `needs_input` Outcome variants that are explicitly v2 additions, allowing v2-style outcomes to pass v1 schema validation."}, {"path": "crates/rustev-contract/schema/rustev.judgment-1.schema.json", "line": 1, "summary": "Judgment/1 schema includes the `refused` and `needs_input` Outcome variants that are explicitly v2 additions, allowing v2-style outcomes to pass v1 schema validation."}]}

Group 2 of 2

Looking through the diff carefully across the schema files, Rust sources, and test code:

Schema emission correctness: The emit function in schema_emit.rs canonicalizes output and pins schema via const. The committed schema files match what the Rust types with their serde attributes would produce. The Outcome/OutcomeWire delegation (via #[serde(from/into)]) is handled correctly by schemars 1.2.x, which delegates schema generation to the from type — the committed schemas show snake_case variant names with additionalProperties: false, confirming OutcomeWire's schema is used.

Hand-written JsonSchema impls: The Decimal, Timestamp, Handle, and ID-type implementations are correct and consistent with their parser constraints (sha256: pattern, timestamp range, handle length bounds).

Test logic: The committed_schemas_equal_emitted_bytes test correctly compares canonicalized bytes plus a trailing newline. The every_committed_document_validates_against_its_schema test skips non-document JSON gracefully and enforces at least 30 validated documents.

Coverage gap: committed_documents() in tests/schemas.rs scans crates, packages, backends, tools but not integrations/. The integrations/rustev-jev/tests/fixtures/ and integrations/rustev-remote-http/tests/ directories contain JSON files that are test-fixture documents (e.g., synthetic snapshots and infer responses). Since the test skips documents without a recognised schema key, adding integrations/ would be safe and improve coverage, but its omission is not a correctness bug.

Unnecessary derive: bounded.rs adds schemars::JsonSchema to the private test struct Doc — harmless but unnecessary.

No security or correctness bugs found.

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

Subject: 355db90...d066d92, diff digest 714b9d265d1c89af3e1ff49e2a7f73ff9c8745880f008da0a4e3e06f89ac1e13, 2 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (no-findings)

Group 1 of 3

Reviewing the Cargo.lock additions, workspace Cargo.toml, crate Cargo.toml, and the new JSON Schema files in group 1.

Dependency additions (Cargo.lock, Cargo.toml, crates/rustev-contract/Cargo.toml)

  • schemars = "=1.2.3" is correctly exact-pinned in the workspace and inherited by the crate; this ensures emitted schemas stay byte-identical across builds as documented.
  • jsonschema = "=0.59.0" is correctly in [dev-dependencies] only with default-features = false, so no HTTP/file resolver is linked for tests.
  • The new getrandom 0.3.4 pulled in by ahash/referencing coexists safely with the existing getrandom 0.2.17 required by ring; the lock file disambiguates them correctly.
  • Two syn versions (2.0.119 for strum_macros, 3.0.6 for schemars_derive/ref-cast-impl) is expected and handled correctly.

Schema files (rustev.backend-1, rustev.backend-output-1, rustev.calibration-1, rustev.definition-1/2, rustev.eval-report-1, rustev.evidence-1/2, rustev.execution-1, rustev.judgment-1/2, rustev.plan-2)

  • All schemas use "$schema":"https://json-schema.org/draft/2020-12/schema" and "additionalProperties":false correctly.
  • The x-rustev-parse-limits extension keyword is valid per JSON Schema (non-$ vendor extension).
  • allow_fractional_numbers is true only for documents that carry floating-point values (backend output, evidence, eval-report, judgment, plan-2) and false for purely structural/config documents. This is consistent.
  • The definition-1 and definition-2 schemas are deliberately permissive: version-2 optional fields (evidence, on_disagreement, nullable, map, present_when) appear in both schemas as nullable/optional, version discriminated by the schema const alone. This is a forward-compatibility design choice rather than a bug.
  • judgment-1 and judgment-2 follow the same pattern; the comment on Notice.action ("omitted in version 1") describes runtime behaviour, not a schema constraint, which is appropriate.
  • plan-2 correctly marks plan-3 members (grades, sources, actionability) as optional (type: ["array","null"] / anyOf [..., null]), so plan-2 documents that lack these fields remain valid.
  • StaticGrade.ceiling using ValueGrade (which includes "ungraded") is semantically coherent: "ungraded" as a ceiling means the value carries no grade bound, matching ungraded inputs.
  • Parse limits are sized appropriately relative to document complexity (definitions and evidence at 4 MB, execution/backend configs at 256 KB).

No bugs, security problems, or inconsistencies found.

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

Group 2 of 3

Reviewing the schema emission infrastructure, schema files, and supporting Rust source changes in this group.

schema_emit.rs — emit function

The emit function generates a fresh SchemaGenerator per call, then post-hoc overwrites the schema property with a const string and injects x-rustev-parse-limits. Both operations are correct: canonical JSON sorts keys so insertion order is irrelevant, and the const override properly supersedes schemars' plain-string derivation. The .expect("a document schema has properties") would panic at test time (not production) if a document type ever produced a properties-less schema — acceptable for test infrastructure.

Version pairing (same Rust type, two schema versions)

emit::<Plan>(schema::PLAN, None) and emit::<Plan>(schema::PLAN_V3, None) emit byte-identical schemas except for the schema const. This is intentional: the parser reads both versions with the same Plan wire type, so the plan-2 schema must accept plan-3 members (e.g., grades). The test the_version_schemas_describe_what_the_parser_accepts explicitly validates this.

Outcome / OutcomeWire schema derivation

Outcome carries #[serde(from = "OutcomeWire", into = "OutcomeWire")]. Schemars follows the from type when both implement JsonSchema, so Outcome's schema correctly describes the wire form (OutcomeWire), not the Rust enum structure. UnresolvedWire with #[serde(untagged)] produces the expected anyOf in $defs. ✓

Handle schema — character vs. byte length

Handle::json_schema emits "maxLength": 256 (JSON Schema counts Unicode code points), while Handle::new enforces a 256-byte limit. A string of 256 four-byte characters would pass the schema but be rejected by the parser. The comment acknowledges this: "a schema bounds characters, so the byte bound is the parser's." Since schemas are documented as descriptive-only (the parser is authoritative), this is an intentional, consistent choice.

committed_schemas_equal_emitted_bytes bless path

RUSTEV_BLESS=1 removes the entire schema/ directory then rewrites it. The path is CARGO_MANIFEST_DIR/schema, which is scoped to this crate. Safe.

every_committed_document_validates_against_its_schema — title-to-schema matching

Schema titles for plain documents equal the version string (e.g., "rustev.plan/3"), which is then matched against doc["schema"]. Request/response schemas (title contains a space suffix like "rustev.remote-infer/1 request") are filtered out before building the lookup table and would never match a document's schema field. The assert!(checked >= 30) guard prevents silent no-op.

committed_documents traversal

Uses let-chain syntax (let Ok(b) = … && let Ok(v) = …) stabilised in Rust 1.88 (May 2025); given the project's modern toolchain this is fine. The schema/ directory is correctly excluded from document traversal.

Schema files spot-checked

rustev.snapshot-{1,2}, rustev.run-{1,3}, rustev.remote-*, rustev.plan-3 — all additionalProperties: false and schema const values match the Rust type structures and the registered schema-string constants.

No bugs, security issues, or inconsistencies found.

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

Group 3 of 3

Both changed files are straightforward and consistent with each other.

specs/027-node-and-wasm-bindings/spec.md

  • The new extends edge on spec: "031-public-api-and-release-family" for tools/rustev-release/ (directory, additive) directly matches the archive-policy change in the same PR, so the boundary claim is accurate.
  • The implementation record's inline comment references "spec 021, 3.5" while the extends entry points to spec 031; this is not a contradiction -- 021 contains the rule, 031 governs the directory, and the extends edge correctly targets the authority holder.
  • No forward-looking or unverified acceptance items are claimed for increments not yet delivered.

tools/rustev-release/archive-policy.json

  • "src/schema_emit.rs" is inserted in the correct alphabetical position: after run.rs (r < s) and before scope.rs (sch < sco). The list order is preserved.
  • No other entries are touched.

Nothing suspicious or incorrect.

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

Subject: f7437ce...7b46c86, diff digest cc8d63f368eefd5b91ca9f57c33fd9f2337fb725e665fc4f5f9b7d0850686871, 3 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Reviewing the group-1 files: Cargo dependency additions, and the first batch of new JSON Schema files.

Dependency additions (Cargo.lock / Cargo.toml / crates/rustev-contract/Cargo.toml)

  • schemars = "=1.2.3" (production dep, exact pin — consistent with the stated rationale of byte-identical schema emission)
  • jsonschema = "=0.59.0" (dev-dep only, correct placement for validation tests)
  • getrandom is now present at both 0.2.17 (for ring) and 0.3.4 (for new deps) — normal for Cargo
  • syn is now at 2.0.119 and 3.0.6; the serde_derive entry correctly disambiguates to syn 3.0.6 — fine

No issues in the dependency changes.

Schema files

The schemas are auto-generated from Rust types via schemars. They are internally consistent and additionalProperties: false is applied correctly throughout. However there is one meaningful contract gap:

Both rustev.judgment-2.schema.json and rustev.evidence-2.schema.json copy the Notice type definition verbatim from their version-1 counterparts. In both, Notice.action is typed anyOf: [Action, null] and is not in the required array. The schema's own description field reads: "Judgment 2: who can act on it (spec 033, 3.5.4); omitted in version 1." — meaning for version 2, action should be present and non-null on every notice. The schema fails to enforce this: a judgment/2 or evidence/2 document that emits null or omits action on any notice will still pass schema validation, silently violating the version-2 contract.

The same type (Notice) appears with the same loose definition in rustev.plan-2.schema.json, though the plan-2 format has less of a strong version-2 obligation there.

No security issues or logic bugs found in the Cargo changes or the schema content itself.

{"head": "d31dca609fb8d20e849764343cb9f9ac575bd611", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/schema/rustev.judgment-2.schema.json", "line": 1, "summary": "The Notice.$defs entry allows `action` to be null and omits it from `required`, but per spec 033 §3.5.4 (noted in the schema's own description) judgment/2 notices must carry a non-null `action`; the schema is identical to judgment-1 on this point and will pass invalid v2 documents."}, {"path": "crates/rustev-contract/schema/rustev.evidence-2.schema.json", "line": 1, "summary": "Same issue as judgment-2: the Notice type in evidence/2 schema still allows null/absent `action`, failing to enforce the version-2 contract from spec 033 §3.5.4."}]}

Group 2 of 3

Reading through the diff, this PR adds schemars::JsonSchema derives to all contract types and a new schema_emit.rs module that emits deterministic draft-2020-12 JSON Schemas for every public document type.

Schema generation / emit function (schema_emit.rs)

  • The root properties["schema"] replacement with {"type":"string","const":version} is correct: the field is already in required (non-optional), so the const constraint tightens it without removing it from required.
  • additionalProperties:false on the root object is derived from #[serde(deny_unknown_fields)] and confirmed present in the committed schemas.
  • T::LIMITS via the Document trait bound supplies the parse-limits record; all emitted document types implement Document.

Outcome/OutcomeWire (judgment.rs)
Outcome uses #[serde(from="OutcomeWire", into="OutcomeWire")] with both types now deriving schemars::JsonSchema. In schemars 1.x the from attribute causes the schema to be generated for OutcomeWire; both types have structurally identical variants so the result is the same either way, as the committed schema confirms.

Request/response schema ambiguity
DescribeRequest and DescribeResponse share the same schema const "rustev.remote-describe/1". Despite identical schema consts, additionalProperties:false differentiates them (e.g., a response with backends/version fails the request schema that only allows versions). The test correctly filters both from the document-validation pass, so committed fixtures for these won't be validated — a minor completeness gap, but not a correctness bug.

Handle schema (scope.rs)
maxLength:256 counts code points, not bytes. Multi-byte strings can satisfy the schema but exceed 256 bytes and be rejected by the parser. The comment explicitly acknowledges this ("a schema bounds characters, so the byte bound is the parser's"), consistent with the spec's "the schema is never stricter than the parser" (3.2.2).

Test traversal (tests/schemas.rs)
committed_documents() skips directories named schema, target, node_modules and requires tests in the path, correctly excluding both committed schema files and non-test data fixtures. The assert!(checked >= 30) sanity bound is modest but acceptable.

the_version_schemas_describe_what_the_parser_accepts
Adding grades:[] to a plan/2 document works because both plan/2 and plan/3 schemas are derived from the same Plan struct; grades is already an optional field in that struct, so both schemas list it in properties without including it in required.

No bugs found.

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

Group 3 of 3

The change adds src/schema_emit.rs to the archive policy's file list for rustev-contract, which matches the new source file introduced in this PR. The entry is inserted in correct alphabetical order between src/run.rs and src/scope.rs.

No issues found.

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

Subject: d29059a...d31dca6, diff digest c252b60b6e0847cbaf29a816e9980a5c6e6ef3dd4dc8c0f901ec0159dd7a9b8b, 3 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception October 20, 2026 17:46 — with GitHub Actions Inactive
@bartekus
bartekus force-pushed the impl/027-schema branch 2 times, most recently from becc7c4 to 86072c9 Compare October 20, 2026 18:57
@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Reviewing the group-1 changes: dependency additions (schemars, jsonschema) and the new golden schema files.

crates/rustev-contract/schema/rustev.execution-1.schema.json

RetryPolicy.max_attempts is described as 1..=8 (the first attempt is included in the count, so 0 is never valid) but the schema emits "minimum":0 — the bound that schemars derives from the underlying u32. A document with max_attempts: 0 would pass schema validation and violate the spec invariant. The same definition is embedded in rustev.plan-2.schema.json.

FallbackPolicy.backends is described as "at most 4, none repeated, never the bound backend" but the schema has no maxItems constraint. Up to 4 is a hard spec limit and is enforceable in JSON Schema.

Both gaps are generated artifacts: schemars maps u32 → minimum:0 and Vec<String> → no maxItems, and the richer constraints live only in doc-comments. If these schemas are used for external validation (the stated purpose — spec 027, 3.2.2), documents that violate the spec pass validation.

Cargo.toml / crates/rustev-contract/Cargo.toml

schemars is added as a production dependency of rustev-contract (the pure-core crate). Its transitive closure (dyn-clone, ref-cast, ref-cast-impl) is lightweight, and spec 027, 3.2.2 is cited as authorisation, so this is not a hard violation, but it does widen the pure-core dependency surface in a way worth flagging for maintainers to confirm is intentional.

No security issues found in the schema files themselves. The schemas are well-formed JSON Schema Draft 2020-12 with consistent $schema, additionalProperties: false, and correct const discriminators per version. The getrandom dual-version (0.2.17 for ring, 0.3.4 for new jsonschema chain) is unavoidable and expected.

{"head": "86072c941cd578de2cc0d99ce611616a64fd4343", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/schema/rustev.execution-1.schema.json", "line": 1, "summary": "RetryPolicy.max_attempts emits \"minimum\":0 but the spec requires 1..=8; a zero-attempt document passes schema validation."}, {"path": "crates/rustev-contract/schema/rustev.execution-1.schema.json", "line": 1, "summary": "FallbackPolicy.backends has no maxItems constraint despite the description capping it at 4, making the schema over-permissive for external validators."}, {"path": "crates/rustev-contract/schema/rustev.plan-2.schema.json", "line": 1, "summary": "Embedded RetryPolicy and FallbackPolicy carry the same minimum/maxItems gaps as the standalone execution schema."}]}

Group 2 of 3

Reviewing the schema emission module, test suite, and committed schema JSON files.

schema_emit.rs

The emit function mutates the derived schema value to add a "const": version constraint to the schema property. Since all root document structs include schema: String in their required array (not Option<>), the const constraint correctly restricts each schema file to its own version string. The unwrap_or_else(|| panic!(...)) guard on properties fires in the test suite for any type that accidentally produces a schema without properties — acceptable sentinel behavior.

tests/schemas.rs

  • committed_documents() uses let-chains (&& let Ok(b) = ...), stabilized in Rust 1.88. Given the project's rust-toolchain.toml and the current date this should be fine.
  • The every_committed_document_validates_against_its_schema test filters out .request. and .response. schema files from the validators, meaning committed test documents whose schema field equals e.g. "rustev.remote-infer/1" are silently skipped. This is a minor gap but doesn't cause false passes — it just omits some documents from validation coverage.
  • The sanity floor assert!(checked >= 30) is appropriate; the codebase has well over 30 JSON test documents.

Schema JSON files (spot-checked)

  • rustev.snapshot-1 / rustev.snapshot-2: identical structure, differ only in schema.const — correct for a shared Rust wire type.
  • rustev.remote-cancel-1.request.schema.json: title = "rustev.remote-cancel/1 request", schema.const = "rustev.remote-cancel/1" — file naming and const are consistent with emit(..., Some("request")).
  • rustev.run-3.schema.json: "additionalProperties":false present on all inline objects, parse limits present, schema.const = "rustev.run/3".
  • Handle schema: maxLength: 256 matches MAX_HANDLE_BYTES; Timestamp range [0, 253402300799999] matches MAX_TIMESTAMP_MS. Both hand-written JsonSchema impls are consistent with the parser's own enforcement.

judgment.rs — private wire types

OutcomeWire, UnresolvedWire, and ActionableUnresolved are private types that also derive schemars::JsonSchema. Because Outcome is tagged #[serde(from = "OutcomeWire", into = "OutcomeWire")], schemars will route through OutcomeWire's schema, producing the correct wire-format description. No issue.

schema_emit.rs — path safety under RUSTEV_BLESS

s.file is produced by version.replace('/', "-"), so the / in e.g. rustev.plan/3 becomes -. No path traversal is possible; the write path stays inside CARGO_MANIFEST_DIR/schema/.

No bugs, security problems, or inconsistencies found.

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

Group 3 of 3

Looking at the two files in this review group:

specs/027-node-and-wasm-bindings/spec.md

The new extends entry at the top of the diff (line ~30) references spec: "031-public-api-and-release-family" for the tools/rustev-release/ directory dependency. However, both the inline comment immediately above that entry and the body text of Increment 2 describe the obligation as coming from spec 021 section 3.5 ("packaging-and-first-release"), not spec 031. The comment says (spec 021, 3.5) and the body says spec 021 3.5. Spec 021 is where the archive-policy obligation originates; spec 031 is a separate spec ("public-api-and-release-family"). This mismatch means the extends edge points to the wrong authority spec.

tools/rustev-release/archive-policy.json

The new entry src/schema_emit.rs is inserted in correct alphabetical order between src/run.rs and src/scope.rs. No issues here.

{"head": "86072c941cd578de2cc0d99ce611616a64fd4343", "verdict": "findings", "findings": [{"path": "specs/027-node-and-wasm-bindings/spec.md", "line": 30, "summary": "The extends entry cites spec '031-public-api-and-release-family' for the tools/rustev-release/ dependency, but both the inline comment and the Increment 2 body text attribute the archive-policy obligation to spec 021 section 3.5; the authority spec reference is inconsistent."}]}

Subject: da2ccd6...86072c9, diff digest ca55194ec32c950c3543b339cfbf1da3a08c8059eeaf3c69387c4cf51b6e6bea, 3 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Cargo.lock — missing zmij package entry

jsonschema-value 0.59.0 in the lock file lists zmij as an activated (non-optional) dependency:

[[package]]
name = "jsonschema-value"
version = "0.59.0"
...
dependencies = [
 ...
 "zmij",
]

In Cargo.lock v4, the dependencies field only lists activated dependencies, so a corresponding [[package]] entry for zmij must exist. Alphabetically zmij (z-m…) sorts after zeroize (z-e…), which is the last visible package in the diff. No [[package]] entry for zmij appears after it. If the diff is complete, the lock file is inconsistent and any cargo build or cargo test invocation will fail with a manifest resolution error.

All other areas look correct: the schemars and jsonschema exact-version pins are coherent with the byte-stability rationale; jsonschema is restricted to [dev-dependencies] only; all schema $ref values are document-internal (#/$defs/…) so remote resolution is never triggered regardless of feature flags; parse-limit annotations are proportional across schema types; and the getrandom two-version split (0.2.17 for ring, 0.3.4 for the new jsonschema tree) is handled correctly in the lock file.

{"head": "87c531de33282d74f0e7ec4f0afddbfdbda5b68c", "verdict": "findings", "findings": [{"path": "Cargo.lock", "line": null, "summary": "jsonschema-value 0.59.0 lists `zmij` as an activated dependency but no [[package]] entry for zmij appears in the lock file; alphabetically it would follow zeroize, the last visible entry, making the lock file inconsistent and breaking builds."}]}

Group 2 of 3

Reviewing the schema emission infrastructure and Rust source changes.

schema_emit.rs emit() function — correctness

The function takes version: &str and overwrites the derived properties.schema entry with { "type": "string", "const": version }. Both the version-1 and version-3 calls for the same Rust type (e.g. RunRecord) use the same T::LIMITS, so parse-limit annotations are identical for both versions. That is consistent with the committed schemas and correct.

bounded.rs:965 — unnecessary derive

schemars::JsonSchema is added to a private test-only helper struct Doc. It is never used to emit a schema and adds noise to the dependency surface.

tests/schemas.rs committed_documents() — coverage gap

let mut stack: Vec<PathBuf> = ["crates", "packages", "backends", "tools"]
    .iter()
    .map(|d| root.join(d))
    .collect();

The integrations/ directory is not searched. integrations/rustev-jev/tests/fixtures/ and integrations/rustev-remote-http/tests/ contain JSON fixtures. Exchange records ("schema":"rustev.remote-exchange/1") in those directories are not covered by every_committed_document_validates_against_its_schema, leaving the exchange-record schema untested against real fixture data.

judgment.rs private wire types — intentional

OutcomeWire, UnresolvedWire, and ActionableUnresolved derive schemars::JsonSchema because Outcome carries #[serde(from = "OutcomeWire")]; schemars follows the from attribute and uses OutcomeWire's schema. The committed schemas correctly render Outcome as a oneOf matching OutcomeWire. No issue.

time.rs Timestamp manual impl

MAX_TIMESTAMP_MS is i64 (253_402_300_799_999) but the schema says "minimum": 0. The committed schemas reproduce this correctly and it matches the parser's enforcement range. No issue.

schema_emit.rs bless mode

let _ = std::fs::remove_dir_all(dir());
std::fs::create_dir_all(dir()).unwrap();

If remove_dir_all fails silently (permissions, locked file), create_dir_all succeeds on the existing directory and previously-stale files survive the bless. This is a dev-tooling concern only; the subsequent non-bless test would catch the mismatch.

{"head": "87c531de33282d74f0e7ec4f0afddbfdbda5b68c", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/bounded.rs", "line": 965, "summary": "schemars::JsonSchema is derived on the private test-only Doc struct where it serves no purpose and adds noise to the dependency surface."}, {"path": "crates/rustev-contract/tests/schemas.rs", "line": 106, "summary": "committed_documents() omits the integrations/ directory, so remote exchange record fixtures (rustev-remote-exchange/1) are never validated against the emitted schema in every_committed_document_validates_against_its_schema."}]}

Group 3 of 3

The two changed files in this group are a spec documentation update and an archive-policy entry. I'll check each carefully.

specs/027-node-and-wasm-bindings/spec.md

The new extends edge (spec: "031-public-api-and-release-family", unit: tools/rustev-release/, nature: additive) correctly signals that this increment makes an additive change to a directory that spec 031 owns, consistent with the archive-policy.json change below. The comment is accurate.

The Increment 2 prose is internally consistent:

  • Claims schemars =1.2.3 exact-pinned and jsonschema =0.59.0 as a dev-dependency.
  • States HTTP and file resolution are disabled for the jsonschema validator -- good security practice preventing filesystem/network access during tests.
  • Describes byte-stable canonical emission and RUSTEV_BLESS=1 rewrite semantics, which is a standard pattern.
  • Cross-references match: the spec says the new file joins the archive list, and it does.

No inconsistencies or missing cross-references observed.

tools/rustev-release/archive-policy.json

src/schema_emit.rs is inserted between src/run.rs and src/scope.rs. Alphabetically: run < schema_emit (r < s) and schema_emit < scope (sch < sco since h < o). The insertion position is correct.

No issues found in either file.

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

Subject: da2ccd6...87c531d, diff digest c71b883fe9f8eeb0bc8b244c441e87d5fd78bddc53bdff3cda5dc7dd6492f7f1, 3 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception October 20, 2026 19:15 — with GitHub Actions Inactive
@bartekus
bartekus force-pushed the impl/027-schema branch 2 times, most recently from 90c1fd7 to 5b772dc Compare October 20, 2026 19:27
@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Reviewing the Cargo dependency additions and the new schema files.

Cargo.lock / Cargo.toml / crates/rustev-contract/Cargo.toml

Both schemars and jsonschema are exactly pinned (=1.2.3 and =0.59.0), which is intentional and documented. The large pull of new transitive dependencies (WASM/WASI bindings via getrandom 0.3.4 → wasip2 → wit-bindgen, plus wasm-bindgen, js-sys, etc.) is unusual for a server-side crate but these are all conditional on the target platform and will not affect native builds. jsonschema is correctly constrained to [dev-dependencies].

Schema files

The definition-1 vs definition-2, evidence-1 vs evidence-2, and judgment-1 vs judgment-2 schemas are nearly identical pairs — the only structural difference between each pair is the "const" value on the schema field (rustev.judgment/1 vs /2, etc.). This is consistent with schemars emitting schemas from shared Rust types.

Finding — judgment-1 and evidence-1 schemas are too permissive for their version

rustev.judgment-1.schema.json: the Outcome oneOf includes all five variants — propose, escalate, unresolved, refused, and needs_input. The schema's own embedded description states: "Version 1 uses Propose, Escalate and Unresolved; version 2 (spec 033, 3.5.1) … adds Refused and NeedsInput." Including the v2 variants in the v1 schema means the v1 schema cannot be used to detect or reject a mislabelled v2 judgment (one whose schema field was incorrectly set to rustev.judgment/1). The same applies to the Outcome/Judgment type embedded in rustev.evidence-1.schema.json, which also includes all five outcome variants.

This is a correctness issue rather than a security issue, but it weakens the intended contract enforcement of the schema versioning system. The v1 schemas should only accept propose, escalate, and unresolved outcomes if strict version fidelity is required.

{"head": "5b772dc5267d601e01faff52c00c5fcd90f33368", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/schema/rustev.judgment-1.schema.json", "line": 1, "summary": "The Outcome oneOf includes refused and needs_input variants which the schema's own description identifies as v2-only additions, making the v1 schema too permissive to enforce version constraints."}]}

Group 2 of 3

Reviewing the schema emission infrastructure, committed JSON Schema files, and the Rust type annotations in this group.

Schema correctness: The emit function correctly replaces the schemars-generated schema property with a version-specific const, adds x-rustev-parse-limits, and produces canonical bytes. The file naming (version.replace('/', "-") + optional part suffix) matches all 16 committed filenames in this group.

Outcome / UnresolvedWire wire fidelity: Outcome carries #[serde(from = "OutcomeWire", into = "OutcomeWire")], which causes schemars to emit the schema from OutcomeWire. The committed run-1 and run-3 schemas correctly show UnresolvedWire in $defs with anyOf[ActionableUnresolved, Unresolved], faithfully representing the v1/v2 dual-parse design.

Parse-limit annotations: allow_fractional_numbers: false on snapshot/plan/source schemas, true on remote protocol schemas — matches bounded.rs configurations visible in the committed files.

Handle / Timestamp / Decimal / digest-id custom JsonSchema impls: All produce schemas (minLength/maxLength, integer bounds, hex pattern) consistent with the bounded parser's own enforcement logic. The Decimal pattern \\.[0-9]+ correctly round-trips through JSON escaping to \.[0-9]+ in regex.

Test coverage: committed_schemas_equal_emitted_bytes ensures determinism and no stale/missing files. every_committed_document_validates_against_its_schema validates ≥30 golden files, and the checked >= 30 assertion guards against silently vacuous runs.

One genuine concern: ContinuationInputs<'a> in actionability.rs:443 derives schemars::JsonSchema despite having a lifetime parameter and not being a Document type. It is not referenced by any emitted schema's type graph, so it has no observable effect on output — but it is misleading about which types contribute to the schema set, and lifetime-parametrised JsonSchema impls are unusual territory.

No other bugs, security issues, or inconsistencies found across the 16 committed schema files, the Rust source additions, and the test harness in this group.

{"head": "5b772dc5267d601e01faff52c00c5fcd90f33368", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/actionability.rs", "line": 443, "summary": "ContinuationInputs<'a> derives schemars::JsonSchema despite having a lifetime parameter and never being a Document type, so it cannot appear in any emitted schema and the derive is misleading noise."}]}

Group 3 of 3

Reviewing the two files in this group:

specs/027-node-and-wasm-bindings/spec.md

The new extends edge declares spec 027 extending spec 031's authority over tools/rustev-release/ with additive nature, which correctly covers the archive-policy.json modification. The comment's attribution ("spec 021 3.5's rule, in the directory spec 031 owns") is accurate and not contradicted by the YAML entry. The Increment 2 prose is internally consistent: it names the new source file, the test mechanism (RUSTEV_BLESS=1), both new dependencies with exact pins (schemars =1.2.3, jsonschema =0.59.0), and explicitly notes jsonschema runs without HTTP or file resolution (good security practice). The spec correctly notes that only jsonschema is a dev-dependency while schemars is a production dependency, consistent with schema_emit.rs going into the archive list rather than being test-only.

tools/rustev-release/archive-policy.json

src/schema_emit.rs is inserted between src/run.rs and src/scope.rs. Alphabetical order is: run < schema_emit < scope -- correct.

No issues found in either file.

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

Subject: 124d1c9...5b772dc, diff digest 34cedba6bf24011f977e47a515d182a4843319be0b621da5519b5685b7d81985, 3 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Reviewing the diff — Cargo dependency additions, workspace pinning, and newly emitted JSON Schema files.

Cargo.toml / Cargo.lock: Pin strategy is sound. The =1.2.3 schemars pin and =0.59.0 jsonschema dev-pin are intentional for schema byte-identity. The getrandom 0.2.17 disambiguation in ring's subtree is a normal Cargo artifact; no issue.

Schema files — structural finding: The v1 schemas (definition-1, evidence-1, judgment-1) include types that the inline descriptions explicitly label as "Version 2" only. Concretely:

  • rustev.definition-1.schema.json: TypeDecl includes nullable ("Version 2, record fields only") and map ("Version 2") variants, InputDecl carries evidence and on_disagreement ("Version 2"), and StepBody includes corroborate ("Version 2: the only way a grade rises"). A definition/1 document using any of these passes schema validation but should be rejected as invalid.

  • rustev.judgment-1.schema.json: Outcome includes refused and needs_input variants and the comment on Outcome itself says "version 2 (spec 033, 3.5.1) replaces Unresolved with UnresolvedAction and adds Refused and NeedsInput". Notice.action is also present, described "Judgment 2: who can act on it (spec 033, 3.5.4); omitted in version 1."

  • rustev.evidence-1.schema.json: InputEvidence.dropped, .entries, .presence, .resolution, .meta are all described as "Evidence 2" fields, yet present in the v1 schema. The top-level checks field is annotated "Evidence 2 with actionability".

This appears to be a side-effect of generating schemas from shared Rust types (schemars derives from the full superset struct), but it means external validators relying on these schemas (especially important for spec 027's Node/WASM bindings audience) cannot catch version misuse — a v1 document containing {"nullable": ...} type declarations or a refused outcome passes validation. The Rust runtime enforces the distinction internally, but the published schema surface does not.

No security issues, no injection risk in the schema content itself. No other bugs found.

{"head": "40bf9f8dbe8c24d4d017f4617025d15524d0ffad", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/schema/rustev.definition-1.schema.json", "line": 1, "summary": "v1 schema includes v2-only TypeDecl variants (nullable, map), InputDecl fields (evidence, on_disagreement) and StepBody variant (corroborate) whose inline descriptions say \"Version 2\", so external validators accept invalid definition/1 documents."}, {"path": "crates/rustev-contract/schema/rustev.judgment-1.schema.json", "line": 1, "summary": "judgment/1 schema includes the v2-only Outcome variants (refused, needs_input) and Notice.action field, all explicitly described as absent in version 1, so external validators cannot catch version misuse."}, {"path": "crates/rustev-contract/schema/rustev.evidence-1.schema.json", "line": 1, "summary": "evidence/1 schema includes the top-level checks array and InputEvidence v2 fields (dropped, entries, presence, resolution, meta) whose descriptions explicitly mark them as Evidence 2, allowing invalid v1 documents to pass schema validation."}]}

Group 2 of 3

Reviewing the schema emission infrastructure, Rust type derivations, committed JSON schemas, and test suite.

schema_emit.rs emit function — schema field override

In schema_emit.rs:50-59, the emitter replaces the schemars-derived schema property with {"type": "string", "const": version}. The bounded parser accepts any string in that field and validates the version discriminant at a higher layer, so for raw wire parsing the schema is marginally stricter than the parser. The design doc acknowledges this ("the schema describes the parser"), and the the_version_schemas_describe_what_the_parser_accepts test verifies the schema never rejects what the parser accepts. No bug, but the intent is explicit.

Handle schema: maxLength counts code points, not bytes (scope.rs:67-78)

fn json_schema(_: &mut schemars::SchemaGenerator) -> schemars::Schema {
    schemars::json_schema!({
        "type": "string",
        "minLength": 1,
        "maxLength": MAX_HANDLE_BYTES   // ← counts Unicode scalar values
    })
}

JSON Schema's maxLength counts Unicode scalar values; the bounded parser enforces a byte limit. A Handle of MAX_HANDLE_BYTES two-byte UTF-8 characters (e.g., "éé…") passes the schema but would be rejected by the parser. The comment documents this gap ("a schema bounds characters, so the byte bound is the parser's"), which is consistent with the "descriptive, not prescriptive" design, but external schema consumers who rely on the schema for validation would incorrectly accept over-long handles. No committed test document exercises this path, so the every_committed_document_validates_against_its_schema test does not catch it.

committed_documents uses let chains requiring Rust ≥ 1.88 (tests/schemas.rs:84-86)

&& let Ok(b) = std::fs::read(&p)
&& let Ok(v) = serde_json::from_slice::<serde_json::Value>(&b)

let-chain stabilisation landed in Rust 1.88 (May 2025). If the pinned toolchain in rust-toolchain.toml predates that, this file fails to compile. Cannot confirm the pinned version from the diff alone.

RUSTEV_BLESS silently swallows remove_dir_all errors (tests/schemas.rs:18)

let _ = std::fs::remove_dir_all(dir());

Permission failures or OS errors are discarded, so a bless run on a read-only directory silently appears to succeed and then fails on create_dir_all or write, which produces a confusing error message. Minor DX issue.

No correctness bugs or security problems found in the core logic—schema derivation, canonicalization, determinism test, and the version-compatibility probes are all sound.

{"head": "40bf9f8dbe8c24d4d017f4617025d15524d0ffad", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/scope.rs", "line": 74, "summary": "Handle's JSON Schema uses maxLength which counts Unicode scalar values, not bytes, so the schema accepts multi-byte UTF-8 strings that the bounded parser would reject on byte-length grounds."}]}

Group 3 of 3

Reviewing the two files in this group.

specs/027-node-and-wasm-bindings/spec.md

The new extends entry claims an additive extension into tools/rustev-release/ (owned by spec 031), which is consistent with modifying archive-policy.json. The comment correctly distinguishes the owning spec (031) from the rule that mandates the entry (spec 021 §3.5), and the body text repeats both facts without contradiction.

The Increment 2 description is internally consistent: schemars and jsonschema versions are exact-pinned, the golden-file bless pattern is conventional, the list of emitted schema types matches the schema files listed in the SUBJECT, and the statement "No document, parse bound or canonical byte changes" is a correctness commitment the other groups of this PR (covering src/) would need to honor.

tools/rustev-release/archive-policy.json

"src/schema_emit.rs" is inserted between "src/run.rs" and "src/scope.rs". Alphabetically: run < schema_emit < scope -- correct placement.

No bugs, security issues, or inconsistencies found.

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

Subject: 124d1c9...40bf9f8, diff digest ea88a275e0efd83452cf86081200d896cdce7780d8fb6959ba2957ae85570748, 3 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Group 1 of 3

Reviewing the diff for the files in group 1: Cargo.lock, Cargo.toml, crates/rustev-contract/Cargo.toml, and the schema JSON files.

Cargo.lock / Cargo.toml / crates/rustev-contract/Cargo.toml

  • schemars is exact-pinned at =1.2.3 (workspace) and jsonschema at =0.59.0 (dev-dep) — both intentional per the comments. The feature set ["derive", "std"] with default-features = false is sufficient for pure-data types.
  • getrandom now has two entries (0.2.17 for ring, 0.3.4 for the new jsonschema chain) — correctly resolved.
  • syn now has both 2.0.119 and 3.0.6 — expected for the mixed dependency graph.
  • jsonschema-value 0.59.0 lists zmij as a dependency, but no [[package]] block for zmij appears among the additions. Since the diff only shows changed lines, zmij is either pre-existing in the lock file (implausible — nothing in the base tree would pull it) or the diff is truncated. The actual cargo build would fail if it were missing, so this is likely a diff-display artifact rather than a real gap.

Schema JSON files

  • All schemas carry a $comment explicitly disclaiming that they are descriptive and that "the parser is the only authority on validity." The permissiveness (e.g., definition/1 schema accepting nullable, map, corroboration — all version-2 additions) is intentional and documented.
  • plan-2.schema.json includes plan/3 fields (grades, sources, actionability) as optional; these are typed ["array","null"] so a true plan/2 document passes validation, and plan/3 documents would fail on "const":"rustev.plan/2" — correct behavior.
  • Judgment.schema in the evidence schemas is typed as open "type":"string" (not const) to accommodate both judgment/1 and judgment/2 embedded in an evidence document — correct.
  • The rustev.evidence/1 and rustev.evidence/2 schemas are structurally identical except for the schema constant, consistent with the single-type-reads-both-versions design.

No bugs, security problems, or meaningful inconsistencies found.

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

Group 2 of 3

Reviewing the source changes and committed schema files in this group, focusing on correctness of the new schema_emit.rs module, the custom JsonSchema implementations, and consistency between the Rust types and generated schemas.

Custom JsonSchema implementations

  • Timestamp: manually emits minimum: 0 / maximum: MAX_TIMESTAMP_MS, consistent with the committed schemas (e.g., 253402300799999). Correct.
  • Decimal: emits the pattern ^-?(0|[1-9][0-9]*)(\\.[0-9]+)?$. Matches committed schemas. Correct.
  • Handle: emits maxLength: MAX_HANDLE_BYTES as a character bound while the parser enforces a byte bound; the comment in scope.rs acknowledges this explicitly, and the $comment in every schema notes the parser is the sole authority. Acceptable as documented.
  • ID types (ArtifactId, etc.) via the identity! macro: delegate to digest_schema() which emits the expected sha256:… pattern. Correct.
  • DurationMs with #[serde(transparent)] over u64: the derived JsonSchema delegates to u64 producing format: uint64, minimum: 0. Correct.

schema_emit::emit function

The function generates a draft 2020-12 root schema, then overwrites properties["schema"] with {"type": "string", "const": version} and appends x-rustev-parse-limits from T::LIMITS. This is sound because:

  • All document types are structs with a schema: String field, so properties is always present.
  • The schema field has no doc comment in any document type, so no description is lost on overwrite.
  • required for schema is already set by the derive and is not disturbed.

For version-paired types (e.g., Plan covering plan/2 and plan/3), both emitted schemas share the same $defs (since they use one Rust type) but differ only in title and the schema const. This is intentional and documented in $comment.

Outcome via serde(from = "OutcomeWire")

Outcome uses #[serde(from = "OutcomeWire", into = "OutcomeWire")]; schemars correctly delegates to OutcomeWire's schema. The committed schemas confirm this: Outcome appears as the OutcomeWire variant structure, with UnresolvedWire and ActionableUnresolved in $defs. Correct.

address: Address optionality in Consequence

The committed schemas consistently exclude address from required in every Consequence variant. Address derives Default (#[default] on Computed), and the description "computed from its causes (when omitted)" confirms intentional #[serde(default)] usage. Consistent.

File naming and schema constants

version.replace('/', "-") produces correct file names for all emitted schemas (e.g., rustev.run-1.schema.json, rustev.remote-cancel-1.request.schema.json). All committed file names and schema const values match the expected output.

Cross-checking committed schemas against source

Spot-checked SupplyEntry, RequestDoc, InferRequest, ReplayBundle, RuntimeReasonDoc, and SourceDescriptor: all required fields match the non-optional Rust fields; optional fields correctly appear as type: ["...", "null"] or absent from required. No discrepancies found.

No bugs, security issues, or inconsistencies identified.

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

Group 3 of 3

Reviewing the three files in this group.

crates/rustev-contract/tests/schemas.rs

committed_schemas_equal_emitted_bytes sorts the on-disk names (committed.sort()) but does not sort names before the assert_eq!:

committed.sort();
let names: Vec<String> = emitted.iter().map(|s| s.file.clone()).collect();
assert_eq!(committed, names, …);   // names is unsorted

If document_schemas() returns schemas in any order other than alphabetical, the test fails even though the file sets are identical. The emission_is_deterministic_and_canonical test validates that calling document_schemas() twice gives the same ordering, but does not guarantee alphabetical order. This is a test-correctness bug: names should be sorted before the comparison, or the assertion should use a set comparison.

specs/027-node-and-wasm-bindings/spec.md

The new increment 2 prose is internally consistent and matches the test file. The extends edge on tools/rustev-release/ is justified by the archive-policy addition. No issues.

tools/rustev-release/archive-policy.json

src/schema_emit.rs is inserted in correct alphabetical position (after src/run.rs, before src/scope.rs). No issues.

{"head": "c6068673c5bc53ad8892a5ac0abb540b418974dd", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/tests/schemas.rs", "line": 31, "summary": "names is collected in document_schemas() order and compared against a sorted committed list; if emission order is not alphabetical the test fails spuriously despite identical file sets."}]}

Subject: 10210e9...c606867, diff digest 15ebb6a193ec38ea136123f4631bbb8b48caead893c99a33cb59278f1b038f8a, 3 call(s). An AI comment is not an approval.

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

Copy link
Copy Markdown

AI review (no-findings)

Group 1 of 3

Reviewing the diff in group 1: dependency additions (Cargo.lock, Cargo.toml, crates/rustev-contract/Cargo.toml) and the first 12 JSON Schema files.

Dependencies

  • schemars = "=1.2.3" is pinned exactly in the workspace, correct for byte-stable schema emission.
  • schemars lands as a production dependency of rustev-contract; jsonschema is correctly dev-only. The split is deliberate: runtime consumers can call JsonSchema impls; tests validate golden fixtures against emitted schemas.
  • Two versions of getrandom (0.2.17 for ring, 0.3.4 for new crates) and two of syn (2.0.119, 3.0.6) are normal Cargo resolution, not a concern.

Schema files

  • The $comment correctly states schemas are descriptive and the bounded parser is the authority on validity — so non-standard "format":"uint64" / "format":"double" annotations, absent pattern enforcement on regex-described strings, and missing maxProperties are all intentional.
  • Version constants are consistent: definition-1 → const:"rustev.definition/1", definition-2 → const:"rustev.definition/2", etc.
  • The embedded Judgment type inside evidence schemas uses "schema":{"type":"string"} (open) rather than a const — correct, because evidence of either version can embed a judgment of either version.
  • The plan-2 schema correctly admits plan-3 fields (grades, sources, actionability) as nullable, matching the stated "admits what the type admits, including later-version members" policy.
  • rustev.calibration-1.schema.json uses oneOf with a single branch for CalibrationMethod — unusual but valid; this is how schemars emits a single-variant enum.
  • The $defs cross-references all resolve within each file.

No bugs, security problems, or inconsistencies found in this group.

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

Group 2 of 3

The diff adds schemars::JsonSchema derives across all contract types, manual JsonSchema impls for Decimal, Handle, Timestamp, and ID types, a new schema_emit.rs module, and committed schema JSON files. I reviewed each area for bugs, security issues, and inconsistencies.

schema_emit.rs — emit logic: The function generates a schema for type T, then overwrites the schema property with {"type": "string", "const": version}. This correctly pins the wire discriminator. The same T (e.g., Plan) is used for multiple version strings; both calls produce identical $defs structures differing only in schema const and title, which is the intended behaviour described in the comment.

Outcome / OutcomeWire relationship: Outcome uses #[serde(from = "OutcomeWire", into = "OutcomeWire")]; schemars (0.8+) follows from and generates the schema for OutcomeWire instead of Outcome. The committed schemas confirm this — "UnresolvedWire" and "ActionableUnresolved" appear in $defs and "Outcome" references the correct wire variants. The result matches the actual wire format.

Handle maxLength approximation: maxLength: 256 counts Unicode code points; the parser enforces 256 bytes. The comment in scope.rs explicitly documents this gap ("a schema bounds characters, so the byte bound is the parser's"). The $comment on every schema file also states the parser is the sole authority on validity.

Timestamp bounds: minimum: 0, maximum: 253402300799999 matches MAX_TIMESTAMP_MS. ✓

required arrays: Checked against the Rust struct definitions for RunRecord, Plan, Snapshot, SourceDescriptor, InferResponse, and others; all required fields are present and no Option<T> fields are incorrectly required.

Shared-type multi-version schemas: emit::<EvidenceRecord>(EVIDENCE, …) and emit::<EvidenceRecord>(EVIDENCE_V2, …) both produce schemas that admit v2 fields under the v1 const — intentional per the stated policy ("the parser reads both versions with one type").

File name derivation: version.replace('/', "-") + optional .{part} + .schema.json matches every committed file name in the diff.

Singletons / unit variants (EvictionOrder::Fifo, BatchChargeAllocation::EvenRemainderByMemberIndex, CalibrationMethod::Temperature1): Committed schemas show correct const/enum representations.

No bugs, security issues, or inconsistencies found.

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

Group 3 of 3

Reviewing the three files in this group.

crates/rustev-contract/tests/schemas.rs

The bless path in committed_schemas_equal_emitted_bytes is correct: removes the old directory, recreates it, writes each schema with exactly one appended \n, and returns. The read-back check (on_disk.strip_suffix(b"\n") == Some(&s.bytes[..])) is consistent with how the bless path writes files.

committed_documents builds the workspace root from env!("CARGO_MANIFEST_DIR") plus ../.. (compile-time, not user-controlled). The let-chain syntax (let Ok(b) = … && let Ok(v) = …) requires Rust 1.88+, stabilised May 2025 -- fine for an October 2026 workspace.

In every_committed_document_validates_against_its_schema, the validator map is keyed by v["title"].as_str().unwrap() from the schema JSON. Documents are matched by doc["schema"]. If the title format ever diverges from the document schema string, documents are silently skipped rather than rejected. The checked >= 30 floor guards against wholesale mismatches but would not catch a single document type being silently excluded. This is a test-design concern, not a correctness bug, and the floor makes it hard to miss entirely.

The the_version_schemas_describe_what_the_parser_accepts test modifies a golden judgment (n["notices"]) and then clones that into an evidence record (en["judgment"]["notices"] = n["notices"].clone()). Since n holds the mutated value at that point, the clone is correct.

specs/027-node-and-wasm-bindings/spec.md

The new extends edge pointing to tools/rustev-release/ is consistent with the archive-policy change below. The Increment 2 narrative accurately summarises the new source file, pinned dependencies, bless workflow, and the checked >= 30 guarantee. No inconsistencies with the other two files.

tools/rustev-release/archive-policy.json

src/schema_emit.rs is inserted alphabetically between src/run.rs and src/scope.rs (r < sch < sc -- h < o confirms the ordering). Correct.

No bugs, security issues, or inconsistencies found.

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

Subject: c972cfa...d4fc8eb, diff digest 4638eefdcb9654f872245a227178a8adc4d7ad0a6e543892f856e390a29c1f8c, 3 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit 2cda285 into main Oct 20, 2026
7 checks passed
@bartekus
bartekus deleted the impl/027-schema branch October 20, 2026 20:26
bartekus added a commit that referenced this pull request Oct 20, 2026
Spec 027, increment 3 of 7: `rustev-surface`, the shared command
surface, adopted by the CLI. Stacked on #126. **Merges only after the
owner ratifies draft spec 045 (#127)**, which admits `rustev-surface` to
the release family in its own layer before the CLI.

- `crates/rustev-surface`: `plan check|compile|show`, offline `replay`,
`eval`, `gate`, `calibrate fit|qualify`, shared dependency reading, the
task adapter, command output and exit codes, and the `run` result
envelope. The CLI's code, moved: typed arguments plus a `Host`
(bounded/budgeted reads by label, never-overwrite publication,
all-or-none writes, label joining) and a rules-descriptor hook. Depends
on contract, core, eval, serde, serde_json only.
- The CLI keeps argument parsing, its file-system host (`Reads`
implements `Host`), the store resolver, the rules backend and the
runtime; each command checks flags and calls the surface; `run` prints
through the surface envelope.
- Every CLI test passes with goldens unchanged (none re-blessed).
`tests/memory_host.rs` drives the surface from an in-memory host and
gets the CLI's golden bytes for `plan check` and `plan show`.
- Release tooling: `rustev-surface` in `release-set.json` (layer 4, CLI
layer 5, upload order), the release-set test's member list, and
`archive-policy.json` (new surface allowlist; `adapter.rs`/`out.rs`
leave the CLI's). `rustev-release` manifests and archives tests pass;
`make boundaries` passes.

Review round 1 (3 findings): (1) the merge precondition is deliberate:
spec 045 is drafted in #127 for the owner's ratification and this
increment waits on it, as its record says; (2) fixed: the test host's
`write_all` removes what it wrote when a later write fails; (3) the test
host reads at most `max` bytes, exactly as the CLI's file host does (a
caller detecting an oversized input asks for its limit plus one and
compares lengths); it has no aggregate budget, so it reports none; the
code says so.

Review round 2 (1 finding): as in round 1, the precondition is
deliberate and tracked: spec 045 is drafted in #127 for ratification;
this pull request is not merged before it.

Review round 3 (3 findings): (1) the spec 045 precondition stands as
stated (#127, awaiting ratification); (2) `Host::ensure_absent` is
documented as a pure, repeatable check, which every command relies on;
(3) fixed: `addressing` is private to the envelope; `judged` is the
public entry.

Review round 4 (2 findings): (1) the spec 045 precondition stands (#127,
awaiting ratification); (2) Cargo adds `Cargo.toml.orig`, `Cargo.lock`,
`.cargo_vcs_info.json` and the workspace readme beyond `include` (as for
every release member), and `rustev-release`'s archives test compares
`cargo package --list` with the policy; the manifest comment says so.

Review round 5 (2 findings): (1) the spec 045 precondition stands (#127,
awaiting ratification); (2) the test host reads at most `max` bytes
exactly as the CLI's file host does; a caller detecting an oversized
input asks for its limit plus one byte and compares lengths, which the
surface's callers do. (Increment 5 replaces this test host with the
shared `host::Memory`.)

Review round 6 (1 finding): spec 045 is added by #127, not this branch,
by design: this PR is held (no auto-merge) until #127 merges and the
owner ratifies 045. The spec record now names that dependency and the
hold explicitly. Restacked on #126.

Review round 7 (1 finding, fixed): `eval::write_all` takes its files by
value and moves the bytes into the host's list; nothing is copied.

Review round 8 (1 finding): `cargo package` writes `Cargo.lock` into
every archive, library or not (`cargo package -l -p rustev-surface`
lists it), and every member's allowlist names it; the archive test
compares against real `cargo package` output and passes. The spec record
now says so, and records spec 045's ratification (A-42).

Review round 9 (3 findings): (1, 2) Spec 045 is ratified (A-42) and
lands with #127, which waits only on the owner's environment approval;
this branch is rebased onto main after #127 merges, before it can merge,
so 045 is in the tree it merges into. (3) fixed: the crate's keywords
and category describe a library (`decision-engine`, `commands`,
`bindings`; `development-tools`).

CI `verify` (spec 006's mutation seeds) failed on this branch: the seeds
still named `crates/rustev-cli/src/` files whose command logic this PR
moves into `rustev-surface`. Fixed: the 13 seeds in moved code now name
the surface file their anchor lives in (one anchor changed with the
move: `host.ensure_absent`), and run the CLI's tests and the surface's
own, since the adapter's unit tests moved with it. Locally all 29 seeds
were run: 27 detected by the CLI's tests alone, and the two adapter
seeds detected once the surface's tests run too (4/4 in the adapter
category). The spec record says so.
bartekus added a commit that referenced this pull request Oct 21, 2026
Spec 027, increment 5: the WebAssembly package. Stacked on #129.

- `integrations/rustev-wasm` (`publish = false`, npm only; excluded from
the crates.io release set): `version`, `check`, `compile`, `show`,
`replay`, `eval`, `gate`, `calibrateFit`, `calibrateQualify` through
`rustev-surface` with an in-memory host (`rustev_surface::host::Memory`,
new, also used by the surface's tests). No runtime, backend, sink or
clock; time is an argument; external items resolve through a synchronous
host callback.
- `make bindings`: exact pins (`wasm-bindgen-cli` 0.2.129 = crate,
`wasm-opt` 116), `web`/`bundler`/`nodejs` targets at `-Oz` (a `wasm`
cargo profile used only here), declaration drift check plus strict
type-check, import allowlist, size and instantiation budgets with a
measurement document, and the JavaScript conformance runner.
- Declarations: `rustev-documents.d.ts` generated offline from the
committed schemas by `json-schema-to-typescript` 16.0.0 (committed
lockfile), type-checked by TypeScript 5.9.3 strict. Generated: 10k of
this PR's lines.
- Imports: only `wasm-bindgen` glue, each reviewed in
`wasm-imports.json`.
- Conformance: the harvest marks pure-command cases for the `wasm`
surface and records rules programs' derived descriptors; all 23 such
cases print the CLI's golden bytes and exit codes on WebAssembly.
- **Measurement (local):** raw 2,215,589 B (over the 2,097,152 B budget
by 5.6%), gzip 762,689 B (under 786,432), Brotli 543,501 B, Node
instantiation median 3.5 ms (budget 50). `make bindings` fails at the
raw gate as 3.10.4 requires; the budget change is drafted as spec 046
for the owner. Chromium timing and the CI measurement come with the
`bindings` job (increment 7).

Review round 1 (2 findings): (1) the resolver passes up to `maxBytes`
plus one byte on purpose, so the library classes an item past its budget
`oversized` exactly as for the CLI's store, which reads one byte past
the maximum; the comment now says so (anything longer is inaccessible).
(2) Fixed: the memory host names the case: an output that already
exists, or a label that names an input. Declarations regenerated after
#126's schema change (Timestamp range).

Review round 2 (3 findings): (1) fixed: `make bindings` refuses first
when cargo metadata names no target directory, so no path is built from
an empty prefix. (2) fixed: `Memory`'s outputs are private, with an
`output(label)` copy accessor; only `create` and `write_all` borrow
them, never across a call. (3) No case names `wasm` on a `run` (the
harvest gives `run` cases `cli` and `native`; `run` is no WebAssembly
command, 3.1.1), so none throws today; the runner now reports such a
case as a failure instead of ending, and the code says why. Restacked on
#129.

Review round 3 (4 findings): (1) `"private": true` is deliberate until
publication: spec 031 owns the npm release and makes the package
publishable then, so no build of this increment can be published by
accident; the spec record says so. (2) fixed: a test pins `join`: an
empty directory is the binding's top level, so the label is the name
alone. (3) lodash 4.18.1 is published on the public registry (`npm view
[email protected] version` answers 4.18.1) and the lockfile resolves it from
registry.npmjs.org with its integrity hash. (4) fixed: a throwing module
call fails its case and the runner continues.

Review round 4 (4 findings): (1) fixed: a derived descriptor that does
not canonicalize fails the harvest naming its program, never a silent
gap. (2) fixed: `Memory`'s inputs are private like its outputs, read
through `inputs()`. (3) Repeated: lodash 4.18.1 is on the public
registry (`npm view [email protected] version` answers 4.18.1); the lockfile
resolves it from registry.npmjs.org with its integrity hash, so the slot
is not unclaimed. (4) No `run` case names `wasm`: the harvest gives a
case `wasm` only when its command is pure, and every `run` case's
surfaces are `["cli"]` in this branch (`native` joins in #132).
Restacked on #129.

Review round 5 (6 findings): (1) Refusing an output that names an input
is deliberate and matches the CLI: on a file system the input is a file
at that path and the file host refuses to replace it, so every surface
gives the same outcome; the code says so. (2) fixed: `CARGO_TARGET` is
read by parsing cargo's JSON, not by a regex. (3) fixed: the unreachable
error arm is an `expect` stating why (`ms` admits at most 2^53 - 1). (4)
fixed: the harvest refuses a `--rules` argument that is not a plain
relative path before writing a descriptor under it. (5) fixed:
`wasm-check.mjs` parses `--chromium-ms`, records the median and fails it
against the 3.10.6 budget (the CI job of increment 7 supplies it). (6)
Repeated and wrong: lodash 4.18.1 is published (`npm view [email protected]
version`), and `npm ci` installs it from the lockfile locally and in CI.
Restacked on #129.

Review round 6 (3 findings): (1) fixed: the message states the
requirement (`must be a non-negative integer`). (2) No case names `wasm`
on a `run`: every case whose command is `run` lists `["cli"]` in this
branch (checked over all case files), and the manifest aggregates them
unchanged. (3) fixed: a flag without a value fails the case naming it;
every flag of the harvested commands takes one value (checked over all
case files).

Review round 7 (1 finding, fixed): `CARGO_TARGET` is evaluated lazily,
once, on first use, so only `make bindings` runs cargo metadata and
node; other targets pay nothing.

Review round 8 (2 findings, the same as rounds before): no `run` case
names `wasm`. The diff placed new `derived` entries on the `run` cases
next to the `wasm` surface added to neighbouring pure cases. To leave
nothing to misread, the harvest now records derived descriptors only for
the cases the WebAssembly surface runs (`plan check`, `plan compile`,
`plan show`, `replay`), so this PR no longer changes any `run` case:
every `run` case keeps its surfaces `["cli"]` and gains nothing. wasm
23/23.

Also fixed here (raised on #131, rounds 1 to 4): in the plan namespaces,
`AddressOverride.to` and `RemediationDecl.for` showed the `Party` type's
description instead of their own rule. The schemas were right; the
generator took whichever description a referenced type was first
resolved with. `gen-types.mjs` now wraps a reference that has its own
description in `allOf`, so every field keeps its own text (`to`: never
`caller`) and shared types become named (`Party`, `Grade`, `Predicate`)
instead of inlined; shapes are unchanged and `tsc --strict` passes.

Review round 9 (2 findings, fixed): (1) the store resolver is
`resolveItem`, no longer shadowing `path.resolve`. (2) a failed
instantiation sample is recorded as a 3.10.5 failure and the measurement
document is still written.

Review round 10 (5 findings): (1) fixed: the wasm-opt pin matches the
whole version token (`wasm-opt version 116` then a space or the end), so
`1160` fails it. (2) Repeated: refusing an output that names an input
matches the file host, where the input is an existing file and
`ensure_absent` refuses it the same way; the code says so. (3) Known and
recorded: the raw size is over its 3.10.4 budget, which draft spec 046
addresses; until the owner decides, the gate reports it rather than the
budget being weakened. (4) fixed: an output without `normalize` is read
as having none. (5) The allowlist is every module name with every base
name on purpose: the same reviewed glue is imported from `wbg` or
`./rustev_wasm_bg.js` depending on the target; the check says so.

Review round 11 (4 findings): (1) fixed: make expands a recipe's lines
before running the first, so the target directory is read before the
Node check whatever the order; the refusal now names what it needs
(cargo metadata and Node 20 or later on PATH). (2) Not a defect:
`max_bytes` goes to the host only as a hint; the guard compares the
returned length with it as integers, and on wasm32 a `usize` is 32 bits,
exact as an f64; the code says so. (3) A harvest that would write
outside its fixtures is a broken test, not a case to skip: the test
fails loudly, and the harvest rewrites its output on the next run. (4)
Verified: the lockfile's integrity for lodash 4.18.1 equals the
registry's (`npm view [email protected] dist.integrity` gives the same
`sha512-dMIn...0Q==`).

Review round 12 (1 finding, fixed): each case, comparison included, runs
in its own `runCase` under the per-case catch, so a throw while reading
a golden fails that case only.

Review round 13 (1 finding, fixed): a replay case without `--now-ms`
fails naming the flag (`flags().need`) instead of passing `NaN` on
(which the Rust side would also refuse).

Review round 14 (3 findings, all raised before): (1) lodash 4.18.1 is
published, and its lockfile integrity equals the registry's (verified in
round 13 and earlier). (2) A case that names the `wasm` surface for a
command it lacks is a failure by design, counted as run: the suite must
not silently skip a case it claims. (3) To settle it, the allowlist is
now the exact reviewed `module:name` pairs (22, both targets' module
names), checked as pairs.

Review round 15 (3 findings): (1) fixed: a case file from an earlier
harvest must record the same derived descriptors this harvest wrote, or
the harvest fails and says to rebuild; run cases now carry the harvest's
own `"derived": []`, so every committed case file is reproduced byte for
byte by `make conformance-harvest` (the wall-clock replay bundles
aside). (2) fixed: the flags a command cannot run without (`definition`,
`out`, `plan`, `bundle`, `now-ms`) fail the case by name when absent.
(3) No WebAssembly case pins a written output today (every one pins
stdout), so nothing passed vacuously; a case that did is now compared
against the artifact the command published under that name, never
skipped.

Review round 16 (1 finding, raised in earlier rounds too): lodash 4.18.1
was published on the public registry on 2026-04-01 (after the reviewer's
knowledge cutoff), and the lockfile's integrity equals the registry's
`sha512-dMIn...0Q==` (`npm view [email protected] time dist.integrity`); it
is json-schema-to-typescript 16.0.0's dependency and `npm ci` installs
it. The package now records this in its `//` note, so the diff carries
the evidence.

Review round 17 (1 finding): verified, and now verified on every build:
`npm view [email protected] dist.integrity` equals the lockfile's
`sha512-dMIn...0Q==`, and `make bindings` now runs `npm audit
signatures` after `npm ci`, which checks every installed package's
registry signature (locally: 16 packages with verified registry
signatures, lodash 4.18.1 among them).

Review round 18 (2 findings): (1) fixed: every path the `bindings`
recipe builds from `BINDINGS_OUT` or `CARGO_TARGET` is quoted, so a
target directory with a space is passed whole. (2) The spec says nothing
about lodash (no "4.18.1" appears in it), and lodash 4.18.1 is published
(2026-04-01) and now verified by registry signature on every `make
bindings` (`npm audit signatures`: 16 packages verified); `npm ci`
installs it.

Review round 19 (3 findings): (1) js-yaml 4.3.2 is published (`npm view
[email protected] version dist.integrity`), as is every package in the
lockfile; the package's note now covers the whole tree rather than one
package at a time: `npm ci` checks each package against its locked
integrity, and `make bindings` verifies every installed package's
registry signature (16 verified). (2) fixed: each scope mode's fields
are required, so a replay case without them fails by name. (3) The hash
width is fixed by the exact wasm-bindgen pin (0.2.129, 3.10.2); a new
pin that changes it fails the allowlist loudly, which is wanted; the
code says so.

Review round 20 (4 findings): (1) fixed: a test pins that an output
naming an input is refused. (2) fixed: a case file from an earlier
harvest must also record the same surfaces. (3) fixed: each built target
directory carries its module type (`web` and `bundler` ES modules,
`node` CommonJS, written by `make bindings`), and the exports name the
matching conditions (`import`, `require`); Node no longer warns that the
module type is unspecified. (4) Already done as asked: `make bindings`
runs `npm audit signatures` after `npm ci` (16 packages with verified
registry signatures, lodash 4.18.1 among them), which checks provenance,
not only content.

Review round 21 (1 finding, resolved): the owner ratified spec 046
(A-43, #136), raising the raw budget to 2,621,440 bytes and keeping the
gzip and instantiation budgets and the gate; `wasm-opt` could not close
the gap (`-Oz` is the smallest at 2,216,152 bytes). The measurement
check now applies the 046 budget, and `make bindings` passes end to end
(wasm conformance 23/23). The spec 027 record says so.
bartekus added a commit that referenced this pull request Oct 21, 2026
Spec 027, increment 6 (first change): the native Node-API package.
Stacked on #130.

- `integrations/rustev-node` (napi 3.14.2, Node-API 8; `publish =
false`, excluded from the crates.io release set): an `Engine` owning one
sized Tokio runtime, rules-program and host backends, a host sink and
optional context source; `compile` (or load a compiled plan) and the
pure commands on the blocking pool, with sync variants; `decide` on the
engine's runtime with `AbortSignal`, deadline, principal handle and
`traceparent`; manual clock; gauges; shutdown.
- Host seams (3.6) via weak threadsafe functions: bounded per-seam
queues refused at once, remaining time, attempt identity, abort,
reserved bound and trace context on every call, late settlements
discarded and counted, non-`SeamFailure` rejections mapped to permanent
/ unknown charge / possibly continuing. Context source once before
admission; `ContextUnavailable` on failure, nothing defaulted.
- JavaScript layer (`index.js`, `index.d.ts`, generated document
declarations byte-identical to the wasm package's): the 3.3 API, typed
`RustevError` subclasses and codes (3.4), `onGauges` drop-oldest
subscription, drain-then-cancel `shutdown`, platform-package loader
naming a missing package.
- `unsafe`: napi-rs's generated glue needs it, so this crate sets
`unsafe_code = "deny"` (reason in the manifest); `tests/no_unsafe.rs`
fails on hand-written `unsafe`.
- `test/negative.test.mjs`: each section 5 row of the native package (20
tests, deterministic on a manual clock). A decision through the binding
produces the CLI's golden run-record bytes.
- `ManualClock::pending_delays` (additive, spec 003's crate) for
deterministic clock driving; the conformance adapter that uses it
follows in the second change.
- Two owner findings, recorded in the spec: a host backend's
cancellation answer is always `not_observed` (the runtime polls a
cancelled attempt once; a host seam answers across threads), and section
5's "output failing the bounded parse" row disagrees with 3.6.5; the
binding follows 3.6.5.

Review round 1 (5 findings): (1) Under `node -e`, `process.argv[1]` is
the first argument after the code (there is no script path), so the copy
reads the target directory; it ran that way in local verification, and
the Makefile now says so. (2) fixed: a decision is counted in flight by
a guard dropped when its task ends, panic included, so shutdown never
waits on a panicked task. (3) fixed: `compile` takes exactly one of a
definition and a plan, otherwise `InvalidDocument`; declared and tested.
(4, 5) The generated types state what each bounded parser accepts
(3.2.2: the schema describes the parser), while a field's description
can state a compiler rule beyond it (`AddressOverride.to` is never
`caller`, `RemediationDecl.for` never `none`: the compiler refuses
both). The generated header now says so; both packages' copies
regenerated and identical. Restacked on #130.

Review round 2 (5 findings): (1) fixed: the no-unsafe check reads source
files only and fails on anything else in `src/` rather than panicking.
(2) fixed: compiles and commands on the blocking pool are counted, and
shutdown waits for them as for decisions. (3) fixed: after raising
cancellation, shutdown waits at most 30 seconds and reports what still
runs (`stillRunning`). (4) fixed: a local build that does not load is a
typed `InternalError` (`local_build_unloadable`) naming it; tested. (5)
Repeated: the generated types state what each bounded parser accepts and
the generated header says a field's description can state a compile rule
beyond that; `compile` refuses `caller` for `AddressOverride.to` in
every plan.

Review round 3 (6 findings): (1) Repeated, and wrong: under `node -e`
the first argument after the code is `process.argv[1]` (`node -e
'console.log(process.argv.slice(1))' x` prints `["x"]`). To leave no
doubt, the copy is now a script,
`tools/rustev-conformance/js/copy-addon.mjs <target> <package>`, run by
`make bindings` and locally. (2) fixed: shutdown's local count is
`active`, no longer shadowing the module's `inFlight`. (3) fixed: a seam
failure with an empty reason records the status instead (`the host seam
failed without a reason (...)`). (4) Repeated: the generated
declarations' header states that the types describe what each parser
accepts and that a description can state a compile rule beyond it (the
compiler refuses `caller` for `AddressOverride.to`); each emitted schema
now says the same in a root `$comment` (#126), which the type generator
does not copy. (5, 6) These are the two owner findings already recorded
in this spec's implementation record (the host backend's cancellation
recorded `not_observed`, and section 5 against 3.6.5 for an unparseable
answer); they need the owner's reading or an amendment, not a code
change here. Restacked on #130.

Review round 4 (5 findings): (1) fixed, and it exposed a real defect:
`compileSync` takes exactly one of a definition and a plan, refusing
otherwise with `InvalidDocument`; the layer's error wrapper also
re-typed errors it had thrown itself as `InternalError`, and now passes
a `RustevError` through unchanged. Tested. (2) fixed: the no-unsafe
check strips a `//` comment only outside string literals; tested. (3)
The diagnostic report is the C-library test napi-rs uses; it runs once,
on Linux only, and now without the network section where Node allows
leaving it out. (4) fixed: `copy-addon.mjs` refuses a platform it has no
package for. (5) fixed at the source (#130): the generator gave plan
fields the referenced type's description; now every field keeps its own
(`AddressOverride.to`: never `caller`), and this package's declarations
are regenerated, byte-identical to the WebAssembly package's.

Review round 5 (2 findings, fixed): (1) an installed platform package
that does not load is `InternalError` (`platform_package_unloadable`,
naming it), and only an absent one is `PlatformPackageMissing`. (2) the
no-unsafe check blanks `/* */` block comments across lines as well as
`//` comments, string literals staying code; tested.

Review round 6 (3 findings, fixed): (1) a command is counted before the
shutdown check (both sequentially consistent), so either shutdown waits
for it or it refuses; it never runs unseen. (2) the no-unsafe check
reads raw strings (`r#"…"#`, `br"…"`), escaped strings and char literals
(`'"'`) as code, with lifetimes left alone; tested. (3) a package is
missing only when Node cannot find the package itself (`Cannot find
module '<package>'`); a missing dependency of an installed package makes
it unloadable.

Review round 7 (3 findings, fixed): (1) a decision is counted in flight
before the shutdown check, as a command is, so shutdown either waits for
it or it refuses. (2) shutdown's count saturates at `u32::MAX` instead
of truncating. (3) the no-unsafe check reads an escaped char literal
(`'\''`) whole; tested.

Review round 8 (4 findings, fixed): (1) the no-unsafe check blanks
string contents (plain, byte and raw) as it blanks comments, so text
inside a string is not code; a real `unsafe` block is still found;
tested. (2) the missing-package test first asserts that no platform
package resolves from its directory (Node also searches ancestors), so
it fails rather than passes if one does. (3) `advanceClock` takes any
integral, non-negative number up to 2^53 - 1 and refuses the rest
instead of truncating to 32 bits; tested. (4) the build-time copy script
leaves out the report's network section too.

Review round 9 (2 findings, fixed): (1) `clockDelays` reports each
pending delay as a JavaScript number, exact to 2^53 - 1 ms, the range
`advanceClock` accepts, instead of capping at 32 bits. (2) the no-unsafe
check matches the keyword `unsafe`, not a longer identifier such as
`unsafe_code`; tested.

Split (the AI review was cancelled at its 15-minute limit twice): this
PR is now increment 6's first change, the native crate (Rust: engine,
seams, commands, errors, the no-unsafe check, the manual clock's pending
delays); the JavaScript layer (`index.js`, declarations, generated
types, package, tests, copy script) moves to a PR stacked on this one,
and #132 is restacked on that.

Review round 10 (2 findings, fixed): (1) every usage refusal states the
requirement (`must be a string`, `must be a list`, `must list strings`).
(2) a compile on the blocking pool is counted and then checked against
shutdown before it reaches the pool, as a command is, so both paths
behave alike: shutdown waits for it, or it refuses.

Review round 11 (2 findings, fixed): (1) `"failure": null` in a host's
answer is no failure; only an object is one. (2) the context source's
fetch runs on its own task, as a backend's attempt does, so a settlement
that arrives after its decision was dropped is discarded and counted
(3.6.4). The 23 native tests (#135) and the 34 native conformance cases
(#132) pass against this build.

Review round 12 (2 findings, fixed): (1) a host answer's `cancel`, when
present, must be `stopped` or `unconfirmed`; any other value is refused
like an unknown charge or remote end, and only an absent one means not
requested. (2) `compile` and `load` on the blocking pool run under
`guard`, so a panic crosses as `InternalError` with its message, as a
command's does. Rebased on main after #134 merged.

Review round 13 (1 finding, fixed): advancing an engine on the system
clock is refused with its own code, `not_a_manual_clock`, instead of
`out_of_range`, which stays for numbers outside the accepted range; #135
tests both.

Review round 14 (1 finding, fixed): the synchronous `command`, `compile`
and `load` are counted and then checked against shutdown, as their
blocking-pool forms are, so a synchronous call (from a worker thread
too) is one shutdown waits for. The native tests (#135, 27) and native
conformance (#132, 34) pass against this build.

Review round 15 (1 finding, fixed): a compile given neither a definition
nor a plan says so (`neither was given`), and one given both says `not
both`.

Review round 16 (2 findings, fixed): (1) `compile` and `load` count
themselves and then call uncounted forms (`compile_uncounted`,
`load_uncounted`), which `prepare_async`, already counted, calls
directly, so nothing is counted twice. (2) `clockSleepers` saturates at
`u32::MAX` instead of truncating. The native tests (#135, 27) and native
conformance (#132, 34) pass against this build.

Review round 17 (2 findings): (1) Nothing is dropped: the workspace's
only lint is `unsafe_code` (`[workspace.lints.rust]`), which this crate
overrides to `deny`; Cargo cannot inherit the workspace table and
override one lint, so the manifest now says the table restates the
workspace's and must mirror any lint it gains. (2) fixed: a host answer
missing its charge or its remote end is refused naming the one that is
missing.
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