opencode-self-improvement 0.15.19 → 0.15.20

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/gate/gate.ts +37 -31
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.20",
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