From 21536a024b0e84e05f8cf2943bb73c2ad18b4377 Mon Sep 17 00:00:00 2001 From: cairn-reviewer-scratch Date: Thu, 20 Aug 2026 02:45:58 -0700 Subject: [PATCH 1/3] =?UTF-8?q?test(cairn):=20red=20=E2=80=94=20cairn=20li?= =?UTF-8?q?brarian:=20file=20a=20bead=20for=20status=3Derror=20stale-branc?= =?UTF-8?q?h=20findings=20too,=20not=20only=20escalate=20(refs=20crn-4j0pa?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formulas/formulas_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/formulas/formulas_test.go b/formulas/formulas_test.go index c277984..b25df5a 100644 --- a/formulas/formulas_test.go +++ b/formulas/formulas_test.go @@ -228,6 +228,38 @@ func TestLibrarianStaleReviewBranchRecoveryStepHasNeedsInvestigationLabelAndGuar } } +// crn-4j0pa: "cairn stale-branches" reports status=error findings (a reviewer +// lookup failure, or ListReviewBranches itself erroring on that branch) with +// the same shape as escalate findings except .reviewer is always empty and +// .error carries the failure text (cmd/branches.go's evaluateBranch never +// sets both). Before this fix the step's jq filter selected only +// status=="escalate", so error findings -- arguably the ones most in need of +// a human's attention, since cairn itself couldn't even evaluate the branch +// -- were silently dropped every cycle instead of filed. +func TestLibrarianStaleReviewBranchRecoveryStepHandlesErrorStatus(t *testing.T) { + f := decodeFormula(t, "mol-cairn-librarian.formula.toml") + s, ok := stepByID(f, "stale-review-branch-recovery") + if !ok { + t.Fatal(`mol-cairn-librarian.formula.toml: no "stale-review-branch-recovery" step found`) + } + + if !strings.Contains(s.Description, `select(.status == "escalate" or .status == "error")`) { + t.Error(`stale-review-branch-recovery: jq filter must widen to select(.status == "escalate" or .status == "error"), or error-status findings are silently dropped and never filed (crn-4j0pa)`) + } + if !strings.Contains(s.Description, `jq -r '.error // empty'`) { + t.Error(`stale-review-branch-recovery: must extract the finding's .error field (error findings have no .reviewer), or the filed bead's body cannot explain what cairn stale-branches itself failed on (crn-4j0pa)`) + } + + notifyIdx := strings.Index(s.Description, `A reminder mail was already sent to`) + guardIdx := strings.Index(s.Description, `if [ -n "$REVIEWER" ]`) + if notifyIdx == -1 { + t.Fatal(`stale-review-branch-recovery: "A reminder mail was already sent to" sentence not found`) + } + if guardIdx == -1 || guardIdx > notifyIdx { + t.Error(`stale-review-branch-recovery: the "A reminder mail was already sent to $REVIEWER" sentence must be guarded behind a non-null-reviewer check (if [ -n "$REVIEWER" ]) placed before it, or error findings (no .reviewer) render "sent to " -- the crn-w4c6-shaped defect this must not reintroduce (crn-4j0pa)`) + } +} + // cairn cull-evict itself is not safely repeatable for the same entry -- // EvictToReviewBranch hard-errors once a proposal is already pending, since // its review branch name is deterministic ("cull/" + entry ID; see From cacda2f2e3eff9455344abf81a33b4a59aaf17bc Mon Sep 17 00:00:00 2001 From: cairn-reviewer-scratch Date: Thu, 20 Aug 2026 02:47:41 -0700 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20green=20=E2=80=94=20cairn=20librari?= =?UTF-8?q?an:=20file=20a=20bead=20for=20status=3Derror=20stale-branch=20f?= =?UTF-8?q?indings=20too,=20not=20only=20escalate=20(refs=20crn-4j0pa)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- formulas/mol-cairn-librarian-rig.formula.toml | 39 +++++++++++++++---- formulas/mol-cairn-librarian.formula.toml | 39 +++++++++++++++---- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/formulas/mol-cairn-librarian-rig.formula.toml b/formulas/mol-cairn-librarian-rig.formula.toml index 2c1f303..879863c 100644 --- a/formulas/mol-cairn-librarian-rig.formula.toml +++ b/formulas/mol-cairn-librarian-rig.formula.toml @@ -90,7 +90,8 @@ pass to pass; if it's instead re-cloned fresh every sweep tick, add ENTRY_ID=$(printf '%s' "$finding" | jq -r '.entry_id') TIER=$(printf '%s' "$finding" | jq -r '.tier') AGE_SECONDS=$(printf '%s' "$finding" | jq -r '.age_seconds') - REVIEWER=$(printf '%s' "$finding" | jq -r '.reviewer') + REVIEWER=$(printf '%s' "$finding" | jq -r '.reviewer // empty') + ERROR_TEXT=$(printf '%s' "$finding" | jq -r '.error // empty') EXISTING=$(bd list --label=dim:review-branch,source:cairn-librarian \ --title-contains="on $BRANCH (" --json --no-pager 2>/dev/null | jq -r '.[0].id // empty') @@ -101,20 +102,42 @@ pass to pass; if it's instead re-cloned fresh every sweep tick, add continue fi + # crn-4j0pa: an error-status finding (cairn itself failed to resolve a + # reviewer, or ListReviewBranches errored) never carries .reviewer -- + # cmd/branches.go's evaluateBranch sets exactly one of the two. Guard the + # reviewer-was-already-notified sentence on it instead of interpolating + # unconditionally, or this renders "sent to " for every error finding + # (the crn-w4c6-shaped defect). + if [ -n "$REVIEWER" ]; then + NOTIFY_LINE="A reminder mail was already sent to $REVIEWER on an earlier +cairn stale-branches pass at this same commit, and it is now past the +escalate threshold with no merge and no new commit since." + RESOLVER="$REVIEWER (or another reviewer)" + else + NOTIFY_LINE="cairn stale-branches could not evaluate this branch normally (see error below), so no automatic reviewer reminder was possible." + RESOLVER="a reviewer" + fi + + ERROR_LINE="" + if [ -n "$ERROR_TEXT" ]; then + ERROR_LINE=" + +cairn stale-branches reported an error while evaluating this branch: +$ERROR_TEXT" + fi + NEW_ID=$(bd create \ --title="cairn librarian: stale review branch on $BRANCH ($TIER)" \ --stdin --type=task --priority=3 \ --labels=dim:review-branch,source:cairn-librarian,needs-pm,needs-investigation --silent </dev/null | jq -r '.[0].id // empty') @@ -110,20 +111,42 @@ pass to pass; if it's instead re-cloned fresh every sweep tick, add continue fi + # crn-4j0pa: an error-status finding (cairn itself failed to resolve a + # reviewer, or ListReviewBranches errored) never carries .reviewer -- + # cmd/branches.go's evaluateBranch sets exactly one of the two. Guard the + # reviewer-was-already-notified sentence on it instead of interpolating + # unconditionally, or this renders "sent to " for every error finding + # (the crn-w4c6-shaped defect). + if [ -n "$REVIEWER" ]; then + NOTIFY_LINE="A reminder mail was already sent to $REVIEWER on an earlier +cairn stale-branches pass at this same commit, and it is now past the +escalate threshold with no merge and no new commit since." + RESOLVER="$REVIEWER (or another reviewer)" + else + NOTIFY_LINE="cairn stale-branches could not evaluate this branch normally (see error below), so no automatic reviewer reminder was possible." + RESOLVER="a reviewer" + fi + + ERROR_LINE="" + if [ -n "$ERROR_TEXT" ]; then + ERROR_LINE=" + +cairn stale-branches reported an error while evaluating this branch: +$ERROR_TEXT" + fi + NEW_ID=$(bd create \ --title="cairn librarian: stale review branch on $BRANCH ($TIER)" \ --stdin --type=task --priority=3 \ --labels=dim:review-branch,source:cairn-librarian,needs-pm,needs-investigation --silent < Date: Thu, 20 Aug 2026 10:19:19 -0700 Subject: [PATCH 3/3] chore: release gate PASS for crn-kq7tz (librarian stale-branch status=error handling) --- release-gates/crn-kq7tz-gate.md | 77 +++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 release-gates/crn-kq7tz-gate.md diff --git a/release-gates/crn-kq7tz-gate.md b/release-gates/crn-kq7tz-gate.md new file mode 100644 index 0000000..54255f3 --- /dev/null +++ b/release-gates/crn-kq7tz-gate.md @@ -0,0 +1,77 @@ +# Release Gate: crn-kq7tz + +**Bead:** crn-kq7tz (deploy) — source: crn-lhchy (review), build: crn-4j0pa (plan: crn-zg69q) +**Reviewed commit:** `cacda2f2e3eff9455344abf81a33b4a59aaf17bc` (matches crn-lhchy's verdict and the deploy bead's `metadata.gc.deploy_commit` — see criterion 1) +**Deploy commit:** `cacda2f2e3eff9455344abf81a33b4a59aaf17bc` — no self-rebase needed, criterion 6 merge-tree came back clean directly +**Date:** 2026-08-20 + +## Background + +`cairn stale-branches` reports two distinct finding shapes on the same +review-branch check: `status == "escalate"` (a reviewer exists but hasn't +acted) and `status == "error"` (cairn itself failed to evaluate the branch — +a reviewer-lookup failure, or `ListReviewBranches` erroring). `evaluateBranch` +sets exactly one of `.reviewer` / `.error`, never both. The +`stale-review-branch-recovery` step's jq filter selected only +`status=="escalate"`, so error-status findings — arguably the ones most +needing a human's attention, since cairn couldn't even evaluate the branch — +were silently dropped every sweep cycle instead of filed. + +The fix widens the filter to `select(.status == "escalate" or .status == +"error")` in both `formulas/mol-cairn-librarian.formula.toml` and +`formulas/mol-cairn-librarian-rig.formula.toml`, adds `ERROR_TEXT` extraction +(`.error // empty`) included in the filed bead body when present, and guards +the "reminder mail already sent to $REVIEWER" sentence behind a +non-null-`$REVIEWER` check (error findings never carry `.reviewer`) — avoiding +a crn-w4c6-shaped "sent to " defect on error findings. + +## Criteria + +| # | Criterion | Result | Evidence | +|---|-----------|--------|----------| +| 1 | Review PASS for exact deployed commit | PASS | crn-lhchy's verdict cites `cacda2f2e3eff9455344abf81a33b4a59aaf17bc`, identical to the deploy bead's `metadata.gc.deploy_commit` — exact SHA match (D = R). Independently re-resolved via `git rev-parse --verify --quiet "^{commit}"`, not trusted as a transcribed string. | +| 2 | Acceptance criteria met | PASS | Verified directly against crn-4j0pa's full `exit_contract` (5 bullets). Read the actual diff, not just builder/reviewer prose: confirmed jq filter widened in both formula files, `ERROR_TEXT` extraction present, `NOTIFY_LINE`/`RESOLVER` branching guards the reminder sentence on `[ -n "$REVIEWER" ]` in both files identically. Sequencing precondition crn-nc9te (6b45121, PR #126) independently confirmed reachable from origin/main via `git merge-base --is-ancestor` (also visible directly in `git log origin/main`). | +| 3 | Tests pass | PASS | Independently re-run at the deploy commit (detached checkout, clean tree). Pre-flight: this repo's suite has no container/testcontainers dependency (`grep -rl testcontainers\|DOCKER_HOST` empty), so the podman setup step is not applicable here. `go build ./...` exit 0; `go vet ./...` exit 0; `go test ./... -race -count=1` — **7/7 packages ok** (`.`, `cmd`, `formulas`, `internal/cairn`, `internal/critic`, `internal/obslog`, `scripts`), 0 FAIL, 0 SKIP. Diff-owned test mapped by exact name: `TestLibrarianStaleReviewBranchRecoveryStepHandlesErrorStatus` re-run individually (`-run '^...$' -v`) — PASS. 3a (attribute failing tests) not applicable, zero failures anywhere. 3b (policy/lint lane): this repo's only policy lane is the CI `lint` job itself (`golangci-lint run ./...` — confirmed via `.github/workflows/ci.yml`; no separate `ci-pr-policy`-style Makefile target exists here, `Makefile` targets are only `all/build/formulas/test/install/fmt/fmt-check/clean/help`). Run with an isolated `GOLANGCI_LINT_CACHE` (avoiding known cross-session cache contamination on this machine): `golangci-lint run ./...` — 0 issues; `golangci-lint fmt -d ./...` exit 0, no diff; `gofmt -l .` empty. | +| 4 | No open HIGH findings | PASS | crn-lhchy records **no blocking findings** ("No blocking findings. Handing off to deployer."). No open HIGH/blocking finding anywhere in the chain. | +| 5 | Clean tree | PASS | Verified via direct detached checkout of `cacda2f2e3eff9455344abf81a33b4a59aaf17bc^{commit}`; `git status --porcelain` empty. | +| 6 | Clean divergence from main | PASS | `git merge-tree --write-tree origin/main cacda2f2e3eff9455344abf81a33b4a59aaf17bc` → clean merge tree `4b1a3794db0e1c91c0d157a6b967b0f366ff5b49`, exit 0, zero conflicts — **no self-rebase needed**. `origin/main` has advanced by exactly one commit since this branch's fork point (`93c2593`) — the crn-bmy54 merge (`a7f9cdc`, PR #131) — and it does not touch either formula file this diff owns, so the merge stays conflict-free without rebasing. Pre-flight (has the target already merged?): `gh api repos/quad341/cairn/commits/cacda2f2e.../pulls` returned empty — no PR exists for this SHA — and `git merge-base --is-ancestor cacda2f2e... origin/main` confirmed it is NOT already on main. Normal flow applies. | +| 7 | Single feature theme | PASS | `git diff origin/main...cacda2f2e3eff9455344abf81a33b4a59aaf17bc --stat` (correct triple-dot form, symmetric-difference from the merge-base — a plain two-dot diff against current `origin/main` is misleading here since main advanced past the branch's fork point and a two-dot diff spuriously shows those advances "reverted") → exactly 3 files: `formulas/formulas_test.go` (+32), `formulas/mol-cairn-librarian-rig.formula.toml`, `formulas/mol-cairn-librarian.formula.toml` — 94 insertions, 16 deletions, all tightly related to the single fix. Out-of-scope paths (`packs/cairn-loop-orders/orders/cairn-librarian-rig-cooldown.toml`, `TestLibrarianStepsHaveNeedsPmLabelAndGuard`) confirmed untouched. | + +## Verdict: PASS — proceeding to PR. + +## Process notes + +1. **Merge authority — self-merge authorized under the reinstated standing + authorization.** Same basis as `release-gates/crn-bmy54-gate.md` note 1: + mayor ruling `gm-wisp-2yhv7u` (2026-08-19) reinstated deployer self-merge + for quad341/cairn (not covered by `mpr`), and explicitly instructs future + sessions not to re-pause on a bare repeat of the generic "route to + mayor/mpr" boilerplate carried in this formula's own step text. crn-kq7tz's + notes raise nothing beyond that same recycled clause. Proceeding under the + STANDING AUTHORIZATION subject to the reinstatement's four conditions: (1) + gate 7/7 PASS — this table; (2) PR state confirmed via a direct, fresh `gh + pr view --json` read at merge time; (3) CLEAN/MERGEABLE with both required + checks (`build-test`, `lint`) COMPLETED/SUCCESS; (4) no `--auto` arm — + plain `gh pr merge --squash --delete-branch` only (per mayor's + `gm-wisp-fvdoja` addendum), then independently verified. + +2. **Pre-flight (target-already-merged check) run before criterion 6**, per + the formula's own ordering requirement (ga-xykek3 incident). No PR existed + for the deploy SHA and it is not yet an ancestor of `origin/main` — normal + flow, not reconciliation. + +3. **SHA integrity:** the deploy commit was independently re-resolved via + `git rev-parse --verify --quiet "^{commit}"` on both the D (deploy + bead metadata) and R (review bead metadata) sides before comparison, never + trusted as an eyeballed or transcribed string. + +4. **Two-dot vs. triple-dot diff pitfall (recorded for future gate + sessions):** a first pass at criterion 7 used `git diff origin/main + cacda2f2e...` (two-dot) and produced an alarming diffstat showing large + deletions across unrelated files (`internal/cairn/entry.go`, + `release-gates/crn-bmy54-gate.md`, etc.) — these were `origin/main`'s own + advances past this branch's fork point being spuriously shown as + "reverted," not real changes in this diff. Re-run with the triple-dot form + (`origin/main...cacda2f2e...`, symmetric difference from the merge-base) + immediately resolved to the correct, narrow 3-file diffstat matching the + reviewer's own count. Worth a formula-text callout if this recurs.