opencode-swarm 7.163.1 → 7.164.1
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 +1 -1
- package/dist/cli/{coder-settlement-f1gtvcy8.js → coder-settlement-w4qk90kh.js} +12 -13
- package/dist/cli/{config-doctor-0fnqzqz1.js → config-doctor-r81bp1nd.js} +3 -3
- package/dist/cli/{core-w81fk5sc.js → core-xfw4s9b9.js} +2 -2
- package/dist/cli/{curation-policy-j12j2gvc.js → curation-policy-2h37sd6p.js} +6 -7
- package/dist/cli/{curator-as495r18.js → curator-7zy6bdmw.js} +36 -39
- package/dist/cli/{curator-drift-g6w4ga1q.js → curator-drift-ykrdf08r.js} +105 -38
- package/dist/cli/curator-llm-factory-7gjvm4ds.js +66 -0
- package/dist/cli/{evidence-summary-service-51dxfcn5.js → evidence-summary-service-519ny6b1.js} +17 -18
- package/dist/cli/{gate-evidence-nb1e8hz0.js → gate-evidence-a7st3vbc.js} +8 -9
- package/dist/cli/guardrail-explain-ewcm37em.js +67 -0
- package/dist/cli/{guardrail-log-2kwntcqw.js → guardrail-log-kp51by1v.js} +8 -9
- package/dist/cli/{guardrail-reset-mrxrc56j.js → guardrail-reset-reyfwtwn.js} +36 -39
- package/dist/cli/hive-promoter-zf2vf5sw.js +81 -0
- package/dist/cli/{index-4p0wyz5p.js → index-1af3rb5n.js} +9 -9
- package/dist/cli/{index-2zgjcmmc.js → index-1b1h770t.js} +3 -3
- package/dist/cli/{index-0tervb1m.js → index-2ee2g27m.js} +7795 -2724
- package/dist/cli/{index-x2f1f011.js → index-2s40e3b0.js} +4 -3
- package/dist/cli/{index-9xd073d4.js → index-2yd732fd.js} +7 -1
- package/dist/cli/{index-9crtmnqg.js → index-36nt17m8.js} +1 -1
- package/dist/cli/{index-d3azve4r.js → index-5084szce.js} +122 -300
- package/dist/cli/{index-d9gdwh34.js → index-5bza8nxz.js} +2 -2
- package/dist/cli/{index-xyhmt813.js → index-6097tx05.js} +1 -1
- package/dist/cli/{index-5056zmpt.js → index-644t46hr.js} +1 -1
- package/dist/cli/{index-2v06a1yh.js → index-6ay5zp1v.js} +5 -5
- package/dist/cli/{index-n2mhyect.js → index-6kd3jnaf.js} +1 -1
- package/dist/cli/{index-n67vx5zw.js → index-6t35714n.js} +2 -2
- package/dist/cli/{index-tnpf9wwv.js → index-862c0xhc.js} +1 -1
- package/dist/cli/{index-2n1ym7jb.js → index-b98r3pyv.js} +5 -5
- package/dist/cli/{index-8ada7ag7.js → index-dhzsvmx6.js} +2 -2
- package/dist/cli/{index-n985274d.js → index-e630pvvw.js} +4 -4
- package/dist/cli/{index-3b762978.js → index-f9nfknjg.js} +182 -37
- package/dist/cli/{index-m1fvbah1.js → index-fwfhbs27.js} +2 -2
- package/dist/cli/{index-t34daffb.js → index-h2f21caa.js} +2 -2
- package/dist/cli/{index-9ss2m4rs.js → index-hcn69kp0.js} +410 -1
- package/dist/cli/{index-g3znh2yd.js → index-hzaw10zh.js} +7 -7
- package/dist/cli/{index-cqgpvx2d.js → index-j0ajeary.js} +2 -2
- package/dist/cli/{index-f923njwh.js → index-jczbtx2x.js} +7 -7
- package/dist/cli/{index-hm239n1p.js → index-k8j7m0e2.js} +1 -1
- package/dist/cli/{index-zjme8atd.js → index-n1wcq816.js} +5 -5
- package/dist/cli/{index-66073kej.js → index-pmmfhzsp.js} +3 -3
- package/dist/cli/{index-fckfgptr.js → index-qbr05tbw.js} +2 -2
- package/dist/cli/{index-r56f3f81.js → index-r5jn0ah5.js} +2 -2
- package/dist/cli/{index-dtn0pne5.js → index-v56mhyhs.js} +1 -1
- package/dist/cli/{index-etvq73mp.js → index-vc3zmtxb.js} +38 -41
- package/dist/cli/{index-kvra3nv1.js → index-vdgw2k4c.js} +3 -3
- package/dist/cli/{index-0103w5pf.js → index-vkckf2ch.js} +2 -2
- package/dist/cli/{index-swgy9xvk.js → index-vrxx0ea4.js} +4 -4
- package/dist/cli/{index-08y8pccg.js → index-wnf1ej2q.js} +4 -4
- package/dist/cli/{index-qynqyfgj.js → index-wv4b01ex.js} +32 -34
- package/dist/cli/{index-7n9jznv0.js → index-x2qmpkth.js} +5 -5
- package/dist/cli/index-y2f5s2cf.js +403 -0
- package/dist/cli/{index-ma52g2pq.js → index-yc415pzf.js} +655 -16
- package/dist/cli/{index-n249fbw7.js → index-zaab1wz9.js} +5 -0
- package/dist/cli/index.js +36 -39
- package/dist/cli/{knowledge-escalator-fq7dm2g4.js → knowledge-escalator-wwkbsgvw.js} +14 -15
- package/dist/cli/{knowledge-events-3zanyfkr.js → knowledge-events-vmmgwfmc.js} +12 -13
- package/dist/cli/{knowledge-link-vmdj5e5d.js → knowledge-link-bvra01zv.js} +5 -6
- package/dist/cli/{knowledge-store-vhehnw52.js → knowledge-store-6wbagbqm.js} +6 -7
- package/dist/cli/{knowledge-validator-0tt0pe6b.js → knowledge-validator-q1z4fmeg.js} +8 -9
- package/dist/cli/{model-preflight-c3mc8njg.js → model-preflight-1ecjbg73.js} +1 -1
- package/dist/cli/{pending-delegations-b92pecbj.js → pending-delegations-cq5g4rr4.js} +6 -8
- package/dist/cli/{pr-subscriptions-2mkdt0ak.js → pr-subscriptions-m0z5wxkb.js} +6 -7
- package/dist/cli/pr-workflow-gate-0zvp0qs9.js +221 -0
- package/dist/cli/{runner-3gw2njnx.js → runner-s55g5233.js} +6 -7
- package/dist/cli/{scan-cursor-1c8a3b0m.js → scan-cursor-z6zepy3r.js} +7 -8
- package/dist/cli/{schema-c554j5c8.js → schema-skf0ckh4.js} +2 -2
- package/dist/cli/{scope-persistence-vtbcszvv.js → scope-persistence-f6davq7x.js} +10 -11
- package/dist/cli/{skill-generator-0es21fck.js → skill-generator-wqbazppk.js} +16 -17
- package/dist/cli/{sqlite-loader-c92413n7.js → sqlite-loader-8zefc142.js} +1 -1
- package/dist/cli/{telemetry-x4zggfd7.js → telemetry-q51s6tyt.js} +1 -1
- package/dist/cli/{worktree-collision-ownership-043dg8gg.js → worktree-collision-ownership-c0030qbm.js} +7 -9
- package/dist/cli/{worktree-isolation-hk42yxw7.js → worktree-isolation-09qq8066.js} +36 -39
- package/dist/db/canonical-project.d.ts +31 -0
- package/dist/db/db-errors.d.ts +24 -0
- package/dist/db/driver-parity.d.ts +31 -0
- package/dist/db/durability.d.ts +40 -0
- package/dist/db/group-commit-writer.d.ts +117 -0
- package/dist/db/health.d.ts +35 -0
- package/dist/db/insight-candidate-store.d.ts +61 -0
- package/dist/db/legacy-import.d.ts +77 -0
- package/dist/db/phase-report-store.d.ts +45 -0
- package/dist/db/project-db.d.ts +35 -8
- package/dist/db/qa-gate-profile.d.ts +2 -0
- package/dist/hooks/curator-drift.d.ts +9 -5
- package/dist/hooks/curator-types.d.ts +1 -0
- package/dist/hooks/delegation-gate.d.ts +1 -0
- package/dist/hooks/knowledge-curator.d.ts +5 -3
- package/dist/hooks/micro-reflector.d.ts +12 -7
- package/dist/hooks/pr-workflow-gate.d.ts +14 -8
- package/dist/hooks/pr-workflow-response-gate.d.ts +9 -12
- package/dist/index.js +627 -574
- package/dist/memory/schema.d.ts +4 -4
- package/dist/pr-review/authorization.d.ts +18 -12
- package/dist/prm/index.d.ts +3 -1
- package/dist/tools/authorize-pr-review-reentry.d.ts +12 -8
- package/package.json +3 -2
- package/dist/cli/authorization-vstrh7ra.js +0 -23
- package/dist/cli/curator-llm-factory-v8vwz20c.js +0 -69
- package/dist/cli/guardrail-explain-z2qb6v67.js +0 -70
- package/dist/cli/hive-promoter-c62x2ncb.js +0 -84
- package/dist/cli/index-c8s9a3zh.js +0 -73
- package/dist/cli/index-ed5ykebp.js +0 -151
- package/dist/cli/index-mmngnxev.js +0 -883
- package/dist/cli/index-w7ekntej.js +0 -643
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
EvaluationRunV1Schema,
|
|
4
4
|
GateAuditResultV1Schema,
|
|
5
5
|
getProtectedEvaluationRunIds
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-vkckf2ch.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readEffectiveSpecSync
|
|
12
|
-
|
|
8
|
+
DURABILITY_CLASSES,
|
|
9
|
+
getProjectDb,
|
|
10
|
+
projectDbExists,
|
|
11
|
+
readEffectiveSpecSync,
|
|
12
|
+
withDurabilityClass
|
|
13
|
+
} from "./index-hcn69kp0.js";
|
|
13
14
|
import {
|
|
14
15
|
getWorktreeMergeFailure
|
|
15
16
|
} from "./index-zsrtt42s.js";
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
readTaskEvidence,
|
|
24
25
|
readTaskEvidenceRaw,
|
|
25
26
|
sanitizeTaskId
|
|
26
|
-
} from "./index-
|
|
27
|
+
} from "./index-n1wcq816.js";
|
|
27
28
|
import {
|
|
28
29
|
LedgerStaleWriterError,
|
|
29
30
|
appendLedgerEvent,
|
|
@@ -43,10 +44,10 @@ import {
|
|
|
43
44
|
replayFromLedgerWithStatus,
|
|
44
45
|
takeSnapshotEvent,
|
|
45
46
|
takeSnapshotWithRetry
|
|
46
|
-
} from "./index-
|
|
47
|
+
} from "./index-vdgw2k4c.js";
|
|
47
48
|
import {
|
|
48
49
|
appendCoreEventSync
|
|
49
|
-
} from "./index-
|
|
50
|
+
} from "./index-dhzsvmx6.js";
|
|
50
51
|
import {
|
|
51
52
|
init_executor,
|
|
52
53
|
isUntrustedEnvKey,
|
|
@@ -62,7 +63,7 @@ import {
|
|
|
62
63
|
estimateTokens,
|
|
63
64
|
readSwarmFileAsync,
|
|
64
65
|
validateSwarmPath
|
|
65
|
-
} from "./index-
|
|
66
|
+
} from "./index-v56mhyhs.js";
|
|
66
67
|
import {
|
|
67
68
|
bunHash,
|
|
68
69
|
bunWrite,
|
|
@@ -70,7 +71,7 @@ import {
|
|
|
70
71
|
} from "./index-r3mvsbtq.js";
|
|
71
72
|
import {
|
|
72
73
|
PlanSchema
|
|
73
|
-
} from "./index-
|
|
74
|
+
} from "./index-862c0xhc.js";
|
|
74
75
|
import {
|
|
75
76
|
GIT_BINARY_ENV_VAR,
|
|
76
77
|
describeGitResolution,
|
|
@@ -81,14 +82,14 @@ import {
|
|
|
81
82
|
assertProjectRoot,
|
|
82
83
|
tryAcquireLock,
|
|
83
84
|
withEvidenceLock
|
|
84
|
-
} from "./index-
|
|
85
|
-
import {
|
|
86
|
-
emit
|
|
87
|
-
} from "./index-2zgjcmmc.js";
|
|
85
|
+
} from "./index-36nt17m8.js";
|
|
88
86
|
import {
|
|
89
87
|
invalidateCachedArtifact,
|
|
90
88
|
readCachedParsedFile
|
|
91
|
-
} from "./index-
|
|
89
|
+
} from "./index-f9nfknjg.js";
|
|
90
|
+
import {
|
|
91
|
+
emit
|
|
92
|
+
} from "./index-1b1h770t.js";
|
|
92
93
|
import {
|
|
93
94
|
ZodError,
|
|
94
95
|
init_zod
|
|
@@ -104,9 +105,9 @@ import {
|
|
|
104
105
|
import {
|
|
105
106
|
closeSync,
|
|
106
107
|
copyFileSync,
|
|
107
|
-
existsSync as
|
|
108
|
+
existsSync as existsSync3,
|
|
108
109
|
fsyncSync,
|
|
109
|
-
mkdirSync as
|
|
110
|
+
mkdirSync as mkdirSync2,
|
|
110
111
|
openSync,
|
|
111
112
|
readdirSync,
|
|
112
113
|
renameSync as renameSync2,
|
|
@@ -118,195 +119,6 @@ import * as path5 from "path";
|
|
|
118
119
|
|
|
119
120
|
// src/db/task-checkpoint-receipt.ts
|
|
120
121
|
import { createHash } from "crypto";
|
|
121
|
-
|
|
122
|
-
// src/db/project-db.ts
|
|
123
|
-
import { existsSync, mkdirSync } from "fs";
|
|
124
|
-
import { join, resolve } from "path";
|
|
125
|
-
var MIGRATIONS = [
|
|
126
|
-
{
|
|
127
|
-
version: 1,
|
|
128
|
-
name: "create_project_constraints",
|
|
129
|
-
sql: `CREATE TABLE project_constraints (
|
|
130
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
131
|
-
constraint_type TEXT NOT NULL,
|
|
132
|
-
content TEXT NOT NULL,
|
|
133
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
134
|
-
)`
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
version: 2,
|
|
138
|
-
name: "create_qa_gate_profile",
|
|
139
|
-
sql: `CREATE TABLE qa_gate_profile (
|
|
140
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
141
|
-
plan_id TEXT NOT NULL UNIQUE,
|
|
142
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
143
|
-
project_type TEXT,
|
|
144
|
-
gates TEXT NOT NULL DEFAULT '{}',
|
|
145
|
-
locked_at TEXT,
|
|
146
|
-
locked_by_snapshot_seq INTEGER
|
|
147
|
-
)`
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
version: 3,
|
|
151
|
-
name: "create_qa_gate_profile_immutability_trigger",
|
|
152
|
-
sql: `CREATE TRIGGER IF NOT EXISTS trg_qa_gate_profile_no_update_after_lock
|
|
153
|
-
BEFORE UPDATE ON qa_gate_profile
|
|
154
|
-
WHEN OLD.locked_at IS NOT NULL
|
|
155
|
-
BEGIN
|
|
156
|
-
SELECT RAISE(ABORT, 'qa_gate_profile row is locked and cannot be modified after critic approval');
|
|
157
|
-
END`
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
version: 4,
|
|
161
|
-
name: "add_qa_gate_profile_raw_swarm",
|
|
162
|
-
sql: "ALTER TABLE qa_gate_profile ADD COLUMN raw_swarm TEXT"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
version: 5,
|
|
166
|
-
name: "add_qa_gate_profile_raw_title",
|
|
167
|
-
sql: "ALTER TABLE qa_gate_profile ADD COLUMN raw_title TEXT"
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
version: 6,
|
|
171
|
-
name: "add_qa_gate_profile_identity_hash",
|
|
172
|
-
sql: "ALTER TABLE qa_gate_profile ADD COLUMN identity_hash TEXT"
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
version: 7,
|
|
176
|
-
name: "create_qa_gate_profile_identity_hash_index",
|
|
177
|
-
sql: `CREATE UNIQUE INDEX IF NOT EXISTS idx_qa_gate_profile_identity_hash
|
|
178
|
-
ON qa_gate_profile(identity_hash)
|
|
179
|
-
WHERE identity_hash IS NOT NULL`
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
version: 8,
|
|
183
|
-
name: "create_qa_gate_profile_identity",
|
|
184
|
-
sql: `CREATE TABLE qa_gate_profile_identity (
|
|
185
|
-
identity_hash TEXT PRIMARY KEY,
|
|
186
|
-
profile_id INTEGER NOT NULL UNIQUE REFERENCES qa_gate_profile(id) ON DELETE CASCADE,
|
|
187
|
-
raw_swarm TEXT NOT NULL,
|
|
188
|
-
raw_title TEXT NOT NULL,
|
|
189
|
-
readable_plan_id TEXT NOT NULL
|
|
190
|
-
)`
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
version: 9,
|
|
194
|
-
name: "create_qa_gate_profile_identity_readable_plan_index",
|
|
195
|
-
sql: `CREATE INDEX idx_qa_gate_profile_identity_readable_plan_id
|
|
196
|
-
ON qa_gate_profile_identity(readable_plan_id)`
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
version: 10,
|
|
200
|
-
name: "backfill_qa_gate_profile_identity_from_legacy_columns",
|
|
201
|
-
sql: `INSERT INTO qa_gate_profile_identity (
|
|
202
|
-
identity_hash,
|
|
203
|
-
profile_id,
|
|
204
|
-
raw_swarm,
|
|
205
|
-
raw_title,
|
|
206
|
-
readable_plan_id
|
|
207
|
-
)
|
|
208
|
-
SELECT
|
|
209
|
-
identity_hash,
|
|
210
|
-
id,
|
|
211
|
-
raw_swarm,
|
|
212
|
-
raw_title,
|
|
213
|
-
plan_id
|
|
214
|
-
FROM qa_gate_profile
|
|
215
|
-
WHERE identity_hash IS NOT NULL
|
|
216
|
-
AND raw_swarm IS NOT NULL
|
|
217
|
-
AND raw_title IS NOT NULL
|
|
218
|
-
AND NOT EXISTS (
|
|
219
|
-
SELECT 1
|
|
220
|
-
FROM qa_gate_profile_identity AS qi
|
|
221
|
-
WHERE qi.profile_id = qa_gate_profile.id
|
|
222
|
-
)`
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
version: 11,
|
|
226
|
-
name: "create_task_checkpoint_receipt",
|
|
227
|
-
sql: `CREATE TABLE task_checkpoint_receipt (
|
|
228
|
-
plan_identity_hash TEXT NOT NULL,
|
|
229
|
-
task_id TEXT NOT NULL,
|
|
230
|
-
label TEXT NOT NULL,
|
|
231
|
-
state TEXT NOT NULL CHECK(state IN ('pending', 'committed', 'logged')),
|
|
232
|
-
sha TEXT,
|
|
233
|
-
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
234
|
-
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
235
|
-
PRIMARY KEY(plan_identity_hash, task_id)
|
|
236
|
-
)`
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
version: 12,
|
|
240
|
-
name: "add_task_checkpoint_receipt_completion_generation",
|
|
241
|
-
sql: `ALTER TABLE task_checkpoint_receipt
|
|
242
|
-
ADD COLUMN generation INTEGER NOT NULL DEFAULT 1;
|
|
243
|
-
ALTER TABLE task_checkpoint_receipt
|
|
244
|
-
ADD COLUMN completion_active INTEGER NOT NULL DEFAULT 1
|
|
245
|
-
CHECK(completion_active IN (0, 1))`
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
version: 13,
|
|
249
|
-
name: "bind_task_checkpoint_receipt_to_completion_ledger_seq",
|
|
250
|
-
sql: `ALTER TABLE task_checkpoint_receipt
|
|
251
|
-
ADD COLUMN completion_ledger_seq INTEGER
|
|
252
|
-
CHECK(completion_ledger_seq IS NULL OR completion_ledger_seq >= 0)`
|
|
253
|
-
}
|
|
254
|
-
];
|
|
255
|
-
var _projectDbs = new Map;
|
|
256
|
-
function runProjectMigrations(db) {
|
|
257
|
-
db.run(`CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
258
|
-
version INTEGER PRIMARY KEY,
|
|
259
|
-
name TEXT NOT NULL,
|
|
260
|
-
applied_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
261
|
-
)`);
|
|
262
|
-
const row = db.query("SELECT MAX(version) as version FROM schema_migrations").get();
|
|
263
|
-
const currentVersion = row?.version ?? 0;
|
|
264
|
-
for (const migration of MIGRATIONS) {
|
|
265
|
-
if (migration.version <= currentVersion)
|
|
266
|
-
continue;
|
|
267
|
-
const apply = db.transaction(() => {
|
|
268
|
-
db.run(migration.sql);
|
|
269
|
-
db.run("INSERT INTO schema_migrations (version, name) VALUES (?, ?)", [
|
|
270
|
-
migration.version,
|
|
271
|
-
migration.name
|
|
272
|
-
]);
|
|
273
|
-
});
|
|
274
|
-
apply();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
function projectDbPath(directory) {
|
|
278
|
-
return join(resolve(directory), ".swarm", "swarm.db");
|
|
279
|
-
}
|
|
280
|
-
function projectDbExists(directory) {
|
|
281
|
-
return existsSync(projectDbPath(directory));
|
|
282
|
-
}
|
|
283
|
-
function getProjectDb(directory) {
|
|
284
|
-
const key = resolve(directory);
|
|
285
|
-
const existing = _projectDbs.get(key);
|
|
286
|
-
if (existing)
|
|
287
|
-
return existing;
|
|
288
|
-
const swarmDir = join(key, ".swarm");
|
|
289
|
-
mkdirSync(swarmDir, { recursive: true });
|
|
290
|
-
const Db = loadDatabaseCtor();
|
|
291
|
-
const db = new Db(join(swarmDir, "swarm.db"));
|
|
292
|
-
db.run("PRAGMA journal_mode = WAL;");
|
|
293
|
-
db.run("PRAGMA synchronous = NORMAL;");
|
|
294
|
-
db.run("PRAGMA busy_timeout = 5000;");
|
|
295
|
-
db.run("PRAGMA foreign_keys = ON;");
|
|
296
|
-
runProjectMigrations(db);
|
|
297
|
-
_projectDbs.set(key, db);
|
|
298
|
-
return db;
|
|
299
|
-
}
|
|
300
|
-
function closeProjectDb(directory) {
|
|
301
|
-
const key = resolve(directory);
|
|
302
|
-
const db = _projectDbs.get(key);
|
|
303
|
-
if (db) {
|
|
304
|
-
db.close();
|
|
305
|
-
_projectDbs.delete(key);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// src/db/task-checkpoint-receipt.ts
|
|
310
122
|
var TASK_COMPLETION_HASH_LENGTH = 16;
|
|
311
123
|
function taskReceiptLabelSuffix(planIdentityHash, taskId, generation) {
|
|
312
124
|
return createHash("sha256").update(JSON.stringify(generation === 1 ? [planIdentityHash, taskId] : [planIdentityHash, taskId, generation]), "utf8").digest("hex").slice(0, TASK_COMPLETION_HASH_LENGTH);
|
|
@@ -340,47 +152,49 @@ function ensureTaskCheckpointReceipt(directory, planIdentityHash, taskId, comple
|
|
|
340
152
|
}
|
|
341
153
|
const db = getProjectDb(directory);
|
|
342
154
|
const initial = buildTaskCompletionDescriptor(planIdentityHash, taskId, 1);
|
|
343
|
-
db.
|
|
344
|
-
db.
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
155
|
+
withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
|
|
156
|
+
db.transaction(() => {
|
|
157
|
+
db.run(`INSERT OR IGNORE INTO task_checkpoint_receipt
|
|
158
|
+
(plan_identity_hash, task_id, label, state, sha, generation,
|
|
159
|
+
completion_active, completion_ledger_seq)
|
|
160
|
+
VALUES (?, ?, ?, 'pending', NULL, 1, 1, ?)`, [planIdentityHash, taskId, initial.label, completionLedgerSeq]);
|
|
161
|
+
const row2 = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
|
|
162
|
+
if (!row2)
|
|
163
|
+
return;
|
|
164
|
+
if (row2.completion_ledger_seq === null) {
|
|
165
|
+
db.run(`UPDATE task_checkpoint_receipt
|
|
166
|
+
SET completion_ledger_seq = ?, completion_active = 1,
|
|
167
|
+
updated_at = datetime('now')
|
|
168
|
+
WHERE plan_identity_hash = ? AND task_id = ?
|
|
169
|
+
AND completion_ledger_seq IS NULL`, [completionLedgerSeq, planIdentityHash, taskId]);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (row2.completion_ledger_seq !== completionLedgerSeq) {
|
|
173
|
+
const nextGeneration = row2.generation + 1;
|
|
174
|
+
const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, nextGeneration);
|
|
175
|
+
db.run(`UPDATE task_checkpoint_receipt
|
|
176
|
+
SET label = ?, state = 'pending', sha = NULL, generation = ?,
|
|
177
|
+
completion_active = 1, completion_ledger_seq = ?,
|
|
178
|
+
updated_at = datetime('now')
|
|
179
|
+
WHERE plan_identity_hash = ? AND task_id = ?
|
|
180
|
+
AND completion_ledger_seq = ?`, [
|
|
181
|
+
descriptor.label,
|
|
182
|
+
nextGeneration,
|
|
183
|
+
completionLedgerSeq,
|
|
184
|
+
planIdentityHash,
|
|
185
|
+
taskId,
|
|
186
|
+
row2.completion_ledger_seq
|
|
187
|
+
]);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (row2.completion_active === 0) {
|
|
191
|
+
db.run(`UPDATE task_checkpoint_receipt
|
|
192
|
+
SET completion_active = 1, updated_at = datetime('now')
|
|
193
|
+
WHERE plan_identity_hash = ? AND task_id = ?
|
|
194
|
+
AND completion_ledger_seq = ? AND completion_active = 0`, [planIdentityHash, taskId, completionLedgerSeq]);
|
|
195
|
+
}
|
|
196
|
+
})();
|
|
197
|
+
});
|
|
384
198
|
const row = readTaskCheckpointReceipt(directory, planIdentityHash, taskId);
|
|
385
199
|
if (!row) {
|
|
386
200
|
throw new Error(`Failed to create or read task checkpoint receipt for ${taskId}`);
|
|
@@ -391,34 +205,38 @@ function activateTaskCheckpointReceipt(directory, planIdentityHash, taskId) {
|
|
|
391
205
|
if (!projectDbExists(directory))
|
|
392
206
|
return null;
|
|
393
207
|
const db = getProjectDb(directory);
|
|
394
|
-
db.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
208
|
+
withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
|
|
209
|
+
db.transaction(() => {
|
|
210
|
+
const row = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
|
|
211
|
+
if (!row || row.completion_active === 1)
|
|
212
|
+
return;
|
|
213
|
+
const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, row.generation);
|
|
214
|
+
db.run(`UPDATE task_checkpoint_receipt
|
|
215
|
+
SET label = ?, state = 'pending', sha = NULL, completion_active = 1,
|
|
216
|
+
updated_at = datetime('now')
|
|
217
|
+
WHERE plan_identity_hash = ? AND task_id = ? AND completion_active = 0`, [descriptor.label, planIdentityHash, taskId]);
|
|
218
|
+
})();
|
|
219
|
+
});
|
|
404
220
|
return readTaskCheckpointReceipt(directory, planIdentityHash, taskId);
|
|
405
221
|
}
|
|
406
222
|
function advanceTaskCheckpointReceiptGeneration(directory, planIdentityHash, taskId) {
|
|
407
223
|
if (!projectDbExists(directory))
|
|
408
224
|
return null;
|
|
409
225
|
const db = getProjectDb(directory);
|
|
410
|
-
db.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
226
|
+
withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
|
|
227
|
+
db.transaction(() => {
|
|
228
|
+
const row = db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(planIdentityHash, taskId);
|
|
229
|
+
if (!row || row.completion_active === 0)
|
|
230
|
+
return;
|
|
231
|
+
const nextGeneration = row.generation + 1;
|
|
232
|
+
const descriptor = buildTaskCompletionDescriptor(planIdentityHash, taskId, nextGeneration);
|
|
233
|
+
db.run(`UPDATE task_checkpoint_receipt
|
|
234
|
+
SET label = ?, state = 'pending', sha = NULL, generation = ?,
|
|
235
|
+
completion_active = 0, completion_ledger_seq = NULL,
|
|
236
|
+
updated_at = datetime('now')
|
|
237
|
+
WHERE plan_identity_hash = ? AND task_id = ? AND completion_active = 1`, [descriptor.label, nextGeneration, planIdentityHash, taskId]);
|
|
238
|
+
})();
|
|
239
|
+
});
|
|
422
240
|
return readTaskCheckpointReceipt(directory, planIdentityHash, taskId);
|
|
423
241
|
}
|
|
424
242
|
function repairTaskCheckpointReceiptForCompletion(directory, planIdentityHash, taskId) {
|
|
@@ -435,21 +253,25 @@ function repairTaskCheckpointReceiptForCompletion(directory, planIdentityHash, t
|
|
|
435
253
|
}
|
|
436
254
|
function updateTaskCheckpointReceipt(directory, descriptor, state, sha) {
|
|
437
255
|
const db = getProjectDb(directory);
|
|
438
|
-
db.
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
256
|
+
const rowAfter = withDurabilityClass(db, DURABILITY_CLASSES.task_checkpoint_receipt, () => {
|
|
257
|
+
db.transaction(() => {
|
|
258
|
+
db.run(`UPDATE task_checkpoint_receipt
|
|
259
|
+
SET state = ?, sha = ?, updated_at = datetime('now')
|
|
260
|
+
WHERE plan_identity_hash = ? AND task_id = ?
|
|
261
|
+
AND generation = ? AND completion_active = 1`, [
|
|
262
|
+
state,
|
|
263
|
+
sha,
|
|
264
|
+
descriptor.planIdentityHash,
|
|
265
|
+
descriptor.taskId,
|
|
266
|
+
descriptor.generation
|
|
267
|
+
]);
|
|
268
|
+
})();
|
|
269
|
+
return db.query("SELECT * FROM task_checkpoint_receipt WHERE plan_identity_hash = ? AND task_id = ?").get(descriptor.planIdentityHash, descriptor.taskId) ?? null;
|
|
270
|
+
});
|
|
271
|
+
if (!rowAfter || rowAfter.generation !== descriptor.generation || rowAfter.completion_active !== 1) {
|
|
450
272
|
throw new Error(`Task checkpoint receipt generation changed for ${descriptor.taskId}`);
|
|
451
273
|
}
|
|
452
|
-
return
|
|
274
|
+
return rowAfter;
|
|
453
275
|
}
|
|
454
276
|
|
|
455
277
|
// src/git/branch.ts
|
|
@@ -762,7 +584,7 @@ async function resetToRemoteBranch(cwd, options) {
|
|
|
762
584
|
let lastError;
|
|
763
585
|
for (let retry = 0;retry < 4; retry++) {
|
|
764
586
|
if (retry > 0 && process.platform === "win32") {
|
|
765
|
-
await new Promise((
|
|
587
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
766
588
|
}
|
|
767
589
|
try {
|
|
768
590
|
gitExec(["reset", "--hard", targetBranch], cwd);
|
|
@@ -972,7 +794,7 @@ async function resetToMainAfterMerge(cwd, options) {
|
|
|
972
794
|
let discardSucceeded = false;
|
|
973
795
|
for (let retry = 0;retry < 4; retry++) {
|
|
974
796
|
if (retry > 0 && process.platform === "win32") {
|
|
975
|
-
await new Promise((
|
|
797
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
976
798
|
}
|
|
977
799
|
try {
|
|
978
800
|
_internals.gitExec(["checkout", "--", "."], cwd);
|
|
@@ -1665,7 +1487,7 @@ var _internals4 = {
|
|
|
1665
1487
|
gitHeadSha: (cwd) => {
|
|
1666
1488
|
return _internals.gitExec(["rev-parse", "HEAD"], cwd).trim();
|
|
1667
1489
|
},
|
|
1668
|
-
sleep: (ms) => new Promise((
|
|
1490
|
+
sleep: (ms) => new Promise((resolve3) => setTimeout(resolve3, ms)),
|
|
1669
1491
|
hasExistingTaskCommit: (cwd, taskId) => {
|
|
1670
1492
|
const safeId = scrubTaskIdForGitSubject(taskId);
|
|
1671
1493
|
const escaped = safeId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -1830,7 +1652,7 @@ function readTaskScopes(directory, taskId) {
|
|
|
1830
1652
|
// src/utils/spec-hash.ts
|
|
1831
1653
|
import { createHash as createHash3 } from "crypto";
|
|
1832
1654
|
import * as fsSync2 from "fs";
|
|
1833
|
-
import { join as
|
|
1655
|
+
import { join as join4 } from "path";
|
|
1834
1656
|
async function computeSpecHash(directory) {
|
|
1835
1657
|
const spec = _internals5.readEffectiveSpecSync(directory);
|
|
1836
1658
|
if (!spec)
|
|
@@ -1859,7 +1681,7 @@ async function isSpecStale(directory, plan) {
|
|
|
1859
1681
|
return { stale: false };
|
|
1860
1682
|
}
|
|
1861
1683
|
function isObligationPreserving(directory) {
|
|
1862
|
-
const snapshotPath =
|
|
1684
|
+
const snapshotPath = join4(directory, ".swarm", "spec-snapshot.md");
|
|
1863
1685
|
try {
|
|
1864
1686
|
let recordedContent;
|
|
1865
1687
|
try {
|
|
@@ -1905,7 +1727,7 @@ var _internals5 = {
|
|
|
1905
1727
|
readEffectiveSpecSync
|
|
1906
1728
|
};
|
|
1907
1729
|
function computeSpecDiff(directory) {
|
|
1908
|
-
const snapshotPath =
|
|
1730
|
+
const snapshotPath = join4(directory, ".swarm", "spec-snapshot.md");
|
|
1909
1731
|
let recordedContent;
|
|
1910
1732
|
try {
|
|
1911
1733
|
const snapshotSize = fsSync2.statSync(snapshotPath).size;
|
|
@@ -2109,7 +1931,7 @@ async function retryCasWithBackoff(directory, eventInput, options) {
|
|
|
2109
1931
|
expectedHashPrefix: currentExpected.slice(0, 8),
|
|
2110
1932
|
delayMs
|
|
2111
1933
|
});
|
|
2112
|
-
await new Promise((
|
|
1934
|
+
await new Promise((resolve4) => setTimeout(resolve4, delayMs));
|
|
2113
1935
|
if (options.verifyValid) {
|
|
2114
1936
|
const stillValid = await options.verifyValid();
|
|
2115
1937
|
if (!stillValid)
|
|
@@ -2583,7 +2405,7 @@ async function savePlan(directory, plan, options) {
|
|
|
2583
2405
|
const oldLedgerPath = path5.join(swarmDir2, "plan-ledger.jsonl");
|
|
2584
2406
|
const oldLedgerBackupPath = path5.join(swarmDir2, `plan-ledger.backup-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
|
|
2585
2407
|
let backupExists = false;
|
|
2586
|
-
if (
|
|
2408
|
+
if (existsSync3(oldLedgerPath)) {
|
|
2587
2409
|
try {
|
|
2588
2410
|
options?.preCommitCheck?.();
|
|
2589
2411
|
renameSync2(oldLedgerPath, oldLedgerBackupPath);
|
|
@@ -2602,11 +2424,11 @@ async function savePlan(directory, plan, options) {
|
|
|
2602
2424
|
const errorMessage2 = String(initErr);
|
|
2603
2425
|
if (errorMessage2.includes("already initialized")) {
|
|
2604
2426
|
try {
|
|
2605
|
-
if (
|
|
2427
|
+
if (existsSync3(oldLedgerBackupPath))
|
|
2606
2428
|
unlinkSync2(oldLedgerBackupPath);
|
|
2607
2429
|
} catch {}
|
|
2608
2430
|
} else {
|
|
2609
|
-
if (
|
|
2431
|
+
if (existsSync3(oldLedgerBackupPath)) {
|
|
2610
2432
|
try {
|
|
2611
2433
|
renameSync2(oldLedgerBackupPath, oldLedgerPath);
|
|
2612
2434
|
} catch {
|
|
@@ -2628,13 +2450,13 @@ async function savePlan(directory, plan, options) {
|
|
|
2628
2450
|
} catch (renameErr) {
|
|
2629
2451
|
warn(`[savePlan] Could not archive old ledger (rename failed: ${renameErr instanceof Error ? renameErr.message : String(renameErr)}). Old ledger may still exist at ${oldLedgerBackupPath}.`);
|
|
2630
2452
|
try {
|
|
2631
|
-
if (
|
|
2453
|
+
if (existsSync3(oldLedgerBackupPath))
|
|
2632
2454
|
unlinkSync2(oldLedgerBackupPath);
|
|
2633
2455
|
} catch {}
|
|
2634
2456
|
}
|
|
2635
2457
|
} else if (!initSucceeded && backupExists) {
|
|
2636
2458
|
try {
|
|
2637
|
-
if (
|
|
2459
|
+
if (existsSync3(oldLedgerBackupPath))
|
|
2638
2460
|
unlinkSync2(oldLedgerBackupPath);
|
|
2639
2461
|
} catch {}
|
|
2640
2462
|
}
|
|
@@ -2932,7 +2754,7 @@ async function rebuildPlan(directory, plan, options) {
|
|
|
2932
2754
|
const swarmDir = path5.join(directory, ".swarm");
|
|
2933
2755
|
const planPath = path5.join(swarmDir, "plan.json");
|
|
2934
2756
|
const mdPath = path5.join(swarmDir, "plan.md");
|
|
2935
|
-
|
|
2757
|
+
mkdirSync2(swarmDir, { recursive: true });
|
|
2936
2758
|
const tempPlanPath = path5.join(swarmDir, `plan.json.rebuild.${Date.now()}.${Math.floor(Math.random() * 1e9)}`);
|
|
2937
2759
|
{
|
|
2938
2760
|
const fd = openSync(tempPlanPath, "w");
|
|
@@ -3472,7 +3294,7 @@ function migrateLegacyPlan(planContent, swarmId) {
|
|
|
3472
3294
|
// src/evidence/manager.ts
|
|
3473
3295
|
init_zod();
|
|
3474
3296
|
import {
|
|
3475
|
-
mkdirSync as
|
|
3297
|
+
mkdirSync as mkdirSync3,
|
|
3476
3298
|
readdirSync as readdirSync2,
|
|
3477
3299
|
realpathSync as realpathSync2,
|
|
3478
3300
|
renameSync as renameSync3,
|
|
@@ -3669,7 +3491,7 @@ async function atomicRenameWithRetry(src, dst, renameFn = fsp.rename) {
|
|
|
3669
3491
|
throw err;
|
|
3670
3492
|
}
|
|
3671
3493
|
if (attempt < RENAME_MAX_ATTEMPTS - 1) {
|
|
3672
|
-
await new Promise((
|
|
3494
|
+
await new Promise((resolve4) => setTimeout(resolve4, RENAME_BACKOFF_MS));
|
|
3673
3495
|
}
|
|
3674
3496
|
}
|
|
3675
3497
|
}
|
|
@@ -3956,7 +3778,7 @@ async function saveEvidence(directory, taskId, evidence, abortSignal) {
|
|
|
3956
3778
|
if (bundleJson.length > EVIDENCE_MAX_JSON_BYTES) {
|
|
3957
3779
|
throw new Error(`Evidence bundle size (${bundleJson.length} bytes) exceeds maximum (${EVIDENCE_MAX_JSON_BYTES} bytes)`);
|
|
3958
3780
|
}
|
|
3959
|
-
|
|
3781
|
+
mkdirSync3(evidenceDir, { recursive: true });
|
|
3960
3782
|
const tempPath = path7.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
|
|
3961
3783
|
try {
|
|
3962
3784
|
await bunWrite(tempPath, bundleJson);
|
|
@@ -4344,4 +4166,4 @@ function mergeDurableGateEntriesFromEvidence(taskId, entries, evidence) {
|
|
|
4344
4166
|
return merged;
|
|
4345
4167
|
}
|
|
4346
4168
|
|
|
4347
|
-
export {
|
|
4169
|
+
export { normalizePath, buildTaskCompletionDescriptor, ensureTaskCheckpointReceipt, updateTaskCheckpointReceipt, MAX_TRANSIENT_RETRIES, isTransientSpawnError, transientBackoff, getGitRepositoryStatus, isGitRepo, getDefaultBaseBranch, detectDefaultRemoteBranch, resetToRemoteBranch, resetToMainAfterMerge, containsPathTraversal, containsControlChars, validateSymlinkBoundary, validateTargetWithinRoot, isStateUnreadable, loadEpicSessionState, isEpicModeActive, enableEpicMode, disableEpicMode, pathsConflict, isGlobalFile, isProtectedPath, readTaskScopes, loadPlanJsonOnly, loadPlan, savePlan, closePlanTerminalState, updateTaskStatus, derivePlanMarkdown, isValidEvidenceType, isSecretscanEvidence, sanitizeTaskId2 as sanitizeTaskId, validateProjectRoot, saveEvidence, loadEvidence, listEvidenceTaskIds, checkRequirementCoverage, archiveEvidence, readDurableGateEvidence, getDurableGateEvidenceStatus, getDurableGateEvidenceStatusForTask, mergeDurableGateEntriesFromEvidence };
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
SWARM_WORKTREE_DIR_NAME,
|
|
15
15
|
init_constants
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-2yd732fd.js";
|
|
17
17
|
import {
|
|
18
18
|
log
|
|
19
19
|
} from "./index-zgwm4ryv.js";
|
|
@@ -92,7 +92,7 @@ var _internals = {
|
|
|
92
92
|
symlinkSync: fs.symlinkSync
|
|
93
93
|
},
|
|
94
94
|
writeScopeToDisk: async (directory, taskId, files) => {
|
|
95
|
-
const { writeScopeToDisk: realWrite } = await import("./scope-persistence-
|
|
95
|
+
const { writeScopeToDisk: realWrite } = await import("./scope-persistence-f6davq7x.js");
|
|
96
96
|
return realWrite(directory, taskId, files);
|
|
97
97
|
},
|
|
98
98
|
writeLaneProfileToDisk: async (_worktreePath, _laneIndex, _envOverrides) => {
|