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
- // The use ledger (#42). Decay, consolidation and the status surfaces all act
1
+ // The use ledger. Decay, consolidation and the status surfaces all act
2
2
  // on memories today with no idea whether anybody ever reads them — the store
3
3
  // knows what was written and nothing about what was used. This module closes
4
4
  // that loop with one append-only logfmt file.
@@ -85,7 +85,7 @@ async function rotateIfNeeded(): Promise<void> {
85
85
  throw err;
86
86
  }
87
87
  if (size <= MAX_HITS_BYTES) return;
88
- // #106: anchor the halving like every other whole-file publish (#89) - on
88
+ // anchor the halving like every other whole-file publish - on
89
89
  // Windows the rename can be refused by a reader's handle, and the retry is
90
90
  // only safe while nothing else moved this file.
91
91
  const since = await fileIdentity(hitsFile());
@@ -106,7 +106,7 @@ async function rotateIfNeeded(): Promise<void> {
106
106
  *
107
107
  * `terms` are the tokens the query and these rows shared (never the query
108
108
  * itself), capped and pre-sanitised by sharedTerms() in src/inject.ts. They
109
- * exist so #45 can ask "if we merge these rows, do the same reads still
109
+ * exist so can ask "if we merge these rows, do the same reads still
110
110
  * land?" — a question no use log without them can answer.
111
111
  */
112
112
  export async function recordHits(
@@ -213,7 +213,7 @@ function parseList(value: string): string[] {
213
213
 
214
214
  /**
215
215
  * Every read the ledger recorded, in file order: the terms used and the rows it
216
- * credited. This is the corpus consolidation (#45) replays — "would this merge
216
+ * credited. This is the corpus consolidation replays — "would this merge
217
217
  * have lost a read that actually happened?" is only answerable against real
218
218
  * reads, and a per-row aggregate has already thrown the grouping away.
219
219
  */
@@ -90,7 +90,7 @@ export interface SessionUsage {
90
90
  read: number;
91
91
  write: number;
92
92
  /**
93
- * Completion tokens the session generated (#387). Absent from the envelope
93
+ * Completion tokens the session generated. Absent from the envelope
94
94
  * before this, so the plugin could report what the prompt cache cost but
95
95
  * never what the session itself produced — and `input` is only the UNCACHED
96
96
  * remainder, so the two together understate a session by most of its size.
@@ -102,7 +102,7 @@ export interface SessionUsage {
102
102
  /**
103
103
  * The message this receipt belongs to — the `message.updated` compatibility
104
104
  * path only. Streaming updates for the same message overwrite each other;
105
- * they must not overwrite another message's receipt (#394 review).
105
+ * they must not overwrite another message's receipt.
106
106
  */
107
107
  messageID?: string;
108
108
  /**
@@ -145,7 +145,7 @@ export function sessionUsageEvent(raw: unknown): SessionUsage | undefined {
145
145
  };
146
146
  }
147
147
 
148
- // #394 review: on the `message.updated` compatibility path each receipt is
148
+ // review: on the `message.updated` compatibility path each receipt is
149
149
  // ONE message's usage, not the session's. Overwriting the session total with
150
150
  // the last message displayed 90 completion tok where two messages produced
151
151
  // 160. Streaming updates arrive repeatedly per message, so the latest receipt
@@ -10,7 +10,7 @@
10
10
  // origin (fresh or remote-less): sha1 of the NORMALIZED resolved
11
11
  // path instead, so repo= is always a bare token — a raw path with
12
12
  // a space gets logfmt-quoted, which breaks naive field extraction
13
- // and can't be hash-compared (#92). path stays the human-readable
13
+ // and can't be hash-compared. path stays the human-readable
14
14
  // secondary, so rows stamped before the hash keep matching.
15
15
  // Rows carry no stamp when their writer had no scope (viewer process,
16
16
  // tests) and legacy rows predate the field: both read as GLOBAL — visible
@@ -60,7 +60,7 @@ function git(args: string[], cwd: string): string | null {
60
60
  }
61
61
  }
62
62
 
63
- // --- case-sensitivity probe (#109) --------------------------------------------
63
+ // --- case-sensitivity probe --------------------------------------------
64
64
  // Folding case by PLATFORM leaked rows across directories: a case-SENSITIVE
65
65
  // APFS volume is a legitimate macOS choice (and NTFS has per-directory
66
66
  // sensitivity), where "Foo" and "foo" really are two dirs that must not share
@@ -149,7 +149,7 @@ export function isCaseInsensitivePath(dir: string): boolean | null {
149
149
  // Normalize a directory for hashing: symlinks, junctions, and Windows 8.3
150
150
  // aliases collapse to the real path (realpath), separators unify to "/",
151
151
  // a trailing separator disappears, and case folds ONLY where the probe says
152
- // the volume folds names itself (#109) — never trusting the platform alone.
152
+ // the volume folds names itself — never trusting the platform alone.
153
153
  export function normalizeDirPath(p: string): string {
154
154
  let r = p;
155
155
  try {
@@ -186,7 +186,7 @@ export function resolveRepo(startDir: string): RepoScope {
186
186
  // --- per-session identity -----------------------------------------------------
187
187
  // Learned from session events (created / execution.started / moved). Bounded
188
188
  // by the shared session cap imported from core/lru.ts, so the two caps cannot
189
- // drift (#224): a long-lived server must not grow this with every session
189
+ // drift: a long-lived server must not grow this with every session
190
190
  // ever seen.
191
191
  const byDir = new Map<string, RepoScope>();
192
192
  const bySession = new Map<string, { dir: string; scope: RepoScope }>();
@@ -213,7 +213,7 @@ export function rememberSessionDir(sid: string, dir: string): void {
213
213
  // plugin instance may resolve an UNKNOWN session to its own setup location —
214
214
  // the caller reached this instance, so this workspace is the caller's repo as
215
215
  // far as the flow can know (never the module scope, which belongs to whoever
216
- // loaded LAST, #127's residual multi-setup gap). Real identity from the event
216
+ // loaded LAST, residual multi-setup gap). Real identity from the event
217
217
  // stream or the session-row API always replaces a provisional binding.
218
218
  const provisional = new Set<string>();
219
219
 
@@ -252,7 +252,7 @@ export function repoScopeFor(sid?: string): RepoScope | null {
252
252
  // The scope of a session bound from the event stream / session-row API, with
253
253
  // NO module-scope fallback. Read paths that carry a caller's session identity
254
254
  // resolve through this: an unbound session must fail closed to global rows
255
- // (#127), never inherit a module scope that belongs to another workspace (or
255
+ //, never inherit a module scope that belongs to another workspace (or
256
256
  // is null, which the ambient reader has always read as "everything").
257
257
  export function sessionScope(sid?: unknown): RepoScope | undefined {
258
258
  if (!isNamedSid(sid)) return undefined;
@@ -264,7 +264,7 @@ export function isNamedSid(sid: unknown): sid is string {
264
264
  return typeof sid === "string" && sid !== "" && sid !== "?";
265
265
  }
266
266
 
267
- // The repository a DURABLE WRITE belongs to (#152) — the write-side twin of
267
+ // The repository a DURABLE WRITE belongs to — the write-side twin of
268
268
  // sessionScope, and deliberately not `repoScopeFor`: that helper's last resort
269
269
  // is the module scope, which is the identity of whoever called setup() LAST.
270
270
  // Reading with the wrong owner can only ever show too little (an unbound
@@ -1,4 +1,4 @@
1
- // Per-setup session binding and caller context (#168). The host object is kept
1
+ // Per-setup session binding and caller context. The host object is kept
2
2
  // intact so optional API methods retain their receiver and are read at call time.
3
3
  import type { GateContext } from "../gate/gate.ts";
4
4
  import { captureEvidenceContext, record } from "../evidence/record.ts";
@@ -40,7 +40,7 @@ export function createSessionContext(
40
40
  ) {
41
41
  const gateContext = (sid?: string): GateContext => {
42
42
  // Every session-scoped member resolves for the CALLER's session when it
43
- // knows one (#116): capture awaits a model call between setCurrent and
43
+ // knows one: capture awaits a model call between setCurrent and
44
44
  // persistence, and on a multi-session server the global current moves
45
45
  // during that await. Falling back to getCurrent() is exactly today's
46
46
  // behavior for callers whose current IS their session (tool hooks).
@@ -65,7 +65,7 @@ export function createSessionContext(
65
65
  };
66
66
  };
67
67
 
68
- // A durable write needs an OWNER (#152). Reads already fail closed for a
68
+ // A durable write needs an OWNER. Reads already fail closed for a
69
69
  // session whose repository never resolved — it sees global rows and nothing
70
70
  // else — so such a session may not write either: the alternatives were the
71
71
  // last setup's repository or an unstamped (hence global) row. This answers
@@ -91,14 +91,14 @@ export function createSessionContext(
91
91
  // execute a per-call ToolContext carrying sessionID; the harness and any
92
92
  // host that omits it fall back to the ambient current, which is correct
93
93
  // exactly because execute.before ran immediately before this tool with
94
- // no await between (#116's documented fallback). Never re-read the global
95
- // after an await to learn who is calling (#127).
94
+ // no await between ( documented fallback). Never re-read the global
95
+ // after an await to learn who is calling.
96
96
  const toolIds = (context?: unknown): { sid: string; call: string } => {
97
97
  const { sessionID: fromCtx, callID: call } = toolIdentity(context);
98
98
  // Entry binding: a session this instance has never seen is resolved to
99
99
  // THIS workspace (provisional — a firm event/API identity still
100
100
  // replaces it), so the tool's reader partitions by the repository the
101
- // call reached, not by the last setup's module scope (#127).
101
+ // call reached, not by the last setup's module scope.
102
102
  if (fromCtx && fromCtx !== "?") {
103
103
  bindSessionProvisional(fromCtx, instanceDir);
104
104
  }
@@ -185,7 +185,7 @@ export function createSessionContext(
185
185
  // host cannot describe (fresh, or a host without the lookup) is bound to
186
186
  // THIS instance's workspace — the caller's repository as the flow knows
187
187
  // it, and strictly better than an unbound read inheriting the module
188
- // scope of whoever loaded last (#127's multi-setup residue).
188
+ // scope of whoever loaded last (multi-setup residue).
189
189
  async function bindSessionIdentity(sid: string | undefined): Promise<void> {
190
190
  if (!sid || sid === "?" || sessionDirFirm(sid)) return;
191
191
  await bindSessionFromMessages(sid);
package/src/index.ts CHANGED
@@ -123,7 +123,7 @@ const impl = {
123
123
  // only as the gate's verification tree when no session location is known.
124
124
  const setupRoot = ctx?.location?.directory;
125
125
  const liveRoot = setupRoot ?? process.cwd();
126
- // #138: mirror every swallowed guarded() failure into the evidence file.
126
+ // mirror every swallowed guarded() failure into the evidence file.
127
127
  // Hook name + error class ONLY — never the message, which can carry
128
128
  // conversation content. Fire-and-forget: evidence must not add a failure
129
129
  // to a path that already failed softly.
@@ -143,7 +143,7 @@ const impl = {
143
143
  setRepoScope(setupRoot ? resolveRepo(setupRoot) : null);
144
144
  // THIS instance's own workspace. The module scope says who loaded last;
145
145
  // this says who I am. An unbound session that calls into THIS instance
146
- // resolves here — never to another instance's scope (#127, multi-setup).
146
+ // resolves here — never to another instance's scope (multi-setup).
147
147
  const instanceDir =
148
148
  typeof setupRoot === "string" && setupRoot ? setupRoot : undefined;
149
149
 
@@ -182,7 +182,7 @@ const impl = {
182
182
  } = createSessionContext(ctx, { instanceDir, liveRoot });
183
183
 
184
184
  // ---- tools --------------------------------------------------------------
185
- // Use ledger (#42). `query` is what retrieval was asked with; what gets
185
+ // Use ledger. `query` is what retrieval was asked with; what gets
186
186
  // stored is the vocabulary the answer SHARES with the query, taken from the
187
187
  // memory side, so the ledger can never become a copy of user prompts.
188
188
  // Fail-soft inside recordHits: telemetry must not break a read path.
@@ -274,7 +274,7 @@ const impl = {
274
274
  });
275
275
  onCompactCapture = capture.onCompactCapture;
276
276
  const captureCleanup = capture.cleanup;
277
- // ---- startup heartbeat (#138) ------------------------------------------
277
+ // ---- startup heartbeat ------------------------------------------
278
278
  // Every other evidence line is written BY something that already worked,
279
279
  // so "capture is off", "capture is misconfigured" and "capture is armed and
280
280
  // inert" were indistinguishable from anything a user could read - which is
@@ -294,7 +294,7 @@ const impl = {
294
294
  // a heartbeat with an unknown version still beats no heartbeat
295
295
  }
296
296
  const wantCapture = ctx.options?.autoCapture === true;
297
- // #139: an omitted captureModel is a valid arm — the capture inherits
297
+ // an omitted captureModel is a valid arm — the capture inherits
298
298
  // the session's model (session.context) or the host default. Only an
299
299
  // explicit but malformed string is invalid_model.
300
300
  const captureModelOpt = ctx.options?.captureModel;
@@ -314,7 +314,7 @@ const impl = {
314
314
  const captureState = !wantCapture
315
315
  ? // captureOnCompact alone is a distinct misconfiguration (the
316
316
  // runtime warns about it and stays disabled) — name it, or "off
317
- // (default)" and "wrong switch set" share one line (#138).
317
+ // (default)" and "wrong switch set" share one line.
318
318
  ctx.options?.captureOnCompact === true
319
319
  ? "switch_mismatch"
320
320
  : "off"
@@ -1,10 +1,10 @@
1
- // detect — split from src/init.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // detect — split from src/init.ts. Declaration bodies are unchanged.
2
2
  // Repository init: re-derive build/test command memories through the write gate.
3
3
  // Deterministic (no model calls): manifests are parsed locally and every write
4
4
  // goes through the 4-gate pipeline with the `trusted` flag (plugin-authored
5
5
  // bookkeeping, not model claims). Degrades gracefully when git is absent, so
6
6
  // install-from-scratch still writes script memories.
7
- // The codebase-memory graph integration was removed (#231): no read or gate
7
+ // The codebase-memory graph integration was removed: no read or gate
8
8
  // path ever consumed the index, and spawning a pinned third-party binary in
9
9
  // the user's repository was a supply-chain surface with no consumer.
10
10
  import { join } from "node:path";
@@ -66,7 +66,7 @@ async function readText(root: string, file: string): Promise<string | null> {
66
66
  // A script key becomes the command a later session is told to run, so it may
67
67
  // only be an identifier: no whitespace and no shell metacharacter can survive
68
68
  // into `npm run <key>`. `:` and `.` are allowed because `test:ci` and
69
- // `lint.fix` are ordinary npm keys (this is wider than #301's literal
69
+ // `lint.fix` are ordinary npm keys (this is wider than literal
70
70
  // `[A-Za-z0-9_-]+`, which would drop them; the rejection this ticket is about —
71
71
  // `test && echo SYNTHETIC` — is rejected either way). Make/Just targets use the
72
72
  // narrower class already, and a Make target cannot contain `:` in any case.
@@ -1,10 +1,10 @@
1
- // format — split from src/init.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // format — split from src/init.ts. Declaration bodies are unchanged.
2
2
  // Repository init: renders the runInit summary for the tool reply. The
3
- // codebase-memory graph line is gone with the graph integration (#231).
3
+ // codebase-memory graph line is gone with the graph integration.
4
4
  import { type InitSummary } from "./run.ts";
5
5
 
6
6
  export function formatInit(s: InitSummary): string {
7
- // #376 review: a migration whose file write failed is not a migration. The row
7
+ // review: a migration whose file write failed is not a migration. The row
8
8
  // was honoured, so this run is still idempotent, but nothing was copied — the
9
9
  // reply says so instead of claiming a migration that left no file behind.
10
10
  const migrated = s.stampMigrated
@@ -14,11 +14,11 @@ export function formatInit(s: InitSummary): string {
14
14
  : "";
15
15
  // A retirement that did not land is named, in the same spirit as the re-tag
16
16
  // repair's partial count: the migration is durable, the row is still there,
17
- // and the operator reads which half failed (#376 review).
17
+ // and the operator reads which half failed.
18
18
  const retireFault = s.stampRetireError
19
19
  ? `Legacy stamp row NOT retired (${s.stampRetireError}); it stays in the store, withheld from recall. Run init again.`
20
20
  : "";
21
- // #375: a repair that did something, or could not finish, is reported. A quiet
21
+ // a repair that did something, or could not finish, is reported. A quiet
22
22
  // "Nothing to do." over a store that still holds a live poisoned row is the
23
23
  // failure this ticket exists to remove.
24
24
  const r = s.retag;
@@ -34,7 +34,7 @@ export function formatInit(s: InitSummary): string {
34
34
  if (s.skipped) {
35
35
  // The skip path can carry a stamp fault of its own: the migration honoured a
36
36
  // legacy row and could not write the file, so the next init re-migrates.
37
- // Silence here is what let a failed migration report success (#376 review).
37
+ // Silence here is what let a failed migration report success.
38
38
  const fault = s.stampError
39
39
  ? `; stamp NOT recorded (${s.stampError}) — the migration will be retried`
40
40
  : "";
package/src/init/retag.ts CHANGED
@@ -1,6 +1,6 @@
1
- // One-time repair for rows stored before #372 screened init's writes (#375).
1
+ // One-time repair for rows stored before screened init's writes.
2
2
  //
3
- // #372 made `/repo-init` run the injection screen over the rows it writes, so a
3
+ // made `/repo-init` run the injection screen over the rows it writes, so a
4
4
  // checkout sitting in a directory named `eval (x)` now gets its command memories
5
5
  // tagged `quarantine`. That covers writes made after it shipped. A store that
6
6
  // already holds an untagged poisoned row keeps it, and re-running init cannot
@@ -40,7 +40,7 @@ export interface RetagResult {
40
40
  blocked: number;
41
41
  /** Promoted, but the retirement did not land (another supersession won). */
42
42
  partial: number;
43
- /** Promoted with a fallen `write_promoted` audit line (#155 class). */
43
+ /** Promoted with a fallen `write_promoted` audit line. */
44
44
  unaudited: number;
45
45
  /** Hits left unprocessed because the per-run bound was reached. */
46
46
  remaining: number;
@@ -48,7 +48,7 @@ export interface RetagResult {
48
48
  collateral: string[];
49
49
  /**
50
50
  * Retirement attempts that REJECTED (lock contention) rather than returning
51
- * false (#378 review). The replacement is durable; the original is not.
51
+ * false. The replacement is durable; the original is not.
52
52
  * Counted in `partial`, named here.
53
53
  */
54
54
  failures: string[];
@@ -134,7 +134,7 @@ export async function retagQuarantinedRows(
134
134
  out.blocked++;
135
135
  continue;
136
136
  }
137
- // #378 review (WhollyMindless): two ways the unsafe original survived.
137
+ // Two ways the unsafe original survived.
138
138
  // (a) COLLAPSED is not "nothing happened" here — it means a quarantined
139
139
  // twin from an earlier interrupted repair is already durable, and the
140
140
  // only missing step is retiring the original. Refusing to act on the
@@ -146,7 +146,7 @@ export async function retagQuarantinedRows(
146
146
  // (b) markSuperseded can REJECT (lock contention), not just return false.
147
147
  // The twin is durable either way, so the failure lands in `partial`
148
148
  // with its reason instead of escaping as if nothing was written —
149
- // the #155 lesson, applied to the repair path.
149
+ // the lesson, applied to the repair path.
150
150
  const successor =
151
151
  outcome.action === "collapsed" ? outcome.collapsedWith : outcome.ts;
152
152
  if (successor === undefined) {
@@ -175,7 +175,7 @@ export async function retagQuarantinedRows(
175
175
  if (!out.collateral.includes(ts)) out.collateral.push(ts);
176
176
  if (!retired) {
177
177
  // The replacement IS durable. Name which half did not land, in the shape
178
- // memory_update uses (#155), instead of counting a clean re-tag.
178
+ // memory_update uses, instead of counting a clean re-tag.
179
179
  out.partial++;
180
180
  continue;
181
181
  }
package/src/init/run.ts CHANGED
@@ -1,11 +1,11 @@
1
- // run — split from src/init.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // run — split from src/init.ts. Declaration bodies are unchanged.
2
2
  // Repository init: re-derive build/test command memories through the write gate
3
3
  // and record an init stamp keyed on git HEAD. Deterministic (no model calls):
4
4
  // manifests are parsed locally and every write goes through the 4-gate pipeline
5
5
  // with the `trusted` flag (plugin-authored bookkeeping, not model claims).
6
6
  // Degrades gracefully when git is absent, so install-from-scratch still writes
7
- // script memories. The codebase-memory graph integration was removed (#231).
8
- // The stamp is a file under the memory root, not a memory row (#374): see
7
+ // script memories. The codebase-memory graph integration was removed.
8
+ // The stamp is a file under the memory root, not a memory row: see
9
9
  // src/init/stamp.ts for why a row was forgeable.
10
10
  import { basename } from "node:path";
11
11
  import { readerFromSid } from "../store/model/visibility.ts";
@@ -27,7 +27,7 @@ import { readStamp, writeStampFile } from "./stamp.ts";
27
27
  export interface InitArgs {
28
28
  liveRoot: string;
29
29
  force?: boolean;
30
- // The calling session (#127): rows this writes are stamped for the CALLER,
30
+ // The calling session: rows this writes are stamped for the CALLER,
31
31
  // resolved after runInit's own awaits (git probing) rather than from the
32
32
  // ambient current, which a concurrent session may have moved.
33
33
  sessionID?: string;
@@ -43,19 +43,19 @@ export interface InitSummary {
43
43
  written: number;
44
44
  collapsed: number;
45
45
  blocked: number;
46
- /** Written rows whose write_promoted audit line fell (#155 review). */
46
+ /** Written rows whose write_promoted audit line fell. */
47
47
  unaudited?: number;
48
- /** The stamp file could not be written; init must be re-run (#374). */
48
+ /** The stamp file could not be written; init must be re-run. */
49
49
  stampError?: string;
50
- /** True when a pre-#374 store row was honoured and copied to the file. */
50
+ /** True when a legacy store-row stamp was honoured and copied to the file. */
51
51
  stampMigrated?: boolean;
52
52
  /**
53
- * A honoured pre-#374 row is still active: its retirement did not land
54
- * (#376 review). The migration itself is durable; the row is inert either
53
+ * A honoured legacy stamp row is still active: its retirement did not
54
+ * land. The migration itself is durable; the row is inert either
55
55
  * way, and the operator hears about it instead of reading a clean migration.
56
56
  */
57
57
  stampRetireError?: string;
58
- /** Pre-#372 rows re-tagged by the injection screen (#375). */
58
+ /** Rows stored before the injection screen existed, re-tagged. */
59
59
  retag?: RetagResult;
60
60
  }
61
61
 
@@ -76,12 +76,12 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
76
76
  ...writeEvidence(args.sessionID ?? getCurrent().sid),
77
77
  hasGateCheck: hasGateCheck(args.sessionID ?? getCurrent().sid),
78
78
  // Stamps land on the caller's session even though runInit awaits git
79
- // probing before the gate writes (#127 / #121's write-side root cause).
79
+ // probing before the gate writes ( / write-side root cause).
80
80
  sessionID: args.sessionID,
81
81
  trusted: true,
82
82
  };
83
83
 
84
- // #375: repair rows written before #372 screened init's output. This runs
84
+ // repair rows written before screened init's output. This runs
85
85
  // BEFORE the stamp check on purpose — the common poisoned store belongs to a
86
86
  // repository init has already stamped, and returning early would leave the
87
87
  // poisoned row live forever. The scan is one store read and five regexes per
@@ -89,7 +89,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
89
89
  const retag = await retagQuarantinedRows(gateCtx);
90
90
 
91
91
  // The stamp is read from (and written to) a file named for the repository
92
- // identity key, never from a row a model could write (#374). The write target
92
+ // identity key, never from a row a model could write. The write target
93
93
  // already holds that identity, so the common path spends no git probes here.
94
94
  // Scope is still a basename, so two "api" checkouts stay apart: the key, not
95
95
  // the name, decides which stamp a repository reads.
@@ -109,7 +109,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
109
109
  head,
110
110
  since: prior.ts,
111
111
  migrated: migrated || undefined,
112
- // #376 review: a migration that honoured the row but could not write the
112
+ // review: a migration that honoured the row but could not write the
113
113
  // file, or could not retire it, is a fault the skip line has to carry.
114
114
  // Without it every later init re-migrates and re-claims success with no
115
115
  // audit trail saying the file was never there.
@@ -152,7 +152,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
152
152
  let written = 0;
153
153
  let collapsed = 0;
154
154
  let blocked = 0;
155
- // Promoted rows whose write_promoted audit line fell (#155 review: the
155
+ // Promoted rows whose write_promoted audit line fell (the
156
156
  // fault must be visible to every writer, bookkeeping included).
157
157
  let unaudited = 0;
158
158
  for (const s of scripts) {
@@ -160,7 +160,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
160
160
  // Auto-capture and import both screen their candidate for injection-shaped
161
161
  // text; init's rows are external text too — the scope is the checkout
162
162
  // directory basename and the command comes from the manifest — so they get
163
- // the same scan (#302). A match is still stored, tagged `quarantine`, and
163
+ // the same scan. A match is still stored, tagged `quarantine`, and
164
164
  // withheld from recall and injection.
165
165
  const outcome = await runWriteGate(
166
166
  quarantineCandidate({
@@ -179,7 +179,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
179
179
  }
180
180
 
181
181
  // The stamp is bookkeeping about this run, not a claim for the model to read,
182
- // so it is a file rather than a gated row (#374). A fault is reported, never
182
+ // so it is a file rather than a gated row. A fault is reported, never
183
183
  // swallowed: the honest consequence is "init will run again", and saying so
184
184
  // beats a stamp the operator believes was written.
185
185
  const stampTs = new Date().toISOString();
@@ -198,7 +198,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
198
198
  unaudited,
199
199
  stamp: stampError ? "-" : stampTs,
200
200
  stamp_error: stampError,
201
- // A migration that copied the row but could not retire it (#376 review).
201
+ // A migration that copied the row but could not retire it.
202
202
  stamp_retire_error: retireError,
203
203
  migrated: migrated || undefined,
204
204
  retagged: retag.retagged || undefined,
package/src/init/stamp.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // The init stamp: plugin-internal bookkeeping for /repo-init idempotency.
2
2
  //
3
- // It deliberately does NOT live in the memory store (#374). A store row is
3
+ // It deliberately does NOT live in the memory store. A store row is
4
4
  // reachable through `memory_remember` and `memory_import`, and nothing reserved
5
5
  // the `init-stamp` tag, so any session could write a `context` row naming the
6
6
  // current short HEAD and make every later `memory_init` answer "Already
@@ -18,7 +18,7 @@
18
18
  // is ignored, and init re-runs: idempotent, cheap, and the safe answer to a
19
19
  // provenance the plugin cannot check. A row that passes the pairing is copied to
20
20
  // the file and then retired, and the head it is copied at is the head that
21
- // evidence line names — never the head the row's own prose claims (#376 review).
21
+ // evidence line names — never the head the row's own prose claims.
22
22
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
23
23
  import { join } from "node:path";
24
24
  import { memoryRoot } from "../core/config/paths.ts";
@@ -109,8 +109,7 @@ function readStampFile(key: string): InitStamp | null {
109
109
  * the evidence line to whatever day it is when the line lands. An init that
110
110
  * starts at 23:59:59.999 and finishes after midnight splits the pair across two
111
111
  * day files, so the row's own day is not enough — the following day has to be
112
- * read too, or that migration is silently lost every night around midnight
113
- * (#376 review).
112
+ * read too, or that migration is silently lost every night around midnight.
114
113
  */
115
114
  function auditDays(ts: string): string[] {
116
115
  const day = /^(\d{4}-\d{2}-\d{2})T/.exec(ts)?.[1];
@@ -122,18 +121,19 @@ function auditDays(ts: string): string[] {
122
121
  }
123
122
 
124
123
  /**
125
- * Did a real init audit this row, and at which head? The pre-#374 run wrote
126
- * `stamp=<row ts>` and `head=<head>` into its `init_complete` evidence line, so
124
+ * Did a real init audit this row, and at which head? The legacy store-row
125
+ * stamp wrote `stamp=<row ts>` and `head=<head>` into its `init_complete`
126
+ * evidence line, so
127
127
  * the pairing is the provenance the row itself cannot supply. Parsed
128
128
  * field-by-field: a value that merely contains the text cannot satisfy it.
129
129
  *
130
- * The head comes from the EVIDENCE LINE, never from the row's prose (#376
131
- * review). `appendMemory` mints `ts` at millisecond resolution and `runInit`
130
+ * The head comes from the EVIDENCE LINE, never from the row's prose.
131
+ * `appendMemory` mints `ts` at millisecond resolution and `runInit`
132
132
  * mints its stamp timestamp the same way, so two concurrent writes can land on
133
- * the same millisecond — 42 of 480 rows did in the review's probe. Pairing on
133
+ * the same millisecond — 42 of 480 rows did in a probe on a live store.
134
134
  * `stamp === ts` alone would then let a row that names one head retire a
135
- * repository's idempotency at a different head, which is the forgery #374 was
136
- * opened to close. Returns null when no line names this ts with a usable head.
135
+ * repository's idempotency at a different head — the forgery this check exists
136
+ * to close. Returns null when no line names this ts with a usable head.
137
137
  */
138
138
  async function initAuditHead(ts: string): Promise<string | null> {
139
139
  for (const day of auditDays(ts)) {
@@ -157,7 +157,7 @@ async function initAuditHead(ts: string): Promise<string | null> {
157
157
  return null;
158
158
  }
159
159
 
160
- /** The pre-#374 stamp: a `context` row in this scope tagged `init-stamp`. */
160
+ /** The legacy stamp: a `context` row in this scope tagged `init-stamp`. */
161
161
  async function legacyStampRow(
162
162
  scope: string,
163
163
  reader: Reader,
@@ -179,17 +179,17 @@ export interface StampRead {
179
179
  stamp: InitStamp | null;
180
180
  /** The repository identity key the stamp file is (or would be) named for. */
181
181
  key: string;
182
- /** True when a pre-#374 store row was honoured and copied to the file. */
182
+ /** True when a legacy store-row stamp was honoured and copied to the file. */
183
183
  migrated: boolean;
184
184
  /**
185
- * The migration copy could not be written (#376 review). The row was still
185
+ * The migration copy could not be written. The row was still
186
186
  * honoured, so init stays idempotent for this run, but nothing was recorded:
187
187
  * the caller must report it the way a failed stamp write is reported, or every
188
188
  * later init re-migrates and re-claims success.
189
189
  */
190
190
  stampError?: string;
191
191
  /**
192
- * The honoured row is still active (#376 review): its retirement was refused
192
+ * The honoured row is still active: its retirement was refused
193
193
  * or threw. The migration is not lost — the file answers the next read — but
194
194
  * the store keeps a row the operator should hear about.
195
195
  */
@@ -230,7 +230,7 @@ export async function readStamp(
230
230
  }
231
231
 
232
232
  /**
233
- * Retire the row a migration just copied (#376 review). The stamp lives in the
233
+ * Retire the row a migration just copied. The stamp lives in the
234
234
  * file now, so leaving the row active would keep a piece of plugin bookkeeping in
235
235
  * the store as an ordinary row; `isInjectable` already withholds the tag from
236
236
  * every model-facing read, and this takes it out of the store's active set too.
@@ -283,7 +283,7 @@ export function writeStampFile(
283
283
  mkdirSync(stampDir(), { recursive: true, mode: 0o700 });
284
284
  tightenDirectory(stampDir());
285
285
  preparePrivateFile(path);
286
- // Per-call temp name (#89): two inits on one store must never rename each
286
+ // Per-call temp name: two inits on one store must never rename each
287
287
  // other's half-written temp over a stamp.
288
288
  const tmp = `${path}.${process.pid}.${Date.now()}.tmp`;
289
289
  writeFileSync(
@@ -1,4 +1,4 @@
1
- // anchor — split from src/inject.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // anchor — split from src/inject.ts. Declaration bodies are unchanged.
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";
@@ -1,4 +1,4 @@
1
- // budget — split from src/inject.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // budget — split from src/inject.ts. Declaration bodies are unchanged.
2
2
  import { type Memory } from "../store/model/memory.ts";
3
3
  import { formatMemory } from "./format.ts";
4
4
  import { omittedLine } from "../recall/score.ts";
@@ -1,4 +1,4 @@
1
- // digest — split from src/inject.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // digest — split from src/inject.ts. Declaration bodies are unchanged.
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";
@@ -20,7 +20,7 @@ import { type TransformOutput } from "./pull.ts";
20
20
  const OPEN_THREAD_LIMIT = 3;
21
21
 
22
22
  const frontierInjectedSessions = new Set<string>();
23
- // #224: the "once per process" set is bounded by the shared session cap. An
23
+ // the "once per process" set is bounded by the shared session cap. An
24
24
  // evicted session is shown the frontier block once more on a later prompt —
25
25
  // one extra evidence row, never unbounded growth.
26
26
  const frontierOrder = new SessionLru(SESSION_CAP, (sid) => {
@@ -46,16 +46,16 @@ export async function systemDigest(
46
46
  ? String((_input as Record<string, unknown>).sessionID)
47
47
  : "?";
48
48
  // Snapshot before any awaits; unresolved callers still need a private sid
49
- // on their evidence even when ordinary call metadata is suppressed (#297).
49
+ // on their evidence even when ordinary call metadata is suppressed.
50
50
  const evidenceContext = captureEvidenceContext(sid);
51
51
  // Repo-scoped: model-facing reads see the CALLER's repo + global rows, via
52
- // the sid carried on this flow's input (#127) — never a global re-read
52
+ // the sid carried on this flow's input — never a global re-read
53
53
  // after the loadAll await.
54
54
  const mems = (
55
55
  opts.rows ?? visibleTo(await loadAll(), readerFromSid(sid))
56
56
  ).filter(isInjectable);
57
57
  if (!mems.length) return;
58
- // CACHE-STABLE BY CONSTRUCTION (issue #162): this line carries no row count
58
+ // CACHE-STABLE BY CONSTRUCTION (issue): this line carries no row count
59
59
  // and no latest-ts. Both change on every promoted write, and the digest rides
60
60
  // the FRONT of the system prompt, so one volatile byte invalidated the whole
61
61
  // cached prefix — every memory write cost the next request a full re-prefill.