opencode-self-improvement 0.15.19 → 0.15.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.15.19",
3
+ "version": "0.15.21",
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/gate/gate.ts CHANGED
@@ -545,22 +545,27 @@ export async function runWriteGate(
545
545
  driftPlan.map((p) => ({ ts: p.s.memory.ts, fields: p.fields })),
546
546
  ctx.durable,
547
547
  );
548
- if (marked.length > 0) {
549
- // Ledger BEFORE the audit lines: what is on disk now stays on disk no
550
- // matter what the record loop below does (round-3 probe 3).
551
- for (const p of driftPlan) {
552
- supersededTs = p.s.memory.ts;
553
- await rec("superseded_by", {
554
- gate: 2,
555
- mem: p.s.memory.ts,
556
- target: p.target,
557
- reason: "drift",
558
- symbol: p.s.symbol,
559
- from: p.s.from,
560
- to: p.s.to,
561
- chain,
562
- });
563
- }
548
+ // #208: the audit trail names only rows THIS call retired. A row the
549
+ // batch skipped (retired out of band between the scan and the publish)
550
+ // belongs to the other session's chain and reason; recording it here
551
+ // would attribute that retirement to this write — the same rule #158
552
+ // round 3 pins for the durable ledger.
553
+ const retired = new Set(marked);
554
+ // Ledger BEFORE the audit lines: what is on disk now stays on disk no
555
+ // matter what the record loop below does (round-3 probe 3).
556
+ for (const p of driftPlan) {
557
+ if (!retired.has(p.s.memory.ts)) continue;
558
+ supersededTs = p.s.memory.ts;
559
+ await rec("superseded_by", {
560
+ gate: 2,
561
+ mem: p.s.memory.ts,
562
+ target: p.target,
563
+ reason: "drift",
564
+ symbol: p.s.symbol,
565
+ from: p.s.from,
566
+ to: p.s.to,
567
+ chain,
568
+ });
564
569
  }
565
570
  }
566
571
 
@@ -607,21 +612,22 @@ export async function runWriteGate(
607
612
  })),
608
613
  ctx.durable,
609
614
  );
610
- if (canonMarked.length > 0) {
611
- // Same ledger discipline as the drift batch above.
612
- for (const p of canonPlan) {
613
- if (!supersededTs) supersededTs = p.ts;
614
- await rec("superseded_by", {
615
- gate: 2,
616
- mem: p.ts,
617
- target,
618
- reason: "canonical",
619
- entity: canon.entry.entity,
620
- from: p.from,
621
- to: canon.entry.value,
622
- chain,
623
- });
624
- }
615
+ // #208: same attribution rule as the drift batch above — evidence and
616
+ // promoted.supersedes name only the rows this call actually retired.
617
+ const canonRetired = new Set(canonMarked);
618
+ for (const p of canonPlan) {
619
+ if (!canonRetired.has(p.ts)) continue;
620
+ if (!supersededTs) supersededTs = p.ts;
621
+ await rec("superseded_by", {
622
+ gate: 2,
623
+ mem: p.ts,
624
+ target,
625
+ reason: "canonical",
626
+ entity: canon.entry.entity,
627
+ from: p.from,
628
+ to: canon.entry.value,
629
+ chain,
630
+ });
625
631
  }
626
632
  }
627
633
 
@@ -76,10 +76,15 @@ export async function removeBlock(ts: string): Promise<boolean> {
76
76
  if ((err as NodeJS.ErrnoException).code === "ENOENT") return false;
77
77
  throw err;
78
78
  }
79
- const kept = text.split("\n").filter((l) => {
79
+ const lines = text.split("\n");
80
+ const kept = lines.filter((l) => {
80
81
  const row = parseLine(l);
81
82
  return !(row && row.ts === ts);
82
83
  });
84
+ // A no-op must report as a no-op (#209): nothing was filtered, so return
85
+ // false and skip the rewrite — republishing identical bytes bumps the
86
+ // file identity for nothing and hands callers a success they did not earn.
87
+ if (kept.length === lines.length) return false;
83
88
  await writeAtomic(
84
89
  file,
85
90
  kept.join("\n") + (kept.length ? "\n" : ""),
@@ -389,10 +389,15 @@ export async function removeTombstone(ch: string): Promise<boolean> {
389
389
  if ((err as NodeJS.ErrnoException).code === "ENOENT") return false;
390
390
  throw err;
391
391
  }
392
- const kept = text.split("\n").filter((l) => {
392
+ const lines = text.split("\n");
393
+ const kept = lines.filter((l) => {
393
394
  const row = parseLine(l);
394
395
  return !(row && row.ch === ch);
395
396
  });
397
+ // A no-op must report as a no-op (#209): unknown ch lifts nothing, so
398
+ // return false and skip the rewrite rather than republishing the file
399
+ // and reporting a withdrawal that never happened.
400
+ if (kept.length === lines.length) return false;
396
401
  await writeAtomic(
397
402
  file,
398
403
  kept.join("\n") + (kept.length ? "\n" : ""),
@@ -275,11 +275,15 @@ export async function blockMemory(input: {
275
275
  // back in view. The tombstone is keyed on the value, so this withdraws the
276
276
  // rejection of that content wherever else a copy of it was blocked; that is the
277
277
  // same decision the tombstone made when it was written.
278
+ // The lift is conditional on an actual un-block (#209): a no-op on a row that
279
+ // was never blocked must not withdraw the rejection still guarding a blocked
280
+ // identical copy, which would let the value be re-ingested.
278
281
  export async function unblockMemory(ts: string): Promise<boolean> {
279
282
  const removed = await removeBlock(ts);
283
+ if (!removed) return false;
280
284
  const mem = (await loadAll()).find((x) => x.ts === ts);
281
285
  if (mem) await removeTombstone(contentHash(mem.content));
282
- return removed;
286
+ return true;
283
287
  }
284
288
 
285
289
  // The explicit un-tombstone escape hatch (#35): lifts a rejection recorded by