Skip to content

Design and plan a hook-based integration that lets the Swarm subsystem… - #4

Merged
SomeRandmGuyy merged 5 commits into
mainfrom
milestone/v2.0-omp-native-swarm
Oct 8, 2026
Merged

SomeRandmGuyy merged 5 commits into
mainfrom
milestone/v2.0-omp-native-swarm

Conversation

@SomeRandmGuyy

@SomeRandmGuyy SomeRandmGuyy commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The branch implements an opt-in (AIO_SWARM_AFTER_ORCH) hook-based trigger wiring Swarm execution to fire after orchestrate/ultrathink completion, with supporting modules (swarm/hook_trigger.py, swarm/signal_detector.py, swarm/observability.py, swarm/state_store.py, swarm/paths.py, swarm/verdicts.py, swarm/results.py, swarm/schema.py), a .claude/swarm-state.json observability artifact, extensive test coverage (test_autonomous_run.py, test_hook.py, test_ingest_parity.py, etc.), CI workflow addition, and a long commit history showing iterative Greptile-review-driven hardening (idempotency, fail-closed gate handling, dedup, signal classification, lease/transition semantics). The gsd signals show milestone v2.0 with all 7 phases verified passed and audit scores 38/38 requirements, 7/7 phases, 23/23 integration, 8/8 flows (status 'tech_debt' only, not failing). Clarifications q1-q4 appear addressed in spirit: default options (a01-orchestrator completion signal, opt-in flag, separate swarm-state file) match what was implemented per commit messages referencing AIO_SWARM_AFTER_ORCH and .claude/swarm-state.json.

Linked issues

Fixes SPE-6053 — [n1] Map current Swarm, hooks, orchestrate/ultrathink, and gsd touchpoints
https://linear.app/swcstudio/issue/SPE-6053/n1-map-current-swarm-hooks-orchestrateultrathink-and-gsd-touchpoints

Fixes SPE-6054 — [n2] Decompose integration into independent subsystems
https://linear.app/swcstudio/issue/SPE-6054/n2-decompose-integration-into-independent-subsystems

Fixes SPE-6055 — [n4] Define the parallel execution model and safety boundaries for Swarm units
https://linear.app/swcstudio/issue/SPE-6055/n4-define-the-parallel-execution-model-and-safety-boundaries-for-swarm

Fixes SPE-6056 — [n3] Define the hook trigger condition and firing mechanism
https://linear.app/swcstudio/issue/SPE-6056/n3-define-the-hook-trigger-condition-and-firing-mechanism

Fixes SPE-6057 — [n5] Define observability and gsd-consistent state/log tracking
https://linear.app/swcstudio/issue/SPE-6057/n5-define-observability-and-gsd-consistent-statelog-tracking

Fixes SPE-6058 — [n7] Evaluate risks across idempotency, concurrency, and failure paths
https://linear.app/swcstudio/issue/SPE-6058/n7-evaluate-risks-across-idempotency-concurrency-and-failure-paths

Fixes SPE-6059 — [n6] Identify unresolved ambiguities requiring user confirmation
https://linear.app/swcstudio/issue/SPE-6059/n6-identify-unresolved-ambiguities-requiring-user-confirmation

Fixes SPE-6060 — [n8] Produce ordered, parallelizable execution plan for the coding agent
https://linear.app/swcstudio/issue/SPE-6060/n8-produce-ordered-parallelizable-execution-plan-for-the-coding-agent

Notion task: https://app.notion.com/p/3edbc1a0c7ae8118b153dbc1a86b4f27?pvs=204

Assessment

  • Done: yes
  • Confidence: 0.68
  • Judge (advisory): done yes, confidence 0.68
  • Judge notes:
    • Full parallel execution engine (lib/swarm-executor.js equivalent with SWARM_MAX_PARALLEL clamp and per-unit failure isolation) referenced in the WORKFLOW Wave 3 is not clearly visible in the diff stat — swarm_run.py has --max-parallel flag but explicit clamping/sequential-fallback-on-unsafe-parallelism logic isn't confirmed in the truncated patch.
    • docs/swarm-integration-decisions.md (Wave 1 deliverable recording the 5 confirmed defaults) is not visible in the diff stat, so explicit written confirmation of clarification defaults may be missing even though behavior suggests defaults were followed.
    • PENDING-timeout watchdog (lib/swarm-watchdog.js equivalent, Wave 4) is not visible in the diff stat/patch excerpt.

ultrathink graph ut-muqh4o5a-4ccc266d


Note

High Risk
Changes orchestration leasing, fail-closed gates, hook-fired autonomous runs, and multi-host install paths—areas where mis-wiring can skip work, target the wrong repo, or weaken gate enforcement.

Overview
This PR tightens how the swarm runs against application repos and how gates record verdicts, while adding Trae SOLO, omp, and post-orchestrator hook integration plus CI.

Orchestration and gates: Generated A01 and gate-agent prompts (Claude, Grok, and aligned Trae copies) now require --repo <app> on plan/status/run tools, store state under <app>/.swarm, lease ready tasks (CLAIMED → IN_PROGRESS) before dispatch, ingest task.result, and forbid the orchestrator from hand-writing gate verdicts. Gate agents (A08/A09/A10/A12) run each gate script once with the gate task id (scripts write verdicts on gate_for targets); dry-run gate output is restricted to runner dry-runs. A09’s public verdict vocabulary moves to pass / fail (legacy aliases documented).

New host surfaces: Adds a generated Trae kit (15 prompts, registration.json, /swarm command, README). Documents and wires an omp extension (.omp/config.yml, package/skills stubs, expanded CLAUDE.md / README for install, guard, and /swarm). GitHub Actions CI runs pytest, agent build checks, and bun tests.

Hooks and autonomous kickoff: Grok hook config uses repo-relative hook paths and registers a Stop handler (on_a01_complete.py → opt-in AIO_SWARM_AFTER_ORCH / swarm.hook_trigger). autonomous_run.py delegates classification to swarm.signal_detector, resolves SWARM_DIR per target repo, skips swarm_run when planning fails, forwards --correlation-id, and adds omp runtime. Adds sample .claude/swarm-state.json for observability shape.

Docs/examples: README and CLAUDE.md examples consistently pass --repo; root package.json test script targets tests/ts only.

Reviewed by Cursor Bugbot for commit ca55021. Bugbot is set up for automated code reviews on this repo. Configure here.

RetriggerConfidence Score: 0/5 Tier: apex

The PR does not appear safe to merge while errored sessions abort scheduling, recovered plans run without leases, event validation fails, and lost leases can coexist with locally completed tasks.

Fix All in Claude CodeFindings

  1. P1 Errored sessions abort scheduling ▶
  2. P1 Unstable payload defeats deduplication ▶
  3. P1 Parallel tasks can overwrite work ▶
  4. P1 Failed sessions can complete tasks ▶
  5. P1 Expired failures remain authoritative ▶
  6. P1 Invalid signing key produces assignment ▶
  7. P1 Follow-on run never starts ▶
  8. P1 Follow-on targets wrong repository ▶
  9. P1 Failed dispatch cannot recover ▶
  10. P1 Installer removes existing Stop hooks ▶
  11. P1 Completion trigger loses its run ▶
  12. P1 Direct test requests are skipped ▶
  13. P2 Signing failure raises TypeError ▶
  14. P2 Event text misstates progress ▶
  15. P2 Pending triggers lack timeout ▶
  16. P2 Reused plans advertise stale work ▶
  17. P2 Security Public key satisfies required signing ▶
Fix with agent prompt
### Issue 1
scripts/swarm_run.py:827-829
When a headless agent exits nonzero or reports `is_error`, this branch uses `ErrorCode.E_EXEC`, which does not exist. It raises `AttributeError` instead of rejecting the result, aborting the scheduling round and leaving the task in progress rather than entering the retry path.

### Issue 2
swarm/hook_trigger.py:30-33
If the same completion is redelivered with a changed timestamp or reordered JSON fields, hashing the serialized payload produces a new trigger ID and fires it again. A missing session ID also becomes `unknown`, making independent events ambiguous. Use stable hook event fields and skip incomplete identities. Greptile automatically discovered a related ticket stating that incomplete hash inputs must fail closed, which informed this comment.

### Issue 3
scripts/swarm_run.py:632-641
If independent ready tasks edit the same file, this loop starts them in one worktree without checking file ownership or falling back to sequential execution. Concurrent edits can lose changes. Greptile automatically discovered a related ticket stating that parallel execution requires an explicit per-unit safety check and sequential fallback when declarations are missing, which informed this comment.

### Issue 4
scripts/swarm_run.py:552-564
If a non-gate agent process exits nonzero or reports `is_error` but leaves a valid `IN_REVIEW` result, this code still applies that result. The error check protects only gate-script execution, so reconciliation can mark failed implementation work `DONE`. Reject errored sessions before applying their results.

### Issue 5
swarm/taskstore.py:333-339
If a failing verdict has expired before a target is reconciled, `_check_row` still returns `fail` before checking its expiry. Reconciliation can therefore send the target into rework or escalation based on expired evidence instead of requiring a fresh gate run. Check expiry for failing verdicts too.

### Issue 6
swarm/envelope.py:154-161
If `SWARM_ED25519_KEY` is set but cannot be loaded and no HMAC key is configured, this function silently signs `task.assign` with the public development key. The verifier rejects that signature under the same configuration, so an agent enforcing signed assignments receives an unverifiable assignment rather than an immediate key-configuration error.

### Issue 7
swarm/hook_trigger.py:undefined-47
The launcher passes a fixed brief, `gsd-autonomous follow-on after a01`, that contains none of the terms accepted by `autonomous_run.py`'s classifier. The child exits before planning or running Swarm, although the completion was marked as fired. Greptile automatically discovered a related ticket stating that the completion trigger must invoke the existing Swarm entry point, which informed this comment.

### Issue 8
swarm/hook_trigger.py:47-48
If the child proceeds past classification after a hook fires in an installed application workspace, it starts in the AgentSwarm checkout without `--cwd`. `autonomous_run.py` therefore plans and runs against the checkout instead of the application. It also receives a placeholder rather than the user's brief, so the planned work does not reflect the request.

### Issue 9
swarm/hook_trigger.py:59-60
If the subprocess fails to start, or exits before dispatching work, the trigger has already been recorded as seen and `FIRED`. This handler swallows the spawn error, and a redelivered completion is skipped as a duplicate, permanently losing its follow-on run. Greptile automatically discovered a related ticket stating that interrupted dispatches must remain recoverable across FIRED, RUNNING, and terminal transitions, which informed this comment.

### Issue 10
scripts/build_agents.py:257-259
If an application workspace already has `Stop` handlers, installing AgentSwarm replaces their entire list with this handler. Those existing completion handlers no longer run after installation; preserve them when adding the new registration.

```suggestion
    stop_hooks = hooks.setdefault("Stop", [])
    complete_hook = {"hooks": [{"type": "command", "command": complete_cmd}]}
    if complete_hook not in stop_hooks:
        stop_hooks.append(complete_hook)
```

### Issue 11
swarm/state_store.py:undefined-83
If `SWARM_DIR` points outside the workspace and `./.swarm` does not exist, the completion hook records the trigger ID in the configured database but tries to write this mirror under `./.swarm`. That write fails before the follow-on run starts. The hook suppresses the error, and a repeated completion is skipped because its ID is already recorded.

```suggestion
        self.swarm_path = swarm_dir(root, create=True) / "swarm-state.json"
```

### Issue 12
swarm/signal_detector.py:15-17
A request such as “test checkout” matched the previous shared classifier, but this expression accepts only “write test” or “write tests,” not `test` on its own. The prompt hook therefore adds no orchestration guidance, and `autonomous_run.py` exits before starting a plan. Preserve direct testing requests when aligning the shared and OMP classifiers.

### Issue 13
swarm/envelope.py:152-153
In a required-key configuration with no usable key, this branch calls `SwarmError` without its required message argument. Signing raises `TypeError` instead of a policy error, so a runner building an assignment aborts the round without reporting the key-configuration failure.

```suggestion
        raise SwarmError(ErrorCode.E_POLICY, err)
```

### Issue 14
swarm/observability.py:32-38
This counts any event whose string contains `DONE` as completed work and uses the number of events as the total. An event that merely mentions `DONE` can make the projection report `COMPLETE` while tasks remain unfinished, and multiple events per task distort progress. Derive these values from task outcomes.

### Issue 15
swarm/state_store.py:83-84
The initial `PENDING` record has no deadline or scheduled check, and the stale-event emitter is never called. If orchestrate/ultrathink never completes, operators get no timeout or `STALE` event to distinguish that condition from silence. Greptile automatically discovered a related ticket stating that pending preconditions need a timeout watchdog or next-invocation stale check, which informed this comment.

### Issue 16
omp/src/commands.ts:56-63
Repeating `/swarm` uses the creation-time plan snapshot, and this function calls any task with no dependencies “ready” without checking its current state. A root task already running or `DONE` is advertised to a new A01 dispatch turn, creating avoidable duplicate-dispatch attempts despite the live status API marking it ineligible.

### Issue 17
swarm/envelope.py:114-116
If a protected configuration explicitly sets `SWARM_SIGNING_KEY=dev-insecure-key`, `SWARM_REQUIRE_KEY=1` treats that publicly known value as a real key. Development-key verdicts then verify and the approval check can pass, defeating the required-key protection. Reject the known development value when a real key is required.

**How this was verified:** The required-key check accepts any nonempty HMAC secret, and verification uses that secret verbatim without checking whether it is the public development value.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR adds an opt-in completion hook and extends Swarm with substrate-backed graph binding, event forwarding, leases, handoffs, governed memory, and per-agent workspace credentials.

  • The new failed-session branch and event-mapping test break important runner and validation paths.
  • Graph binding and lease reconciliation need recovery and ownership checks before the substrate integration is reliable.
  • Greptile automatically discovered a related ticket that helped explain the purpose of this PR: firing Swarm after orchestration completion while deduplicating the trigger.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Hook[Completion hook] --> Auto[Autonomous runner]
  Auto --> Plan[Plan]
  Plan --> Bind[Bind and register graph]
  Plan --> Tasks[(Task Store)]
  Tasks --> Claim{Claim node}
  Claim --> Agent[Agent session]
  Agent --> Gate[Gate script]
  Gate --> Review[Reconcile results]
  Review --> Complete[Complete node]
  Review --> Handoff[Write handoff]
  Tasks --> Log[Local event log]
  Log --> Tee[Substrate event tee]
Loading

Reviews (4) · Last reviewed commit: "fix: resolve review findings for complet..." · Reviewed by Greptile

@cursor

cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 10dad0d9-14e5-41b6-a9cf-814317eced36)

Comment thread .grok/hooks/agent-swarm.json
Comment thread swarm/hook_trigger.py Outdated
Comment thread hooks/on_a01_complete.py
Comment thread swarm/signal_detector.py Outdated
Comment thread swarm/signal_detector.py
Comment thread swarm/results.py
Comment thread swarm/taskstore.py
Comment on lines +333 to +341
if p.get("dry_run") and not task["notes_json"].get("dry_run"):
return "dry-run"
if p["verdict"] not in ("pass", "waive"):
return "fail"
try:
if not float(p["issued_at"]) + float(p["expires_s"]) > now:
return "expired"
except (KeyError, TypeError, ValueError):
return "mismatch"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Expired failures remain authoritative If a failing verdict has expired before a target is reconciled, _check_row still returns fail before checking its expiry. Reconciliation can therefore send the target into rework or escalation based on expired evidence instead of requiring a fresh gate run. Check expiry for failing verdicts too.

Knowledge Base Used: Gate evaluation

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/taskstore.py
Line: 333-341

Comment:
**Expired failures remain authoritative** If a failing verdict has expired before a target is reconciled, `_check_row` still returns `fail` before checking its expiry. Reconciliation can therefore send the target into rework or escalation based on expired evidence instead of requiring a fresh gate run. Check expiry for failing verdicts too.

**Knowledge Base Used:** [Gate evaluation](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/gate-evaluation.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread omp/src/commands.ts
Comment on lines +56 to +63
/** Ready = the plan's tasks with an empty depends_on list (the only definition; no Task Store re-read). */
function readyTaskIds(json: Record<string, unknown>): string[] {
const tasks = Array.isArray(json.tasks) ? json.tasks : [];
const ids: string[] = [];
for (const t of tasks) {
if (typeof t !== "object" || t === null) continue;
const { task_id, depends_on } = t as { task_id?: unknown; depends_on?: unknown };
if (typeof task_id === "string" && Array.isArray(depends_on) && depends_on.length === 0) ids.push(task_id);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Reused plans advertise stale work Repeating /swarm uses the creation-time plan snapshot, and this function calls any task with no dependencies “ready” without checking its current state. A root task already running or DONE is advertised to a new A01 dispatch turn, creating avoidable duplicate-dispatch attempts despite the live status API marking it ineligible.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: omp/src/commands.ts
Line: 56-63

Comment:
**Reused plans advertise stale work** Repeating `/swarm` uses the creation-time plan snapshot, and this function calls any task with no dependencies “ready” without checking its current state. A root task already running or `DONE` is advertised to a new A01 dispatch turn, creating avoidable duplicate-dispatch attempts despite the live status API marking it ineligible.

**Knowledge Base Used:**
- [Orchestration workflow](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/orchestration-workflow.md)
- [OMP integration](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/omp-integration.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread swarm/envelope.py
Comment on lines 148 to +155
key = _ed25519_key()
if key is not None:
sig = key.sign(_canonical(env))
env["sig"] = "ed25519:" + base64.b64encode(sig).decode()
else:
secret = os.environ.get("SWARM_SIGNING_KEY", "dev-insecure-key").encode()
# an empty SWARM_SIGNING_KEY counts as unset, exactly as verify_envelope treats it
secret = (os.environ.get("SWARM_SIGNING_KEY") or "dev-insecure-key").encode()
if audit and not os.environ.get("SWARM_SIGNING_KEY"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Invalid signing key produces assignment If SWARM_ED25519_KEY is set but cannot be loaded and no HMAC key is configured, this function silently signs task.assign with the public development key. The verifier rejects that signature under the same configuration, so an agent enforcing signed assignments receives an unverifiable assignment rather than an immediate key-configuration error.

Knowledge Base Used: Result envelopes and verdicts

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/envelope.py
Line: 148-155

Comment:
**Invalid signing key produces assignment** If `SWARM_ED25519_KEY` is set but cannot be loaded and no HMAC key is configured, this function silently signs `task.assign` with the public development key. The verifier rejects that signature under the same configuration, so an agent enforcing signed assignments receives an unverifiable assignment rather than an immediate key-configuration error.

**Knowledge Base Used:** [Result envelopes and verdicts](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/result-envelopes-and-verdicts.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread swarm/envelope.py Outdated
Comment on lines +114 to +116
def real_key_configured() -> bool:
"""True when a non-dev signing key is configured (loadable Ed25519 seed or HMAC secret)."""
return _ed25519_key() is not None or bool(os.environ.get("SWARM_SIGNING_KEY"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security Public key satisfies required signing If a protected configuration explicitly sets SWARM_SIGNING_KEY=dev-insecure-key, SWARM_REQUIRE_KEY=1 treats that publicly known value as a real key. Development-key verdicts then verify and the approval check can pass, defeating the required-key protection. Reject the known development value when a real key is required.

How this was verified: The required-key check accepts any nonempty HMAC secret, and verification uses that secret verbatim without checking whether it is the public development value.

Knowledge Base Used: Result envelopes and verdicts

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/envelope.py
Line: 114-116

Comment:
**Public key satisfies required signing** If a protected configuration explicitly sets `SWARM_SIGNING_KEY=dev-insecure-key`, `SWARM_REQUIRE_KEY=1` treats that publicly known value as a real key. Development-key verdicts then verify and the approval check can pass, defeating the required-key protection. Reject the known development value when a real key is required.

**How this was verified:** The required-key check accepts any nonempty HMAC secret, and verification uses that secret verbatim without checking whether it is the public development value.

**Knowledge Base Used:** [Result envelopes and verdicts](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/result-envelopes-and-verdicts.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

@greptile-apps

This comment has been minimized.

@cursor

cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: d018d13e-81c4-4db9-980d-3d6e57477aed)

@cursor

cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 20b566ee-e966-4760-bc25-d2ac8071af51)

Comment thread swarm/hook_trigger.py Outdated
env["SWARM_CHILD"] = "0"
env["AIO_SWARM_AFTER_ORCH"] = "1"
subprocess.Popen(
["python3", str(hook_path), "--brief", f"gsd-autonomous follow-on after a01 {corr or ''}"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Follow-on run never starts The launcher passes a fixed brief, gsd-autonomous follow-on after a01, that contains none of the terms accepted by autonomous_run.py's classifier. The child exits before planning or running Swarm, although the completion was marked as fired. Greptile automatically discovered a related ticket stating that the completion trigger must invoke the existing Swarm entry point, which informed this comment.

Knowledge Base Used: Autonomous run hooks

Source Used: Linear — [n3] Define the hook trigger condition and firing mechanism

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/hook_trigger.py
Line: 47

Comment:
**Follow-on run never starts** The launcher passes a fixed brief, `gsd-autonomous follow-on after a01`, that contains none of the terms accepted by `autonomous_run.py`'s classifier. The child exits before planning or running Swarm, although the completion was marked as fired. Greptile automatically discovered a related ticket stating that the completion trigger must invoke the existing Swarm entry point, which informed this comment.

**Knowledge Base Used:** [Autonomous run hooks](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/autonomous-run-hooks.md)

**Source Used:** Linear — [\[n3\] Define the hook trigger condition and firing mechanism](https://linear.app/swcstudio/issue/SPE-6056/n3-define-the-hook-trigger-condition-and-firing-mechanism)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread swarm/hook_trigger.py Outdated
Comment on lines +47 to +48
["python3", str(hook_path), "--brief", f"gsd-autonomous follow-on after a01 {corr or ''}"],
cwd=str(Path(__file__).resolve().parent.parent),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Follow-on targets wrong repository If the child proceeds past classification after a hook fires in an installed application workspace, it starts in the AgentSwarm checkout without --cwd. autonomous_run.py therefore plans and runs against the checkout instead of the application. It also receives a placeholder rather than the user's brief, so the planned work does not reflect the request.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/hook_trigger.py
Line: 47-48

Comment:
**Follow-on targets wrong repository** If the child proceeds past classification after a hook fires in an installed application workspace, it starts in the AgentSwarm checkout without `--cwd`. `autonomous_run.py` therefore plans and runs against the checkout instead of the application. It also receives a placeholder rather than the user's brief, so the planned work does not reflect the request.

**Knowledge Base Used:**
- [Autonomous run hooks](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/autonomous-run-hooks.md)
- [Orchestration workflow](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/orchestration-workflow.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread swarm/hook_trigger.py
Comment on lines +54 to +55
except Exception:
pass # fail open

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Failed dispatch cannot recover If the subprocess fails to start, or exits before dispatching work, the trigger has already been recorded as seen and FIRED. This handler swallows the spawn error, and a redelivered completion is skipped as a duplicate, permanently losing its follow-on run. Greptile automatically discovered a related ticket stating that interrupted dispatches must remain recoverable across FIRED, RUNNING, and terminal transitions, which informed this comment.

Knowledge Base Used: Autonomous run hooks

Source Used: Linear — [n7] Evaluate risks across idempotency, concurrency, and failure paths

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/hook_trigger.py
Line: 54-55

Comment:
**Failed dispatch cannot recover** If the subprocess fails to start, or exits before dispatching work, the trigger has already been recorded as seen and `FIRED`. This handler swallows the spawn error, and a redelivered completion is skipped as a duplicate, permanently losing its follow-on run. Greptile automatically discovered a related ticket stating that interrupted dispatches must remain recoverable across FIRED, RUNNING, and terminal transitions, which informed this comment.

**Knowledge Base Used:** [Autonomous run hooks](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/autonomous-run-hooks.md)

**Source Used:** Linear — [\[n7\] Evaluate risks across idempotency, concurrency, and failure paths](https://linear.app/swcstudio/issue/SPE-6058/n7-evaluate-risks-across-idempotency-concurrency-and-failure-paths)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread scripts/build_agents.py Outdated
Comment on lines +257 to +259
hooks["Stop"] = [
{"hooks": [{"type": "command", "command": complete_cmd}]}
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Installer removes existing Stop hooks If an application workspace already has Stop handlers, installing AgentSwarm replaces their entire list with this handler. Those existing completion handlers no longer run after installation; preserve them when adding the new registration.

Suggested change
hooks["Stop"] = [
{"hooks": [{"type": "command", "command": complete_cmd}]}
]
stop_hooks = hooks.setdefault("Stop", [])
complete_hook = {"hooks": [{"type": "command", "command": complete_cmd}]}
if complete_hook not in stop_hooks:
stop_hooks.append(complete_hook)

Knowledge Base Used: Agent artifact generation

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/build_agents.py
Line: 257-259

Comment:
**Installer removes existing Stop hooks** If an application workspace already has `Stop` handlers, installing AgentSwarm replaces their entire list with this handler. Those existing completion handlers no longer run after installation; preserve them when adding the new registration.

```suggestion
    stop_hooks = hooks.setdefault("Stop", [])
    complete_hook = {"hooks": [{"type": "command", "command": complete_cmd}]}
    if complete_hook not in stop_hooks:
        stop_hooks.append(complete_hook)
```

**Knowledge Base Used:** [Agent artifact generation](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/agent-artifact-generation.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

@cursor

cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: e6b9b60c-eae6-48c8-8cdc-e90e20bce594)

Comment thread swarm/state_store.py Outdated
def __init__(self, path: str | Path | None = None, *, root: str | Path | None = None):
self.root = Path(root) if root else Path(".")
self.claude_path = self.root / ".claude" / "swarm-state.json"
self.swarm_path = (swarm_dir(root, create=True) / "swarm-state.json") if root else (Path(".swarm") / "swarm-state.json")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Completion trigger loses its run If SWARM_DIR points outside the workspace and ./.swarm does not exist, the completion hook records the trigger ID in the configured database but tries to write this mirror under ./.swarm. That write fails before the follow-on run starts. The hook suppresses the error, and a repeated completion is skipped because its ID is already recorded.

Suggested change
self.swarm_path = (swarm_dir(root, create=True) / "swarm-state.json") if root else (Path(".swarm") / "swarm-state.json")
self.swarm_path = swarm_dir(root, create=True) / "swarm-state.json"

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/state_store.py
Line: 83

Comment:
**Completion trigger loses its run** If `SWARM_DIR` points outside the workspace and `./.swarm` does not exist, the completion hook records the trigger ID in the configured database but tries to write this mirror under `./.swarm`. That write fails before the follow-on run starts. The hook suppresses the error, and a repeated completion is skipped because its ID is already recorded.

```suggestion
        self.swarm_path = swarm_dir(root, create=True) / "swarm-state.json"
```

**Knowledge Base Used:**
- [Task and run state](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/task-and-run-state.md)
- [Autonomous run hooks](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/autonomous-run-hooks.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread swarm/signal_detector.py
Comment on lines +15 to +17
SDLC = re.compile(
r"\b(build|implement|add|create|fix|refactor|migrate|deploy|release|ship|write tests?|set up|setup|integrate|scaffold|upgrade)\b",
re.I | re.A,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Direct test requests are skipped A request such as “test checkout” matched the previous shared classifier, but this expression accepts only “write test” or “write tests,” not test on its own. The prompt hook therefore adds no orchestration guidance, and autonomous_run.py exits before starting a plan. Preserve direct testing requests when aligning the shared and OMP classifiers.

Knowledge Base Used: Autonomous run hooks

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/signal_detector.py
Line: 15-17

Comment:
**Direct test requests are skipped** A request such as “test checkout” matched the previous shared classifier, but this expression accepts only “write test” or “write tests,” not `test` on its own. The prompt hook therefore adds no orchestration guidance, and `autonomous_run.py` exits before starting a plan. Preserve direct testing requests when aligning the shared and OMP classifiers.

**Knowledge Base Used:** [Autonomous run hooks](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/autonomous-run-hooks.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

…n1-n8 plan; opt-in AIO_SWARM_AFTER_ORCH; state/obs/trigger/detector shims; thin classify delegates; .claude/swarm-state.json obs)

- New swarm/ modules for state idempotency, observability, signal detection, hook trigger per n8 execution plan.
- Thin shims + on_a01_complete.py for a01-complete / uplift end signal.
- Adopted n6 defaults (a01 signal, opt-in, seq default, separate state).
- Guardrails stub + n5 6-state projection.
- Enables parallel gsd run after ultrathink/orchestrate via hooks.
- Tests and smoke pass; no regression.

Part of rebuilding Swarm for gsd + claude-ultrathink autonomous via hooks.
…esses greptile completion handler never registered; enables AIO_SWARM_AFTER_ORCH trigger for gsd+ultrathink)

- merge_claude_settings and write_grok_hooks now also emit Stop -> on_a01_complete.py
- .grok/hooks updated
- install dry-run messages updated
- matches n3/n8 design for hook reg

This should allow the after-orchestrate signal to fire.
…er FIRED (addresses greptile P1 firing never starts swarm; actual detached kick for gsd follow-on)
…1-specific detect, stable dedup+optin parse, .claude primary+unique tmp+GSD root, invoke entry)

- on_a01: sys.path for workspace
- signal: full guards + a01 check
- trigger: stable id, explicit bool, invoke
- state: .claude advertised, pid tmp, root append
- keeps opt-in, idemp, fail-open

Ready for 5/5 review and merge per ultrathink-ship.
@SomeRandmGuyy
SomeRandmGuyy force-pushed the milestone/v2.0-omp-native-swarm branch from ca55021 to 6015382 Compare October 8, 2026 11:49
@SomeRandmGuyy
SomeRandmGuyy merged commit eeefe74 into main Oct 8, 2026
1 of 3 checks passed
@SomeRandmGuyy
SomeRandmGuyy deleted the milestone/v2.0-omp-native-swarm branch October 8, 2026 11:49
Comment thread scripts/swarm_run.py
Comment on lines +827 to +829
elif meta.get("is_error") or meta.get("returncode"):
result, err = None, SwarmError(ErrorCode.E_EXEC, f"agent session reported error (rc={meta.get('returncode')})",
task_id=tid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Errored sessions abort scheduling When a headless agent exits nonzero or reports is_error, this branch uses ErrorCode.E_EXEC, which does not exist. It raises AttributeError instead of rejecting the result, aborting the scheduling round and leaving the task in progress rather than entering the retry path.

Knowledge Base Used: Orchestration workflow

Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/swarm_run.py
Line: 827-829

Comment:
**Errored sessions abort scheduling** When a headless agent exits nonzero or reports `is_error`, this branch uses `ErrorCode.E_EXEC`, which does not exist. It raises `AttributeError` instead of rejecting the result, aborting the scheduling round and leaving the task in progress rather than entering the retry path.

**Knowledge Base Used:** [Orchestration workflow](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/orchestration-workflow.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread swarm/envelope.py
Comment on lines +152 to +153
from .errors import SwarmError
raise SwarmError(f"E-POLICY {err}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Signing failure raises TypeError In a required-key configuration with no usable key, this branch calls SwarmError without its required message argument. Signing raises TypeError instead of a policy error, so a runner building an assignment aborts the round without reporting the key-configuration failure.

Suggested change
from .errors import SwarmError
raise SwarmError(f"E-POLICY {err}")
raise SwarmError(ErrorCode.E_POLICY, err)

Knowledge Base Used: Swarm execution foundation

Prompt To Fix With AI
This is a comment left during a code review.
Path: swarm/envelope.py
Line: 152-153

Comment:
**Signing failure raises TypeError** In a required-key configuration with no usable key, this branch calls `SwarmError` without its required message argument. Signing raises `TypeError` instead of a policy error, so a runner building an assignment aborts the round without reporting the key-configuration failure.

```suggestion
        raise SwarmError(ErrorCode.E_POLICY, err)
```

**Knowledge Base Used:** [Swarm execution foundation](https://app.greptile.com/swcstudio/-/custom-context/knowledge-base/swcstudiospace/agent-swarm/-/docs/swarm-execution-foundation.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant