cairn prime: warn on scope-dimension silent-miss#23
Merged
Conversation
Prime() now flags a likely tag-shape mismatch: for each scope-dimension prefix (rig:, role:, agent:) present in the caller's identity, if the store holds entries tagged in that dimension anywhere but none of them survived into the visible set, emit a warning naming the dimension. An empty dimension (nothing in the store to miss) or a genuine non-empty match (working as intended) both stay quiet. The warning fires even when it drives the visible count to zero, since that silent "No cached knowledge" read is the failure mode this exists to catch. Refactored Visible() to split out visibleFrom(entries, identity) so Prime() can walk the store once via IterEntries and derive both the full and visible entry sets from a single pass, instead of a second store walk. Visible()'s external signature and behavior are unchanged.
quad341
enabled auto-merge (squash)
July 22, 2026 18:22
quad341
added a commit
that referenced
this pull request
Jul 22, 2026
…and (#34) * cairn prime: stop telling agents remember doesn't exist (crn-6az.2) prime's footer hardcoded "no `remember` command yet" and told every agent to hand-author `+++`-fenced markdown entries directly. That was correct when it was written (commit 33f1fc1), but commit 571515d added the remember scaffold without updating prime.go, and the crn-419.x stack has since made remember a fully working write path (private tier commits directly, shared tiers route through branch+review) -- not just a scaffold. So prime denied a command that cairn --help lists and that actually works, while telling agents to bypass it via manual file authorship instead. Point the footer at `cairn remember` and defer flag specifics to `cairn remember --help` rather than re-hardcoding them here -- this is the same failure mode that caused the bug (a hand-maintained claim about the CLI surface going stale the moment the surface changed), so the fix shouldn't reintroduce another version of it. Reconciled against PR #23/crn-rbjm (merged to main at 703f58e), which added the scopeMismatchWarnings diagnostic block immediately before this same footer b.WriteString call without touching the footer text itself. The two changes are orthogonal (diagnostic-warnings addition vs. stale-text correction) and combine cleanly: the warnings block is carried over unchanged, and the footer-text fix is re-applied unchanged on top of it. Supersedes the prime.go/prime_test.go content of feature/crn-6az.2 @ ad7f6f0 (reviewed+passed in crn-o6j7, but never landed -- deploy hit a real conflict against the merged PR #23, routed to builder as crn-3b85). TestPrime's "hand-author" assertion is updated to check for "cairn remember" instead. New TestPrimeDoesNotClaimRememberMissing directly covers the bug's own complaint: prime must not claim remember doesn't exist. Mutation- verified: reverting the footer text alone (keeping the updated assertions) makes both tests fail exactly as expected. Did not touch DESIGN.md's CLI (v0) list (also missing remember) or the gc-management pack fragment cairn-usage.md.tmpl (also stale, tells agents remember is "coming soon" -- a different repo, injected fleet-wide into every agent's context). Both out of this bead's stated scope (prime.go only). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * chore: release gate PASS for cairn-prime-remember-footer-fix Bead: crn-ilu8. All 7 criteria PASS, independently re-verified in an isolated worktree (build/vet/gofmt/lint/test-race clean, mutation-tested). Zero divergence from main. --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Closed
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cairn primenow catches a specific silent-failure mode: an agent whoseidentity includes a
rig:,role:, oragent:tag, querying a store thatdoes hold entries tagged in that dimension, but where none of them match —
usually because of a tag-shape mismatch (e.g.
rig:webvsrig=web, or atypo). Previously this just produced a low or empty entry count with no
signal that anything was wrong. Now
primeappends a warning naming thedimension, e.g.:
The warning only fires when the store has entries in that dimension but the
match came up empty — a dimension with nothing in the store at all, or a
genuine non-empty match, stays quiet. It fires even when it drives the
visible count to zero, since that's exactly the case it exists to catch.
Why built this way
Prime()previously calledVisible()and only saw the filtered result, soit had no way to tell "nothing to find" apart from "found nothing, but
something was there and didn't match." The fix pulls the full unfiltered
entry set (
IterEntries) once, derives the visible subset from it in-process(
visibleFrom, factored out ofVisible()), and compares the two —one store walk instead of two, and
Visible()'s own external signature andbehavior are unchanged.
Review notes
change to
Visible()or any other command.visibleFrom,scopeMismatchWarnings, andanyTagWithPrefixare newinternal helpers in
internal/cairn/prime.go;internal/cairn/entry.gogained a small supporting change.
Test plan
go build ./...,go vet ./...,gofmt -l .cleango test ./... -race -count=1— zero regressions acrosscmd,internal/cairn,internal/criticgolangci-lint run ./...— 0 issuesrelease-gates/cairn-prime-scope-mismatch-diagnostic-gate.md