opencode-swarm 6.47.1 → 6.48.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/README.md CHANGED
@@ -840,7 +840,7 @@ To disable entirely, set `context_budget.enabled: false` in your swarm config.
840
840
  | incremental_verify | Post-coder typecheck for TS/JS, Go, Rust, C# (v6.29.2) |
841
841
  | quality_budget | Enforces complexity, duplication, and test ratio limits |
842
842
  | pre_check_batch | Runs lint, secretscan, SAST, and quality budget in parallel (~15s vs ~60s sequential) |
843
- | phase_complete | Enforces phase completion, verifies required agents, requires a valid retrospective evidence bundle, logs events, and resets state |
843
+ | phase_complete | Enforces phase completion, verifies required agents, requires a valid retrospective evidence bundle, logs events, and resets state; appends to `events.jsonl` with file locking |
844
844
 
845
845
 
846
846
  All tools run locally. No Docker, no network calls, no external APIs.
@@ -866,6 +866,61 @@ Optional enhancement: Semgrep (if on PATH).
866
866
 
867
867
  </details>
868
868
 
869
+ <details>
870
+ <summary><strong>File Locking for Concurrent Write Safety</strong></summary>
871
+
872
+ Swarm uses file locking to protect shared state files from concurrent write corruption. The locking strategy differs by file: `plan.json` uses hard locking (write blocked on contention), while `events.jsonl` uses advisory locking (write proceeds with a warning on contention).
873
+
874
+ ### Locking Implementation
875
+
876
+ - **Library**: `proper-lockfile` with `retries: 0` (fail-fast — no polling retries)
877
+ - **Scope**: Each tool acquires an exclusive lock on the target file before writing
878
+ - **Agents**: Lock is tagged with the current agent name and task context for diagnostics
879
+
880
+ ### Protected Files
881
+
882
+ | File | Tool | Lock Key |
883
+ |------|------|----------|
884
+ | `.swarm/plan.json` | `update_task_status` | `plan.json` |
885
+ | `.swarm/events.jsonl` | `phase_complete` | `events.jsonl` |
886
+
887
+ ### Lock Semantics
888
+
889
+ The two protected tools use different strategies:
890
+
891
+ **`update_task_status` — Hard lock on `plan.json`**
892
+
893
+ When two calls contend for `plan.json`:
894
+ 1. **Exactly one call wins** — only the first to acquire the lock proceeds
895
+ 2. **Winner writes** — the lock holder writes to the file, then releases the lock
896
+ 3. **Losers receive `success: false`** — with `recovery_guidance: "retry"` and an error message identifying the lock holder
897
+
898
+ ```json
899
+ {
900
+ "success": false,
901
+ "message": "Task status write blocked: plan.json is locked by architect (task: update-task-status-1.1-1234567890)",
902
+ "errors": ["Concurrent plan write detected — retry after the current write completes"],
903
+ "recovery_guidance": "Wait a moment and retry update_task_status. The lock will expire automatically if the holding agent fails."
904
+ }
905
+ ```
906
+
907
+ **What the caller should do**: Retry `update_task_status` after a short delay.
908
+
909
+ **`phase_complete` — Advisory lock on `events.jsonl`**
910
+
911
+ When two calls contend for `events.jsonl`:
912
+ 1. **Lock is attempted** — if acquired, write is serialized
913
+ 2. **If lock unavailable** — a warning is added to the result and the write proceeds anyway
914
+ 3. **Both callers return `success: true`** — duplicate concurrent appends are possible but `events.jsonl` is an append-only log and duplicate phase entries do not corrupt state
915
+
916
+ This asymmetry is intentional: `plan.json` stores mutable structured JSON where concurrent overwrites produce malformed files; `events.jsonl` is an append-only log where a duplicate entry is a recoverable nuisance.
917
+
918
+ ### Lock Recovery
919
+
920
+ If a lock-holding agent crashes or hangs, the lock file will eventually expire (handled by `proper-lockfile` stale-lock cleanup). On the next retry, the call will succeed. Swarm does not auto-retry on lock contention — the architect receives the error and decides when to retry.
921
+
922
+ </details>
923
+
869
924
  <details>
870
925
  <summary id="configuration-reference"><strong>Full Configuration Reference</strong></summary>
871
926
 
@@ -1066,6 +1121,7 @@ Control how tool outputs are summarized for LLM context.
1066
1121
  | `/swarm reset --confirm` | Clear swarm state files |
1067
1122
  | `/swarm preflight` | Run phase preflight checks |
1068
1123
  | `/swarm config doctor [--fix]` | Config validation with optional auto-fix |
1124
+ | `/swarm doctor tools` | Tool registration coherence and binary readiness check |
1069
1125
  | `/swarm sync-plan` | Force plan.md regeneration from plan.json |
1070
1126
  | `/swarm specify [description]` | Generate or import a feature specification |
1071
1127
  | `/swarm clarify [topic]` | Clarify and refine an existing feature specification |
@@ -1160,7 +1216,7 @@ The following tools can be assigned to agents via overrides:
1160
1216
  | `gitingest` | Ingest external repositories |
1161
1217
  | `imports` | Analyze import relationships |
1162
1218
  | `lint` | Run project linters |
1163
- | `phase_complete` | Enforces phase completion, verifies required agents, logs events, resets state |
1219
+ | `phase_complete` | Enforces phase completion, verifies required agents, logs events, resets state; appends to `events.jsonl` with file locking |
1164
1220
  | `pkg_audit` | Security audit of dependencies |
1165
1221
  | `pre_check_batch` | Parallel pre-checks (lint, secrets, SAST, quality) |
1166
1222
  | `retrieve_summary` | Retrieve summarized tool outputs |
@@ -1168,7 +1224,7 @@ The following tools can be assigned to agents via overrides:
1168
1224
  | `secretscan` | Scan for secrets in code |
1169
1225
  | `symbols` | Extract exported symbols |
1170
1226
  | `test_runner` | Run project tests |
1171
- | `update_task_status` | Mark plan tasks as pending/in_progress/completed/blocked; track phase progress |
1227
+ | `update_task_status` | Mark plan tasks as pending/in_progress/completed/blocked; track phase progress; acquires lock on `plan.json` before writing |
1172
1228
  | `todo_extract` | Extract TODO/FIXME comments |
1173
1229
  | `write_retro` | Document phase retrospectives via the phase_complete workflow; capture lessons learned |
1174
1230
  | `write_drift_evidence` | Write drift verification evidence after critic_drift_verifier completes |