Skip to content

fix: one link reader for validate, the gate and promote; search_smoke on Windows - #113

Merged
pasrom merged 5 commits into
mainfrom
fix/link-tidy
Nov 27, 2026
Merged

pasrom merged 5 commits into
mainfrom
fix/link-tidy

Conversation

@pasrom

@pasrom pasrom commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Link-handling tidy-up: one reader for links across km validate, the gate and km promote, plus CI and docs. Five commits (CI and docs are split).

1. Label lines are not links (fix(validate)). [Status]: open has the shape of a reference definition and gave a false dead-link warning; in the gate a bare value could even resolve by name to a draft. A reference definition now counts only when its target looks like a link: <...>, a URL scheme, a / or \, an #anchor, ./.., or a file extension starting with a letter (so 1.2 and 27.11.2026 stay text). Known edges: n/a or J.Doe still read as links; a bare [x]: page definition is no longer checked and no longer credits page.md in an _index.md.
Tests: index_smoke (label lines silent in a good and a faulty doc; [s]: sub/gone15 still warns), gate_smoke ([Status]: wip next to a draft wip.md gives no bergab).

2. The gate uses link_path (refactor(validate)). resolve_path is gone; body links, related and superseded_by resolve through link_path with an existence test as a parameter (gate_known). Parsing and candidate order are shared with the dead-link pass; existence differs on purpose:

  • the gate also counts a doc not yet staged (it runs before git add), and outside git only what is on disk;
  • a path in a mounted brain counts only where that brain is checked out and has it on disk (the dead-link warning still trusts a mount it cannot see).

Behaviour changes in the gate:

  • now caught: [a](w%20x.md), [[./wip]], [[wip#sec]] to a draft;
  • a target is cut at its first @, as resolve_ref cuts a ref (related: [d/wip.md@main] and @v1.2 still reach the draft);
  • a frontmatter value is a name as written, with no title, query or escapes stripped (related: ["notes (old)"] is notes (old).md);
  • a [[wiki]] name keeps a ? ([[why? x]] is why? x.md), so [[w?p]] in the glob case is now read as the name w?p;
  • [[dup]] means the doc of its own folder first, before the first dup.md elsewhere by sorted path;
  • a name longer than the file system holds is no target instead of a Traceback (known_file catches the OSError).

resolve_ref (frontmatter ref warnings) is unchanged.

3. promote reads links as validate does (refactor(promote)). The cross-repo outward-link check drops its own patterns and resolver for link_targets, link_path and link_doc with gate_known. Intended changes: a folder link, a %-escaped name, a label line and a link in a ~~~ fence no longer refuse a promote. Unchanged: a gitignored target is dead, an unstaged doc resolves, and a path into a mounted brain that is not checked out is refused. New cases: those link forms pass; ../brains/peer/nope.md into an uninitialised mount, an unclosed [[ before 300 bytes and a 300-byte file name are refused without a crash.

4. CI and docs (ci(windows), docs(skill)). search_smoke.sh runs on Windows. Its stand-in gh is a bash script, which Python on Windows cannot start (it runs gh only as gh.exe), so those cases are POSIX-only (GH_STANDIN); 15 of 51 run there. Six docs-only cases pass --no-prs on Windows only ($NOPRS), so on POSIX they still cover the PR path. On Windows any stray call goes to a refusing proxy, never to the runner's real gh; a local run with the Windows branch forced made zero gh calls. km prints in the console's code page on Windows by design, so the case-folding case asks it for UTF-8 there. The forks.json cache (kept by km/search.py) is documented in skills/km/reference/github-reads.md; validate-and-gate.md states the reference-definition rule. SKILL.md is unchanged (11992 bytes). Both are skill reference text: evals not run.

Mutation checks (fix reverted, new cases fail):

  • item 1: 2 index and 2 gate cases;
  • item 2: %20, [[./wip]], [[wip#sec]], both @ refs, notes (old), [[why? x]], both 300-byte names; [[dup]] fails against the resolver on main;
  • item 3: the link-forms case, the uninitialised-mount case and both 300-byte cases.

Local runs (all suites the smoke job runs, plus encoding_smoke): gate 393, index 82, pins 38, cites 90, doctor 103, list 45, ready 28, search 51, automerge 139, signoff 136, skill 5, hook 31, mounted_pins 2, runner 31, action 13, e2e 40, e2e_agent 121, team 278, encoding 4, sync (uv) 79, all passing. sync with KM_TEST_UV=forbid 78/1: its precondition fails because uv is on PATH on this machine, same as on main.

Review: simplify and code-review were done as one manual pass over the diff, with no parallel reviewers, then a separate review whose findings are folded into the commits above.

…a link

A line of the shape [label]: value is a reference definition to Markdown, so
the dead-link pass, the gate and the index lint read 'open' as a link target:
a false dead-link warning, and in the gate a bare name that could resolve to a
draft. A reference definition now counts only when its target looks like a
link: angle brackets, a URL scheme, a / or \, an #anchor, . or .., or a file
extension starting with a letter (so 1.2 and 27.11.2026 stay text).
The gate kept a resolver of its own (resolve_path), so it read a link
differently from the dead-link pass: no %-escapes, Markdown escapes, angle
brackets in a reference definition or NFC names, and a [[wiki]] target only
by its bare name. It now goes through link_path with the existence test as a
parameter (gate_known): a file a clone will have, staged or not yet (the
gate runs before git add; a gitignored file is none), or a path the brain's
own index lists. A path in a mounted brain counts only where it is checked
out and on disk; outside git only what is on disk.

A target is cut at its first @, as resolve_ref cuts a ref. A [[wiki]] name
keeps a ? (no query) and is tried as <target>.md before it is looked up by
name, so [[dup]] means the doc of its own folder first. A frontmatter value
(related, superseded_by) is a name as written: no title, query or escapes are
stripped. known_file counts a path the file system cannot hold (a name over
its length limit) as no file instead of failing. resolve_path is gone;
link_targets now yields (target, is_wiki) pairs for the gate and the index lint.
…ink_path

promote's cross-repo check had its own link patterns and resolver, so it
refused links km validate accepts: a folder link, a %-escaped name, a label
line such as [Status]: open, a link inside a ~~~ fence. It now uses
link_targets, link_path and link_doc with the gate's existence test
(gate_known): a gitignored file is still dead, a doc not yet staged still
resolves, and a path into a mounted brain that is not checked out is
refused, as before.
The cases that need the stand-in gh run on POSIX only: on Windows Python
starts gh only as gh.exe, so a bash script on the PATH cannot answer. The
others (docs search, case folding, mounts, usage errors, the internal error
path) run everywhere; on Windows they pass --no-prs or stop before GitHub,
and a call that slips through goes to a proxy that refuses it rather than to
the runner's own gh. km prints in the console's code page there, so the
case-folding case asks it for UTF-8.
Where forks.json lives (km-search/ under the common git dir), what it maps,
that an entry is written once and never refreshed, when it is not read
(an upstream remote, km.fork false for the origin) and how to clear it.
@pasrom
pasrom merged commit 89ea376 into main Nov 27, 2026
5 checks passed
@pasrom pasrom mentioned this pull request Nov 27, 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