Article nodes and annotation anchors in the library

A node per annotated Wikipedia article, created with its first annotation
under one container: a section of the library root flagged articles. It is
not a document (sections() and documents() skip it, it has no slug), its
nodes never go stale, the link scanner, the vector index, the title index
and the backlinks index leave it out, and a prompt about an annotation
carries its article's node rather than the whole container.

An annotation is an ordinary note under the article's node whose anchor is
a WikiAnchor (headings, exact words, context either side, revision) instead
of CRDT cursors. reanchor() finds it again in a later revision: its own
section, then anywhere, exactly, then tolerantly, never inside other words;
otherwise it is detached. Two replicas annotating a new article at once keep
both nodes; readers take annotations from all of them and write under the
first, so they read as one. The new fields hash only when set, so old
commits still verify. Property tests for re-anchoring, a convergence test,
and the tasks that write a note from an article's lead and section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Opus 5.5 committed 2026-11-15 21:53:00 -05:00
1 parent 02e044af35
commit f63fc10dc0
8 files changed
+502 -18

No files matched your search

+3 -2
View File
@@ -5,6 +5,7 @@
* request that made the edit (a section whose text is unchanged is skipped by its hash). Without a
* model the index still holds the texts, so BM25 search works and "related" is text-only.
*/
import { inArticles } from "../../src/core/article";
import { Doc, docOf, isLibraryRoot, type NodeId, type Snap } from "../../src/core/model";
import { plain } from "../../src/core/text";
import { VectorIndex, type Embedder, type Hit, type HybridHit } from "../embed";
@@ -15,10 +16,10 @@ const nodeText = (snap: Snap, id: NodeId) => {
return `${n.title}\n${plain(n.body)}`.trim();
};
/** Sections (and documents) worth indexing: not the library root, not notes, and with some text. */
/** Sections (and documents) worth indexing: not the library root, not notes, not the Wikipedia container's, and with some text. */
const indexable = (snap: Snap, id: NodeId) => {
const n = snap.nodes[id];
return !!n && n.kind === "section" && !isLibraryRoot(snap, id) && (n.body.trim().length > 0 || n.title.trim().length > 0);
return !!n && n.kind === "section" && !isLibraryRoot(snap, id) && !inArticles(snap, id) && (n.body.trim().length > 0 || n.title.trim().length > 0);
};
interface IndexStatus {