Skip to content

073 increment 1: extraction programs and templates on plan check and plan compile - #601

Merged
bartekus merged 2 commits into
mainfrom
impl/073-increment-1
Nov 25, 2026
Merged

bartekus merged 2 commits into
mainfrom
impl/073-increment-1

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Summary

Spec 073 increment 1 (#598), stacked on #599.

  • rustev-surface: DepArgs and Deps carry extraction programs and prompt templates, read after calibrations in the order supplied, each under its type's bound. compile_definition_bytes calls compile_with_extraction_documents when either is given, and exactly today's compile/compile_with otherwise (3.3.1). The instantiation path refuses them with invalid_input (3.3.4).
  • rustev-cli: --extract-rules and --template on plan check and plan compile, capped at 4 096 files each (006 3.3.2). They are a usage error with --profile, --profile-base, --variant, --definition-version or a second --definition. The help text is updated.
  • Shared golden (3.7): crates/rustev-core/tests/golden/rules-first/ holds a synthetic fictional airline confirmation (/2 program with token_after, token_matching and date{dmy_name}, fill: rules_first). tests/rules_first_golden.rs pins its plan and PlanId, and the CLI writes the same bytes.
  • Tests: crates/rustev-cli/tests/extraction_documents.rs (10 tests over section 5), goldens extraction-documents.*.json, and five harvested conformance cases (cli here; increment 2 adds native).

No contract type, schema, generated binding type, existing golden or existing conformance case changes.

Checks

make gate, the coupling check and make code pass locally.

@bartekus bartekus added the statecraft:stacked-ci Run the full CI matrix on a stacked pull request label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for spec 073 increment 1 (surface and CLI support for --extract-rules and --template).

Byte limits for new document types (crates/rustev-surface/src/deps.rs)

Extraction programs route through the existing parse() helper (uses DESCRIPTOR_V1.max_bytes), and templates use parse_within(..., DEFINITION_V1.max_bytes). Both match spec 073 section 3.1.

CLI validation ordering (crates/rustev-cli/src/plan.rs)

The flag-combination check (--profile, --profile-base, --variant, --definition-version, second --definition) runs in validate() before any reads, producing exit 2. This is consistent with 3.3.4's requirement that argument-driven instantiation be refused before any file is read.

Profile-path check (crates/rustev-surface/src/profile.rs)

The plan_command guard fires after the definition is loaded but before dependencies are read, returning invalid_input (exit 4) naming the first template or extract-rules file. This covers the "version 2 template with parameters or variants" case that can only be detected post-definition-read. The test a_template_definition_is_invalid_input_before_any_dependency_is_read exercises this path and asserts the correct exit code and input field.

Unchanged callers (..Default::default())

Node commands, the WASM package, the serve offline path, and the repeat commands all use ..Default::default() to pass empty slices for the new DepArgs fields. This is consistent with spec 3.5 (Node increment 2, WASM unchanged).

Conformance surface filtering (crates/rustev-cli/tests/common/harvest.rs)

extraction-documents.* cases are limited to surface ["cli"], matching the spec's statement that the native binding joins in increment 2 and WASM gains nothing (3.5).

#[allow(clippy::large_enum_variant)] on DiffArgs (crates/rustev-surface/src/plan_diff.rs)

The comment explains the rationale (the enum is a Copy bundle of borrowed slices built once per command, never boxed), and the enum remains correct. This is a lint suppression with explicit justification, not a defect.

Golden plan identity

Both extraction-documents.check.json and extraction-documents.compile.json carry plan_id: sha256:d9404c... matching crates/rustev-core/tests/golden/rules-first/plan.id. The core golden test (rules_first_golden.rs) pins the same id from the Rust path.

No concrete bugs, security issues, or contradictions with the governance documents were found.

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

Subject: 13cb581...fe716a4, diff digest f4e058972b48a01b8ee15c6892eded8e38f57159ecc4ba2da80cdf85d6cff983, 1 call(s). An AI comment is not an approval.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff against spec 073 and the governance rules.

Structural changes are consistent: DepArgs gains extract_rules and templates with correct Default impl wiring; all existing callers (wasm, serve, repeat, node) add ..Default::default(); Deps::has_documents() gates the routing; byte limits use DESCRIPTOR_V1 for programs and DEFINITION_V1 for templates per the spec record; file-count caps of 4 096 match spec 3.2.1; usage guards in plan.rs and profile.rs enforce spec 3.3.4; golden fixture bytes are consistent across core/cli/conformance.

One concrete defect found:

integrations/rustev-node/src/commands.rs and integrations/rustev-node/src/profile.rs are both in the SUBJECT's changed paths and both modified in the diff (each adds ..Default::default() to a DepArgs literal). The spec 073 diff adds extends entries for integrations/rustev-wasm/ (under spec 027) and integrations/rustev-serve/ (under spec 010), but adds no entry for integrations/rustev-node/. The spec record then states "Every other caller of DepArgs (the Node binding's commands … ) passes no documents and is unchanged" — a factual contradiction with the diff. The coupling gate (spec-spine couple) checks that every changed code path is covered by a spec ownership claim; the node integration files are not claimed, so this PR is likely to fail that gate.

The fix is to add an extends entry for integrations/rustev-node/ (owned by spec 027) and correct the implementation record's "is unchanged" claim for the Node binding.

No security issues were found: file I/O goes through the Host abstraction, count caps are enforced before reads, byte limits use typed constants, no shell interpolation is introduced.

{"head": "ab652c150a843b3cf4884fc8263325c2bbf778f9", "verdict": "findings", "findings": [{"path": "specs/073-compile-extraction-documents-from-hosts/spec.md", "line": null, "severity": "medium", "category": "correctness", "summary": "integrations/rustev-node/src/commands.rs and src/profile.rs are modified in this PR but no extends entry for integrations/rustev-node/ is added to spec 073, and the implementation record incorrectly states the Node binding is unchanged, leaving those paths unclaimed for the coupling gate."}]}

Subject: c03069f...ab652c1, diff digest 6926228adf5575d2cabb85d0727b0796a309dc476768a41040707c3fe5da14f7, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 24, 2026 20:42 — with GitHub Actions Inactive
Base automatically changed from spec/073-074-drafts to main November 24, 2026 21:46
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for spec 073 (increment 1: surface/CLI) and spec 074 (spec text only), plus the supply-chain advisory update to spec 001.

Code and logic review:

crates/rustev-surface/src/deps.rs — The parse_within path for templates correctly uses DEFINITION_V1.max_bytes; the parse helper (used for extraction programs) uses DESCRIPTOR_V1.max_bytes. Order of reads (definitions → descriptors → rules → calibrations → extraction programs → templates) matches spec 073 §3.4.3. ✓

crates/rustev-surface/src/plan.rs — has_documents() returns true when either list is non-empty; routes correctly through compile_with_extraction_documents with sources=[]. The fall-through to the existing compile/compile_with paths when no documents are supplied satisfies I-2. ✓

crates/rustev-surface/src/profile.rs — The check for extract-rules/template documents fires after i (loaded definitions) is in scope but before select_template reads dependencies — matching spec 073 §3.3.4's "after the definition is read and before any dependency is read." ✓

crates/rustev-cli/src/plan.rs — Correctly forbids --profile, --profile-base, --variant, --definition-version with the new flags before any read (exit 2), and separately forbids more than one --definition. Covers all instantiation-argument cases in §3.3.4. ✓

..Default::default() additions in repeat.rs, rustev-node/commands.rs, profile.rs, rustev-serve/offline.rs, rustev-wasm/lib.rs — extract_rules and templates default to &[], correct. ✓

plan_diff.rs — #[allow(clippy::large_enum_variant)] is documented in the implementation record ("DiffArgs keeps its Copy bundle under an allowed large_enum_variant"). ✓

One lifecycle inconsistency:

Spec 073's frontmatter declares implementation: pending and the opening sentence repeats "the implementation is pending," yet the implementation record immediately describes increment 1 (the full surface/CLI/core-test change) as delivered in this same PR. Per the contract, pending means work has not started; in-progress is the accurate value once an increment is under way. Both values are schedulable with a W-001 warning, so there is no functional impact, but the lifecycle claim is inaccurate.

Spec 074's implementation: pending is correct — no 074 implementation code is in this diff.

{"head": "ab652c150a843b3cf4884fc8263325c2bbf778f9", "verdict": "findings", "findings": [{"path": "specs/073-compile-extraction-documents-from-hosts/spec.md", "line": 7, "severity": "low", "category": "ratification", "summary": "Frontmatter declares `implementation: pending` and the opening sentence repeats the same claim, but the implementation record in the same file describes increment 1 as fully delivered in this PR; the accurate lifecycle value is `in-progress`."}]}

Subject: fa50cbb...ab652c1, diff digest a57c01309a5db580f670d9819642526aaab2801267f2bd978e6f9ab6bd9b3014, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 24, 2026 21:53 — with GitHub Actions Inactive
…and Node's command path in 3.3.4 (AI review)
…plan compile

`rustev plan check` and `plan compile` take repeatable `--extract-rules`
and `--template` and compile through `compile_with_extraction_documents`
(spec 073, 3.2 to 3.4); without them, the call is exactly today's. The
shared rules-first golden (3.7, a synthetic airline confirmation) is
pinned in the core and compiled by the CLI to the same bytes and PlanId.
Five CLI conformance cases, surfaces `cli`.
@bartekus
bartekus force-pushed the impl/073-increment-1 branch from ab652c1 to c6dc918 Compare November 24, 2026 22:23
@bartekus
bartekus enabled auto-merge November 24, 2026 22:23
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff for spec 073 increment 1: CLI and surface plumbing for --extract-rules / --template on plan check and plan compile.

args.rs / deps.rs / io.rs — flags registered for the two commands only, count caps wired through MAX_EXTRACT_RULES_FILES / MAX_TEMPLATE_FILES (both 4096, as spec 073 3.2.1 requires). Clean.

plan.rs validation — when either new flag is present, --profile, --profile-base, --variant, --definition-version and a second --definition are all forbidden before any read (exit 2). Matches 3.3.4. The same matches! block also covers profile check, but those flags are not registered for that command so the check is dead-but-harmless there.

surface/deps.rs — extraction programs read under DESCRIPTOR_V1.max_bytes (via the shared parse helper), templates under DEFINITION_V1.max_bytes via parse_within. Matches spec 073 3.1 / 3.2.1. has_documents() returns true when either list is non-empty, correctly routing through compile_with_extraction_documents. DepFail variants are consistent with 3.4.1.

surface/plan.rs — the early return for has_documents() correctly bypasses the existing compile/compile_with match, passing execution.as_ref() to handle both the None and Some cases inside the extraction-documents path. The &[] fourth argument is consistently &[] in both the surface call and the core golden test, so usage is internally consistent.

surface/profile.rs — refusal of extraction documents on the parameterized/profile path occurs before load_deps (after definition read), reporting invalid_input naming the first offending label. Matches 3.3.4's "refused after the definition is read and before any dependency is read". The Done::invalid(command, input.1, …) call uses the filename as the input label, consistent with what the CLI test (a_template_definition_is_invalid_input_before_any_dependency_is_read) asserts.

Other callers (repeat.rs, node commands/profile, serve offline, wasm) — all use ..Default::default() for the new fields, leaving them empty. Requires DepArgs to implement Default; all fields are &'a [String] which is Default. The diff adds #[derive(Default)] to the rustev-cli-local DepArgs; the surface-level DepArgs likely already had it or the struct-update syntax wouldn't compile. No evidence of an absence.

plan_diff.rs — #[allow(clippy::large_enum_variant)] added with an explanatory comment. Legitimate suppression: the enum is Copy and "never boxed", so Clippy's box-the-large-variant heuristic is inapplicable. The comment correctly attributes the size growth to spec 073's addition of two slice fields.

Golden consistency — plan.id (sha256:9c79b...432b) matches across the core golden, the CLI extraction-documents.check.json and .compile.json goldens, and the CLI test assertions. Cross-surface identity is pinned as 3.3.3 requires.

spec 073 edits — adds integrations/rustev-wasm/ and integrations/rustev-serve/ extends edges to match the actual code touched, clarifies 3.2.1 wording, and adds an implementation record. All within the approved spec's own text; no governance authority changed.

No concrete defects found.

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

Subject: 9e1ab3a...c6dc918, diff digest 07b6a44f133027078694bf5bd5d0ba6288371736402215789cf6336fd583976f, 1 call(s). An AI comment is not an approval.

@bartekus bartekus closed this Nov 24, 2026
auto-merge was automatically disabled November 24, 2026 23:00

Pull request was closed

@bartekus bartekus reopened this Nov 24, 2026
@bartekus
bartekus enabled auto-merge November 24, 2026 23:00
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR, which implements spec 073 increment 1: CLI/surface support for --extract-rules and --template on plan check and plan compile.

args.rs — New flags added only to plan check and plan compile. The profile check path is included in the outer matches! guard in plan.rs but p.has(f) is always false for it since those flags aren't registered; dead but harmless.

deps.rs — parse (via parse_within) uses DESCRIPTOR_V1.max_bytes for extract-rules programs; templates use parse_within with DEFINITION_V1.max_bytes. Both match spec 073 §3.1 ("programs read under DESCRIPTOR_V1 and templates under DEFINITION_V1"). Load order: descriptors → rules → calibrations → extract-rules → templates, matching §3.4.3.

plan.rs — Validation block correctly forbids --profile, --profile-base, --variant, --definition-version and multiple --definition when documents are present (§3.3.4), producing exit 2 before any read. The subsequent compile_definition_bytes call uses compile_with_extraction_documents when deps.has_documents() and falls through to the existing compile/compile_with paths otherwise; the execution policy is forwarded in both branches.

profile.rs — The guard before select_template catches documents on the instantiation path after the definition is read but before dependencies are read, matching §3.3.4's "found in the definition" timing requirement and returning Done::invalid. The CLI never reaches this path with documents present (blocked in plan.rs), so for Node this is the right catch point.

plan_diff.rs — #[allow(clippy::large_enum_variant)] is added because spec 073 grew DepArgs by two slice fields, widening the DiffArgs variant that holds it. The enum is Copy with borrowed data; the suppress is correctly justified (-D warnings enforced by make code).

other callers (rustev-node, rustev-wasm, rustev-serve, repeat.rs) — All use ..Default::default() to fill extract_rules: &[] and templates: &[], leaving those surfaces unchanged as §3.5 requires.

golden fixtures — rules-first/plan.id (sha256:9c79b...) matches the IDs in extraction-documents.check.json and extraction-documents.compile.json. rules_first_golden.rs pins both the plan bytes and the PlanId from compile_with_extraction_documents. Conformance fixtures replicate the shared inputs byte-for-byte.

spec file — The two new extends edges (rustev-wasm/, rustev-serve/, both additive) correctly cover the ..Default::default() additions. The existing amending edge for rustev-node/ covers the Node binding changes. The implementation record is factually consistent with the diff.

No concrete defects found.

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

Subject: 9e1ab3a...c6dc918, diff digest 07b6a44f133027078694bf5bd5d0ba6288371736402215789cf6336fd583976f, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 25, 2026
@bartekus
bartekus added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 27e915d Nov 25, 2026
225 of 255 checks passed
@bartekus
bartekus deleted the impl/073-increment-1 branch November 25, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant