-
Notifications
You must be signed in to change notification settings - Fork 1
fix: suppress context-drift-check false positives (generated-bridge, renamed, external-repo refs) #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Nathan Schram (nathanschram)
wants to merge
1
commit into
main
Choose a base branch
from
fix/drift-check-false-positives
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: suppress context-drift-check false positives (generated-bridge, renamed, external-repo refs) #32
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,18 @@ fi | |
| CONTEXT_FILES=("CLAUDE.md" "AGENTS.md" "GEMINI.md" ".cursorrules" | ||
| ".github/copilot-instructions.md" "llms.txt" ".windsurfrules" ".clinerules") | ||
|
|
||
| # Generated-bridge filenames the plugin emits into *other* projects. A context | ||
| # file may list these as outputs without them existing in this repo, so a | ||
| # missing local copy is not drift. (Basename match.) | ||
| GENERATED_BRIDGES=("GEMINI.md" "AGENTS.md" "CLAUDE.md" "llms.txt" "llms-full.txt" | ||
| ".windsurfrules" ".cursorrules" ".clinerules" | ||
| "copilot-instructions.md" "agents.mdc" "agents.md") | ||
|
|
||
| # Same-line cue words that mark a reference as descriptive rather than a live | ||
| # local path: rename history ("renamed from `index.md`") or a file in another | ||
| # repo ("the marketing-site `scripts/docs-sync.config.ts` mapping"). | ||
| DESCRIPTIVE_CUE='renamed|formerly|previously|used to be|marketing[- ]site|external repo|upstream repo|other repo' | ||
|
|
||
| STALE=() | ||
| BROKEN_PATHS=() | ||
|
|
||
|
|
@@ -63,9 +75,23 @@ for CTX in "${CONTEXT_FILES[@]}"; do | |
| # Quick broken-path check: extract backtick-quoted file references | ||
| while IFS= read -r REF_PATH; do | ||
| if [ -n "$REF_PATH" ] && [ ! -e "$REF_PATH" ]; then | ||
| # Fallback: check if basename exists anywhere in repo (tracked or untracked) | ||
| BASENAME=$(basename "$REF_PATH") | ||
| if ! git ls-files "*/$BASENAME" "$BASENAME" 2>/dev/null | grep -q . \ | ||
|
|
||
| # Skip generated-bridge filenames — plugin output, not a local file. | ||
| SKIP_REF=false | ||
| for BRIDGE in "${GENERATED_BRIDGES[@]}"; do | ||
| if [ "$BASENAME" = "$BRIDGE" ]; then SKIP_REF=true; break; fi | ||
| done | ||
|
|
||
| # Skip references marked descriptive by a same-line cue word (rename | ||
| # history or a path that lives in another repo). | ||
| if ! $SKIP_REF && grep -F -- "$REF_PATH" "$CTX" 2>/dev/null | grep -qiE "$DESCRIPTIVE_CUE"; then | ||
| SKIP_REF=true | ||
| fi | ||
|
|
||
| # Fallback: check if basename exists anywhere in repo (tracked or untracked) | ||
| if ! $SKIP_REF \ | ||
| && ! git ls-files "*/$BASENAME" "$BASENAME" 2>/dev/null | grep -q . \ | ||
| && ! find . -name "$BASENAME" -not -path './.git/*' -print -quit 2>/dev/null | grep -q .; then | ||
| BROKEN_PATHS+=("$CTX references \`$REF_PATH\` (not found)") | ||
|
Comment on lines
78
to
96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the target script and related symbols.
git ls-files hooks/context-drift-check.sh
wc -l hooks/context-drift-check.sh
sed -n '1,220p' hooks/context-drift-check.sh
printf '\n--- search ---\n'
rg -n 'GENERATED_BRIDGES|CONTEXT_FILES|DESCRIPTIVE_CUE|SKIP_REF|BROKEN_PATHS|REF_PATH|BASENAME' hooks/context-drift-check.shRepository: littlebearapps/contextdocs Length of output: 6267 🏁 Script executed: python3 - <<'PY'
from pathlib import PurePosixPath
import re
GENERATED_BRIDGES = {"GEMINI.md", "AGENTS.md", "CLAUDE.md", "llms.txt", "llms-full.txt",
".windsurfrules", ".cursorrules", ".clinerules",
"copilot-instructions.md", "agents.mdc", "agents.md"}
DESCRIPTIVE_CUE = re.compile(r"renamed|formerly|previously|used to be|marketing[- ]site|external repo|upstream repo|other repo", re.I)
def should_skip(ref_path, ctx_text):
# mirrors the script's logic closely
if not ref_path:
return False
if True: # [ -n "$REF_PATH" ] && [ ! -e "$REF_PATH" ] is modeled as missing inputs only
basename = PurePosixPath(ref_path).name
skip = False
for bridge in GENERATED_BRIDGES:
if basename == bridge:
skip = True
break
if not skip:
# grep -F -- "$REF_PATH" "$CTX" | grep -qiE "$DESCRIPTIVE_CUE"
matching_lines = [line for line in ctx_text.splitlines() if ref_path in line]
if any(DESCRIPTIVE_CUE.search(line) for line in matching_lines):
skip = True
return skip
cases = [
(
"docs/other-project/CLAUDE.md",
"See `docs/other-project/CLAUDE.md` for details.",
"A missing nested CLAUDE.md reference"
),
(
"docs/other-project/CLAUDE.md",
"renamed from `docs/other-project/CLAUDE.md`\nLater we still reference `docs/other-project/CLAUDE.md` elsewhere.",
"Same ref string appears on a cue line and a non-cue line"
),
(
"scripts/docs-sync.config.ts",
"The marketing-site `scripts/docs-sync.config.ts` mapping.",
"Descriptive external path"
),
]
for ref, ctx, label in cases:
print(f"\nCASE: {label}")
print("ref:", ref)
print("skip:", should_skip(ref, ctx))
PYRepository: littlebearapps/contextdocs Length of output: 439 Restrict bridge skipping to exact filename refs.
🤖 Prompt for AI Agents |
||
| fi | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
agents.mdcbridge entry is unreachable — extraction regex has no.mdcextension.GENERATED_BRIDGESincludes"agents.mdc"(Line 46), but the backtick-reference extraction regex on Line 99 only matchests|js|py|go|rs|md|json|toml|yaml|yml|shextensions. A reference like`agents.mdc`will never even be captured, so this allowlist entry can never fire — it's dead. If Cursor's modernagents.mdc(mentioned in CHANGELOG Line 25) needs suppression too, the extraction regex needs the extension added.🐛 Proposed fix
done < <(grep -oE '`[a-zA-Z][a-zA-Z0-9._/-]+\.(ts|js|py|go|rs|md|json|toml|yaml|yml|sh)`' "$CTX" 2>/dev/null \ + done < <(grep -oE '`[a-zA-Z][a-zA-Z0-9._/-]+\.(ts|js|py|go|rs|md|mdc|json|toml|yaml|yml|sh)`' "$CTX" 2>/dev/null \Also applies to: 99-100
🤖 Prompt for AI Agents