agent-valley 0.3.0 → 1.0.1

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 ADDED
@@ -0,0 +1,505 @@
1
+ # Agent Valley
2
+
3
+ Give a Chief Director a goal for service improvement, refactoring, usability, or revenue growth. It uses installed OMA skills and Technical Director, Design Director, and Marketing Director personas to choose skills, assign Actors, review work, repair or replan, and verify progress. Its report explains the decisions, reasons, results, and verification evidence. Actors work in isolated Git worktrees; Linear/GitHub issues also support queued, parallel work.
4
+
5
+ > Read this in: [한국어](./README.ko.md)
6
+
7
+ > **Token usage warning:** AV prioritizes your goal over token savings. Planning, persona consultation, Actor work, independent reviews, repairs, and replanning can consume substantial model usage and incur API charges. AV does not check or manage your subscription's remaining allowance. Reported usage is recorded; optional estimated-cost limits and execution limits still apply.
8
+
9
+ ```
10
+ Linear Issue (Todo)
11
+ → Webhook → Orchestrator → Git Worktree → Actor Session
12
+ → Completion → Merge/PR → Done
13
+ ```
14
+
15
+ Tracker mode manages lifecycle transitions (Todo → In Progress → Done/Cancelled) and delivers verified changes. Chief Director orders keep a local plan, task reviews, and verification results for a goal.
16
+
17
+ Built with **TypeScript + Bun**. Supports **Claude Code, Codex, Qwen Code, Antigravity, Cursor, Grok, Kimi, and OpenCode** through the AgentSession interface.
18
+
19
+ See the [operability audit](./docs/reports/operability-audit-2026-10-03.md) for tested user journeys, fixes, and remaining limits.
20
+
21
+ ---
22
+
23
+ ## How It Works
24
+
25
+ 1. Create an issue on Linear or GitHub (or `bun av issue "description"`)
26
+ 2. The tracker sends a webhook to the dashboard
27
+ 3. Orchestrator verifies HMAC signature, transitions the issue to In Progress
28
+ 4. DAG scheduler checks dependencies — blocked issues wait until blockers complete
29
+ 5. WorkspaceManager creates an isolated git worktree under `workspace.root`
30
+ 6. AgentRunnerService starts the configured actor CLI
31
+ 7. After verification: merge and push or create a PR, post a tracker summary, transition to Done
32
+ 8. On failure: exponential backoff retry (60s × 2^n, max 3 attempts), then cancel with error comment
33
+ 9. Slot refill: completed actors free up capacity, next waiting issue starts automatically
34
+
35
+ Multiple issues run in parallel up to `actor.max_parallel` (auto-detected from hardware).
36
+
37
+ ---
38
+
39
+ ## Quick Start
40
+
41
+ For agent-led setup, give a local shell-capable agent [AGENT_SETUP.md](./AGENT_SETUP.md) and the target repository. That user-facing initiating agent becomes the Chief Director, keeps its confirmed current model or saves the native default when the exact model is unknown, prepares AV/OMA/project MCP, and reports readiness without starting a mission. Delegating installation to a worker preserves the initiating session's vendor/model.
42
+
43
+ ```text
44
+ /absolute/path/to/repo에 AV를 설치하고 설정해줘.
45
+ https://raw.githubusercontent.com/first-fluke/agent-valley/main/AGENT_SETUP.md 를 따라
46
+ 너 자신을 Chief Director로 지정하고, 실제 완료 항목과 남은 조치를 보고해줘.
47
+ AV 설치, OMA 준비, 프로젝트 MCP 설정을 승인한다. 확인용 미션은 실행하지 마.
48
+ ```
49
+
50
+ For interactive setup, run the installer from the Git repository you want actors to work on. It prepares Node.js 26.10.0 and Bun 1.4.2 when needed, installs `av`, and opens the setup wizard in an interactive terminal.
51
+
52
+ ```bash
53
+ cd /absolute/path/to/repo
54
+ curl -fsSL https://raw.githubusercontent.com/first-fluke/agent-valley/main/scripts/install.sh | bash
55
+ export PATH="$HOME/.local/bin:$PATH"
56
+ ```
57
+
58
+ The interactive wizard asks for the target repository and Chief Director CLI and model, and can save a trusted verification command. Agent-led setup passes the initiating agent's own runtime and model choice to `av setup --yes --json`. Setup guides provider preparation and prepares the latest OMA CLI and skills in the target repository. OMA preparation is the default. Browser sign-in and unsupported readiness checks remain concrete pending actions. The repository must have at least one commit. After setup is ready, give AV a goal with `av order "Fix the login failure"`. See the [installation, first-task and recovery guide](./docs/guides/environment-setup.md).
59
+
60
+ The Chief Director consults its Technical Director, Design Director and Marketing Director concurrently, turns the goal into success criteria and executable checks, creates 4–8 Actors including those advisers, and assigns work using available supported CLIs and installed OMA skills. Up to three independent Actors run in separate worktrees by default; reviewed changes are integrated before dependent work and final verification. Use `--parallel 1` for serial execution. The Technical Director focuses on cost, reuse, standardization and dependencies; the Design Director focuses on usability, user tests, data and retention, including a preference for dark patterns; the Marketing Director focuses on promotion, acquisition, revenue and ROI. The Chief Director reviews evidence and decides whether to repair, reassign, or replan when work fails. Each order produces a report with a plain-language explanation, checks, and remaining limits. Orders start without a tracker or daemon. `--actor` and `--model` override the saved Chief Director choice for one order; `--actors` supplies your own team. See [Chief Director orders and named actors](./docs/guides/chief-missions.md).
61
+
62
+ Without `--verify` or a saved command, the Chief Director designs fixed file, JSON, or explicit test checks bound to the original success criteria. A supplied command remains immutable. The foreground supervisor resumes child crashes and scheduled retries within saved limits; `--no-supervise` runs directly and `av missions --watch` restores eligible checkpoints after a stopped supervisor or machine. Authentication and uncertain external effects pause for inspection. `--runs`, `--duration`, `--rounds`, and the configured-price estimate limit `--cost` can be increased on resume without resetting spent budgets. Unknown cost pauses when a cost limit is set; in-flight or subscription charges are not an exact billing cap.
63
+
64
+ The Chief Director chooses how to execute and supervise the work. The user retains operational responsibility for the goal and resulting actions; the report records those actions and their verification evidence.
65
+
66
+ Orders also record actual token usage, duration and review outcomes for routing, select different available CLI types for task review, reuse repository organization evidence and enforce configured business metric targets. User-configured Stripe revenue, HTTP JSON, or file sources provide real observations; orders wait for the measurement window and unmet targets remain incomplete. Optional reporting sends actual report, screenshot and video files through replaceable Slack, Discord, Telegram, Teams, Google Chat, Mattermost or webhook adapters. Aside MCP captures the configured browser target; MP4 encoding requires ffmpeg. See [operations and report attachments](./docs/guides/chief-integrations.md).
67
+
68
+ For issue tracker automation, use an Agent Valley source checkout containing `apps/dashboard`. Run `bun av setup --mode tracker`, then `bun av doctor` and `bun av up --dev` there. Set `workspace.root` to the repository actors should work on.
69
+
70
+ The CLI attempts automatic Linear webhook registration. For manual registration use `{url}/api/webhook`; GitHub uses `{url}/api/webhook/github`.
71
+ The default tunnel provider is ngrok; set `tunnel.provider: cloudflare` in `av.yaml` to use Cloudflare Tunnel (see Configuration below).
72
+
73
+ ---
74
+
75
+ ## CLI
76
+
77
+ ```bash
78
+ bun av setup # Local orders: repository, Chief Director, login, OMA, verification
79
+ bun av setup --yes --actor codex --model '' --workspace /absolute/path/to/repo --json # Codex initiator, explicit user target
80
+ bun av setup --mode tracker # Linear/GitHub automation setup
81
+ bun av doctor # Validate configuration and runtime prerequisites
82
+ bun av dev # Start in foreground (file watching + auto-restart)
83
+ bun av up --dev # Start background daemon without a production build
84
+ bun av up # Build dashboard, then start background daemon
85
+ bun av down # Stop background daemon
86
+ bun av status # Query orchestrator status
87
+ bun av top # Live actor status monitor
88
+ bun av logs # Tail dashboard logs (-n for line count)
89
+ bun av login # Login to team (Supabase auth)
90
+ bun av logout # Logout from team
91
+ bun av invite # Copy team config to clipboard
92
+ bun av order --help # Give a Chief Director a goal; --verify supplies an optional trusted command
93
+ bun av missions # List saved local Chief Director orders
94
+ bun av missions --watch # Resume eligible saved orders and scheduled observations
95
+ bun av reports list # Inspect third-party delivery receipts
96
+ bun av reports retry # Retry saved report files without running Actors
97
+ bun av integrations install # Install AV skills and MCP entries for Codex, Claude Code, Cursor, Qwen, and Antigravity
98
+ bun av mcp --workspace /absolute/project # Expose local Chief Director mission tools over stdio
99
+ ```
100
+
101
+ To delegate goals from Codex, Claude Code, Cursor, Qwen Code, or Antigravity, install the project `av` skill and MCP server, then restart the client and complete its normal trust step. AV also exports [native plugin packages](./docs/guides/native-plugins.md) and supplies a [web OAuth gateway](./docs/guides/web-mcp.md) for ChatGPT and Claude. See [agent client integration](./docs/guides/agent-clients.md).
102
+
103
+ ### Creating Issues
104
+
105
+ ```bash
106
+ bun av issue "fix auth bug" # Create issue (Claude expands description)
107
+ bun av issue "fix auth bug" --raw # Create without expansion
108
+ bun av issue "fix auth bug" --yes # Skip confirmation
109
+ bun av issue "add tests" --parent ACR-10 # Create as sub-issue
110
+ bun av issue "migrate db" --blocked-by ACR-5 # Set dependency
111
+ bun av issue "refactor auth" --breakdown # Auto-decompose into sub-tasks
112
+ ```
113
+
114
+ `--parent`, `--blocked-by`, and `--breakdown` require Linear. GitHub supports plain issue creation and `--scope`; `--raw` works with either tracker without Claude expansion.
115
+
116
+ ---
117
+
118
+ ## Configuration
119
+
120
+ ### Config Files
121
+
122
+ Two YAML config files, merged at startup (project wins over global):
123
+
124
+ | File | Scope | Description |
125
+ |---|---|---|
126
+ | `~/.config/agent-valley/settings.yaml` | Global (user) | API key, actor defaults, team dashboard |
127
+ | `av.yaml` | Project | Team config, workspace root, prompt template, routing |
128
+
129
+ Run `av setup` to create both files interactively, or follow [agent-led setup](./AGENT_SETUP.md) for an unattended installation using the initiating agent as Chief Director. See `av.example.yaml` for format reference.
130
+
131
+ Project configuration uses only `av.yaml`; setup and edits save that file. Configuration uses `actor:`. Actor profiles use `director`, `actors`, and `actorType`; existing profile fields and CLI flags remain aliases.
132
+
133
+ ### Global Config (`~/.config/agent-valley/settings.yaml`)
134
+
135
+ ```yaml
136
+ linear:
137
+ api_key: lin_api_xxx
138
+
139
+ actor:
140
+ type: claude # Default actor: claude / codex / antigravity / cursor / grok / kimi / opencode
141
+ timeout: 3600
142
+ max_retries: 3
143
+ max_parallel: 3 # Max concurrent actor runs (default: hardware-detected recommendation)
144
+
145
+ logging:
146
+ level: info # debug / info / warn / error
147
+ format: json # json / text
148
+
149
+ server:
150
+ port: 9741
151
+
152
+ # Team Dashboard (optional)
153
+ team:
154
+ supabase_url: https://xxx.supabase.co
155
+ supabase_anon_key: your-anon-key
156
+ id: my-team
157
+ display_name: my-node
158
+ ```
159
+
160
+ ### Project Config (`av.yaml`)
161
+
162
+ ```yaml
163
+ # Tracker selector (v0.2+). Defaults to `linear` when omitted.
164
+ tracker:
165
+ kind: linear # linear | github
166
+
167
+ linear:
168
+ team_id: ACR
169
+ team_uuid: uuid-xxx
170
+ webhook_secret: whsec_xxx
171
+ workflow_states:
172
+ todo: state-uuid
173
+ in_progress: state-uuid
174
+ done: state-uuid
175
+ cancelled: state-uuid
176
+
177
+ # GitHub tracker (v0.2+) — used when tracker.kind = github.
178
+ # github:
179
+ # token_env: GITHUB_TOKEN
180
+ # owner: my-org
181
+ # repo: my-repo
182
+ # webhook_secret: whsec_xxx
183
+ # labels:
184
+ # todo: valley:todo
185
+ # in_progress: valley:wip
186
+ # done: valley:done
187
+ # cancelled: valley:cancelled
188
+
189
+ workspace:
190
+ root: /absolute/path/to/target-repo
191
+
192
+ delivery:
193
+ mode: merge # merge (auto merge+push) or pr (create draft PR)
194
+
195
+ prompt: |
196
+ You are working on {{issue.identifier}}: {{issue.title}}.
197
+ {{issue.description}}
198
+ Path: {{workspace_path}}
199
+
200
+ # Multi-Repo Routing (optional)
201
+ routing:
202
+ rules:
203
+ - label: "backend"
204
+ workspace_root: /path/to/backend
205
+ - label: "frontend"
206
+ workspace_root: /path/to/frontend
207
+ actor_type: codex
208
+ delivery_mode: pr
209
+ verify_command: "pytest && mypy ." # overrides verify.command below for this route
210
+
211
+ # Verification Gate (required for code tasks). Runs before delivery and before the
212
+ # issue transitions to Done; on failure the actor retries with the captured
213
+ # output as context. Set this to commands available in the target repository.
214
+ verify:
215
+ command: "bun run typecheck && bun run test"
216
+ timeout_sec: 600
217
+
218
+ # Score-Based Routing (optional)
219
+ scoring:
220
+ model: haiku
221
+ routes:
222
+ easy: { min: 1, max: 3, actor: antigravity }
223
+ medium: { min: 4, max: 7, actor: codex }
224
+ hard: { min: 8, max: 10, actor: claude }
225
+
226
+ # Actor Budget Caps (optional, v0.2+). Omit to disable (default).
227
+ # budget:
228
+ # per_issue:
229
+ # tokens: 2_000_000
230
+ # usd: 5.00
231
+ # per_day:
232
+ # tokens: 20_000_000
233
+ # usd: 50.00
234
+
235
+ # Webhook tunnel (optional, v0.3+). Omit to keep the v0.2 default (ngrok).
236
+ # tunnel:
237
+ # provider: cloudflare # cloudflare | ngrok | none
238
+ # cloudflare:
239
+ # mode: quick # quick (random *.trycloudflare.com URL) | named
240
+ # # name: av-webhook # required when mode: named
241
+ # # hostname: webhook.example.com # UI-only, used when mode: named
242
+
243
+ # Observability (optional, v0.2+). Both default to off.
244
+ # observability:
245
+ # otel:
246
+ # enabled: false
247
+ # endpoint: http://localhost:4318
248
+ # service_name: agent-valley
249
+ # prometheus:
250
+ # enabled: false
251
+ # path: /api/metrics
252
+ ```
253
+
254
+ **Prompt template variables:** `{{issue.identifier}}`, `{{issue.title}}`, `{{issue.description}}`, `{{workspace_path}}`, `{{attempt.id}}`, `{{retry_count}}`
255
+
256
+ ---
257
+
258
+ ## Architecture
259
+
260
+ ### Monorepo Structure
261
+
262
+ ```
263
+ agent-valley/
264
+ ├── apps/
265
+ │ ├── cli/ @agent-valley/cli — Commander CLI (bun av)
266
+ │ └── dashboard/ agent-valley-dashboard — Next.js 16 + PixiJS
267
+ ├── packages/
268
+ │ └── core/ @agent-valley/core — Orchestration engine
269
+ │ └── src/
270
+ │ ├── config/ YAML config loader (settings.yaml + av.yaml)
271
+ │ ├── domain/ Pure types: Issue, Workspace, RunAttempt, DAG
272
+ │ ├── orchestrator/ State machine, actor runner, retry queue, DAG scheduler
273
+ │ ├── sessions/ Actor plugins: Claude, Codex, Antigravity
274
+ │ ├── tracker/ Linear GraphQL client + webhook HMAC verification
275
+ │ ├── workspace/ Git worktree lifecycle + merge/PR
276
+ │ └── observability/ Structured JSON/text logger
277
+ ├── docs/
278
+ │ ├── architecture/ LAYERS.md, CONSTRAINTS.md, enforcement/
279
+ │ ├── specs/ Symphony 7-component interface specs
280
+ │ ├── stacks/ TypeScript, Python, Go guides
281
+ │ └── harness/ SAFETY.md, LEGIBILITY.md, ENTROPY.md, FEEDBACK-LOOPS.md
282
+ ├── scripts/
283
+ │ ├── dev.sh Dev environment bootstrap
284
+ │ ├── install.sh Harness installer (new + existing projects)
285
+ │ └── harness/
286
+ │ ├── validate.sh Architecture validation (secrets, layer violations)
287
+ │ └── gc.sh Worktree garbage collector
288
+ ├── AGENTS.md Actor instructions (shared entry point)
289
+ ├── AGENT_SETUP.md Agent-led installation and readiness procedure
290
+ ├── CLAUDE.md Claude Code project instructions
291
+ └── av.example.yaml Project config template
292
+ ```
293
+
294
+ ### Clean Architecture Layers
295
+
296
+ ```
297
+ Presentation dashboard route handlers (no business logic)
298
+ ↓
299
+ Application Orchestrator (core / lifecycle / router / bus), AgentRunnerService
300
+ ↓
301
+ Domain Issue, Workspace, RunAttempt, DAG, ParsedWebhookEvent (pure types)
302
+ + ports: IssueTracker, WebhookReceiver, WorkspaceGateway, AgentRunnerPort
303
+ ↓
304
+ Infrastructure Linear + GitHub adapters, git operations, actor sessions, observability
305
+ ```
306
+
307
+ Dependency arrows point **downward only**. See `docs/architecture/LAYERS.md`.
308
+
309
+ ### Domain Port Layer
310
+
311
+ Since v0.2 the Application layer talks to the outside world through four
312
+ domain ports so adapters can be swapped without touching the orchestrator:
313
+
314
+ | Port | Purpose | Current adapters |
315
+ |---|---|---|
316
+ | `IssueTracker` | Fetch / update issues, post comments, attach labels | `LinearTrackerAdapter`, `GitHubTrackerAdapter` |
317
+ | `WebhookReceiver<TEvent>` | Verify signature + parse to `ParsedWebhookEvent` | `LinearWebhookReceiver`, `GitHubWebhookReceiver` |
318
+ | `WorkspaceGateway` | Per-issue worktree lifecycle + delivery | `FileSystemWorkspaceGateway` |
319
+ | `AgentRunnerPort` | Spawn actors + expose `RunHandle` for interventions | `SpawnAgentRunnerAdapter` |
320
+
321
+ ### The 7 Symphony Components
322
+
323
+ | # | Component | Responsibility | Spec |
324
+ |---|---|---|---|
325
+ | 1 | **Workflow Loader** | Prompt template rendering + input sanitization | `docs/specs/workflow-loader.md` |
326
+ | 2 | **Config Layer** | YAML config loader (settings.yaml + av.yaml) + Zod validation | `docs/specs/config-layer.md` |
327
+ | 3 | **Tracker Client** | Linear GraphQL — fetch issues, state transitions, comments, HMAC verification | `docs/specs/tracker-client.md` |
328
+ | 4 | **Orchestrator** | Webhook event handler, state machine, retry queue, DAG scheduler | `docs/specs/orchestrator.md` |
329
+ | 5 | **Workspace Manager** | Per-issue git worktree creation, merge/PR, cleanup | `docs/specs/workspace-manager.md` |
330
+ | 6 | **Actor Runner** | AgentSession abstraction, timeout enforcement, parallel execution | `docs/specs/agent-runner.md` |
331
+ | 7 | **Observability** | Structured JSON logs, system metrics, SSE status surface | `docs/specs/observability.md` |
332
+
333
+ ### Actor Session Plugins
334
+
335
+ | Actor | Config value | Executable |
336
+ |---|---|---|
337
+ | Claude Code | `claude` | `claude` |
338
+ | Codex | `codex` | `codex` |
339
+ | Qwen Code | `qwen` | `qwen` |
340
+ | Antigravity | `antigravity` | `agy` |
341
+ | Cursor | `cursor` | `cursor-agent` |
342
+ | Grok | `grok` | `grok` |
343
+ | Kimi | `kimi` | `kimi` |
344
+ | OpenCode | `opencode` | `opencode` |
345
+
346
+ Extensible via `registerSession()` — implement the `AgentSession` interface to add custom actors.
347
+
348
+ ---
349
+
350
+ ## Dashboard
351
+
352
+ PixiJS-rendered office scene showing real-time actor status:
353
+
354
+ - **Actor characters** at desks with issue identifier bubbles
355
+ - **Office visualization** — desks scale to `actor.max_parallel`, coffee machine, server rack, etc.
356
+ - **Operations panel** — dependency blockers, retry reasons and next retry times
357
+ - **System metrics** — CPU, memory, uptime
358
+ - **SSE real-time events** — instant updates on actor.start, actor.done, actor.failed
359
+ - **Team HUD** — multi-node view (requires Supabase config)
360
+
361
+ ### API Endpoints
362
+
363
+ | Endpoint | Method | Description |
364
+ |---|---|---|
365
+ | `/api/webhook` | POST | Linear webhook receiver (HMAC-SHA256 verified) |
366
+ | `/api/webhook/github` | POST | GitHub webhook receiver (HMAC-SHA256 verified) |
367
+ | `/api/events` | GET | SSE stream for real-time dashboard updates |
368
+ | `/api/status` | GET | JSON orchestrator status snapshot |
369
+ | `/api/health` | GET | Health check (503 if the orchestrator is unavailable or stopped) |
370
+ | `/api/intervention` | POST | Live actor intervention; local by default, token-authenticated when configured |
371
+ | `/api/metrics` | GET | Prometheus-format metrics (enabled via `observability.prometheus.enabled`) |
372
+
373
+ ---
374
+
375
+ ## Key Features
376
+
377
+ ### GitHub Issues Support (v0.2+)
378
+
379
+ Alongside Linear, GitHub Issues can drive the orchestrator. Set `tracker.kind: github` in `av.yaml` and configure the GitHub section — the domain `IssueTracker` / `WebhookReceiver` ports swap transparently. Both trackers reuse the same orchestration, retry, and delivery pipeline.
380
+
381
+ ### Observability (v0.2+)
382
+
383
+ OpenTelemetry OTLP HTTP traces and Prometheus metrics ship built in but **default to off**. Enable per deployment via the `observability` section in `av.yaml`. When enabled:
384
+
385
+ - OTel spans are emitted for actor start/done/failed + webhook + DAG events.
386
+ - Prometheus metrics are served from `GET /api/metrics` (active actors, retry queue size, completion counts, failure counts, DAG cycle detections).
387
+
388
+ ### Actor Budget Caps (v0.2+)
389
+
390
+ Per-issue and per-day token / cost caps prevent runaway actors. Budgets are evaluated before each spawn (`BudgetService.checkBeforeSpawn`) — when exceeded, the issue is cancelled with an actionable comment instead of spawning.
391
+
392
+ ### Live Intervention (v0.2+)
393
+
394
+ Mid-run control from the dashboard via `POST /api/intervention`:
395
+
396
+ - `pause` / `resume` — Codex native (JSON-RPC)
397
+ - `append_prompt` — native on Codex / Antigravity ACP; cancel + respawn on stateless Claude
398
+ - `abort` — force-kill the session
399
+
400
+ Commands flow through `InterventionBus`. Without a configured intervention token, only local requests are accepted. Setting `SYMPHONY_INTERVENTION_TOKEN` requires a matching bearer token or browser session on every request, including local requests. The remote flag is not needed when a token is configured; setting `SYMPHONY_ALLOW_REMOTE_INTERVENTION=1` without a token rejects all requests. See [dashboard access](./docs/guides/environment-setup.md#dashboard-and-webhook-access).
401
+
402
+ ### DAG Dependency Scheduling
403
+
404
+ Issues with `blocked_by` relations wait until all blockers complete. On blocker completion, the DAG scheduler cascades and dispatches unblocked issues. Cycles are detected and ignored.
405
+
406
+ ### Retry Queue
407
+
408
+ Failed actor runs are retried with exponential backoff (`60s × 2^(attempt-1)`, max 3 attempts). Workspace creation failures and state transition failures are also retried. Max retries exceeded → issue cancelled with error comment.
409
+
410
+ ### Safety Net
411
+
412
+ - Detects uncommitted actor work and auto-commits before delivery
413
+ - Creates safety-net draft PRs in PR mode
414
+ - Graceful shutdown on SIGTERM/SIGINT — stops all running actors
415
+ - Hot reload cleanup — previous orchestrator instance stopped before new one starts
416
+
417
+ ### Startup Sync
418
+
419
+ On boot, the orchestrator fetches all Todo + In Progress issues from the configured tracker and reconciles the DAG cache. Existing in-progress issues resume automatically.
420
+
421
+ ---
422
+
423
+ ## Development
424
+
425
+ ```bash
426
+ bun run test # Run the Vitest suite
427
+ bun run lint # Lint (biome)
428
+ bun run lint:fix # Auto-fix lint issues
429
+ ./scripts/harness/validate.sh # Architecture validation
430
+ ./scripts/dev.sh # Bootstrap dev environment
431
+ ./scripts/harness/gc.sh # Garbage-collect stale worktrees
432
+ ```
433
+
434
+ ### Install Harness into Existing Project
435
+
436
+ ```bash
437
+ cd your-existing-project
438
+ curl -fsSL https://raw.githubusercontent.com/first-fluke/agent-valley/main/scripts/install.sh | bash
439
+ ```
440
+
441
+ ### CI/CD
442
+
443
+ | Workflow | Trigger | Purpose |
444
+ |---|---|---|
445
+ | `ci.yml` | Push/PR to main | `validate.sh` + tests |
446
+ | `harness-gc.yml` | Weekly (Sunday 00:00 UTC) | Stale worktree cleanup |
447
+
448
+ ---
449
+
450
+ ## Security
451
+
452
+ - **HMAC-SHA256** webhook signature verification on all incoming Linear and GitHub events
453
+ - **Prompt injection defense** — prompt template in `av.yaml` is trusted, issue body is always sanitized at entry point
454
+ - **Least privilege** — actors operate only within their assigned worktree
455
+ - **Secret management** — secrets in `av.yaml` and `settings.yaml` (gitignored), pre-commit secret detection
456
+ - **Fetch timeout** — 30s timeout on all tracker API calls
457
+ - **Intervention access** — local by default. A configured `SYMPHONY_INTERVENTION_TOKEN` requires authentication for local and remote requests. Browser mutations require a matching Origin; a valid bearer token also authorizes API clients. The remote flag without a token rejects all requests.
458
+ - **Sandbox execution** — every spawned actor CLI runs inside an OS-level sandbox (`sandbox-exec` on macOS, `bwrap` on Linux); spawns fail closed if no sandbox is available unless `SYMPHONY_ALLOW_UNSANDBOXED=1` is explicitly set
459
+ - **Audit logging** — all actor actions logged in structured JSON
460
+
461
+ Full documentation: `docs/harness/SAFETY.md`
462
+
463
+ ---
464
+
465
+ ## Architecture Constraints
466
+
467
+ | # | Rule | Rationale |
468
+ |---|---|---|
469
+ | 1 | No framework imports in Domain layer | Domain stays pure and testable |
470
+ | 2 | No business logic in routers | Presentation delegates to Application |
471
+ | 3 | No hardcoded secrets | Config YAML only (gitignored) |
472
+ | 4 | Issue body is untrusted | Sanitize at boundary |
473
+ | 5 | Max 500 lines per file | Readability |
474
+ | 6 | No shared mutable state outside Orchestrator | Single state authority |
475
+ | 7 | Error messages must include fix instructions | Agents self-correct from errors |
476
+
477
+ Full list with examples: `docs/architecture/CONSTRAINTS.md`
478
+
479
+ ---
480
+
481
+ ## For AI Agents
482
+
483
+ If you are an AI actor reading this repository, see **[AGENTS.md](./AGENTS.md)** for detailed setup instructions, conventions, and implementation guidance.
484
+
485
+ Claude Code sub-agents are available in `.claude/agents/`:
486
+ - `symphony-architect.md` — Architecture decisions, SPEC interpretation
487
+ - `symphony-implementer.md` — Feature implementation with preflight checks
488
+ - `symphony-reviewer.md` — Code review using PR template framework
489
+
490
+ ---
491
+
492
+ ## Metrics
493
+
494
+ | Metric | Description |
495
+ |---|---|
496
+ | **Time to PR** | Issue assigned → PR created |
497
+ | **CI pass rate** | PRs that pass CI on the first run |
498
+ | **Review time per PR** | Average human reviewer time per PR |
499
+ | **Doc freshness** | Days since `AGENTS.md` last updated (flag if > 30 days) |
500
+
501
+ ---
502
+
503
+ ## License
504
+
505
+ [AGPL-3.0](LICENSE)