LearnNewsExamplesServices
Frontmatter
id11347
titleLayer 3 of 4-layer PR-base defense: pr-review Cycle-0 baseRef verification gate
stateClosed
labels
documentationenhancementaiarchitecturemodel-experience
assigneesneo-opus-4-7
createdAtMay 14, 2026, 9:08 AM
updatedAtMay 14, 2026, 1:09 PM
githubUrlhttps://github.com/neomjs/neo/issues/11347
authorneo-opus-4-7
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMay 14, 2026, 1:09 PM

Layer 3 of 4-layer PR-base defense: pr-review Cycle-0 baseRef verification gate

Closeddocumentationenhancementaiarchitecturemodel-experience
neo-opus-4-7
neo-opus-4-7 commented on May 14, 2026, 9:08 AM

Context

Closes the reviewer-side discipline gap in the 4-layer PR-base defense (Layers 1 + 4 LIVE; Layer 2 still open):

Layer Mechanism State
1 §0 invariant elevation (always-loaded) LIVE via #11337 / PR #11339
2 Workflow discipline strengthening OPEN for pickup
3 pr-review Cycle-0 baseRef gate (reviewer-side mechanical) THIS ticket
4 Mechanical CI/MCP guard (machine-enforceable backstop) LIVE via #11336 / PR #11340

Empirical anchor: PR #11335 base=main blowup (2026-05-13T21:38Z; operator-caught). I was the primary reviewer and missed the baseRefName verification at Cycle 1 review-start, rationalizing the 990K-line diff as "stale-branch" while the actual root cause was the catastrophic base-branch misconfiguration. Saved as feedback_pr_review_base_branch_verification memory (private). The 4-layer defense converged on the architectural framing, but the reviewer-side Cycle-0 mechanical gate was deferred for separate ticket — this is that ticket.

The Problem

Current pr-review-guide.md §9.0 Premise Pre-Flight + §5.x audits structure REQUIRES reviewer to dive into substantive scope before mechanical pre-flight. When PR diff is much larger than the stated scope (e.g., +990K lines for a feature PR claiming ~106 lines), the reviewer's natural impulse is to investigate "why so big?" via substantive diff inspection FIRST. This is precisely when wrong-base misconfiguration gets rationalized as something else (stale-branch, force-push noise, etc.).

The Cycle-0 mechanical gate fires BEFORE §9.0 Premise Pre-Flight: the reviewer MUST run the 3-command base/merge-base/divergence check IF the PR scope claim doesn't match observed size. ONLY AFTER base + merge-base + divergence verified, dive into substantive code review.

The Fix

Substrate-Additive via Recursive Application pattern (per #11324 / Discussion #11314 sub-rule sibling discipline):

  1. New sub-rule sibling file: .agents/skills/pr-review/audits/base-branch-verification.md (~40-60 lines)

    • The 3-command check (gh pr view --json baseRefName,headRefName, git merge-base <head> origin/dev, git rev-list --count origin/main..origin/dev)
    • Trigger conditions (diff size >> expected scope; PR title says "small change" but diff is huge)
    • Drop+Supersede framing when base=main on feature PR
    • Empirical anchor: PR #11335 stale-branch rationalization
  2. 1-line trigger pointer in pr-review-guide.md (~100 char addition):

       <!-- trigger: PR diff size >> stated scope OR baseRefName uncertain → read ./audits/base-branch-verification.md -->

    Insertion point: BEFORE §9.0 Premise Pre-Flight (Cycle-0 gate fires first).

  3. pr-review-template.md checkbox (+1 line):

    • Add to existing Cycle-1 sections: - [ ] §5.x Base-Branch Verification: baseRefName + merge-base verified before substantive review

Substrate Budget Impact

Surface Delta Conditionally-loaded?
.agents/skills/pr-review/audits/base-branch-verification.md +~40-60 lines (~2-3 KB) Yes — only loads when trigger fires
.agents/skills/pr-review/references/pr-review-guide.md +1 line (~100 bytes) Yes — already conditionally-loaded
.agents/skills/pr-review/assets/pr-review-template.md +1 line (~80 bytes) Yes — already conditionally-loaded

No always-loaded substrate touched. No AGENTS.md / AGENTS_STARTUP.md / AGENTS_ATLAS.md mutation. Per friction → gold asymmetric ratchet discipline (feedback_friction_to_gold_asymmetric_ratchet): substrate-addition justified by net preventive value — would have caught PR #11335 base=main in <1 min at Cycle-0 vs the ~20-min substantive-review-then-correction cycle.

Acceptance Criteria

  • New file .agents/skills/pr-review/audits/base-branch-verification.md created with 3-command check + trigger conditions + Drop+Supersede framing + PR #11335 empirical anchor
  • pr-review-guide.md augmented with 1-line trigger pointer BEFORE §9.0 Premise Pre-Flight
  • pr-review-template.md augmented with 1-line Cycle-1 checkbox for base-branch verification
  • Skill manifest entries updated (.agents/skills/skills.manifest.json if perFilePayloadBudget tracking needs adjustment)
  • PR body cites this ticket + feedback_pr_review_base_branch_verification rationale + PR #11335 empirical anchor + measurement contract (catch the next wrong-base PR in <1 min Cycle-0)
  • git diff --check passes
  • Skill manifest lint passes (node ai/scripts/lint-skill-manifest.mjs --base origin/dev)

Out of Scope

  • Layer 2 (workflow discipline strengthening) — separate ticket
  • 5th layer / "ticket already has APPROVED PR" duplicate-resolution detector — separate ticket
  • Modifying §0 invariants — not in scope; Layer 1 (#11337/PR #11339) already covers always-loaded prose
  • Mechanical CI gate — covered by Layer 4 (#11336/PR #11340)

Avoided Traps

  • Bloating pr-review-guide.md monolith — at 57K already; per Recursive Application pattern, new gate goes in sub-rule sibling file + trigger pointer
  • Always-loaded substrate addition — Layer 3 is reviewer-side discipline; lives in skill payload, not AGENTS.md
  • Cycle-1 substantive-review-before-mechanical-gate order — current §9.0 fires first; new gate fires BEFORE §9.0 as Cycle-0 mechanical pre-flight
  • Rule-card demotion — not applicable here; new substrate is multi-step discipline content, not single-rule prose

Related

  • Discussion #11341 (graduated) — 4-layer defense framing
  • #11337 / PR #11339 — Layer 1 (LIVE)
  • #11336 / PR #11340 — Layer 4 (LIVE)
  • PR #11335 — empirical anchor: my Cycle 1 miss + Drop+Supersede + collision-trigger
  • #11324 / PR #11343 — Recursive Application sub-rule sibling pattern precedent + INV1 cascade demotion sister-pilot
  • feedback_pr_review_base_branch_verification — private feedback memory anchoring discipline
  • feedback_friction_to_gold_asymmetric_ratchet — substrate-budget justification frame

Origin Session ID: 46c1f1f9-c521-4b71-85fa-f7cc5c7531ee

🤖 Authored by @neo-opus-4-7 — Layer 3 closure of the 4-layer PR-base defense started by Discussion #11341 graduation arc. Continuing on-lane per operator direction 2026-05-14T07:06Z.