> For the complete documentation index, see [llms.txt](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/sessions/phase40-session16-voice-parity-and-broker-respawn/tasks.md).

# Task Checklist

**Session ID**: `phase40-session16-voice-parity-and-broker-respawn` **Total Tasks**: 20 **Estimated Duration**: 3-4 hours **Created**: 2026-07-03

***

Legend: `[x]` completed; `[ ]` pending; `[P]` parallelizable; `[SNNMM]` session ref; `TNNN` task ID.

***

## Setup (3 tasks)

* [x] T001 \[S4016] Review upstream saved-key start behavior, Phase 40 Session 16 scope, and Session 01 voice decisions before edits (`.spec_system/specs/phase40-session16-voice-parity-and-broker-respawn/implementation-notes.md`, `.spec_system/PRD/phase_40/session_16_voice_parity_and_broker_respawn.md`, `.spec_system/specs/phase40-session01-baseline-and-port-invariants/implementation-notes.md`)
* [x] T002 \[S4016] Verify current bridge, broker, hook, portal, and docs ownership for environment-backed voice startup (`scripts/lib/voice-launch-bridge.ts`, `scripts/lib/voice-broker.ts`, `src/hooks/use-hermes-intelligence-voice.ts`, `src/components/hermes/intelligence/intelligence-portal.tsx`, `docs/local-voice-setup.md`, `docs/intelligence-view.md`)
* [x] T003 \[S4016] Prepare focused test fixtures for empty launch bodies, browser-supplied key/base bodies, missing env key, invalid token, health timeout, provider/session failure, broker-down respawn, and active voice controls (`scripts/lib/__tests__/voice-launch-bridge.test.ts`, `src/hooks/__tests__/use-hermes-intelligence-voice.test.tsx`, `src/components/hermes/intelligence/__tests__/intelligence-portal.test.tsx`)

***

## Foundation (4 tasks)

* [x] T004 \[S4016] \[P] Extend launch bridge tests for truly empty body acceptance, empty-object compatibility, provider-config rejection, and env-only child spawn with schema-validated input and explicit error mapping (`scripts/lib/__tests__/voice-launch-bridge.test.ts`)
* [x] T005 \[S4016] \[P] Extend voice hook tests for `/__start_voice` payload shape, no key/base fields, broker-down respawn, missing key, invalid token, timeout, and provider failure with explicit loading, empty, error, and offline states (`src/hooks/__tests__/use-hermes-intelligence-voice.test.tsx`)
* [x] T006 \[S4016] \[P] Extend Intelligence portal tests for recovery copy, disabled start, active voice loop controls, and Voice-specific product copy with platform-appropriate accessibility labels, focus management, and input support (`src/components/hermes/intelligence/__tests__/intelligence-portal.test.tsx`)
* [x] T007 \[S4016] Record the upstream non-port rationale, AI OS parity target, and Session 17 documentation queue in the session notes (`.spec_system/specs/phase40-session16-voice-parity-and-broker-respawn/implementation-notes.md`)

***

## Implementation (7 tasks)

* [x] T008 \[S4016] Audit and, if tests require it, tighten launch-body parsing so provider config bodies are rejected while empty launches remain accepted with schema-validated input and explicit error mapping (`scripts/lib/voice-launch-bridge.ts`)
* [x] T009 \[S4016] Audit and, if tests require it, tighten broker respawn so broker-down plus env key spawns once, blocks duplicate starts while in-flight, and cleans the child process on health timeout (`scripts/lib/voice-launch-bridge.ts`)
* [x] T010 \[S4016] Audit and, if tests require it, tighten provider environment handling so `OPENAI_BASE_URL` stays OpenAI/loopback-only and no provider key reaches argv, logs, browser state, or generated output (`scripts/lib/voice-launch-bridge.ts`, `scripts/lib/voice-broker.ts`)
* [x] T011 \[S4016] Audit and, if tests require it, adjust the hook start flow to call `/__start_voice` before setup/error UI, send no provider config, and map bridge errors distinctly (`src/hooks/use-hermes-intelligence-voice.ts`)
* [x] T012 \[S4016] Audit and, if tests require it, adjust hook runtime failure handling for broker, session, provider, microphone, and WebRTC errors with cleanup on scope exit for all acquired resources (`src/hooks/use-hermes-intelligence-voice.ts`)
* [x] T013 \[S4016] Audit and, if tests require it, adjust Intelligence portal recovery and Start/Stop control states for demo, missing token, missing key, bad token, broker down, timeout, provider failure, and active voice loops with product-facing copy only (`src/components/hermes/intelligence/intelligence-portal.tsx`)
* [x] T014 \[S4016] Finalize the parity audit, fix summary, test evidence, and docs handoff notes for Session 17 (`.spec_system/specs/phase40-session16-voice-parity-and-broker-respawn/implementation-notes.md`)

***

## Testing (6 tasks)

* [x] T015 \[S4016] Run focused bridge and broker tests for launch, respawn, provider policy, token, timeout, and safe-error behavior (`bunx vitest run scripts/lib/__tests__/voice-launch-bridge.test.ts scripts/lib/__tests__/voice-broker.test.ts`)
* [x] T016 \[S4016] Run focused hook and Intelligence portal tests for start ordering, payload shape, error mapping, cleanup, recovery copy, and active controls (`bunx vitest run src/hooks/__tests__/use-hermes-intelligence-voice.test.tsx src/components/hermes/intelligence/__tests__/intelligence-portal.test.tsx`)
* [x] T017 \[S4016] Run local control-plane and sanitizer-adjacent regression tests for route gates and safe browser-visible errors (`bunx vitest run scripts/lib/__tests__/local-control-plane-guard.test.ts scripts/lib/__tests__/sanitize.test.ts`)
* [x] T018 \[S4016] Run TypeScript checks for application and script surfaces touched by voice bridge and hook work (`bun run typecheck`, `bun run typecheck:scripts`)
* [x] T019 \[S4016] Run lint and diff whitespace checks before handoff (`bun run lint`, `git diff --check`)
* [x] T020 \[S4016] Validate ASCII/LF and scan touched session/voice files for private paths, raw provider keys, bearer tokens, and secret-shaped strings (`.spec_system/specs/phase40-session16-voice-parity-and-broker-respawn/spec.md`, `.spec_system/specs/phase40-session16-voice-parity-and-broker-respawn/tasks.md`, `scripts/lib/voice-launch-bridge.ts`, `scripts/lib/voice-broker.ts`, `src/hooks/use-hermes-intelligence-voice.ts`, `src/components/hermes/intelligence/intelligence-portal.tsx`)

***

## Completion Checklist

* [x] All tasks marked `[x]`
* [x] All tests and checks passing
* [x] All files ASCII-encoded with LF line endings
* [x] implementation-notes.md updated
* [x] Ready for `creview` (next step in the implement -> creview -> validate sequence)

***

## Next Steps

Run the `implement` workflow step.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/sessions/phase40-session16-voice-parity-and-broker-respawn/tasks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
