Skip to content

docs: fail on any relative docs path in a doc comment and complete the retry guidance - #8

Merged
kiwidream merged 1 commit into
release/0.1.1from
devex/late-review-nits-2
Oct 29, 2026
Merged

kiwidream merged 1 commit into
release/0.1.1from
devex/late-review-nits-2

Conversation

@kiwidream

@kiwidream kiwidream commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes for the three nits qbit-reviewer posted on #7 after it merged, plus what local reviews of those fixes found:

  • Retry guidance for a signer that can't re-sign. docs: fix late review findings on signing retries, retryAfterMs and doc links #7 said such a signer is left out of the retry's keys and the other plans are then signed without it. That isn't safe when another entry depends on the dropped key. The README, the signing page and the P2mrPsbtSigningError TSDoc now give the full rule:
    • Drop the signer's entry, or have sign return undefined for it. Throwing stops the retry at the same plan again.

    • Also drop every entry that can no longer help finalize the transaction:

      • the other entries for a leaf that can't complete without the dropped key, such as a multi_a leaf left short of its threshold;
      • every entry, when an input is left with no leaf that can complete.

      Signing those spends key uses for nothing.

  • Relative docs paths. check-doc-links.mjs no longer tries to recognize each link form. It enforces one rule: in a doc comment, outside code, a relative path into a docs directory fails, as a link target or as plain text. Examples are docs/x.md, ../docs/x.md#a, ./docs/ and ../docs, in any case, including inside emphasis or before sentence punctuation. Neither TypeDoc nor an IDE hover resolves such a path against the repository, so a doc comment links a topic page by its URL.
    • Code means fenced blocks, which open and close as in the script's heading slugger, and code spans. Code spans may wrap lines but not cross a paragraph, and an escaped backtick doesn't open one.
    • A bare docs or docs#x is a word or a declaration reference, so it passes.
    • A doc comment is a /** at the start of a line or after whitespace, so a trailing /** … */ after code is checked and a glob string such as 'src/**' isn't.
    • The doc comments that still named a topic page by a relative path now link it by URL. That's one in plain text on p2mrSighash and three in code spans in the api client. CONTRIBUTING describes the check.
  • Absolute links. A token counts as absolute only with // after an optional scheme (HTTPS:, ftp:, any case), so Note:../docs/x.md is still caught. Before, only lower-case http: and https: targets counted.

Testing

  • The script runs a self-test first: 23 samples it must flag, 12 it must pass, and 3 doc-comment detection cases.
  • Each of 18 mutations of the rule makes the self-test fail. The mutations cover:
    • every part of the path pattern
    • token trimming
    • absolute detection
    • fence opening and closing
    • code-span escapes, paragraphs, wrapping and backtick runs
    • doc-comment detection
  • A relative link planted in packages/api/src/index.ts, wrapped across two comment lines, is reported at its file and line. A path in a code span next to it is not.
  • pnpm format:check, pnpm docs:api:check (111 links) and pnpm typecheck pass.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…e retry guidance

- A stateful signer that cannot sign the same digest twice has its entry
  dropped from the retry's keys, or sign returns undefined for it, since a
  throw would stop the retry at the same plan again. The retry also drops
  every entry that can no longer help finalize the transaction: the other
  entries for a leaf that cannot complete without that key, and every
  entry when an input is left with no leaf that can complete. The README,
  the signing page and the P2mrPsbtSigningError TSDoc say so.
- check-doc-links.mjs fails on a relative path into a docs directory
  anywhere in a doc comment outside code, in a link or in plain text,
  instead of trying to recognize each link form. A token is absolute only
  with // after an optional scheme, in any case. A self-test pins the rule.
- The doc comments that still named a topic page by a relative path
  (p2mrSighash, three in the api client) link it by URL, and CONTRIBUTING
  describes the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T19:53:05.488989Z 446ca28 PR opened
ℹ️ 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 review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kiwidream
kiwidream merged commit 6248d1b into release/0.1.1 Oct 29, 2026
3 checks passed
@kiwidream
kiwidream deleted the devex/late-review-nits-2 branch October 29, 2026 19:52

@qbit-reviewer qbit-reviewer 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.

Approved: a complete review with no bugs found.

3 findings posted inline.

// repository, as a link target or as plain text, so a doc comment links a
// topic page by its URL instead. A bare `docs` or `docs#x` is a word or a
// declaration reference, not a path.
const RELATIVE_DOCS_PATH = /(?:^|[/=])docs\/|\/docs(?:[#?]|$)/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1. [low · nit] RELATIVE_DOCS_PATH misses docs/ glued to ':' (e.g. [x]​:docs/x.md) and a bare ../docs right before */

scripts/check-doc-links.mjs:34

Case 1: a doc comment line such as * [guide]​:docs/x.md is a valid CommonMark link reference definition. So is Note:docs/x.md. URL_TOKEN (line 23) splits the first at ], giving the token :docs/x.md. TOKEN_TRIM (line 36) strips only *_~ from the front, so the : stays. RELATIVE_DOCS_PATH then needs start, / or = before docs/, so nothing is reported. Case 2: in /** pages in ../docs*/ the token is ../docs*/. Nothing gets trimmed and neither branch matches. The self-test only covers : ../docs and :../docs, where a / comes before docs. Either way, the check passes a relative docs path, which contradicts CONTRIBUTING's 'anywhere in a doc comment outside code'.

Suggested change
const RELATIVE_DOCS_PATH = /(?:^|[/=])docs\/|\/docs(?:[#?]|$)/i
const RELATIVE_DOCS_PATH = /(?:^|[^\w.-])docs\/|\/docs(?:[#?]|\*\/|$)/i

const ABSOLUTE = /^(?:[a-z][a-z0-9+.-]*:)?\/\//i
// A doc comment: a `/**` at the start of a line or after whitespace. One glued
// to other text, as in a glob string, is not.
const DOC_COMMENT = /(?:^|(?<=[ \t]))\/\*\*(?!\/)[\s\S]*?\*\//gm

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2. [low · nit] DOC_COMMENT ignores doc comments glued to '(' or '{', a regression from the old every-line check

scripts/check-doc-links.mjs:42

DOC_COMMENT only accepts /** at the start of a line or after a space or tab. Take function f(/** see [x]​(../docs/x.md) */ a: number) or {/** ../docs/x.md */ a: 1}. TypeScript and TypeDoc attach these comments to the parameter or member, but the comment is never matched, so relativeDocsPaths never sees it (lines 184-185). The old RELATIVE_DOC_LINK ran on every line and flagged ]​(../docs/x.md there. The same boundary also takes a /** after whitespace inside a string or a // comment as a doc comment that runs to the next */, which could flag code as prose. Neither form occurs in packages/*/src today.

.map(line => {
const prefix = /^(?:[ \t]*\/\*\*|[ \t]*\*(?!\/))?[ \t]?/.exec(line)[0]
const content = line.slice(prefix.length)
const marker = /^\s{0,3}(`{3,}|~{3,})(.*)$/.exec(content)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3. [low · nit] A line starting with a ​code ​span is taken as a fence opener, which blanks the rest of the comment

scripts/check-doc-links.mjs:56

Take the doc comment line * ```​foo``` ​see ../docs/x.md. CommonMark does not let a backtick fence's info string contain backticks, so this line is an inline code span followed by prose. The marker regex at line 56 matches it anyway. Lines 58-60 then set fence, and since no bare closing run follows, that line and every later line of the comment are blanked as code. A relative docs path there is never reported.

Suggested change
const marker = /^\s{0,3}(`{3,}|~{3,})(.*)$/.exec(content)
const marker = /^\s{0,3}(`{3,}(?=[^`]*$)|~{3,})(.*)$/.exec(content)

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