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,5 +1,5 @@
1
- // propose — split from src/consolidate.ts (#168 domain restructure). Declaration bodies are unchanged.
2
- // Consolidation proposals (#45): episodic rows → one canonical row, proposed and
1
+ // propose — split from src/consolidate.ts. Declaration bodies are unchanged.
2
+ // Consolidation proposals: episodic rows → one canonical row, proposed and
3
3
  // measured, never silently applied.
4
4
  //
5
5
  // The write-gate already collapses byte-identical restatements and flags >0.9
@@ -25,7 +25,7 @@
25
25
  // reads as the best single member did. "Looks redundant" is not a reason.
26
26
  // 3. PROPOSALS, not writes. Nothing here mutates the store. A human resolves a
27
27
  // proposal through memory_merge_review (supersede-not-delete, recoverable).
28
- // 4. The most recently used member is never a loser (#42's rule, inherited).
28
+ // 4. The most recently used member is never a loser (the rule, inherited).
29
29
  import type { Memory } from "../store/model/memory.ts";
30
30
  import type { UseSignal } from "../hits/ledger.ts";
31
31
  import { cmpTs } from "../core/cmp-ts.ts";
@@ -127,7 +127,7 @@ export function clustersFor(
127
127
  * The canonical row of a cluster: the most recently used member, falling back to
128
128
  * the newest row when the ledger knows nothing. Recency in the boost is not
129
129
  * recency in the ledger — a row that retrieval has actually been landing on is
130
- * the one worth keeping, and this is #42's rule applied to merges.
130
+ * the one worth keeping, and this is rule applied to merges.
131
131
  */
132
132
  export function survivorFor(
133
133
  cluster: Memory[],
@@ -1,4 +1,4 @@
1
- // render — split from src/consolidate.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // render — split from src/consolidate.ts. Declaration bodies are unchanged.
2
2
 
3
3
  import { type ProposalReport } from "./propose.ts";
4
4
  import { flattenMemoryText } from "../store/sanitize.ts";
@@ -14,7 +14,7 @@ export function renderProposals(report: ProposalReport): string {
14
14
  out.push(
15
15
  `${p.id} ${p.type}/${p.scope} ${p.losers.length + 1} rows → 1`,
16
16
  ` keep ${p.survivor.ts}`,
17
- // Row prose is multiline in the store and flattened only here (#299):
17
+ // Row prose is multiline in the store and flattened only here:
18
18
  // one row is one output line, the same rule memory_recall follows.
19
19
  ` ${flattenMemoryText(p.survivor.content.slice(0, 160))}`,
20
20
  ...p.losers.map(
@@ -1,4 +1,4 @@
1
- // cmp-ts — split from src/inject.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // cmp-ts — split from src/inject.ts. Declaration bodies are unchanged.
2
2
 
3
3
  // Numeric compare, with the string compare kept as fallback for non-dates
4
4
  // (the ledger hands "" when a row was never used). ISO strings agree with
@@ -1,4 +1,4 @@
1
- // budgets — split from src/config.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // budgets — split from src/config.ts. Declaration bodies are unchanged.
2
2
 
3
3
  // Character budget for the injected "Relevant durable memory" block (the
4
4
  // cache-safe epoch injection). Overridable via OPENCODE_MEMORY_INJECT_BUDGET
@@ -1,4 +1,4 @@
1
- // paths — split from src/config.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // paths — split from src/config.ts. Declaration bodies are unchanged.
2
2
  // Store paths for the self-improvement harness. Everything lives OUTSIDE any
3
3
  // repository: under ~/.config/opencode/memory by default, or
4
4
  // under $OPENCODE_MEMORY_DIR when set (tests use this for hermetic runs).
@@ -24,7 +24,7 @@ export const USER_GUIDED_TAG = "user-guided";
24
24
  * A row that is genuinely restatable gets the tag again from the next capture
25
25
  * pass, so dropping it costs a demotion and never a fact.
26
26
  *
27
- * The viewer's edit path deliberately does NOT go through here: #129 keeps tag
27
+ * The viewer's edit path deliberately does NOT go through here: keeps tag
28
28
  * provenance across a typo fix, where the verdict still describes the prose, and
29
29
  * a human can clear the tag by hand.
30
30
  */
package/src/core/hooks.ts CHANGED
@@ -1,6 +1,6 @@
1
- // Fail-soft wrapper for plugin bookkeeping hooks (#168).
1
+ // Fail-soft wrapper for plugin bookkeeping hooks.
2
2
  //
3
- // Fail-soft must never mean invisible (#138): a plugin whose hook failed on
3
+ // Fail-soft must never mean invisible: a plugin whose hook failed on
4
4
  // EVERY turn looked identical to a healthy one in every artifact, because the
5
5
  // only trace was a console.warn into the host log. setup() installs a failure
6
6
  // reporter that mirrors each swallowed error into the evidence file; the
@@ -24,10 +24,10 @@ export async function guarded(
24
24
  fn: () => Promise<void>,
25
25
  // Optional: "is this failure still worth a receipt?" A caller that owns a
26
26
  // lifecycle passes `() => !disposed`. Teardown is not a capture failure
27
- // (#211): once cleanup() has returned the caller may have removed the store,
27
+ // once cleanup() has returned the caller may have removed the store,
28
28
  // so mirroring the rejection into evidence is the ENOENT noise that issue was
29
29
  // filed about — the same reason the idle capture path checks its abort signal
30
- // inside its own catch. Omitted, the #138 contract is untouched: every
30
+ // inside its own catch. Omitted, the contract is untouched: every
31
31
  // swallowed failure is mirrored.
32
32
  reportable?: () => boolean,
33
33
  ): Promise<void> {
package/src/core/host.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Structural subset of the OpenCode host used by setup and hook wiring (#168).
1
+ // Structural subset of the OpenCode host used by setup and hook wiring.
2
2
  interface ToolDef {
3
3
  name: string;
4
4
  description: string;
@@ -1,4 +1,4 @@
1
- // format — split from src/logfmt.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // format — split from src/logfmt.ts. Declaration bodies are unchanged.
2
2
 
3
3
  export const IS_WINDOWS = process.platform === "win32";
4
4
 
@@ -1,4 +1,4 @@
1
- // publish — split from src/logfmt.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // publish — split from src/logfmt.ts. Declaration bodies are unchanged.
2
2
  // Minimal logfmt reader/writer shared by the durable store and the evidence
3
3
  // log. Field order is preserved on write so chains are diffable.
4
4
  import { dirname } from "node:path";
@@ -1,4 +1,4 @@
1
- // read — split from src/logfmt.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // read — split from src/logfmt.ts. Declaration bodies are unchanged.
2
2
  import { readFile } from "node:fs/promises";
3
3
 
4
4
  export async function readLines(file: string): Promise<string[]> {
package/src/core/lru.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  // evicted session simply starts over (no block until its next prompt, then a
6
6
  // "first" epoch), which costs one recompute and never serves stale state.
7
7
  // Single shared cap: repokey.ts's session-scope cache imports this constant,
8
- // so the ledgers cannot drift (#224).
8
+ // so the ledgers cannot drift.
9
9
  export const SESSION_CAP = 64;
10
10
 
11
11
  export class SessionLru {
package/src/core/state.ts CHANGED
@@ -27,7 +27,7 @@ export interface FirstTap {
27
27
  export interface SessionState {
28
28
  sid: string;
29
29
  calls: ToolResult[];
30
- // Lifetime facts that outlive the CALLS_CAP tail (#224): calls keeps only
30
+ // Lifetime facts that outlive the CALLS_CAP tail: calls keeps only
31
31
  // the most recent CALLS_CAP entries, so counts and ever-seen signals are
32
32
  // recorded as they happen instead of being derived from the array.
33
33
  callsTotal: number;
@@ -48,7 +48,7 @@ export interface SessionState {
48
48
  count: number;
49
49
  fix?: { call: string; index: number };
50
50
  } | null;
51
- // Bounded provenance for write telemetry (#163), independent of the full
51
+ // Bounded provenance for write telemetry, independent of the full
52
52
  // calls ledger used by grounding, attribution, and convergence.
53
53
  writeEvidence?: {
54
54
  recent: string[];
@@ -65,7 +65,7 @@ export interface SessionState {
65
65
  finalized: boolean;
66
66
  }
67
67
 
68
- // Rows this session promoted, for the riding-bytes rule (#165): a session must
68
+ // Rows this session promoted, for the riding-bytes rule: a session must
69
69
  // not pay a prompt-cache bust to be shown a fact it wrote itself, because that
70
70
  // fact is already in its transcript. Filled where a write is promoted (the one
71
71
  // place a row is created ON behalf of a named session — the viewer's own writes
@@ -112,7 +112,7 @@ export function setLastSeenSid(sid: string): void {
112
112
 
113
113
  const sessions = new Map<string, SessionState>();
114
114
 
115
- // Bounded like every other session-keyed ledger (#224): a resident server must
115
+ // Bounded like every other session-keyed ledger: a resident server must
116
116
  // not retain a SessionState for every session it ever saw. An evicted session
117
117
  // starts over — its retained call tail and lifetime counters are dropped, the
118
118
  // same "starts over" cost lru.ts already accepts for the epoch caches.
package/src/core/tags.ts CHANGED
@@ -2,12 +2,11 @@
2
2
  export const AUTO_CAPTURE_TAG = "auto-capture";
3
3
 
4
4
  /**
5
- * #402: the working tree already states this fact, so the next session can read
6
- * it there. Captured from #389's availability check, which used to DROP these
7
- * candidates. Measured on this repo's store, that check refused 0 of 1166 real
8
- * rows after four review rounds, and the version before it refused 30 of which
9
- * 29 were wrong — so the verdict is a tag now, and a wrong match costs a tag
10
- * instead of a fact.
5
+ * the working tree already states this fact, so the next session can read
6
+ * it there. Captured from the availability check, which TAGS instead of
7
+ * dropping: the original refusal rule rejected 30 of 1,166 real rows and 29
8
+ * of those were wrong — so a wrong match costs a tag instead of a fact
9
+ * (docs/adr/0008).
11
10
  *
12
11
  * Retrieval sorts these rows last within their score band: a restatement is the
13
12
  * first thing to give up budget when the block is full, and the last thing worth
@@ -16,19 +15,19 @@ export const AUTO_CAPTURE_TAG = "auto-capture";
16
15
  export const RESTATABLE_TAG = "restatable";
17
16
 
18
17
  /**
19
- * #393: a capture candidate whose numeric claim was CHECKED against the working
18
+ * a capture candidate whose numeric claim was CHECKED against the working
20
19
  * tree and agreed. Absent on every other row, which is what makes the injected
21
20
  * `[unverified]` marker mean something rather than decorate everything.
22
21
  */
23
22
  export const CODE_CHECKED_TAG = "code-checked";
24
23
 
25
- // The pre-#374 init stamp: a `context` row written by an older release's
24
+ // The legacy init stamp: a `context` row written by an older release's
26
25
  // `/repo-init`. It is plugin bookkeeping that the stamp file replaced, so it is
27
26
  // never a fact for a model to read. `src/init/stamp.ts` retires a row once its
28
27
  // audit line confirms the migration; the tag keeps every other row — including
29
28
  // one whose audit line is gone, which migration cannot reach — out of the
30
- // prompt (#376 review).
29
+ // prompt.
31
30
  export const INIT_STAMP_TAG = "init-stamp";
32
31
 
33
- // The public write boundaries reserve this same tag (#342/#355).
32
+ // The public write boundaries reserve this same tag.
34
33
  export { USER_GUIDED_TAG } from "./guidance.ts";
package/src/core/time.ts CHANGED
@@ -1,4 +1,4 @@
1
- // time — split from src/config.ts (#168 domain restructure). Declaration bodies are unchanged.
1
+ // time — split from src/config.ts. Declaration bodies are unchanged.
2
2
 
3
3
  export function dateStr(d: Date = new Date()): string {
4
4
  return d.toISOString().split("T")[0];
@@ -52,7 +52,7 @@ export function jaccard(a: string[], b: string[]): number {
52
52
  }
53
53
 
54
54
  // ---------------------------------------------------------------------------
55
- // The two things token overlap cannot see (#35 review).
55
+ // The two things token overlap cannot see.
56
56
  //
57
57
  // The rejection sketch decides "same statement reworded" from shared tokens, and
58
58
  // for the two shapes below that judgement is wrong in the same direction — it
package/src/events.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Host hook registration and measured-usage listener (#168). Setup owns the
1
+ // Host hook registration and measured-usage listener. Setup owns the
2
2
  // returned controller and supplies the live compaction-capture callback.
3
3
  import type { PluginCtx } from "./core/host.ts";
4
4
  import type { guarded as Guarded } from "./core/hooks.ts";
@@ -112,7 +112,7 @@ export async function registerHooks(
112
112
  // Evidence lines written below stamp the RECORDING repository. Bind
113
113
  // an unbound caller to this instance first (SYNC provisional; the
114
114
  // prompt hook / events bind firmly in production) so a tool_result
115
- // can never carry another instance's stamp (#127).
115
+ // can never carry another instance's stamp.
116
116
  if (typeof event?.sessionID === "string") {
117
117
  bindSessionProvisional(event.sessionID, instanceDir);
118
118
  }
@@ -153,12 +153,12 @@ export async function registerHooks(
153
153
  // Route store reads in this hook through the right session's scope:
154
154
  // the sid is captured from the event BEFORE any await and carried
155
155
  // explicitly — the global current set here is legacy bookkeeping
156
- // only, never the identity this flow filters with (#127).
156
+ // only, never the identity this flow filters with.
157
157
  const sid =
158
158
  typeof event?.sessionID === "string" ? event.sessionID : undefined;
159
159
  setCurrent({ sessionID: event?.sessionID });
160
160
  if (typeof sid === "string") sessions.touch(sid);
161
- // #139: SessionRequest declares a readonly model, so the host already
161
+ // SessionRequest declares a readonly model, so the host already
162
162
  // tells us which model this session runs on. Remember it: an omitted
163
163
  // captureModel inherits it in capture/runtime.ts.
164
164
  if (typeof sid === "string") recordSessionModel(sid, event?.model);
@@ -167,7 +167,7 @@ export async function registerHooks(
167
167
  // and silently lose its own frontier rows. SYNC provisional bind to
168
168
  // this instance's workspace — the prompt hook (or an event) has
169
169
  // already bound firmly in production, so no host lookup belongs in
170
- // this hot path (#127).
170
+ // this hot path.
171
171
  if (typeof sid === "string") bindSessionProvisional(sid, instanceDir);
172
172
  await sessions.deliver(sid, (text) =>
173
173
  event?.system?.push?.({ type: "text", text }),
@@ -202,7 +202,7 @@ export async function registerHooks(
202
202
  // parts (visible to the summarizer model, which runs AFTER hooks) so the
203
203
  // summary preserves the facts. Never sets event.result — that would skip
204
204
  // the summarizer call entirely. Also fires the context-death auto-capture
205
- // (issue #41, opt-in; see the capture section): the transcript is mined
205
+ // (issue, opt-in; see the capture section): the transcript is mined
206
206
  // while it still exists, BEFORE the summarizer replaces it.
207
207
  await ctx.session?.hook("compaction", (event: any) =>
208
208
  guarded("session.compaction (onCompacting)", async () => {
@@ -211,7 +211,7 @@ export async function registerHooks(
211
211
  setCurrent({ sessionID: event?.sessionID });
212
212
  // The anchor read and the capture pass below partition by the session's
213
213
  // repository; SYNC provisional bind only — a host lookup from this
214
- // hook would violate the zero-token promise (#127, see capture).
214
+ // hook would violate the zero-token promise (see capture).
215
215
  if (typeof sid === "string") bindSessionProvisional(sid, instanceDir);
216
216
  await onCompacting({ sessionID: event?.sessionID });
217
217
  if (typeof event?.sessionID === "string") {
@@ -265,7 +265,7 @@ export async function registerHooks(
265
265
  if (!usage) continue;
266
266
  const { sessionID } = usage;
267
267
  sessions.touch(sessionID);
268
- // #394 review: fold, do not overwrite — on the compatibility path a
268
+ // review: fold, do not overwrite — on the compatibility path a
269
269
  // receipt is per-message, and the last message is not the session.
270
270
  measuredTurns.set(
271
271
  sessionID,
@@ -18,7 +18,7 @@ import { redactSecrets } from "../store/secrets.ts";
18
18
 
19
19
  export type EvidenceEvent = string;
20
20
 
21
- // The ONLY path memory_evidence may read (#130): a real calendar date in
21
+ // The ONLY path memory_evidence may read: a real calendar date in
22
22
  // YYYY-MM-DD form, resolved INSIDE the evidence directory. The schema layer
23
23
  // already refuses non-date strings at the boundary; this is the second door —
24
24
  // impossible dates (2026-02-30, which Date would silently roll over) and
@@ -56,7 +56,7 @@ export function evidenceFileFor(date?: string): string | null {
56
56
  // Credential scrub at the evidence WRITE boundary. Evidence fields routinely
57
57
  // carry caller-authored prose (gate reasons, block reasons, review notes) and
58
58
  // tool-derived summaries; a recognized credential must not persist in the
59
- // durable log no matter which line carried it (#128). redactSecrets is a
59
+ // durable log no matter which line carried it. redactSecrets is a
60
60
  // no-op on ordinary text (ids, hashes, paths, counts).
61
61
  function scrubFields(fields: Record<string, unknown>): Record<string, unknown> {
62
62
  const out: Record<string, unknown> = {};
@@ -78,19 +78,18 @@ export function captureEvidenceContext(sessionID?: string): EvidenceContext {
78
78
  const cur = getCurrent();
79
79
  // An explicitly threaded session outranks the ambient one: gate-authored
80
80
  // lines must name the session the gate runs FOR, not whichever setCurrent
81
- // fired last during the gate's own awaits (#118 review note 1 — the rows
82
- // were fixed in #118, these lines were the residue). When the two disagree,
81
+ // fired last during the gate's own awaits. When the two disagree,
83
82
  // the ambient call belongs to the OTHER session's flow, so it is dropped
84
83
  // rather than borrowed. With sessionID undefined this captures the ambient
85
84
  // session and call at entry by design (maintenance/direct callers). An
86
85
  // explicit "?" keeps the ambient call only when cur.sid is also "?";
87
86
  // otherwise it stays absent, even if a later setCurrent supplies a call.
88
87
  // Normal tool hooks setCurrent before execute; this snapshot never guesses
89
- // a missing operation call from a later hook. See #121 for identity context.
88
+ // a missing operation call from a later hook. See for identity context.
90
89
  const sid = sessionID ?? cur.sid;
91
90
  const call =
92
91
  sessionID !== undefined && sessionID !== cur.sid ? undefined : cur.call;
93
- // Read-side partitioning of the shared log (#131's rule, applied to
92
+ // Read-side partitioning of the shared log (the rule, applied to
94
93
  // evidence; the re-review closed the last two gaps in it). A NAMED session
95
94
  // is stamped from its OWN resolved scope only — the module scope is never
96
95
  // the fallback here: in a process that loaded several plugin instances it
@@ -98,7 +97,7 @@ export function captureEvidenceContext(sessionID?: string): EvidenceContext {
98
97
  // repository. A named session whose repository is unresolvable writes an
99
98
  // UNSTAMPED line that stays private to that session (memory.ts
100
99
  // evidenceVisibleTo pairs with this choice): "unknown" is never
101
- // "everything" (#127), and it is never somebody else's repo either. Only a
100
+ // "everything", and it is never somebody else's repo either. Only a
102
101
  // genuinely session-less line — out-of-plugin maintenance, viewer, CLI —
103
102
  // takes the process scope, and unstamped session-less lines (legacy, or a
104
103
  // scope-less process) keep their historical global reading.
@@ -111,7 +110,7 @@ export function captureEvidenceContext(sessionID?: string): EvidenceContext {
111
110
  });
112
111
  }
113
112
 
114
- // #305: evidence ABOUT a specific row inherits the ROW's repository, not the
113
+ // evidence ABOUT a specific row inherits the ROW's repository, not the
115
114
  // writing process's. The viewer is an admin entry point with no repository of
116
115
  // its own, so its ambient context stamps nothing — and evidenceVisibleTo
117
116
  // reads an unstamped, sid-less line as GLOBAL. Without this, editing or
@@ -122,7 +121,7 @@ export function captureEvidenceContext(sessionID?: string): EvidenceContext {
122
121
  // becomes an explicit `repo=global` line — same visibility as before, now
123
122
  // honest on the line itself. The fields spread last in record(), so they
124
123
  // outrank any ambient stamp even in a process that loaded a plugin. The
125
- // global branch returns an EXPLICIT `repoPath: undefined` (N1 on #308): the
124
+ // global branch returns an EXPLICIT `repoPath: undefined` (N1 on): the
126
125
  // spread must also clear an ambient repoPath, or a shared process that
127
126
  // happens to hold repo B's scope would leave B's path on a globally readable
128
127
  // line about a global row. formatLine drops undefined values, so the key
@@ -175,7 +174,7 @@ export function chainId(): string {
175
174
  /**
176
175
  * One capture decision, in both directions. `lagMs` is the wall-clock distance
177
176
  * from the last message of the transcript to the moment the capture model was
178
- * asked — the number #44 asks for ("how stale is a capture?"). Negative and
177
+ * asked — the number asks for ("how stale is a capture?"). Negative and
179
178
  * missing values are dropped rather than guessed: a capture with no observed
180
179
  * message time has no lag, and inventing 0 would pull p50 toward "instant".
181
180
  */
@@ -184,7 +183,7 @@ export async function recordCaptureLag(
184
183
  lagMs: number | null,
185
184
  outcome: string,
186
185
  context?: EvidenceContext,
187
- // #139: the model the capture actually ran on, so a cost audit can join a
186
+ // the model the capture actually ran on, so a cost audit can join a
188
187
  // lag line to the model that spent the tokens. Optional: metric tests and
189
188
  // any caller without a resolved model keep the old shape.
190
189
  model?: string,
package/src/gate/gate.ts CHANGED
@@ -52,7 +52,7 @@ export interface WriteCandidate {
52
52
  content: string;
53
53
  issue?: string;
54
54
  tags?: string[];
55
- // Retrieval keywords (#40) — indexed for recall, never rendered. Normalised
55
+ // Retrieval keywords — indexed for recall, never rendered. Normalised
56
56
  // (trim/lowercase/cap) at promotion, so a caller may hand junk without
57
57
  // changing the verdict the prose deserves.
58
58
  kw?: string[];
@@ -79,7 +79,7 @@ export const sameStrList = (a?: string[], c?: string[]) =>
79
79
  (a ?? []).every((x, i) => (c ?? [])[i] === x);
80
80
 
81
81
  // The sentence every success reply owes the reader when the gate promoted a
82
- // row but its write_promoted audit line failed to land (#155 review): the
82
+ // row but its write_promoted audit line failed to land: the
83
83
  // row IS durable — and memory_evidence, where every other verdict points
84
84
  // the curious reader, will show NOTHING for it. Only silence was optional.
85
85
  export const auditCaveat = (outcome: GateOutcome): string =>
@@ -102,7 +102,7 @@ export interface GateContext {
102
102
  hasGateCheck: boolean;
103
103
  // The session this write belongs to, when the caller knows it by name.
104
104
  // Repo-stamp resolution prefers it over the mutable global current, which
105
- // a capture's model-call await can outlive into another session (#116).
105
+ // a capture's model-call await can outlive into another session.
106
106
  sessionID?: string;
107
107
  // True when the session exercised the code (read/grep/edit/bash results
108
108
  // recorded). Empirical engagement substitutes for hand-copied refs (gate
@@ -117,7 +117,7 @@ export interface GateContext {
117
117
  // excludes it from rivalry: the update IS the sanctioned supersession, so it
118
118
  // must never be blocked as a conflict with the row it is about to supersede.
119
119
  supersedesTs?: string;
120
- // Optional caller-owned ledger (#158 round 3): GATE-2's drift/canonical
120
+ // Optional caller-owned ledger: GATE-2's drift/canonical
121
121
  // supersessions append the ts values they made durable HERE, immediately
122
122
  // after the batch publish and BEFORE their audit lines — so a failed audit
123
123
  // line can no longer hide a persisted retirement from the caller's catch.
@@ -133,7 +133,7 @@ interface GateOutcomeFields {
133
133
  chain: string;
134
134
  hint?: string;
135
135
  // Promoted with the row DURABLE but its post-append write_promoted audit
136
- // line failed (#155). Entry points with a further post-mutation step
136
+ // line failed. Entry points with a further post-mutation step
137
137
  // (memory_update's supersede) must still run it and report a partial
138
138
  // result. Throwing was the old shape of this signal and it lied: callers
139
139
  // read it as "nothing happened" while the row sat on disk. Pre-append
@@ -141,8 +141,8 @@ interface GateOutcomeFields {
141
141
  evidenceError?: string;
142
142
  // On a collapsed (un-stored) write: the ts of the ACTIVE row whose content
143
143
  // already IS the candidate. An update completing its supersession needs the
144
- // survivor's id to retire its own target in the survivor's favor (#155
145
- // convergence: a retry must be able to end with one active row).
144
+ // survivor's id to retire its own target in the survivor's favor: a retry
145
+ // must be able to end with one active row.
146
146
  collapsedWith?: string;
147
147
  }
148
148
 
@@ -152,7 +152,7 @@ export type GateOutcome =
152
152
  | (GateOutcomeFields & { action: "collapsed" });
153
153
 
154
154
  // STOPWORDS, tokens, rawTokens and jaccard now live in tokenize.ts so the
155
- // rejection sketch (#35) scores similarity with the same definition GATE-3
155
+ // rejection sketch scores similarity with the same definition GATE-3
156
156
  // uses. Imported below; behavior is byte-identical to the local copies.
157
157
 
158
158
  // GATE-3 similarity floors. OVERLAP_FLOOR: reworded near-duplicates of any
@@ -299,7 +299,7 @@ function deltaTokens(
299
299
  }
300
300
 
301
301
  /**
302
- * The #419 symptom-clause rule (learning/blocker content must open with
302
+ * The symptom-clause rule (learning/blocker content must open with
303
303
  * "When <symptom>:") is ON unless OPENCODE_MEMORY_SYMPTOM is off/0/false.
304
304
  * Read per call so tests and automation can flip it without a restart.
305
305
  */
@@ -448,7 +448,7 @@ export async function runWriteGate(
448
448
  };
449
449
  }
450
450
 
451
- // The #419 capture convention, enforced: a `learning`/`blocker` row must
451
+ // The capture convention, enforced: a `learning`/`blocker` row must
452
452
  // open with the observable trigger a future session will hit. The measured
453
453
  // gap is the whole argument — the same lesson surfaced 0/8 written as a
454
454
  // session diary and ranked 1-7 written symptom-first, because the future
@@ -460,7 +460,7 @@ export async function runWriteGate(
460
460
  symptomRuleEnabled() &&
461
461
  !/^when\b[^\n]{0,160}:/i.test(candidate.content.replace(/^[\s\uFEFF]+/, ""))
462
462
  ) {
463
- // New-vs-legacy distinction (#423 review): a rewrite that carries the
463
+ // New-vs-legacy distinction: a rewrite that carries the
464
464
  // supersede target's content byte-identical is a metadata repair, not a
465
465
  // new lesson. retagQuarantinedRows and metadata-only memory_update on a
466
466
  // legacy row re-submit unchanged prose — blocking them would stall
@@ -577,7 +577,7 @@ export async function runWriteGate(
577
577
  });
578
578
  // Drift-fed supersession is AUTO (provable) and target depends on whether a
579
579
  // valid write will land; stale data is neutralized either way. One batch
580
- // publish for the whole set (#61): a row marked out-of-band between the scan
580
+ // publish for the whole set: a row marked out-of-band between the scan
581
581
  // and the pass is skipped by the batch (it re-reads under the lock).
582
582
  const target = g1.candidateStale ? "<-" : chain;
583
583
  if (typeof s.memory.superseded_by === "string") continue;
@@ -606,14 +606,14 @@ export async function runWriteGate(
606
606
  driftPlan.map((p) => ({ ts: p.s.memory.ts, fields: p.fields })),
607
607
  ctx.durable,
608
608
  );
609
- // #208: the audit trail names only rows THIS call retired. A row the
609
+ // the audit trail names only rows THIS call retired. A row the
610
610
  // batch skipped (retired out of band between the scan and the publish)
611
611
  // belongs to the other session's chain and reason; recording it here
612
- // would attribute that retirement to this write — the same rule #158
613
- // round 3 pins for the durable ledger.
612
+ // would attribute that retirement to this write — the same rule the
613
+ // durable ledger pins.
614
614
  const retired = new Set(marked);
615
615
  // Ledger BEFORE the audit lines: what is on disk now stays on disk no
616
- // matter what the record loop below does (round-3 probe 3).
616
+ // matter what the record loop below does.
617
617
  for (const p of driftPlan) {
618
618
  if (!retired.has(p.s.memory.ts)) continue;
619
619
  supersededTs = p.s.memory.ts;
@@ -658,7 +658,7 @@ export async function runWriteGate(
658
658
  );
659
659
  canonPlan.push({ ts: m.ts, from });
660
660
  }
661
- // One batch publish for the whole neutralization set (#61); rows marked
661
+ // One batch publish for the whole neutralization set; rows marked
662
662
  // out-of-band since the scan are skipped by the batch (re-read under lock).
663
663
  const { marked: canonMarked } = await markManySupersededReport(
664
664
  canonPlan.map((p) => ({
@@ -673,7 +673,7 @@ export async function runWriteGate(
673
673
  })),
674
674
  ctx.durable,
675
675
  );
676
- // #208: same attribution rule as the drift batch above — evidence and
676
+ // same attribution rule as the drift batch above — evidence and
677
677
  // promoted.supersedes name only the rows this call actually retired.
678
678
  const canonRetired = new Set(canonMarked);
679
679
  for (const p of canonPlan) {
@@ -693,7 +693,7 @@ export async function runWriteGate(
693
693
  }
694
694
 
695
695
  // ---- GATE-3: no dupes ----------------------------------------------------
696
- // #35: a value a human rejected stays rejected. This is the "have we already
696
+ // a value a human rejected stays rejected. This is the "have we already
697
697
  // seen this" gate, and it is the only place a rejection can be enforced
698
698
  // before a write becomes durable — but unlike every other check here, it is
699
699
  // keyed on the VALUE, not on row identity. The blocklist keys on `ts` and
@@ -961,7 +961,7 @@ export async function runWriteGate(
961
961
  return { action: "collapsed", chain, collapsedWith: collapseMatch.ts };
962
962
  }
963
963
 
964
- // #390 plan: live rows the incoming row CORRECTS, computed before the append
964
+ // live rows the incoming row CORRECTS, computed before the append
965
965
  // because the retirement pointer must name the ts the append creates — and
966
966
  // the marking must wait until the append actually lands, or a blocked write
967
967
  // would delete the old value with no successor behind it. An open planning
@@ -1008,21 +1008,21 @@ export async function runWriteGate(
1008
1008
  ...owner,
1009
1009
  sessionID: ctx.sessionID,
1010
1010
  });
1011
- // #165: remember who made this row, so the writing session is not billed a
1011
+ // remember who made this row, so the writing session is not billed a
1012
1012
  // prompt-cache bust to be shown its own thought. Only promoted writes are
1013
1013
  // attributed — a blocked candidate created nothing.
1014
1014
  noteAuthored(ctx.sessionID, ts);
1015
1015
  // Everything past the append is durable state: an audit failure from here
1016
1016
  // must not escape as a throw, or the caller reports a write that happened
1017
- // as if it had not (#155 — memory_update told the model "Nothing was
1018
- // written" while the replacement row sat un-superseded on disk). The
1017
+ // as if it had not — memory_update once told the model "Nothing was
1018
+ // written" while the replacement row sat un-superseded on disk. The
1019
1019
  // outcome carries the error instead.
1020
1020
  let evidenceError: string | undefined;
1021
1021
  try {
1022
- // #390 apply: the append landed, so the retired rows now have a named
1022
+ // the append landed, so the retired rows now have a named
1023
1023
  // successor. Ledger first (markManySupersededReport appends to ctx.durable
1024
1024
  // after each publish), evidence only for rows THIS call actually retired
1025
- // (#208's attribution rule) — a row retired out-of-band belongs to the
1025
+ // (the attribution rule above) — a row retired out-of-band belongs to the
1026
1026
  // other session's chain.
1027
1027
  if (conflictPlan.length > 0) {
1028
1028
  const { marked } = await markManySupersededReport(
@@ -1,4 +1,4 @@
1
- // Row-vs-row numeric conflict (#390): a correction must retire the row it
1
+ // Row-vs-row numeric conflict: a correction must retire the row it
2
2
  // corrects IN THE DATA, not only in its wording.
3
3
  //
4
4
  // R3 (`results-stale-x5/`, values 2150 → 1900) showed the store keeping BOTH
@@ -23,7 +23,7 @@
23
23
  // 2. value — the numbers attached to that anchor must actually disagree
24
24
  // (`valuesAgree === false`); "21.5%" and "2150" are one fact restated.
25
25
  // 3. sentence — with the numbers stripped, the two rows must say the SAME
26
- // thing (#400 review round 2, WhollyMindless). Every non-numeric word
26
+ // thing. Every non-numeric word
27
27
  // outside a closed ignore list (prose glue, copulas) must appear in BOTH
28
28
  // rows or in a closed EDITORIAL set — words that narrate the act of
29
29
  // correcting ("corrected", "actually", "supersedes") and nothing about
@@ -35,8 +35,7 @@
35
35
  // open: tenants, regions, editions, customers). Same-context is now
36
36
  // ESTABLISHED, not looked up: a difference the words cannot explain is
37
37
  // a difference in the fact. Retirement requires the correction to be
38
- // the only thing that changed; anything coexisting is the pre-#390
39
- // state — both rows inject, retrieval prefers the newer — never a
38
+ // the only thing that changed; anything coexisting is the pre-correction// state — both rows inject, retrieval prefers the newer — never a
40
39
  // hidden fact.
41
40
  import { USER_GUIDED_TAG } from "../core/tags.ts";
42
41
  import { STOPWORDS, tokens } from "../core/tokenize.ts";
@@ -54,7 +53,7 @@ export interface ValueConflict {
54
53
  }
55
54
 
56
55
  // How far after a symbol a number may sit and still be that symbol's value.
57
- // Same window as the capture claim check (#393) on purpose: one rule for
56
+ // Same window as the capture claim check on purpose: one rule for
58
57
  // "this number belongs to this name".
59
58
  const WINDOW = 48;
60
59
 
@@ -104,7 +103,7 @@ const EDITORIAL: ReadonlySet<string> = new Set([
104
103
  /**
105
104
  * The qualifying content of a row with ONE occurrence removed: the number
106
105
  * the given symbol asserts, excised by POSITION before tokenizing. Numbers
107
- * otherwise STAY (#400 review rounds 3 and 4, WhollyMindless): "tenant 101"
106
+ * otherwise STAY: "tenant 101"
108
107
  * and "tenant 202" are distinguished only by digits, and a literal skip of
109
108
  * the compared value also skipped a qualifier carrying the same literal —
110
109
  * "is 3 for tenant 3" lost its tenant when the 3 was skipped globally.
@@ -214,9 +213,9 @@ function assertedValueSpan(
214
213
  * The value each symbol in a row asserts: the first number within WINDOW
215
214
  * after the symbol (falling back to the first before it). Built per call —
216
215
  * a module-level `g` regex carries `lastIndex` between calls, which made the
217
- * #393 check depend on which row was checked last.
216
+ * check depend on which row was checked last.
218
217
  *
219
- * The sign is part of the value: "-5" and "5" disagree (#399's class — an
218
+ * The sign is part of the value: "-5" and "5" disagree ( class — an
220
219
  * unsigned extractor grants agreement across a sign flip).
221
220
  */
222
221
  export function symbolValues(content: string): Map<string, string> {