Skip to content

cairn prime: warn on scope-dimension silent-miss#23

Merged
quad341 merged 3 commits into
mainfrom
deploy/crn-rbjm-gate
Jul 22, 2026
Merged

cairn prime: warn on scope-dimension silent-miss#23
quad341 merged 3 commits into
mainfrom
deploy/crn-rbjm-gate

Conversation

@quad341

@quad341 quad341 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

cairn prime now catches a specific silent-failure mode: an agent whose
identity includes a rig:, role:, or agent: tag, querying a store that
does hold entries tagged in that dimension, but where none of them match —
usually because of a tag-shape mismatch (e.g. rig:web vs rig=web, or a
typo). Previously this just produced a low or empty entry count with no
signal that anything was wrong. Now prime appends a warning naming the
dimension, e.g.:

warning: your identity has a rig: tag, and the store has rig-scoped
entries, but none matched you -- check for a tag-shape mismatch

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 called Visible() and only saw the filtered result, so
it 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 of Visible()), and compares the two —
one store walk instead of two, and Visible()'s own external signature and
behavior are unchanged.

Review notes

  • New surface is warning text only — no new flags, no config, no behavior
    change to Visible() or any other command.
  • visibleFrom, scopeMismatchWarnings, and anyTagWithPrefix are new
    internal helpers in internal/cairn/prime.go; internal/cairn/entry.go
    gained a small supporting change.

Test plan

quad341 added 3 commits July 21, 2026 23:31
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
quad341 enabled auto-merge (squash) July 22, 2026 18:22
@quad341
quad341 merged commit 703f58e into main Jul 22, 2026
2 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant