opencode-self-improvement 0.30.1 → 0.30.3

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
@@ -1,4 +1,4 @@
1
- // score — split from src/inject.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // Recall scoring: the matcher over the store.
2
2
  import { loadAll } from "../store/files/load.ts";
3
3
  import { type Memory } from "../store/model/memory.ts";
4
4
  import { isInjectable } from "../store/model/predicates.ts";
@@ -6,30 +6,21 @@ import { cmpTs } from "../core/cmp-ts.ts";
6
6
  import { type UseSignals, useBoost } from "./relevant.ts";
7
7
 
8
8
  /**
9
- * The matcher's tokenizer. Identifier-aware (#409, RESULTS §15): the shipped
10
- * version kept `_` inside a token and never touched case, so `getUserAccount`,
11
- * `get_user_account` and `get-user-account` were three unrelated tokens.
9
+ * The matcher's tokenizer. Each identifier (a maximal run of letters, digits,
10
+ * `_`, `.`, `-`, `/`) emits TWO granularities: the whole identifier
11
+ * lower-cased, and its segments split at camelCase boundaries and separators.
12
12
  *
13
- * Each identifier (a maximal run of letters, digits, `_`, `.`, `-`, `/`) emits
14
- * TWO granularities: the whole identifier lower-cased, and its segments split
15
- * at camelCase boundaries and separators. The whole form is what preserves the
16
- * exact match the shipped tokenizer had — `db_id` and `OPENCODE_MEMORY_DIR`
17
- * stay single tokens, and an authored keyword stored fused (`memoryrecallthreshold`)
18
- * still matches the query that cites it. Dropping the whole form is the
19
- * regression that made the first version of this change abstain on `db_id`
20
- * queries and break the #40 vocabulary bridge for camelCase aliases. The
21
- * segments are what make the styles match each other: a query typed
22
- * `getUserAccount` shares `get`, `user`, `account` with a row written
13
+ * Both are load-bearing. The whole form preserves the exact identifier match:
14
+ * `db_id` and `OPENCODE_MEMORY_DIR` stay single tokens, and an authored
15
+ * keyword stored fused (`memoryrecallthreshold`) still matches the query that
16
+ * cites it. The segments make identifier styles match each other: a query
17
+ * typed `getUserAccount` shares `get`, `user`, `account` with a row written
23
18
  * `get_user_account`.
24
19
  *
25
20
  * The scan is one linear pass with no backtracking: a 4,000-character row of
26
21
  * adversarial text costs microseconds, not milliseconds.
27
22
  *
28
- * Measured on the bench fixture at the SHIPPED configuration (`kw` indexed,
29
- * store 200 and 48): lexical R@1 stays 98% and top-1 noise stays 6% — the
30
- * fixture's queries never spell the same identifier two ways, so this is a
31
- * correctness fix the fixture cannot price, not a measured win. The no-keyword
32
- * arm moves (lexical R@1 98% -> 100%), but production indexes keywords.
23
+ * History and measurements: docs/adr/0003.
33
24
  */
34
25
  export function words(text: string): string[] {
35
26
  const out: string[] = [];
@@ -103,11 +94,11 @@ export const LONG_QUERY_TOKENS = 3;
103
94
  // Ties break deliberately, in this order: open threads first (a pinned frontier
104
95
  // row beats an equal-scoring settled one — that is what the frontier is for),
105
96
  // then rows the use ledger has actually retrieved, most-recently-used first
106
- // (#42 reinforcement), then the newer row (#40 item 2: between two equally
97
+ //, then the newer row (between two equally
107
98
  // relevant facts, the one stating what is true NOW is the better guess;
108
99
  // epoch-freeze-safe because ts never changes for a given row).
109
100
  // The haystack is `scope + type + content + kw`, where `kw` are the
110
- // author-supplied aliases indexed at write time (#40 item 3, the vocabulary
101
+ // author-supplied aliases indexed at write time (the vocabulary
111
102
  // bridge for the bench's strict-paraphrase wall). Keywords are indexed, never
112
103
  // rendered, so they cannot change what a block costs.
113
104
  // Exported for bench/runners/recall-quality.ts — the benchmark measures the shipped
@@ -116,14 +107,14 @@ export const LONG_QUERY_TOKENS = 3;
116
107
  // Superseded rows are dropped HERE, not only by the callers. Every model-facing
117
108
  // sink already passes isInjectable() rows, but a scorer that can be handed a raw
118
109
  // loadAll() result must not be the one place a retired memory leaks back into
119
- // an injected block (#43 item 1: forbidden hits). The drop also keeps a
110
+ // an injected block (forbidden hits). The drop also keeps a
120
111
  // retired row from diluting the document frequencies the ranking depends on.
121
112
  /**
122
113
  * The query's distinct concepts. `words()` emits each identifier at two
123
114
  * granularities — whole form plus camel/separator segments — and the admission
124
115
  * gate must count ONE concept per identifier, not one per token: a query
125
116
  * citing `memoryRecallThreshold` is a single concept even though it emits
126
- * four tokens (review #417: the flat token count raised needShared from 1 to
117
+ * four tokens: the flat token count raised needShared from 1 to
127
118
  * 2 and a row carrying that keyword fused in `kw` stopped matching its own
128
119
  * keyword). Identifiers sharing any token — the same concept spelled two ways
129
120
  * in one query — merge into one group.
@@ -1,4 +1,4 @@
1
- // shared-terms — split from src/inject.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // The query terms a row actually carries, for evidence display.
2
2
  import { type Memory } from "../store/model/memory.ts";
3
3
  import { QUERY_STOPWORDS, haystack, words } from "./score.ts";
4
4
 
@@ -1,4 +1,4 @@
1
- // format — split from src/status.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // format — split from src/status.ts. Declaration bodies are unchanged.
2
2
 
3
3
  import { type Measured, type StatusPayload } from "./payload.ts";
4
4
 
@@ -1,4 +1,4 @@
1
- // metrics — split from src/status.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // metrics — split from src/status.ts. Declaration bodies are unchanged.
2
2
  import { join } from "node:path";
3
3
  import { evidenceDir } from "../core/config/paths.ts";
4
4
  import { parseLine } from "../core/logfmt/format.ts";
@@ -81,7 +81,7 @@ export async function captureLagLines(days = 30): Promise<string[]> {
81
81
  }
82
82
 
83
83
  /**
84
- * What the plugin's own model calls cost (#387).
84
+ * What the plugin's own model calls cost.
85
85
  *
86
86
  * Capture is a separate `generate.text` call made after the turn, so it appears
87
87
  * in NO session's usage: read from the session event stream the plugin's cost
@@ -149,7 +149,7 @@ export function captureCost(
149
149
  }
150
150
 
151
151
  /**
152
- * Capture health (#138): the answer to "is auto-capture off, misconfigured,
152
+ * Capture health: the answer to "is auto-capture off, misconfigured,
153
153
  * armed-but-inert, or alive?" read from the evidence file ALONE — the
154
154
  * `plugin_load` heartbeat names the configured state, `auto_capture_*` lines
155
155
  * name the activity. The newest heartbeat wins (a reload with new options
@@ -174,7 +174,7 @@ export interface CaptureHealth {
174
174
  /**
175
175
  * Newest `capture_lag` completion receipt in the window: proof the capture
176
176
  * ran, independent of candidate outcome. A model response of `[]` writes
177
- * only this line, so the inert verdict must consult it (#288 F1).
177
+ * only this line, so the inert verdict must consult it ( F1).
178
178
  */
179
179
  lastExecuted: string | null;
180
180
  }
@@ -218,7 +218,7 @@ export function captureHealth(
218
218
  }
219
219
  if (ev === "capture_lag") {
220
220
  // Completion receipt: the model call finished whether or not it found
221
- // candidates. Execution evidence on its own (#288 F1).
221
+ // candidates. Execution evidence on its own ( F1).
222
222
  if (ts && ts >= cutoff && (!lastExecuted || ts > lastExecuted))
223
223
  lastExecuted = ts;
224
224
  continue;
@@ -1,4 +1,4 @@
1
- // payload — split from src/status.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // payload — split from src/status.ts. Declaration bodies are unchanged.
2
2
  // The status hand-off between the two surface halves. The server plugin writes
3
3
  // one status file per session on every epoch recompute AND every measured
4
4
  // assistant turn (src/index.ts); the terminal plugin (src/tui.tsx) and the
@@ -32,7 +32,7 @@ export interface StoreCounts {
32
32
  malformed: number;
33
33
  /**
34
34
  * Active rows the use ledger has never credited (or not inside the window).
35
- * Undefined until #42's ledger is read — an absent number, never a zero.
35
+ * Undefined until ledger is read — an absent number, never a zero.
36
36
  */
37
37
  neverRetrieved?: number;
38
38
  /**
@@ -50,7 +50,7 @@ export interface StoreCounts {
50
50
  /** Capture latency in ms, p50/p95, from `capture_lag` evidence. */
51
51
  captureLag?: { p50: number; p95: number; n: number };
52
52
  /**
53
- * What the plugin's own model calls cost (#387), from `capture_cost`
53
+ * What the plugin's own model calls cost, from `capture_cost`
54
54
  * evidence. An ESTIMATE: the host gives capture no receipt. Absent until
55
55
  * evidence is read — a missing number, never a zero that reads as free.
56
56
  */
@@ -98,7 +98,7 @@ export interface Measured {
98
98
  read: number;
99
99
  write: number;
100
100
  /**
101
- * Completion tokens for the session (#387): what the model produced, split
101
+ * Completion tokens for the session: what the model produced, split
102
102
  * so a reasoning-heavy seat is visible as one. `input` alone is only the
103
103
  * uncached remainder, so quoting it as "what the session cost" understates
104
104
  * it by most of its size — measured 13,393 reported against 187,856 moved.
@@ -1,4 +1,4 @@
1
- // report — split from src/status.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // report — split from src/status.ts. Declaration bodies are unchanged.
2
2
  import { join } from "node:path";
3
3
  import { cacheRate, estTok, fmtBytes, fmtCount, fmtMs } from "./format.ts";
4
4
  import {
@@ -109,7 +109,7 @@ export function windowLines(p: StatusPayload): string[] {
109
109
  " of what you sent not measured yet — receipts appear after the first assistant turn",
110
110
  );
111
111
  }
112
- // #387: the completion side. Everything above counts the prompt only, and
112
+ // the completion side. Everything above counts the prompt only, and
113
113
  // `input` is the UNCACHED remainder, so neither was ever "what the session
114
114
  // cost" — the tokens the model produced were not reported at all. Rendered
115
115
  // only when the host reports them: an absent number stays absent rather than
@@ -149,7 +149,7 @@ export function attributionLines(p: StatusPayload): string[] {
149
149
  }
150
150
 
151
151
  /**
152
- * AUTO-CAPTURE line (#138): the chat-facing answer to "is capture off,
152
+ * AUTO-CAPTURE line: the chat-facing answer to "is capture off,
153
153
  * misconfigured, armed-but-inert, or alive?" — the states the evidence file
154
154
  * distinguishes, surfaced so a user never has to read a logfmt file to learn
155
155
  * the pipeline never ran. `unknown` means no heartbeat was found at all, which
@@ -175,7 +175,7 @@ export function captureLines(c: CaptureHealth): string[] {
175
175
  // Inert means NO execution evidence at all: no candidate line and no
176
176
  // `capture_lag` completion receipt. A successful capture whose model
177
177
  // returned `[]` writes only the receipt, and is alive, not inert
178
- // (#288 F1).
178
+ // ( F1).
179
179
  if (!c.lastExecuted && c.rows === 0 && c.blocked === 0)
180
180
  return [
181
181
  " auto-capture: ARMED BUT NEVER FIRED — capture is on, no auto_capture_* or capture_lag lines in the last 30d",
@@ -295,7 +295,7 @@ export function renderMemoryReport(input: {
295
295
  `capture lag p50 ${fmtMs(store.captureLag.p50)} / p95 ${fmtMs(store.captureLag.p95)}`,
296
296
  );
297
297
  }
298
- // #387: capture is a separate model call outside every session's usage, so
298
+ // capture is a separate model call outside every session's usage, so
299
299
  // anything that reads session numbers reports it as free. Render it even at
300
300
  // zero, with the reason, because "0" and "never ran" are different facts and
301
301
  // the plugin billed it as the first for its whole history.
@@ -1,4 +1,4 @@
1
- // Shared store counts for epoch payloads and the chat report (#168).
1
+ // Shared store counts for epoch payloads and the chat report.
2
2
  // Callers own I/O and visibility policy; this summarizes exactly their rows.
3
3
  import { neverRetrieved, type UseLedger } from "../hits/ledger.ts";
4
4
  import type { Memory } from "../store/model/memory.ts";
@@ -1,4 +1,4 @@
1
- // write — split from src/status.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // write — split from src/status.ts. Declaration bodies are unchanged.
2
2
  // The status hand-off between the two surface halves. The server plugin writes
3
3
  // one status file per session on every epoch recompute AND every measured
4
4
  // assistant turn (src/index.ts); the terminal plugin (src/tui.tsx) and the
@@ -106,8 +106,7 @@ export async function readStatus(
106
106
  }
107
107
 
108
108
  // Newest-first last `limit` write_blocked evidence rows, scanning today and
109
- // yesterday so a block just before midnight stays visible. #306 (decision #213
110
- // B): the lines follow the SAME visibility rule as memory_evidence — a row
109
+ // yesterday so a block just before midnight stays visible. (a decision// the lines follow the SAME visibility rule as memory_evidence — a row
111
110
  // stamped to another repository, or private to a named session, is not this
112
111
  // surface's data. The default is the historical unfiltered read (ADMIN_READER)
113
112
  // for out-of-plugin callers; every plugin-facing surface must pass its own
@@ -143,7 +142,7 @@ export async function blockedRecent(
143
142
  }
144
143
  }
145
144
 
146
- // #306: the Reader for the terminal panel. The TUI process owns no
145
+ // the Reader for the terminal panel. The TUI process owns no
147
146
  // session→repo map (the server binds sessions in its own process), so the
148
147
  // panel resolves the ACTIVE session's repository from its root directory —
149
148
  // resolveRepo is deterministic for the same path on this machine, hence the
@@ -86,7 +86,7 @@ export async function removeBlock(ts: string): Promise<boolean> {
86
86
  const row = parseLine(l);
87
87
  return !(row && row.ts === ts);
88
88
  });
89
- // A no-op must report as a no-op (#209): nothing was filtered, so return
89
+ // A no-op must report as a no-op: nothing was filtered, so return
90
90
  // false and skip the rewrite — republishing identical bytes bumps the
91
91
  // file identity for nothing and hands callers a success they did not earn.
92
92
  if (kept.length === lines.length) return false;
@@ -1,4 +1,4 @@
1
- // append — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // append — split from src/memory.ts. Declaration bodies are unchanged.
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { memoryRoot } from "../../core/config/paths.ts";
@@ -24,7 +24,7 @@ export interface AppendMemoryInput {
24
24
  content: string;
25
25
  issue?: string;
26
26
  tags?: string[];
27
- /** Retrieval keywords (#40); normalised and capped by appendMemory. */
27
+ /** Retrieval keywords; normalised and capped by appendMemory. */
28
28
  kw?: string[];
29
29
  status?: MemoryStatus;
30
30
  /**
@@ -45,7 +45,7 @@ export interface AppendMemoryInput {
45
45
  repo?: string;
46
46
  repoPath?: string;
47
47
  // Which session the write belongs to, when the caller knows it (the gate
48
- // threads it from GateContext, #116). Preferred over the ambient current.
48
+ // threads it from GateContext,). Preferred over the ambient current.
49
49
  sessionID?: string;
50
50
  }
51
51
 
@@ -62,7 +62,7 @@ function existingTs(text: string): Set<string> {
62
62
  return set;
63
63
  }
64
64
 
65
- // #152: the store's answer to a write whose owner it cannot determine. Thrown
65
+ // the store's answer to a write whose owner it cannot determine. Thrown
66
66
  // from the one place that knows what an owner is (the stamp resolution below),
67
67
  // so no caller — gate, import, capture, or a future one — can quietly persist
68
68
  // an ownerless row. `unresolvedWriteMessage` is the same text the model-facing
@@ -142,11 +142,11 @@ export async function appendMemory(input: AppendMemoryInput): Promise<string> {
142
142
  if (repo === undefined) {
143
143
  // The caller's session when it named one: capture awaits a model call, and
144
144
  // the last setCurrent before persistence may belong to another session
145
- // entirely (#116). Unnamed writers (tools, viewer, restore) keep the
145
+ // entirely. Unnamed writers (tools, viewer, restore) keep the
146
146
  // ambient binding.
147
147
  //
148
148
  // A NAMED session that never resolved a repository is not an unnamed one
149
- // (#152): falling back to the module scope stamped its rows into whatever
149
+ // falling back to the module scope stamped its rows into whatever
150
150
  // workspace set up last, and with no module scope at all it stamped nothing
151
151
  // — which every reader calls global. Both outcomes publish private content
152
152
  // somewhere its owner can no longer see it, so the store refuses the write
@@ -162,7 +162,7 @@ export async function appendMemory(input: AppendMemoryInput): Promise<string> {
162
162
  }
163
163
  // The day file is chosen before the lock because it IS the lock key. A
164
164
  // colliding ts is bumped inside that lock, and the bump can cross UTC midnight
165
- // — which #215 made more than cosmetic: a supersede addresses a row by the day
165
+ // — which made more than cosmetic: a supersede addresses a row by the day
166
166
  // its own ts names, so a row filed under another day is a second, unreachable
167
167
  // address for the same identity (two files can then hold the same ts). So when
168
168
  // the bumped ts leaves the day, hand the row to the file it names and take that
@@ -220,7 +220,7 @@ export async function appendMemory(input: AppendMemoryInput): Promise<string> {
220
220
  // A lock excludes writers, not readers: an O_APPEND read can end mid-row.
221
221
  // Publish the complete day file using the read already needed for IDs.
222
222
  // This costs a whole-file write and can refuse on Windows reader handles;
223
- // the old destination remains intact if publication fails (#198).
223
+ // the old destination remains intact if publication fails.
224
224
  await writeAtomic(
225
225
  file,
226
226
  prior + (prior && !prior.endsWith("\n") ? "\n" : "") + line + "\n",
@@ -1,4 +1,4 @@
1
- // deletions — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // deletions — split from src/memory.ts. Declaration bodies are unchanged.
2
2
  import { deletionsFile } from "../../core/config/paths.ts";
3
3
  import { formatLine } from "../../core/logfmt/format.ts";
4
4
  import { appendLog } from "../../core/logfmt/publish.ts";
@@ -23,12 +23,12 @@ export async function logDeletion(
23
23
  type: memory.type,
24
24
  scope: memory.scope,
25
25
  content: memory.content,
26
- // Origin survives the delete/restore round trip (#129): a restore-entry
26
+ // Origin survives the delete/restore round trip: a restore-entry
27
27
  // made from this line re-stamps what the row carried. A row with no
28
28
  // stamp writes no stamp here — the legacy global path, unchanged.
29
29
  repo: memory.repo,
30
30
  repoPath: memory.repoPath,
31
- // #207: the visibility- and provenance-bearing metadata survives here
31
+ // the visibility- and provenance-bearing metadata survives here
32
32
  // too. tags carry the quarantine marker, so a restore that reads this
33
33
  // line cannot silently release quarantine; issue and kw keep provenance
34
34
  // and recall aliases alive; status keeps an open thread open. Comma-
@@ -1,4 +1,4 @@
1
- // load — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // load — split from src/memory.ts. Declaration bodies are unchanged.
2
2
  // Durable memory store engine. Reproduces the opencode-memory logfmt format
3
3
  // (MIT, github.com/shuans/opencode-memory; license retained under
4
4
  // vendor/opencode-memory/LICENSE) and extends it with the fields the write-gate
@@ -26,7 +26,7 @@ const RESERVED = new Set([
26
26
  "deleted.logfmt",
27
27
  "canonical.logfmt",
28
28
  "blocklist.logfmt",
29
- // Value-keyed rejection tombstones (#35). Hashes only, never prose — and it
29
+ // Value-keyed rejection tombstones. Hashes only, never prose — and it
30
30
  // must never be ingested as a row, exported, or restored by undo.
31
31
  "rejected.logfmt",
32
32
  // The use ledger (src/hits.ts): telemetry, not memory. A hit line must never
@@ -122,7 +122,7 @@ export async function memoryFiles(): Promise<string[]> {
122
122
  * The day file a row's own ts names, as a `YYYY-MM-DD.logfmt` basename, or null
123
123
  * when the string is not an ISO instant. `appendMemory` mints ts at write time
124
124
  * and appends to that same day file, so for every row the plugin wrote the ts
125
- * date IS the file date (#215).
125
+ * date IS the file date.
126
126
  */
127
127
  export function dayFileName(ts: string): string | null {
128
128
  const m = /^(\d{4}-\d{2}-\d{2})T/.exec(ts);
@@ -130,7 +130,7 @@ export function dayFileName(ts: string): string | null {
130
130
  }
131
131
 
132
132
  /**
133
- * Day files ordered so the ones these ts values name come first (#215). A
133
+ * Day files ordered so the ones these ts values name come first. A
134
134
  * single-row mutation that stops as soon as it has SEEN the row then locks one
135
135
  * file instead of one per day of store age — the cost that made supersing a row
136
136
  * 25x a full read on a 30-day store.
@@ -168,7 +168,7 @@ export function previousDayName(day: string): string {
168
168
 
169
169
  /**
170
170
  * The day files that could hold a copy of `ts` — the addresses a single-row
171
- * mutation must try before it may report success (#373 review).
171
+ * mutation must try before it may report success.
172
172
  *
173
173
  * Two files, at most. The one the ts names, plus the previous day's file ONLY
174
174
  * when a text scan finds the identity in it: `appendMemory` used to pick the
@@ -1,4 +1,4 @@
1
- // prune — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // prune — split from src/memory.ts. Declaration bodies are unchanged.
2
2
  import { basename, join } from "node:path";
3
3
  import { parseLine } from "../../core/logfmt/format.ts";
4
4
  import { fileIdentity, writeAtomic } from "../../core/logfmt/publish.ts";
@@ -23,7 +23,7 @@ export interface PruneResult {
23
23
  // logging every deletion with its reason. Each file is filtered and republished
24
24
  // under the store lock, so a row another session appended while we were reading
25
25
  // is not quietly filtered out along with the targets. The reader is the
26
- // caller's captured identity (#127); out-of-plugin callers keep ambient.
26
+ // caller's captured identity; out-of-plugin callers keep ambient.
27
27
  export async function prune(
28
28
  scope: string,
29
29
  type: string,
@@ -32,7 +32,7 @@ export async function prune(
32
32
  durable: PruneResult = { deleted: [], snapshot: [] },
33
33
  ): Promise<PruneResult> {
34
34
  const { deleted, snapshot } = durable;
35
- // #206: a later file failing must not undo the bookkeeping an earlier file
35
+ // a later file failing must not undo the bookkeeping an earlier file
36
36
  // already earned, and no bookkeeping may claim a row the store never let go
37
37
  // of. So the order per file is: publish, then audit; and the tombstone pass
38
38
  // runs over everything committed even when the loop itself threw. Errors are
@@ -45,7 +45,7 @@ export async function prune(
45
45
  bookkeepingError = bookkeepingError ? `${bookkeepingError}; ${msg}` : msg;
46
46
  };
47
47
  try {
48
- // #215 narrowed the ts-addressed write paths (supersede, clearSuperseded,
48
+ // narrowed the ts-addressed write paths (supersede, clearSuperseded,
49
49
  // releaseQuarantine) to the day file the row's own ts names. This one keeps
50
50
  // the full sweep on purpose: a forget is addressed by scope/type, not by ts,
51
51
  // so the only way to know which files match is to look — and a pre-pass that
@@ -90,7 +90,7 @@ export async function prune(
90
90
  },
91
91
  LOCK_WRITE,
92
92
  );
93
- // #206 STORE-2: the deletion audit FOLLOWS the publish, as in the viewer's
93
+ // STORE-2: the deletion audit FOLLOWS the publish, as in the viewer's
94
94
  // delete (mutate.ts audits after its locked handover). Auditing inside the
95
95
  // read loop claimed rows as deleted when a snapshot/publish failure left
96
96
  // them live: the viewer's Deleted panel listed a still-live row, its
@@ -113,7 +113,7 @@ export async function prune(
113
113
  } catch (err) {
114
114
  loopError = err;
115
115
  }
116
- // #35: tombstone every forgotten VALUE, keyed on content rather than on the
116
+ // tombstone every forgotten VALUE, keyed on content rather than on the
117
117
  // row's `ts`, so replaying the source cannot store the fact again.
118
118
  //
119
119
  // ONE batched call, not one per row: `memory_forget` deletes by scope+type and
@@ -124,10 +124,10 @@ export async function prune(
124
124
  // the first, and one consistent order across the codebase is what keeps the
125
125
  // lock manager from having to reason about nesting at all.
126
126
  //
127
- // #206 STORE-1: this runs even when the loop threw. The committed rows are
127
+ // STORE-1: this runs even when the loop threw. The committed rows are
128
128
  // already out of the store, so a retry of the forget will never see them
129
129
  // again — skipping the tombstone here is how a partial forget quietly
130
- // reopened the rejection hole #35 closed. If THIS write fails too, the
130
+ // reopened the rejection hole closed. If THIS write fails too, the
131
131
  // PARTIAL reply names it: the committed rows are gone and unprotected, and
132
132
  // only a human (the viewer's reject route) can restore the marker — the
133
133
  // agreed recoverable partial-result semantics, pinned by test.
@@ -1,4 +1,4 @@
1
- // snapshots — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // snapshots — split from src/memory.ts. Declaration bodies are unchanged.
2
2
  import { open, readFile } from "node:fs/promises";
3
3
  import { basename, join } from "node:path";
4
4
  import { snapshotDir } from "../../core/config/paths.ts";
@@ -1,4 +1,4 @@
1
- // supersede — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // supersede — split from src/memory.ts. Declaration bodies are unchanged.
2
2
 
3
3
  import { basename } from "node:path";
4
4
  import {
@@ -36,7 +36,7 @@ export async function markSuperseded(
36
36
  );
37
37
  }
38
38
 
39
- // Batch supersession (#61): one lock acquisition, one read, one snapshot and
39
+ // Batch supersession: one lock acquisition, one read, one snapshot and
40
40
  // one publish PER FILE touched - N rows retire as one undo point instead of
41
41
  // N. decay and the gate's drift/canonical loops used to call markSuperseded
42
42
  // per row, which meant N full read-modify-write cycles, N undo points, and
@@ -52,8 +52,7 @@ export async function markManySuperseded(
52
52
  return (await markManySupersededReport(entries, durable)).marked.length;
53
53
  }
54
54
 
55
- // Same operation, reporting WHICH rows retired rather than how many (#158
56
- // round 3): the write gate needs the ids to keep a durable-mutation ledger,
55
+ // Same operation, reporting WHICH rows retired rather than how many:// the write gate needs the ids to keep a durable-mutation ledger,
57
56
  // because a failed audit line after a persisted retirement must still be able
58
57
  // to name what actually landed. Skipped-by-the-batch rows (already retired
59
58
  // out of band) are absent from `marked` — the ledger never claims a retirement
@@ -73,8 +72,8 @@ export async function markManySupersededReport(
73
72
  withStoreLock(
74
73
  file,
75
74
  async () => {
76
- // #106: identity BEFORE the read, like every other whole-file
77
- // read-modify-write (#89's contract) - the publish below may retry a
75
+ // identity BEFORE the read, like every other whole-file
76
+ // read-modify-write (the write contract) - the publish below may retry a
78
77
  // Windows handover only while the destination still matches this.
79
78
  const since = await fileIdentity(file);
80
79
  const lines = await readLines(file);
@@ -90,7 +89,7 @@ export async function markManySupersededReport(
90
89
  if (!fields) continue;
91
90
  // Whole line rewritten, not extended: an old-format line comes out in
92
91
  // the current format with its values unchanged (as markSuperseded did).
93
- // The one exception is SECRET SCRUB (#128, review probe 4): the
92
+ // The one exception is SECRET SCRUB: the
94
93
  // fields a merge/decay/update copies into the loser's row carry
95
94
  // caller-authored prose (the rotation note "key ghp_... rotated"),
96
95
  // and content already scrubs at this same boundary (appendMemory
@@ -116,7 +115,7 @@ export async function markManySupersededReport(
116
115
  LOCK_WRITE,
117
116
  );
118
117
 
119
- // #215 + #373 review: retire every address a row can have, and pay for it.
118
+ //+ review: retire every address a row can have, and pay for it.
120
119
  // Pass 1 walks the day files the batch's own ts values name, plus the previous
121
120
  // day's file ONLY where a cheap scan proves a second copy lives there — the
122
121
  // one shape an older `appendMemory` could write at UTC midnight. A one-row
@@ -137,14 +136,14 @@ export async function markManySupersededReport(
137
136
  }
138
137
  }
139
138
  // A ts that appears in more than one file retires in EVERY file that holds it
140
- // (#373 review): reporting a retirement while a live copy stands would be the
139
+ // reporting a retirement while a live copy stands would be the
141
140
  // worse bug, so the neighbour-day scan above exists. `appendMemory` now also
142
141
  // refuses to create the collision in the first place; the scan is what keeps a
143
142
  // store written before that fix honest.
144
143
  return { marked };
145
144
  }
146
145
 
147
- // The #126 provenance guard: which supersession a merge_review may clear.
146
+ // The provenance guard: which supersession a merge_review may clear.
148
147
  export interface ClearProvenance {
149
148
  // The review's loser: a survivor the loser itself superseded first is the
150
149
  // legitimate revival the merge exists for.
@@ -157,7 +156,7 @@ export interface ClearProvenance {
157
156
  // Drop a row's supersession markers IN PLACE (snapshot-first), making it active
158
157
  // again. Used by memory_merge_review: a declared survivor must be recallable
159
158
  // even when an earlier row — now the loser — had superseded it first.
160
- // #126: with a provenance guard the marker is cleared ONLY when it points at
159
+ // with a provenance guard the marker is cleared ONLY when it points at
161
160
  // this review's loser or carries the review's reason. A survivor superseded by
162
161
  // anything else (e.g. a memory_update that retired it after the review was
163
162
  // filed) keeps its marker and the clear reports false — erasing that later
@@ -190,7 +189,7 @@ export async function clearSuperseded(
190
189
  }
191
190
  return formatLine(parsed);
192
191
  };
193
- // #215 + #373 review: revive every copy a row has. The common case is the one
192
+ //+ review: revive every copy a row has. The common case is the one
194
193
  // day file the ts names; the previous day's file joins ONLY when a scan finds
195
194
  // the same identity in it, which is what an older midnight-boundary append
196
195
  // could write. Reviving one copy while a duplicate stayed retired would put
@@ -1,4 +1,4 @@
1
- // target — split from src/memory.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // target — split from src/memory.ts. Declaration bodies are unchanged.
2
2
 
3
3
  import { type Memory, targetScore } from "../model/memory.ts";
4
4