Skip to content

context-forge: content-anchor code citations (CF-N13) for large multi-tenant repos - #20

Merged
davcs86 merged 1 commit into
mainfrom
claude/context-forge-code-cites-84hbjn
Sep 23, 2026
Merged

davcs86 merged 1 commit into
mainfrom
claude/context-forge-code-cites-84hbjn

Conversation

@davcs86

@davcs86 davcs86 commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Problem

The context-forge skills bake a path:line citation contract into everything they emit — constitution rules, both findings logs — and both staleness engines (the refresh re-check and the scrubber's stale citation category) resolve citations by line number. In large, churning, multi-tenant repos this is exactly backwards:

  • Line drift = false staleness. Any edit above a cited line shifts the number, so a citation goes "stale" without the referenced knowledge changing at all. Every refresh/scrub then re-flags real citations → constant rework, the churn the toolkit exists to prevent.
  • Path ambiguity across tenants. The same relative path shape recurs under many tenants/modules (services/<tenant>/handler.go), so a bare path + line is both fragile and ambiguous.

The repo already stated the correct principle in one place — apply-protocol.md: "located by content … line numbers drift … content-anchored edits stay correct." This change generalizes that established principle to the entire citation contract.

Change

Re-key every emitted citation on a stable content anchor, with the line demoted to an optional hint.

  • New governing norm CF-N13 (shared principles.md, both byte-identical copies): a citation is path#anchor — a grep-resolvable symbol / migration id / doc heading (or a short unique quoted snippet when no symbol fits), repo-root-relative and module-qualified so tenants aren't ambiguous — and a line number is only ever an approximate, regenerable (~Lnn) hint, never the identity. CF-N1 and CF-N9 amended to reference it.
  • Staleness redefined in both engines: a citation is stale only when its anchor no longer resolves (renamed/deleted symbol, grep zero hits). A merely drifted ~L hint is current and is re-stamped in place as metadata (like the header provenance line) — never a refresh "stale" flag, never a scrubber finding. This is the single change that stops the false-positive churn.
  • Ambiguity is disambiguated or deduped, never guessed: a multi-site anchor carries its module-qualified path or is deduped up the tree (CF-N3).
  • Backward compatible: legacy path:line citations stay valid input and are re-grounded to path#anchor the next time a refresh/re-audit touches the row — a legacy line-only citation whose file exists but whose line drifted is re-grounded, never retired.
  • Threaded the path#anchor (~Lnn) form through every placeholder and example across both agents, all protocols, and all three templates; README gains a Content-anchored citations design section.
  • Version 0.8.0 → 0.9.0 across all three tool manifests (Claude Code, Cursor, Codex), kept identical.

Validation

python3 plugins/context-forge/scripts/validate.py --self-test   # OK
python3 plugins/context-forge/scripts/validate.py               # OK
python3 scripts/validate_manifests.py --self-test              # PASSED
python3 scripts/validate_manifests.py                          # PASSED

Shared principles.md copies confirmed byte-identical (validator's DRIFT check). No behavioral change to the marketplace catalogs; membership/semver parity intact.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VzYYP7rcbdLLLKapxfvfvR


Generated by Claude Code

…-tenant repos

Raw `path:line` citations were the identity of every citation the toolkit
emits (constitution rules, both findings logs) and the key both staleness
engines checked (refresh re-check, scrubber's "stale citation" category). In
large, churning, multi-tenant repos this backfired: any edit above a cited
line drifted the number, so citations went "stale" without the referenced
knowledge changing, and the same relative path shape recurring under many
tenants made a bare path+line ambiguous. The result was constant re-flagging
and rework — the exact churn the plugin exists to prevent.

Re-key every emitted citation on a stable content anchor:

- New governing norm CF-N13 (shared principles.md, both copies): citations are
  `path#anchor` — a grep-resolvable symbol/heading (or short unique snippet),
  repo-root-relative and module-qualified so tenants aren't ambiguous — with a
  line number only ever an optional, approximate `(~Lnn)` hint, never the
  identity. Amends CF-N1 and CF-N9 to reference it.
- Staleness redefined across both engines: a citation is stale only when its
  anchor no longer resolves; a merely drifted `~L` hint is current and is
  re-stamped in place as metadata, never flagged (refresh-protocol,
  audit-protocol, both SKILLs, both agents).
- Multi-site ambiguity is disambiguated by module-qualified path or deduped up
  the tree (CF-N3), never guessed.
- Legacy `path:line` citations stay valid input and are re-grounded to
  `path#anchor` the next time refresh/re-audit touches the row — backward
  compatible.
- Threaded the `path#anchor (~Lnn)` form through every placeholder and example
  in the agents, protocols, and all three templates; README gains a
  "Content-anchored citations" design note.
- Version 0.8.0 -> 0.9.0 across all three tool manifests.

Validators (plugin + marketplace, self-tests and live) pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VzYYP7rcbdLLLKapxfvfvR
@davcs86
davcs86 merged commit b391a2c into main Sep 23, 2026
2 checks passed
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.

2 participants