Repository navigation
fix: one link reader for validate, the gate and promote; search_smoke on Windows - #113
Merged
Merged
Conversation
pasrom
force-pushed
the
fix/link-tidy
branch
from
November 27, 2026 12:47
8432c96 to
9a7f541
Compare
…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
force-pushed
the
fix/link-tidy
branch
from
November 27, 2026 13:29
9a7f541 to
a236eb4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link-handling tidy-up: one reader for links across
km validate, the gate andkm promote, plus CI and docs. Five commits (CI and docs are split).1. Label lines are not links (
fix(validate)).[Status]: openhas the shape of a reference definition and gave a falsedead-linkwarning; 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 (so1.2and27.11.2026stay text). Known edges:n/aorJ.Doestill read as links; a bare[x]: pagedefinition is no longer checked and no longer creditspage.mdin an_index.md.Tests: index_smoke (label lines silent in a good and a faulty doc;
[s]: sub/gone15still warns), gate_smoke ([Status]: wipnext to a draftwip.mdgives no bergab).2. The gate uses
link_path(refactor(validate)).resolve_pathis gone; body links,relatedandsuperseded_byresolve throughlink_pathwith an existence test as a parameter (gate_known). Parsing and candidate order are shared with the dead-link pass; existence differs on purpose:git add), and outside git only what is on disk;Behaviour changes in the gate:
[a](w%20x.md),[[./wip]],[[wip#sec]]to a draft;@, asresolve_refcuts a ref (related: [d/wip.md@main]and@v1.2still reach the draft);related: ["notes (old)"]isnotes (old).md);[[wiki]]name keeps a?([[why? x]]iswhy? x.md), so[[w?p]]in the glob case is now read as the namew?p;[[dup]]means the doc of its own folder first, before the firstdup.mdelsewhere by sorted path;known_filecatches 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 forlink_targets,link_pathandlink_docwithgate_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.mdinto 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.shruns on Windows. Its stand-inghis a bash script, which Python on Windows cannot start (it runsghonly asgh.exe), so those cases are POSIX-only (GH_STANDIN); 15 of 51 run there. Six docs-only cases pass--no-prson 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 realgh; a local run with the Windows branch forced made zeroghcalls. km prints in the console's code page on Windows by design, so the case-folding case asks it for UTF-8 there. Theforks.jsoncache (kept bykm/search.py) is documented inskills/km/reference/github-reads.md;validate-and-gate.mdstates 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):
%20,[[./wip]],[[wip#sec]], both@refs,notes (old),[[why? x]], both 300-byte names;[[dup]]fails against the resolver on main;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=forbid78/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.