Lock, not pin: the flag that keeps the model from rewriting a node
The badge reads LOCKED, the status line and messages say lock and unlock, p's help says what it is and that it is not P, and the cascade says a locked node was flagged, not rewritten. Pin now means only a pane's pin. The stored flag and the op API keep the old name, pinned, so a live library keeps its locks. 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
edc31aac9a
commit
abf79c14cc
8 files changed
+21
-18
No files matched your search
@@ -63,7 +63,8 @@ Press `?` for every key. The short version:
|
|||||||
two gets an inline gloss, a sentence a margin note, several sentences an inset passage, a node
|
two gets an inline gloss, a sentence a margin note, several sentences an inset passage, a node
|
||||||
child sections.
|
child sections.
|
||||||
- `c` edits, `r` renames, `a` adds, `D` deletes, `u` undoes (the last edit made in this tab,
|
- `c` edits, `r` renames, `a` adds, `D` deletes, `u` undoes (the last edit made in this tab,
|
||||||
wherever it was). On a node, `:` hands an instruction to the editor agent; `Esc` stops it.
|
wherever it was). `p` locks a node: the model never rewrites a locked node (your own edits lock
|
||||||
|
it). Locking is not pinning: a pin (`P`) keeps a pane open in the panes view. On a node, `:` hands an instruction to the editor agent; `Esc` stops it.
|
||||||
- `g` opens history: commits, branches, conflicts. `f` shows only what touched the current
|
- `g` opens history: commits, branches, conflicts. `f` shows only what touched the current
|
||||||
document; `r` reverts the current document to a commit, leaving the rest of the library alone.
|
document; `r` reverts the current document to a commit, leaving the rest of the library alone.
|
||||||
- The library is the first page. `l` or `Enter` opens a document in place; `h` or `Esc` at its top
|
- The library is the first page. `l` or `Enter` opens a document in place; `h` or `Esc` at its top
|
||||||
@@ -196,8 +197,9 @@ What is sent where:
|
|||||||
writer: the keyboard, the editor agent and `POST /api/ops`.
|
writer: the keyboard, the editor agent and `POST /api/ops`.
|
||||||
- **Staleness is computed, not stored.** Each node remembers a hash of the children and of the
|
- **Staleness is computed, not stored.** Each node remembers a hash of the children and of the
|
||||||
parent text it was last reconciled with; a mismatch makes it stale in that direction. A person's
|
parent text it was last reconciled with; a mismatch makes it stale in that direction. A person's
|
||||||
edits pin a node: flagged when stale, never rewritten. The library and its documents are not
|
edits lock a node: flagged when stale (LOCKED beside it), never rewritten. `p` locks or unlocks
|
||||||
reconciled with each other.
|
one by hand; the flag keeps its old name, `pinned`, in the data and the op API, so existing
|
||||||
|
libraries keep their locks. The library and its documents are not reconciled with each other.
|
||||||
- **Snapshots are patched, not rebuilt**: a change re-reads only the nodes it wrote, so an edit
|
- **Snapshots are patched, not rebuilt**: a change re-reads only the nodes it wrote, so an edit
|
||||||
costs what it touches, whatever the size of the library.
|
costs what it touches, whatever the size of the library.
|
||||||
- **`src/core/repo.ts`** Every commit records the SHA-256 of the tree, so any checkout can be
|
- **`src/core/repo.ts`** Every commit records the SHA-256 of the tree, so any checkout can be
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ export interface NodeSnap {
|
|||||||
title: string;
|
title: string;
|
||||||
body: string;
|
body: string;
|
||||||
by: Actor;
|
by: Actor;
|
||||||
/** Pinned nodes are flagged when stale but never rewritten by a model. Human edits pin. */
|
/** Locked: flagged when stale but never rewritten by a model. Human edits lock. (Stored as `pinned`, its old name, so existing libraries keep their flags.) */
|
||||||
pinned: boolean;
|
pinned: boolean;
|
||||||
form?: Form;
|
form?: Form;
|
||||||
lens?: string;
|
lens?: string;
|
||||||
|
|||||||
+3
-3
@@ -243,7 +243,7 @@ export async function reconcile(llm: LLM, doc: Doc, id: NodeId, onText: OnText =
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CascadeEvent {
|
export interface CascadeEvent {
|
||||||
kind: "decide" | "rewrite" | "keep" | "pinned" | "revise";
|
kind: "decide" | "rewrite" | "keep" | "locked" | "revise";
|
||||||
node: NodeId;
|
node: NodeId;
|
||||||
text: string;
|
text: string;
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ export async function cascade(
|
|||||||
let i = 0;
|
let i = 0;
|
||||||
for (; i < levels; i++) {
|
for (; i < levels; i++) {
|
||||||
if (doc.snap().nodes[chain[i]]?.pinned) {
|
if (doc.snap().nodes[chain[i]]?.pinned) {
|
||||||
emit({ kind: "pinned", node: chain[i], text: "pinned: flagged, not rewritten" });
|
emit({ kind: "locked", node: chain[i], text: "locked: flagged, not rewritten" });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (await regenUp(llm, doc, chain[i], noop, opts.signal, opts.hooks)) emit({ kind: "rewrite", node: chain[i], text: "re-summarised" });
|
if (await regenUp(llm, doc, chain[i], noop, opts.signal, opts.hooks)) emit({ kind: "rewrite", node: chain[i], text: "re-summarised" });
|
||||||
@@ -297,7 +297,7 @@ export async function cascade(
|
|||||||
snap = doc.snap();
|
snap = doc.snap();
|
||||||
if (!snap.nodes[c] || !staleness(snap, c).down || !rendered(c)) continue;
|
if (!snap.nodes[c] || !staleness(snap, c).down || !rendered(c)) continue;
|
||||||
if (snap.nodes[c].pinned) {
|
if (snap.nodes[c].pinned) {
|
||||||
emit({ kind: "pinned", node: c, text: "pinned: flagged, not rewritten" });
|
emit({ kind: "locked", node: c, text: "locked: flagged, not rewritten" });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (await regenDown(llm, doc, c, noop, opts.signal, opts.hooks)) {
|
if (await regenDown(llm, doc, c, noop, opts.signal, opts.hooks)) {
|
||||||
|
|||||||
+1
-1
@@ -391,7 +391,7 @@ function StatusLine() {
|
|||||||
: "Enter open/enter · e toggle · D delete note · w link it"
|
: "Enter open/enter · e toggle · D delete note · w link it"
|
||||||
: `e expand${store.generating ? "" : " (no model)"} · d define · y why · x example · c challenge · : ask · w link`
|
: `e expand${store.generating ? "" : " (no model)"} · d define · y why · x example · c challenge · : ask · w link`
|
||||||
: st.up || st.down
|
: st.up || st.down
|
||||||
? `stale · ${n.pinned ? "b accept · p unpin" : "R reconcile · b accept"}`
|
? `stale · ${n.pinned ? "b accept · p unlock" : "R reconcile · b accept"}`
|
||||||
: "";
|
: "";
|
||||||
return (
|
return (
|
||||||
<footer class="status">
|
<footer class="status">
|
||||||
|
|||||||
+2
-2
@@ -168,7 +168,7 @@ export function NoteView({ v, inNote }: { v: VNote; inNote: boolean }) {
|
|||||||
const meta = (lens || stale || (v.id && snap.nodes[v.id].pinned)) && (
|
const meta = (lens || stale || (v.id && snap.nodes[v.id].pinned)) && (
|
||||||
<span class="meta">
|
<span class="meta">
|
||||||
{lens}
|
{lens}
|
||||||
{v.id && snap.nodes[v.id].pinned ? " · pinned" : ""}
|
{v.id && snap.nodes[v.id].pinned ? " · locked" : ""}
|
||||||
{stale ? " · stale" : ""}
|
{stale ? " · stale" : ""}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@@ -354,7 +354,7 @@ export function Flags({ id }: { id: NodeId }) {
|
|||||||
conflict && "conflict",
|
conflict && "conflict",
|
||||||
st.up && "sections changed",
|
st.up && "sections changed",
|
||||||
st.down && "parent changed",
|
st.down && "parent changed",
|
||||||
n.pinned && n.parent && "pinned",
|
n.pinned && n.parent && "locked",
|
||||||
].filter(Boolean) as string[];
|
].filter(Boolean) as string[];
|
||||||
if (!flags.length) return null;
|
if (!flags.length) return null;
|
||||||
return <span class={`flags${st.up || st.down || conflict ? " attn" : ""}`}>{flags.join(" · ")}</span>;
|
return <span class={`flags${st.up || st.down || conflict ? " attn" : ""}`}>{flags.join(" · ")}</span>;
|
||||||
|
|||||||
+2
-2
@@ -57,7 +57,7 @@ export const HELP: [string, [string, string][]][] = [
|
|||||||
["D", "delete (no confirmation; u undoes)"],
|
["D", "delete (no confirmation; u undoes)"],
|
||||||
["J K", "move down / up among siblings"],
|
["J K", "move down / up among siblings"],
|
||||||
["> <", "indent / outdent (a document's sections can be moved into another this way, or over HTTP)"],
|
["> <", "indent / outdent (a document's sections can be moved into another this way, or over HTTP)"],
|
||||||
["p", "pin or unpin: pinned nodes are never rewritten by the model"],
|
["p", "lock or unlock: a locked node is never rewritten by the model (your own edits lock it). Not the same as P, which pins a pane"],
|
||||||
["f", "on a note: cycle its form (inline · margin · inset)"],
|
["f", "on a note: cycle its form (inline · margin · inset)"],
|
||||||
[":", "on a node: tell the editor agent what to change"],
|
[":", "on a node: tell the editor agent what to change"],
|
||||||
["u U", "undo / redo: the last edit made in this tab, in whichever document it was"],
|
["u U", "undo / redo: the last edit made in this tab, in whichever document it was"],
|
||||||
@@ -465,7 +465,7 @@ export function handleKey(e: KeyboardEvent, hooks: KeyHooks) {
|
|||||||
store.indent(-1);
|
store.indent(-1);
|
||||||
break;
|
break;
|
||||||
case "p":
|
case "p":
|
||||||
store.togglePin();
|
store.toggleLock();
|
||||||
break;
|
break;
|
||||||
case "f":
|
case "f":
|
||||||
store.cycleForm();
|
store.cycleForm();
|
||||||
|
|||||||
+6
-5
@@ -1925,11 +1925,12 @@ class Store {
|
|||||||
this.emit();
|
this.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePin() {
|
/** p: lock or unlock a node. A locked node is never rewritten by a model (stored as `pinned`, its old name). */
|
||||||
|
toggleLock() {
|
||||||
if (!this.writable()) return;
|
if (!this.writable()) return;
|
||||||
const n = this.snap.nodes[this.focus.node];
|
const n = this.snap.nodes[this.focus.node];
|
||||||
this.apply([{ op: "update", id: n.id, pinned: !n.pinned }], `${n.pinned ? "Unpin" : "Pin"} “${clip(label(this.snap, n.id), 40)}”`);
|
this.apply([{ op: "update", id: n.id, pinned: !n.pinned }], `${n.pinned ? "Unlock" : "Lock"} “${clip(label(this.snap, n.id), 40)}”`);
|
||||||
this.say(n.pinned ? "Unpinned: the model may rewrite this node." : "Pinned: the model will not rewrite this node.");
|
this.say(n.pinned ? "Unlocked: the model may rewrite this node." : "Locked: the model will not rewrite this node.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** b: accept a stale node as it stands. */
|
/** b: accept a stale node as it stands. */
|
||||||
@@ -1948,7 +1949,7 @@ class Store {
|
|||||||
const id = this.focus.node;
|
const id = this.focus.node;
|
||||||
if (!this.generating) return this.say("No model configured.");
|
if (!this.generating) return this.say("No model configured.");
|
||||||
if (!isStale(s, id)) return this.say("This node is not stale.");
|
if (!isStale(s, id)) return this.say("This node is not stale.");
|
||||||
if (s.nodes[id].pinned) return this.say("Pinned nodes are not rewritten. p unpins; b accepts it as it stands.");
|
if (s.nodes[id].pinned) return this.say("Locked nodes are not rewritten. p unlocks; b accepts it as it stands.");
|
||||||
const doc = this.doc;
|
const doc = this.doc;
|
||||||
void this.enqueue(`reconciling “${clip(label(s, id), 30)}”`, async () => {
|
void this.enqueue(`reconciling “${clip(label(s, id), 30)}”`, async () => {
|
||||||
if (await reconcile(this.llm, doc, id, undefined, undefined, this.writeHooks())) this.status = "";
|
if (await reconcile(this.llm, doc, id, undefined, undefined, this.writeHooks())) this.status = "";
|
||||||
@@ -2507,7 +2508,7 @@ class Store {
|
|||||||
|
|
||||||
/** Why a key that works on a node does nothing on Wikipedia's text, for the status line; null for a key that does work there. */
|
/** Why a key that works on a node does nothing on Wikipedia's text, for the status line; null for a key that does work there. */
|
||||||
articleRefuses(k: string, selecting: boolean): string | null {
|
articleRefuses(k: string, selecting: boolean): string | null {
|
||||||
const own = "Wikipedia's text is shown as it is: it cannot be edited, renamed, moved, pinned, reconciled or rewritten here. Annotations on it can: i selects words, e d y x c writes one.";
|
const own = "Wikipedia's text is shown as it is: it cannot be edited, renamed, moved, locked, reconciled or rewritten here. Annotations on it can: i selects words, e d y x c writes one.";
|
||||||
if (["r", "a", "A", "J", "K", ">", "<", "p", "R", "b", "o", "O", "z"].includes(k) && !(selecting && (k === "J" || k === "K"))) return own;
|
if (["r", "a", "A", "J", "K", ">", "<", "p", "R", "b", "o", "O", "z"].includes(k) && !(selecting && (k === "J" || k === "K"))) return own;
|
||||||
if (k === "c" && !selecting) return "Wikipedia's text cannot be edited here. Select words (i) and press c to challenge them, or e d y x to annotate them.";
|
if (k === "c" && !selecting) return "Wikipedia's text cannot be edited here. Select words (i) and press c to challenge them, or e d y x to annotate them.";
|
||||||
if (["e", "d", "y", "x"].includes(k) && !selecting) return "Select words first: i, then e d y x c or :. An article itself is never deepened or rewritten.";
|
if (["e", "d", "y", "x"].includes(k) && !selecting) return "Select words first: i, then e d y x c or :. An article itself is never deepened or rewritten.";
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ describe("cascade", () => {
|
|||||||
doc.apply(sections(doc.snap(), part).map((id) => ({ op: "bless" as const, id })), "Accept");
|
doc.apply(sections(doc.snap(), part).map((id) => ({ op: "bless" as const, id })), "Accept");
|
||||||
doc.apply([{ op: "update", id: a, body: "Leaf A changed again." }], "Human edit");
|
doc.apply([{ op: "update", id: a, body: "Leaf A changed again." }], "Human edit");
|
||||||
const events = await cascade(llm, doc, a, "edit");
|
const events = await cascade(llm, doc, a, "edit");
|
||||||
expect(events.map((e) => e.kind)).toEqual(["decide", "pinned"]);
|
expect(events.map((e) => e.kind)).toEqual(["decide", "locked"]);
|
||||||
expect(doc.snap().nodes[part].body).toBe("A human wrote this summary.");
|
expect(doc.snap().nodes[part].body).toBe("A human wrote this summary.");
|
||||||
expect(staleness(doc.snap(), part).up).toBe(true);
|
expect(staleness(doc.snap(), part).up).toBe(true);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user