← Back to Pull requests

docs(contracts): machine triggers for defect-shape blocks and verification rules (refs #5753) #5754

Open
unknown opened this pull request with 555 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 22, 2026 20:06 UTC
Author

Summary

Every <important if="…"> block in docs/defect-shapes.md now carries a machine trigger line (path globs and/or a diff regex), and a governance test refuses a block without a readable one. The contract lines for items 3 to 6 of #5753 land where each role reads its rules. Refs #5753.

Notes for the reviewer

  • Rival interface, considered before the first edit: trigger attributes on the <important> tag against a JSON comment line directly after the opener. The comment wins: agents-governance.test.ts anchors ^<important if="[^"]">$, so attributes would loosen an anchored guard and need escaped quotes; the comment leaves the opener alone and parses with one regex plus JSON.parse.

  • Semantics, stated in the catalog intro: paths or diff (a regex over each added line) applies the block when either matches; {"always": true} applies it to every change. Globs come from the files each block's shapes name, not from titles. Block 3 also matches catch because shapes 31 and 75 govern any runtime catch.

  • Net-count: the test extends the existing #3259 trigger-governance describe; no new file, hook or ratchet. It admits always alone or paths/diff, and refuses an unknown key and a glob that matches no file.

  • Contract lines: item 3 in the reviewer's Standing probes and the merge policy's tier rule; items 4 and 6 in AGENTS.md; item 5 in the fixer's Evidence. AGENTS.md carries no issue number there: its reference ceiling (55) is full.

  • Remainder on #5753: item 2, and the script halves of items 1, 3 and 4 (orchestrator tooling).
  • Change outline

    - docs/defect-shapes.md: intro sentence + 7 trigger lines (openers unchanged)
    - tests/config/agents-governance.test.ts: + triggerProblems(line), two cases
    - docs/pi-lens-{reviewer,merge-policy,fixer}.md, AGENTS.md: one short rule each
    

    Proof and checks

    Tests

    Failure list, written first: no trigger line; bad JSON; unknown key; always not alone or not true; none of paths, diff, always; empty paths; dead glob; non-compiling diff.

    Red-first, tests/config/agents-governance.test.ts on master's docs/defect-shapes.md:

    tests/config/agents-governance.test.ts
     × gives every catalog block a machine-readable trigger line (#5753)
    AssertionError: expected [ …(7) ] to deeply equal []
    +   "line 13 (<important if=\"touching a path key or path spelling\">): no `<!-- trigger: {...} -->` line directly after the opener",
    +   ... six more, lines 93, 174, 340, 543, 799, 948
     Test Files  1 failed (1)
          Tests  1 failed | 10 passed (11)
    

    Green: that file 11 passed; with four sibling governance files 102 passed. gov-check.sh exit 0: Test Files 226 passed;Tests 4730 passed | 5 skipped. CI must confirm the full Unit tests lane.

    Mutations

    | mutation | result |
    | --- | --- |
    | docs: glob misspelled | 1 failed: glob matches no file |
    | docs: leading quote dropped from JSON | 1 failed: JSON does not parse |
    | docs: key renamed from paths to path | 1 failed: unknown trigger key |
    | docs: always set to "yes" | 1 failed: always is true alone |
    | docs: unbalanced paren in a diff | 1 failed: does not compile |
    | test: dead-glob check off | 1 failed: planted-line case |
    | test: unknown-key check off | 1 failed: planted-line case |
    | test: empty paths allowed | 1 failed: planted-line case |

    Class sweep

    Class: a loaded block with no machine trigger. grep -rlE '<important if=' --include=.md . finds the catalog (fixed here) plus AGENTS.md (14 blocks), docs/invariants/*.md (6 files) and docs/pi-lens-release.md (1). Stay specific: #5753 item 1 scopes the catalog, the host loads AGENTS.md whole, and the other blocks need globs derived from their own entries. The orchestrator decides whether to extend the gate.

    Alignment: none: docs and a governance test touch no tool family.

    Observability

    none: contract prose and a test-only gate; no runtime failure path.

    Fold check

    None has its acceptance met here, so none is folded:

  • #5316 not folded: bot scores untouched.

  • #5315 not folded: triggers feed the risk map, which is not built.

  • #5004 not folded: no verbosity pass.

  • #4364 not folded: no fixer-lane eval added.

  • #4361 not folded: adds rules, no audit of AGENTS.md.

  • #3815 not folded: a different seam, the ownership map.

  • #3260 not folded: no ADR added.

  • #3259 not folded: no glossary term added.
  • 🤖 Generated with Claude Code

    Diff: 555 lines (+416 / -139) across 6 files Reviewer: coderabbitai[bot] Review duration: 5m
    All Vouch review confidence checks passed
    Residual risk 0.35 = Change Risk (0.48) × (1 − Review Confidence (0.26)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 555 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 37% · Reviewer familiarity: 35%
    26%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.378
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #5754"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 26.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 26.5% · Lower = rushed or shallow review
    26.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 35.4% · Moderate risk
    35.4%