Skip to content

impl(042): increment 1, serve and plan-bundle contract documents - #180

Merged
bartekus merged 1 commit into
mainfrom
impl/042-serve-documents
Oct 23, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/042-serve-documents

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Spec 042 increment 1 (serve half), stacked on #176: rustev.serve/1 with its operation table and every rustev.serve-*/1 document, plus rustev.plan-bundle/1, rustev.plan-bundle-signature/1 and rustev.plan-registration/1, with emitted schemas and regenerated binding declarations (the .d.ts growth is generated: serve envelopes inline the run record and judgment types). Embedded evidence is carried as original bytes (serde_json raw_value feature; no new dependency). Items that depend on 034 or 036 are held back with extension points. Bounds the spec leaves unstated are recorded as engineering choices in the implementation record. Checks: cargo test -p rustev-contract, clippy, fmt, make gate, couple, gen-types --check.

@github-actions

Copy link
Copy Markdown

AI review skipped: oversized

The change adds 23857 lines, over the backstop of 20000.

This pull request was not reviewed by the AI reviewer. A green ci-gate does not say otherwise.

@bartekus
bartekus force-pushed the impl/042-serve-documents branch from c392c86 to 2a6e95f Compare October 22, 2026 23:41
@bartekus
bartekus force-pushed the impl/042-remote-documents branch from 34f29ea to 16444d5 Compare October 22, 2026 23:47
@github-actions

Copy link
Copy Markdown

AI review (findings)

Looking at the PR, I'll examine the core Rust modules, schemas, TypeScript bindings, and spec changes.

Rust implementation review

serve.rs and plan_bundle.rs are well-structured. deny_unknown_fields is applied everywhere via the service_document! macro. The Validate trait enforces cross-field invariants correctly (snapshot/context mutual exclusion, status/judgment/evidence_disposition consistency, shutdown id-list totals). The canonical_envelope function preserves embedded evidence bytes verbatim for judgment, run_record, and compile_refusal inside rustev.serve-decision/1 and rustev.serve-refusal/1 while sorting other keys — the recursive render correctly identifies nested decisions by their schema string. The Reference path validation correctly rejects parent traversal, absolute paths, and URLs.

TypeScript bindings — concrete defect

The RustevServeDecide1 type in both binding files is generated as an open intersection type:

export type RustevServeDecide1 = {
  context?: Context | null;
  decision_id: Handle;
  evaluation_time: Timestamp;
  schema: "rustev.serve-decide/1";
  snapshot?: EmbeddedRustevSnapshot_1 | null;
} & {
  [k: string]: unknown | undefined;   // ← open index signature
};

The schema file rustev.serve-decide-1.schema.json correctly emits "additionalProperties":false. The parser enforces deny_unknown_fields. But the oneOf constraint generated by document_shape (for the snapshot/context mutual exclusion) causes the TypeScript schema-to-type converter to drop additionalProperties: false and emit an open index signature instead. TypeScript callers can add arbitrary extra fields (e.g. { ...decide, endpoint: "x" }) without a compile error, but the server will reject those requests with invalid_document. Every other generated document type in the same files is a closed interface; only ServeDecide has this gap. The same issue appears identically in both the node and wasm bindings.

Other observations (not bugs)

  • SigstoreBundle correctly uses allow_fractional_numbers: false for its inner parser limits; the outer document limits use true. Consistent with the schema comment "integer tokens 40 bytes."
  • configuration_digest strips address fields from backends/sinks/context-sources and listener transport paths. TLS cert file paths are not stripped; this appears intentional — cert choice is configuration identity.
  • The spec section records size choices as "made by the implementing agent, not by the owner," but the spec also states the owner ratified in advance all #76 child implementations.
{"head": "2a6e95fe1df0fe94f16d2cb8ff9e0841c7e7f9f3", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/types/rustev-documents.d.ts", "line": null, "summary": "RustevServeDecide1 is emitted as an open intersection type with an index signature, allowing arbitrary extra properties in TypeScript despite the schema having additionalProperties:false and the parser enforcing deny_unknown_fields; callers can silently construct invalid requests."},{"path": "integrations/rustev-wasm/types/rustev-documents.d.ts", "line": null, "summary": "Same open index-signature defect on RustevServeDecide1 as in the node bindings — contradicts additionalProperties:false in the schema and deny_unknown_fields in the parser."}]}

Subject: 34f29ea...2a6e95f, diff digest b4108274ab1f92c86aad52cbff4979adf80a169b9f2214945468963c3c373a80, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 22, 2026 23:48 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 2a6e95f to 76331d3 Compare October 22, 2026 23:51
@bartekus
bartekus force-pushed the impl/042-remote-documents branch 2 times, most recently from 084fb73 to c698af2 Compare October 23, 2026 00:09
Base automatically changed from impl/042-remote-documents to main October 23, 2026 00:32
@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 76331d3 to 18501af Compare October 23, 2026 01:09
@bartekus
bartekus enabled auto-merge (squash) October 23, 2026 01:09
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the PR, which adds contract documents for spec 042 (decision service and remote seams): serve.rs, plan_bundle.rs, nineteen new JSON schemas, TypeScript type declarations, and tests.

Schema and Rust logic

The bounded parsers, Text<MIN, MAX> byte-length enforcement, Number<MIN, MAX> range checks, Embedded<T> raw-value preservation, and canonical_envelope key-sorting are internally consistent and exercised by the test suite. The document_shape hook correctly adds not:{"type":"null"} to the JSON schemas for optional non-nullable fields (snapshot, context, judgment, run_record, attempts, compile_refusal) so that the published schemas are tighter than schemars' default anyOf:[T, null].

TypeScript declarations

The not: null constraint generated in the JSON schemas is not reflected in the produced TypeScript type declarations. The TypeScript generator appears to convert anyOf:[T, null] → T | null without subtracting the not: null restriction, so the TypeScript types for those same fields still carry | null even though the Rust parser rejects null for each of them via deserialize_with="present". Consumers of the Node and WASM bindings see a false contract: they can write code that passes null explicitly, receive a type error nowhere, and then get an unexpected runtime rejection. This affects every new namespace that uses the pattern (RustevServeCancel1.attempts, RustevServeDecide1.snapshot/context, RustevServeDecision1.judgment/run_record, RustevServeRefusal1.compile_refusal, and the corresponding WASM file).

No other concrete defects found. The PlanBundle::digest() / canonical() split, the strip_addresses choices, the evidence_not_delivered + judgment permissiveness, and the u64::MAX numeric limits are all either internally consistent or design decisions with insufficient spec-visible authority to contradict.

{"head": "18501af75705963dadce1924d07a05224c0b0538", "verdict": "findings", "findings": [{"path": "integrations/rustev-node/types/rustev-documents.d.ts", "line": null, "summary": "Optional non-nullable fields (attempts, snapshot, context, judgment, run_record, compile_refusal) are typed as T | null in the TypeScript declarations even though the Rust parser rejects null for them; the JSON Schema's not:{type:null} constraint is not being honored by the declaration generator, producing a false type contract for Node and WASM consumers."}, {"path": "integrations/rustev-wasm/types/rustev-documents.d.ts", "line": null, "summary": "Same false T | null type contract for the same optional non-nullable fields in the WASM bindings type declarations."}]}

Subject: 3119423...18501af, diff digest 84461ed218946f6ff0a45240123359170564397620070e556068530a6bae537a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 23, 2026 01:20 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 18501af to 235ce4d Compare October 23, 2026 01:28
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for bugs, security issues, and inconsistencies across the new plan_bundle.rs, serve.rs, JSON schemas, TypeScript declarations, tests, and spec update.

Schema–parser byte-vs-codepoint gap (documented, not a defect): The JSON schema minLength/maxLength for Text<MIN, MAX> count Unicode code points while the Rust parser counts UTF-8 bytes. The $comment field in every schema explicitly records this, and the design allows the schema to be looser than the parser. The é-repetition test confirms byte semantics. Intentional.

canonical_envelope evidence-passthrough list: Only judgment, run_record, and compile_refusal are passed verbatim when the schema is rustev.serve-decision/1 or rustev.serve-refusal/1. Remaining embedded documents (definition, calibrations, execution policy in a bundle) are recursively normalised. Correct for the stated design.

ServeDecision cross-field validation — EvidenceNotDelivered + judgment: The validator forbids judgment for Cancelled and requires it for Judged, but leaves EvidenceNotDelivered unconstrained. The JSON schema's allOf is identical. Whether a judgment can accompany an undelivered-evidence status is a spec question, but parser and schema are consistent with each other.

Reference path allows control characters: The validation rejects \0, \, :, .., ., and empty components, but allows whitespace and other control characters (e.g. \n) in path components. The type comment defers containment to the host resolver, so this is a design assumption rather than a defect.

Concrete defect — PlanBundle::digest() uses a different canonical function than Document::canonical():

plan_bundle.rs lines 83–88 call crate::canonical::canonical_bytes(self), while the service_document! macro wires Document::canonical() and Document::record_canonical() to the new canonical_envelope(self) (defined in serve.rs). These are distinct code paths. canonical_envelope is a new function written for service documents that sorts keys via BTreeMap and preserves specific embedded-document bytes verbatim; canonical_bytes is the pre-existing function and may produce different output for the same logical document (e.g. different treatment of serialised Embedded<T> raw values, or number normalisation). No test verifies that bundle.digest() equals the hash of bundle.canonical(). A verifier that checks registration.bundle_digest == sha256(canonical(bundle)) would silently obtain a wrong answer whenever the two functions diverge, breaking signature verification for any implementation that reconstructs the digest from the canonical form.

{"head": "235ce4d1abec20a2085635eab958fb6a4b745da1", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/plan_bundle.rs", "line": 84, "summary": "PlanBundle::digest() uses crate::canonical::canonical_bytes while Document::canonical() (injected by service_document!) uses canonical_envelope; the two functions may produce different byte sequences for the same bundle, making bundle_digest irreproducible from canonical() and breaking verifiers that compute hash(canonical(bundle))."}]}

Subject: 3119423...235ce4d, diff digest d697dede4ee59d2d0b49942c381eb693e939c83d4d10889a14cb15220d495f03, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 23, 2026 01:35 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 235ce4d to 4586b18 Compare October 23, 2026 01:40
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR, which adds the "serve half" contract documents for spec 042: the serve.rs and plan_bundle.rs modules plus matching JSON schemas, TypeScript type declarations, tests, and an updated spec note.

serve.rs — core types and canonical envelope

  • Text<MIN,MAX>::new calls value.len(), which returns UTF-8 bytes in Rust. The schema's $comment acknowledges the schema uses character counts while the parser uses bytes; this is intentional and consistent with spec 027 §3.2.2.
  • canonical_envelope sets evidence = true per object when its schema raw-value matches "rustev.serve-decision/1" or "rustev.serve-refusal/1", then preserves judgment, run_record, and compile_refusal verbatim. Recursion is per-object, so embedded decisions within events are correctly identified at that inner level. Round-trip idempotency is verified by the contract<T> test helper.
  • ServeDecision::validate doesn't explicitly forbid judgment when status == evidence_not_delivered; the JSON Schema allOf rules in document_shape also omit that constraint. Whether this is intentional is not contradicted by anything in the supplied evidence.
  • Reference deserialization rejects .., ., empty path components, backslashes, embedded colons, and URL schemes. Test coverage in references_cannot_be_urls_or_escape is exhaustive.
  • Number<MIN,MAX> deserializes via u64::deserialize, which rejects negatives and floats; test confirms this.
  • SocketMode restricts values to 0o600/0o660 (384/432); tested.

plan_bundle.rs

  • PlanBundle::digest() calls Document::canonical(self), which routes through canonical_envelope. The bundle_digest_is_over_canonical_bytes test confirms digest() equals tagged_digest(SCHEMA, canonical()). ✓
  • PlanRegistration::registration_id() converts to Value, removes registered_at_ms, then calls canonical_value_bytes. unwrap() on the object is safe because a struct always serialises to an object. Stability across registered_at_ms changes is tested.
  • SigstoreBundle is stored as serde_json::Value, losing original bytes; the original Sigstore bundle bytes are accessible via Embedded<PlanBundleSignature>::bytes() for verification. The design separates document content-addressing (canonical) from signature verification (raw bytes). Limits are 1 MiB, depth 32, strings 256 KiB, fractional numbers rejected; all edge cases tested.
  • PlanBundleSignature::signing_input() produces "rustev.plan-bundle-signature/1\n{bundle_digest}", providing domain separation for ed25519.

ServeConfig::configuration_digest

Strips TCP addresses, Unix socket paths, and address fields in bindings/context sources/sinks; replaces resolver root values with "configured". credentials_file paths, TLS certificate/key paths, and token_file for development bearer are not stripped. The doc-comment says "socket paths, endpoint addresses and resolver directory locations" are excluded; not listing credential file paths appears intentional (they affect security policy identity). Tested for Unix path exclusion and semantic field changes.

Governance

Changed paths include no .github/workflows/, scripts/statecraft/, or scripts/check-authored-content.sh files, so no statecraft-review-exception approval is required per AGENTS.md. The spec 042 document is updated with an "Increment 1" section documenting what was implemented, consistent with the spec-first pattern. The Cargo.toml spec metadata (spec = "002-…") was not updated to reference 042, but this crate has a pattern of multiple specs contributing to it and the coupling gate would catch any unowned paths.

No concrete defects found.

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

Subject: 5a3fe1f...4586b18, diff digest 5811bbc9094cd28faa79ba7fa8e2b602de004db1053b4cd8d88f3061354208d4, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 4586b18 to 90296c2 Compare October 23, 2026 02:43
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

I reviewed the entire diff carefully: the new plan_bundle.rs and serve.rs contract modules, all JSON schemas, TypeScript type declarations, the spec increment, and the test file.

Structural and correctness checks:

  • Text<MIN, MAX>::new uses value.len() which in Rust returns UTF-8 byte count (not character count); the schema's $comment and field description document that the parser enforces bytes, and the test with multi-byte 'é' confirms the byte semantics are correct.
  • canonical_envelope correctly sets evidence = true per-object by reading the schema field's raw JSON bytes (comparing with quotes included), then preserves judgment/run_record/compile_refusal verbatim only within serve-decision/refusal objects. Nested serve-decisions inside serve-events are handled correctly because the flag is re-evaluated per object.
  • Cross-field validations in ServeDecision::validate, ServeShutdown::validate, and ServeConfig::validate are sound and consistent with the schema allOf/if/then/else conditions.
  • Number<MIN, MAX>, Text<MIN, MAX>, List<T, MIN, MAX>, Maybe<T>, and Embedded<T> types are implemented consistently with their JSON schemas and TypeScript declarations.
  • Reference validation correctly blocks URLs, absolute paths, .. traversal, double slashes, and null bytes; all test cases in references_cannot_be_urls_or_escape are verified by the rules.
  • PlanBundle::digest() uses tagged_digest over Document::canonical() output, confirmed by the bundle_digest_is_over_canonical_bytes test.
  • registration_id() removes registered_at_ms before hashing; configuration_digest() strips addresses and socket paths; both are consistent with the spec notes.
  • Archive policy entries for plan_bundle.rs and serve.rs are inserted in correct alphabetical order.
  • The spec update is additive (implementation notes only, no frontmatter changes), consistent with the corpus's approved status.

Security checks:

  • No path traversal via Reference — host resolver responsibility is explicitly documented.
  • SigstoreBundle bounded parser uses allow_fractional_numbers: false and 1 MiB cap.
  • TCP transport requires at least one client CA file (List<…, 1, 64>), enforcing mTLS.
  • SocketMode only accepts 0o600 (384) and 0o660 (432).
  • DevelopmentBearer is clearly named and treated as a development-only path.

No concrete defects found.

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

Subject: 5a3fe1f...90296c2, diff digest afce9a1ed45f9a52d989523112c2bcefd6a88a301c236bf4f9abb5fb8099006d, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 90296c2 to 7396b95 Compare October 23, 2026 03:08
@github-actions

Copy link
Copy Markdown

AI review (findings)

Review

The PR introduces the "serve half" of spec 042: contract documents for the decision-service protocol (rustev.serve-*/1, rustev.plan-bundle*/1, rustev.plan-registration/1), their JSON schemas, TypeScript declarations, and tests.

Finding 1 — Missing cross-field constraint: judgment not prohibited for EvidenceNotDelivered

ServeDecision::validate() enforces that judgment is absent when status == Cancelled, but it imposes no constraint on judgment when status == EvidenceNotDelivered. The same gap appears in document_shape's generated allOf block.

crates/rustev-contract/src/serve.rs, validate() around line 615:

if (self.status == DecisionStatus::Judged && self.judgment.is_none())
    || (self.status == DecisionStatus::Cancelled && self.judgment.is_some())
{
    return Err("judgment does not match status".into());
}

EvidenceNotDelivered is a separate terminal state (distinct from Judged) that also requires run_record; the absence of a matching constraint means a document with status = "evidence_not_delivered" and a judgment field passes validation, which is inconsistent with the Cancelled treatment. The generated JSON schema (allOf) has the identical omission — it never adds "not":{"required":["judgment"]} for the evidence_not_delivered branch.

Finding 2 — u64::MAX schema maximum cannot be represented in IEEE 754

Number<1, {u64::MAX}> and Number<2049, {u64::MAX}> emit JSON schema fragments with "maximum": 18446744073709551615. That integer (≈ 1.84 × 10¹⁹) exceeds the exact integer range of IEEE 754 double-precision (2⁵³ ≈ 9 × 10¹⁵), so any JSON Schema validator that parses numbers as f64 will see a different — and larger — maximum (typically 18446744073709551616). The affected schemas are rustev.serve-decision-1 (the Dropped.count field) and rustev.serve-refusal-1 (the CompileRefusal.Digest.length field). The test harness uses the Rust jsonschema crate, which likely stores numbers as exact 64-bit integers and so does not expose the bug there; external consumers of the emitted schema files will.


{"head": "7396b9529e4fa5d6898aa6a1d7f082210676b2af", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/serve.rs", "line": 615, "summary": "ServeDecision::validate() does not prohibit judgment when status is EvidenceNotDelivered, creating an inconsistency with the explicit prohibition applied to Cancelled status."}, {"path": "crates/rustev-contract/schema/rustev.serve-decision-1.schema.json", "line": null, "summary": "The schema emits maximum:18446744073709551615 (u64::MAX) which cannot be represented exactly in IEEE 754 double-precision, causing incorrect maximum validation in JavaScript/standard JSON Schema consumers."}]}

Subject: 66eabb7...7396b95, diff digest f22c3a8266ba15b144bc494d9ec043840ff1e198906bf59ebfe9d907f875b9b5, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 23, 2026 03:13 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 7396b95 to 1b59278 Compare October 23, 2026 03:16
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the PR, which adds contract documents for the decision service (spec 042): new plan_bundle.rs and serve.rs modules, JSON schemas, TypeScript type declarations, a test suite, and a spec increment note.

Code and schema review

Text<MIN, MAX>::new uses String::len() (byte count), and the schema descriptions say "Length is enforced in decoded UTF-8 bytes by the parser" — schemas use maxLength in code points, which is looser; the test confirms this is intentional and matches spec 027 § 3.2.2. No defect.

canonical_envelope sorts object keys using BTreeMap, detects rustev.serve-decision/1 / rustev.serve-refusal/1 by reading the raw schema field before iteration, and preserves judgment, run_record, compile_refusal verbatim. Detection is correct (raw value includes quotes, e.g., "\"rustev.serve-decision/1\""). No defect.

ServeConfig::configuration_digest recursively strips all address keys from backend bindings, context sources, and sinks; socket path is stripped explicitly for unix listeners; resolver roots are redacted to "configured". This matches the spec note ("Socket paths, endpoint addresses and resolver directory locations are deployment locations"). No defect.

Validate for ServeDecision correctly enforces the cross-field rules (run_record ↔ evidence_not_delivered, judgment ↔ judged/cancelled). ServeInvalidations::validate correctly allows empty batches. PlanRegistration::registration_id correctly excludes registered_at_ms. SocketMode allows only 0o600 (384) and 0o660 (432). All tested.

Concrete defect — SigstoreBundle discards original bytes

CompilerRefusal explicitly uses Box<serde_json::value::RawValue> and is commented "kept byte-for-byte." SigstoreBundle reads a RawValue to enforce the 1 MiB / depth-32 limits, then converts to serde_json::Value and discards raw:

// crates/rustev-contract/src/plan_bundle.rs  (SigstoreBundle Deserialize)
let raw = Box::<serde_json::value::RawValue>::deserialize(d)?;
// ...
let value: serde_json::Value =
    parse_bounded(raw.get().as_bytes(), &limits).map_err(serde::de::Error::custom)?;
// raw is dropped; only `value` is stored
Ok(Self(value))

When re-serialized (e.g., for canonical_envelope or wire transmission), serde_json::Value re-encodes the bundle, losing original whitespace and number formatting. Sigstore verification libraries typically consume the bundle bytes verbatim. If the bytes change, verification can fail depending on the library's tolerance. The Embedded<T> pattern used for all other opaque sub-documents explicitly avoids this by carrying raw: Box<RawValue>. SigstoreBundle should follow the same pattern.

No issues found with the spec update (which honestly labels bound choices as agent-selected, not owner-ratified), the archive-policy additions, or the TypeScript declarations (they correctly reflect the generated schemas).

{"head": "1b592789867157e79e62732af264684ffe93431c", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/plan_bundle.rs", "line": 113, "summary": "SigstoreBundle converts the deserialized RawValue to serde_json::Value and discards the original bytes, so re-serialization can change whitespace and number formatting; unlike CompilerRefusal (which stores RawValue), this breaks byte-perfect round-tripping required by Sigstore verification libraries."}]}

Subject: 66eabb7...1b59278, diff digest 3caa1b3aae8cd66bbf1cbcb4ba3c61fd6cd4109ccc92a7e94241203786017973, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 23, 2026 03:21 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/042-serve-documents branch 2 times, most recently from c9b4ce1 to 424c83b Compare October 23, 2026 04:43
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the PR, which adds contract documents for the decision-service protocol (spec 042 increment 1): plan_bundle.rs, serve.rs, new JSON schema files, updated TypeScript declarations, and spec 042 body text.

crates/rustev-contract/src/serve.rs — canonical_envelope, evidence-passthrough check

The function detects ServeDecision and ServeRefusal documents by comparing s.get() (the raw JSON bytes of the schema field, including surrounding quotes) against string literals that also carry the JSON quotes:

matches!(
    s.get(),
    "\"rustev.serve-decision/1\"" | "\"rustev.serve-refusal/1\""
)

This is correct: serde_json::value::RawValue::get() guarantees the surrounding quotes are present. No bug here.

crates/rustev-contract/src/serve.rs — ServeDecision::validate(), run_record requirement

The comment at line ~720 acknowledges that evidence_not_delivered can result from either a judged-then-delivery-failed path or a cancelled-then-delivery-failed path. In the cancelled case the system may not have produced a run record. However, the validation requires run_record unconditionally for every evidence_not_delivered decision:

if (self.status == DecisionStatus::EvidenceNotDelivered) != self.run_record.is_some() {
    return Err("run_record is required only for evidence_not_delivered".into());
}

If a decision reaches evidence_not_delivered after cancellation (no judgment, possibly no run record), this validation would prevent expressing that state. This is a semantic contradiction with the comment in the same block ("it was cancelled and delivery failed"). Whether a run record is always available at that point is a runtime guarantee not established by the contract layer alone. This is a concrete logical inconsistency between the comment's stated intent and the enforced invariant.

specs/042-decision-service-and-remote-seams/spec.md — engineering-choice disclosure

The added text reads "Engineering choices made by the implementing agent … not by the owner". The governance rules (AGENTS.md, constitution §III) require that normative bounds be owner-ratified. By embedding these as observed fact in the spec body rather than in an impl note section, they enter the corpus as if ratified, despite the disclaimer. This is a governance process concern, not a code defect, but is worth flagging.

Everything else checked and found correct:

  • Text<MIN,MAX> counts UTF-8 bytes (value.len()) — consistent with documented parser behavior, schema is intentionally looser (spec 027 3.2.2).
  • Number<MIN,MAX> range checks match schema bounds.
  • Reference validator correctly rejects empty components, parent-directory segments, absolute paths, and extra colons; the test cases are exhaustive.
  • SigstoreBundle preserves raw bytes for transport; canonical_envelope re-sorts its keys for hash purposes only (not used for Sigstore verification, which uses SigstoreBundle::bytes() directly).
  • SocketMode allows only 0o600 (384) and 0o660 (432); test confirms.
  • signing_input domain separator (schema\nbundle_digest) is unambiguous and ContentDigest pattern enforces no newline can appear.
  • Serve::validate locks the operation table to the compiled-in operation_table(), making it tamper-evident.
  • ServeShutdown cross-validates failed/unflushed counts against their id-list totals.
  • ServeInvalidations::validate enforces monotone sequences and matching source_id.
  • document_shape transform correctly removes serde-generated null branches and adds if/then/else for compile_refusal and allOf for run_record.
  • PlanRegistration::registration_id correctly excludes registered_at_ms before hashing; PlanBundle::digest correctly uses canonical_envelope over the full document bytes.
{"head": "424c83bf2bd18040005ad57e9ac47dc4bfdd1115", "verdict": "findings", "findings": [{"path": "crates/rustev-contract/src/serve.rs", "line": 720, "summary": "The comment states that `evidence_not_delivered` can arise after cancellation (no run record), but the validation unconditionally requires `run_record` for every `evidence_not_delivered` decision, making the cancelled-plus-delivery-failure state unrepresentable."}]}

Subject: 979fab7...424c83b, diff digest 1c4b178dcaeae1858ee6e99330d278510a0d2325dcaf367fe01fd62b070628cd, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception October 23, 2026 04:52 — with GitHub Actions Error
@bartekus
bartekus force-pushed the impl/042-serve-documents branch from 424c83b to 7c09ad3 Compare October 23, 2026 04:53
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reading through the diff carefully, I examined the new serve.rs and plan_bundle.rs modules, all 19 new JSON schemas, the test suite, and the spec update.

Text<MIN, MAX> byte-length validation: String::len() in Rust returns UTF-8 bytes, matching the schema description "Length is enforced in decoded UTF-8 bytes by the parser." The test with "é".repeat(128) (256 bytes) vs "é".repeat(129) (258 bytes) against Text<0,256> confirms this is correct.

canonical_envelope verbatim-preservation logic: The function correctly detects "rustev.serve-decision/1" and "rustev.serve-refusal/1" by comparing the raw JSON string value (including quotes) and preserves judgment, run_record, and compile_refusal verbatim within those envelopes. Key-sorting via BTreeMap is applied consistently elsewhere.

ServeDecision cross-field validation: The three-way check (run_record ↔ evidence_not_delivered, judgment presence ↔ judged/cancelled, evidence disposition ↔ evidence_not_delivered) is logically correct, including the comment's explanation that a cancelled-then-undelivered decision has status=evidence_not_delivered but no judgment.

PlanRegistration.registration_id(): Correctly removes registered_at_ms before hashing, confirmed by the identities_exclude_observations_and_addresses test (changing registered_at_ms does not change the id; changing service_build does).

SigstoreBundle deserialization with allow_fractional_numbers: false: Deliberate design to ensure byte-exact round-trip; the test explicitly verifies {"number":1.5} is rejected.

Reference path validation: Correctly rejects URLs, absolute paths, parent-directory components (..), and empty segments; the test matrix covers all cases.

operation_table() has 14 entries matching List<OperationDescription,14,14>; Serve.validate() enforces exact match.

ServeConfig.configuration_digest(): Strips TCP address and Unix socket path from listeners, then recursively strips all address fields from backend bindings, context sources, and sinks; replaces resolver root paths with "configured". The test confirms path changes don't alter the digest while max_plans changes do.

DecisionIdList.validate(): Correctly enforces total >= ids.len() and truncated == (total > ids.len()), with ServeShutdown.validate() cross-checking failed == failed_ids.total and unflushed == unflushed_ids.total.

Spec update: The new increment section explicitly labels engineering-chosen bounds as "choices made by the implementing agent… not by the owner," consistent with the governance model's handling of unspecified ranges.

No concrete defects found.

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

Subject: 979fab7...7c09ad3, diff digest d5fe261d03f668877468caf1ed91c311db3c62da7558407a5251e4577a5e3971, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus merged commit c391679 into main Oct 23, 2026
31 checks passed
@bartekus
bartekus deleted the impl/042-serve-documents branch October 23, 2026 05:14
bartekus added a commit that referenced this pull request Oct 23, 2026
Amends the spec 010 section 3.4 `rustev-serve` binding record, stacked
on #180.

- Item 2 (schemas): refuse -> pass. Spec 042's documents now exist in
`rustev-contract` (#176, #180) with bounds, emitted schemas and negative
fixtures.
- Sigstore row: unverified -> pass. `sigstore-verify` 0.15.0 with
`default-features = false, features = ["aws-lc-rs"]` verifies a v0.3
bundle offline against a host-supplied trusted root, with no HTTP
client, tokio or TUF in its tree (checked with `cargo tree`). Crypto is
`aws-lc-rs` 1.18.2, which needs a C compiler and CMake at build time.

This is the owner's review act under 3.4 (R-44): implementation of
`rustev-serve` waits for the owner's approval of this text, which will
be recorded as a dated decision.
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