Commit Graph

8 Commits

Author SHA1 Message Date
freemo 8c13e63c75 chore(agents): add system watchdog, remove force_merge, fix 9 systemic agent issues
Add ca-system-watchdog (16th supervisor) for continuous system health
monitoring with quality gate auditing, zombie detection, ticket state
reconciliation, and priority enforcement. Add ca-quality-enforcer and
ca-state-reconciler as one-off fix agents dispatched by the watchdog.

Critical fix: remove all force_merge: true usage from ca-pr-self-reviewer
which was bypassing branch protection and allowing PRs to merge with
failing CI. Replace with strict CI-gating merge logic that respects
branch protection rules per CONTRIBUTING.md.

Update product-builder to launch 16 supervisors, strengthen anti-return
language with explicit context hygiene, add tracking ticket lifecycle
management (one open at a time, closed on completion).

Update ca-project-bootstrapper with strict branch protection config
requiring status-check CI context, 2 approvals, and dismiss stale reviews.
Fix label set to match CONTRIBUTING.md exactly.

Update issue-implementor with priority gate enforcing lowest-milestone-first
and critical-bugs-first ordering. Update ca-backlog-groomer with closed
issue state reconciliation, PAT for REST API dependency operations, and
health signaling. Update ca-spec-updater with proactive full-scan mode.

Add health signaling and context self-management to 7 continuous
supervisors to prevent zombie sessions from context exhaustion.

Strengthen state label transitions in ca-pr-self-reviewer, ca-pr-api-creator,
ca-issue-state-updater, and ca-backlog-groomer to ensure closed issues
always have correct terminal state labels.

Add Forgejo PAT and REST API curl templates for dependency link creation
to ca-backlog-groomer and ca-project-owner since the MCP does not support
dependency manipulation.
2026-04-03 14:01:41 -04:00
freemo a538713134 refactor(agents): enforce strict curl-only permissions for all supervisors
BREAKING CHANGE: Supervisors can no longer use Task tool to launch workers

Major refactor of the permission model for product-builder and all 15
continuous supervisors to enforce strict separation: supervisors MUST use
curl/prompt_async via bash to launch workers, and CANNOT use the Task tool.

Key Changes:

1. Product-Builder Permissions (product-builder.md):
   - Removed ALL Task permissions for supervisors (previously had 17)
   - Kept Task permissions ONLY for 7 one-shot agents:
     ca-project-bootstrapper, ca-ref-reader, ca-issue-finder,
     ca-session-persister, ca-product-verifier, ca-milestone-reviewer,
     ca-final-reporter
   - Restricted bash to: echo, curl, sleep, jq only
   - Removed Phase B (Architecture) and Phase C.1 (Planning)
   - Updated to launch 15 supervisors (up from 13)

2. New Continuous Supervisors:
   - ca-architect: Converted from one-shot to continuous supervisor
     Monitors for spec needs, new milestones, ambiguities
   - ca-epic-planner: Converted from one-shot to continuous supervisor
     Monitors for milestones without issues, incomplete epics

3. All 15 Supervisors - Standardized Permissions:
   - Removed ALL Task permissions for launching workers
   - Workers MUST be launched via curl to OpenCode Server prompt_async API
   - Added 'jq *' for JSON parsing (replacing python3)
   - Restricted bash to specific commands only (deny all, allow specific)
   - Git commands restricted to specific operations (clone*, fetch*, etc.)
   - Directory operations (cd, mkdir, rm -rf) only where needed

4. Supervisor-Specific Updates:
   - issue-implementor: Removed ca-issue-worker task permission
   - ca-continuous-pr-reviewer: Added git + directory ops, removed worker tasks
   - ca-uat-tester: Added read-only file/git commands, removed self-dispatch
   - ca-bug-hunter: Restricted git to read-only, removed self-dispatch
   - ca-test-infra-improver: Added read-only commands, removed self-dispatch
   - ca-human-liaison: Removed ca-epic-planner/ca-architect task permissions
   - ca-agent-evolver: Added git + directory operations
   - ca-architecture-guard: Added read-only + git clone operations
   - ca-spec-updater: Added git + directory operations
   - ca-backlog-groomer: Removed ca-epic-planner task permission
   - ca-docs-writer: Added git + directory operations
   - ca-timeline-updater: Added git + directory operations
   - ca-project-owner: Minimal permissions (curl, jq, sleep only)

Impact:
- Proper separation of concerns: supervisors orchestrate, workers execute
- No possibility of supervisors blocking on Task tool calls
- True fire-and-forget worker launching via prompt_async
- Consistent permission model across all 15 supervisors
- Maximum parallelism with proper isolation

Architecture now enforces: Product-builder → 15 supervisors → N workers
All launched via curl/prompt_async, NO Task tool for supervisors.
2026-04-03 02:33:00 +00:00
freemo 3e9de4ca21 build(agents): enforce CONTRIBUTING.md label, milestone, and dependency compliance
Issues and PRs created by agents were missing required labels, milestones,
and Forgejo dependency links per CONTRIBUTING.md. This commit adds explicit
API call instructions and a continuous compliance audit to fix the gaps.

Changes across 6 agent definitions:

- ca-new-issue-creator: Added curl bash permission. Added explicit
  post-creation compliance steps: set labels (State/Unverified, Type/*,
  Priority/*) via forgejo_add_issue_labels, set milestone via
  forgejo_update_issue, create parent Epic dependency link via REST API
  (POST /issues/{child}/blocks with parent Epic number — correct direction:
  child blocks parent). Added compliance verification step.

- ca-epic-planner: Added curl bash permission. Added post-creation API
  call checklists for both Epics (labels, Legendary link) and child issues
  (labels, milestone, Epic dependency link, inter-issue dependency links).
  Added compliance verification step.

- ca-backlog-groomer: Added curl and sleep bash permissions. Expanded
  Pass 4 (Label Quality) to auto-fix missing labels (State, Type, Priority)
  and milestones via Forgejo API. Added PR label/milestone compliance
  checking. Added new Pass 9 (Dependency Link Compliance) to auto-fix
  missing parent Epic links, PR-to-issue links, and wrong dependency
  direction. Added new Pass 10 (Issue Body Compliance) to flag missing
  Metadata, Subtasks, and Definition of Done sections.

- ca-pr-api-creator: Added curl bash permission. Replaced vague "add
  dependency" instruction with explicit REST API curl call for creating
  PR-blocks-issue dependency link. Added post-creation compliance
  verification step.

- ca-agent-evolver: Added Priority/Backlog label and milestone assignment
  to proposal issues.

- ca-spec-updater: Added Priority/Backlog label and milestone assignment
  to proposal issues.
2026-04-02 18:28:08 +00:00
freemo 270160eca9 build(agents): add proposal issue gate before spec and agent-definition PRs
Both the spec-updater and agent-evolver previously skipped straight to
creating PRs with 'needs feedback' for proposed changes. The user needs
a two-step human-approval workflow:

Step 1: Agent creates a PROPOSAL ISSUE with 'needs feedback' label
  describing what it wants to change and why. No branch, no code changes.
Step 2: Human reviews the issue and approves it (by removing 'needs
  feedback', adding 'State/Verified', or commenting with approval).
Step 3: Agent detects approval, normalizes labels, creates branch + PR
  (also with 'needs feedback') implementing the approved change.
Step 4: Human reviews the PR and merges it.

Changes across 3 agent definitions:

- ca-agent-evolver: Step 4 split into proposal issue creation (Step 4)
  and approved-proposal implementation (Step 5). Added pending_proposals
  and pending_prs state tracking. Approval detected via 3 signals:
  label removal, State/Verified addition, or human approval comment.

- ca-spec-updater: Removed the minor/major classification and the
  "commit directly to master" path. ALL spec changes now go through
  proposal issues first (Step 6a creates issue, Step 7 monitors for
  approval). Added pending_spec_proposals and rejected_proposals state.
  Approval check runs every cycle before checking for new merged PRs.

- ca-human-liaison: Added Step 4 guard — issues with 'needs feedback'
  label are NOT auto-verified. The liaison acknowledges them with a
  comment but does not change state labels. Only issues WITHOUT 'needs
  feedback' proceed to the normal auto-verify flow (now Step 5).
2026-04-02 14:19:56 -04:00
freemo 9bbec0e698 build(agents): prompt_async for pool supervisors, session resume, bot signatures, cleanup agent
Four changes in one commit across 27 agent files:

1. POOL SUPERVISOR PROMPT_ASYNC: All 4 pool supervisors (issue-implementor,
   ca-continuous-pr-reviewer, ca-uat-tester, ca-bug-hunter) now dispatch
   their internal workers via the OpenCode Server's prompt_async endpoint
   instead of the Task tool. This eliminates the wait_for_all bottleneck
   at the supervisor level — workers run independently, and a 10-second
   polling loop detects completions and immediately refills vacant slots.
   Added curl/sleep bash permissions where needed. Each supervisor keeps
   N workers running at all times with zero idle slots.

2. SESSION RESUME INSTEAD OF CLEANUP: The product-builder and all 4 pool
   supervisors now RESUME existing sessions from a previous interrupted
   run instead of aborting them. Phase C.0 queries the server for sessions
   titled "[CA-AUTO] supervisor:*" and adopts any that are still active
   into the monitoring loop. Pool supervisors similarly adopt existing
   "[CA-AUTO] worker-*" sessions. This enables "continue where you left
   off" — restarting the product-builder reconnects to running supervisors
   and workers rather than duplicating them.

3. DEDICATED CLEANUP AGENT: New ca-session-cleanup.md primary agent for
   explicit fresh-start cleanup. Run this BEFORE the product-builder when
   you want to abort all previous sessions and start completely fresh. It
   finds all "[CA-AUTO]" sessions, aborts them, and deletes them. This is
   the ONLY way to kill old sessions — the product-builder never does it
   automatically.

4. BOT SIGNATURES: All 26 agents that post content to Forgejo now include
   a mandatory "Bot Signature" section requiring every comment, issue body,
   PR description, and review to end with:

   ---
   **Automated by CleverAgents Bot**
   Supervisor: <category> | Agent: <agent-name>

   24 agents have hardcoded categories. 2 shared agents (ca-new-issue-creator,
   ca-epic-planner) use a parameter-based category from their caller's prompt.
2026-04-02 14:01:43 -04:00
freemo eee51b7d54 build(agents): use prompt_async for fire-and-forget supervisor launch + bash sleep for real waiting
Two fundamental architectural changes that solve the "supervisor exits and
never gets relaunched" problem:

1. PROMPT_ASYNC LAUNCH: The product-builder no longer uses the Task tool to
   launch supervisors. The Task tool blocks until ALL parallel tasks return,
   meaning if one supervisor exits, the product-builder can't relaunch it
   until all 10 others also exit. Instead, supervisors are now launched via
   the OpenCode Server HTTP API's POST /session/:id/prompt_async endpoint,
   which returns 204 immediately (true fire-and-forget). The product-builder
   then enters a bash-driven monitoring loop that checks session status
   every 60 seconds via curl and relaunches any dead supervisor instantly
   — independently of whether the other 10 are still running.

   Requires: opencode started with --port 4096 (fixed known port).
   Added curl and sleep to product-builder's bash allow list.

2. BASH SLEEP FOR GENUINE WAITING: All 11 supervisors now use the Bash
   tool with "sleep N" (and explicit timeout > sleep duration) for real
   blocking waits between polling cycles. Previously, pseudocode "wait N
   minutes" was interpreted by the LLM as "I'm done, return to caller" —
   causing supervisors to exit after their first idle cycle. The bash sleep
   call genuinely blocks the agent for the specified duration, then the
   agent resumes its loop. Every supervisor has a prominent instruction
   block explaining this mechanism and warning against returning to caller.

   All idle break/exit conditions removed across all 11 supervisors.
   Supervisors now loop forever: poll Forgejo → do work → bash sleep → repeat.

Changes across 12 agent definitions:

- product-builder: Phase C.2 rewritten to use curl + prompt_async.
  Phase C.3 rewritten as bash sleep + curl monitoring loop (checks every
  60s, relaunches dead supervisors, checks convergence every 10 min).
  Phase C.4 simplified to cleanup only.

- All 11 supervisors: Added "CRITICAL: Bash Sleep" instruction block.
  Replaced all pseudocode "wait N" with bash("sleep N", timeout=N*1.5).
  Removed all idle break/exit conditions — agents now sleep and re-poll
  instead of exiting.
2026-04-02 13:19:51 -04:00
CleverAgents 3db9113bac build(agents): replace rounds-based orchestration with continuous watchdog model
The product-builder was acting as a workflow orchestrator that ran
supervisors in sequential "rounds" (launch all → wait for ALL to finish →
check convergence → re-launch). This caused three problems:

1. Supervisors were treated as batch jobs, not services — they ran once
   and exited, leaving gaps in coverage between rounds.
2. The product-builder blocked on wait_for_all(), meaning if one supervisor
   ran for hours, all others were dead during that time.
3. Coordination flowed through the product-builder (passing data between
   supervisors) instead of through Forgejo.

The new model treats the product-builder as a process supervisor (like
systemd). Its only jobs are: launch all 11 supervisors in a single
parallel batch, keep them alive (re-launch on exit), and periodically
check convergence by querying Forgejo. It never coordinates between
supervisors — they self-coordinate exclusively through Forgejo issues,
PRs, and comments.

Changes across 11 agent definitions:

- product-builder: Replaced Phase C.2/C.3 rounds loop with watchdog
  loop (wait_for_any + re-launch). Added mandatory pre-flight checklist
  and post-dispatch validation requiring all 11 supervisors. Removed
  all "round" variables and batch-wait semantics.

- issue-implementor: Added 60-minute idle polling loop after queue
  drains — polls Forgejo for new issues every 60s before exiting,
  allowing it to pick up UAT bugs and human-created issues.

- ca-continuous-pr-reviewer: Increased idle exit from 50 polls (~25 min)
  to 300 polls (~150 min).

- ca-backlog-groomer: Increased from 30 cycles/5 clean to 200 cycles/
  20 clean before exit.

- ca-bug-hunter: Increased idle tolerance from 5 waits (~5 min) to 60
  waits (~60 min).

- ca-uat-tester: Increased idle tolerance from 5 waits (~5 min) to 60
  waits (~60 min).

- ca-architecture-guard, ca-spec-updater, ca-docs-writer,
  ca-timeline-updater: Converted from one-shot agents to continuous
  services with monitoring loops that re-check for new code/changes
  at 10-30 minute intervals and exit after 100-300 minutes idle.

- ca-agent-evolver: Clarified idle exit timing (~150 min).
2026-04-02 16:37:58 +00:00
freemo a0f3999362 build(agents): restructure for async pool supervision, PR merge lifecycle, and human interaction
Overhauls the agent orchestration architecture to solve three systemic issues:

1. PARALLELISM: Replaces the N-instances-per-stream-type model with a
   pool-supervisor pattern. Product-builder now launches ONE supervisor per
   stream type, each managing N workers internally. Eliminates batch-and-wait
   tail latency where 15 finished agents waited for 1 slow one. UAT tester
   and bug hunter gain dual-mode operation (pool supervisor + worker) with
   self-dispatch for parallel batches of narrow-scope workers.

2. PR MERGE LIFECYCLE: Fixes PRs being reviewed but never merged. PR self-
   reviewer now uses force_merge (no approval count required), checks CI
   status before merge, uses merge_when_checks_succeed for pending CI, and
   retries 3x on failure. Continuous PR reviewer converted to pool supervisor
   dispatching N parallel reviews, with approved-but-unmerged tracking and
   5-attempt merge retry budget. Stale threshold increased from 5 to 25 min.

3. HUMAN INTERACTION: New ca-human-liaison agent continuously monitors
   Forgejo for developer activity (comments, issues, reviews), responds
   with context-aware replies, triages new issues with full authority,
   decomposes epics into child issues, fills epic/legendary gaps, and
   coordinates spec changes through human-approved PR workflow.

Additionally adds ca-agent-evolver for self-improvement: analyzes agent
performance patterns and proposes targeted modifications to agent
definitions via PRs with 'needs feedback' label (human must approve).

Backlog groomer gains epic/legendary completeness analysis (passes 9-10)
to proactively create missing child issues for parent tickets with gaps.

All agent permission cross-references verified consistent.
2026-04-02 16:12:17 +00:00