opencode-self-improvement 0.30.1 → 0.30.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/package.json +3 -2
  2. package/src/capture/available.ts +30 -31
  3. package/src/capture/candidates.ts +2 -2
  4. package/src/capture/checked.ts +3 -3
  5. package/src/capture/guided-rules.ts +1 -1
  6. package/src/capture/lag.ts +2 -2
  7. package/src/capture/policy.ts +7 -7
  8. package/src/capture/prompt.ts +4 -4
  9. package/src/capture/runtime.ts +86 -90
  10. package/src/capture/session-model.ts +2 -2
  11. package/src/capture/transcript.ts +5 -5
  12. package/src/capture/triggers.ts +7 -7
  13. package/src/consolidate/propose.ts +4 -4
  14. package/src/consolidate/render.ts +2 -2
  15. package/src/core/cmp-ts.ts +1 -1
  16. package/src/core/config/budgets.ts +1 -1
  17. package/src/core/config/paths.ts +1 -1
  18. package/src/core/guidance.ts +1 -1
  19. package/src/core/hooks.ts +4 -4
  20. package/src/core/host.ts +1 -1
  21. package/src/core/logfmt/format.ts +1 -1
  22. package/src/core/logfmt/publish.ts +1 -1
  23. package/src/core/logfmt/read.ts +1 -1
  24. package/src/core/lru.ts +1 -1
  25. package/src/core/state.ts +4 -4
  26. package/src/core/tags.ts +9 -10
  27. package/src/core/time.ts +1 -1
  28. package/src/core/tokenize.ts +1 -1
  29. package/src/events.ts +8 -8
  30. package/src/evidence/record.ts +10 -11
  31. package/src/gate/gate.ts +25 -25
  32. package/src/gate/value-conflict.ts +7 -8
  33. package/src/hits/ledger.ts +4 -4
  34. package/src/identity/host-events.ts +3 -3
  35. package/src/identity/repokey.ts +7 -7
  36. package/src/identity/session-context.ts +7 -7
  37. package/src/index.ts +6 -6
  38. package/src/init/detect.ts +3 -3
  39. package/src/init/format.ts +6 -6
  40. package/src/init/retag.ts +7 -7
  41. package/src/init/run.ts +18 -18
  42. package/src/init/stamp.ts +17 -17
  43. package/src/inject/anchor.ts +1 -1
  44. package/src/inject/budget.ts +1 -1
  45. package/src/inject/digest.ts +5 -5
  46. package/src/inject/epochs.ts +15 -15
  47. package/src/inject/format.ts +2 -2
  48. package/src/inject/pull.ts +3 -3
  49. package/src/inject/version.ts +1 -1
  50. package/src/portable/decay.ts +1 -1
  51. package/src/portable/export.ts +7 -7
  52. package/src/portable/import.ts +5 -5
  53. package/src/recall/conflicts.ts +1 -1
  54. package/src/recall/dedupe.ts +31 -55
  55. package/src/recall/gate.ts +19 -40
  56. package/src/recall/relevant.ts +11 -11
  57. package/src/recall/score.ts +14 -23
  58. package/src/recall/shared-terms.ts +1 -1
  59. package/src/status/format.ts +1 -1
  60. package/src/status/metrics.ts +5 -5
  61. package/src/status/payload.ts +4 -4
  62. package/src/status/report.ts +5 -5
  63. package/src/status/store-summary.ts +1 -1
  64. package/src/status/write.ts +3 -4
  65. package/src/store/blocklist.ts +1 -1
  66. package/src/store/files/append.ts +8 -8
  67. package/src/store/files/deletions.ts +3 -3
  68. package/src/store/files/load.ts +5 -5
  69. package/src/store/files/prune.ts +8 -8
  70. package/src/store/files/snapshots.ts +1 -1
  71. package/src/store/files/supersede.ts +11 -12
  72. package/src/store/files/target.ts +1 -1
  73. package/src/store/lock.ts +12 -12
  74. package/src/store/model/memory.ts +4 -4
  75. package/src/store/model/predicates.ts +2 -2
  76. package/src/store/model/provenance.ts +1 -1
  77. package/src/store/model/visibility.ts +4 -4
  78. package/src/store/prune.ts +1 -1
  79. package/src/store/quarantine/quarantine.ts +2 -2
  80. package/src/store/quarantine/release.ts +2 -2
  81. package/src/store/secrets.ts +1 -1
  82. package/src/store/tombstones/rejection.ts +1 -1
  83. package/src/store/tombstones/tombstone.ts +5 -5
  84. package/src/store/undo.ts +12 -12
  85. package/src/tools/consolidate.ts +1 -1
  86. package/src/tools/decay.ts +2 -2
  87. package/src/tools/deps.ts +1 -1
  88. package/src/tools/evidence.ts +4 -4
  89. package/src/tools/export.ts +1 -1
  90. package/src/tools/forget.ts +2 -2
  91. package/src/tools/import.ts +3 -3
  92. package/src/tools/init.ts +1 -1
  93. package/src/tools/list.ts +1 -1
  94. package/src/tools/merge-review.ts +11 -11
  95. package/src/tools/recall.ts +5 -5
  96. package/src/tools/registry.ts +2 -2
  97. package/src/tools/remember.ts +4 -4
  98. package/src/tools/schema.ts +4 -4
  99. package/src/tools/status-tool.ts +5 -5
  100. package/src/tools/undo.ts +4 -4
  101. package/src/tools/update.ts +18 -19
  102. package/src/viewer/mutate.ts +13 -13
  103. package/src/viewer/rejections.ts +1 -1
  104. package/src/viewer/server.ts +47 -49
package/src/store/lock.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  // Windows, fcntl F_SETLK on POSIX — so the lock lives in the kernel's
17
17
  // handle table, not in a directory entry.
18
18
  //
19
- // Why this is not a lock file (#407). The previous protocol put the state of
19
+ // Why this is not a lock file. The previous protocol put the state of
20
20
  // the lock in the EXISTENCE of a file and released it with unlink. On Windows
21
21
  // that entry's lifetime is not ours to decide: DeleteFile marks a file for
22
22
  // deletion on close and the name stays in the directory until the last handle
@@ -45,7 +45,7 @@
45
45
  // Supported storage. SQLite's locking is byte-range locks plus a journal it
46
46
  // renames into place, and neither is dependable on network filesystems. A
47
47
  // memory root on SMB, NFS or a OneDrive-mounted folder is therefore
48
- // unsupported (#407): writes there can report a disk I/O error rather than
48
+ // unsupported: writes there can report a disk I/O error rather than
49
49
  // serialise. That is a deliberate cut, not an oversight — the lock is the
50
50
  // correctness mechanism for the whole store, so a silently unserialised store
51
51
  // on a share was the worse option.
@@ -99,7 +99,7 @@ const DEFAULT_TIMEOUT_MS = 10_000;
99
99
  // reported "locked for 5001ms" while the holder was mid-handover-retry, not
100
100
  // wedged. 10 s still fails closed and reports, but stops refusing writes that
101
101
  // were simply behind two honest retries.
102
- // #216: the default policy is fail-closed, the policy #196 moved every
102
+ // the default policy is fail-closed, the policy moved every
103
103
  // production writer to. A writer that omits opts must refuse at the deadline,
104
104
  // not silently reintroduce the unlocked-proceed row loss the LOCK_WRITE
105
105
  // contract retired. "proceed" survives only as an explicit opt-in.
@@ -110,7 +110,7 @@ const MAX_BACKOFF_MS = 25;
110
110
  // the hot path, so it gets its own bound rather than the caller's budget.
111
111
  const JOURNAL_CONVERT_BUDGET_MS = 5_000;
112
112
 
113
- // The one source of the timeout policy (#216): both give-up paths — the FIFO
113
+ // The one source of the timeout policy: both give-up paths — the FIFO
114
114
  // hand-off and the SQLite wait — resolve through here, so the fail-closed
115
115
  // default cannot drift between them.
116
116
  function timeoutPolicy(opts: LockOptions): "proceed" | "fail" {
@@ -128,7 +128,7 @@ export interface LockOptions {
128
128
  timeoutMs?: number;
129
129
  /**
130
130
  * What waiting past `timeoutMs` means. The default, "fail", refuses the
131
- * mutation (#216: fail-closed is the contract every store writer keeps;
131
+ * mutation (fail-closed is the contract every store writer keeps;
132
132
  * LOCK_WRITE and LOCK_RESTORE spell it out). "proceed" runs the write
133
133
  * unlocked and can lose acknowledged writes when another caller rewrites
134
134
  * the same file — pass it only where that concession is intended.
@@ -140,7 +140,7 @@ export interface LockOptions {
140
140
  // Every writer of a shared store file must respect exclusion, INCLUDING
141
141
  // appenders: an unlocked append inside a holder's read-modify-write window is
142
142
  // overwritten by its publish. Refuse at the deadline so the caller can retry;
143
- // never acknowledge a mutation performed outside the holder's lock (#196).
143
+ // never acknowledge a mutation performed outside the holder's lock.
144
144
  export const LOCK_WRITE: LockOptions = {
145
145
  onTimeout: "fail",
146
146
  onEvent: (event, waitedMs) => {
@@ -193,7 +193,7 @@ async function timed(prev: Promise<void>, ms: number): Promise<boolean> {
193
193
  * correctness, because eviction skips anything in use. Closing is also what
194
194
  * lets a test delete a store on Windows — a held handle keeps the file alive —
195
195
  * and that is exactly why it happens on eviction and teardown, never per
196
- * acquisition (#407 is about Windows refusing a delete we do not need to
196
+ * acquisition ( is about Windows refusing a delete we do not need to
197
197
  * attempt).
198
198
  */
199
199
  interface Pinned {
@@ -491,7 +491,7 @@ async function holdLock<T>(
491
491
  throw new Error(busyMessage(file, now() - started));
492
492
  }
493
493
  // Proceeding without the lock is the explicit "proceed" opt-in
494
- // (#216: no longer the default). heldLocks is deliberately NOT touched
494
+ // (no longer the default). heldLocks is deliberately NOT touched
495
495
  // here: a writer that never held the lock must not let a nested call
496
496
  // believe it did.
497
497
  return await fn();
@@ -551,7 +551,7 @@ async function acquire<T>(
551
551
  // Same call chain, same lock: the outer section already excludes everyone
552
552
  // else, so re-entering neither starts a second transaction nor queues
553
553
  // behind the FIFO the outer section owns. The hook still fires — it counts
554
- // which store files a write path touches (#215), and this path touched one.
554
+ // which store files a write path touches, and this path touched one.
555
555
  acquiredHook?.(file);
556
556
  return await fn();
557
557
  }
@@ -594,12 +594,12 @@ async function acquire<T>(
594
594
  }
595
595
 
596
596
  /**
597
- * Test seam (#197): refuse the acquisition of chosen files.
597
+ * Test seam: refuse the acquisition of chosen files.
598
598
  *
599
599
  * The tests that pin "a batch that published file 1 and then lost file 2 must
600
600
  * report file 1 as durable" need a refusal at a chosen point in a sequence.
601
601
  * Under the lock file a test could hold one day file and let the batch reach
602
- * the next one. The lock is per file again (#407 round two), so that driver
602
+ * the next one. The lock is per file again, so that driver
603
603
  * exists again; this seam remains for the cases that need a refusal at a chosen
604
604
  * step rather than a rival that holds a file.
605
605
  *
@@ -657,7 +657,7 @@ export async function withStoreBatch<T>(
657
657
  }
658
658
 
659
659
  /**
660
- * Test seam (#215): observe how many store files a write path locks.
660
+ * Test seam: observe how many store files a write path locks.
661
661
  *
662
662
  * The narrowing this ticket asked for is invisible to a functional test — a
663
663
  * supersede that sweeps every day file and one that touches a single file both
@@ -1,4 +1,4 @@
1
- // memory — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // memory — split from src/memory.ts. Declaration bodies are unchanged.
2
2
 
3
3
  import { flattenMemoryText } from "../sanitize.ts";
4
4
 
@@ -48,7 +48,7 @@ const CONFLICT_REF_RE = /^[A-Za-z_][A-Za-z0-9_]{1,63}$/;
48
48
 
49
49
  export const MAX_CLAIM_CHARS = 32;
50
50
 
51
- /** Cap on the verbatim user utterance a guided row may carry (bench #347 follow-up). */
51
+ /** Cap on the verbatim user utterance a guided row may carry. */
52
52
  export const MAX_ORIGINAL_CHARS = 300;
53
53
 
54
54
  /**
@@ -96,7 +96,7 @@ export interface Memory {
96
96
  content: string;
97
97
  issue?: string;
98
98
  tags?: string[];
99
- // Retrieval keywords (#40): author-supplied aliases, verb forms and synonyms
99
+ // Retrieval keywords: author-supplied aliases, verb forms and synonyms
100
100
  // for this row, written at capture time. They widen the scoring haystack
101
101
  // ONLY — a row is never rendered through them, so injection bytes and the
102
102
  // content cap stay exactly what the prose says. This is the zero-embedding
@@ -117,7 +117,7 @@ export interface Memory {
117
117
  // authority (klass). Injection reads the code at render time — deterministically,
118
118
  // no model call — and a collision renders one CONFLICT line whose Action is
119
119
  // fixed by the class: behavior class trusts the code, spec class fixes it.
120
- // #345 measured the alternative: a wrong guided row rewrote correct code.
120
+ // measured the alternative: a wrong guided row rewrote correct code.
121
121
  ref?: string;
122
122
  claim?: string;
123
123
  klass?: "spec" | "behavior";
@@ -1,4 +1,4 @@
1
- // predicates — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // predicates — split from src/memory.ts. Declaration bodies are unchanged.
2
2
  import { INIT_STAMP_TAG } from "../../core/tags.ts";
3
3
  import { isQuarantined } from "../quarantine/quarantine.ts";
4
4
  import type { Memory } from "./memory.ts";
@@ -8,7 +8,7 @@ export function isActive(m: Memory): boolean {
8
8
  }
9
9
 
10
10
  // Quarantine remains durable and reviewable; only model-facing reads withhold it.
11
- // The legacy `init-stamp` tag joins it (#376 review). A pre-#374 stamp row is
11
+ // The legacy `init-stamp` tag joins it. A legacy stamp row is
12
12
  // plugin bookkeeping, and migration only retires a row whose `init_complete`
13
13
  // audit line survives; in a store where that line is gone the row stays active
14
14
  // forever, so the tag itself has to keep it off the prompt. This is the one
@@ -1,4 +1,4 @@
1
- // Provenance: how a row was obtained (#393).
1
+ // Provenance: how a row was obtained.
2
2
  //
3
3
  // R4 (`benchmark-tests/ocsi/results-poison-x5/`, n=5) is why this exists. With an
4
4
  // empty store the agent produced no artifact in 3 of 5 runs and never invented a
@@ -17,7 +17,7 @@ import type { Memory } from "./memory.ts";
17
17
  // in that flow. Resolution must NOT be deferred to filter time: the module
18
18
  // global current moves whenever another session's hook or tool dispatches, and
19
19
  // a store read awaits filesystem I/O — filtering after the await with the
20
- // ambient identity injects the OTHER session's repo (#127).
20
+ // ambient identity injects the OTHER session's repo.
21
21
  //
22
22
  // repo — the caller's session resolved a repository (its own when
23
23
  // bound; the setup location for an unbound session in a
@@ -41,7 +41,7 @@ export const ADMIN_READER: Reader = { kind: "admin" };
41
41
  // captured synchronously at flow entry. Bound session → its repo; unbound →
42
42
  // global-only. The module scope is NOT a fallback here: in a process that
43
43
  // loaded more than one plugin instance it belongs to whoever set up LAST,
44
- // which is another workspace (#127's multi-setup gap). Plugin flows bind an
44
+ // which is another workspace (multi-setup gap). Plugin flows bind an
45
45
  // unbound caller to their OWN setup location at entry (index.ts), so ordinary
46
46
  // single-workspace sessions resolve through the session map, never here.
47
47
  export function readerForSession(sid?: unknown): Reader {
@@ -66,9 +66,9 @@ export function readerFromSid(sid?: unknown): Reader {
66
66
  : readerForAmbient();
67
67
  }
68
68
 
69
- // Before #109, path-derived keys on win32/darwin hashed the whole canonical
69
+ // Before, path-derived keys on win32/darwin hashed the whole canonical
70
70
  // path in lowercase, even on case-sensitive volumes. Such a key can equal a
71
- // distinct lowercase sibling's current key (#254). The stored path identifies
71
+ // distinct lowercase sibling's current key. The stored path identifies
72
72
  // these legacy stamps without a migration: require the same directory, allowing
73
73
  // real symlink/case-insensitive aliases, instead of trusting that key alone.
74
74
  // Remote-derived keys still share across clones with different paths. A stamp
@@ -10,7 +10,7 @@ export async function pruneMemory(
10
10
  scope: string,
11
11
  type: string,
12
12
  reason: string,
13
- // The calling session (#127): the repo floor on prune must follow the
13
+ // The calling session: the repo floor on prune must follow the
14
14
  // CALLER's identity, captured at tool entry, not the ambient current the
15
15
  // locked file walk may outlive. "?" / undefined keep ambient semantics.
16
16
  sid?: string,
@@ -48,8 +48,8 @@ export function quarantineCandidate<
48
48
  tags?: string[];
49
49
  },
50
50
  >(candidate: T): T {
51
- // #205: scope renders model-facing (inject/format.ts prints it on every
52
- // injected line), so the scanner covers it as well as content. #364 review:
51
+ // scope renders model-facing (inject/format.ts prints it on every
52
+ // injected line), so the scanner covers it as well as content. review:
53
53
  // so does `original`, the verbatim quote the same line prints as
54
54
  // `(user said: "...")` — a benign summary carrying an instruction-shaped
55
55
  // quote reached the prompt untagged. Hits are merged and deduplicated;
@@ -1,4 +1,4 @@
1
- // release — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // release — split from src/memory.ts. Declaration bodies are unchanged.
2
2
  import { type Fields, formatLine } from "../../core/logfmt/format.ts";
3
3
  import { filesHoldingTs, memoryFiles } from "../files/load.ts";
4
4
  import { stampRow } from "../files/snapshots.ts";
@@ -21,7 +21,7 @@ export async function releaseQuarantine(
21
21
  else delete fields.tags;
22
22
  return formatLine(fields);
23
23
  };
24
- // #215 + #373 review: release every copy. The day file the ts names is the
24
+ //+ review: release every copy. The day file the ts names is the
25
25
  // common case; the previous day's file joins ONLY when a scan finds the same
26
26
  // identity in it, which is what an older midnight-boundary append could write.
27
27
  // Leaving a duplicate quarantined beside a released copy would keep the row
@@ -7,7 +7,7 @@ export const REDACTED_SECRET = "[redacted]";
7
7
  // PEM redaction is a linear marker-pair scan, not one lazy regex. The old
8
8
  // /-----BEGIN...[\s\S]*?-----END.../g re-scanned to end-of-input at every
9
9
  // unmatched BEGIN, so a large tool output of repeated BEGIN lines with no END
10
- // line stalled the hook for seconds per megabyte (#290). The marker regexes
10
+ // line stalled the hook for seconds per megabyte. The marker regexes
11
11
  // below are anchored (sticky) and never span lines, so each probe is bounded.
12
12
  const PRIVATE_KEY_BEGIN = "-----BEGIN";
13
13
  const PRIVATE_KEY_END = "-----END";
@@ -1,4 +1,4 @@
1
- // rejection — split from src/tombstones.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // rejection — split from src/tombstones.ts. Declaration bodies are unchanged.
2
2
  import { join } from "node:path";
3
3
  import { memoryRoot } from "../../core/config/paths.ts";
4
4
  import { contentHash } from "../../evidence/record.ts";
@@ -1,5 +1,5 @@
1
- // tombstone — split from src/tombstones.ts (#168 domain restructure). Declaration bodies are unchanged.
2
- // Value-keyed rejection tombstones (#35).
1
+ // tombstone — split from src/tombstones.ts. Declaration bodies are unchanged.
2
+ // Value-keyed rejection tombstones.
3
3
  //
4
4
  // The blocklist keys on `ts` — ROW identity. memory_forget/prune deletes the
5
5
  // row outright. Neither survives re-ingestion: replay the original source (a
@@ -297,7 +297,7 @@ export async function tombstones(): Promise<Tombstone[]> {
297
297
  * The heavy concurrent scenario on the Windows runner failed 2/2 with that shape
298
298
  * (run 41112466339). At that time, lock-budget expiry let a writer proceed
299
299
  * unlocked, losing rows behind a long read-modify-write. LOCK_WRITE now refuses
300
- * on timeout (#196); batching still reduces lock contention and its I/O cost.
300
+ * on timeout; batching still reduces lock contention and its I/O cost.
301
301
  *
302
302
  * Still idempotent by `ch`, and de-duplicated WITHIN the batch too, so a forget
303
303
  * that removes fifty rows carrying the same content records one tombstone.
@@ -315,7 +315,7 @@ export async function tombstoneMany(
315
315
  const at = new Date().toISOString();
316
316
  // An audit reason is human prose (prune passes the caller's straight through),
317
317
  // and this is the boundary where it becomes durable — the same rule the
318
- // deletion audit and the evidence log apply (#128). Scrubbing here rather than
318
+ // deletion audit and the evidence log apply. Scrubbing here rather than
319
319
  // at each call site is what keeps a future caller from forgetting to.
320
320
  const reason = redactSecrets(opts.reason);
321
321
  const fresh: string[] = [];
@@ -395,7 +395,7 @@ export async function removeTombstone(ch: string): Promise<boolean> {
395
395
  const row = parseLine(l);
396
396
  return !(row && row.ch === ch);
397
397
  });
398
- // A no-op must report as a no-op (#209): unknown ch lifts nothing, so
398
+ // A no-op must report as a no-op: unknown ch lifts nothing, so
399
399
  // return false and skip the rewrite rather than republishing the file
400
400
  // and reporting a withdrawal that never happened.
401
401
  if (kept.length === lines.length) return false;
package/src/store/undo.ts CHANGED
@@ -11,10 +11,10 @@
11
11
  // and additionally snapshots the file it replaces, so the state it drops stays
12
12
  // undoable (result.safety). Every mode consults the rejection tombstones: a
13
13
  // row whose content was rejected by a human is omitted from what it publishes,
14
- // never revived (#35, decision #214 A).
14
+ // never revived.
15
15
  //
16
16
  // A day file is shared across REPOSITORIES too, and foreign rows are outside
17
- // a caller's reach in every sense (#153): no mode revives them from the
17
+ // a caller's reach in every sense: no mode revives them from the
18
18
  // snapshot, rewinds them to a stale copy, or drops them. Foreign live lines
19
19
  // are carried over verbatim in every mode, appended at the end — line content
20
20
  // preserved, position in the shared file not — and only the caller's own rows
@@ -22,7 +22,7 @@
22
22
  // visibility, not ownership: GLOBAL rows (repo=global, or legacy unstamped)
23
23
  // are visible to every reader, so every repository's rollback treats them as
24
24
  // its own — a force restore may drop a global line appended after the
25
- // snapshot (pinned in test/undo-ownership). That is #131's "act on exactly
25
+ // snapshot (pinned in test/undo-ownership). That is "act on exactly
26
26
  // what you may read", the same rule memory_forget applies to global scope.
27
27
  // Admin readers (the viewer, out-of-plugin maintenance) keep the whole-file
28
28
  // restore exactly as it was.
@@ -109,7 +109,7 @@ export interface RestoreResult {
109
109
  // ts of rows intentionally deleted after this snapshot. CHECK and MERGE
110
110
  // leave them deleted; FORCE is the explicit recovery path — except for rows
111
111
  // whose content carries a rejection tombstone, which no mode recovers
112
- // (rejectedOmitted): a rejection is absolute (#35, decision #214 A).
112
+ // (rejectedOmitted): a rejection is absolute.
113
113
  deletedOmitted: string[];
114
114
  // ts of caller-owned rows the restore omitted because their content carries a
115
115
  // rejection tombstone. Reporting them separately from deletedOmitted is the
@@ -120,7 +120,7 @@ export interface RestoreResult {
120
120
  // different row, which the identity-keyed deletion audit cannot catch.
121
121
  rejectedOmitted: string[];
122
122
  // Live rows owned by other repositories, whose lines are carried over
123
- // verbatim (appended at the end) in every mode (#153). Admin restores
123
+ // verbatim (appended at the end) in every mode. Admin restores
124
124
  // report 0 — there is no foreign reader.
125
125
  foreignPreserved: number;
126
126
  }
@@ -273,8 +273,8 @@ export async function restoreSnapshot(
273
273
  // finished just before this restore is honoured.
274
274
  const audited =
275
275
  mode !== "force" ? await auditedDeletions() : new Set<string>();
276
- // Rejection tombstones are keyed on the VALUE (#35), and a rejection is
277
- // absolute (decision #214 A): no tool lifts one, so EVERY mode reads them
276
+ // Rejection tombstones are keyed on the VALUE, and a rejection is
277
+ // absolute (decision A): no tool lifts one, so EVERY mode reads them
278
278
  // and applies the content-hash floor to the caller-owned rows it publishes
279
279
  // (see the floor below), not just FORCE. The identity-keyed deletion audit
280
280
  // above cannot catch a rejected value carried by an older snapshot
@@ -282,7 +282,7 @@ export async function restoreSnapshot(
282
282
  // lock, like the deletion audit, so a forget that finished just before
283
283
  // this restore is honoured.
284
284
  const rejected = new Set((await tombstones()).map((t) => t.ch));
285
- // Ownership before anything else (#153): rows a foreign repo owns are
285
+ // Ownership before anything else: rows a foreign repo owns are
286
286
  // excluded from the snapshot side in EVERY mode (never revived, never
287
287
  // rewound), excluded from the deletion audit and the divergence
288
288
  // bookkeeping (not this caller's to reason about), and carried verbatim
@@ -315,7 +315,7 @@ export async function restoreSnapshot(
315
315
  else if (s !== l) concurrentChanged.push(k);
316
316
  }
317
317
 
318
- // CHECK keeps its documented conservatism (#153 control): ANY divergence
318
+ // CHECK keeps its documented conservatism ( control): ANY divergence
319
319
  // of the shared file — including other repositories' rows, which FORCE
320
320
  // and MERGE now provably leave untouched — refuses until the caller picks
321
321
  // a mode deliberately. The refusal is a "the file moved, say again on
@@ -359,7 +359,7 @@ export async function restoreSnapshot(
359
359
  .concat(curOwn.filter((l) => !snapByKey.has(rowKey(l))));
360
360
  }
361
361
 
362
- // Rejection is absolute (#35, decision #214 A): the content-hash floor is
362
+ // Rejection is absolute: the content-hash floor is
363
363
  // the last gate before publishing, applied to the caller-owned rows of
364
364
  // EVERY mode. A row whose content carries a tombstone is omitted here and
365
365
  // reported in rejectedOmitted, so the store never ends up holding an
@@ -369,7 +369,7 @@ export async function restoreSnapshot(
369
369
  // rollback drops the original with no audit, then a later copy is
370
370
  // forgotten). The tombstone file itself is read-only to a restore —
371
371
  // mis-forget recovery stays human. Foreign rows are carried verbatim and
372
- // never filtered: they are outside this caller's reach (#153).
372
+ // never filtered: they are outside this caller's reach.
373
373
  const rejectedOmitted: string[] = [];
374
374
  if (rejected.size > 0) {
375
375
  pubOwn = pubOwn.filter((line) => {
@@ -389,7 +389,7 @@ export async function restoreSnapshot(
389
389
  mode === "force" ? (await snapshotFiles([target]))[0] : undefined;
390
390
 
391
391
  // Foreign live lines are re-admitted verbatim in every mode, appended at
392
- // the end — line content preserved, position not (#153). Under the admin
392
+ // the end — line content preserved, position not. Under the admin
393
393
  // reader curForeign is empty and the write is the historical whole-file
394
394
  // restore, byte for byte — modulo the rejected-row omission above, which
395
395
  // applies to every reader and every mode: a rejection is absolute, not
@@ -1,4 +1,4 @@
1
- // The memory_consolidate tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_consolidate tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -1,4 +1,4 @@
1
- // The memory_decay tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_decay tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -58,7 +58,7 @@ export const register: ToolRegister = (editor, deps) => {
58
58
  const snapshot = await snapshotFiles([
59
59
  ...new Set(stale.map((m) => m.file)),
60
60
  ]);
61
- // One lock/read/snapshot/publish per file for the whole decay run (#61):
61
+ // One lock/read/snapshot/publish per file for the whole decay run:
62
62
  // N retired rows are one undo point, not N. Idempotent (a no-op on rows
63
63
  // already superseded, out-of-band ones skipped under the lock).
64
64
  const durable: string[] = [];
package/src/tools/deps.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Shared dependency surface for the memory tools (#168). The tools module is
1
+ // Shared dependency surface for the memory tools. The tools module is
2
2
  // a leaf: host wiring stays in index.ts and arrives through this interface,
3
3
  // so a tool file never reaches into the plugin setup closure.
4
4
  import type { GateContext } from "../gate/gate.ts";
@@ -1,4 +1,4 @@
1
- // The memory_evidence tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_evidence tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -19,7 +19,7 @@ export const register: ToolRegister = (editor, deps) => {
19
19
  async execute(args, context): Promise<{ content: string }> {
20
20
  const { sid } = toolIds(context);
21
21
  const reader = readerFromSid(sid);
22
- // #130: the ONE path the schema-validated date can resolve to —
22
+ // the ONE path the schema-validated date can resolve to —
23
23
  // a real calendar day inside the evidence dir, never a traversal
24
24
  // into the raw store or the filesystem beyond it.
25
25
  const file = evidenceFileFor(args.date);
@@ -30,11 +30,11 @@ export const register: ToolRegister = (editor, deps) => {
30
30
  };
31
31
  }
32
32
  let lines = await readLines(file);
33
- // Data partitions too (#131's ownership rule, applied to evidence):
33
+ // Data partitions too (the ownership rule, applied to evidence):
34
34
  // a line stamped to another repository is not this session's data,
35
35
  // and a line a NAMED session wrote while unresolved is private to
36
36
  // that session — the caller's sid is what the private branch
37
- // matches against (#128 re-review).
37
+ // matches against.
38
38
  if (reader.kind !== "admin") {
39
39
  lines = lines.filter((l) => {
40
40
  const fields = parseLine(l);
@@ -1,4 +1,4 @@
1
- // The memory_export tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_export tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -1,4 +1,4 @@
1
- // The memory_forget tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_forget tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -15,7 +15,7 @@ export const register: ToolRegister = (editor, deps) => {
15
15
  options: direct,
16
16
  async execute(args, context): Promise<{ content: string }> {
17
17
  const { sid } = toolIds(context);
18
- // Identity before the prune's repo floor (#260): resolve the session
18
+ // Identity before the prune's repo floor: resolve the session
19
19
  // from the host (messages, then session row) before pruneMemory
20
20
  // captures the Reader, so an unseen serve-host session is partitioned
21
21
  // by its own repository, not the instance's provisional binding.
@@ -1,4 +1,4 @@
1
- // The memory_import tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_import tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -25,7 +25,7 @@ export const register: ToolRegister = (editor, deps) => {
25
25
  const { sid } = toolIds(context);
26
26
  // Resolve before touching the file: every imported row is re-stamped
27
27
  // with the IMPORTING session's repository, so an unresolved caller
28
- // would move a whole export into whoever set up last (#152).
28
+ // would move a whole export into whoever set up last.
29
29
  await bindSessionIdentity(sid);
30
30
  const ownerless = ownerlessWriter(sid);
31
31
  if (ownerless) return await refuseOwnerlessWrite(ownerless, "import");
@@ -51,7 +51,7 @@ export const register: ToolRegister = (editor, deps) => {
51
51
  ? ` ${t.downgraded} open rows downgraded to settled (missing eligible memory_export header or verifiable repo scope).`
52
52
  : "") +
53
53
  // Rows that landed without their write_promoted line are
54
- // durable but invisible to memory_evidence (#155 review) —
54
+ // durable but invisible to memory_evidence —
55
55
  // the tally owes the reader the count, not silence.
56
56
  (t.unaudited
57
57
  ? ` ${t.unaudited} promoted rows landed without their write_promoted audit line (${t.auditError}); memory_evidence will miss them.`
package/src/tools/init.ts CHANGED
@@ -1,4 +1,4 @@
1
- // The memory_init tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_init tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
package/src/tools/list.ts CHANGED
@@ -1,4 +1,4 @@
1
- // The memory_list tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_list tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -1,4 +1,4 @@
1
- // The memory_merge_review tool, extracted from index.ts (#168).
1
+ // The memory_merge_review tool, extracted from index.ts.
2
2
  // Closure access arrives through ToolDeps.
3
3
  import type { ToolRegister } from "./deps.ts";
4
4
  import { memoryRoot } from "../core/config/paths.ts";
@@ -21,7 +21,7 @@ export const register: ToolRegister = (editor, deps) => {
21
21
  options: direct,
22
22
  async execute(args, context): Promise<{ content: string }> {
23
23
  const { sid } = toolIds(context);
24
- // Identity before authorization (#260): the entry binding is only
24
+ // Identity before authorization: the entry binding is only
25
25
  // provisional on the INSTANCE's directory. On a serve host the session
26
26
  // row is the sole truth, and a tool call can be the first thing this
27
27
  // instance sees for a session — resolve it like the write tools do
@@ -41,11 +41,11 @@ export const register: ToolRegister = (editor, deps) => {
41
41
  "merge_review blocked: loser and survivor are the same row — nothing to resolve. No evidence written.",
42
42
  };
43
43
  }
44
- // A row id is a pointer, not authority (#131): resolving and
44
+ // A row id is a pointer, not authority: resolving and
45
45
  // authorizing BOTH seats happens against the caller's Reader —
46
- // captured at entry, never re-read after an await (#127) — and the
46
+ // captured at entry, never re-read after an await — and the
47
47
  // whole resolve/check/mutate runs under the same update-order lock
48
- // memory_update serializes on (#125), so the authorization is
48
+ // memory_update serializes on, so the authorization is
49
49
  // revalidated under the mutation lock instead of against a snapshot
50
50
  // a concurrent update could have replaced. Acquisition order is
51
51
  // always update-order then store-file locks, never the reverse, so
@@ -53,7 +53,7 @@ export const register: ToolRegister = (editor, deps) => {
53
53
  // closed with nothing written.
54
54
  const reader = readerFromSid(sid);
55
55
  // A batch may publish the loser then refuse a later file. The sink
56
- // records that publish before the overall promise settles (#197).
56
+ // records that publish before the overall promise settles.
57
57
  const mergeDurable: string[] = [];
58
58
  try {
59
59
  return await withStoreBatch(
@@ -75,14 +75,14 @@ export const register: ToolRegister = (editor, deps) => {
75
75
  const loserRow = all.find((m) => m.ts === args.loser);
76
76
  // loadAll omits blocklisted rows. An unresolved id therefore
77
77
  // proves neither existence nor ownership; raw mutation helpers
78
- // must not use it to bypass this read boundary (#204).
78
+ // must not use it to bypass this read boundary.
79
79
  if (!loserRow) {
80
80
  return {
81
81
  content:
82
82
  "merge_review blocked: loser is missing or unavailable — nothing to resolve. No evidence written.",
83
83
  };
84
84
  }
85
- // Visibility is the authorization contract (#131): a session
85
+ // Visibility is the authorization contract: a session
86
86
  // may merge exactly the rows it may read. Global and legacy
87
87
  // unstamped rows are visible everywhere and therefore
88
88
  // mergeable from anywhere — stated here, not granted
@@ -101,7 +101,7 @@ export const register: ToolRegister = (editor, deps) => {
101
101
  "merge_review blocked: the survivor belongs to another repository — this session may not promote or revive it. Nothing was done. No evidence written.",
102
102
  };
103
103
  }
104
- // Provenance guard (#126): a survivor carrying a supersession
104
+ // Provenance guard: a survivor carrying a supersession
105
105
  // written by anything OTHER than this review — its marker points
106
106
  // at a later row (a memory_update that retired the survivor
107
107
  // after the review was filed), and the marker's reason is not
@@ -146,7 +146,7 @@ export const register: ToolRegister = (editor, deps) => {
146
146
  // The survivor may itself have been superseded earlier (e.g. by
147
147
  // a row this very call just made the loser). Declaring it
148
148
  // canonical has to make it recallable, so clear its own marker —
149
- // but only the marker this review owns (#126): the guard above
149
+ // but only the marker this review owns: the guard above
150
150
  // already refused anything else, and this re-check runs under the
151
151
  // file lock against the line as it is at mutation time.
152
152
  const revived = await clearSuperseded(args.survivor, {
@@ -154,7 +154,7 @@ export const register: ToolRegister = (editor, deps) => {
154
154
  reason: args.reason,
155
155
  });
156
156
  // The response has always claimed "Evidence recorded" — now it
157
- // is true, and it names the session the merge ran FOR (#121's
157
+ // is true, and it names the session the merge ran FOR (
158
158
  // residue on this line). The host tool_result hook covers
159
159
  // grep/read/edit/shell only, so a merge used to leave zero
160
160
  // trace: which reviewer decision, on which reason, reviving
@@ -1,4 +1,4 @@
1
- // The memory_recall tool, extracted from index.ts (#168). Schema, description
1
+ // The memory_recall tool, extracted from index.ts. Schema, description
2
2
  // and handler are byte-identical to the pre-split source; closure access arrives
3
3
  // through ToolDeps.
4
4
  import type { ToolRegister } from "./deps.ts";
@@ -19,7 +19,7 @@ import { firstFrontierTap, markFrontierTap } from "../capture/triggers.ts";
19
19
  import { dedupeThreshold, dedupeWindow } from "../recall/dedupe.ts";
20
20
 
21
21
  function scoreMemory(m: Memory, q: string): number {
22
- // Same indexed fields as the injection scorer (#40): a row recalled by one of
22
+ // Same indexed fields as the injection scorer: a row recalled by one of
23
23
  // its keywords is the same row recalled by the prose that keyword stands for.
24
24
  const hay = recallHaystack(m);
25
25
  let score = 0;
@@ -53,7 +53,7 @@ export const register: ToolRegister = (editor, deps) => {
53
53
  if (args.query) {
54
54
  // Default on: a row must share two whole words of the query — the
55
55
  // concepts rule, not the scorer's substring test (src/recall/gate.ts,
56
- // #409). OPENCODE_MEMORY_QUERY_GATE=off restores the old matcher.
56
+ //). OPENCODE_MEMORY_QUERY_GATE=off restores the old matcher.
57
57
  const gate = gateEnabled();
58
58
  const concepts = gate ? queryConcepts(args.query) : [];
59
59
  results = results
@@ -62,7 +62,7 @@ export const register: ToolRegister = (editor, deps) => {
62
62
  .sort((a, b) => b.score - a.score)
63
63
  .map((x) => x.m);
64
64
  }
65
- // #409: the default window was 20. A live audit joined 1,090 recall
65
+ // the default window was 20. A live audit joined 1,090 recall
66
66
  // events to their session transcripts: rank-1 rows go on to be
67
67
  // referenced at 3.4x the rate of a random store row, ranks 11-20 at
68
68
  // 1.16x — noise. Returning 17.7 rows per call meant most of the window
@@ -71,7 +71,7 @@ export const register: ToolRegister = (editor, deps) => {
71
71
  // Non-positive or fractional limits are coerced, never trusted: a
72
72
  // negative slice(0, n) / slice(-n) silently returns MORE rows, not fewer.
73
73
  const limit = args.limit && args.limit > 0 ? Math.floor(args.limit) : 5;
74
- // #409 dedup lane (RESULTS §17): default on at 0.8 — near-duplicate
74
+ // dedup lane (RESULTS §17): default on at 0.8 — near-duplicate
75
75
  // copies are skipped so the window fills with distinct rows instead of
76
76
  // repeats of the top hit. OPENCODE_MEMORY_DEDUP=0 restores the plain
77
77
  // slice.
@@ -1,6 +1,6 @@
1
- // Memory tool registration (#168): one module per tool, registered here in
1
+ // Memory tool registration: one module per tool, registered here in
2
2
  // the same order index.ts used before the split. Behavior, schemas and result
3
- // shapes are pinned by the e2e characterization suite (#241) and the
3
+ // shapes are pinned by the e2e characterization suite and the
4
4
  // registration coverage gate (e2e/coverage.test.ts).
5
5
  import { register as registerRemember } from "./remember.ts";
6
6
  import { register as registerConsolidate } from "./consolidate.ts";