loadout-ai 0.8.0 → 0.9.0

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +76 -1
  2. package/README.md +149 -304
  3. package/SECURITY.md +21 -1
  4. package/catalog/discovered.json +27897 -25327
  5. package/catalog/packages.json +4 -4
  6. package/dist/src/cli.js +12 -4
  7. package/dist/src/commands/agents.js +3 -1
  8. package/dist/src/commands/catalog-candidate.js +150 -0
  9. package/dist/src/commands/catalog-workflows.js +147 -0
  10. package/dist/src/commands/catalog.js +9 -354
  11. package/dist/src/commands/coordinate.js +586 -0
  12. package/dist/src/commands/coordination-discussions.js +194 -0
  13. package/dist/src/commands/coordination-sessions.js +197 -0
  14. package/dist/src/commands/inventory.js +4 -2
  15. package/dist/src/core/{routing → agents}/model-config.js +7 -2
  16. package/dist/src/core/catalog/catalog.js +1 -0
  17. package/dist/src/core/catalog/registry.js +5 -19
  18. package/dist/src/core/coordination/adapters/claude-code.js +154 -0
  19. package/dist/src/core/coordination/adapters/codex.js +137 -0
  20. package/dist/src/core/coordination/adapters/types.js +64 -0
  21. package/dist/src/core/coordination/auth.js +59 -0
  22. package/dist/src/core/coordination/bridge-lease.js +79 -0
  23. package/dist/src/core/coordination/conflict-preview.js +167 -0
  24. package/dist/src/core/coordination/contract-diff.js +106 -0
  25. package/dist/src/core/coordination/coordinator.js +552 -0
  26. package/dist/src/core/coordination/crash-recovery.js +169 -0
  27. package/dist/src/core/coordination/daemon.js +667 -0
  28. package/dist/src/core/coordination/discussion.js +340 -0
  29. package/dist/src/core/coordination/events.js +161 -0
  30. package/dist/src/core/coordination/http-api.js +118 -0
  31. package/dist/src/core/coordination/interrupt-policy.js +89 -0
  32. package/dist/src/core/coordination/lock.js +110 -0
  33. package/dist/src/core/coordination/mcp-server.js +424 -0
  34. package/dist/src/core/coordination/redaction.js +85 -0
  35. package/dist/src/core/coordination/replay.js +188 -0
  36. package/dist/src/core/coordination/retention.js +128 -0
  37. package/dist/src/core/coordination/runtime.js +21 -0
  38. package/dist/src/core/coordination/session-manager.js +366 -0
  39. package/dist/src/core/coordination/watcher.js +128 -0
  40. package/dist/src/core/{routing → delegation}/first-party-skills.js +25 -13
  41. package/dist/src/core/{routing → delegation}/handoff.js +40 -9
  42. package/dist/src/core/discovery/candidate-intelligence-evidence.js +108 -0
  43. package/dist/src/core/discovery/candidate-intelligence-types.js +1 -0
  44. package/dist/src/core/discovery/candidate-intelligence-validation.js +108 -0
  45. package/dist/src/core/discovery/candidate-intelligence.js +3 -214
  46. package/dist/src/core/discovery/community.js +12 -4
  47. package/dist/src/core/discovery/github-discovery.js +6 -2
  48. package/dist/src/core/discovery/private-discovery.js +6 -2
  49. package/dist/src/core/install/reconcile.js +1 -1
  50. package/dist/src/core/install/uninstall.js +39 -3
  51. package/dist/src/core/reporting/cli-guide.js +9 -5
  52. package/dist/src/core/reporting/completion.js +43 -38
  53. package/dist/src/core/reporting/doctor.js +1 -1
  54. package/dist/src/core/runtime/bounded-json.js +65 -0
  55. package/dist/src/core/runtime/github.js +30 -16
  56. package/dist/src/core/runtime/mcp-recipes.js +1 -1
  57. package/dist/src/core/workspace/active-policy.js +1 -1
  58. package/docs/DEMO_SCRIPT.md +19 -23
  59. package/docs/DISCOVERED.md +251 -251
  60. package/docs/FEATURE_TEST_MATRIX.md +3 -3
  61. package/docs/LIVE_COLLABORATION.md +234 -0
  62. package/docs/REFERENCE.md +163 -0
  63. package/docs/RELEASE_REVIEW.md +1 -1
  64. package/docs/TESTING.md +17 -1
  65. package/docs/USER_TEST_GUIDE.md +138 -3
  66. package/docs/assets/loadout-discover-activate.webp +0 -0
  67. package/docs/assets/loadout-handoff-coordinate.webp +0 -0
  68. package/docs/assets/loadout-social-preview.png +0 -0
  69. package/docs/decisions/001-coordination-jsonl-locking.md +35 -0
  70. package/docs/decisions/002-local-daemon-authentication.md +32 -0
  71. package/docs/decisions/003-bounded-agent-discussions.md +91 -0
  72. package/docs/specs/BOUNDED_AGENT_DISCUSSIONS.md +169 -0
  73. package/docs/superpowers/plans/2026-09-03-coordination-hardening.md +231 -0
  74. package/docs/superpowers/plans/2026-09-03-release-readiness.md +232 -0
  75. package/docs/superpowers/plans/2026-09-04-bounded-agent-discussions.md +121 -0
  76. package/package.json +13 -4
  77. package/skills/loadout-handoff/SKILL.md +238 -0
  78. package/dist/src/core/routing/policy.js +0 -147
  79. package/dist/src/core/routing/route.js +0 -411
  80. package/docs/assets/loadout-workflow.png +0 -0
  81. package/skills/loadout-router/SKILL.md +0 -85
  82. /package/dist/src/core/{routing → agents}/credentials.js +0 -0
@@ -0,0 +1,32 @@
1
+ # ADR 002: Loopback-only authenticated coordination daemon
2
+
3
+ - Status: accepted
4
+ - Date: 2026-09-03
5
+
6
+ ## Context
7
+
8
+ A localhost HTTP service is still reachable by browser pages, local malware,
9
+ and other users on an incorrectly configured machine. Coordination events can
10
+ contain private repository structure and can influence paid provider turns.
11
+
12
+ ## Decision
13
+
14
+ Bind the daemon only to `127.0.0.1`. Generate a random 32-byte project token in
15
+ `.handoff/daemon.token` with mode `0600`. REST and SSE require a bearer header;
16
+ query-string tokens are rejected. Validate loopback Host headers and allow only
17
+ same-origin browser requests.
18
+
19
+ The CLI passes the token to the dashboard in a URL fragment. The dashboard
20
+ moves it into session storage immediately and removes the fragment from browser
21
+ history. Human-readable status does not expose the project root. Request bodies,
22
+ routes, cursors, agent names, and typed event payloads are bounded and validated.
23
+
24
+ ## Consequences
25
+
26
+ - The dashboard opens conveniently without putting credentials in HTTP request
27
+ URLs or referrers.
28
+ - API clients must explicitly read the local token and set `Authorization`.
29
+ - The daemon is observability and local transport only; it is not supported as
30
+ a LAN or internet-facing service.
31
+ - Activating the project kill switch fails closed across storage, daemon,
32
+ compaction, MCP/CLI writes, and provider-driven turns.
@@ -0,0 +1,91 @@
1
+ # ADR 003: Bounded sequential agent discussions
2
+
3
+ ## Status
4
+
5
+ Accepted
6
+
7
+ ## Date
8
+
9
+ 2026-09-04
10
+
11
+ ## Context
12
+
13
+ The coordination bridge can deliver structured events to Claude Code and Codex,
14
+ but it does not make the agents deliberate. Users who want both models to weigh
15
+ the same feature must manually relay responses, and an unconstrained automatic
16
+ relay could consume quota indefinitely, spread prompt injection, or let two
17
+ agents edit the same files concurrently.
18
+
19
+ Provider interfaces can start or resume turns, but neither supported interface
20
+ offers a shared hidden context or reliable mid-turn steering. Provider output
21
+ is also untrusted data and may be empty, malformed, oversized, or contain
22
+ instructions unrelated to the user's question.
23
+
24
+ ## Decision
25
+
26
+ Implement an opt-in, two-participant design room as a sequential protocol:
27
+
28
+ - one proposer and one reviewer alternate for 1-8 rounds;
29
+ - each response is explicitly public, redacted, bounded, persisted, and linked
30
+ to the prior event by thread and reply IDs;
31
+ - each round costs two provider turns and final synthesis costs one, so the
32
+ exact required budget is known before any provider session starts;
33
+ - prompts prohibit file edits, commands, tools, and disclosure of private
34
+ reasoning;
35
+ - the proposer returns a strict final JSON decision, rationale, alternatives,
36
+ and unresolved disagreements;
37
+ - Loadout emits a normal decision event and a terminal discussion event;
38
+ - provider rejection, invalid output, and empty output close the discussion as
39
+ failed without silent retries;
40
+ - the existing project kill switch is checked before every provider turn;
41
+ - provider turns default to 120 seconds and are explicitly bounded to a
42
+ user-selectable 10-600 seconds.
43
+
44
+ Fresh sessions start lazily with their first discussion prompt so setup does not
45
+ spend a hidden extra turn. Existing provider session IDs are attached without a
46
+ turn and then resumed on the first discussion response. The project bridge
47
+ lease prevents a background bridge and a design room from controlling the same
48
+ sessions concurrently.
49
+
50
+ ## Alternatives considered
51
+
52
+ ### Let both agents edit the same feature during the discussion
53
+
54
+ Rejected. The purpose of the design room is to settle an approach before file
55
+ ownership and implementation. Concurrent edits make the outcome harder to
56
+ review and reintroduce the conflicts the ownership protocol prevents.
57
+
58
+ ### Forward full provider transcripts automatically
59
+
60
+ Rejected. It would expose unrelated context, increase prompt-injection risk,
61
+ and make storage and quota use unpredictable. Only responses requested for the
62
+ public discussion are shared.
63
+
64
+ ### Run both agents concurrently and ask a third model to judge
65
+
66
+ Rejected for the first release. Parallel first proposals do not support genuine
67
+ back-and-forth critique, and a third model adds provider, billing, and tie-break
68
+ semantics without evidence that it improves decisions.
69
+
70
+ ### Continue until the agents agree
71
+
72
+ Rejected. Agreement is not guaranteed, and an unbounded loop is unsafe. The
73
+ final result preserves unresolved disagreement rather than claiming consensus.
74
+
75
+ ### Host a remote coordination bus
76
+
77
+ Rejected for this release. Authentication, tenant isolation, encryption,
78
+ availability, and remote conflict semantics require a separate design. The
79
+ current protocol remains local to one repository and machine.
80
+
81
+ ## Consequences
82
+
83
+ - Users get a real Claude↔Codex critique loop with a predictable maximum cost.
84
+ - The transcript is inspectable with `coord discuss show` and the normal replay.
85
+ - The discussion cannot steer a provider mid-turn; a kill switch takes effect
86
+ before the next turn.
87
+ - Strict final JSON may fail when a provider ignores the requested format. That
88
+ failure is visible and auditable instead of being misrepresented as a valid
89
+ decision.
90
+ - More than two agents, voting, hosted rooms, and automatic implementation are
91
+ intentionally out of scope.
@@ -0,0 +1,169 @@
1
+ # Spec: Bounded agent discussions
2
+
3
+ ## Objective
4
+
5
+ Add an opt-in design room in which Claude Code and Codex can discuss one
6
+ technical question, challenge each other's proposals, and record a final
7
+ decision. The user chooses the topic, participants, round count, and provider
8
+ turn budget. Success means the exchange is genuinely bidirectional, bounded,
9
+ auditable, resumable from the coordination log, and unable to edit files merely
10
+ because a discussion was started.
11
+
12
+ The initial release targets two participants. One is the proposer and one is
13
+ the reviewer. A round gives each participant one turn; after the configured
14
+ rounds, the proposer receives one synthesis turn and Loadout records the final
15
+ decision and considered alternative.
16
+
17
+ ## Assumptions approved by the user
18
+
19
+ 1. `loadout coord discuss start` is explicitly opt-in and may spend paid
20
+ provider turns.
21
+ 2. A discussion shares only responses produced for the public design room. It
22
+ does not expose hidden reasoning, unrelated chat history, or provider state.
23
+ 3. Discussion prompts forbid code edits and command execution. Implementation
24
+ begins only after the discussion completes and the user acts on the result.
25
+ 4. Exactly Claude Code and Codex are supported in the first release, using
26
+ either fresh sessions (`--agents`) or explicit existing sessions
27
+ (`--sessions`).
28
+ 5. A discussion has 1-8 rounds and a hard turn budget. The expected budget is
29
+ `rounds * 2 + 1`; invalid or insufficient budgets fail before any paid turn.
30
+ 6. Provider output is untrusted, redacted at the existing persistence boundary,
31
+ length-bounded, and stored only as explicit discussion events.
32
+
33
+ ## Tech stack
34
+
35
+ - TypeScript 5.7, ESM, Node.js 20+
36
+ - Commander 12 for the public CLI
37
+ - Zod 4 for boundary validation
38
+ - Vitest 4 for unit, integration, and CLI tests
39
+ - Existing Claude Code CLI and official Codex SDK adapters
40
+ - Existing project-local `.handoff/coordination.jsonl` protocol
41
+
42
+ ## Commands
43
+
44
+ ```bash
45
+ # Build and static checks
46
+ npm run build
47
+ npm run typecheck
48
+ npm run lint
49
+ npm run format:check
50
+
51
+ # Focused tests
52
+ npx vitest run tests/coordination-discussion.test.ts
53
+ npx vitest run tests/coordination-session-commands.test.ts
54
+
55
+ # Full release gate
56
+ npm run verify:full
57
+
58
+ # Start fresh provider sessions
59
+ loadout coord discuss start "REST or GraphQL for checkout?" \
60
+ --agents claude-code,codex --rounds 4 --max-turns 9
61
+
62
+ # Reuse existing provider sessions
63
+ loadout coord discuss start "REST or GraphQL for checkout?" \
64
+ --sessions claude-code:<session-id> codex:<thread-id> \
65
+ --rounds 4 --max-turns 9
66
+
67
+ # Inspect a discussion without spending provider turns
68
+ loadout coord discuss show <thread-id>
69
+ loadout coord discuss list
70
+ ```
71
+
72
+ ## Project structure
73
+
74
+ - `src/core/coordination/discussion.ts`: pure discussion state, prompts,
75
+ orchestration, result formatting, and bounded public transcript.
76
+ - `src/core/coordination/events.ts`: additive discussion payload schema.
77
+ - `src/commands/coordination-discussions.ts`: CLI registration and provider
78
+ session composition.
79
+ - `src/commands/coordinate.ts`: registers the discussion command group.
80
+ - `tests/coordination-discussion.test.ts`: protocol and orchestrator behavior.
81
+ - `tests/coordination-session-commands.test.ts`: public argument parsing.
82
+ - `docs/decisions/003-bounded-agent-discussions.md`: architecture rationale.
83
+ - `docs/LIVE_COLLABORATION.md`, `docs/USER_TEST_GUIDE.md`, `README.md`: user
84
+ workflow and safety language.
85
+
86
+ ## Public contract and code style
87
+
88
+ Discussion events extend the existing protocol without changing old events:
89
+
90
+ ```ts
91
+ type DiscussionPayload = {
92
+ threadId: string;
93
+ kind: "started" | "proposal" | "critique" | "revision" | "summary" | "closed";
94
+ round: number;
95
+ role: "system" | "proposer" | "reviewer";
96
+ content: string;
97
+ participants?: [string, string];
98
+ replyTo?: string;
99
+ alternatives?: string[];
100
+ unresolved?: string[];
101
+ outcome?: "decided" | "failed";
102
+ };
103
+ ```
104
+
105
+ Names use current camelCase TypeScript conventions. Inputs and outputs are
106
+ separate interfaces. Boundary schemas are strict and descriptive. Existing
107
+ event error semantics and redaction are reused.
108
+
109
+ ## Testing strategy
110
+
111
+ - Unit-test schemas, state reconstruction, prompt safety text, reply chains,
112
+ round limits, turn-budget validation, provider failure, and kill-switch
113
+ behavior with real coordination storage and fake participants.
114
+ - Integration-test a complete alternating discussion and assert the persisted
115
+ event order and final decision.
116
+ - CLI-test parsing for `--agents`, `--sessions`, rounds, and mutually exclusive
117
+ modes without invoking a paid provider.
118
+ - Extend replay/adapter formatting tests so discussion events are legible.
119
+ - Run all coordination suites, then `npm run verify:full`.
120
+ - Manually run one real Claude Code/Codex discussion before publishing 0.9.0.
121
+
122
+ ## Boundaries
123
+
124
+ ### Always
125
+
126
+ - Validate all CLI and persisted discussion input.
127
+ - Check the kill switch before every provider turn and persisted event.
128
+ - Emit a stable thread ID and reply ID for every public statement.
129
+ - Keep turns sequential so each agent sees the previous public response.
130
+ - Redact and bound shared responses through the canonical event store.
131
+ - Print the exact paid-turn count before starting fresh or resumed sessions.
132
+
133
+ ### Ask first
134
+
135
+ - Adding a third provider or more than two participants.
136
+ - Allowing discussion prompts to edit files or execute commands.
137
+ - Adding remote/networked coordination or a hosted message broker.
138
+ - Persisting private provider transcripts or hidden reasoning.
139
+
140
+ ### Never
141
+
142
+ - Start paid turns when validation or budget checks fail.
143
+ - Route a discussion output as an instruction outside its thread.
144
+ - Run an unbounded loop or retry provider turns silently.
145
+ - Continue after the kill switch, missing response, or provider rejection.
146
+ - Claim consensus when the synthesis records unresolved disagreement.
147
+
148
+ ## Success criteria
149
+
150
+ - `coord discuss start` alternates Claude Code and Codex for exactly the
151
+ requested number of rounds and runs at most the declared turn budget.
152
+ - Every response is a validated `discussion` event with `threadId`, `kind`,
153
+ `round`, `role`, and an explicit reply chain.
154
+ - A successful discussion ends in `summary`, `decision`, and `closed` events;
155
+ a failed discussion ends in a bounded error/closed state without extra turns.
156
+ - `list` and `show` reconstruct bounded discussion state from the JSONL log.
157
+ - Both fresh sessions and explicit existing sessions are supported, but cannot
158
+ be selected together.
159
+ - The kill switch halts the exchange before the next provider turn.
160
+ - Each provider turn defaults to a 120-second timeout and accepts a validated
161
+ 10-600 second override.
162
+ - Existing coordination consumers continue to parse and operate unchanged.
163
+ - Focused tests, all coordination tests, build, lint, formatting, package smoke,
164
+ and the complete release gate pass.
165
+
166
+ ## Open questions
167
+
168
+ - None for the two-agent MVP. Multi-agent voting, remote machines, and automatic
169
+ implementation are intentionally deferred.
@@ -0,0 +1,231 @@
1
+ # Coordination Hardening 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:** Make Loadout coordination safe under concurrent processes, secure on localhost, correctly packaged over MCP, truthful about provider capabilities, and releasable behind an explicit beta contract.
6
+
7
+ **Architecture:** Keep the human-readable JSONL audit log, but serialize every state-changing operation through one project-local lock and one canonical validated/redacted write path. Treat the HTTP daemon and stdio MCP server as authenticated/validated adapters over that core. Provider adapters may submit a new turn to a resumable session; they must never claim to inject into an active turn unless the host exposes that capability.
8
+
9
+ **Tech Stack:** Node.js 20+, TypeScript, Zod, Vitest, `@modelcontextprotocol/sdk` v1, `@openai/codex-sdk`.
10
+
11
+ ## Global Constraints
12
+
13
+ - Preserve existing `loadout handoff` behavior and `.handoff/messages.jsonl` compatibility.
14
+ - Persist coordination events before notifying watchers or SSE subscribers.
15
+ - Every persisted event has a unique, strictly increasing sequence number across concurrent processes.
16
+ - Bind HTTP only to loopback and require a project-scoped bearer token for every API/SSE request.
17
+ - Never persist raw secrets through any CLI, HTTP, or MCP write path.
18
+ - Keep destructive actions, publishing, deployment, and permission expansion under user control.
19
+ - Mark provider-driven live turns beta until both installed-host integration tests pass.
20
+
21
+ ---
22
+
23
+ ### Task 1: Restore the quality gate
24
+
25
+ **Files:**
26
+
27
+ - Modify: `src/core/coordination/adapters/codex.ts`
28
+ - Modify: `src/core/coordination/daemon.ts`
29
+ - Modify: `src/core/coordination/retention.ts`
30
+ - Modify: `tests/coordination-concurrency.test.ts`
31
+ - Modify: `tests/coordination-crash-recovery.test.ts`
32
+ - Modify: `tests/coordination-interrupt-policy.test.ts`
33
+
34
+ **Interfaces:**
35
+
36
+ - Produces: a zero-error `npm run lint` baseline without weakening ESLint rules.
37
+
38
+ - [ ] Remove imports that have no runtime or type use.
39
+ - [ ] Rename or omit unused parameters rather than disabling lint rules.
40
+ - [ ] Run `npm run lint`; expect exit 0.
41
+ - [ ] Run `npm run typecheck`; expect exit 0.
42
+ - [ ] Commit as `chore: restore coordination quality gate`.
43
+
44
+ ### Task 2: Serialize the coordination log and enforce invariants
45
+
46
+ **Files:**
47
+
48
+ - Create: `src/core/coordination/lock.ts`
49
+ - Modify: `src/core/coordination/coordinator.ts`
50
+ - Modify: `src/core/coordination/events.ts`
51
+ - Modify: `src/commands/coordinate.ts`
52
+ - Modify: `tests/coordination-concurrency.test.ts`
53
+ - Create: `tests/fixtures/coordination-writer.mjs`
54
+
55
+ **Interfaces:**
56
+
57
+ - Produces: `withCoordinationLock<T>(projectRoot, operation): Promise<T>`.
58
+ - Produces: `claimOwnership(projectRoot, input): Promise<CoordinationEvent>`.
59
+ - Produces: atomic `publishContract` revision allocation and validated `ack` watermarks.
60
+
61
+ - [ ] Add a failing multi-process test that starts independent Node writers and asserts 100 unique sequence numbers equal `0..99`.
62
+ - [ ] Add failing tests for overlapping ownership (`src/api` vs `src/api/user.ts`), future acknowledgements, concurrent contract revisions, stale-lock recovery, and permission errors from an existing unreadable log.
63
+ - [ ] Run `npx vitest run tests/coordination-concurrency.test.ts`; confirm failures describe duplicate sequences and missing validation.
64
+ - [ ] Implement an exclusive lock file using `open(path, "wx", 0o600)`, bounded jittered retries, owner metadata, stale-owner recovery, and `finally` cleanup.
65
+ - [ ] Move append, sequence allocation, contract revision allocation, ownership check/claim, and acknowledgement validation inside the lock.
66
+ - [ ] Normalize project-relative paths and detect equal, parent, and child overlap.
67
+ - [ ] Catch only `ENOENT` as an empty coordination log; propagate other I/O errors.
68
+ - [ ] Cap IDs/agent names at 128 characters, descriptions at 8 KiB, context at 64 KiB, path counts at 256, and paths at 1 KiB.
69
+ - [ ] Run the focused test until green, then run all coordination tests.
70
+ - [ ] Commit as `fix: make coordination state atomic across processes`.
71
+
72
+ ### Task 3: Make redaction canonical
73
+
74
+ **Files:**
75
+
76
+ - Modify: `src/core/coordination/redaction.ts`
77
+ - Modify: `src/core/coordination/coordinator.ts`
78
+ - Modify: `src/core/coordination/daemon.ts`
79
+ - Modify: `tests/coordination-redaction.test.ts`
80
+ - Modify: `tests/coordination.test.ts`
81
+
82
+ **Interfaces:**
83
+
84
+ - Produces: `sanitizeEmitOptions(options): EmitOptions` used by the sole append path.
85
+
86
+ - [ ] Add failing tests that emit secrets through direct core calls, CLI-equivalent calls, nested payloads, and daemon calls.
87
+ - [ ] Confirm direct writes currently persist the sample secret.
88
+ - [ ] Apply redaction inside the canonical locked writer before schema validation and persistence.
89
+ - [ ] Remove adapter-specific duplicate redaction.
90
+ - [ ] Verify all paths persist `[REDACTED]` and preserve non-sensitive fields.
91
+ - [ ] Commit as `fix: redact every coordination write path`.
92
+
93
+ ### Task 4: Secure the localhost daemon and stabilize its API
94
+
95
+ **Files:**
96
+
97
+ - Create: `src/core/coordination/auth.ts`
98
+ - Create: `src/core/coordination/http-api.ts`
99
+ - Modify: `src/core/coordination/daemon.ts`
100
+ - Modify: `src/commands/coordinate.ts`
101
+ - Modify: `tests/coordination-daemon.test.ts`
102
+ - Create: `tests/coordination-daemon-security.test.ts`
103
+
104
+ **Interfaces:**
105
+
106
+ - Produces: `ensureDaemonToken(projectRoot): Promise<string>` with a mode-0600 token file.
107
+ - Produces: one structured error shape `{ error: { code, message } }`.
108
+ - Consumes: atomic coordinator operations from Task 2.
109
+
110
+ - [ ] Add failing tests for missing/wrong bearer token, malicious `Origin`, forged `Host`, unauthenticated SSE, oversized bodies, malformed JSON, and project-root leakage.
111
+ - [ ] Confirm authenticated loopback requests remain possible.
112
+ - [ ] Generate a 32-byte random token, store it under `.handoff` with mode `0600`, and compare tokens using `timingSafeEqual`.
113
+ - [ ] Require `Authorization: Bearer <token>` for API requests; allow a query token only for the initial dashboard document and immediately move it to session storage/history-free state.
114
+ - [ ] Replace wildcard CORS with same-origin behavior and reject non-loopback Host headers.
115
+ - [ ] Return 400 for malformed JSON, 401 for missing authentication, 403 for origin/host rejection, 409 for ownership/revision conflict, and 413 for oversized bodies.
116
+ - [ ] Stop returning absolute project paths from browser-visible status payloads.
117
+ - [ ] Split the 700-line daemon into HTTP policy/route and lifecycle modules.
118
+ - [ ] Run daemon security, daemon behavior, and full coordination tests.
119
+ - [ ] Commit as `fix: authenticate and isolate the coordination daemon`.
120
+
121
+ ### Task 5: Ship a real MCP server
122
+
123
+ **Files:**
124
+
125
+ - Modify: `package.json`
126
+ - Modify: `package-lock.json`
127
+ - Modify: `tsconfig.json`
128
+ - Modify: `src/core/coordination/mcp-server.ts`
129
+ - Create: `tests/coordination-mcp.test.ts`
130
+ - Modify: `scripts/package-smoke.mjs`
131
+
132
+ **Interfaces:**
133
+
134
+ - Produces: packaged `dist/src/core/coordination/mcp-server.js`.
135
+ - Produces: stdio tools backed only by validated coordinator operations.
136
+
137
+ - [ ] Add `@modelcontextprotocol/sdk` v1 as a runtime dependency and remove the TypeScript exclusion.
138
+ - [ ] Add a failing package test asserting that `mcp-server.js` exists in the tarball.
139
+ - [ ] Add an MCP client smoke test that initializes the server, lists tools, emits an event, and reads a snapshot in a temporary project.
140
+ - [ ] Update handlers to use the SDK v1 API and convert validation/conflict failures into MCP tool errors.
141
+ - [ ] Verify stdout contains only protocol messages and diagnostics go to stderr.
142
+ - [ ] Run MCP tests and `npm pack --dry-run --json`.
143
+ - [ ] Commit as `fix: compile and package the coordination MCP server`.
144
+
145
+ ### Task 6: Replace fictional provider commands with supported adapters
146
+
147
+ **Files:**
148
+
149
+ - Modify: `package.json`
150
+ - Modify: `package-lock.json`
151
+ - Modify: `src/core/coordination/adapters/types.ts`
152
+ - Modify: `src/core/coordination/adapters/codex.ts`
153
+ - Modify: `src/core/coordination/adapters/claude-code.ts`
154
+ - Modify: `src/core/coordination/session-manager.ts`
155
+ - Create: `tests/coordination-adapter-codex.test.ts`
156
+ - Create: `tests/coordination-adapter-claude.test.ts`
157
+ - Create: `tests/coordination-session-manager.test.ts`
158
+
159
+ **Interfaces:**
160
+
161
+ - Produces: capability `canSubmitTurn`, distinct from unsupported mid-turn injection.
162
+ - Produces: Codex `start`, `resume`, and `submitTurn` through `@openai/codex-sdk`.
163
+ - Produces: Claude `start`, `resume`, and `submitTurn` through documented positional CLI prompts.
164
+
165
+ - [ ] Write adapter contract tests around injected process/SDK drivers so exact command arguments and session IDs are observable.
166
+ - [ ] Assert Codex never uses `--quiet` and Claude never uses `--message` or `sessions list`.
167
+ - [ ] Add `@openai/codex-sdk` as a runtime dependency and implement start/resume/turn using `startThread()`, `resumeThread(id)`, and `run()`.
168
+ - [ ] Implement Claude print-mode turns as `claude -p --output-format json [--resume id] <prompt>` and parse `session_id` from validated output.
169
+ - [ ] Track sessions Loadout itself creates instead of claiming to enumerate every host session.
170
+ - [ ] Queue relevant events until an adapter is idle; do not interrupt active work unless a future host capability explicitly supports steering.
171
+ - [ ] Run adapter and session-manager tests with fake drivers, followed by opt-in smoke checks against the locally installed CLIs.
172
+ - [ ] Commit as `fix: use supported Codex and Claude session APIs`.
173
+
174
+ ### Task 7: Reconcile retention, recovery, and observability
175
+
176
+ **Files:**
177
+
178
+ - Modify: `src/core/coordination/retention.ts`
179
+ - Modify: `src/core/coordination/crash-recovery.ts`
180
+ - Modify: `src/core/coordination/replay.ts`
181
+ - Modify: `src/core/coordination/watcher.ts`
182
+ - Modify: `tests/coordination-retention.test.ts`
183
+ - Modify: `tests/coordination-crash-recovery.test.ts`
184
+ - Modify: `tests/coordination-replay.test.ts`
185
+
186
+ **Interfaces:**
187
+
188
+ - Consumes: the same lock from Task 2 for compaction and recovery.
189
+ - Produces: explicit health data without filesystem secrets.
190
+
191
+ - [ ] Add failing tests for append-during-compaction, truncated final lines, duplicate legacy sequences, reconnect after compaction, and backup restoration.
192
+ - [ ] Make compaction and recovery use the same exclusive lock as append.
193
+ - [ ] Preserve corrupt-line evidence rather than silently discarding it.
194
+ - [ ] Bound replay and snapshot queries by event count and serialized byte size.
195
+ - [ ] Add counters for connected clients, high watermark, corrupt records, rejected writes, and last compaction time.
196
+ - [ ] Run focused recovery/retention/replay tests.
197
+ - [ ] Commit as `fix: harden coordination recovery and retention`.
198
+
199
+ ### Task 8: Make the product contract truthful and test the release artifact
200
+
201
+ **Files:**
202
+
203
+ - Create: `docs/decisions/001-coordination-jsonl-locking.md`
204
+ - Create: `docs/decisions/002-local-daemon-authentication.md`
205
+ - Modify: `README.md`
206
+ - Modify: `MASTERPLAN.md`
207
+ - Modify: `docs/LIVE_COLLABORATION.md`
208
+ - Modify: `docs/USER_TEST_GUIDE.md`
209
+ - Modify: `CHANGELOG.md`
210
+ - Modify: `scripts/readme-product-flow.mjs`
211
+ - Modify: `scripts/cli-product-flow.mjs`
212
+
213
+ **Interfaces:**
214
+
215
+ - Produces: one user-facing distinction between durable handoff, live coordination, and provider-driven beta turns.
216
+
217
+ - [ ] Document the locking and authentication decisions, rejected alternatives, limitations, and recovery behavior.
218
+ - [ ] Remove contradictory phase/status claims and document exact supported commands.
219
+ - [ ] Add a two-agent walkthrough: backend contract publish, frontend acknowledgement, revision diff, ownership conflict, reconnect, and kill switch.
220
+ - [ ] Add CLI/product-flow coverage for the walkthrough without invoking paid model turns.
221
+ - [ ] Run `npm run verify:full` from the clean branch.
222
+ - [ ] Run `npm pack --dry-run --json`, install the tarball in a temporary directory, and execute `loadout --version`, `loadout coordinate --help`, daemon authentication, and MCP initialization.
223
+ - [ ] Run opt-in real-host smoke tests with installed Codex and Claude CLIs; do not make destructive project changes.
224
+ - [ ] Review `git diff` for secrets and unrelated changes.
225
+ - [ ] Commit as `docs: define the live coordination beta contract`.
226
+
227
+ ## Self-review
228
+
229
+ - Spec coverage: concurrency, authentication, MCP packaging, real provider APIs, validation, redaction, ownership overlap, acknowledgements, retention, recovery, documentation, clean-room packaging, and launch gates are each assigned to a task.
230
+ - Placeholder scan: no deferred implementation placeholders are used; provider mid-turn interruption is explicitly excluded until supported by a host API.
231
+ - Type consistency: all external adapters converge on `canSubmitTurn` and canonical coordinator operations; HTTP and MCP do not own state logic.