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:
1 parent
02e044af35
commit
f63fc10dc0
8 files changed
+502
-18
No files matched your search
+5
-2
@@ -74,7 +74,7 @@ export class LinkIndex {
|
||||
for (const [id, before] of was) {
|
||||
if (before?.ref) this.file(id, before.ref, false);
|
||||
const after = nodes[id];
|
||||
if (after?.ref) this.file(id, after.ref, true);
|
||||
if (after?.ref && !articleNode(nodes, after)) this.file(id, after.ref, true);
|
||||
}
|
||||
});
|
||||
this.rebuild(doc.snap().nodes);
|
||||
@@ -86,7 +86,7 @@ export class LinkIndex {
|
||||
this.unresolved.clear();
|
||||
for (const id in nodes) {
|
||||
const r = nodes[id as NodeId].ref;
|
||||
if (r) this.file(id as NodeId, r, true);
|
||||
if (r && !articleNode(nodes, nodes[id as NodeId])) this.file(id as NodeId, r, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,9 @@ export class LinkIndex {
|
||||
}
|
||||
}
|
||||
|
||||
/** An article's own node in the Wikipedia container (article.ts) is where its annotations hang, not a mention of it. */
|
||||
const articleNode = (nodes: Record<NodeId, NodeSnap>, n: NodeSnap) => !!n.parent && !!nodes[n.parent]?.articles;
|
||||
|
||||
const indexes = new WeakMap<Doc, LinkIndex>();
|
||||
/** The backlinks index of a library, made on first use and kept current from then on. */
|
||||
export function linkIndex(doc: Doc): LinkIndex {
|
||||
|
||||
Reference in new issue
Block a user