Skip to content

fix(links,notes): id-form backlinks, a way to fix a title, and stop eating one - #166

Merged
navbytes merged 2 commits into
mainfrom
claude/fix-id-backlinks-and-titles
Jul 28, 2026
Merged

navbytes merged 2 commits into
mainfrom
claude/fix-id-backlinks-and-titles

Conversation

@navbytes

Copy link
Copy Markdown
Owner

Tier 1 of the field-test backlog — four interlocking problems about titles and links. They belong together because each one made the others unrecoverable.

1. [[<id>]] produced no backlink

SKILL.md promises, verbatim: "Use [[note-slug]] or [[<id>]] … backlinks are found automatically." And Resolve accepts the 6-char short id — which is what nt prints at creation, in nt index, nt search and nt recall.

But references() matched only the full ULID. So an id-form link resolved forward while the target reported linked from: (none), and nt links --orphans called it an orphan.

Backlink discovery now accepts the short form, restricted to Crockford base32 (the ULID alphabet — no I/L/O/U) so an ordinary slug can't be misread as an id suffix. Resolve gets to disambiguate against the real note list; this function doesn't, so it deliberately errs narrow. The candidate scan also runs for an id-only target now, so short-id links to tasks are found too.

2. A path-style title silently overrode --kind and deleted a word

The guard rejected a slash only when the prefix contained whitespace. So any title opening with a bare directory token was read as filing syntax:

$ nt note "internal/cli test-gap audit" --kind ref
note 425J53  notes/internal/cli-test-gap-audit.md

Filed under internal/ — not ref/ — with "internal" stripped from the title permanently. 94e0ab1 fixed the whitespace case; this is the other half.

Three of five field-test agents hit this independently, which is the strongest signal in the whole exercise.

Now: an explicit --kind suppresses the inference, the way --folder already did. And when the shorthand does fire it says so on stderr, rather than leaving the created path as the only clue. nt note "custom/x" with no flags is unchanged.

⚠️ This changes documented behavior. TestNotePathStyleTitleBeatsKindFolder pinned path-style beating --kind as deliberate, so it's replaced by two tests stating the new precedence. The justification is that the old rule didn't just choose a folder — it destroyed part of the title, with no way to put it back (see #3).

3. There was no way to fix a title from the CLI

nt edit had --desc but no --title. And nt mv pins the old title into frontmatter, where it beats the body H1 — so editing the H1 changed nothing visible. The only escapes were --supersede (new id, every inbound link broken) or hand-editing frontmatter, which is what one field-test agent actually resorted to.

nt edit --title sets both, rewriting a leading H1 only when it still carries the previous title (an H1 the author chose independently is left alone). This is also the recovery path for #2.

4. nt mv didn't slug its destination

nt mv <note> "ref/My Long Name" wrote a file with literal spaces — the only file in the store nt hadn't slugged, unlike nt note, which always does.

Tests

Regression tests for all four. The backlink test was confirmed to fail against the unfixed code before committing. A companion test pins that a non-id slug link does not create a spurious backlink, covering the Crockford guard.

go build, go vet ./..., go test ./... all clean.


Generated by Claude Code

claude added 2 commits July 28, 2026 14:43
…ating one

Tier 1 of the field-test backlog — four interlocking problems about titles and
links, all of which ended in something unrecoverable.

**`[[<id>]]` produced no backlink**, though SKILL.md promises "[[note-slug]] or
[[<id>]] … backlinks are found automatically" and Resolve accepts the 6-char
short id nt prints at creation, in index, search and recall. references() only
ever matched the full ULID, so an id-form link resolved FORWARD while the
target showed "linked from: (none)" and `nt links --orphans` called it an
orphan. Backlink discovery now accepts the short form too, restricted to
Crockford base32 (the ULID alphabet, no I/L/O/U) so an ordinary slug can't be
misread as an id suffix — Resolve disambiguates against the real note list,
this function can't, so it errs narrow. The candidate scan also runs for an
id-only target now, so short-id links to TASKS are found as well.

**A path-style title silently overrode --kind and deleted a word.** The guard
only rejected prefixes containing whitespace, so any title opening with a bare
directory token — "internal/cli test-gap audit", "README/SPEC drift", "CI/CD"
— was read as filing syntax: filed under internal/, with "internal" stripped
from the title for good. Three of five field-test agents hit this
independently. An explicit --kind (like --folder already did) now suppresses
the inference, and when the shorthand does fire it says so on stderr instead of
leaving the created path as the only clue. `nt note "custom/x"` with no flags
is unchanged.

**There was no way to fix a title from the CLI.** `nt edit` had --desc but no
--title, and `nt mv` pins the OLD title into frontmatter where it beats the
body H1 — so editing the H1 changed nothing visible and the only escape was
--supersede (new id, every inbound link broken) or hand-editing frontmatter.
`nt edit --title` sets both, rewriting a leading H1 only when it still carries
the previous title. This is also the recovery path for the truncation above.

**`nt mv` didn't slug its destination**, so a human-readable name produced the
one file in the store with literal spaces in it, unlike `nt note` which always
slugs.

Regression tests for all four; the backlink one was confirmed to fail against
the unfixed code. TestNotePathStyleTitleBeatsKindFolder is replaced by two
tests stating the new precedence, since it pinned the behavior being changed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgqQf7Lvou5F5as9aNmagu
@navbytes
navbytes marked this pull request as ready for review July 28, 2026 14:50
@navbytes
navbytes merged commit 64b9e4e into main Jul 28, 2026
9 checks passed
@navbytes
navbytes deleted the claude/fix-id-backlinks-and-titles branch July 28, 2026 14:58
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.

2 participants