Repository navigation
fix(docs): keep mirrored ClawHub routes resolvable in anchor audits - #143002
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 6:44 AM ET / 10:44 UTC (Revision 2). ClawSweeper reviewWhat this changesThe documentation link auditor accepts declared ClawHub routes without a local source checkout while reporting unverifiable fragments only in anchor mode. Merge readiness✅ Ready for maintainer review Both prior findings are resolved, and the supplied CLI evidence covers their triggering cases. The repair remains necessary on current main; no blocking introduced defect remains. Priority: P2 Review scores
Verification
How this fits togetherThe documentation auditor reads Markdown links, navigation, and redirects to identify broken published links. ClawHub pages come from a separate source tree, so local audits must distinguish declared routes from fragments that require that source. flowchart TD
A[Markdown links and navigation] --> C[Documentation auditor]
B[Optional ClawHub source] --> C
C --> D{Source page available?}
D -->|Yes| E[Validate page and fragment]
D -->|No| F[Check declared mirrored route]
F --> G[Report unverified fragments in anchor mode]
E --> H[Audit results]
G --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +186, Other +74. Total +260 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep route existence and fragment verification distinct, preserving plain-mode behavior and requiring actual mirrored source to verify ClawHub anchors. Do we have a high-confidence way to reproduce the issue? Yes: current main rejects navigation-declared ClawHub routes in anchor mode when their source checkout is absent. Source inspection establishes the path, and the supplied CLI comparisons corroborate it; this review did not execute tests. Is this the best way to solve the issue? Yes: the patch extends the existing mirrored-route allowance, preserves ordinary fragment handling, and retains explicit diagnostics where source absence prevents verification. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 056d14028ff1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
195f598 to
a3ac93e
Compare
`/clawhub/**` pages are authored in openclaw/clawhub and injected into the publish tree by `scripts/docs-sync-publish.mjs`, so a checkout without the ClawHub source has the docs.json navigation entries but no Markdown pages. `buildAuditIndex` already accepts those declared routes when the source is absent (`allowExternalClawHubRoutes`), but `--anchors` mode discarded the allowance: its route check required a parsed page and ignored `resolved.ok`. Every link into `/clawhub/**` was therefore reported as "route/file not found", and the three redirects targeting `/clawhub` as "Redirect has no terminal Markdown page" — 42 false positives on a clean tree, while plain mode reported 0. Accept a declared mirrored route in anchors mode when the link carries no fragment, count mirrored routes as terminal pages for redirect resolution, and report fragment-bearing links into them as unverified rather than missing. Anchors mode now also prints `mirrored_clawhub_docs=` and warns on stderr when the source is absent, so the reduced coverage is visible instead of silent. No docs content changes: the 39 links were correct as authored.
The unverified-fragment branch for ClawHub-mirrored routes ran in plain mode too, so a link like /clawhub/publishing#section turned into a broken link and failed docs:check-links -- a mode that has never inspected fragments. Gate the diagnostic on anchor mode and let plain mode resolve the declared route as it did before. Redirect destinations that land on a mirrored route now resolve off the navigation declaration, which proves the route but not the fragment. Report those fragments as unverified instead of skipping them silently.
a3ac93e to
9999bf1
Compare
|
Both findings fixed in Two notes on how the evidence was produced. This worktree has no sibling 1. Keep unverified fragment errors behind anchor mode —
|
broken_links |
exit | |
|---|---|---|
origin/main |
0 | 0 |
| previous revision of this PR | 1 | 1 |
| current | 0 | 0 |
The previous revision's failure line was:
zz-clawhub-fragment-repro.md:10 :: /clawhub/publishing#package-publish-source :: fragment unverified without the ClawHub source checkout (terminal: /clawhub/publishing#package-publish-source); set OPENCLAW_DOCS_SYNC_CLAWHUB_REPO
The current revision's plain-mode output is byte-identical to main's for that same tree. Anchors mode is unaffected by the gate — it still reports the link as unverified (4 findings with the repro page present, vs 43 on main).
Covered through the CLI test boundary. Two tests added, in the same describe block:
leaves fragments into mirrored routes alone in plain mode— directauditDocsLinks({ allowExternalClawHubRoutes: true }), expectsbrokenempty andunverifiedMirroredFragments === 0.exits clean from the CLI in plain mode for a fragment into a mirrored route—spawnSynconscripts/docs-link-audit.mjswith no--anchors, expectsbroken_links=0, exit0, and nofragment unverifiedin stdout. The fixture root is nested one directory deeper than the existing CLI harness's so that<root>/../clawhubcannot accidentally resolve and flip the allowance off — this run has to be the source-absent shape to mean anything.
Both fail against the previous revision.
2. Report unverified fragments in mirrored redirect destinations — scripts/docs-link-audit.mts:514-517
Confirmed, including the subtlety that the link loop does not compensate when nothing references the redirect. The redirect loop now diagnoses it while processing the record, using the same reason string as the link path:
// A redirect into a ClawHub-mirrored route now resolves off the navigation
// declaration, which proves the route but not the fragment. Say so instead
// of letting the destination fragment go silently unchecked.
if (!page && destination.hash) {
const terminal = normalizeRoute(destination.pathname);
if (index.mirroredRoutes.has(terminal)) {
unverifiedMirroredFragments++;
broken.push({ file: "docs.json", line: 0, link: record.source, reason: ... });
}
}Reproduced from the CLI. Rewriting the existing /tools/clawhub redirect destination to /clawhub/publishing#package-publish-source and running --anchors with no ClawHub source — nothing in docs/ links to /tools/clawhub, so this is exactly the unreferenced case:
main docs.json:unknown :: /tools/clawhub :: Redirect has no terminal Markdown page: /tools/clawhub -> /clawhub/publishing
previous (no line mentioning /tools/clawhub — resolved silently, and unverifiedMirroredFragments stayed 0)
current docs.json:unknown :: /tools/clawhub :: fragment unverified without the ClawHub source checkout (terminal: /clawhub/publishing#package-publish-source); set OPENCLAW_DOCS_SYNC_CLAWHUB_REPO
Totals for those runs: 42 / 3 / 4. Plain mode reports 0 in all three.
Two tests added: reports unverified fragments in redirect destinations into mirrored routes (anchors; asserts the count, file, link, and reason) and keeps mirrored redirect destinations silent in plain mode (the mode guard, so the fix for finding 2 cannot reintroduce finding 1).
3. Complete next step
Both cases are fixed and validated through the CLI test boundary, per the above.
Verification on 9999bf149fd
pnpm check:docs — the aggregate the CI docs job runs, not a hand-picked subset — exit 0, both with and without OPENCLAW_DOCS_SYNC_CLAWHUB_REPO set.
Plain mode is unchanged from main in every configuration, diagnostics included:
| run | main |
this PR |
|---|---|---|
| plain, no ClawHub source | 0 | 0 — byte-identical |
| plain, with ClawHub source | 0 | 0 — byte-identical |
--anchors, with ClawHub source |
4 | 4 — byte-identical |
--anchors, no ClawHub source |
42 | 3 — the intended change |
Tests: src/scripts/docs-link-audit.test.ts under test/vitest/vitest.tooling.config.ts is 32 passed / 1 failed. The failure is preserves Mint component targets for raw component apostrophes normalized after separators (as-s-guide), which reproduces unchanged at origin/main, where the same file is 24 passed / 1 failed. It is untouched by this PR.
pnpm check:test-types reports an identical set of 8 pre-existing src/infra/* errors with and without this change; none are in the audited files. (Run from a full clone — tsgo refuses to start in a git worktree whose node_modules is a symlink.)
@clawsweeper re-review
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…penclaw#143002) * fix(docs): keep mirrored ClawHub routes resolvable in anchor audits `/clawhub/**` pages are authored in openclaw/clawhub and injected into the publish tree by `scripts/docs-sync-publish.mjs`, so a checkout without the ClawHub source has the docs.json navigation entries but no Markdown pages. `buildAuditIndex` already accepts those declared routes when the source is absent (`allowExternalClawHubRoutes`), but `--anchors` mode discarded the allowance: its route check required a parsed page and ignored `resolved.ok`. Every link into `/clawhub/**` was therefore reported as "route/file not found", and the three redirects targeting `/clawhub` as "Redirect has no terminal Markdown page" — 42 false positives on a clean tree, while plain mode reported 0. Accept a declared mirrored route in anchors mode when the link carries no fragment, count mirrored routes as terminal pages for redirect resolution, and report fragment-bearing links into them as unverified rather than missing. Anchors mode now also prints `mirrored_clawhub_docs=` and warns on stderr when the source is absent, so the reduced coverage is visible instead of silent. No docs content changes: the 39 links were correct as authored. * fix(docs): keep the mirrored-fragment diagnostic in anchor mode The unverified-fragment branch for ClawHub-mirrored routes ran in plain mode too, so a link like /clawhub/publishing#section turned into a broken link and failed docs:check-links -- a mode that has never inspected fragments. Gate the diagnostic on anchor mode and let plain mode resolve the declared route as it did before. Redirect destinations that land on a mirrored route now resolve off the navigation declaration, which proves the route but not the fragment. Report those fragments as unverified instead of skipping them silently.
Summary
node scripts/docs-link-audit.mjs --anchorsreports 42 broken links on a cleanmainwhen the checkout has no ClawHub source beside it, while plain mode reports 0. All 39/clawhub/**findings are false positives. No docs content is changed by this PR — the links are correct as authored.Diagnosis
/clawhub/**pages are authored in openclaw/clawhub, not here.scripts/docs-sync-publish.mjsreplaces the whole publishdocs/clawhub/tree from that source, anddocs/AGENTS.md(added in #138157, which removed the last local copies) says explicitly not to keep authored copies in this repo.docs/docs.jsondeclares the twelve/clawhub/**navigation entries and three redirects into/clawhub; those are real published routes ondocs.openclaw.ai.buildAuditIndexalready handles this: when no ClawHub checkout is resolvable it setsallowExternalClawHubRoutesand adds the navigation-declared routes toroutes, soresolveRoutesucceeds. But the link check discarded that allowance in anchors mode:options.anchorsshort-circuits ahead ofresolved.ok, so anchors mode demanded a parsed Markdown page and ignored the allowance that plain mode honours. Same for redirect resolution, which built itspageslist from parsed pages only — hence the threeRedirect has no terminal Markdown page: /clawdhub -> /clawhuberrors.The intent behind the short-circuit is sound: a route declaration cannot prove a fragment. But it can prove the route, and 39 of the 39 findings are fragment-less links.
Fix
fragment unverified without the ClawHub source checkout; set OPENCLAW_DOCS_SYNC_CLAWHUB_REPO, instead of the misleadingroute/file not found. Plain mode has never inspected fragments, so it keeps resolving the declared route and stays silent.mirrored_clawhub_docs=yes|noin anchors mode and warn on stderr when the source is absent, so reduced coverage is visible rather than silent.When the ClawHub source is present,
mirroredRoutesis empty and behaviour is byte-identical to before.Results
Run against the repo as authored (no
/clawhub/**link here carries a fragment today):--anchors, no ClawHub source--anchors, with ClawHub sourceEach of the three unchanged rows is byte-identical to
main, diagnostics included.The remaining 3 are the pre-existing
maturity/#windows-app-nodefailures. The 4th in the with-source run isclawhub/publishing.md:216 :: /clawhub/cli#package-publish-source— a real broken anchor inopenclaw/clawhub, not fixable from this repo. I have not filed it upstream; it is reported to the docs-audit orchestrator for routing toopenclaw/clawhub.Fragment-bearing link (the plain-mode edge case)
Temporarily adding a page containing
[publishing](/clawhub/publishing#package-publish-source):mainmain--anchors, no source--anchors, with sourceFragment-bearing redirect destination
Temporarily rewriting the
/tools/clawhubredirect to/clawhub/publishing#package-publish-source,--anchorswith no ClawHub source:Plain mode reports 0 in all three.
Why CI did not catch this
It is not a CI regression — there was nothing to catch.
check:docsruns plaindocs:check-links, which correctly reports 0, and both lanes (.github/workflows/ci.yml,.github/workflows/docs.yml) check outopenclaw/clawhubintoclawhub-sourceand setOPENCLAW_DOCS_SYNC_CLAWHUB_REPO, so even anchors mode would be clean there.Two related gaps worth recording, neither introduced here:
docs:check-links:anchorsis not run by any workflow. It appears only inpackage.json,CHANGELOG.md, and three docs pages describing it as a manual step. Anchor regressions are ungated, which is why the three#windows-app-nodefailures have survived. Turning it on would need those fixed first, so I have not done it here.<repo>/../clawhubviaDEFAULT_CLAWHUB_REPO_CANDIDATES. Coverage therefore depends on the directory beside the checkout, with no output saying which mode ran. That is what made this look like a regression: the same command reports 4 from a clone with a siblingclawhub/and 42 from a git worktree without one. The newmirrored_clawhub_docs=line makes that visible.Validation
pnpm check:docs— the aggregate the CI docs job runs — passes (exit 0), with and withoutOPENCLAW_DOCS_SYNC_CLAWHUB_REPOset.Tests:
src/scripts/docs-link-audit.test.tsundertest/vitest/vitest.tooling.config.ts, 32 passed / 1 pre-existing failure (preserves Mint component targets…,as-s-guide; reproduced unchanged atorigin/main, where the file is 24 passed / 1 failed).Eight hermetic tests cover: mirrored route accepted; fragment reported unverified in anchors mode; fragment left alone in plain mode, both through
auditDocsLinksand through the real CLI; redirect destination fragment reported unverified in anchors mode and silent in plain mode; undeclared/clawhub/*route still reported missing; allowance-off still reporting missing. Three of the four added in the current revision fail against the previous revision of this PR.pnpm check:test-typesreports the same 8 pre-existingsrc/infra/*errors with and without this change (identical error set); none are in the audited files.