| 1 | # AutoResearch Runtime Implementation Plan |
| 2 | |
| 3 | > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| 4 | |
| 5 | **Goal:** Implement the host-managed AutoResearch runtime from the design spec, including durable state, controller integration, desktop API, and frontend visibility. |
| 6 | |
| 7 | **Architecture:** Add `internal/autoresearch` as the source of truth for task state under `.reasonix/autoresearch/<task-id>/`. Goal controller code creates, resumes, summarizes, heartbeats, and gates completion through that package. Desktop and frontend read compact status metadata for the active tab and fetch heavier details on demand. |
| 8 | |
| 9 | **Tech Stack:** Go standard library, existing `internal/control` goal FSM, desktop Wails bindings, React/TypeScript frontend, existing Go and frontend test runners. |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## Implementation Tasks |
| 14 | |
| 15 | ### Task 1: AutoResearch Store And Schema |
| 16 | |
| 17 | **Files:** |
| 18 | - Create: `internal/autoresearch/task.go` |
| 19 | - Create: `internal/autoresearch/store.go` |
| 20 | - Create: `internal/autoresearch/schema.go` |
| 21 | - Create: `internal/autoresearch/store_test.go` |
| 22 | |
| 23 | - [ ] Write failing tests that prove `CreateTask` creates `.reasonix/autoresearch/<task-id>/state` and `logs`, writes `task_spec.json`, `progress.json`, empty JSONL files, and validates required fields. |
| 24 | - [ ] Run: `go test ./internal/autoresearch -run 'TestCreateTask|TestValidateTask' -count=1` |
| 25 | - [ ] Implement types, task id generation, atomic JSON writes, JSONL append validation, `CreateTask`, `LoadTask`, `ValidateTask`. |
| 26 | - [ ] Run: `go test ./internal/autoresearch -count=1` |
| 27 | |
| 28 | ### Task 2: Findings, Directions, Summary, Readiness |
| 29 | |
| 30 | **Files:** |
| 31 | - Create: `internal/autoresearch/summary.go` |
| 32 | - Create: `internal/autoresearch/readiness.go` |
| 33 | - Modify: `internal/autoresearch/store.go` |
| 34 | - Modify: `internal/autoresearch/store_test.go` |
| 35 | |
| 36 | - [ ] Write failing tests for `AppendFinding`, `RecordDirection`, stale/pivot thresholds, `Summary`, and `Readiness`. |
| 37 | - [ ] Run: `go test ./internal/autoresearch -run 'TestAppendFinding|TestRecordDirection|TestReadiness|TestSummary' -count=1` |
| 38 | - [ ] Implement accepted evidence lookup, direction fingerprint tracking, stale count updates, pivot requirement, readiness blocking, and compact summary generation. |
| 39 | - [ ] Run: `go test ./internal/autoresearch -count=1` |
| 40 | |
| 41 | ### Task 3: Goal Controller Runtime Integration |
| 42 | |
| 43 | **Files:** |
| 44 | - Modify: `internal/control/goal.go` |
| 45 | - Modify: `internal/control/input.go` |
| 46 | - Modify: `internal/control/controller.go` |
| 47 | - Modify: `internal/control/turn_orchestrator.go` |
| 48 | - Modify: `internal/control/goal_test.go` |
| 49 | - Modify: `internal/control/input_test.go` |
| 50 | |
| 51 | - [ ] Write failing tests that `/goal --research` creates or resumes an AutoResearch task and stores `AutoResearchTaskID` in persisted goal state. |
| 52 | - [ ] Write failing tests that `Compose` injects a host-generated `<autoresearch-runtime>` summary only in the current user turn. |
| 53 | - [ ] Write failing tests that goal completion is intercepted when AutoResearch readiness fails. |
| 54 | - [ ] Run targeted control tests for the new cases. |
| 55 | - [ ] Implement store wiring, create/resume, heartbeat hooks, runtime summary injection, and readiness intercept. |
| 56 | - [ ] Run: `go test ./internal/control -count=1` |
| 57 | |
| 58 | ### Task 4: Desktop API Surface |
| 59 | |
| 60 | **Files:** |
| 61 | - Modify: `desktop/app.go` |
| 62 | - Modify: `desktop/tabs.go` |
| 63 | - Modify: `desktop/app_test.go` |
| 64 | - Modify: `desktop/tab_profile_test.go` |
| 65 | |
| 66 | - [ ] Write failing tests for `AutoResearchStatus`, `AutoResearchCurrent`, `AutoResearchFindings`, and compact tab metadata. |
| 67 | - [ ] Implement view structs and methods that call `internal/autoresearch` without parsing prompt text. |
| 68 | - [ ] Ensure findings are capped and loaded on demand. |
| 69 | - [ ] Run: `go test ./desktop -run 'AutoResearch|MetaReports' -count=1` |
| 70 | |
| 71 | ### Task 5: Frontend Status And Detail UI |
| 72 | |
| 73 | **Files:** |
| 74 | - Modify: `desktop/frontend/src/lib/statusBarItems.ts` |
| 75 | - Modify: `desktop/frontend/src/components/StatusBar.tsx` |
| 76 | - Modify: `desktop/frontend/src/components/ContextPanel.tsx` |
| 77 | - Modify: `desktop/frontend/src/bridge.ts` |
| 78 | - Modify: `desktop/frontend/src/__tests__/statusbar-workspace.test.tsx` |
| 79 | - Add frontend tests for AutoResearch detail rendering. |
| 80 | |
| 81 | - [ ] Write failing frontend tests for hidden chip, running/pivot/blocked labels, opening the detail panel, and rendering loaded findings. |
| 82 | - [ ] Implement compact status chip, tooltip, detail section, refresh hooks, and on-demand findings loading. |
| 83 | - [ ] Run: `pnpm --dir desktop/frontend test` |
| 84 | |
| 85 | ### Task 6: End-To-End Verification |
| 86 | |
| 87 | **Files:** |
| 88 | - Update generated Wails bindings if required. |
| 89 | - No broad refactors. |
| 90 | |
| 91 | - [ ] Run: `go test ./internal/autoresearch ./internal/control ./desktop -count=1` |
| 92 | - [ ] Run: `pnpm --dir desktop/frontend test` |
| 93 | - [ ] Run the desktop app through the project dev command when feasible and manually verify a research goal shows the chip and panel state. |
| 94 | - [ ] Audit each design-spec goal against implementation and record remaining gaps before marking the goal complete. |
| 95 |