Propagate + audit the P6 /kg-discovery reflex into existing workspaces (BRO-1555)#79
Conversation
…RO-1555) Two propagation gaps: BRO-1426 added the §P6 "/kg for discovery, never substrate grep" retrieval reflex to the AGENTS.md template, but existing workspaces never received it — scaffold_governance_file is idempotent-never-overwrite, and repair.sh only backfilled the Development Philosophy section. doctor never checked AGENTS.md actually carried the reflex either. - repair.sh: backfill_retrieval_discipline() backfills the §P6 retrieval paragraph into an existing AGENTS.md — idempotent (skip if present), anchored (§P6 → next heading; skip with warning if absent), file-only awk extraction (no shell interpolation of content, backticks/pipes survive). Flag-clear (not awk `exit`) on the boundary so tr|awk doesn't SIGPIPE under pipefail. Mirrors backfill_philosophy_section; registered next to it. - doctor.sh §4c: advisory check that AGENTS.md carries the reflex. Informational only — never a GAP, never fails --strict (mirrors §4b convention). Proven gap-neutral + strict-neutral by test. - Marker is the coined phrase "substrate grep" (not the full "never substrate grep") so a workspace carrying the reflex under DIFFERENT wording — e.g. this workspace's hand-authored "not a substrate grep" variant — is detected as present and NOT duplicated. Verified: doctor reports [ok] + repair won't duplicate on the real workspace. Tests: tests/retrieval-discipline-backfill.test.sh (16 assertions) — backfill + idempotency + position-inside-§P6 + verbatim content + --dry-run + missing-anchor skip + §4c advisory both directions + gap/strict-neutral + CRLF. Sibling philosophy-backfill + all 5 canary suites still green. BRO-1555 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 47 minutes and 44 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a new AGENTS.md retrieval-discipline backfill in ChangesAGENTS.md retrieval-discipline reflex
Sequence Diagram(s)sequenceDiagram
participant Repair as "scripts/repair.sh"
participant Template as "AGENTS.md.template"
participant Target as "AGENTS.md"
Repair->>Template: extract Retrieval discipline paragraph
Repair->>Target: verify P6/P7 anchors and existing marker
Repair->>Target: insert paragraph into P6 and replace file
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…lex (P20 review) Cross-review [MAJOR]: the "substrate grep" phrase marker only guards variants that RETAIN the phrase; a reflex reworded to drop it (e.g. "never grep the substrate directly") was not detected → backfill appended a second paragraph. - repair.sh: add a structural guard — also treat `^**Retrieval discipline` as present (the reflex's bold-lead signature), so a phrase-dropping reword isn't duplicated. Comment scoped to the true guarantee. - doctor.sh §4c: match the same two signals (phrase OR `**Retrieval discipline` lead) so doctor + repair agree on "present" (doctor won't tell the user to run repair when repair would correctly skip). - test: +Test 4b — a reworded reflex (drops the phrase, keeps the lead) is not duplicated by --apply-all. 17 assertions, all green. BRO-1555 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Review fixes pushed ( [MAJOR] reworded-reflex duplication — resolved. Added a structural guard: repair now also treats [MINOR] decoy/nested [NIT] interactive path — |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/retrieval-discipline-backfill.test.sh`:
- Around line 186-189: The reworded-doctor verification in
retrieval-discipline-backfill.test.sh is currently a no-op because it only
enters a placeholder branch when grep matches, so failures in doctor.sh
recognition are never asserted. Update the check around the doctor invocation to
use a real assertion tied to the existing doctor.sh and grep -q "has P6
retrieval-discipline reflex" logic, so the test fails when the reworded
**Retrieval discipline variant is not recognized and only passes when the
expected output is present.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ddd2094c-7ca8-4881-804b-44089519658a
📒 Files selected for processing (3)
scripts/doctor.shscripts/repair.shtests/retrieval-discipline-backfill.test.sh
…t) + pipefail fix CodeRabbit: Test 4b's doctor-consistency check was a silent no-op (`: # skip`). Turned it into a real assertion that doctor §4c recognizes the reworded (phrase-less) reflex. Surfaced a test-harness bug: `doctor | grep -q` under `set -o pipefail` returns doctor's exit (non-zero on a gappy fixture), not grep's — capture the output to a var first, then grep (the pattern Test 5 uses). Verified non-vacuous by mutation: removing doctor's structural OR-clause makes Test 4b fail; restoring passes. 18/18 green. BRO-1555 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Fixed in |
Why
Auditing "does installing bstack update agent rules to use
/kg" surfaced two propagation gaps. BRO-1426 added the §P6 "/kg for discovery, never substrate grep" retrieval reflex to the AGENTS.md template — but:repairnever backfilled it.scaffold_governance_fileis idempotent-never-overwrite (existing AGENTS.md preserved), andrepair.shonly backfilled the Development Philosophy section. A workspace bootstrapped before BRO-1426 never got the reflex.doctornever audited it. §6 checked catalog freshness + that/kgis installed, but never that AGENTS.md contains the reflex.Change
repair.shbackfill_retrieval_discipline()— backfills the §P6 paragraph into an existing AGENTS.md. Idempotent (skip if present), anchored (§P6 → next heading; warn+skip if absent), file-only awk extraction (content never shell-interpolated, backticks/pipes survive). Mirrorsbackfill_philosophy_section; registered beside it. (Uses flag-clear, not awkexit, on the boundary — avoids thetr|awkSIGPIPE-under-pipefail trap the philosophy code documents.)doctor.sh§4c — advisory:[ok]when present,[info]+ backfill hint when absent. Never a GAP, never fails--strict(mirrors §4b). Proven gap-neutral + strict-neutral by test.Robust marker
Detection uses the coined phrase
substrate grep(not the full "never substrate grep"), so a workspace carrying the reflex under different wording — e.g. this workspace's hand-authored "not a substrate grep" variant — is detected as present and not duplicated. Verified on the real workspace: doctor →[ok], repair dry-run → no backfill (no dup).substrate grepappears only in the reflex (1× in template).Tests
tests/retrieval-discipline-backfill.test.sh— 16 assertions: backfill + idempotency + position-inside-§P6 + verbatim content +--dry-runwrites-nothing + missing-anchor skip + §4c advisory both directions + GAP/--strictneutrality + CRLF tolerance. Siblingphilosophy-backfill(17) + all 5 canary suites green. shellcheck -S error clean.Scope
broomva/bstackonly. No primitive-count / doctor-integer-section change (sub-rule + advisory subsection). The workspace's own AGENTS.md already carries the reflex (BRO-1426 lockstep) — this is purely propagation-to-other/existing-workspaces + audit.Closes BRO-1555
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes