Skip to content

check-docs: ignore link-shaped text in inline code spans without hiding real links #201

Closed

Description

@frostyard-machines

Problem

scripts/check-docs.mjs strips fenced code blocks, but not inline code spans, before it finds Markdown links. A Go generic call in inline code, such as errors.AsType[T](err) or reflect.TypeAssert[T](v), matches the link pattern \[[^\]]*\]\(([^)\s]+)\) and fails the gate as a broken link.

core#200 (vendored Go skills) worked around 3 such calls in .agents/skills/golang-error-handling/SKILL.md, .agents/skills/golang-safety/SKILL.md and .agents/skills/golang-modernize/references/versions.md. Each call is split into the code span X[T] and a code span for the argument list, and each carries a marked <!-- Frostyard override --> comment (see docs/design/shared-skills.md, "Vendored Go skills"). A gate that understands code spans can remove these overrides.

Attempt in core#200 and why it was dropped

core#200 tried a code-span stripper in check-docs.mjs. The cross-review (openai/gpt-6.1-sol) found 10 points over 5 rounds. 5 were in the stripper (1 per round), and each time a real broken link could be hidden from the gate. Brian chose to drop the parser from #200 (T928b). The stripper findings, split into 6 test cases, are the test corpus for a later PR:

  1. A regex `[^`\n]*` removes a real link between escaped backticks: \` [x](missing.md) \`.
  2. Delimiter runs must match by length (CommonMark): a [x](missing.md) `` `` is 1 span, and `` `` [x](missing.md) `` is an unclosed run, so the link is checked.
  3. Spans must not pair across blocks: adjacent headings # First ` / # [x](missing.md) `.
  4. A span that wraps over lines: `code / continued` [x](missing.md) `tail` . If the closer of the wrapped span is read as a new opener, the link is hidden.
  5. A GFM table cell boundary splits inline contexts: | ` | [x](missing.md) ` |.
  6. Raw HTML and autolinks can hold a literal backtick: <span title="`">[x](missing.md)`</span> and the email autolink <1`@example.com> [x](missing.md) ` .

Of the other 5 findings, 4 were in scripts/sync-skills.sh and its tests (config shape, 1 JSON document, empty skill list, a push assertion that could not fail) and 1 was a description count in the design doc. #200 fixed them and keeps them.

Proposed direction

  • A conservative rule that never hides a real link: strip a code span only where no line in its blank-line-separated run has an unpaired backtick run, a |, or a < (case 6 shows that a narrower < rule is not enough). Otherwise check every link in the run.
  • Alternative: parse with a CommonMark/GFM library (for example markdown-it) and collect link nodes. This adds a dependency and changes how links are found (reference links, autolinks), so it needs its own decision.
  • Each of the 6 cases above becomes a test in test/docs-integrity.test.mjs, and each must make the gate fail on missing.md. Add 1 positive test: a fully paired X[T](v) code span passes.
  • After the merge, remove the 3 overrides from the vendored Go skills.

Risk: check-docs.mjs is a quality gate; the PR needs a cross-review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions