opencode-self-improvement 0.15.33 → 0.15.35
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.
|
|
3
|
+
"version": "0.15.35",
|
|
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/store/blocklist.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from "../core/logfmt/publish.ts";
|
|
15
15
|
import { readLines } from "../core/logfmt/read.ts";
|
|
16
16
|
import { withStoreLock, LOCK_WRITE } from "./lock.ts";
|
|
17
|
+
import { redactSecrets } from "./secrets.ts";
|
|
17
18
|
|
|
18
19
|
const BLOCKLIST_FILENAME = "blocklist.logfmt";
|
|
19
20
|
|
|
@@ -54,7 +55,11 @@ export async function addBlock(ts: string, reason: string): Promise<string> {
|
|
|
54
55
|
() =>
|
|
55
56
|
appendLog(
|
|
56
57
|
file,
|
|
57
|
-
formatLine({
|
|
58
|
+
formatLine({
|
|
59
|
+
ts,
|
|
60
|
+
reason: redactSecrets(reason),
|
|
61
|
+
blocked_at: new Date().toISOString(),
|
|
62
|
+
}),
|
|
58
63
|
),
|
|
59
64
|
LOCK_WRITE,
|
|
60
65
|
);
|
|
@@ -115,13 +115,37 @@ export async function markManySupersededReport(
|
|
|
115
115
|
return { marked };
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// The #126 provenance guard: which supersession a merge_review may clear.
|
|
119
|
+
export interface ClearProvenance {
|
|
120
|
+
// The review's loser: a survivor the loser itself superseded first is the
|
|
121
|
+
// legitimate revival the merge exists for.
|
|
122
|
+
supersededBy: string;
|
|
123
|
+
// The review's reason: a marker this very review wrote (a retried apply)
|
|
124
|
+
// is its own provenance.
|
|
125
|
+
reason: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
118
128
|
// Drop a row's supersession markers IN PLACE (snapshot-first), making it active
|
|
119
129
|
// again. Used by memory_merge_review: a declared survivor must be recallable
|
|
120
130
|
// even when an earlier row — now the loser — had superseded it first.
|
|
121
|
-
|
|
131
|
+
// #126: with a provenance guard the marker is cleared ONLY when it points at
|
|
132
|
+
// this review's loser or carries the review's reason. A survivor superseded by
|
|
133
|
+
// anything else (e.g. a memory_update that retired it after the review was
|
|
134
|
+
// filed) keeps its marker and the clear reports false — erasing that later
|
|
135
|
+
// supersession would revive the retired row next to its live replacement.
|
|
136
|
+
export async function clearSuperseded(
|
|
137
|
+
ts: string,
|
|
138
|
+
provenance?: ClearProvenance,
|
|
139
|
+
): Promise<boolean> {
|
|
122
140
|
for (const file of await memoryFiles()) {
|
|
123
141
|
const outcome = await stampRow(file, ts, (parsed) => {
|
|
124
142
|
if (typeof parsed.superseded_by !== "string") return null;
|
|
143
|
+
if (
|
|
144
|
+
provenance &&
|
|
145
|
+
parsed.superseded_by !== provenance.supersededBy &&
|
|
146
|
+
parsed.reason !== provenance.reason
|
|
147
|
+
)
|
|
148
|
+
return null;
|
|
125
149
|
// These six keys are written only by markSuperseded (drift, canonical,
|
|
126
150
|
// update and merge_review), never by appendMemory, so they are all part of
|
|
127
151
|
// the marker and go with it. Field order round-trips because parseLine
|
|
@@ -7,6 +7,7 @@ import { withStoreLock } from "../store/lock.ts";
|
|
|
7
7
|
import { loadAll } from "../store/files/load.ts";
|
|
8
8
|
import { clearSuperseded, markSuperseded } from "../store/files/supersede.ts";
|
|
9
9
|
import { isVisibleTo, readerFromSid } from "../store/model/visibility.ts";
|
|
10
|
+
import { isActive } from "../store/model/predicates.ts";
|
|
10
11
|
import { MergeReviewArgs, validated } from "./schema.ts";
|
|
11
12
|
import { join } from "node:path";
|
|
12
13
|
|
|
@@ -16,7 +17,7 @@ export const register: ToolRegister = (editor, deps) => {
|
|
|
16
17
|
validated(MergeReviewArgs, {
|
|
17
18
|
name: "memory_merge_review",
|
|
18
19
|
description:
|
|
19
|
-
"Resolve an open merge/review gate non-destructively: mark the loser as superseded_by the survivor, and clear any supersession the survivor itself carries so the canonical row stays recallable. Both rows stay active data (the loser is recoverable via memory_undo); nothing is deleted. A session may merge exactly the rows it may read: global rows are mergeable from anywhere, but a row belonging to another repository is refused in either seat. Refuses before writing when the reason or the survivor id is missing, either id names a missing or blocklisted row, the loser is already superseded or is the survivor itself,
|
|
20
|
+
"Resolve an open merge/review gate non-destructively: mark the loser as superseded_by the survivor, and clear any supersession the survivor itself carries so the canonical row stays recallable. Both rows stay active data (the loser is recoverable via memory_undo); nothing is deleted. A session may merge exactly the rows it may read: global rows are mergeable from anywhere, but a row belonging to another repository is refused in either seat. Refuses before writing when the reason or the survivor id is missing, either id names a missing or blocklisted row, the loser is already superseded or is the survivor itself, either seat names a foreign repository's row, or the survivor's supersession was written by a row other than this review's loser (a later update's marker is never erased). Later lock or I/O failures can leave partial changes; the reply names the completed retirement and failure.",
|
|
20
21
|
options: direct,
|
|
21
22
|
async execute(args, context): Promise<{ content: string }> {
|
|
22
23
|
const { sid } = toolIds(context);
|
|
@@ -99,6 +100,31 @@ export const register: ToolRegister = (editor, deps) => {
|
|
|
99
100
|
"merge_review blocked: the survivor belongs to another repository — this session may not promote or revive it. Nothing was done. No evidence written.",
|
|
100
101
|
};
|
|
101
102
|
}
|
|
103
|
+
// Provenance guard (#126): a survivor carrying a supersession
|
|
104
|
+
// written by anything OTHER than this review — its marker points
|
|
105
|
+
// at a later row (a memory_update that retired the survivor
|
|
106
|
+
// after the review was filed), and the marker's reason is not
|
|
107
|
+
// this review's reason — must not be revived. Clearing that
|
|
108
|
+
// marker would erase the later supersession and leave the
|
|
109
|
+
// retired survivor active next to its live replacement. Refuse
|
|
110
|
+
// BEFORE touching the loser: a half-applied merge is exactly the
|
|
111
|
+
// state this guard exists to prevent.
|
|
112
|
+
const later = survivorRow.superseded_by;
|
|
113
|
+
if (
|
|
114
|
+
later &&
|
|
115
|
+
later !== args.loser &&
|
|
116
|
+
survivorRow.reason !== args.reason
|
|
117
|
+
) {
|
|
118
|
+
const laterRow = all.find((m) => m.ts === later);
|
|
119
|
+
return {
|
|
120
|
+
content:
|
|
121
|
+
`merge_review blocked: survivor ${args.survivor} was superseded by ${later}` +
|
|
122
|
+
(laterRow && isActive(laterRow)
|
|
123
|
+
? ` — ${later} is the current live row`
|
|
124
|
+
: "") +
|
|
125
|
+
` after this review was written; reviving the survivor would erase that supersession. Nothing was done. No evidence written.`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
102
128
|
const ok = await markSuperseded(
|
|
103
129
|
args.loser,
|
|
104
130
|
{
|
|
@@ -118,8 +144,14 @@ export const register: ToolRegister = (editor, deps) => {
|
|
|
118
144
|
}
|
|
119
145
|
// The survivor may itself have been superseded earlier (e.g. by
|
|
120
146
|
// a row this very call just made the loser). Declaring it
|
|
121
|
-
// canonical has to make it recallable, so clear its own marker
|
|
122
|
-
|
|
147
|
+
// canonical has to make it recallable, so clear its own marker —
|
|
148
|
+
// but only the marker this review owns (#126): the guard above
|
|
149
|
+
// already refused anything else, and this re-check runs under the
|
|
150
|
+
// file lock against the line as it is at mutation time.
|
|
151
|
+
const revived = await clearSuperseded(args.survivor, {
|
|
152
|
+
supersededBy: args.loser,
|
|
153
|
+
reason: args.reason,
|
|
154
|
+
});
|
|
123
155
|
// The response has always claimed "Evidence recorded" — now it
|
|
124
156
|
// is true, and it names the session the merge ran FOR (#121's
|
|
125
157
|
// residue on this line). The host tool_result hook covers
|