Skip to content

The docs link check and gstack-prose-lint read code fences as CommonMark does - #4393

Closed
Davmunrey wants to merge 2 commits into
garrytan:mainfrom
Davmunrey:fix/doc-links-inline-code-fence
Closed

Davmunrey wants to merge 2 commits into
garrytan:mainfrom
Davmunrey:fix/doc-links-inline-code-fence

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Why (in your own words)

The docs lane's link check refuses valid links. unfenced() in lib/doc-links.ts opened a fence on any line that starts with backticks, and closed one on any later line that starts with the same character. docs/troubleshooting.md:3098 starts with the inline code span ````gstack-ship-receipt````, so the checker read lines 3098 to 3729 as code. Every heading and <a id> there vanished, and a docs change linking to one of them failed scripts/check-doc-links.ts and the docs lane's pregate. Six links already on main hit this (for example unattended.md → troubleshooting.md#unattended-runs-and-artifacts), and the links on those lines were never checked.

gstack-prose-lint had the same opening rule. On that file it masked lines 3098 to 4054 as code, took the bare fence at 4058 for an unclosed block and read nothing after it, so /ship's --base --gate run passed prose added in the second half of the file.

Both now follow CommonMark: a backtick fence's info string has no backtick. The link check also ends a block only on a bare run of the same character at least as long as the opening one; prose-lint already did, and keeps its loose indentation for fences nested in list items. #4193 carried a similar change inside a three-area PR and was closed because the link-checker case did not change a workflow; the refusal below is that workflow.

Live evidence

$ git log -1 --format=%h
0326b14
$ printf '\nSee [Unattended runs and artifacts](troubleshooting.md#unattended-runs-and-artifacts) and [ROUTE_BOUNDED_REFUSED](troubleshooting.md#route-bounded-refused).\n' >> docs/unattended.md
$ bun scripts/check-doc-links.ts --base HEAD docs/unattended.md
docs/unattended.md:1045: troubleshooting.md#unattended-runs-and-artifacts: no heading or <a id> for #unattended-runs-and-artifacts; fix: correct the link or add the heading it names
docs/unattended.md:1045: troubleshooting.md#route-bounded-refused: no heading or <a id> for #route-bounded-refused; fix: correct the link or add the heading it names
DOC_LINKS: broken 2
exit=1
$ grep -n '^## Unattended runs and artifacts\|^<a id="route-bounded-refused"' docs/troubleshooting.md
3171:## Unattended runs and artifacts
3377:<a id="route-bounded-refused"></a>

# after (this branch), same added line
$ bun scripts/check-doc-links.ts --base HEAD docs/unattended.md
DOC_LINKS: ok (1 file(s))

# brokenLinks over every tracked Markdown file
main:        23 missing anchors (6 are the false positives above)
this branch: 17 missing anchors, all real (#4320 and the skills.md / review-policy.md links)

# prose-lint on docs/troubleshooting.md
main:        unclosed-block at 4058 ("nothing after it was read"), found=23
this branch: found=72, no unclosed block
# a sentence added after line 5000, linted as /ship does (--base HEAD --gate)
main:        not reported (only the copy added after line 500 is)
this branch: reported at 5002 and at 501

$ bun test test/docs-only.test.ts test/prose-lint.test.ts test/plain-title.test.ts
 123 pass, 0 fail   # both new tests fail on main; the link-check test fails again with either half of its fix reverted
$ bun run typecheck && bun run typecheck:test
test typecheck ratchet: 812 known diagnostics, none new.
$ bin/gstack-prose-lint changelog.d/fix-doc-links-inline-code-fence.md --gate
PROSE_LINT: ok files=1

Scope

  • Changed: unfenced() in lib/doc-links.ts, the fence-opening pattern in lib/prose-lint.ts, one test in each of test/docs-only.test.ts and test/prose-lint.test.ts, and a changelog fragment.
  • Verified live by: the docs-lane command and gstack-prose-lint on main and on this branch (output above), and brokenLinks over the whole repository before and after.
  • Did NOT test: a docs-lane or /ship run in CI. Other fence readers in lib/ (markdown-sections, agent-notes, review-verdict and others) keep their own patterns; only these two were shown to misread a real file. I did not run the full free suite.

Liveness proof (required for external contributors)

Checklist

A line that opens with an inline code span (````x````, as docs/troubleshooting.md:3098 does) opened a fence, and any later run of the same character closed one. On main that hides every heading and <a id> in troubleshooting.md from line 3098 to 3729, so scripts/check-doc-links.ts and the docs lane's pregate refuse six valid links to them and skip the links on those lines.
… prose

Its fence pattern opened a fence on ````x```` at the start of a line, the same misreading the link check had. On docs/troubleshooting.md it masked lines 3098 to 4054 as code, took the bare fence at 4058 for an unclosed block and read nothing after it: 23 of 72 findings, and /ship's --base gate passed a sentence added in that half. A backtick fence now needs an info string without a backtick; indentation stays loose for fences nested in list items.
@trunk-io

trunk-io Bot commented Nov 15, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Thank you. This fixes #4391, and the change to unfenced() is small and matches how CommonMark reads fences. We're taking it. Outside code is rebuilt on current main rather than merged directly, so it will land as a new change with you credited as co-author, and this PR will be closed with a link then (after November 21).

@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for this. We're picking up the idea. A maintainer agent working through a batch of fixes (our tracking thread GSTA-802) will first reproduce the problem on current main. If it reproduces, the agent rebuilds the fix on main with you credited as co-author, because we don't merge outside branches directly, and we'll close this PR with a link when it lands. If it no longer reproduces, we'll close this and say what changed.

@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thanks @Davmunrey. We rebuilt this change on current main and merged it in #4677 (ef72e41), with you credited as co-author. Over every tracked Markdown file it cleared the 6 false broken links and reported no new ones. Closing this PR in favor of that one.

@capy-ai capy-ai Bot closed this Nov 22, 2026
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.

1 participant