opencode-self-improvement 0.15.37 → 0.15.38

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.
package/README.md CHANGED
@@ -206,6 +206,7 @@ STORE
206
206
  - **No prompt content is stored.** The ledger keeps a scan-truncated string from the *memory* side, never your message.
207
207
  - **Reinforcement is a tie-break only** (`useBoost ≤ 1.0`): a recently used row wins a tie and can never outrank a real score gap. In consolidation the most recently used member of a cluster is never the merge loser.
208
208
  - **`never retrieved` is stated, not acted on.** Pruning is your decision. Retired rows cannot inherit reinforcement: ledger rows are verified against the store on read.
209
+ - **Aggregate STORE counts are machine-wide by decision (#213 B).** They count every repository's rows in the shared store on this machine, never just the reading session's repository — the numbers describe the store, not your slice of it. Privacy applies to the content surfaces instead: `memory_evidence` and the recent-blocked-writes list in `memory_status` and `/memory` follow each reader's repository visibility (#306).
209
210
  - **Capture lag** is how stale the newest message was when auto-capture fired. The line prints only when at least one `capture_lag` sample exists, which needs auto-capture to have fired — see [Auto-capture is experimental](#auto-capture-is-experimental).
210
211
 
211
212
  ## Consolidation
@@ -351,6 +352,8 @@ The output is a canonical mutation score — killed over total, with equivalent
351
352
 
352
353
  Run it when you want to know whether the suite still has teeth — after changing tests or coverage, or as a pre-release gate with `bun scripts/test-sweep.ts --fail-on-survivors`, which exits 4 when anything survives. Two cheaper checks come first: `bun scripts/test-sweep.ts --validate` confirms every mutation pattern still lands on exactly one source site without running the suite, and `bun scripts/test-sweep.ts --selftest` plants a mutation in a trivially-tested pure function and fails unless the suite kills it — proof the instrument itself can go red.
353
354
 
355
+ **Pre-release ritual (decided 2026-11-04, #72):** before pushing a release commit, a human runs `--validate`, then `--selftest`, then `--fail-on-survivors`, and records the mutation score and the survivor list in `bench/RESULTS.md` beside the published evidence. Cadence is pre-release only, run by a person: the sweep is a full suite per mutant and never belongs in CI, where it would cost more than it informs. Survivors become entries on the unpinned-invariant list, not red checks.
356
+
354
357
  ## Troubleshooting
355
358
 
356
359
  | Problem | Fix |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.15.37",
3
+ "version": "0.15.38",
4
4
  "description": "Durable memory for opencode: remember facts, decisions, and commands across sessions, plus a one-command per-repo setup (/repo-init).",
5
5
  "main": "index.ts",
6
6
  "exports": {
@@ -111,6 +111,31 @@ export function captureEvidenceContext(sessionID?: string): EvidenceContext {
111
111
  });
112
112
  }
113
113
 
114
+ // #305: evidence ABOUT a specific row inherits the ROW's repository, not the
115
+ // writing process's. The viewer is an admin entry point with no repository of
116
+ // its own, so its ambient context stamps nothing — and evidenceVisibleTo
117
+ // reads an unstamped, sid-less line as GLOBAL. Without this, editing or
118
+ // deleting another repository's private row from the viewer exposed the
119
+ // operator's reason and row ids to every other repository's memory_evidence.
120
+ // Callers that hold the target row spread these fields into record(): a
121
+ // private stamp is carried verbatim; a global (or legacy unstamped) target
122
+ // becomes an explicit `repo=global` line — same visibility as before, now
123
+ // honest on the line itself. The fields spread last in record(), so they
124
+ // 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
126
+ // spread must also clear an ambient repoPath, or a shared process that
127
+ // happens to hold repo B's scope would leave B's path on a globally readable
128
+ // line about a global row. formatLine drops undefined values, so the key
129
+ // never lands on disk — it only cancels the ambient one in the merge.
130
+ export function targetRepoFields(target: {
131
+ repo?: string;
132
+ repoPath?: string;
133
+ }): { repo: string; repoPath?: string } {
134
+ return target.repo && target.repo !== "global"
135
+ ? { repo: target.repo, repoPath: target.repoPath }
136
+ : { repo: "global", repoPath: undefined };
137
+ }
138
+
114
139
  export async function record(
115
140
  ev: EvidenceEvent,
116
141
  fields: Record<string, unknown> = {},
@@ -19,6 +19,12 @@ import { evidenceDir, memoryRoot } from "../core/config/paths.ts";
19
19
  import { dateStr } from "../core/time.ts";
20
20
  import { parseLine } from "../core/logfmt/format.ts";
21
21
  import { readLines } from "../core/logfmt/read.ts";
22
+ import { resolveRepo } from "../identity/repokey.ts";
23
+ import {
24
+ ADMIN_READER,
25
+ evidenceVisibleTo,
26
+ type Reader,
27
+ } from "../store/model/visibility.ts";
22
28
  import {
23
29
  type BlockedRow,
24
30
  SESSION_FILE_CAP,
@@ -100,8 +106,17 @@ export async function readStatus(
100
106
  }
101
107
 
102
108
  // Newest-first last `limit` write_blocked evidence rows, scanning today and
103
- // yesterday so a block just before midnight stays visible.
104
- export async function blockedRecent(limit = 6): Promise<BlockedRow[]> {
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
111
+ // stamped to another repository, or private to a named session, is not this
112
+ // surface's data. The default is the historical unfiltered read (ADMIN_READER)
113
+ // for out-of-plugin callers; every plugin-facing surface must pass its own
114
+ // Reader, exactly like the quarantine list beside it in the same report.
115
+ export async function blockedRecent(
116
+ limit = 6,
117
+ reader: Reader = ADMIN_READER,
118
+ callerSid?: unknown,
119
+ ): Promise<BlockedRow[]> {
105
120
  try {
106
121
  const today = dateStr();
107
122
  const yesterday = new Date(Date.now() - 86_400_000)
@@ -114,6 +129,7 @@ export async function blockedRecent(limit = 6): Promise<BlockedRow[]> {
114
129
  )) {
115
130
  const f = parseLine(line);
116
131
  if (!f || f.ev !== "write_blocked") continue;
132
+ if (!evidenceVisibleTo(f, reader, callerSid)) continue;
117
133
  rows.push({
118
134
  ts: String(f.ts ?? day),
119
135
  sid: String(f.sid ?? "?"),
@@ -126,3 +142,19 @@ export async function blockedRecent(limit = 6): Promise<BlockedRow[]> {
126
142
  return []; // A refused root is no status data, not an unhandled panel refresh.
127
143
  }
128
144
  }
145
+
146
+ // #306: the Reader for the terminal panel. The TUI process owns no
147
+ // session→repo map (the server binds sessions in its own process), so the
148
+ // panel resolves the ACTIVE session's repository from its root directory —
149
+ // resolveRepo is deterministic for the same path on this machine, hence the
150
+ // same key the server stamped the evidence line with. An absent or
151
+ // unresolvable root fails closed to global-only, exactly like
152
+ // readerForSession: unknown is never everything.
153
+ export function blockedReaderFor(rootDir?: string): Reader {
154
+ if (!rootDir) return { kind: "global-only" };
155
+ try {
156
+ return { kind: "repo", scope: resolveRepo(rootDir) };
157
+ } catch {
158
+ return { kind: "global-only" };
159
+ }
160
+ }
@@ -26,7 +26,7 @@ export const register: ToolRegister = (editor, deps) => {
26
26
  validated(EmptyArgs, {
27
27
  name: "memory_status",
28
28
  description:
29
- "Plain-text memory report for chat clients (desktop/web/IDE), same sections as the terminal /memory panel: CONTEXT (this session's injected block, budget use, cumulative ride and abstentions), CACHE (plain-language cache receipts: bust count, and the provider-reported share of prompt tokens served from cache — the proof that memory never mutates your prefix), the block verbatim, recent blocked writes with gate reasons, and store stats. Reads only — no model call.",
29
+ "Plain-text memory report for chat clients (desktop/web/IDE), same sections as the terminal /memory panel: CONTEXT (this session's injected block, budget use, cumulative ride and abstentions), CACHE (plain-language cache receipts: bust count, and the provider-reported share of prompt tokens served from cache — the proof that memory never mutates your prefix), the block verbatim, recent blocked writes with gate reasons (filtered to this reader's evidence visibility, #306), and store stats. Aggregate STORE counts are machine-wide — they count every repository's rows by decision (#213 B), not this reader's. Reads only — no model call.",
30
30
  options: direct,
31
31
  async execute(_args, context): Promise<{ content: string }> {
32
32
  // In-process truth: the live epoch + ledger, fresher than any file.
@@ -61,7 +61,7 @@ export const register: ToolRegister = (editor, deps) => {
61
61
  content: renderMemoryReport({
62
62
  status,
63
63
  store,
64
- blocked: await blockedRecent(6),
64
+ blocked: await blockedRecent(6, reportReader, sid),
65
65
  quarantined: act
66
66
  .filter((m) => isVisibleTo(m, reportReader) && isQuarantined(m))
67
67
  .map((m) => ({ ts: m.ts, patterns: quarantineReasons(m) })),
package/src/tui/panel.tsx CHANGED
@@ -23,7 +23,12 @@ import {
23
23
  contextLines,
24
24
  windowLines,
25
25
  } from "../status/report.ts";
26
- import { blockedRecent, readStatus, statusDir } from "../status/write.ts";
26
+ import {
27
+ blockedReaderFor,
28
+ blockedRecent,
29
+ readStatus,
30
+ statusDir,
31
+ } from "../status/write.ts";
27
32
 
28
33
  const PANEL = "self-improvement.memory";
29
34
  const POLL_MS = 5000;
@@ -80,7 +85,18 @@ export default Plugin.define({
80
85
  const refresh = async (sid?: string): Promise<void> => {
81
86
  if (sid !== undefined) activeSid = sid;
82
87
  setStatus(await readStatus(activeSid));
83
- const rows = await blockedRecent(8);
88
+ // #306: the blocked list follows evidence visibility. The terminal
89
+ // process owns no session→repo map (the server binds sessions in its
90
+ // own process), so resolve the active session's repository from its
91
+ // root — same machine, same resolveRepo hash the server stamped the
92
+ // line with. Unknown root fails closed to global-only.
93
+ let rootDir: string | undefined;
94
+ try {
95
+ rootDir = activeSid ? context.data.session.root(activeSid) : undefined;
96
+ } catch {
97
+ rootDir = undefined; // an unknown session has no repository here
98
+ }
99
+ const rows = await blockedRecent(8, blockedReaderFor(rootDir), activeSid);
84
100
  setBlocked(rows);
85
101
  const keys = new Set(rows.map((r) => `${r.ts}|${r.reason}`));
86
102
  if (notifyBlocked && seenBlockKeys) {
@@ -8,7 +8,12 @@
8
8
  // All mutations require a reason and write audit + evidence lines.
9
9
  import { deletionsFile } from "../core/config/paths.ts";
10
10
  import { addBlock, removeBlock } from "../store/blocklist.ts";
11
- import { record, chainId, contentHash } from "../evidence/record.ts";
11
+ import {
12
+ record,
13
+ chainId,
14
+ contentHash,
15
+ targetRepoFields,
16
+ } from "../evidence/record.ts";
12
17
  import { removeTombstone, tombstone } from "../store/tombstones/tombstone.ts";
13
18
  import { redactSecrets } from "../store/secrets.ts";
14
19
  import { formatLine, parseLine } from "../core/logfmt/format.ts";
@@ -20,7 +25,7 @@ import {
20
25
  import { readLines } from "../core/logfmt/read.ts";
21
26
  import { withStoreLock, LOCK_WRITE } from "../store/lock.ts";
22
27
  import { appendMemory } from "../store/files/append.ts";
23
- import { loadAll } from "../store/files/load.ts";
28
+ import { loadAll, memoryFiles } from "../store/files/load.ts";
24
29
  import { snapshotFiles } from "../store/files/snapshots.ts";
25
30
  import { markSuperseded } from "../store/files/supersede.ts";
26
31
  import { type Memory } from "../store/model/memory.ts";
@@ -123,6 +128,9 @@ export async function editMemory(input: EditInput): Promise<MutationResult> {
123
128
  reason: input.reason,
124
129
  snapshot: snapshot[0] ?? "-",
125
130
  op: "write",
131
+ // #305: the line inherits the target's repository, so a repo-B edit is
132
+ // private to B (and admin), never a global broadcast of the reason.
133
+ ...targetRepoFields(target),
126
134
  });
127
135
 
128
136
  return {
@@ -175,6 +183,9 @@ export async function deleteMemory(
175
183
  snapshot: snapshot[0] ?? "-",
176
184
  audit: deletionsFile(),
177
185
  tool: "memory_viewer",
186
+ // #305: same inheritance as viewer_edit — a delete of a private row is
187
+ // not a globally readable event.
188
+ ...targetRepoFields(target),
178
189
  });
179
190
 
180
191
  return {
@@ -224,6 +235,29 @@ async function audit(
224
235
  );
225
236
  }
226
237
 
238
+ // F1 on #308: the origin lookup must NOT go through loadAll(). loadAll
239
+ // intentionally hides blocklisted rows, but releaseQuarantine scans the raw
240
+ // day files and acts on them anyway — so a blocked private row released from
241
+ // the viewer resolved to no target, and its evidence line fell back to the
242
+ // unstamped/global reading: the operator's reason leaked to every other
243
+ // repository's memory_evidence. This reads the same raw files the release
244
+ // acts on, and returns ONLY the origin fields, never content.
245
+ async function findTargetOrigin(
246
+ ts: string,
247
+ ): Promise<{ repo?: string; repoPath?: string } | undefined> {
248
+ for (const file of await memoryFiles()) {
249
+ for (const line of await readLines(file)) {
250
+ const f = parseLine(line);
251
+ if (f && f.ts === ts)
252
+ return {
253
+ repo: typeof f.repo === "string" ? f.repo : undefined,
254
+ repoPath: typeof f.repoPath === "string" ? f.repoPath : undefined,
255
+ };
256
+ }
257
+ }
258
+ return undefined;
259
+ }
260
+
227
261
  export async function releaseQuarantinedMemory(
228
262
  ts: string,
229
263
  reason: string,
@@ -235,6 +269,12 @@ export async function releaseQuarantinedMemory(
235
269
  // Layered with ReleaseQuarantineBody's trim/min check. Neither layer alone
236
270
  // is pinned by the route rejection test; direct callers still need this one.
237
271
  requireReason(reason);
272
+ // Resolve the target's origin BEFORE releasing so the audit line can
273
+ // inherit it (#305). A not_found noop has no row — no origin exists to
274
+ // carry, and the line names nothing private, so it stays unstamped. The
275
+ // lookup is unfiltered (F1 on #308): a blocklisted row is still a row the
276
+ // release below can act on, and its evidence must carry its repo.
277
+ const target = await findTargetOrigin(ts);
238
278
  const outcome = await releaseQuarantine(ts);
239
279
  const result =
240
280
  outcome === "released"
@@ -243,7 +283,13 @@ export async function releaseQuarantinedMemory(
243
283
  try {
244
284
  await record(
245
285
  result.released ? "quarantine_released" : "quarantine_release_noop",
246
- { mem: ts, reason, outcome, source: "viewer" },
286
+ {
287
+ mem: ts,
288
+ reason,
289
+ outcome,
290
+ source: "viewer",
291
+ ...(target ? targetRepoFields(target) : {}),
292
+ },
247
293
  false,
248
294
  );
249
295
  return result;