Skip to content

docs(072): selection gate feature page and runnable example (increment 4) - #595

Merged
bartekus merged 1 commit into
mainfrom
impl/072-inc4-page
Nov 11, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/072-inc4-page

Conversation

@bartekus

Copy link
Copy Markdown
Contributor

Spec 072 increment 4: the selection gate feature page and its runnable example (3.4, R-2).

  • docs/features/selection-gate.md: what the gate decides, when to use it, a worked example with real output, the decision order, the documents and their fields, exit codes, pitfalls and limits.
  • docs/features/selection-gate/example/: run.sh compiles synthetic-example.definition.json (increment 1, no digest rewriting), captures replay bundles for every dataset case, evaluates the baseline and two threshold variants twice by replay, records the baseline, and runs gate select with gate.json and gate-strict.json. It compares verdicts and rule results (not bytes: run records carry measured latency) with expected-gate.json and expected-gate-strict.json.

Stacked on #589. 072 joins VERIFIED_SPECS and an acceptance group in the last increment, because its Verification also names increment 3's schema test.

Verified locally: make gate; env RUSTEV=<built rustev> sh docs/features/selection-gate/example/run.sh exits 0 with both verdict files matching.

@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for bugs, security problems, and inconsistencies against the governance context.

Spec 072 change — removing planned: true from the directory unit is consistent with the directory now receiving content; the increment 4 prose is internally coherent.

Shell script review (run.sh) — set -eu is appropriate. Environment-variable expansion in the sed command is safe because $threshold is sourced from a hardcoded loop literal (0.35, 0.8), not user input. All rustev commands redirect stdout to /dev/null or a named file; no uncontrolled output escapes.

Documented output vs. actual script output — The "Try it" section in selection-gate.md shows four lines of expected output:

sh docs/features/selection-gate/example/run.sh
# gate select: exit 0, selected        ← spurious
# gate: gate select exit 0, selected
# gate-strict: gate select exit 0, selected
# verdicts match the expected files (/tmp/rustev-selection-gate.XXXXXX)

The script produces exactly three lines of output: the echo inside check_gate for each of the two gates (gate: gate select exit 0, selected and gate-strict: gate select exit 0, selected), and the final echo "verdicts match...". Every rustev invocation's stdout is either redirected to /dev/null or captured to a file; no other output is printed. The first documented line # gate select: exit 0, selected has no corresponding source in run.sh and cannot appear when the script is run as written.

Expected JSON vs. documentation tables — The tables in selection-gate.md match expected-gate.json and expected-gate-strict.json: route-less rejected on require[1] in both files, route-more qualifies in both.

check_gate error handling — When rustev gate select exits non-zero without writing the output file, the subsequent jq call on the missing file will fail under set -e before reaching the controlled exit 1, producing a jq error rather than the diagnostic diff. This is a minor robustness gap in the tutorial script but does not affect correctness when the binary writes the file on all exit paths (which the documentation implies it does).

{"head": "f8590bf2286e019af983660ed160007a30a0064f", "verdict": "findings", "findings": [{"path": "docs/features/selection-gate.md", "line": 74, "severity": "low", "category": "correctness", "summary": "The documented script output includes a spurious first line '# gate select: exit 0, selected' that run.sh never produces; the script emits only the two 'gate:' / 'gate-strict:' echo lines and the final 'verdicts match' line."}]}

Subject: 21156e4...f8590bf, diff digest 4b2f4bfa9c67dbd087a36a32f59b6b97370ce7c3f175d5ab6602773b3987dfaa, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception November 11, 2026 00:51 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff against governance context and checking each changed file for bugs, security problems, and inconsistencies.

specs/072-documentation-source-gaps/spec.md
Removes planned: true from the docs/features/ directory unit — correct, since files are now being committed into that directory. The increment 4 description accurately reflects what is committed in this PR.

docs/features/selection-gate/example/run.sh

  • set -eu is in place; all variables from the for variant in route-more:0.35 route-less:0.8 loop are hardcoded, so the sed substitution of $threshold and use of $name as file paths carry no injection risk.
  • All command invocations quote "$RUSTEV", "$DATA", "$WORK", "$HERE", "$snapshot", "$1" etc. correctly.
  • exit inside check_gate is not in a subshell, so it correctly terminates the main script on failure.
  • The || status=$? idiom correctly captures non-zero exit without triggering set -e.

Expected JSON files vs. documentation tables

  • expected-gate.json: route-less → require[0] unknown (zero denominator), require[1] fail (acceptance_coverage), rejected on require[1]; route-more → both pass, qualifies. Matches the doc table exactly.
  • expected-gate-strict.json: route-less → require[0] unknown, require[1] fail (case regressions), require[2] fail, rejected on require[1]; route-more → all pass, qualifies. Matches.
  • 3 regressions (sr-m01, sr-m02, sr-m03) out of 4 is internally consistent: the baseline escalated one of the four (acceptance = 0.0), so it does not regress when route-less also escalates it.

Documentation internal consistency

  • The jq filter in check_gate selects only require-prefixed clauses; the expected files contain only require entries — consistent.
  • The "Writing a gate" composite example with 3 rules is a deliberate union of gate.json (2 rules) and gate-strict.json (3 rules) for illustration; not a bug.
  • The verdict decision table is consistent with the example outcomes. The absence of and_any in both gate files is handled by the table's "(if declared)" qualifier.
  • Governance links point to specs 029, 061, 064, 065, all present in the repo context.

No concrete bugs, security problems, or governance contradictions found.

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

Subject: 21156e4...5042b3a, diff digest 4a10f845a7d0b0b9b9241007341b65aad890b9fa65ee1d14d56497968c1353d3, 1 call(s). An AI comment is not an approval.

Base automatically changed from impl/072-inc1-definition to main November 11, 2026 01:52
@bartekus
bartekus enabled auto-merge November 11, 2026 01:53
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for correctness, security, and consistency with governance.

docs/features/selection-gate.md — New documentation file. Content is internally consistent: the verdict table, the "how a verdict is decided" table, and the two expected JSON files all agree. The step ordering (comparable → integrity → coverage → rules), the precedence of a definite failure over an unknown, and the guarantee list all align with what specs 029, 061, 064, 065 are described as requiring. No contradiction visible in the supplied text.

docs/features/selection-gate/example/run.sh — The script uses set -eu throughout, quotes all variable expansions, derives $threshold from hardcoded loop literals (no injection), and captures the gate select exit code with || status=$? before the set -e guard fires. The check_gate comparison is against the committed expected-*.json files and is freshly generated each invocation, so stale artifacts cannot silently pass. One discrepancy: the usage comment states the work directory "must not exist," but mkdir -p "$WORK" silently succeeds if a caller provides an existing path. If the directory is reused, the previous *.selection.json will be overwritten by the new run before the comparison, so the actual risk is minimal; it is still a documentation–code inconsistency.

docs/features/selection-gate/example/gate*.json / expected-gate*.json / repeat-config.json — Internally consistent. gate-strict.json adds a case_regressions rule as require[1]; expected-gate-strict.json correctly shows route-less rejected on require[1] (case regressions, the first failing rule) with require[0] unknown and require[2] also failing. gate.json has two require rules; expected-gate.json shows two clauses for route-less. Consistent with each other and with the narrative.

specs/072-documentation-source-gaps/spec.md — Removes planned: true from the establishes unit for docs/features/ and adds an increment-4 prose description. Removing planned: true is a factual update: the directory now exists. This is an edit to 072's own spec, not to an amended spec; the contract's prohibition on editing an amended spec.md does not apply here. The increment description is consistent with what this PR adds.

No security issues found. The shell script does not construct commands from external data, uses no eval, and quotes all variables.

{"head": "05a28d5631c504fbd58d5f69b82f59f687e71567", "verdict": "findings", "findings": [{"path": "docs/features/selection-gate/example/run.sh", "line": 16, "severity": "low", "category": "correctness", "summary": "Comment says the work directory 'must not exist' when provided as an argument, but mkdir -p silently accepts an existing directory; no guard enforces the documented precondition."}]}

Subject: dc60f26...05a28d5, diff digest 4a10f845a7d0b0b9b9241007341b65aad890b9fa65ee1d14d56497968c1353d3, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception November 11, 2026 01:57 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff against the governance context and the changed files.

run.sh — sed substitution pattern

Line 51–52 of run.sh:

sed "s/\"threshold\":\"0.6\"/\"threshold\":\"$threshold\"/" \
  baseline.definition.json > "$name.definition.json"

The pattern matches the compact form "threshold":"0.6" (no space after the colon). Standard pretty-printed JSON writes "threshold": "0.6". If synthetic-example.definition.json is formatted with that space, the substitution silently produces no change, so both candidate plans are identical to the baseline. The script would then fail at the cmp -s verdict check with a diff error, with no message indicating the sed pattern was the cause. This is a brittle dependency on the exact byte representation of a committed data file.

selection-gate.md — verdict decision table

Lines ~212–221 (the five-row table in "How a verdict is decided"): the column header reads "and_any rules (if declared)", but none of the five rows covers the case where and_any is absent and all require rules pass. The fifth row's condition "at least one passes" does not straightforwardly apply when there are no and_any rules. Both example gate documents (gate.json, gate-strict.json) omit and_any, making this the primary scenario exercised in the tutorial, yet the table leaves its verdict unspecified.

specs/072-documentation-source-gaps/spec.md — removing planned: true

The removal of planned: true from the establishes unit is consistent with the files being committed in this PR; no defect here.

expected-gate.json / expected-gate-strict.json / run.sh verdict comparison

The jq filter selects only require[*] clauses (select(.clause | test("^require"))); the expected files contain only those clauses and no slices field, matching the filter output. The rejection verdict on require[1] for route-less in both cases correctly names the first definitively failing rule, with require[0] unknown (not failing). No defect.

{"head": "a5b419359584f8765fa18103702a2ec9718350b6", "verdict": "findings", "findings": [{"path": "docs/features/selection-gate/example/run.sh", "line": 51, "severity": "low", "category": "correctness", "summary": "The sed pattern matches compact JSON 'threshold\":\"0.6\"' without a space; if synthetic-example.definition.json is pretty-printed with a space after the colon, the substitution silently fails and both candidate plans are identical to the baseline, causing an opaque verdict-diff failure rather than a clear diagnostic."}, {"path": "docs/features/selection-gate.md", "line": 212, "severity": "low", "category": "correctness", "summary": "The verdict decision table's 'and_any (if declared)' column has no row for the absent-and_any case with all require rules passing, leaving the most common case (used by both gate.json examples) unspecified in the table."}]}

Subject: dc60f26...a5b4193, diff digest aa61058f66c058ade633c4edd0b374dd20fab58053dd062451e30bcee0b409c5, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus had a problem deploying to statecraft-review-exception November 11, 2026 02:02 — with GitHub Actions Error
@github-actions

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff: a new feature doc (selection-gate.md), its worked example files, and an update to spec 072 to drop planned: true from the docs/features/ directory unit and record increment 4.

Checks performed

  • Spec 072 lifecycle change: removing planned: true is correct now that docs/features/ is populated.
  • run.sh: uses set -eu, quotes all paths, validates the data directory before use, checks the work directory for non-existence, and constructs jq patterns from hardcoded strings — no injection surface.
  • Verdict combination table vs. narrative: the "unknown never becomes a pass / definite failure is never hidden" rule is consistent with the table rows.
  • Expected JSON files vs. prose: expected-gate.json and expected-gate-strict.json match the per-candidate verdicts and clause results described in the "What the gate decided" section.
  • gate-strict.json has three require rules; expected-gate-strict.json lists three require[0/1/2] clauses per candidate — consistent.

Finding

In the increment 4 prose added to specs/072-documentation-source-gaps/spec.md (last line of the new block):

The page still keeps the selection documents' field tables by hand until increment 3 publishes their schemas.

Increment 3 is prior to the current increment 4, so the condition "until increment 3 publishes their schemas" names a past increment as a future gate. The intent is plainly to defer until a later increment publishes the schemas; this should reference a future increment (e.g., "a later increment" or a not-yet-numbered one).

{"head": "97bf8a20d5b0ec333f3c899e4ec4b7867450bf43", "verdict": "findings", "findings": [{"path": "specs/072-documentation-source-gaps/spec.md", "line": 243, "severity": "low", "category": "correctness", "summary": "Increment 4 prose says 'until increment 3 publishes their schemas', but increment 3 is already past; this should reference a future increment."}]}

Subject: dc60f26...97bf8a2, diff digest 72887fe7bcba16ed6b220c628b5e181db6e38b89dccfc0b656eaa3a2bdaf6a9a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 11, 2026 02:04 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across the three changed paths: the new documentation page and example directory, and the spec modification.

specs/072-documentation-source-gaps/spec.md

The only change is removing planned: true from the docs/features/ directory unit. This is correct: planned: true signals an establishes claim for content not yet committed; removing it when the content lands is the appropriate lifecycle transition. The increment 4 prose is internally consistent with what the diff adds.

docs/features/selection-gate.md

Verdict logic table vs. examples: route-less has require[0]=unknown and require[1]=fail. The rule says "any fails → rejected, naming the first failing rule." The narrative names require[1] as the clause, which is the first (and only) failing rule. Consistent.

The and_any rows of the verdict table are logically partitioned without gap: row 2 covers "none-fail + all-and_any-fail" (rejected), row 3 covers "none-fail + any-unknown + and_any not-all-failing" (unknown); the edge of require-unknowns with all-and_any-failing falls correctly under row 2 since "anything not all-failing" in row 3 would not apply.

The "Reading the result" JSON block is explicitly labelled abridged (clauses list is not exhaustive); its content matches expected-gate.json's verdicts for route-less and route-more.

The acknowledged gap (selection-gate/1 and selection/1 schemas not yet published; field tables hand-kept until increment 3 merges) is stated clearly and is not a defect introduced by this PR.

run.sh

  • set -eu throughout; no eval; paths are double-quoted.
  • $threshold values are split from hardcoded literals route-more:0.35 / route-less:0.8; no injection surface.
  • The sentinel check (! cmp -s baseline.definition.json "$name.definition.json" || { ... exit 1; }) correctly aborts if sed found no match.
  • || status=$? pattern captures exit code without triggering set -e.
  • The jq filter in check_gate selects only ^require clauses before comparing to expected files, matching how the expected JSON files are structured.
  • Glob expansion "$DATA"/snapshots/*.json produces absolute paths (starting with /) so no risk of argument injection via filenames beginning with -.

Example JSON files

expected-gate.json and expected-gate-strict.json are consistent with their respective gate configs (require index assignments, verdict clauses, regression counts). Three regressions in the strict gate match the narrative (baseline routes 3 of 4; route-less escalates all 4, so sr-m01/02/03 each drop from 1.0→0.0 on acceptance_coverage, exceeding at_most: 0).

No concrete defects found.

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

Subject: dc60f26...b19f785, diff digest 123d9a324c5c08a927f704c7e5a512c9be49a4737a39f065a3ee9b5f58f14f2d, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 11, 2026
…mple

docs/features/selection-gate.md and its example, which compiles the
synthetic example definition, evaluates two threshold variants by replay
and checks both gates' verdicts against committed expected files.
@github-actions

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff: new feature documentation (selection-gate.md), companion example files, and a spec increment update in 072-documentation-source-gaps.

Documentation consistency

The verdict decision table in selection-gate.md matches the expected output files:

  • gate.json has 2 require rules; expected-gate.json shows exactly require[0] and require[1] for each candidate. ✓
  • gate-strict.json has 3 require rules; expected-gate-strict.json shows all three for each candidate. ✓
  • For route-less in both gates, require[0] (error_among_accepted) is unknown (zero denominator — nothing routed) and require[1] is the first fail, which is correctly named as the rejection clause per the "first failing rule" logic. ✓
  • For route-more, all require clauses are pass and the verdict is qualifies. ✓

The numbers in the table (0.75 = 3/4 routed at baseline, 1.0 at route-more, 0.0 at route-less) are internally consistent with the binary threshold logic described. The replay-band-zero claim ("On replay, the band is zero") correctly explains why acceptance_coverage 0.0 vs 0.75 is an immediate fail with no tolerance.

Shell script (run.sh)

  • set -eu is correct for POSIX sh; set -o pipefail is not POSIX-portable and there are no actual pipelines (cmd1 | cmd2) in the main flow — the diff ... || true is a conditional, not a pipeline. No silent failure risk.
  • The sed substitution on JSON is fragile but guarded: ! cmp -s baseline.definition.json "$name.definition.json" exits on no-op, ensuring the threshold was present and replaced.
  • status=0; "$RUSTEV" ... || status=$? correctly captures exit codes, including 11/12.
  • The jq filter that produces *.verdicts.json for cmp only extracts {ranked, unranked, candidates[…require clauses…]}, which correctly strips measured latency fields that differ between runs — matching the structure of both expected files. ✓

Spec change

Removing planned: true from the docs/features/ directory unit is the correct progression: the unit was declared planned in earlier increments, and this increment actually commits the files. The increment 4 description accurately names what is being committed.

Minor note (not a finding)

The example in the "Reading the result" section shows only route-less in candidates. The note "The clauses list is abridged" is there, but the omission of route-more from the example JSON is not explicitly flagged. This is a style gap but not a defect — the section is explicitly labelled hand-kept and the full output is not claimed.

No concrete defects found.

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

Subject: aa1225e...73321bc, diff digest a2edc79e2ea220eedc27c9fbf1f9c35ef8430ba852ea5f03e763ead43bb54a5a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit e31d409 Nov 11, 2026
26 checks passed
@bartekus
bartekus deleted the impl/072-inc4-page branch November 11, 2026 04:08
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