Skip to content

forge-engine: gate promotion on retained executions (R02/R04 gaps from #111) - #112

Merged
RecursiveIntell merged 1 commit into
mainfrom
rsi/p2-r04-promotion-gate-20261130
Dec 1, 2026
Merged

RecursiveIntell merged 1 commit into
mainfrom
rsi/p2-r04-promotion-gate-20261130

Conversation

@RecursiveIntell

Copy link
Copy Markdown
Owner

What this does

Addresses the five evidence/promotion gaps disclosed in #111. Four are closed by default: retained-execution admission, trial de-duplication, receipt resolution, and comparability. The fifth, stale evidence, is gated only when an operator sets lab.promotion_max_evidence_age_secs; with the default None, stale evidence is not refused.

  • Single owner for the check. New ExperimentEvidenceBundle::admission_gap() returns the first reason the retained executions cannot support a qualified claim: no completed trials, invalid comparability, no comparability verdict recorded, or a trial citing a receipt the bundle does not carry. Both the canonical lifecycle/promotion-state derivation and promote() consult it, so they cannot disagree on retained-execution admission. The store-backed raw-artifact check is enforced in promote() only (see Not closed here).
  • Duplicated trials. distinct_completed_trial_count() counts trials by trial_id; copies count once, and records sharing a trial_id that contradict each other (side, attempt or completion) are not counted as completed.
  • promote() now refuses with criterion completed_trials, pair_comparability, pair_comparability_missing or trial_receipt from that gap, and with raw_artifact when a StoreRow receipt does not resolve to a tool_receipts row (wrong table or missing row) through the store promote() already holds.
  • Promotion state. Invalid comparability or a dangling trial receipt derives Blocked{…}; no completed trial or no comparability verdict derives NotPromoted. Neither derives Eligible.
  • Evidence age is an operator parameter only: lab.promotion_max_evidence_age_secs: Option<u64>, default None (no change to current behaviour). When set, promote() refuses evidence older than the limit, dated in the future, or with an unparsable created_at (criterion evidence_age). Documented in PROMOTION.md and CONFIG.md.

Behaviour changes to note

  • A bundle with no recorded comparability verdict is no longer promotable (previously only an explicitly invalid verdict blocked it). Comparability is not assumed.
  • A StoreRow receipt naming a table other than tool_receipts is refused, because it cannot be resolved here.
  • The promotion_tests and r04_witness_tests fixtures built assessment-only bundles with zero trials — the case the contract forbids. Their fixtures now carry two distinct completed trials and a valid comparability verdict; their assertions are unchanged. export_tests::claim_metadata_carries_projected_verification_summary now carries the two receipts its trials cite; asserted values are unchanged. Test counts in all three files are unchanged (5, 7 and 27) and no assertion line was removed; the fixtures only gained the data described.

Evidence

On head 988102d (on main 4d030f8):

  • cargo fmt --all -- --check, and cargo clippy --locked --workspace --all-targets --all-features -- -D warnings: clean.
  • cargo test --locked --workspace --all-targets --all-features --no-fail-fast (root workspace): 3,614 passed, 0 failed, 7 ignored.
  • The gap tests from tests: R02/R04 acceptance witnesses; disclose five promotion/evidence gaps (P2) #111 are added in the new tests/r04_promotion_gate_tests.rs (13 tests).
  • 18 single-line mutants of the new guards, each killed by a test, sources restored byte-identical (sha256). The mutant run was made before a clean rebase onto 4d030f8; the full gates above were re-run after it.

These are local runs on one host; hosted CI results will be reported by this PR's own checks.

Not closed here

  • The pure canonical projection has no store handle, so a bundle whose StoreRow raw artifact is absent still projects lifecycle Verified; only promote() refuses it. Closing that needs store-aware lifecycle derivation.
  • ArtifactPath receipts are not resolved (no operator-defined artifact root in this crate), and raw-artifact content hashes are not re-verified — only row existence.
  • No default evidence TTL is set, because the contract specifies no threshold value; staleness gating is opt-in.

No provider call, deployment or activation.

- Count distinct trials by trial_id; contradictory records for one id do not
  count as completed (R02-N6).
- One admission_gap() owner drives both the canonical lifecycle/promotion state
  and promote(): zero completed trials, invalid or unrecorded pair
  comparability, and trial-cited receipts absent from the bundle are not
  Verified/Eligible and are refused by promote() (R04-N2/N6/N7).
- promote() resolves StoreRow raw-artifact receipts against tool_receipts and
  refuses unresolved ones.
- Optional operator-owned lab.promotion_max_evidence_age_secs (default None:
  behaviour unchanged; the contract defines no TTL) (R04-N8).
- Move the PR #111 gap tests in as r04_promotion_gate_tests; positive-path
  fixtures in promotion/r04_witness/export tests now carry the executions the
  gate requires.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-30T23:51:50.389287Z
We couldn’t complete this review. Comment @codex review to try again.
988102d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@RecursiveIntell
RecursiveIntell merged commit a4dfb91 into main Dec 1, 2026
14 checks passed
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