opencode-swarm 6.20.3 → 6.21.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
@@ -370,6 +370,17 @@ Every agent runs inside a circuit breaker that kills runaway behavior before it
370
370
 
371
371
  Limits reset per task. A coder working on Task 2.3 is not penalized for tool calls made during Task 2.2.
372
372
 
373
+ #### Architect Self-Coding Block
374
+
375
+ If the architect writes files directly instead of delegating to the coder, a hard block fires:
376
+
377
+ | Write count | Behavior |
378
+ |:-----------:|----------|
379
+ | 1–2 | Warning injected into next architect message |
380
+ | ≥ 3 | `Error` thrown with `SELF_CODING_BLOCK` — identifies file paths written and count |
381
+
382
+ The counter resets only when a coder delegation is dispatched. This is a hard enforcement — not advisory.
383
+
373
384
  Per-agent overrides:
374
385
 
375
386
  ```json
@@ -727,7 +738,7 @@ Swarm limits which tools each agent can access based on their role. This prevent
727
738
 
728
739
  | Agent | Tools | Count | Rationale |
729
740
  |-------|-------|:---:|-----------|
730
- | **architect** | All 17 tools | 17 | Orchestrator needs full visibility |
741
+ | **architect** | All 21 tools | 21 | Orchestrator needs full visibility |
731
742
  | **reviewer** | diff, imports, lint, pkg_audit, pre_check_batch, secretscan, symbols, complexity_hotspots, retrieve_summary, extract_code_blocks, test_runner | 11 | Security-focused QA |
732
743
  | **coder** | diff, imports, lint, symbols, extract_code_blocks, retrieve_summary | 6 | Write-focused, minimal read tools |
733
744
  | **test_engineer** | test_runner, diff, symbols, extract_code_blocks, retrieve_summary, imports, complexity_hotspots, pkg_audit | 8 | Testing and verification |
@@ -811,11 +822,62 @@ The following tools can be assigned to agents via overrides:
811
822
  | `todo_extract` | Extract TODO/FIXME comments |
812
823
  | `write_retro` | Document phase retrospectives via the phase_complete workflow; capture lessons learned |
813
824
  | `phase_complete` | Enforces phase completion, verifies required agents, logs events, resets state |
825
+ | `declare_scope` | Pre-declare the file scope for the next coder delegation (architect-only); violations trigger warnings |
814
826
 
815
827
  ---
816
828
 
817
829
  ## Recent Changes
818
830
 
831
+ ### v6.21 — Gate Enforcement Hardening
832
+
833
+ This release replaces soft advisory warnings with hard runtime blocks and adds structural compliance tooling for all model tiers.
834
+
835
+ #### Phase 1 — P0 Bug Fixes: Hard Blocks Replace Soft Warnings
836
+
837
+ - **`qaSkipCount` reset fixed**: The skip-detection counter in `delegation-gate.ts` now resets only when **both** reviewer **and** test_engineer have been seen since the last coder entry — not when either one runs alone.
838
+ - **`update_task_status` reviewer gate check**: Accepting `status='completed'` now validates that the reviewer gate is present in the session's `gateLog` for the given task. Missing reviewer returns a structured error naming the absent gate.
839
+ - **Architect self-coding hard block**: `architectWriteCount ≥ 3` now throws an `Error` with message `SELF_CODING_BLOCK` (previously a warning only). Counts 1–2 remain advisory warnings. Counter resets on coder delegation.
840
+
841
+ #### Phase 2 — Per-Task State Machine
842
+
843
+ Every task now has a tracked workflow state in the session:
844
+
845
+ | State | Meaning |
846
+ |-------|---------|
847
+ | `idle` | Task not started |
848
+ | `coder_delegated` | Coder has received the delegation |
849
+ | `pre_check_passed` | Automated gates (lint, SAST, secrets, quality) passed |
850
+ | `reviewer_run` | Reviewer agent has returned a verdict |
851
+ | `tests_run` | Test engineer has completed (verification + adversarial) |
852
+ | `complete` | `update_task_status` accepted the `completed` transition |
853
+
854
+ Transitions are forward-only. `advanceTaskState()` throws `INVALID_TASK_STATE_TRANSITION` if an illegal jump is attempted. `getTaskState()` returns `'idle'` for unknown tasks.
855
+
856
+ `session.lastGateOutcome` records the most recent gate result: `{ gate, taskId, passed, timestamp }`.
857
+
858
+ #### Phase 3 — State Machine Integration
859
+
860
+ - `update_task_status` now uses the state machine (not a raw `gateLog.has()` check): `status='completed'` is rejected unless the task is in `'tests_run'` or `'complete'` state.
861
+ - `delegation-gate.ts` protocol-violation check additionally verifies that the prior task's state has advanced past `'coder_delegated'` before allowing a new coder delegation.
862
+
863
+ #### Phase 4 — Context Engineering
864
+
865
+ - **Progressive task disclosure**: When >5 tasks are visible in the last user message, `delegation-gate.ts` trims to the current task ± a context window. A `[Task window: showing N of M tasks]` comment marks the trim point.
866
+ - **Deliberation preamble**: Each architect turn is prefixed with `[Last gate: {tool} {result} for task {taskId}]` sourced from `session.lastGateOutcome`, prompting the architect to identify the single next step.
867
+ - **Low-capability model detection**: `LOW_CAPABILITY_MODELS` constant (matches substrings `mini`, `nano`, `small`, `free`) and `isLowCapabilityModel(modelId)` helper added to `constants.ts`.
868
+ - **Behavioral guidance markers**: Three `<!-- BEHAVIORAL_GUIDANCE_START --> … <!-- BEHAVIORAL_GUIDANCE_END -->` pairs wrap the BATCHING DETECTION, ARCHITECT CODING BOUNDARIES, and QA gate behavioral sections in the architect prompt.
869
+ - **Tier-based prompt trimming**: When `session.activeModel` matches `isLowCapabilityModel()`, the behavioral guidance blocks are stripped from the architect prompt and replaced with `[Enforcement: programmatic gates active]`. Programmatic enforcement substitutes for verbose prompt instructions on smaller models.
870
+
871
+ #### Phase 5 — Structural Scope Declaration (`declare_scope`)
872
+
873
+ New architect-only tool and supporting runtime enforcement:
874
+
875
+ - **`declare_scope` tool**: Pre-declares which files the coder is allowed to modify for a given task. Input: `{ taskId, files, whitelist?, working_directory? }`. Validates task ID format, plan membership, and non-`complete` state. On success, sets `session.declaredCoderScope`. Architect-only.
876
+ - **Automatic scope from FILE: directives**: When a coder delegation is detected, `delegation-gate.ts` extracts FILE: directive values and stores them as `session.declaredCoderScope` automatically — no explicit `declare_scope` call required.
877
+ - **Scope containment tracking**: `guardrails.ts` appends every file the architect writes to `session.modifiedFilesThisCoderTask`. On coder delegation start, the list resets to `[]`.
878
+ - **Violation detection**: After a coder task completes, `toolAfter` compares `modifiedFilesThisCoderTask` against `declaredCoderScope`. If >2 files are outside the declared scope, `session.lastScopeViolation` is set. The next architect message receives a scope violation warning.
879
+ - **`isInDeclaredScope(filePath, scopeEntries)`**: Module-level helper using `path.resolve()` + `path.relative()` for proper directory containment (not string matching).
880
+
819
881
  ### v6.13.2 — Pipeline Enforcement
820
882
 
821
883
  This release adds enforcement-layer tooling and self-healing guardrails:
package/dist/cli/index.js CHANGED
@@ -16603,7 +16603,8 @@ var TOOL_NAMES = [
16603
16603
  "phase_complete",
16604
16604
  "save_plan",
16605
16605
  "update_task_status",
16606
- "write_retro"
16606
+ "write_retro",
16607
+ "declare_scope"
16607
16608
  ];
16608
16609
  var TOOL_NAME_SET = new Set(TOOL_NAMES);
16609
16610
 
@@ -16643,7 +16644,8 @@ var AGENT_TOOL_MAP = {
16643
16644
  "test_runner",
16644
16645
  "todo_extract",
16645
16646
  "update_task_status",
16646
- "write_retro"
16647
+ "write_retro",
16648
+ "declare_scope"
16647
16649
  ],
16648
16650
  explorer: [
16649
16651
  "complexity_hotspots",
@@ -21,3 +21,17 @@ export declare const DEFAULT_SCORING_CONFIG: ScoringConfig;
21
21
  * @returns The effective scoring configuration with all defaults applied
22
22
  */
23
23
  export declare function resolveScoringConfig(userConfig?: ScoringConfig): ScoringConfig;
24
+ /**
25
+ * Model ID substrings that identify low-capability models.
26
+ * If a model's ID contains any of these substrings (case-insensitive),
27
+ * it is considered a low-capability model.
28
+ */
29
+ export declare const LOW_CAPABILITY_MODELS: readonly ["mini", "nano", "small", "free"];
30
+ /**
31
+ * Returns true if the given modelId contains any LOW_CAPABILITY_MODELS substring
32
+ * (case-insensitive comparison).
33
+ *
34
+ * @param modelId - The model ID to check
35
+ * @returns true if the model is considered low capability, false otherwise
36
+ */
37
+ export declare function isLowCapabilityModel(modelId: string): boolean;