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
@@ -17,6 +17,7 @@
|
||||
* strongest kept. See judge() for the rule. Only phrases and search queries go to Wikipedia;
|
||||
* embeddings are local.
|
||||
*/
|
||||
import { inArticles } from "../../src/core/article";
|
||||
import { docOf, notesOf, sections, ancestors as ancestorsOf, descendants, type Doc, type NodeId, type Snap } from "../../src/core/model";
|
||||
import { nodeRef } from "../../src/core/links";
|
||||
import type { Mark } from "../../src/core/marks";
|
||||
@@ -304,7 +305,7 @@ function titleIndex(snap: Snap): Map<string, NodeId[]> {
|
||||
ix = new Map();
|
||||
for (const id in snap.nodes) {
|
||||
const n = snap.nodes[id as NodeId];
|
||||
if (n.kind !== "section" || !n.parent) continue;
|
||||
if (n.kind !== "section" || !n.parent || inArticles(snap, n.id)) continue;
|
||||
const key = titleKeyOf(n.title);
|
||||
if (!key) continue;
|
||||
const list = ix.get(key) ?? [];
|
||||
|
||||
Reference in new issue
Block a user