Skip to content

fix(hooks): treat planned suite siblings as suggestions, not broken links#51

Merged
Anthony Johnson II (AJ-EthereaLogic-ai) merged 1 commit into
mainfrom
fix/planned-sibling-link-classification
Jun 18, 2026
Merged

fix(hooks): treat planned suite siblings as suggestions, not broken links#51
Anthony Johnson II (AJ-EthereaLogic-ai) merged 1 commit into
mainfrom
fix/planned-sibling-link-classification

Conversation

@AJ-EthereaLogic-ai

@AJ-EthereaLogic-ai Anthony Johnson II (AJ-EthereaLogic-ai) commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Resolves the deferred open item from the hook review: links to planned-but-not-yet-generated suite siblings were reported as Broken link consistency issues during incremental suite generation (false positives).

The post-write hook now distinguishes the two cases (Policy A — warn vs error):

  • A missing link target that matches a planned document's output_path in any suite manifest → non-blocking suggestion (Planned sibling not yet generated).
  • A missing target not declared in any manifest → remains a Broken link issue, preserving genuine broken-link detection (cross_reference_rules.validate_internal_links, doc-review/doc-sync intent).

Changes

  • hook_utils.py: new load_suite_output_paths(project_dir) helper (globs .claude/docs/suites/*/manifest.json, resolves output_path values to normalized absolute paths), mirroring the existing load_quality_profiles load-with-fallback idiom.
  • doc_post_write.py: check_internal_links returns (issues, suggestions); planned-path set loaded once per call; caller routes both buckets.
  • tests/smoke.sh: two regression tests — planned-sibling → suggestion, genuine-missing → broken-link issue (using the real _example manifest fixture api/reference.md).

Verification

  • npm test green (40/40 locally with jsonschema>=4.18; schema checks skip without it).
  • python3 -m py_compile .claude/hooks/*.py, bash -n tests/smoke.sh, git diff --check clean.
  • Manual: a doc linking both api/reference.md (planned) and nope.md (unknown) splits correctly — suggestion vs issue.
  • .codex/hooks/ (gitignored local mirror) kept byte-for-byte in sync; parity test skips cleanly in CI.

Out of scope (intentional)

validate_internal_links on/off gate, anchor-existence checks, doc_id-based matching.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Documentation link validation now differentiates between broken links and links to planned-but-not-yet-generated internal documents, reducing false error reports and providing more accurate feedback.
  • Tests

    • Added tests to verify handling of planned internal links and broken link detection.

…inks

The post-write consistency hook flagged any internal link to a missing
file as a broken-link issue. During incremental suite generation a document
can legitimately link to a sibling that is declared in a suite manifest but
not yet written, producing false-positive "Broken link" issues.

check_internal_links now loads every manifest output_path via the new
hook_utils.load_suite_output_paths() helper and routes missing-but-planned
targets to non-blocking suggestions ("Planned sibling not yet generated"),
while genuinely unknown missing targets remain broken-link issues. Adds
smoke coverage for both the planned-sibling and genuine-broken paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 18, 2026 00:08
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR extends the doc_post_write.py hook's internal link checker to distinguish planned-but-not-yet-generated suite siblings from genuinely broken links. A new load_suite_output_paths utility in hook_utils.py reads suite manifest JSON files to collect declared output paths. check_internal_links is rewritten to return (issues, suggestions), routing missing links through the planned-path set. Two smoke tests cover both paths.

Changes

Planned-sibling link differentiation

Layer / File(s) Summary
Suite manifest path loader
.claude/hooks/hook_utils.py
Adds glob import and load_suite_output_paths(project_dir: Path) -> set, which scans .claude/docs/suites/*/manifest.json, resolves each document's output_path to an absolute project path, and returns the set; skips malformed or unreadable manifests.
check_internal_links rewrite and caller update
.claude/hooks/doc_post_write.py
Adds os import and load_suite_output_paths import; rewrites check_internal_links to initialize planned paths, resolve each internal link target, and emit a non-blocking suggestion for planned siblings or a broken-link issue for unrecognized targets; returns (issues, suggestions); updates check_document_consistency to unpack and merge both lists.
Smoke tests for both link outcomes
tests/smoke.sh
Adds test 5b-i asserting a link to a suite-declared path yields a "planned sibling" suggestion without a broken-link error, and test 5b-ii asserting a link to an undeclared path yields a broken-link issue.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A broken link, or just not born yet?
The rabbit checks the manifest set.
If planned but absent, just a nudge—
No scary error, just a smudge.
True missing links still get their say,
While siblings wait for their big day! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and specifically describes the main change: treating planned suite siblings (from manifests) as non-blocking suggestions rather than broken-link issues. It's concise, clear, and directly reflects the core problem being solved.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/planned-sibling-link-classification

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The job was not started because the account is locked due to a billing issue.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@AJ-EthereaLogic-ai Anthony Johnson II (AJ-EthereaLogic-ai) merged commit b728160 into main Jun 18, 2026
3 of 10 checks passed
@AJ-EthereaLogic-ai Anthony Johnson II (AJ-EthereaLogic-ai) deleted the fix/planned-sibling-link-classification branch June 18, 2026 00:09

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d27d0fff6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

for doc in data.get("documents", []):
output_path = doc.get("output_path")
if output_path:
planned.add(os.path.normpath(str(project_dir / output_path)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize documented docs/ output paths before matching

The documented writer behavior redirects manifest output_path values that start with docs/ into spec_driven_docs/rough_draft/ (.claude/commands/doc/doc-write.md:253), but this helper records only the literal /project/docs/... path. For suites following the documented manifest style, a generated draft linking to a pending sibling such as api/auth.md resolves under /project/spec_driven_docs/rough_draft/..., so candidates & planned_paths misses and the post-write hook still reports a broken link instead of the intended planned-sibling suggestion.

Useful? React with 👍 / 👎.

Comment on lines +104 to +107
for doc in data.get("documents", []):
output_path = doc.get("output_path")
if output_path:
planned.add(os.path.normpath(str(project_dir / output_path)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Only downgrade links for unfinished manifest entries

Because every manifest output_path is added regardless of document status, a missing target for a suite document already marked completed is now downgraded to a planned-sibling suggestion. In a suite where a completed generated file is deleted, moved incorrectly, or otherwise missing, links to it should remain real broken-link issues; filter this set to statuses that can legitimately be not-yet-generated, such as pending or writing.

Useful? React with 👍 / 👎.

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