# ACTIVE TASK — Aria AI-Company Phase 1 (auto-resume record)

> This is the durable current-work record (the very mechanism KAR-679 builds).
> If Aria/this session restarts: READ THIS, then execute "Next Action" — do NOT wait for a trigger.

## Goal
Implement Aria-AI-Company Phase 1 per `/root/aria/state/ai-company-plan/SPEC-FINAL.md` (all 10 critic fixes baked in) + `CONSTITUTION.md`. Authorized by Kais 2026-06-03 00:37 ("plane extrem genau, dann autonom umsetzen, alle Freigaben, /ultracode + Workflow"). Linear: KAR-679.

## Current Step
Plan finalized (SPEC-FINAL 1406 lines + CONSTITUTION + 7 design docs + adversarial critic). Starting implementation of the SAFE additive files (Steps 1-9 of SPEC-FINAL).

## Next Action
Read `/root/aria/state/ai-company-plan/SPEC-FINAL.md` for the exact file contents, then create the NEW files in order: (1) dir scaffold + `max_concurrent`, (2) 3 role files, (3) `aria-worker-auto-approve.sh`, (4) `aria-worker-start.sh`, (5) `aria-idempotency-check.sh`, (6) `aria-worker.sh`, (7) `aria-worker-stop.sh`, (8) `test-auto-refuse-push.sh`. Verify each with `bash -n`.

## Done So Far (append-only, idempotency log)
- [done] Planning workflow w6cslkvo6 (5 designs + SPEC + critic) + brain-harvest + auto-resume design.
- [done] SPEC-FINAL.md + CONSTITUTION.md written to /root/aria/state/ai-company-plan/.
- [done] Safe sub-scripts created (impl agent): aria-worker-auto-approve.sh (CF fixes), aria-worker-start.sh, aria-idempotency-check.sh, test-auto-refuse-push.sh + roles + vault dirs + max_concurrent. All bash -n pass.
- [done] HAZARD CAUGHT + NEUTRALIZED: a planning design-agent overstepped and wrote a real UNSAFE aria-worker.sh (00:44) missing CF-1/CF-2 (no unset ANTHROPIC_API_KEY, no ARIA_WORKER_NAME guard). Renamed to aria-worker.sh.PLANNING-UNSAFE.bak + chmod -x. Same for aria-worker-stop.sh.PLANNING-UNSAFE.bak. NO runnable aria-worker.sh currently exists.

## Done So Far (continued)
- [done] CORRECT aria-worker.sh (397 lines) + aria-worker-stop.sh (187) written with ALL CF fixes. VERIFIED ON DISK: unset ANTHROPIC_API_KEY (x2), export ARIA_WORKER_NAME before tmux, triple dash-guard (never targets bare "aria"), concurrent cap via tmux list-sessions, watchdog 3600s+disown, flock, mode+active-task before approve loop. stop-script "aria.service" is only a comment. bash -n OK both. => ALL SAFE PHASE-1 FILES DONE + VERIFIED.

## REMAINING (live-touches + demo)
1. [DONE 2026-06-03 ~08:50] session-start.sh CF-1 guard — backup .bak.1780479482, bash -n OK, guard at lines 7-12, functional test: ARIA_WORKER_NAME set → exit 0 no CEO build; CEO session alive. VERIFIED.
3. [DONE 2026-06-03 ~09:00] aria-control.py Team-View (Step 10). 5 additive edits (TEAM_PAGE const + WORKERS_STATE/_WORKER_NAME_RE + 7 helpers + 3 GET routes + 4 POST routes + Team tab). CF-7 applied (cycleMode assist/auto/yolo; _worker_set_mode rejects off). py_compile OK. Restore-point: aria-control.py.bak.1780480713.pre-restart. NOTE: pre-edit backup was MISSED (CF-4 process miss) — edits are additive+reversible, aria-v4/aria-1-1 hold reference copies. Restarted + verified: health online, /status+/activity unaffected, /team HTML, /api/workers ok, off rejected, 404 intact. ALL 6 CHECKS GREEN.
4. [OUT OF SCOPE — Phase 1.5] aria-wrapper.sh auto-resume: SPEC-FINAL §2.2 explicitly leaves aria-wrapper.sh UNTOUCHED. Fleet auto-resume already lives in aria-worker.sh (active-task.md + resume-prompt). CEO self-auto-resume = separate Phase-1.5 track, NOT done in this run (own-restart risk).
5. [DONE 2026-06-03 ~10:06] Supervised 2-worker demo (Step 11). researcher-demo (yolo) + frontend-demo (auto) spawned in parallel via panel-less direct spawn. Auto-resume worked: frontend correctly REFUSED to invent work (waited for brief = crash-loop-safety proven). ALL 5 ACCEPTANCE CRITERIA MET: (1) CEO aria untouched, (2) both parallel, (3) researcher output.md 10 URLs >=3, (4) frontend commit on worker branch (author Kais Aseckzai, +10 lines lib/utils.ts, no push), (5) clean stop — sessions gone, worktree removed+pruned, branch deleted, state archived. Both workers stopped, clean slate verified (0 demo procs).

## BUGS FOUND IN DEMO (fix next)
- BUG-1 (real, minor): aria-worker-stop.sh Step 5 watchdog-kill uses pgrep pattern "aria-worker-stop.sh <name>" but the spawn-script watchdog cmdline is "aria-worker.sh <name>" → orphaned `sleep 3600` watchdog survives stop (had to kill manually). Fires harmless no-op in ~1h. FIX: broaden pattern to also match the spawn-script watchdog subshell, or record watchdog PID in state dir and kill by PID.
- BUG-2 (cosmetic): foreground `bash aria-worker-stop.sh` returns exit 144 (128+16) when it force-kills the tmux session — script itself completes fully (log shows "fully stopped"). Likely SIGSTKFLT/process-group interaction with tmux kill-session. Run stop detached or trap the signal.

## Blockers / Constraints
- LIVE-TOUCH CAUTION: editing `/root/.claude/hooks/session-start.sh` (CF-1 guard) and `/root/aria/scripts/aria-wrapper.sh` (auto-resume) affects THIS Aria's own restart → do with `cp .bak` + `bash -n` verify, never break them. The aria-control.py panel edit needs a mandatory backup first.
- COST: workers must `unset ANTHROPIC_API_KEY` (CF-2). Do NOT leave unsupervised unbounded workers running overnight; demo = short-lived + stopped.
