opencode-swarm 7.167.1 → 7.168.0
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/agents/project-context.d.ts +12 -8
- package/dist/cli/{coder-settlement-2ye4s5xr.js → coder-settlement-a35acvj1.js} +16 -16
- package/dist/cli/{config-doctor-b0k8eyd6.js → config-doctor-9csx775x.js} +3 -3
- package/dist/cli/{core-xgzgjk8s.js → core-agk5s7dm.js} +4 -4
- package/dist/cli/{curation-policy-bvxf5pxv.js → curation-policy-mgwv8h2k.js} +7 -7
- package/dist/cli/{curator-jpvzrxcv.js → curator-2fcagjyk.js} +45 -45
- package/dist/cli/{curator-drift-20m2ab5w.js → curator-drift-k0zrnm09.js} +8 -8
- package/dist/cli/curator-llm-factory-qaxmyy46.js +71 -0
- package/dist/cli/{dispatch-tmb929w8.js → dispatch-8ks9dyk5.js} +244 -70
- package/dist/cli/{evidence-summary-service-74az43cb.js → evidence-summary-service-4s6cje60.js} +22 -22
- package/dist/cli/{explorer-zvk5kbcb.js → explorer-2cv64zfj.js} +1 -1
- package/dist/cli/{gate-evidence-f26h2gn3.js → gate-evidence-saja4dan.js} +11 -11
- package/dist/cli/guardrail-explain-z41q6sf0.js +72 -0
- package/dist/cli/{guardrail-log-pnye3xw8.js → guardrail-log-0h24spq0.js} +9 -9
- package/dist/cli/{guardrail-reset-0da7q8ap.js → guardrail-reset-cwbe47k5.js} +44 -44
- package/dist/cli/hive-promoter-esxtcvr1.js +86 -0
- package/dist/cli/{index-bv8ha57q.js → index-00zx94vn.js} +6 -6
- package/dist/cli/{index-9e6fdz2h.js → index-0mhftbpp.js} +1 -1
- package/dist/cli/{index-7qefgq4j.js → index-1xnse449.js} +11 -1
- package/dist/cli/{index-qyr17fbz.js → index-21ree67h.js} +62 -106
- package/dist/cli/{index-q265ytw6.js → index-30h1pk05.js} +4 -4
- package/dist/cli/{index-f8xk5q5j.js → index-3dywbkyr.js} +4 -4
- package/dist/cli/{index-2w0beg3s.js → index-4r5pmtvk.js} +5 -5
- package/dist/cli/{index-69y9p6dh.js → index-54w1564x.js} +2 -2
- package/dist/cli/{index-251vrmge.js → index-5zqakgp4.js} +4 -4
- package/dist/cli/{index-bzdc4b7t.js → index-64phnth4.js} +6 -6
- package/dist/cli/{index-fmzz6aw7.js → index-8f0kscpg.js} +4 -4
- package/dist/cli/{index-t8tw1bhs.js → index-8ybjqg51.js} +2 -2
- package/dist/cli/{index-9ss2m4rs.js → index-9br68j86.js} +1 -1
- package/dist/cli/{index-4rhhvd1a.js → index-a1w58b47.js} +1 -1
- package/dist/cli/{index-qd619x3r.js → index-a8xbvsse.js} +2 -2
- package/dist/cli/{index-mgc3c483.js → index-an8b5gda.js} +10 -10
- package/dist/cli/{index-9wv6a3jx.js → index-bvqqwx84.js} +2 -2
- package/dist/cli/{index-bf6zx8cq.js → index-cyenn3pf.js} +6 -2
- package/dist/cli/{index-8x4zwk0t.js → index-ddr97ram.js} +47 -47
- package/dist/cli/{index-3nm1b3t2.js → index-dfyv3xkd.js} +8 -8
- package/dist/cli/{index-87agfprq.js → index-exatbqwj.js} +13 -4
- package/dist/cli/{index-70ha9e09.js → index-fyfbpz4f.js} +1 -1
- package/dist/cli/{index-5bd84nxc.js → index-gp9yzr1v.js} +1 -1
- package/dist/cli/{index-es13aqdb.js → index-h0e2e3h1.js} +1 -1
- package/dist/cli/{index-6d4dc99f.js → index-h439y187.js} +1 -1
- package/dist/cli/{index-9bhzbwa4.js → index-j950hqmq.js} +9 -9
- package/dist/cli/{index-sahf5yz3.js → index-kear8gb7.js} +11 -6
- package/dist/cli/{index-qww0h314.js → index-m35hybf0.js} +1 -1
- package/dist/cli/{index-qtd3hrk8.js → index-mr0wn36f.js} +5 -5
- package/dist/cli/{index-zwsbegc1.js → index-nprngf8p.js} +7 -7
- package/dist/cli/{index-z5gdgdkp.js → index-nsyxj57e.js} +12 -12
- package/dist/cli/{index-1aex5zd9.js → index-nwwk3dej.js} +2 -2
- package/dist/cli/{index-75f9jj3h.js → index-pyf517sz.js} +2 -2
- package/dist/cli/{index-m3tx1q9v.js → index-qhey6vc3.js} +1 -1
- package/dist/cli/{index-qd726agw.js → index-qwsh0h2g.js} +3 -3
- package/dist/cli/{index-n4fzmqz8.js → index-rdm3px0g.js} +4 -2
- package/dist/cli/index-rxcgrgkc.js +116 -0
- package/dist/cli/{index-54vzqy47.js → index-s0d5xter.js} +6 -6
- package/dist/cli/{index-emwezg3y.js → index-seetnhpx.js} +3 -3
- package/dist/cli/{index-0tc0pcmh.js → index-sxt7fgcw.js} +38 -2
- package/dist/cli/{index-m21x1bkx.js → index-v3xc4sde.js} +11 -8
- package/dist/cli/{index-79wnzc8q.js → index-wnzxcr0z.js} +3 -3
- package/dist/cli/{index-rk10x4zr.js → index-wst6n478.js} +106 -6
- package/dist/cli/{index-hdsg7yf6.js → index-x7k3dps5.js} +4 -3
- package/dist/cli/{index-32bxwzw0.js → index-yevn4jpe.js} +92908 -90093
- package/dist/cli/index-yv76j77m.js +2008 -0
- package/dist/cli/{index-f6zgz02s.js → index-z6qreakh.js} +7 -7
- package/dist/cli/{index-eretcr6t.js → index-ze520xw1.js} +11 -11
- package/dist/cli/index.js +44 -44
- package/dist/cli/{knowledge-escalator-p2a8xh8x.js → knowledge-escalator-b2tf3sd1.js} +17 -17
- package/dist/cli/{knowledge-events-jmh28m8d.js → knowledge-events-bgs2kxe0.js} +15 -15
- package/dist/cli/{knowledge-link-w1fwqts4.js → knowledge-link-dr3xnwyd.js} +6 -6
- package/dist/cli/{knowledge-store-8gmabtsn.js → knowledge-store-stbmb1b9.js} +7 -7
- package/dist/cli/{knowledge-validator-yk579vs4.js → knowledge-validator-zykgnsag.js} +9 -9
- package/dist/cli/{model-preflight-b3b5pgsc.js → model-preflight-1ycat9jz.js} +1 -1
- package/dist/cli/{pending-delegations-nw7ph53z.js → pending-delegations-n5qavj20.js} +14 -14
- package/dist/cli/{pr-subscriptions-9815fxbc.js → pr-subscriptions-gnvmyrng.js} +14 -14
- package/dist/cli/{pr-workflow-gate-98a7b6py.js → pr-workflow-gate-cf3ybrws.js} +44 -44
- package/dist/cli/{runner-nmrjv7te.js → runner-k0ycgv8x.js} +7 -7
- package/dist/cli/{scan-cursor-6zcs0frg.js → scan-cursor-b3mcrx23.js} +10 -10
- package/dist/cli/{schema-warvhy9h.js → schema-08049cjb.js} +4 -2
- package/dist/cli/{scope-persistence-c2ck77cv.js → scope-persistence-a493gv51.js} +20 -20
- package/dist/cli/{skill-generator-jamm1cna.js → skill-generator-2qqzkdpv.js} +19 -19
- package/dist/cli/{snapshot-coordination-init-st0xsn3f.js → snapshot-coordination-init-8yt8p7q0.js} +44 -44
- package/dist/cli/{sqlite-loader-xrnf6bq8.js → sqlite-loader-amp9z7ty.js} +1 -1
- package/dist/cli/{telemetry-ce0tx41h.js → telemetry-2wzapf11.js} +2 -2
- package/dist/cli/{workspace-snapshot-0kxj2grt.js → workspace-snapshot-rkgxhj9b.js} +6 -6
- package/dist/cli/{worktree-collision-ownership-qra7r8pw.js → worktree-collision-ownership-xttafc4h.js} +17 -17
- package/dist/cli/{worktree-isolation-yr9gnf64.js → worktree-isolation-e5q5rewk.js} +45 -45
- package/dist/commands/close/align-stage.d.ts +10 -0
- package/dist/commands/close/archive-stage.d.ts +34 -0
- package/dist/commands/close/clean-stage.d.ts +2 -0
- package/dist/commands/close/constants.d.ts +122 -0
- package/dist/commands/close/context.d.ts +129 -0
- package/dist/commands/close/db-helpers.d.ts +10 -0
- package/dist/commands/close/dry-run.d.ts +12 -0
- package/dist/commands/close/finalize-stage.d.ts +44 -0
- package/dist/commands/close/fs-helpers.d.ts +17 -0
- package/dist/commands/close/internals.d.ts +55 -0
- package/dist/commands/close/orchestrator.d.ts +32 -0
- package/dist/commands/close/wiring.d.ts +2 -0
- package/dist/commands/close.d.ts +10 -402
- package/dist/commands/reset.d.ts +10 -0
- package/dist/commands/rollback.d.ts +9 -0
- package/dist/config/schema.d.ts +29 -0
- package/dist/db/project-db.d.ts +8 -0
- package/dist/db/sqlite-loader.d.ts +2 -1
- package/dist/dispatch/spawn-circuit.d.ts +121 -0
- package/dist/dispatch/token-bucket.d.ts +46 -0
- package/dist/hooks/delegation-gate/dead-lane-reclaim.d.ts +61 -0
- package/dist/hooks/delegation-gate/worktree-isolation.d.ts +22 -0
- package/dist/hooks/issue-trace.d.ts +3 -0
- package/dist/hooks/utils.d.ts +1 -1
- package/dist/index.js +811 -726
- package/dist/lang/dispatch.d.ts +6 -6
- package/dist/plan/ledger-sqlite.d.ts +226 -0
- package/dist/plan/ledger.d.ts +24 -0
- package/dist/plan/manager.d.ts +19 -0
- package/dist/retention/sweep.d.ts +2 -0
- package/dist/services/spec-drift-recovery.d.ts +2 -1
- package/dist/utils/canonical-root.d.ts +19 -0
- package/dist/utils/ephemeral-session-teardown.d.ts +55 -2
- package/opencode-swarm.schema.json +41 -0
- package/package.json +1 -1
- package/dist/cli/curator-llm-factory-zeb0pe2j.js +0 -71
- package/dist/cli/guardrail-explain-5vhveypz.js +0 -72
- package/dist/cli/hive-promoter-2vj54xc4.js +0 -86
- package/dist/cli/index-fenasyvr.js +0 -967
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export declare const NO_RECEIPT_PHASE_CLOSE_SCOPE_DETAIL = "no exact receipt lifecycle scope exists for phase closure";
|
|
2
|
+
export declare const CLOSE_SKILL_REVIEW_TIMEOUT_MS = 120000;
|
|
3
|
+
export declare const CLOSE_REFLECTION_TIMEOUT_MS = 90000;
|
|
4
|
+
/**
|
|
5
|
+
* Flat-file artifacts to include in the archive bundle.
|
|
6
|
+
* Each entry is a relative path under .swarm/.
|
|
7
|
+
*
|
|
8
|
+
* plan-ledger.jsonl is included so the archive bundle is a self-contained
|
|
9
|
+
* forensic snapshot of the session: the ledger holds the full audit trail of
|
|
10
|
+
* task state transitions and snapshot events that plan.json/plan.md don't
|
|
11
|
+
* preserve.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ARCHIVE_ARTIFACTS: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Active-state flat files to clean after archiving so future swarms start clean.
|
|
16
|
+
*
|
|
17
|
+
* plan.json, plan.md, and plan-ledger.jsonl are all removed so the next /swarm
|
|
18
|
+
* session starts with a clean slate. The user's original ask for /swarm close
|
|
19
|
+
* was to "archive plan files so future swarms aren't confused" — leaving a
|
|
20
|
+
* terminal-state plan.json in place violates that invariant because the next
|
|
21
|
+
* session's loadPlan() would pick it up as if it were still active.
|
|
22
|
+
*
|
|
23
|
+
* CRITICAL: the ledger must also be removed. Without this, loadPlan()'s Step 4
|
|
24
|
+
* would see no plan.json but a surviving ledger, call replayFromLedger(), and
|
|
25
|
+
* materialize the CLOSED plan back into plan.json on the next session. The
|
|
26
|
+
* ledger is a second backing store for the same "terminal-state plan" and
|
|
27
|
+
* leaving it behind re-enables the exact bug this cleanup is meant to fix.
|
|
28
|
+
* The archive-first guard below ensures we only delete files we successfully
|
|
29
|
+
* copied to the archive bundle, so the audit trail is preserved in the bundle.
|
|
30
|
+
*
|
|
31
|
+
* knowledge-rejected.jsonl, repo-graph.json, doc-manifest.json,
|
|
32
|
+
* dark-matter.md, telemetry.jsonl, and swarm.db are
|
|
33
|
+
* session-generated artifacts that do not persist meaningfully across sessions —
|
|
34
|
+
* they are recreated on next session init and must be removed to avoid stale-state
|
|
35
|
+
* interference.
|
|
36
|
+
*
|
|
37
|
+
* The SQLite WAL sidecars swarm.db-shm and swarm.db-wal are deliberately NOT in
|
|
38
|
+
* either list (the archive-first guard would preserve them anyway): since #2483
|
|
39
|
+
* they are removed immediately AFTER the swarm.db unlink by
|
|
40
|
+
* removeSqliteSidecarsAfterClose, deliberately reversing #1692. Post-unlink the
|
|
41
|
+
* sidecar paths are meaningless for future opens (no new opener can attach),
|
|
42
|
+
* live processes keep their already-open fds so deleting the PATH cannot
|
|
43
|
+
* corrupt them, and a Windows open-handle collision yields EBUSY which the
|
|
44
|
+
* helper skips fail-open.
|
|
45
|
+
*
|
|
46
|
+
* Note: knowledge.jsonl is intentionally NOT cleaned because it contains cumulative
|
|
47
|
+
* project knowledge (lessons learned) that should persist across sessions and finalize
|
|
48
|
+
* cycles. The archive step still creates a backup for safety.
|
|
49
|
+
* close-summary.md is NOT cleaned because it is written as the final close output
|
|
50
|
+
* AFTER the clean stage runs. spec.md IS cleaned: it is single-session state coupled
|
|
51
|
+
* to the plan lifecycle (the plan it produced is removed above), so leaving it behind
|
|
52
|
+
* makes the next session pick up a stale spec via readEffectiveSpecSync and mis-route
|
|
53
|
+
* the architect into CLARIFY-SPEC/overwrite prompts. It is archived first (archive-first
|
|
54
|
+
* guard), so the forensic copy is preserved in the bundle. The earlier "spec.md may not
|
|
55
|
+
* exist" rationale was wrong — handoff.md is equally optional and is cleaned the same way.
|
|
56
|
+
* session-reflection.md is a single-session snapshot (not cumulative like
|
|
57
|
+
* knowledge.jsonl) so it IS cleaned to maintain the clean-slate invariant.
|
|
58
|
+
* spec-staleness.json and spec-snapshot.md are the same class of single-session
|
|
59
|
+
* spec-drift state as spec.md. spec-staleness.json is an existence-only gate
|
|
60
|
+
* checked unconditionally by enforceSpecDriftGate, which hard-blocks the core
|
|
61
|
+
* write tools (save_plan, update_task_status, phase_complete,
|
|
62
|
+
* lean_turbo_run_phase, lean_turbo_acquire_locks) with SPEC_DRIFT_BLOCK — a
|
|
63
|
+
* survivor would block the NEXT session against drift that no longer applies.
|
|
64
|
+
* spec-snapshot.md is its companion diff source, feeding the mismatch shown in
|
|
65
|
+
* the SPEC_DRIFT_BLOCK message. Both are archived first (archive-first guard),
|
|
66
|
+
* then cleaned so the next session starts drift-free.
|
|
67
|
+
*/
|
|
68
|
+
export declare const ACTIVE_STATE_TO_CLEAN: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Terminal plan-state files that must be removed at finalize UNCONDITIONALLY — even
|
|
71
|
+
* when archiving them failed — so the next session cannot resurrect the CLOSED plan
|
|
72
|
+
* (loadPlan Step 1 / replayFromLedger have no terminal-status filter). Kept as a
|
|
73
|
+
* shared constant so the archive-failure diagnostics and the unconditional removal
|
|
74
|
+
* below agree on the set; otherwise the "Preserved …" warning would contradict the
|
|
75
|
+
* removal that always follows for these files.
|
|
76
|
+
*/
|
|
77
|
+
export declare const TERMINAL_STATE_FILES: readonly ["plan.json", "plan-ledger.jsonl", "spec-staleness.json", "spec-snapshot.md"];
|
|
78
|
+
/**
|
|
79
|
+
* Knowledge-family artifacts whose backing store redirects to a shared link
|
|
80
|
+
* directory when the worktree is linked (`.swarm/link.json`). A single
|
|
81
|
+
* worktree's `/swarm close` must NOT archive or delete the cohort-shared store —
|
|
82
|
+
* peers may still be active, and the shared store is durable with its own
|
|
83
|
+
* lifecycle (curation/hive-promotion already run on it, link-aware, during
|
|
84
|
+
* close). When the worktree is NOT linked these are handled normally (local).
|
|
85
|
+
*
|
|
86
|
+
* Scope: this set lists exactly the knowledge-family files that close otherwise
|
|
87
|
+
* archives/cleans — i.e. the intersection with `ARCHIVE_ARTIFACTS` /
|
|
88
|
+
* `ACTIVE_STATE_TO_CLEAN`. The other redirected files (retractions, counters,
|
|
89
|
+
* quarantine, unactionable, application, knowledge-events) appear in neither
|
|
90
|
+
* list, so close never touches them and they need no guard here. Note the two
|
|
91
|
+
* stages cover different members: the archive-stage guard fires for both
|
|
92
|
+
* `knowledge.jsonl` and `knowledge-rejected.jsonl` (both in `ARCHIVE_ARTIFACTS`),
|
|
93
|
+
* while the clean-stage guard is only reachable for `knowledge-rejected.jsonl`
|
|
94
|
+
* (`ACTIVE_STATE_TO_CLEAN` has no `knowledge.jsonl`).
|
|
95
|
+
*/
|
|
96
|
+
export declare const KNOWLEDGE_FAMILY_ARTIFACTS: Set<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Artifacts whose absence is a genuine state anomaly (vs the normal "optional,
|
|
99
|
+
* session-generated, may simply not exist" case). `plan.json`/`plan-ledger.jsonl`
|
|
100
|
+
* back the authoritative plan state (plan-durability invariant 5); their
|
|
101
|
+
* absence in a plan-based session warrants a warning. All other artifacts —
|
|
102
|
+
* including `swarm.db`, which `getProjectDb` creates lazily only when a
|
|
103
|
+
* DB-backed tool actually runs — are optional: a fresh or plan-free session
|
|
104
|
+
* legitimately has none of them, and an absent optional artifact is reported
|
|
105
|
+
* as `source_disposition: 'absent'`, NOT as a failure (issue #2030 item 7).
|
|
106
|
+
*/
|
|
107
|
+
export declare const REQUIRED_ARTIFACTS: Set<string>;
|
|
108
|
+
/**
|
|
109
|
+
* Active-state directories to archive and clean after archiving.
|
|
110
|
+
* These contain session-generated data that must be removed so future
|
|
111
|
+
* swarms start clean. Each entry is a relative path under .swarm/.
|
|
112
|
+
*/
|
|
113
|
+
export declare const ACTIVE_STATE_DIRS_TO_CLEAN: string[];
|
|
114
|
+
/**
|
|
115
|
+
* STAGE 3: CLEAN
|
|
116
|
+
*
|
|
117
|
+
* Removes active-state files and directories that were successfully archived
|
|
118
|
+
* (archive-first guard), plus stale config-backup/ledger-sibling/SWARM_PLAN/.tmp
|
|
119
|
+
* artifacts. Resets context.md for the next session. All state mutations are
|
|
120
|
+
* written back to ctx so the caller can build the close summary.
|
|
121
|
+
*/
|
|
122
|
+
export declare const ACTIVE_STATE_UNLINK_RETRY_DELAYS_MS: readonly [25, 50, 100, 200];
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { KnowledgeConfig, PluginConfig } from '../../config/schema';
|
|
2
|
+
import type { SessionReflectionResult } from '../../services/session-reflection';
|
|
3
|
+
import type { SqliteRowCounts } from '../archive-sqlite';
|
|
4
|
+
export interface PlanPhase {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
status: string;
|
|
8
|
+
tasks: Array<{
|
|
9
|
+
id: string;
|
|
10
|
+
status: string;
|
|
11
|
+
close_reason?: string;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
export interface PlanData {
|
|
15
|
+
title: string;
|
|
16
|
+
phases: PlanPhase[];
|
|
17
|
+
}
|
|
18
|
+
export interface CloseCommandOptions {
|
|
19
|
+
sessionID?: string;
|
|
20
|
+
skillReviewTimeoutMs?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CurationCounts {
|
|
23
|
+
stored: number;
|
|
24
|
+
/** Issue #2077: surfaced for the reflection knowledge-delta report. */
|
|
25
|
+
reinforced: number;
|
|
26
|
+
skipped: number;
|
|
27
|
+
rejected: number;
|
|
28
|
+
quarantined: number;
|
|
29
|
+
}
|
|
30
|
+
export interface CloseKnowledgeEntry {
|
|
31
|
+
created_at?: string;
|
|
32
|
+
}
|
|
33
|
+
export type ArchiveRequiredness = 'required' | 'optional';
|
|
34
|
+
export type ArchiveAttempt = 'not_attempted' | 'succeeded' | 'failed';
|
|
35
|
+
export type ArchiveValidation = 'not_applicable' | 'passed' | 'failed';
|
|
36
|
+
export type ArchiveSourceDisposition = 'absent' | 'retained' | 'removed';
|
|
37
|
+
export interface ArtifactArchiveResult {
|
|
38
|
+
artifact: string;
|
|
39
|
+
requiredness: ArchiveRequiredness;
|
|
40
|
+
attempt: ArchiveAttempt;
|
|
41
|
+
validation: ArchiveValidation;
|
|
42
|
+
source_disposition: ArchiveSourceDisposition;
|
|
43
|
+
method: string;
|
|
44
|
+
reason_code: string;
|
|
45
|
+
/** Counts only (no row content), present for validated sqlite snapshots. */
|
|
46
|
+
row_counts?: SqliteRowCounts;
|
|
47
|
+
/** Non-sensitive diagnostic. */
|
|
48
|
+
detail?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ArchiveStageContext {
|
|
51
|
+
directory: string;
|
|
52
|
+
swarmDir: string;
|
|
53
|
+
config: PluginConfig;
|
|
54
|
+
warnings: string[];
|
|
55
|
+
}
|
|
56
|
+
export interface CloseStageContext {
|
|
57
|
+
directory: string;
|
|
58
|
+
swarmDir: string;
|
|
59
|
+
planData: PlanData;
|
|
60
|
+
planExists: boolean;
|
|
61
|
+
planAlreadyDone: boolean;
|
|
62
|
+
config: KnowledgeConfig;
|
|
63
|
+
projectName: string;
|
|
64
|
+
warnings: string[];
|
|
65
|
+
closedPhases: number[];
|
|
66
|
+
closedTasks: string[];
|
|
67
|
+
sessionStart: string | undefined;
|
|
68
|
+
isForced: boolean;
|
|
69
|
+
runSkillReview: boolean;
|
|
70
|
+
options: CloseCommandOptions;
|
|
71
|
+
phases: PlanPhase[];
|
|
72
|
+
inProgressPhases: PlanPhase[];
|
|
73
|
+
curationSucceeded: boolean;
|
|
74
|
+
curationResult: CurationCounts | undefined;
|
|
75
|
+
allLessons: string[];
|
|
76
|
+
explicitLessons: string[];
|
|
77
|
+
retroLessons: string[];
|
|
78
|
+
knowledgeSkillHint: string;
|
|
79
|
+
skillReviewSummary: string;
|
|
80
|
+
postMortemSummary: string;
|
|
81
|
+
sessionReflection: SessionReflectionResult | undefined;
|
|
82
|
+
hivePromoted: number;
|
|
83
|
+
sessionKnowledgeCreated: number;
|
|
84
|
+
fallbackKnowledgeCreated: number;
|
|
85
|
+
/** Issue #2077: FR-015 dedup drop count (retro lessons dropped as already-known). */
|
|
86
|
+
dedupDropped: number;
|
|
87
|
+
/** Issue #2077: false when the dedup knowledge read failed (fail-open). */
|
|
88
|
+
dedupAvailable: boolean;
|
|
89
|
+
/** Issue #2077: total retro lessons before dedup. */
|
|
90
|
+
retroLessonTotal: number;
|
|
91
|
+
/** Issue #2077: full-auto state computed once, reused at reflection + menu render. */
|
|
92
|
+
fullAuto: boolean;
|
|
93
|
+
originalStatuses: Map<string, string>;
|
|
94
|
+
guaranteeResult: {
|
|
95
|
+
closedPhaseIds: number[];
|
|
96
|
+
closedTaskIds: string[];
|
|
97
|
+
};
|
|
98
|
+
terminalizationError?: string;
|
|
99
|
+
archiveResult: string;
|
|
100
|
+
archivedFileCount: number;
|
|
101
|
+
archivedActiveStateFiles: Set<string>;
|
|
102
|
+
archivedActiveStateDirs: Set<string>;
|
|
103
|
+
archiveFailureReasons: Map<string, string>;
|
|
104
|
+
/** Structured per-artifact results — single source of truth (issue #2030). */
|
|
105
|
+
archiveResults: ArtifactArchiveResult[];
|
|
106
|
+
/** True when the archive STAGE threw wholesale (e.g. mkdir EACCES/ENOSPC). */
|
|
107
|
+
archiveStageFailed: boolean;
|
|
108
|
+
timestamp: string;
|
|
109
|
+
archiveDir: string;
|
|
110
|
+
archiveSuffix: string;
|
|
111
|
+
args: string[];
|
|
112
|
+
}
|
|
113
|
+
export interface GitAlignResult {
|
|
114
|
+
gitAlignResult: string;
|
|
115
|
+
prunedBranches: string[];
|
|
116
|
+
}
|
|
117
|
+
export interface CleanStageResult {
|
|
118
|
+
cleanedFiles: string[];
|
|
119
|
+
configBackupsRemoved: number;
|
|
120
|
+
swarmPlanFilesRemoved: number;
|
|
121
|
+
/**
|
|
122
|
+
* Stale atomic-write temp files MOVED into `.swarm/quarantine/<batch>/`
|
|
123
|
+
* (issue #2035). Quarantine is a recoverable move with a manifest — the
|
|
124
|
+
* pre-#2035 blind `.tmp.*` unlink sweep is gone; preserved candidates
|
|
125
|
+
* (recent/active/tracked/ambiguous) are counted in `residuePreserved`.
|
|
126
|
+
*/
|
|
127
|
+
residueQuarantined: number;
|
|
128
|
+
residuePreserved: number;
|
|
129
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove the SQLite WAL sidecars (swarm.db-wal / swarm.db-shm) immediately
|
|
3
|
+
* after the clean stage unlinks swarm.db (#2483, deliberately reversing the
|
|
4
|
+
* #1692 preserve decision): once the main db is unlinked the sidecar paths
|
|
5
|
+
* are meaningless for future opens — no new opener can attach — and live
|
|
6
|
+
* processes keep their already-open fds, so deleting the PATH cannot corrupt
|
|
7
|
+
* them. Best-effort and per-file fail-open: ENOENT (already gone) and EBUSY
|
|
8
|
+
* (Windows open-handle collision) are skipped silently.
|
|
9
|
+
*/
|
|
10
|
+
export declare function removeSqliteSidecarsAfterClose(swarmDir: string): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PlanData } from './context.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds the `/swarm finalize --dry-run` report. Purely READ-ONLY: inspects the
|
|
4
|
+
* plan and the filesystem and describes what a real finalize WOULD do, without
|
|
5
|
+
* acquiring the finalize lock, creating an archive bundle, deleting any file,
|
|
6
|
+
* running git, or tearing down session state. (#1692)
|
|
7
|
+
*
|
|
8
|
+
* The archive-first guard means the clean stage only removes files it first
|
|
9
|
+
* archived successfully; this report approximates that by listing existing
|
|
10
|
+
* clean-set members as "would remove" and notes the approximation.
|
|
11
|
+
*/
|
|
12
|
+
export declare function runFinalizeDryRun(directory: string, swarmDir: string, planData: PlanData, planExists: boolean): Promise<string>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Plan } from '../../config/plan-schema';
|
|
2
|
+
import { runSessionReflection } from '../../services/session-reflection';
|
|
3
|
+
import { type SkillImproveRequest, type SkillImproveResult } from '../../services/skill-improver';
|
|
4
|
+
import { type CloseTerminalResult } from '../../workflow/close-terminal.js';
|
|
5
|
+
import type { CloseKnowledgeEntry, CloseStageContext, PlanData } from './context.js';
|
|
6
|
+
/**
|
|
7
|
+
* Close-command wrapper around the exact-task terminal reconciliation service.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately NOT named `closePlanTerminalState`: `src/plan/manager.ts` exports a
|
|
10
|
+
* distinct function by that name (ledger-first phase/projection persistence), which
|
|
11
|
+
* `reconcileCloseTerminalState` itself calls downstream. Keeping the two identifiers
|
|
12
|
+
* distinct avoids a same-name collision across close.ts / close-terminal.ts /
|
|
13
|
+
* plan/manager.ts. The `_internals` key below stays `closePlanTerminalState` so the
|
|
14
|
+
* existing test seam is unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export declare function reconcileCloseTerminalStateForPlan(directory: string, targetPlan: Plan, options: {
|
|
17
|
+
actor: string;
|
|
18
|
+
requestedClosedTaskIds: string[];
|
|
19
|
+
closedPhaseIds: number[];
|
|
20
|
+
originalStatuses?: Map<string, string>;
|
|
21
|
+
}): Promise<CloseTerminalResult | undefined>;
|
|
22
|
+
export declare function hardStopTerminalization(ctx: CloseStageContext, message: string): void;
|
|
23
|
+
export declare function runAbortableReflection(input: Parameters<typeof runSessionReflection>[0], timeoutMs: number): Promise<Awaited<ReturnType<typeof runSessionReflection>>>;
|
|
24
|
+
export declare function runAbortableSkillReview(req: SkillImproveRequest, timeoutMs: number): Promise<SkillImproveResult>;
|
|
25
|
+
export declare function normalizeLessonText(text: string): string;
|
|
26
|
+
export declare function countSessionKnowledgeEntries(entries: CloseKnowledgeEntry[], sessionStart: string | undefined, fallbackCount: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Guarantee all phases and tasks in a plan are marked complete/closed.
|
|
29
|
+
* Mutates planData in place. Returns actual IDs of newly closed phases and
|
|
30
|
+
* tasks so the caller can track only genuinely new closures (idempotent).
|
|
31
|
+
*/
|
|
32
|
+
export declare function guaranteeAllPlansComplete(planData: PlanData): {
|
|
33
|
+
closedPhaseIds: number[];
|
|
34
|
+
closedTaskIds: string[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* STAGE 1: FINALIZE
|
|
38
|
+
*
|
|
39
|
+
* Writes retrospectives for in-progress phases (or a session-level retro for
|
|
40
|
+
* plan-free closes), curates lessons, promotes to hive, runs skill review,
|
|
41
|
+
* persists terminal plan state, and runs post-mortem. All state mutations are
|
|
42
|
+
* written back to ctx so the caller can build the close summary.
|
|
43
|
+
*/
|
|
44
|
+
export declare function runFinalizeStage(ctx: CloseStageContext): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function copyDirRecursiveWithFailures(src: string, dest: string): Promise<{
|
|
2
|
+
copied: number;
|
|
3
|
+
failures: string[];
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* Backward-compatible wrapper that returns only the copied count.
|
|
7
|
+
* Direct callers (including tests) that expect a number continue to work.
|
|
8
|
+
* Use copyDirRecursiveWithFailures when per-file failure tracking is needed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function copyDirRecursive(src: string, dest: string): Promise<number>;
|
|
11
|
+
/**
|
|
12
|
+
* Delete one archived active-state artifact, tolerating the short-lived file
|
|
13
|
+
* locks Windows antivirus and SQLite sidecars can retain after handle close.
|
|
14
|
+
* Non-transient errors fail immediately; the retry budget is bounded to
|
|
15
|
+
* 375 ms so `/swarm close` remains responsive.
|
|
16
|
+
*/
|
|
17
|
+
export declare function unlinkActiveStateFileWithRetry(filePath: string): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as fsSync from 'node:fs';
|
|
2
|
+
/** Narrow seam for receipt/plan ordering tests. Wired by the close facade. */
|
|
3
|
+
export declare const closeReceiptLifecycleInternals: {
|
|
4
|
+
recordPhaseCloseIntent: typeof import("../../hooks/knowledge-receipt-ledger.js").recordPhaseCloseIntent;
|
|
5
|
+
reconcilePhaseClose: typeof import("../../hooks/knowledge-receipt-ledger.js").reconcilePhaseClose;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Canonical mutable close-command dependency seam.
|
|
9
|
+
*
|
|
10
|
+
* This module intentionally has no imports from the command, agent, state, or
|
|
11
|
+
* hook graphs. The facade wires concrete implementations after all stage
|
|
12
|
+
* modules have initialized, so a direct stage import cannot re-enter close.ts
|
|
13
|
+
* through the command registry (FB-005/FB-006).
|
|
14
|
+
*/
|
|
15
|
+
export declare const _internals: {
|
|
16
|
+
closeSnapshotCoordinationInitialization: typeof import("../../session/snapshot-coordination-init.js").closeSnapshotCoordinationInitialization;
|
|
17
|
+
closeRepoMemory: typeof import("../../tools/repo-graph/indexed-storage.js").closeRepoMemory;
|
|
18
|
+
unlinkActiveStateFileWithRetry: typeof import("./fs-helpers.js").unlinkActiveStateFileWithRetry;
|
|
19
|
+
unlink: typeof fsSync.promises.unlink;
|
|
20
|
+
unlinkSidecarSync: typeof fsSync.unlinkSync;
|
|
21
|
+
sleep: typeof import("../../utils/bun-compat.js").sleep;
|
|
22
|
+
collectGarbageBestEffort: typeof import("../../utils/bun-compat.js").collectGarbageBestEffort;
|
|
23
|
+
ACTIVE_STATE_DIRS_TO_CLEAN: string[];
|
|
24
|
+
countSessionKnowledgeEntries: typeof import("./finalize-stage.js").countSessionKnowledgeEntries;
|
|
25
|
+
CLOSE_SKILL_REVIEW_TIMEOUT_MS: number;
|
|
26
|
+
CLOSE_REFLECTION_TIMEOUT_MS: number;
|
|
27
|
+
detectFullAuto: typeof import("./orchestrator.js").detectFullAuto;
|
|
28
|
+
guaranteeAllPlansComplete: typeof import("./finalize-stage.js").guaranteeAllPlansComplete;
|
|
29
|
+
getGitRepositoryStatus: typeof import("../../git/branch.js").getGitRepositoryStatus;
|
|
30
|
+
resetToMainAfterMerge: typeof import("../../git/branch.js").resetToMainAfterMerge;
|
|
31
|
+
resetToRemoteBranch: typeof import("../../git/branch.js").resetToRemoteBranch;
|
|
32
|
+
copyDirRecursive: typeof import("./fs-helpers.js").copyDirRecursive;
|
|
33
|
+
loadPluginConfigWithMeta: typeof import("../../config/index.js").loadPluginConfigWithMeta;
|
|
34
|
+
curateAndStoreSwarm: typeof import("../../hooks/knowledge-curator.js").curateAndStoreSwarm;
|
|
35
|
+
checkHivePromotions: typeof import("../../hooks/hive-promoter.js").checkHivePromotions;
|
|
36
|
+
runCuratorPostMortem: typeof import("../../hooks/curator-postmortem.js").runCuratorPostMortem;
|
|
37
|
+
createCuratorLLMDelegate: typeof import("../../hooks/curator-llm-factory.js").createCuratorLLMDelegate;
|
|
38
|
+
resetSwarmStatePreservingSingletons: typeof import("../../state.js").resetSwarmStatePreservingSingletons;
|
|
39
|
+
runFinalizeStage: typeof import("./finalize-stage.js").runFinalizeStage;
|
|
40
|
+
runFinalizeRewardSweep: typeof import("../../memory/finalize-reward-sweep.js").runFinalizeRewardSweep;
|
|
41
|
+
acquireFinalizeLock: typeof import("./orchestrator.js").acquireFinalizeLock;
|
|
42
|
+
runArchiveStage: typeof import("./archive-stage.js").runArchiveStage;
|
|
43
|
+
archiveCloseSummary: typeof import("./orchestrator.js").archiveCloseSummary;
|
|
44
|
+
runArchiveEvidenceRetention: typeof import("./archive-stage.js").runArchiveEvidenceRetention;
|
|
45
|
+
runCleanStage: typeof import("./clean-stage.js").runCleanStage;
|
|
46
|
+
runAlignStage: typeof import("./align-stage.js").runAlignStage;
|
|
47
|
+
runFinalizeDryRun: typeof import("./dry-run.js").runFinalizeDryRun;
|
|
48
|
+
archiveEvidence: typeof import("../../evidence/manager.js").archiveEvidence;
|
|
49
|
+
closePlanTerminalState: typeof import("./finalize-stage.js").reconcileCloseTerminalStateForPlan;
|
|
50
|
+
endAgentSession: typeof import("../../state.js").endAgentSession;
|
|
51
|
+
flushAndDrainTelemetry: () => Promise<void>;
|
|
52
|
+
finalizeContextTelemetry: typeof import("../../context-map/telemetry.js").finalizeContextTelemetry;
|
|
53
|
+
finalizeCoreEvents: typeof import("../../events/core-events.js").finalizeCoreEventsForClose;
|
|
54
|
+
finalizeShellAudit: (directory: string) => void;
|
|
55
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CloseCommandOptions, CloseStageContext } from './context.js';
|
|
2
|
+
export declare function archiveCloseSummary(ctx: Pick<CloseStageContext, 'archiveStageFailed' | 'archiveDir' | 'warnings'>, closeSummaryPath: string, summaryWritten: boolean): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* Handles /swarm close command - performs full terminal session finalization:
|
|
5
|
+
* 0. Guarantee: mark all incomplete phases/tasks as closed
|
|
6
|
+
* 1. Finalize: write retrospectives, produce terminal summary
|
|
7
|
+
* 2. Archive: create timestamped bundle of swarm artifacts
|
|
8
|
+
* 3. Clean: clear active-state files that confuse future swarms
|
|
9
|
+
* 4. Align: safe git alignment to main
|
|
10
|
+
*
|
|
11
|
+
* Must be idempotent - safe to run multiple times.
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleCloseCommand(directory: string, args: string[], options?: CloseCommandOptions): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Acquire the finalize lock for the close command (FR-012).
|
|
16
|
+
* Wraps tryAcquireLock with a directory-only API.
|
|
17
|
+
*/
|
|
18
|
+
export declare function acquireFinalizeLock(directory: string): Promise<{
|
|
19
|
+
acquired: boolean;
|
|
20
|
+
release?: () => Promise<void>;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Issue #2077: detect full-auto state for the action-menu prompt suppression.
|
|
24
|
+
* Combines the in-memory session flag (hasActiveFullAuto) with the durable
|
|
25
|
+
* run state (isFullAutoRunActive reads .swarm/full-auto-state.json) so a
|
|
26
|
+
* process restart mid-run does not silently re-enable the interactive menu
|
|
27
|
+
* prompt. The durable check is sync and takes a state lock; if it throws,
|
|
28
|
+
* fall back to the in-memory flag alone. Caller MUST guard with a defined
|
|
29
|
+
* sessionID to avoid the cross-session leak (hasActiveFullAuto(undefined)
|
|
30
|
+
* scans all sessions).
|
|
31
|
+
*/
|
|
32
|
+
export declare function detectFullAuto(directory: string, sessionID: string): boolean;
|