Skip to content

feat: lint anchor_drift and anchor_missing from code drift (#147) - #159

Merged
jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/lint-anchor-drift
Nov 10, 2026
Merged

jflowers merged 7 commits into
unbound-force:mainfrom
jflowers:opsx/lint-anchor-drift

Conversation

@jflowers

@jflowers jflowers commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #147. Part of #153.

Stacked on #156 (#146). Rebased onto #156's current head. This branch contains #156's commits; review only the last three commits, or wait until #156 merges and this PR rebases to just those.

Summary

lint gains two deterministic checks that detect staleness from code drift rather than age. They apply to learnings pinned with as_of (added in #146) whose evidence cites <repo>:<path> for the vault's own repository:

  • anchor_missing: the path doesn't exist at the as_of commit, or that commit isn't in the repository. An unknown pin produces one finding per learning.
  • anchor_drift: the path changed between the pin and HEAD. Deletion counts as a change.

lint with fix: true marks drifted learnings validity: stale-unverified in the store and in their markdown frontmatter. Tiers and content are never changed. The result reports fixed.anchor_drift. Summary counters anchor_drift / anchor_missing appear only when they're non-zero, so the existing summary shape is unchanged.

Only local git runs, behind an anchorChecker interface with a 5 s timeout per call. The checks are skipped when there's no vault path or the vault isn't a git repo.

Not checked:

A trailing :<line>[-<line>] suffix on a locator is stripped. The 30-day stale_decision check is unchanged and stays as a secondary signal.

Hardening carried over from the #156 council findings:

  • fix checks the identity with ValidLearningIdentity and decodes properties before writing anything. An unsafe identity or unreadable properties is an error, and the store and markdown file stay as they were. A literal JSON null no longer panics.
  • Only hexadecimal as_of pins reach git as a revision. as_of can come from re-ingested frontmatter, so a value like --output=x is skipped rather than treated as a pin.
  • Git subprocess tests are skipped in short mode.

Spec: openspec/changes/lint-anchor-drift/.

Tests

tools/lint_anchors_test.go, using a real temporary git repository:

  • drift on a changed file; no finding for an unchanged file with a line suffix;
  • missing path, and an unknown pin;
  • other-repository locators, issue-number locators, historical/superseded learnings and unpinned learnings are all skipped;
  • fix updates store and frontmatter and leaves the tier alone;
  • skipped outside git;
  • checker failures are logged and the lint run still completes;
  • fix fails closed on corrupt properties and unsafe identities, and handles null and empty properties;
  • option-like and non-hex pins are skipped;
  • locator and pin parsing.

Verification (CI parity)

  • go build ./..., go vet ./..., gofmt: clean
  • go test -race -count=1 -coverprofile=coverage.out ./...: all pass
  • Gaze gate: CRAPload 47/48, GazeCRAPload 39/45, the same as current main
  • golangci-lint: no findings in changed files

Before ready

🤖 Generated with Claude Code

@jflowers
jflowers force-pushed the opsx/lint-anchor-drift branch 2 times, most recently from f7c5948 to f221569 Compare November 8, 2026 16:15
@uf-divisor
uf-divisor marked this pull request as ready for review November 8, 2026 23:12
@jflowers
jflowers enabled auto-merge (rebase) November 8, 2026 23:13

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Verdict: REQUEST CHANGES

1 HIGH finding blocks this PR. The implementation is solid — the anchor-check logic is well-tested, fail-closed against untrusted input, and both CI checks pass — but the website documentation sync gate (AGENTS.md, Website Documentation Sync) has no tracking issue for this user-facing change.

Summary

Two deterministic lint checks (anchor_missing, anchor_drift) detect staleness of as_of-pinned learnings from code drift via local git, with a fix mode that marks drifted learnings validity: stale-unverified in both the store and the markdown backup. 23 findings from 5 reviewer personas, deduplicated to 18 distinct issues: 1 HIGH, 7 MEDIUM, 10 LOW; no CRITICAL.

Dispatch Provenance

Run Agent Source Model Verdict
aca2808f adversary advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES
4ddf08d0 architect advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES
df372e44 curator advisor enmaas/rits/zai-org/glm-5-3 REQUEST CHANGES
f360c7f3 guard advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES
24077c38 testing advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES

Correlation ID: 4989a387-0fd7-41d1-ba89-883665459ed9 · CI: build-and-test PASS, MegaLinter PASS

Findings not attached to a diff line

  • [MEDIUM] AGENTS.md not updated (architect, curator): the CLI table row for dewey lint and the Recent Changes section do not mention the anchor checks. AGENTS.md is outside this PR's diff, so this lands as a follow-up commit on this branch.
  • [LOW] README MCP tools table row for lint (curator): the tool summary (README.md:130) does not list the new finding types. The line falls outside this PR's hunks; update alongside the AGENTS.md follow-up.
  • [LOW] Corrupt-properties skip in the check path untested (testing): a learning whose properties fail to parse is silently skipped by learningAnchors (lint_anchors.go:128); no test covers that skip.

Resolution notes

The HIGH finding resolves by filing docs: sync dewey lint anchor checks documentation in unbound-force/website (docs label), covering the new finding types, skip conditions, fix semantics, and summary counters, referencing content/docs/projects/dewey.md and cross-linking website#380 — the same gate #156 satisfied via website#380.

This review was generated by /uf.review-pr (AI-assisted).

Comment thread README.md Resolved
Comment thread tools/lint.go Resolved
Comment thread tools/lint_anchors.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
Comment thread tools/lint_anchors.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
Comment thread tools/lint_anchors_test.go Resolved

@uf-divisor uf-divisor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Verdict: APPROVE WITH ADVISORIES

No blocking findings. The prior round's HIGH (website docs sync) is resolved — website#398 (docs) and website#399 (blog) are filed, and commits 23748af + 198cfcf address the earlier findings (anchor_checks outcome, context threading with a 60s pass budget, --no-ext-diff --no-textconv, other-repo pin skip, fix counting store writes with anchor_fix_warnings, shared updateLearningBackup/decodeLearningProperties). Both CI checks pass on the head. This review supersedes the earlier CHANGES_REQUESTED review, which was rendered against the pre-fix commit f221569. 13 findings from 5 reviewer personas, deduplicated to 11 distinct issues: 2 MEDIUM, 9 LOW; no CRITICAL or HIGH.

Summary

Two deterministic lint checks (anchor_missing, anchor_drift) detect staleness of as_of-pinned learnings from local git code drift, with a fail-closed fix that marks drifted learnings validity: stale-unverified in the store and markdown backup without touching tiers. The implementation re-validates evidence limits at the consumption site, threads the request context with per-call (5s) and per-pass (60s) budgets, disables repository-configured diff drivers, and reports every pass outcome as anchor_checks so a skipped pass is never read as clean.

Dispatch Provenance

Run Agent Source Model Verdict
6c131429 adversary advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES
41833e2b architect advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES
f0c8aa65 curator advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES
81429189 guard advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES
94c86258 testing advisor enmaas/rits/zai-org/glm-5-3 APPROVE WITH ADVISORIES

Correlation ID: 809dbb52-8b63-4481-b8de-b530c51fec68 · CI: build-and-test PASS, MegaLinter PASS

Findings not attached to a diff line

  • [MEDIUM] lint registry Description and Fix schema stale (companion to the first inline finding): server.go:518 still enumerates only the four original check kinds, and LintInput.Fix's jsonschema (types/tools.go:340) still says "Auto-repair mechanical issues (missing embeddings)" — both files are outside this PR's diff, so the fix lands as a follow-up commit on this branch.

Resolution notes

The two MEDIUM advisories are a documentation-surface update (server.go Description, Lint GoDoc, Fix jsonschema) and a one-line test-fixture correction; neither blocks merge. The LOW advisories are optional hardening and coverage improvements.

This review was generated by /uf.review-pr (AI-assisted).

Comment thread tools/lint.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
Comment thread tools/lint_anchors.go Resolved
Comment thread tools/lint_anchors.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
Comment thread tools/lint_anchors.go Resolved
Comment thread tools/lint_anchors.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
Comment thread tools/lint_anchors_test.go Resolved
@jflowers

Copy link
Copy Markdown
Contributor Author

Review-body findings (not attached to a diff line), all addressed:

  • [MEDIUM] AGENTS.md not updated: the dewey lint CLI table row and a Recent Changes bullet now cover the anchor checks (198cfcf).
  • [LOW] README MCP tools table row for lint: it now lists anchor drift and missing anchors (198cfcf).
  • [LOW] Corrupt-properties skip untested: corrupt-1 in TestLint_AnchorChecks has unreadable properties and asserts no finding (23748af).

Website tracking: docs website#398, blog website#399.

@jflowers

Copy link
Copy Markdown
Contributor Author

Round-2 review-body finding [MEDIUM] lint registry Description and Fix schema stale: fixed in 6920165, with server.go's lint Description, the Lint GoDoc and LintInput.Fix's jsonschema (see the tools/lint.go:70 thread). All 11 round-2 threads are answered: 10 fixed, and the FR-id finding is left as a repo-wide decision. Tutorial tracking is website#402.

@jflowers
jflowers dismissed uf-divisor’s stale review November 10, 2026 17:23

Superseded: every finding in this review was addressed in 23748af/198cfcf, and uf-divisor's re-review on the fixed head (5844659613) returned APPROVE WITH ADVISORIES. Its 11 advisories are addressed in 6920165/f949752.

jflowers and others added 7 commits November 10, 2026 12:34
…orce#147)

For learnings pinned with as_of, lint checks each <repo>:<path>
evidence locator for the vault's repository against local git:
anchor_missing when the path is absent at the pin (or the pin is
unknown), anchor_drift when it changed between the pin and HEAD.
fix marks drifted learnings validity: stale-unverified; tiers are
never changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
)

Port the unbound-force#156 review-council hardening to lint: markStaleUnverified
validates the identity with ValidLearningIdentity and decodes
properties before writing, so an unsafe identity or unreadable
properties fails closed and a JSON null no longer panics. Only
hexadecimal as_of pins reach git as a revision. Git subprocess tests
are skipped in short mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Report every pass as anchor_checks {status, reason}: checked,
  skipped (no vault path, not a git repository), or failed (git
  error, cancelled request, budget exhausted), so MCP clients can
  tell a clean pass from one that never ran.
- Thread the request context through the checker, bound the whole
  pass (60s) as well as each git call (5s, now including HEAD), and
  re-check store_learning's evidence limits where evidence is read.
- Skip learnings pinned to another repository: the pin's repo must
  be the vault's own, not just match its evidence.
- Pass --no-ext-diff --no-textconv to git diff.
- Count a fix once the store write succeeds and report backup
  failures in anchor_fix_warnings.
- Share the backup write (updateLearningBackup) and properties
  decoder (decodeLearningProperties) with the unbound-force#146 supersession flow.
- Tests: multi-anchor dedup, two-path unknown pin, anchor_missing-only
  fix negative, deleted-after-pin, corrupt properties, other-repo
  pins, evidence limits, post-failure store and file state,
  cancellation, repository diff drivers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Spec and design state the eligibility rule (pin to the vault's own
repository, at least one path anchor), the evidence limits, the pass
budget, anchor_checks, and the fix warning contract. README MCP
tools table and lint section, AGENTS.md CLI table and Recent
Changes. Website tracking: docs website#398, blog website#399.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- lint's tool description, Lint GoDoc, and fix schema describe the
  anchor checks and what fix does to validity
- PathChanged passes a literal pathspec, so glob characters or
  pathspec magic in a file name match only that file
- per-call and per-pass bounds are fields so tests can expire them;
  gitOutput shares the anchor checker's git runner
- updateLearningProperties re-reads and rewrites stored properties
  under one lock, used by fix and the supersession link; fix leaves a
  learning superseded mid-pass unchanged
- tests: escape canary at the real target, path dedup, at-limit
  evidence, both time bounds, glob-named file, warning attribution,
  concurrent fix and supersede

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Spec, design, proposal, tasks, and README cover literal path
comparison, at-limit evidence, the locked properties rewrite, and the
tutorial issue website#402.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jflowers
jflowers force-pushed the opsx/lint-anchor-drift branch from f949752 to 54642ce Compare November 10, 2026 17:36
@uf-divisor
uf-divisor self-requested a review November 10, 2026 18:56
@jflowers
jflowers merged commit f0194ec into unbound-force:main Nov 10, 2026
2 checks passed
@jflowers
jflowers deleted the opsx/lint-anchor-drift branch November 15, 2026 20:39
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.

feat: lint anchor_drift / anchor_missing — detect staleness from code drift, not age

2 participants