F4 SLICE-1: anchor prune counts proposal anchorIds (closes store.ts F4 TODO) (#12)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ben Stull
2026-06-10 22:02:48 -07:00
parent 652f8619d2
commit d5beb619aa
2 changed files with 32 additions and 2 deletions
+3 -2
View File
@@ -61,8 +61,8 @@ export class CoauthorStore {
* Read-modify-write for sidecar co-ownership (spec F3 §6.2): each controller
* mutates only its own section against a FRESH load, so ThreadController and
* AttributionController never clobber each other. After the mutation, anchors
* referenced by neither threads nor attributions are pruned (proposals are
* still empty in F3 — revisit in F4). `mutate` MUST be synchronous: the
* referenced by no thread, attribution, OR proposal are pruned (threads,
* attributions, and proposals all keep their anchors — F4). `mutate` MUST be synchronous: the
* read-modify-write (and the self-write mark) completes within this call.
*/
update(docPath: string, mutate: (artifact: Artifact) => void): Artifact {
@@ -71,6 +71,7 @@ export class CoauthorStore {
const referenced = new Set<string>([
...artifact.threads.map((t) => t.anchorId),
...artifact.attributions.map((a) => a.anchorId),
...artifact.proposals.map((p) => p.anchorId),
]);
for (const id of Object.keys(artifact.anchors)) {
if (!referenced.has(id)) delete artifact.anchors[id];