Skip to content

DOC-6740 improve Claude hook with relrefs#3500

Merged
andy-stark-redis merged 4 commits into
mainfrom
DOC-6740-improve-hook-with-relrefs
Jun 15, 2026
Merged

DOC-6740 improve Claude hook with relrefs#3500
andy-stark-redis merged 4 commits into
mainfrom
DOC-6740-improve-hook-with-relrefs

Conversation

@andy-stark-redis

@andy-stark-redis andy-stark-redis commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Claude initially said that checking relrefs in the post-edit hook would be prohibitively complicated. However, most of the relrefs we actually use in the docs can be checked fairly easily (it's the stuff we don't use that causes problems). Given that there was a dodgy link in one of my use case pages the other day, I figured it would be worth having a simple relref check even if it doesn't handle everything. It should at least help prevent hallucinations of common pathnames, like the one in the use case page.


Note

Medium Risk
The hook can block doc edits when relref or path heuristics disagree with Hugo, though git-unavailable skip and fail-open paths reduce that; mis-scoped blocking would affect every PostToolUse markdown edit.

Overview
Extends check_shortcode_paths.py so Claude edits to content/**/*.md can be blocked for bad absolute relref targets, not only missing image/embed file paths. Relative relrefs stay unchecked; SHORTCODE_SKIP_RELREF=1 disables relref validation.

Relref behavior: Resolution is filesystem-based with Hugo-style path normalization and config.toml [[module.mounts]] remapping. In hook mode, only relrefs new vs git show HEAD: are validated; git errors/timeouts skip relref checks entirely. Scan mode (--scan) still reports all absolute relrefs.

File-ref tightening: Shortcode regexes use tempered matching so >/} in attributes do not hide filename/image. Static/embed checks use case-exact leaf names where the build is strict; embed-code / embed-yaml match exact readFile paths. Broken file refs and broken new relrefs both exit 2; uncaught hook exceptions exit 0 (fail open).

Also adds a Validator Source-Of-Truth Drift candidate pattern to .codex/skills/claude-review/references/claude-review-patterns.md for reviewing Hugo approximators.

Reviewed by Cursor Bugbot for commit ac6a492. Bugbot is set up for automated code reviews on this repo. Configure here.

@andy-stark-redis andy-stark-redis requested a review from a team June 15, 2026 14:20
@andy-stark-redis andy-stark-redis self-assigned this Jun 15, 2026
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

DOC-6740

@jit-ci

jit-ci Bot commented Jun 15, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@dwdougherty dwdougherty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🫣 Approved.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ac6a492. Configure here.

if not is_abs_relref(ref):
continue # relative / pure-anchor -> skip (can't resolve cheaply)
if not resolve_relref(root, ref):
bad_links.append(("relref", ref))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

HEAD baseline mislabels local relrefs

Medium Severity

Relref diff-scoping compares the edited file to committed HEAD via git show, not to the version that existed immediately before the tool run. Any absolute relref already on disk but not yet committed is treated as newly introduced, so a later unrelated edit can exit 2 for broken links this change did not add.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ac6a492. Configure here.

@andy-stark-redis

Copy link
Copy Markdown
Contributor Author

Thanks @dwdougherty !

@andy-stark-redis andy-stark-redis merged commit 1d58902 into main Jun 15, 2026
74 of 75 checks passed
@andy-stark-redis andy-stark-redis deleted the DOC-6740-improve-hook-with-relrefs branch June 15, 2026 14:45
EliShteinman added a commit to EliShteinman/docs that referenced this pull request Jun 15, 2026
Improve the shortcode-path validation hook with relref checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants