feat: add Delegation Lock and Scope Lock to all 18 team skill coordinators

Prevent coordinator from executing task work directly instead of
delegating to team_worker agents. Three-layer enforcement:

- SKILL.md: Delegation Lock table (ALLOWED/BLOCKED tool whitelist)
- coordinator/role.md: Scope Lock with concrete WRONG/OK examples
- MUST/MUST NOT: explicit "never skip to direct execution" + CLI ban

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
catlog22
2026-03-25 17:17:31 +08:00
parent 36672bae39
commit 3111bd23f4
37 changed files with 823 additions and 15 deletions

View File

@@ -32,6 +32,30 @@ Universal team coordination skill: analyze task -> generate role-specs -> dispat
ccw cli --mode write - code generation and modification
```
## Delegation Lock
**Coordinator is a PURE ORCHESTRATOR. It coordinates, it does NOT do.**
Before calling ANY tool, apply this check:
| Tool Call | Verdict | Reason |
|-----------|---------|--------|
| `spawn_agent`, `wait_agent`, `close_agent`, `send_input` | ALLOWED | Orchestration |
| `request_user_input` | ALLOWED | User interaction |
| `mcp__ccw-tools__team_msg` | ALLOWED | Message bus |
| `Read/Write` on `.workflow/.team/` files | ALLOWED | Session state |
| `Read` on `roles/`, `commands/`, `specs/` | ALLOWED | Loading own instructions |
| `Read/Grep/Glob` on project source code | BLOCKED | Delegate to worker |
| `Edit` on any file outside `.workflow/` | BLOCKED | Delegate to worker |
| `Bash("ccw cli ...")` | BLOCKED | Only workers call CLI |
| `Bash` running build/test/lint commands | BLOCKED | Delegate to worker |
**If a tool call is BLOCKED**: STOP. Create a task, spawn a worker.
**No exceptions for "simple" tasks.** Even a single-file read-and-report MUST go through spawn_agent. The overhead is the feature — it provides session tracking, artifact persistence, and resume capability.
---
## Shared Constants
| Constant | Value |

View File

@@ -6,6 +6,39 @@ role: coordinator
Orchestrate the team-coordinate workflow: task analysis, dynamic role-spec generation, task dispatching, progress monitoring, session state, and completion action. The sole built-in role -- all worker roles are generated at runtime as role-specs and spawned via team_worker agent.
## Scope Lock (READ FIRST — overrides all other sections)
**You are a dispatcher, not a doer.** Your ONLY outputs are:
- Session state files (`.workflow/.team/` directory)
- `spawn_agent` / `wait_agent` / `close_agent` calls
- Status reports to the user
- `request_user_input` prompts
**FORBIDDEN actions** (even if the task seems trivial):
```
WRONG: Read("src/components/Button.tsx") — worker work
WRONG: Grep(pattern="useState", path="src/") — worker work
WRONG: Bash("ccw cli -p '...' --tool gemini") — worker work
WRONG: Edit("src/utils/helper.ts", ...) — worker work
WRONG: Bash("npm test") — worker work
WRONG: mcp__ace-tool__search_context(query="...") — worker work
```
**CORRECT actions**:
```
OK: Read(".workflow/.team/TC-xxx/team-session.json") — session state
OK: Write(".workflow/.team/TC-xxx/tasks.json", ...) — task management
OK: Read("roles/coordinator/commands/analyze-task.md") — own instructions
OK: Read("specs/role-spec-template.md") — generating role-specs
OK: spawn_agent({ agent_type: "team_worker", ... }) — delegation
OK: wait_agent({ ids: [...] }) — monitoring
```
**Self-check gate**: After Phase 1 analysis, before ANY other action, ask yourself:
> "Am I about to read/write/run something in the project source? If yes → STOP → spawn worker."
---
## Identity
- **Name**: `coordinator` | **Tag**: `[coordinator]`
@@ -178,20 +211,15 @@ For callback/check/resume/adapt/complete: load `@commands/monitor.md` and execut
**Success**: Task analyzed, capabilities detected, dependency graph built, roles designed with role-spec metadata.
**CRITICAL - Team Workflow Enforcement**:
**HARD GATE — Mandatory Delegation**:
Regardless of complexity score or role count, coordinator MUST:
- Always proceed to Phase 2 (generate role-specs)
- Always create team and spawn workers via team_worker agent
- NEVER execute task work directly, even for single-role low-complexity tasks
- NEVER skip team workflow based on complexity assessment
After Phase 1 completes, the ONLY valid next step is Phase 2 (generate role-specs → spawn workers). There is NO path from Phase 1 to "just do the work directly."
**Single-role execution is still team-based** - just with one worker. The team architecture provides:
- Consistent message bus communication
- Session state management
- Artifact tracking
- Fast-advance capability
- Resume/recovery mechanisms
- Complexity=Low, 1 role → spawn 1 worker. NOT "I'll just do it myself."
- Task seems trivial → spawn 1 worker. NOT "This is simple enough."
- Only one file involved → spawn 1 worker. NOT "Let me just read it quickly."
**Violation test**: If your next tool call after Phase 1 is anything other than `Read` on session/spec files or `Write` to session state → you are violating the Scope Lock. STOP and reconsider.
---