opencode-self-improvement 0.15.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -118,7 +118,7 @@ Rows are stamped with your git origin (an id that survives re-clones and moves b
118
118
 
119
119
  Injection, recall, the frontier block, compaction, `memory_forget` and decay only see the current repo plus global rows, resolved from the calling session's identity at flow entry. A session that reaches a plugin instance is bound to that instance's own workspace on first contact — in a process hosting several workspaces, one session never borrows the repository some other workspace's setup left behind. A session whose repository cannot be resolved at all sees global rows only; "unknown" is never "everything". Writes follow that rule in the stricter direction: a named session with no resolved repository has **no write target**, so `memory_remember`, `memory_update`, `memory_import` and auto-capture refuse it (evidence `write_refused`) and store nothing — the alternatives were stamping your private content into whichever workspace's `setup()` ran last, or publishing it to every project as an unstamped row. A caller that names no session at all (the viewer process, a restore, a script) keeps the process scope, and an explicit `global: true` is a deliberate owner. Evidence lines carry the same stamp, so `memory_evidence` answers from the caller's repo plus global lines; a line a named session wrote while its repository was unresolvable is private to that session, and only an explicitly global (or predating-stamps) line reads as global. Preferences that should follow you everywhere go in with `memory_remember global: true`. Rows written before scoping existed are global, and the viewer (an admin surface over every repo) edits and restores a row with its own repo stamp — the viewer's missing session scope never decides a row's visibility. `memory_merge_review` applies the same rule to its inputs: a session may merge exactly the rows it may read — global rows plus its own repo's, from either seat — and a row id it merely knows is not authority to retire another repo's memory. Upgrading changes nothing.
120
120
 
121
- Gate-authored evidence captures attribution at operation entry: if a session moves repositories while the gate runs, its audit lines remain in the starting repository's partition and can be read with `memory_evidence` from a session bound there. Caller-level init/capture lifecycle events still resolve attribution per event and can land in a different partition; [#199](https://github.com/abogartz/opencode-self-improvement/issues/199) tracks that boundary.
121
+ Gate-authored evidence and its init/capture lifecycle records capture attribution at operation entry: if a session moves repositories while the operation runs, its audit lines remain in the starting repository's partition and can be read with `memory_evidence` from a session bound there. Init start/complete/skip, capture outcomes/refusals, and capture lag share that captured owner. A captured named session with no resolved repository keeps a session-private `sid` label even on lifecycle records that suppress call metadata; otherwise an unstamped line would appear global. Viewer audit attribution and cancellation of in-flight capture are separate boundaries.
122
122
 
123
123
  ## Token cost and caching
124
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
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": {
package/src/evidence.ts CHANGED
@@ -106,7 +106,10 @@ export async function record(
106
106
  const line = formatLine({
107
107
  ev,
108
108
  ts: new Date().toISOString(),
109
- ...(includeContext ? { sid, call } : {}),
109
+ // A captured unresolved owner still needs a privacy label: without sid or
110
+ // repo, evidenceVisibleTo treats a line as legacy/global. Suppress call
111
+ // metadata as requested, but never turn an explicit private owner global.
112
+ ...(includeContext ? { sid, call } : context && !scope && sid && sid !== "?" ? { sid } : {}),
110
113
  ...(scope ? { repo: scope.key, repoPath: scope.path } : {}),
111
114
  ...scrubFields(fields),
112
115
  });
@@ -135,6 +138,7 @@ export async function recordCaptureLag(
135
138
  session: string,
136
139
  lagMs: number | null,
137
140
  outcome: string,
141
+ context?: EvidenceContext,
138
142
  ): Promise<void> {
139
143
  await record(
140
144
  "capture_lag",
@@ -144,6 +148,8 @@ export async function recordCaptureLag(
144
148
  outcome,
145
149
  },
146
150
  false,
151
+ session,
152
+ context,
147
153
  );
148
154
  }
149
155
 
package/src/index.ts CHANGED
@@ -1543,15 +1543,15 @@ const impl = {
1543
1543
  // no-op there). SYNC only: a lookup call here would break the
1544
1544
  // zero-token promise of the capture tests.
1545
1545
  bindSessionProvisional(sid, instanceDir);
1546
+ const captureGate = gateContext(sid);
1546
1547
  // #152: an instance with no workspace cannot say which repository the
1547
1548
  // mined rows belong to, and rows with no owner are exactly what the
1548
1549
  // store refuses. Skip BEFORE the model call — no tokens spent on a
1549
1550
  // capture that cannot be stored — and leave the reason in evidence.
1550
1551
  if (!writeTarget(sid).ok) {
1551
- await record("auto_capture_refused", { session: sid, trigger }, true, sid);
1552
+ await record("auto_capture_refused", { session: sid, trigger }, true, sid, captureGate.evidenceContext);
1552
1553
  return;
1553
1554
  }
1554
- const captureGate = gateContext(sid);
1555
1555
  let transcript = seeded;
1556
1556
  let msgs = seededMsgs;
1557
1557
  if (transcript.length < 200) {
@@ -1595,7 +1595,7 @@ const impl = {
1595
1595
  await record(durable.length ? "auto_capture_partial" : "auto_capture_refused", {
1596
1596
  session: sid, trigger, type: c.type, scope: redactSecrets(c.scope),
1597
1597
  reason: String(err), retired: durable.join(",") || undefined,
1598
- }, false, sid);
1598
+ }, false, sid, captureGate.evidenceContext);
1599
1599
  continue;
1600
1600
  }
1601
1601
  await record(
@@ -1615,9 +1615,11 @@ const impl = {
1615
1615
  audit_error: outcome.evidenceError,
1616
1616
  },
1617
1617
  false,
1618
+ sid,
1619
+ captureGate.evidenceContext,
1618
1620
  );
1619
1621
  }
1620
- await recordCaptureLag(sid, lagMs, candidates.length ? "candidates" : "empty");
1622
+ await recordCaptureLag(sid, lagMs, candidates.length ? "candidates" : "empty", captureGate.evidenceContext);
1621
1623
  }
1622
1624
 
1623
1625
  void (async () => {
package/src/init.ts CHANGED
@@ -232,7 +232,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
232
232
 
233
233
  const prior = await initStamp(scope, args.sessionID, reader);
234
234
  if (prior && !force && prior.head === head) {
235
- await record("init_skip", { scope, head, since: prior.ts }, false);
235
+ await record("init_skip", { scope, head, since: prior.ts }, false, args.sessionID, evidenceContext);
236
236
  return {
237
237
  scope,
238
238
  root,
@@ -247,7 +247,7 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
247
247
  };
248
248
  }
249
249
 
250
- await record("init_start", { scope, head, force, mode }, false);
250
+ await record("init_start", { scope, head, force, mode }, false, args.sessionID, evidenceContext);
251
251
 
252
252
  const graph = await ensureGraph(root, mode, force);
253
253
  const scripts = await detectScripts(root);
@@ -298,6 +298,8 @@ export async function runInit(args: InitArgs): Promise<InitSummary> {
298
298
  stamp: stampTs ?? "-",
299
299
  },
300
300
  false,
301
+ args.sessionID,
302
+ evidenceContext,
301
303
  );
302
304
 
303
305
  return {