opencode-swarm 7.184.0 → 7.184.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/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
- package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
- package/dist/background/delegation-health.d.ts +1 -1
- package/dist/background/index.d.ts +1 -0
- package/dist/background/pr-event-delivery.d.ts +29 -14
- package/dist/background/pr-event-subscribers.d.ts +6 -5
- package/dist/background/pr-feedback-event-queue.d.ts +19 -2
- package/dist/background/pr-feedback-loop-runtime.d.ts +75 -0
- package/dist/background/pr-feedback-loop.d.ts +47 -12
- package/dist/cli/{coder-settlement-vrc5zxvv.js → coder-settlement-vqh4b7fb.js} +15 -12
- package/dist/cli/{config-doctor-y0bpap07.js → config-doctor-8fp6s15v.js} +2 -2
- package/dist/cli/{core-7f955h2f.js → core-75bsfgse.js} +4 -4
- package/dist/cli/{curation-policy-fa2h82c4.js → curation-policy-49f8jx48.js} +7 -6
- package/dist/cli/{curator-drift-48x02n2m.js → curator-drift-pmcpywr0.js} +9 -9
- package/dist/cli/{curator-m7enwwz2.js → curator-gwqs85sp.js} +40 -39
- package/dist/cli/curator-llm-factory-g6hb1vvw.js +75 -0
- package/dist/cli/{dispatch-p5zjg5e6.js → dispatch-cv89p2y1.js} +1 -1
- package/dist/cli/{evidence-summary-service-k8a5vkfk.js → evidence-summary-service-rm0tp8d1.js} +21 -20
- package/dist/cli/{gate-evidence-nktrs0w2.js → gate-evidence-ra0trg97.js} +14 -7
- package/dist/cli/guardrail-explain-kghhhjky.js +76 -0
- package/dist/cli/{guardrail-log-dppv6tgn.js → guardrail-log-r72971jr.js} +8 -8
- package/dist/cli/{guardrail-reset-btzq4ses.js → guardrail-reset-1kq1m70y.js} +40 -39
- package/dist/cli/{hive-promoter-yp1baj9z.js → hive-promoter-82ygdw79.js} +40 -39
- package/dist/cli/{index-6h81yvyc.js → index-131ay7x1.js} +3 -3
- package/dist/cli/{index-rwfmx7vn.js → index-1v13c6r0.js} +2 -2
- package/dist/cli/{index-ad3yskxy.js → index-279xp2be.js} +158 -27
- package/dist/cli/{index-9yvjwfay.js → index-2wn8ww1e.js} +3156 -1887
- package/dist/cli/{index-0bpr8vag.js → index-3n5zsp31.js} +2 -2
- package/dist/cli/{index-w81jmdkt.js → index-456awy1p.js} +2 -2
- package/dist/cli/{index-74x26wyj.js → index-475bkab8.js} +2 -2
- package/dist/cli/{index-nvm6mxep.js → index-5r5s0dbb.js} +271 -80
- package/dist/cli/{index-r30xs0wp.js → index-6ayk7a3q.js} +1 -1
- package/dist/cli/{index-4t0wd9sv.js → index-6g664sy8.js} +1 -1
- package/dist/cli/{index-me39468k.js → index-8chh1c96.js} +38 -18
- package/dist/cli/{index-079xzcxb.js → index-ahe4mn8t.js} +40 -39
- package/dist/cli/{index-3fhg7pqf.js → index-amhr3swp.js} +2 -2
- package/dist/cli/{index-e90m050y.js → index-ar2gsn6b.js} +8 -8
- package/dist/cli/{index-51xtrf7g.js → index-b0qyb790.js} +39 -15
- package/dist/cli/{index-edrgc139.js → index-bga7w4rt.js} +2 -2
- package/dist/cli/{index-t1swv35d.js → index-dm2ydm2b.js} +1 -1
- package/dist/cli/{index-v3hpsxvd.js → index-earq3mda.js} +1 -1
- package/dist/cli/{index-3rb5gs4w.js → index-f0nj3d8z.js} +1 -1
- package/dist/cli/{index-152b9c6m.js → index-hkqd9jz6.js} +5 -5
- package/dist/cli/{index-ysr6n4ca.js → index-j2xcdbfd.js} +1 -1
- package/dist/cli/{index-t26gj2fh.js → index-jct9kb50.js} +2 -2
- package/dist/cli/{index-mn5zzmqx.js → index-jvk95e6y.js} +2 -2
- package/dist/cli/{index-b5mkznms.js → index-k1cxfede.js} +1 -1
- package/dist/cli/{index-5cve9g2b.js → index-k53a69vb.js} +6 -6
- package/dist/cli/{index-1xnse449.js → index-mc72pk74.js} +1 -1
- package/dist/cli/{index-nm8ma9xb.js → index-peg6sftq.js} +8 -8
- package/dist/cli/{index-fs9y88h1.js → index-q5115jpe.js} +3 -3
- package/dist/cli/{index-4gr9pj67.js → index-rp6sfpwp.js} +4 -4
- package/dist/cli/{index-pq6vr26z.js → index-rpsmx4ke.js} +3 -3
- package/dist/cli/{index-z3b157ew.js → index-rr1m7cc6.js} +12 -10
- package/dist/cli/{index-bf1726rj.js → index-stcacf0k.js} +42 -41
- package/dist/cli/{index-01wt209s.js → index-t7hmqgjy.js} +90 -141
- package/dist/cli/{index-5wk0etp8.js → index-w6agyrzs.js} +4 -4
- package/dist/cli/{index-08x7gsnf.js → index-w9hxzcz4.js} +2 -2
- package/dist/cli/{index-nmh0s6dg.js → index-wy3zpwjy.js} +1 -1
- package/dist/cli/{index-fbhtb6f5.js → index-x1gyqgze.js} +7 -7
- package/dist/cli/{index-6b4vkz6q.js → index-x9wpvhpk.js} +1 -1
- package/dist/cli/index-xf69xty9.js +105 -0
- package/dist/cli/{index-46z4c89b.js → index-xka1cq9k.js} +4 -4
- package/dist/cli/{index-z8smhv7k.js → index-ya32wfkp.js} +4 -2
- package/dist/cli/{index-njf5pbkm.js → index-zmgs43tw.js} +6 -6
- package/dist/cli/{index-qyx53xrz.js → index-zq40mkha.js} +7 -7
- package/dist/cli/{index-j40czc9v.js → index-zvbn85q0.js} +5 -5
- package/dist/cli/{index-1d6ssjcj.js → index-zzvxj02e.js} +3 -3
- package/dist/cli/index.js +41 -40
- package/dist/cli/{knowledge-escalator-4296y1h2.js → knowledge-escalator-x0159cv7.js} +14 -13
- package/dist/cli/{knowledge-events-31nga9yt.js → knowledge-events-4879bjbz.js} +12 -11
- package/dist/cli/{knowledge-link-ydpvzam8.js → knowledge-link-ap2274vm.js} +6 -5
- package/dist/cli/{knowledge-store-0qz3zmq3.js → knowledge-store-zvstn7dy.js} +7 -6
- package/dist/cli/{knowledge-validator-vndnwdj6.js → knowledge-validator-k0q00zsj.js} +9 -8
- package/dist/cli/{mcp-taace90a.js → mcp-tmr9kgrr.js} +15 -1
- package/dist/cli/mcp.d.ts +1 -0
- package/dist/cli/{model-preflight-bv8nvjjx.js → model-preflight-17y17gys.js} +40 -39
- package/dist/cli/{pending-delegations-kwdk8j9d.js → pending-delegations-jzr2w62w.js} +13 -12
- package/dist/cli/{pr-subscriptions-w2fwdpkk.js → pr-subscriptions-t867sq1q.js} +13 -12
- package/dist/cli/{pr-workflow-gate-sqjc6jmd.js → pr-workflow-gate-npgdhk7j.js} +40 -39
- package/dist/cli/{runner-r6gxq7m1.js → runner-yz3ysehf.js} +7 -6
- package/dist/cli/{scan-cursor-f74b9b4k.js → scan-cursor-5zy5h556.js} +8 -7
- package/dist/cli/{schema-cyet68tw.js → schema-80nb4z6k.js} +1 -1
- package/dist/cli/{scope-persistence-rg8v0r8q.js → scope-persistence-t2888gjf.js} +16 -15
- package/dist/cli/{server-765s4stz.js → server-41f41q15.js} +40 -39
- package/dist/cli/{skill-generator-qg5m18k7.js → skill-generator-6kj1xzk8.js} +16 -15
- package/dist/cli/{snapshot-coordination-init-zzs4bkmj.js → snapshot-coordination-init-pbdzjv20.js} +40 -39
- package/dist/cli/{speckit-checkoff-2bsm6p0c.js → speckit-checkoff-4ppx68ks.js} +4 -4
- package/dist/cli/{telemetry-rzvcp2n9.js → telemetry-39zmx4fp.js} +2 -2
- package/dist/cli/{workspace-snapshot-t22m6gbd.js → workspace-snapshot-0q1n1xq5.js} +4 -4
- package/dist/cli/{worktree-collision-ownership-qf2shp2n.js → worktree-collision-ownership-hn1mgtta.js} +14 -13
- package/dist/cli/{worktree-isolation-0b0jy6dt.js → worktree-isolation-w4nq6yzp.js} +40 -39
- package/dist/db/qa-gate-session-override.d.ts +12 -12
- package/dist/gate-evidence.d.ts +43 -1
- package/dist/hooks/guardrails/index.d.ts +13 -7
- package/dist/index.js +507 -503
- package/dist/plan/ledger.d.ts +20 -4
- package/dist/plan/manager.d.ts +20 -2
- package/dist/session/hydration-ownership.d.ts +39 -12
- package/dist/session/snapshot-coordination-init.d.ts +11 -4
- package/dist/session/snapshot-reader.d.ts +9 -4
- package/dist/session/snapshot-writer.d.ts +2 -3
- package/dist/state.d.ts +35 -5
- package/dist/tools/phase-complete.d.ts +1 -0
- package/dist/tools/update-task-status.d.ts +1 -1
- package/dist/utils/project-boundary.d.ts +32 -1
- package/dist/workflow/coder-settlement.d.ts +8 -0
- package/dist/workflow/task-terminal.d.ts +2 -1
- package/dist/workflow/workflow-wal-schema.d.ts +2 -0
- package/package.json +1 -1
- package/dist/cli/curator-llm-factory-g6at4hn6.js +0 -74
- package/dist/cli/guardrail-explain-1ccchxdr.js +0 -75
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
validateSwarmPath
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-wy3zpwjy.js";
|
|
5
5
|
import {
|
|
6
6
|
bunSpawn
|
|
7
7
|
} from "./index-2s7dvzff.js";
|
|
8
8
|
import {
|
|
9
9
|
canonicalRootKey,
|
|
10
10
|
sameProjectRoot
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-mc72pk74.js";
|
|
12
12
|
import {
|
|
13
13
|
atomicWriteSwarmFile
|
|
14
|
-
} from "./index-
|
|
14
|
+
} from "./index-k53a69vb.js";
|
|
15
15
|
import {
|
|
16
16
|
init_git_executable,
|
|
17
17
|
resolveGitExecutable
|
|
@@ -14,14 +14,14 @@ import {
|
|
|
14
14
|
detectWindowsWrites,
|
|
15
15
|
getSharedClassifierGuardrailBlock,
|
|
16
16
|
resolveWriteTargets
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-2wn8ww1e.js";
|
|
18
18
|
import {
|
|
19
19
|
checkFileAuthority,
|
|
20
20
|
classifyFile,
|
|
21
21
|
isInDeclaredScope,
|
|
22
22
|
redactPath,
|
|
23
23
|
redactShellCommand
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-rpsmx4ke.js";
|
|
25
25
|
|
|
26
26
|
// src/services/guardrail-explain-service.ts
|
|
27
27
|
import path from "path";
|
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
import {
|
|
3
3
|
autoCommitDirty,
|
|
4
4
|
cleanUntrackedFiles
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-rp6sfpwp.js";
|
|
6
6
|
import {
|
|
7
7
|
validateSwarmPath
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-wy3zpwjy.js";
|
|
9
9
|
import {
|
|
10
10
|
bunSpawn,
|
|
11
11
|
classifySpawnFailure
|
|
12
12
|
} from "./index-2s7dvzff.js";
|
|
13
13
|
import {
|
|
14
|
-
assertProjectRoot,
|
|
15
14
|
atomicWriteFile,
|
|
16
15
|
taskEvidencePath,
|
|
17
16
|
withTaskEvidenceLock
|
|
18
|
-
} from "./index-
|
|
17
|
+
} from "./index-xf69xty9.js";
|
|
18
|
+
import {
|
|
19
|
+
assertProjectRoot
|
|
20
|
+
} from "./index-t7hmqgjy.js";
|
|
19
21
|
import {
|
|
20
22
|
telemetry
|
|
21
|
-
} from "./index-
|
|
23
|
+
} from "./index-x1gyqgze.js";
|
|
22
24
|
import {
|
|
23
25
|
advisoryWarn,
|
|
24
26
|
init_git_executable,
|
|
@@ -40,7 +42,7 @@ import {
|
|
|
40
42
|
|
|
41
43
|
// src/gate-evidence.ts
|
|
42
44
|
init_zod();
|
|
43
|
-
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "fs";
|
|
45
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, realpathSync as realpathSync2, statSync as statSync2 } from "fs";
|
|
44
46
|
import * as path4 from "path";
|
|
45
47
|
|
|
46
48
|
// src/evidence/task-gate-requirements.ts
|
|
@@ -1487,7 +1489,7 @@ function parseCoderSettlementWal(raw, filePath, expectedTaskId) {
|
|
|
1487
1489
|
const baseline = context?.baseline;
|
|
1488
1490
|
const worktree = parsed.worktree;
|
|
1489
1491
|
const provenance = parsed.mergeProvenance;
|
|
1490
|
-
if (parsed.version !== 1 || !["ABORTED", "COMMITTED", "DISPATCHED", "PREPARED"].includes(String(parsed.state)) || typeof parsed.taskId !== "string" || !TASK_ID_PATTERN.test(parsed.taskId) || typeof parsed.transitionId !== "string" || parsed.transitionId.length === 0 || parsed.transitionId.length > 512 || typeof parsed.actor !== "string" || parsed.actor.length === 0 || parsed.actor.length > 512 || !Number.isInteger(parsed.processId) || (parsed.processId ?? 0) <= 0 || typeof parsed.runtimeId !== "string" || parsed.runtimeId.length === 0 || !Number.isInteger(parsed.expectedGeneration) || (parsed.expectedGeneration ?? -1) < 0 || !context || !baseline || typeof baseline.directory !== "string" || baseline.directory.length === 0 || baseline.directory.length > 4096 || typeof baseline.gitHead !== "string" && baseline.gitHead !== null || typeof baseline.dirtyHash !== "string" && baseline.dirtyHash !== null || typeof baseline.prHeadSha !== "string" && baseline.prHeadSha !== null || typeof baseline.scope !== "string" && baseline.scope !== null || !Array.isArray(baseline.changedFiles) && baseline.changedFiles !== null && baseline.changedFiles !== undefined || Array.isArray(baseline.changedFiles) && (baseline.changedFiles.length > 50000 || baseline.changedFiles.some((candidatePath) => typeof candidatePath !== "string" || candidatePath.length > 4096)) || !Array.isArray(context.declaredFiles) && context.declaredFiles !== null || Array.isArray(context.declaredFiles) && (context.declaredFiles.length > 50000 || context.declaredFiles.some((candidatePath) => typeof candidatePath !== "string" || candidatePath.length > 4096)) || parsed.observedFiles !== undefined && (!Array.isArray(parsed.observedFiles) || parsed.observedFiles.length > 50000 || parsed.observedFiles.some((candidatePath) => typeof candidatePath !== "string" || candidatePath.length > 4096 || !isPathWithinDeclaredScope(candidatePath, context.declaredFiles
|
|
1492
|
+
if (parsed.version !== 1 || !["ABORTED", "COMMITTED", "DISPATCHED", "PREPARED"].includes(String(parsed.state)) || typeof parsed.taskId !== "string" || !TASK_ID_PATTERN.test(parsed.taskId) || typeof parsed.transitionId !== "string" || parsed.transitionId.length === 0 || parsed.transitionId.length > 512 || typeof parsed.actor !== "string" || parsed.actor.length === 0 || parsed.actor.length > 512 || !Number.isInteger(parsed.processId) || (parsed.processId ?? 0) <= 0 || typeof parsed.runtimeId !== "string" || parsed.runtimeId.length === 0 || !Number.isInteger(parsed.expectedGeneration) || (parsed.expectedGeneration ?? -1) < 0 || !context || !baseline || typeof baseline.directory !== "string" || baseline.directory.length === 0 || baseline.directory.length > 4096 || typeof baseline.gitHead !== "string" && baseline.gitHead !== null || typeof baseline.dirtyHash !== "string" && baseline.dirtyHash !== null || typeof baseline.prHeadSha !== "string" && baseline.prHeadSha !== null || typeof baseline.scope !== "string" && baseline.scope !== null || !Array.isArray(baseline.changedFiles) && baseline.changedFiles !== null && baseline.changedFiles !== undefined || Array.isArray(baseline.changedFiles) && (baseline.changedFiles.length > 50000 || baseline.changedFiles.some((candidatePath) => typeof candidatePath !== "string" || candidatePath.length > 4096)) || !Array.isArray(context.declaredFiles) && context.declaredFiles !== null || Array.isArray(context.declaredFiles) && (context.declaredFiles.length > 50000 || context.declaredFiles.some((candidatePath) => typeof candidatePath !== "string" || candidatePath.length > 4096)) || parsed.observedFiles !== undefined && (!Array.isArray(parsed.observedFiles) || parsed.observedFiles.length > 50000 || parsed.observedFiles.some((candidatePath) => typeof candidatePath !== "string" || candidatePath.length > 4096 || Array.isArray(context.declaredFiles) && context.declaredFiles.length > 0 && !isPathWithinDeclaredScope(candidatePath, context.declaredFiles, baseline.directory))) || worktree !== undefined && (typeof worktree.callID !== "string" || typeof worktree.parentSessionId !== "string" || typeof worktree.taskId !== "string" || worktree.taskId !== parsed.taskId || !isSafeWorktreePath(worktree.worktreePath) || !isSafeGitBranchName(worktree.branchName) || typeof worktree.worktreeId !== "string" || typeof worktree.worktreeSessionId !== "string" || !["merge", "rebase", "cherry-pick"].includes(String(worktree.mergeStrategy)) || !Number.isInteger(worktree.laneIndex)) || provenance !== undefined && (typeof provenance.operationId !== "string" || provenance.operationId !== parsed.transitionId || typeof provenance.sourceHead !== "string" || !GIT_OBJECT_ID_PATTERN.test(provenance.sourceHead) || typeof provenance.targetHeadBefore !== "string" || !GIT_OBJECT_ID_PATTERN.test(provenance.targetHeadBefore) || !isSafeGitBranchName(provenance.branchName) || worktree !== undefined && (provenance.branchName !== worktree.branchName || provenance.strategy !== worktree.mergeStrategy) || !["merge", "rebase", "cherry-pick"].includes(String(provenance.strategy))) || typeof parsed.recordedAt !== "string" || parsed.state === "PREPARED" && typeof parsed.accepted !== "boolean" || parsed.cleanupComplete !== undefined && typeof parsed.cleanupComplete !== "boolean" || parsed.settlementFailed !== undefined && typeof parsed.settlementFailed !== "boolean" || parsed.abortReason !== undefined && (typeof parsed.abortReason !== "string" || parsed.abortReason.length === 0 || parsed.abortReason.length > 512)) {
|
|
1491
1493
|
formatUnreadableMessage("CODER_SETTLEMENT_WAL_UNREADABLE", filePath, "is not a valid v1 coder-settlement WAL", "Preserve this file, reconcile the task lane, and only then move it aside.");
|
|
1492
1494
|
}
|
|
1493
1495
|
if (expectedTaskId && parsed.taskId !== expectedTaskId) {
|
|
@@ -1507,7 +1509,7 @@ function parseTaskRepairWal(raw, filePath, expectedTaskId) {
|
|
|
1507
1509
|
}
|
|
1508
1510
|
function parseTaskTerminalWal(raw, filePath, expectedTaskId) {
|
|
1509
1511
|
const parsed = parseWalObject(raw, filePath, "TASK_TERMINAL_WAL_UNREADABLE", "Preserve this file and reconcile the task terminal transition before moving it aside.");
|
|
1510
|
-
if (parsed.version !== 1 && parsed.version !== 2 || parsed.state !== "PREPARED" && parsed.state !== "COMMITTED" && parsed.state !== "ABORTED" || typeof parsed.taskId !== "string" || !TASK_ID_PATTERN.test(parsed.taskId) || typeof parsed.transitionId !== "string" || parsed.transitionId.length === 0 || parsed.transitionId.length > 512 || typeof parsed.actor !== "string" || parsed.actor.length === 0 || parsed.actor.length > 512 || typeof parsed.oldPlanStatus !== "string" || parsed.oldPlanStatus.length === 0 || parsed.oldPlanStatus.length > 128 || parsed.newPlanStatus !== "completed" && parsed.newPlanStatus !== "blocked" && parsed.newPlanStatus !== "closed" || typeof parsed.oldWorkflowState !== "string" || !WORKFLOW_STATES.has(parsed.oldWorkflowState) || parsed.newWorkflowState !== "complete" && parsed.newWorkflowState !== "blocked" && parsed.newWorkflowState !== "closed" || !Number.isInteger(parsed.generation) || (parsed.generation ?? -1) < 0 || typeof parsed.qaExempt !== "boolean" || typeof parsed.recordedAt !== "string" || !Number.isFinite(Date.parse(parsed.recordedAt))) {
|
|
1512
|
+
if (parsed.version !== 1 && parsed.version !== 2 || parsed.state !== "PREPARED" && parsed.state !== "COMMITTED" && parsed.state !== "ABORTED" || typeof parsed.taskId !== "string" || !TASK_ID_PATTERN.test(parsed.taskId) || typeof parsed.transitionId !== "string" || parsed.transitionId.length === 0 || parsed.transitionId.length > 512 || typeof parsed.actor !== "string" || parsed.actor.length === 0 || parsed.actor.length > 512 || typeof parsed.oldPlanStatus !== "string" || parsed.oldPlanStatus.length === 0 || parsed.oldPlanStatus.length > 128 || parsed.newPlanStatus !== "completed" && parsed.newPlanStatus !== "blocked" && parsed.newPlanStatus !== "closed" || typeof parsed.oldWorkflowState !== "string" || !WORKFLOW_STATES.has(parsed.oldWorkflowState) || parsed.newWorkflowState !== "complete" && parsed.newWorkflowState !== "blocked" && parsed.newWorkflowState !== "closed" || !Number.isInteger(parsed.generation) || (parsed.generation ?? -1) < 0 || typeof parsed.qaExempt !== "boolean" || parsed.readOnlyNoMutation !== undefined && typeof parsed.readOnlyNoMutation !== "boolean" || typeof parsed.recordedAt !== "string" || !Number.isFinite(Date.parse(parsed.recordedAt))) {
|
|
1511
1513
|
formatUnreadableMessage("TASK_TERMINAL_WAL_UNREADABLE", filePath, "is not a valid terminal WAL", "Preserve this file and reconcile the task terminal transition before moving it aside.");
|
|
1512
1514
|
}
|
|
1513
1515
|
if (parsed.version === 2 && (typeof parsed.planIdentityHash !== "string" || !SHA256_PATTERN.test(parsed.planIdentityHash) || typeof parsed.planEpoch !== "string" || !UUID_PATTERN.test(parsed.planEpoch))) {
|
|
@@ -1516,6 +1518,9 @@ function parseTaskTerminalWal(raw, filePath, expectedTaskId) {
|
|
|
1516
1518
|
if (parsed.version === 1 && (parsed.newPlanStatus === "closed" || parsed.newWorkflowState === "closed")) {
|
|
1517
1519
|
formatUnreadableMessage("TASK_TERMINAL_WAL_UNREADABLE", filePath, "claims a closed transition in a legacy v1 terminal WAL", "Preserve this file and reconcile the task terminal transition before moving it aside.");
|
|
1518
1520
|
}
|
|
1521
|
+
if (parsed.readOnlyNoMutation === true && (parsed.newPlanStatus !== "completed" || parsed.newWorkflowState !== "complete" || parsed.generation !== 0 || parsed.qaExempt !== false)) {
|
|
1522
|
+
throw new Error(`TASK_TERMINAL_WAL_STATE_MISMATCH: ${filePath} claims read-only no-mutation completion outside generation 0`);
|
|
1523
|
+
}
|
|
1519
1524
|
if (!(parsed.newPlanStatus === "completed" && parsed.newWorkflowState === "complete" || parsed.newPlanStatus === "blocked" && parsed.newWorkflowState === "blocked" || parsed.newPlanStatus === "closed" && parsed.newWorkflowState === "closed")) {
|
|
1520
1525
|
throw new Error(`TASK_TERMINAL_WAL_STATE_MISMATCH: ${filePath} encodes ${String(parsed.newPlanStatus)} -> ${String(parsed.newWorkflowState)}`);
|
|
1521
1526
|
}
|
|
@@ -1746,6 +1751,43 @@ var TASK_WORKFLOW_OUTCOMES = [
|
|
|
1746
1751
|
"task_closed",
|
|
1747
1752
|
"repair_idle"
|
|
1748
1753
|
];
|
|
1754
|
+
var MAX_PLAN_SCOPE_INSPECTION_BYTES = 4 * 1024 * 1024;
|
|
1755
|
+
function readCurrentTaskDeclaredFiles(directory, taskId) {
|
|
1756
|
+
try {
|
|
1757
|
+
const planPath = validateSwarmPath(directory, "plan.json");
|
|
1758
|
+
const stat = statSync2(planPath);
|
|
1759
|
+
if (!stat.isFile() || stat.size > MAX_PLAN_SCOPE_INSPECTION_BYTES) {
|
|
1760
|
+
return null;
|
|
1761
|
+
}
|
|
1762
|
+
const parsed = JSON.parse(readFileSync3(planPath, "utf8"));
|
|
1763
|
+
if (!Array.isArray(parsed.phases))
|
|
1764
|
+
return null;
|
|
1765
|
+
let declaredFiles = null;
|
|
1766
|
+
for (const phase of parsed.phases) {
|
|
1767
|
+
if (!phase || typeof phase !== "object")
|
|
1768
|
+
return null;
|
|
1769
|
+
const tasks = phase.tasks;
|
|
1770
|
+
if (!Array.isArray(tasks))
|
|
1771
|
+
return null;
|
|
1772
|
+
for (const task of tasks) {
|
|
1773
|
+
if (!task || typeof task !== "object")
|
|
1774
|
+
return null;
|
|
1775
|
+
const record = task;
|
|
1776
|
+
if (record.id !== taskId)
|
|
1777
|
+
continue;
|
|
1778
|
+
if (!Array.isArray(record.files_touched) || !record.files_touched.every((file) => typeof file === "string")) {
|
|
1779
|
+
return null;
|
|
1780
|
+
}
|
|
1781
|
+
if (declaredFiles !== null)
|
|
1782
|
+
return null;
|
|
1783
|
+
declaredFiles = [...record.files_touched];
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
return declaredFiles;
|
|
1787
|
+
} catch {
|
|
1788
|
+
return null;
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1749
1791
|
var TASK_GATE_REQUIREMENTS_RECONSTRUCTION_SENTINEL = "requirements_reconstruction";
|
|
1750
1792
|
function assertTaskEvidenceWriteAllowed(directory, taskId, event) {
|
|
1751
1793
|
assertValidTaskId(taskId);
|
|
@@ -1784,7 +1826,12 @@ var TaskWorkflowMetadataSchema = exports_external.object({
|
|
|
1784
1826
|
lastTransitionId: exports_external.string().min(1).nullable().optional().default(null),
|
|
1785
1827
|
updatedAt: exports_external.string(),
|
|
1786
1828
|
forcedCompletion: exports_external.boolean().optional(),
|
|
1787
|
-
supervisedRecovery: exports_external.boolean().optional()
|
|
1829
|
+
supervisedRecovery: exports_external.boolean().optional(),
|
|
1830
|
+
noMutationSettlement: exports_external.object({
|
|
1831
|
+
generation: exports_external.literal(0),
|
|
1832
|
+
transitionId: exports_external.string().min(1).max(512),
|
|
1833
|
+
declaredFiles: exports_external.array(exports_external.string()).length(0)
|
|
1834
|
+
}).optional()
|
|
1788
1835
|
});
|
|
1789
1836
|
var TaskEvidenceSchema = exports_external.object({
|
|
1790
1837
|
taskId: exports_external.string(),
|
|
@@ -1918,8 +1965,43 @@ function assertExpectedGeneration(snapshot, event) {
|
|
|
1918
1965
|
}
|
|
1919
1966
|
}
|
|
1920
1967
|
function isDuplicateTransition(snapshot, event) {
|
|
1968
|
+
if (event.type === "dispatch_no_mutation" && event.context?.declaredFiles?.length === 0 && event.context.settlementTransitionId === event.transitionId && !snapshot.noMutationSettlement) {
|
|
1969
|
+
return false;
|
|
1970
|
+
}
|
|
1921
1971
|
return snapshot.authoritative && typeof event.transitionId === "string" && event.transitionId.length > 0 && snapshot.lastTransitionId === event.transitionId && snapshot.lastOutcome === getEventOutcome(event);
|
|
1922
1972
|
}
|
|
1973
|
+
function isNoMutationSettlementMetadata(workflow) {
|
|
1974
|
+
const settlement = workflow.noMutationSettlement;
|
|
1975
|
+
if (!workflow.authoritative || workflow.generation !== 0 || settlement?.generation !== 0 || typeof settlement.transitionId !== "string" || settlement.transitionId.length === 0 || !Array.isArray(settlement.declaredFiles) || settlement.declaredFiles.length !== 0)
|
|
1976
|
+
return false;
|
|
1977
|
+
return workflow.state === "idle" || workflow.state === "complete";
|
|
1978
|
+
}
|
|
1979
|
+
function deriveApplicableGateSet(evidence, options) {
|
|
1980
|
+
if (!evidence) {
|
|
1981
|
+
return {
|
|
1982
|
+
requiredGates: ["pre_check"],
|
|
1983
|
+
satisfiedGates: [],
|
|
1984
|
+
missingGates: ["pre_check"],
|
|
1985
|
+
readOnlyNoMutation: false
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
const workflow = getTaskWorkflowSnapshot(evidence);
|
|
1989
|
+
const readOnlyNoMutation = isNoMutationSettlementMetadata(workflow) && (options?.currentDeclaredFiles === undefined ? true : options.currentDeclaredFiles !== null && options.currentDeclaredFiles.length === 0);
|
|
1990
|
+
const requiredGates = [...new Set(evidence.required_gates ?? [])];
|
|
1991
|
+
if (!readOnlyNoMutation && !requiredGates.includes("pre_check")) {
|
|
1992
|
+
requiredGates.unshift("pre_check");
|
|
1993
|
+
}
|
|
1994
|
+
const satisfiedGates = requiredGates.filter((gate) => evidence.gates?.[gate] != null);
|
|
1995
|
+
return {
|
|
1996
|
+
requiredGates,
|
|
1997
|
+
satisfiedGates,
|
|
1998
|
+
missingGates: requiredGates.filter((gate) => evidence.gates?.[gate] == null),
|
|
1999
|
+
readOnlyNoMutation
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
function isReadOnlyNoMutationEligible(evidence, options) {
|
|
2003
|
+
return deriveApplicableGateSet(evidence, options).readOnlyNoMutation;
|
|
2004
|
+
}
|
|
1923
2005
|
function reduceTaskWorkflowSnapshot(current, event, context) {
|
|
1924
2006
|
if ((current.state === "complete" || current.state === "blocked" || current.state === "closed") && event.type !== "repair_idle" && !(current.state === "complete" && event.type === "task_completed" || current.state === "blocked" && event.type === "task_blocked" || current.state === "blocked" && event.type === "task_closed")) {
|
|
1925
2007
|
throw new Error(`TASK_WORKFLOW_TERMINAL: cannot apply ${event.type} from ${current.state}`);
|
|
@@ -1936,18 +2018,30 @@ function reduceTaskWorkflowSnapshot(current, event, context) {
|
|
|
1936
2018
|
lastTransitionId: event.transitionId ?? current.lastTransitionId,
|
|
1937
2019
|
updatedAt: context.nowIso,
|
|
1938
2020
|
...current.forcedCompletion === true ? { forcedCompletion: true } : {},
|
|
1939
|
-
...current.supervisedRecovery === true ? { supervisedRecovery: true } : {}
|
|
2021
|
+
...current.supervisedRecovery === true ? { supervisedRecovery: true } : {},
|
|
2022
|
+
...current.noMutationSettlement ? { noMutationSettlement: current.noMutationSettlement } : {}
|
|
1940
2023
|
};
|
|
1941
2024
|
switch (event.type) {
|
|
1942
|
-
case "dispatch_attempted":
|
|
1943
|
-
|
|
1944
|
-
|
|
2025
|
+
case "dispatch_attempted": {
|
|
2026
|
+
const { noMutationSettlement: _clearedSettlement, ...withoutSettlement } = base;
|
|
2027
|
+
return withoutSettlement;
|
|
2028
|
+
}
|
|
2029
|
+
case "dispatch_no_mutation": {
|
|
2030
|
+
const { noMutationSettlement: _clearedSettlement, ...withoutSettlement } = base;
|
|
1945
2031
|
return {
|
|
1946
|
-
...
|
|
2032
|
+
...withoutSettlement,
|
|
1947
2033
|
retryCount: Math.min(current.retryCount + 1, 3),
|
|
1948
2034
|
retryHistory: [...current.retryHistory, outcome].slice(-3),
|
|
1949
|
-
retryEpoch: current.retryEpoch || current.generation + 1
|
|
2035
|
+
retryEpoch: current.retryEpoch || current.generation + 1,
|
|
2036
|
+
...current.generation === 0 && event.transitionId && Array.isArray(event.context?.declaredFiles) && event.context.declaredFiles.length === 0 && event.context.settlementTransitionId === event.transitionId ? {
|
|
2037
|
+
noMutationSettlement: {
|
|
2038
|
+
generation: 0,
|
|
2039
|
+
transitionId: event.transitionId,
|
|
2040
|
+
declaredFiles: []
|
|
2041
|
+
}
|
|
2042
|
+
} : {}
|
|
1950
2043
|
};
|
|
2044
|
+
}
|
|
1951
2045
|
case "stage_b_failed":
|
|
1952
2046
|
if (current.state !== "pre_check_passed" && current.state !== "reviewer_run" && current.state !== "tests_run" && current.state !== "rework_required") {
|
|
1953
2047
|
throw new Error(`TASK_WORKFLOW_STAGE_A_REQUIRED: cannot reject ${event.gate} from ${current.state}`);
|
|
@@ -1959,10 +2053,11 @@ function reduceTaskWorkflowSnapshot(current, event, context) {
|
|
|
1959
2053
|
retryHistory: [...current.retryHistory, outcome].slice(-3),
|
|
1960
2054
|
retryEpoch: current.retryEpoch || current.generation + 1
|
|
1961
2055
|
};
|
|
1962
|
-
case "accepted_mutation":
|
|
2056
|
+
case "accepted_mutation": {
|
|
2057
|
+
const { noMutationSettlement: _clearedSettlement, ...withoutSettlement } = base;
|
|
1963
2058
|
if (event.context?.settlementFailed === true) {
|
|
1964
2059
|
return {
|
|
1965
|
-
...
|
|
2060
|
+
...withoutSettlement,
|
|
1966
2061
|
generation: current.generation + 1,
|
|
1967
2062
|
state: "rework_required",
|
|
1968
2063
|
retryCount: Math.min(current.retryCount + 1, 3),
|
|
@@ -1972,11 +2067,12 @@ function reduceTaskWorkflowSnapshot(current, event, context) {
|
|
|
1972
2067
|
};
|
|
1973
2068
|
}
|
|
1974
2069
|
return {
|
|
1975
|
-
...
|
|
2070
|
+
...withoutSettlement,
|
|
1976
2071
|
generation: current.generation + 1,
|
|
1977
2072
|
state: "coder_delegated",
|
|
1978
2073
|
supervisedRecovery: undefined
|
|
1979
2074
|
};
|
|
2075
|
+
}
|
|
1980
2076
|
case "stage_a_passed":
|
|
1981
2077
|
if (current.state !== "coder_delegated" && current.state !== "pre_check_passed" && !(current.state === "rework_required" && event.supervisedRecovery === true)) {
|
|
1982
2078
|
throw new Error(`TASK_WORKFLOW_CODER_MUTATION_REQUIRED: cannot pass Stage A from ${current.state}`);
|
|
@@ -2019,8 +2115,9 @@ function reduceTaskWorkflowSnapshot(current, event, context) {
|
|
|
2019
2115
|
...base,
|
|
2020
2116
|
state: current.state
|
|
2021
2117
|
};
|
|
2022
|
-
case "task_completed":
|
|
2023
|
-
|
|
2118
|
+
case "task_completed": {
|
|
2119
|
+
const readOnlyNoMutation = event.readOnlyNoMutation === true && current.state === "idle" && current.generation === 0 && isNoMutationSettlementMetadata(current) && context.requiredGates.every((gate) => context.gates[gate] != null);
|
|
2120
|
+
if (event.qaExempt !== true && current.state !== "tests_run" && current.state !== "complete" && !(current.state === "pre_check_passed" && context.gates.council != null) && !readOnlyNoMutation) {
|
|
2024
2121
|
throw new Error(`TASK_WORKFLOW_QA_REQUIRED: cannot complete from ${current.state}`);
|
|
2025
2122
|
}
|
|
2026
2123
|
return {
|
|
@@ -2028,6 +2125,7 @@ function reduceTaskWorkflowSnapshot(current, event, context) {
|
|
|
2028
2125
|
state: "complete",
|
|
2029
2126
|
...event.qaExempt === true ? { forcedCompletion: true } : {}
|
|
2030
2127
|
};
|
|
2128
|
+
}
|
|
2031
2129
|
case "task_blocked":
|
|
2032
2130
|
return {
|
|
2033
2131
|
...base,
|
|
@@ -2042,6 +2140,7 @@ function reduceTaskWorkflowSnapshot(current, event, context) {
|
|
|
2042
2140
|
const {
|
|
2043
2141
|
forcedCompletion: _cleared,
|
|
2044
2142
|
supervisedRecovery: _clearedMarker,
|
|
2143
|
+
noMutationSettlement: _clearedSettlement,
|
|
2045
2144
|
...withoutForced
|
|
2046
2145
|
} = base;
|
|
2047
2146
|
return {
|
|
@@ -2078,6 +2177,32 @@ function getEvidencePath(directory, taskId) {
|
|
|
2078
2177
|
assertValidTaskId(taskId);
|
|
2079
2178
|
return taskEvidencePath(directory, taskId);
|
|
2080
2179
|
}
|
|
2180
|
+
function bindTrustedNoMutationSettlement(directory, taskId, event) {
|
|
2181
|
+
if (event.type !== "dispatch_no_mutation")
|
|
2182
|
+
return event;
|
|
2183
|
+
const context = event.context;
|
|
2184
|
+
if (!context || event.transitionId === undefined) {
|
|
2185
|
+
return { ...event, context: undefined };
|
|
2186
|
+
}
|
|
2187
|
+
try {
|
|
2188
|
+
const wal = readWorkflowWalFileSync("coder-settlement", validateSwarmPath(directory, `coder-settlements/${taskId}.json`), taskId);
|
|
2189
|
+
const declaredFiles = wal?.context?.declaredFiles;
|
|
2190
|
+
const trusted = wal !== null && (wal.state === "PREPARED" || wal.state === "COMMITTED") && wal.accepted === false && wal.transitionId === event.transitionId && Array.isArray(declaredFiles) && declaredFiles.length === 0 && Array.isArray(context.declaredFiles) && context.declaredFiles.length === 0;
|
|
2191
|
+
return {
|
|
2192
|
+
...event,
|
|
2193
|
+
context: trusted ? {
|
|
2194
|
+
...context,
|
|
2195
|
+
declaredFiles,
|
|
2196
|
+
settlementTransitionId: wal.transitionId
|
|
2197
|
+
} : { ...context, settlementTransitionId: undefined }
|
|
2198
|
+
};
|
|
2199
|
+
} catch {
|
|
2200
|
+
return {
|
|
2201
|
+
...event,
|
|
2202
|
+
context: { ...context, settlementTransitionId: undefined }
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2081
2206
|
function readExisting(evidencePath, taskId) {
|
|
2082
2207
|
try {
|
|
2083
2208
|
const raw = readFileSync3(evidencePath, "utf-8");
|
|
@@ -2220,10 +2345,11 @@ async function withTaskEvidenceTransaction(directory, taskId, agent, callback) {
|
|
|
2220
2345
|
taskId,
|
|
2221
2346
|
read: () => current,
|
|
2222
2347
|
transition: async (event) => {
|
|
2223
|
-
|
|
2224
|
-
|
|
2348
|
+
const boundEvent = bindTrustedNoMutationSettlement(directory, taskId, event);
|
|
2349
|
+
assertTaskEvidenceWriteAllowed(directory, taskId, boundEvent);
|
|
2350
|
+
const nextEvidence = updateEvidenceForTransition(current, boundEvent);
|
|
2225
2351
|
nextEvidence.taskId = taskId;
|
|
2226
|
-
return persist(nextEvidence,
|
|
2352
|
+
return persist(nextEvidence, boundEvent);
|
|
2227
2353
|
}
|
|
2228
2354
|
});
|
|
2229
2355
|
});
|
|
@@ -2320,16 +2446,21 @@ function readTaskEvidenceRaw(directory, taskId) {
|
|
|
2320
2446
|
throw error;
|
|
2321
2447
|
}
|
|
2322
2448
|
}
|
|
2323
|
-
async function hasPassedAllGates(directory, taskId) {
|
|
2449
|
+
async function hasPassedAllGates(directory, taskId, currentDeclaredFiles) {
|
|
2324
2450
|
const evidence = await readTaskEvidence(directory, taskId);
|
|
2325
2451
|
if (!evidence)
|
|
2326
2452
|
return false;
|
|
2327
|
-
if (!Array.isArray(evidence.required_gates)
|
|
2453
|
+
if (!Array.isArray(evidence.required_gates))
|
|
2328
2454
|
return false;
|
|
2329
|
-
|
|
2455
|
+
if (currentDeclaredFiles === undefined) {
|
|
2456
|
+
if (deriveApplicableGateSet(evidence).readOnlyNoMutation)
|
|
2457
|
+
return false;
|
|
2458
|
+
return hasAllRequiredGatesPassed(evidence.required_gates, evidence.gates);
|
|
2459
|
+
}
|
|
2460
|
+
return deriveApplicableGateSet(evidence, { currentDeclaredFiles }).missingGates.length === 0;
|
|
2330
2461
|
}
|
|
2331
2462
|
function compareTaskWorkflowStateRank(left, right) {
|
|
2332
2463
|
return WORKFLOW_STATE_RANK[left] - WORKFLOW_STATE_RANK[right];
|
|
2333
2464
|
}
|
|
2334
2465
|
|
|
2335
|
-
export { isStrictTaskId, sanitizeTaskId, listRecoveryRecords, GitBinaryMissingError, GitSpawnCwdError, isGitBinaryMissing, isSpawnCwdMissing, isSpawnCwdUnreadable, _internals, SOURCE_WORKTREE_GONE_STAGE, SOURCE_WORKTREE_UNCERTAIN_STAGE, getMergeStrategy, recoverMergeBackFromImmutableCoordinates, reconcileLandedMerge, postMergeCleanup, pruneStaleWorktreeMetadata, attemptMergeBackFromDirty, cleanupOrphanedBranches, startupOrphanRecovery, readWorkflowWalFile, writeWorkflowWalFile, _internals3 as _internals1, TASK_WORKFLOW_SCHEMA_MARKER, TASK_GATE_REQUIREMENTS_RECONSTRUCTION_SENTINEL, assertTaskEvidenceWriteAllowed, parseTaskEvidence, DEFAULT_REQUIRED_GATES, isValidTaskId, getTaskWorkflowSnapshot, reduceTaskWorkflowSnapshot, deriveRequiredGates, expandRequiredGates, transitionTaskWorkflowEvidence, withTaskEvidenceTransaction, ensureTaskGateRequirementsReceiptForSettledTransition, recordGateEvidence, recordAgentDispatch, readTaskEvidence, readTaskEvidenceState, readTaskEvidenceRaw, hasPassedAllGates, compareTaskWorkflowStateRank };
|
|
2466
|
+
export { isStrictTaskId, sanitizeTaskId, listRecoveryRecords, GitBinaryMissingError, GitSpawnCwdError, isGitBinaryMissing, isSpawnCwdMissing, isSpawnCwdUnreadable, _internals, SOURCE_WORKTREE_GONE_STAGE, SOURCE_WORKTREE_UNCERTAIN_STAGE, getMergeStrategy, recoverMergeBackFromImmutableCoordinates, reconcileLandedMerge, postMergeCleanup, pruneStaleWorktreeMetadata, attemptMergeBackFromDirty, cleanupOrphanedBranches, startupOrphanRecovery, readWorkflowWalFile, writeWorkflowWalFile, _internals3 as _internals1, TASK_WORKFLOW_SCHEMA_MARKER, readCurrentTaskDeclaredFiles, TASK_GATE_REQUIREMENTS_RECONSTRUCTION_SENTINEL, assertTaskEvidenceWriteAllowed, parseTaskEvidence, DEFAULT_REQUIRED_GATES, isValidTaskId, getTaskWorkflowSnapshot, deriveApplicableGateSet, isReadOnlyNoMutationEligible, reduceTaskWorkflowSnapshot, deriveRequiredGates, expandRequiredGates, transitionTaskWorkflowEvidence, withTaskEvidenceTransaction, ensureTaskGateRequirementsReceiptForSettledTransition, recordGateEvidence, recordAgentDispatch, readTaskEvidence, readTaskEvidenceState, readTaskEvidenceRaw, hasPassedAllGates, compareTaskWorkflowStateRank };
|