feat: wiki-links by id — id-first resolution + heph.nvim [[ picker (§8.4)
Some checks failed
Build / validate (pull_request) Failing after 6m34s

Backend: `links::resolve_id` now checks for an exact live node id before
alias/title, so a canonical `[[NODEID]]` link resolves to its node and
can't be shadowed by a like-named node. Legacy `[[Name]]` links still
resolve by name (until the migration), so this is additive.

heph.nvim: `link.insert` (bound to insert-mode `[[` and `:Heph link`)
searches via the `search` RPC and inserts `[[NODEID]]`, with a "+ Create
new doc" entry; `<CR>` follow resolves the id directly. e2e covers
search→insert→materialize and the create path.

Remaining (§8.4): read-expansion/conceal display + the one-time
[[Title]]→[[NODEID]] migration (then retire name-resolution + the hack).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-06-03 12:07:46 -07:00
commit 4e8f6743cf
7 changed files with 139 additions and 9 deletions

View file

@ -169,6 +169,15 @@ pub(super) fn sync_wiki_links(
/// first, then an exact title. `None` if nothing matches. Shared by `wiki`
/// link materialization and the `node.resolve` surface (tech-spec §5, §6).
pub(super) fn resolve_id(conn: &Connection, owner: &str, target: &str) -> Result<Option<String>> {
// 1. An exact **node id** — the canonical at-rest link form (`[[NODEID]]`,
// tech-spec §8.4). Checked first so id-addressed links never collide with a
// like-named node. (Legacy `[[Name]]` links still resolve below, until the
// one-time migration rewrites them.)
if let Some(node) = super::nodes::get(conn, target)? {
if node.owner_id == owner && !node.tombstoned {
return Ok(Some(node.id));
}
}
let by_alias: Option<String> = conn
.query_row(
"SELECT n.id FROM aliases a JOIN nodes n ON n.id = a.node_id