Skip to content

impl(022): the stage 3 qualification construction, stage 2 at jev-1.14.0 and stage 3's record - #406

Merged
bartekus merged 1 commit into
mainfrom
impl/022-qualification
Oct 30, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/022-qualification

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Stacked on #402 (spec 022 3.7.4); retarget to main after #402 merges. Implements 3.7.4 and records stage 2 at jev-1.14.0 and stage 3, run live on 2026-10-29 under the owner's authorization (A-68).

3.7.4: JevBackend::new_qualification

  • It refuses a production journal, a Gateway decision binding, any mapping other than rustev-jev-mapping/2, a plaintext endpoint, and facts that fail 3.4, all before any credential lookup.
  • Its records name the production binding's identity and protocol, qualification: stage 3 and the zero-retention fact. It keeps request and response bytes, since the content is synthetic.
  • It shares its construction with new_mechanics, and new_production still refuses.

Two defects found live, each with a test

  • The client prefixed the binding's full endpoint to its path, which gave HTTP 404. It now takes the origin.
  • The synthetic mechanics privacy member was sent under the direct mapping, which gave HTTP 400. production_body now adds it only under the synthetic mapping.

Recordings and evidence

  • Stage 2 at jev-1.14.0: four recorded fixtures (recorded-direct-114-*), replayed beside the 1.13 ones in tests/direct_recorded.rs.
  • The live_direct_smoke placeholder is removed, because stage 2 is recorded.
  • Spec 022's implementation record holds stage 3: binding identity, set, calls, the spec 004 metrics against the rules baseline, the two failed runs, and spend (USD 0.023 of the USD 5 testing cap in all).
  • 022 stays in-progress. Only 3.7.4.4's later change remains: accepting a stage 3 record and enabling new_production.

make code, make gate, spec-spine verify 022 and the authored-content check pass. The fixtures were checked for the key.

@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the changes: a refactor of new_mechanics into a shared over_production_binding helper, a new new_qualification constructor, two new public helpers (production_body, origin), four jev-1.14.0 fixture files, extended tests, and a spec.md update recording stages 2 and 3.

adapter.rs

production_body correctly conditions the privacy member on the synthetic mapping ("rustev-jev-direct-synthetic/1"), leaving the direct mapping body unchanged. The test only_the_synthetic_mapping_adds_a_privacy_member covers both branches. The origin helper strips the trailing slash before strip_suffix, and the three test cases cover the empty-path edge (base_path "" → strip_suffix("") always returns Some).

new_qualification checks transport, both mapping fields, and journal budget before calling check_facts, then derives the origin before forwarding to over_production_binding with retain_bytes = true. new_mechanics continues to forward with retain_bytes = false (consistent with spec 009 R-19). Both pass "synthetic mechanics only" / "stage 3" as the qualification label, which lands in inner.privacy.

over_production_binding calls Endpoint::parse(&binding.facts.endpoint) a second time to extract base_path after origin() already parsed it once, but this is a minor inefficiency, not a bug.

direct_recorded.rs

recorded_114 reuses the projections from recorded() (same question text and state) and substitutes new fixtures and outputs. The test each_recorded_request_is_the_body_the_direct_mapping_sends creates a JevBinding::direct(pin) per pin, so the model field in the serialised request correctly shifts to "jev-1.14.0".

Fixture files

The four jev-1.14.0 fixtures are structurally consistent with the existing jev-1.13.0 set. recorded-direct-114-boolean-hotel-200.json carries the flight question ("Does the message confirm a flight booking?") on hotel content — this is intentional (it's the negative case from recorded()), not an error.

production.rs

The removed live_direct_smoke placeholder is no longer needed because stage 2 is now recorded. The remaining live_production_qualification placeholder is still marked #[ignore] for the later step (3.7.4.4). The new a_qualification_record_names_the_production_binding_and_stage_3 test uses a dead loopback URL so no request leaves the machine; it still verifies the record fields because the exchange sink delivers on connect failure.

spec.md

The narrative is internally consistent: stage 2 at jev-1.14.0 is recorded, stage 3 is recorded with its spend and defects, new_production still refuses, and 022 stays in-progress pending 3.7.4.4. No governance claim contradicts the code evidence visible in the diff.

No concrete defects found.

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

Subject: 894e2cf...46cee65, diff digest 6ca55bfaef127cd2bc582dc4fa4ce3735940e877502390ab215f5013a876ce67, 1 call(s). An AI comment is not an approval.

Base automatically changed from spec/022-qualification to main October 30, 2026 04:21
@bartekus
bartekus force-pushed the impl/022-qualification branch from 46cee65 to 3212418 Compare October 30, 2026 04:42
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff across the changed paths.

integrations/rustev-jev/src/adapter.rs — production_body

The new public function guards the privacy-member injection with a hard-coded string literal:

if binding.mapping != "rustev-jev-direct-synthetic/1" {
    return body;
}

Everywhere else in this file and in the test (new_qualification, the refusal guard in qualification_refuses_everything_3_7_4_forbids_before_any_credential) the same synthetic mapping identity is compared via crate::binding::MAPPING_VERSION. Using a bare literal here instead of the constant means a future change to MAPPING_VERSION would silently leave production_body sending (or not sending) the privacy member to the wrong mapping — the exact defect this function was written to prevent (the HTTP 400 incident). The function is pub, so external callers also see the inconsistency.

integrations/rustev-jev/tests/production.rs — a_qualification_record_names_the_production_binding_and_stage_3

let dead = dead_url().await;
let endpoint = format!("{}/v1/systemone", dead.replacen("http://", "https://", 1));

replacen("http://", "https://", 1) only replaces the first occurrence. If dead_url() ever returns a URL whose path contains the substring http:// (e.g. a redirect-trap URL), the replacement would occur in the wrong position, producing a malformed endpoint. This is unlikely but the replacen call is fragile where a structured URL mutation would be safer. No concrete production impact given dead_url() is a controlled test helper, but it is a latent brittleness.

specs/022-jev-production-transport/spec.md — no factual inconsistencies detected. The SHA-256 cited (sha256:12897cdf3796818833af333769e913d1a1f65a267532ea4de2ec3b144fd40bd4) is 64 hex digits. The spend arithmetic and the in-progress status explanation are internally consistent.

Fixture files — well-formed JSON; model pins, question shapes, and output types match the code paths exercised in direct_recorded.rs.

{"head": "32124189247a08c766a6fbaa2791b5d9f797559c", "verdict": "findings", "findings": [{"path": "integrations/rustev-jev/src/adapter.rs", "line": 295, "summary": "production_body compares binding.mapping against the hard-coded string literal \"rustev-jev-direct-synthetic/1\" instead of the crate::binding::MAPPING_VERSION constant used everywhere else for this mapping identity, creating a silent divergence risk if the constant value is ever changed."}]}

Subject: b7984a4...3212418, diff digest 6ca55bfaef127cd2bc582dc4fa4ce3735940e877502390ab215f5013a876ce67, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception October 30, 2026 04:47 — with GitHub Actions Inactive
@bartekus
bartekus force-pushed the impl/022-qualification branch from 3212418 to 5019420 Compare October 30, 2026 04:48
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing each changed file for bugs, security problems, and inconsistencies.

integrations/rustev-jev/src/adapter.rs

production_body: The .expect("generated JSON") calls are safe because the body is produced by request_body in the same call path and is always valid JSON. The extraction from the inline code in run_exchange is correct — the guard binding.mapping != SYNTHETIC_MECHANICS_MAPPING now correctly routes both mappings.

origin: trim_end_matches('/') strips trailing slashes, then strip_suffix(base_path) removes the path component. The unwrap_or(trimmed) fallback handles the no-path case correctly. The three test assertions in a_qualification_adapter_takes_the_endpoint_origin cover the path, trailing-slash, and no-path cases. No defect.

new_qualification: Validates facts first (catches plaintext HTTP, empty retention_terms), then checks all four conditions (transport, both mapping fields, journal budget) before any credential lookup — consistent with the test name and assertions. origin() is called only after those guards pass. over_production_binding is called with retain_bytes: true and qualification = "stage 3", matching the record assertions in a_qualification_record_names_the_production_binding_and_stage_3.

over_production_binding: The refactor correctly captures the shared construction. For mechanics retain_bytes = false preserves prior behavior; qualification = "synthetic mechanics only" preserves the original privacy label. No regressions.

The removal of the loopback check from the qualification path is intentional: mechanics is loopback-only (3.7.3), but qualification targets the production HTTPS endpoint (3.7.4). check_facts enforces HTTPS; the test uses a loopback dead URL and closes with assert_loopback_only() to confirm no external traffic.

integrations/rustev-jev/src/production.rs

SYNTHETIC_MECHANICS_MAPPING constant replaces the string literal scattered in adapter.rs and the test. No semantic change.

integrations/rustev-jev/tests/direct_recorded.rs

The recorded_114 / pins refactor is correct. The fixture filenames match the new JSON files. rec.served.identity is now asserted against pin (the variable) rather than the hardcoded "jev-1.13.0", which is correct for multi-pin iteration.

Fixture files

The four recorded-direct-114-*-200.json files are internally consistent: model in request and response both say "jev-1.14.0"; request_body shapes match the direct-mapping format (no privacy member); response_body shapes are correct for noul, choice, and score types respectively.

specs/022-jev-production-transport/spec.md

The spec accurately describes the state: stage 2 at jev-1.14.0 recorded, stage 3 run with two defects found and tested, new_production still refuses (3.7.4.4 deferred), 022 stays in-progress. No contradiction with the code.

No concrete defects found.

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

Subject: b7984a4...5019420, diff digest 17d9c13f4c21c61ca926d32b8b38e0fd7d7c964cde8c895f3ec6b44bd6c257d1, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge October 30, 2026 04:51
@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 30, 2026
@bartekus
bartekus enabled auto-merge October 30, 2026 06:03
@bartekus
bartekus disabled auto-merge October 30, 2026 15:04
@bartekus
bartekus force-pushed the impl/022-qualification branch from 5019420 to 4dcb5ab Compare October 30, 2026 15:05
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across all changed paths.

integrations/rustev-jev/src/adapter.rs

production_body (new lines ~290-305): Clean refactor of the inline body-augmentation logic. The gate binding.mapping != SYNTHETIC_MECHANICS_MAPPING correctly preserves the original semantics — only the synthetic mechanics mapping receives the privacy member.

origin (new lines ~308-319): Parses the endpoint to extract base_path, trims trailing slashes from the raw string, then strips the path suffix. Three cases are tested (/v1/systemone, trailing-slash variant, no-path). The strip_suffix("") case (no path) returns Some(self) in Rust, which is correct. The unwrap_or(trimmed) fallback would silently return the full URL with path on a mismatch, but since Endpoint::parse is called on the same string it extracts base_path from, a mismatch cannot occur in practice.

new_qualification: Pre-validates via check_facts (which enforces HTTPS and the USD 5 cap), then checks Transport::Direct, both binding.mapping and binding.decision.mapping_version against DIRECT_MAPPING_VERSION, and BudgetKind::Testing. Order is correct and the test confirms no credential is read before these guards pass.

over_production_binding: The refactored shared constructor receives endpoint as an already-stripped origin for qualification (via origin()) and whatever the original caller passed for mechanics (which was already the loopback origin). inner.path is correctly re-extracted from binding.facts.endpoint in both cases, so the client gets origin + path assembled without doubling.

integrations/rustev-jev/tests/production.rs

qualification_binding: Sets b.mapping = DIRECT_MAPPING_VERSION but relies on the base binding()'s JevBinding::direct(...) to already carry mapping_version = DIRECT_MAPPING_VERSION. The test explicitly exercises the mapping_version != DIRECT_MAPPING_VERSION refusal path, so any drift there would be caught.

qualification_refuses_everything_3_7_4_forbids_before_any_credential: Covers production journal, wrong mapping, wrong mapping_version, Gateway transport, HTTP endpoint, and invalid facts. The count == 0 assertion at the end confirms construction-time credential abstinence throughout, including the success case.

a_qualification_record_names_the_production_binding_and_stage_3: Uses a dead HTTPS URL (loopback port, HTTPS scheme) so check_facts passes but the connect fails, giving a record without any network egress. Fields checked match what over_production_binding sets.

only_the_synthetic_mapping_adds_a_privacy_member: Directly tests production_body for both the direct and synthetic cases.

Fixture files

The four recorded-direct-114-*-200.json fixtures are internally consistent: model field matches jev-1.14.0 in both request and response, question types match the parser's expected shapes (noul/choice/score), and the recorded outputs align with the recorded_114() expected-output array. The score fixture reports score: 1.92 against computed probabilities yielding 1.91 — a sub-LSB difference from the live API's own arithmetic, not a PR defect.

Spec specs/022-jev-production-transport/spec.md

The removed paragraph ("Externally blocked, never reported as passed") is correctly superseded by the stage 3 record. The spec accurately describes both defects found in live runs, the fixes, the spend accounting, and the remaining gap (3.7.5 / new_production still refuses). implementation: in-progress is consistent with that description.

No concrete defects found.

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

Subject: d2a496f...4dcb5ab, diff digest a15eb14f436b7898601e578093352f04beb1ce612c6b55c24d412a3411fae264, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus enabled auto-merge October 30, 2026 15:09
@bartekus
bartekus added this pull request to the merge queue Oct 30, 2026
Merged via the queue into main with commit c593fd4 Oct 30, 2026
30 checks passed
@bartekus
bartekus deleted the impl/022-qualification branch October 30, 2026 16:01
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