# Work Control State Machine Report: Hooks Fixed Through Chunk 000276

## Metadata

- Schema: work-control-state-report-v1
- Capture start: 2026-05-19T17:52:47.062Z
- Setup window: chunk 000275 hook-fix probes before capture start
- Primary window: capture start through end of chunk 000276
- Source of truth: Runtime work-history, Runtime State Journal events, browser proof reports, cfd-0029 notes, and chunk evidence
- Scope: role/activity/status/source/action metadata for work registration, hook registration, QA, validation, browser proof, and lifecycle transitions

## Setup Findings Before Capture Start

- Hosted tool probes showed direct `exec_command` and `apply_patch` calls did not create Runtime work-history records before hook matcher fixes.
- Local Codex logs identified hosted tool names as `exec_command` and `apply_patch`; `.codex/hooks.json` matched `Bash|apply_patch|Edit|Write|mcp__.*`, so shell tool calls were not matched.
- `.codex/hooks.json` was expanded to match `exec_command`, `functions.exec_command`, `write_stdin`, `functions.write_stdin`, `apply_patch`, `functions.apply_patch`, `multi_tool_use.parallel`, and existing edit/write/MCP names.
- The Codex hook adapter now maps `functions.apply_patch`/`apply_patch` to `filesystem_write`, `functions.write_stdin`/`write_stdin` to `shell_read`, and `multi_tool_use.parallel` by nested command content.
- Filesystem-write hook handling now creates a dedicated Developer coding session/step with `file_change_expected=true`, instead of being swallowed by an unrelated active parent session.
- Read-only hook steps now explicitly set `file_change_expected=false` so they do not inherit write metadata from a previous parent session.

## Chunk 000275 Evidence Snapshot

- Focused state-model test: `connection-recovery-state-model.spec.ts`, 22 tests passed.
- Connection status service test: 27 tests passed.
- App connection recovery service test: 9 tests passed.
- Runtime tests passed, including hosted-tool hook map assertions.
- Browser proof run: `browser-smoke-mpcx7vdq`, passed.
- Browser proof report: `ai/reports/report-000275-runtime-action-panel-state-machine-browser-proof.md`

## Work-Control Timeline Extract

| Time UTC | Role | Activity | Status | Source Action | Artifact | Notes |
| --- | --- | --- | --- | --- | --- | --- |
| 2026-05-19T17:45:48.887Z | Runtime Supervisor | supervising | completed | runtime.supervisor_action | c2ed8c4f | Backend resurrection/restart proof completed during browser run. |
| 2026-05-19T17:46:44.618Z | Runtime Executor | runtime_tests | completed | runtime.testing.browser_smoke | 000275 | Browser proof runtime test step completed. |
| 2026-05-19T17:46:44.705Z | QA | qa_review | completed | runtime.testing.browser_smoke.qa_role_completion | 000275 | QA role completion proof remained visible. |
| 2026-05-19T17:47:32.819Z | Requirements | planning | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Requirements mode. |
| 2026-05-19T17:47:41.359Z | Requirements Review | qa_review | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Requirements Review mode. |
| 2026-05-19T17:48:08.091Z | Prompt Synthesizer | summary_writing | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Prompt Synthesizer mode. |
| 2026-05-19T17:48:17.030Z | Consultant Checkpoint | handoff_preparation | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Consultant mode. |
| 2026-05-19T17:48:45.961Z | Orchestrator | planning | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Orchestrator mode. |
| 2026-05-19T17:49:10.388Z | Chunk Planner | planning | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Chunk Planner mode. |
| 2026-05-19T17:49:37.251Z | Developer | coding | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Developer mode. |
| 2026-05-19T17:49:47.683Z | QA | qa_review | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered QA mode. |
| 2026-05-19T17:50:13.711Z | Runtime Executor | runtime_tests | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Runtime Executor mode. |
| 2026-05-19T17:50:42.776Z | Dispatcher | close_commit | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Dispatcher mode. |
| 2026-05-19T17:51:02.242Z | Operator | waiting | completed | runtime.testing.browser_smoke.role_work_matrix | 000275 | Role matrix proof registered Operator mode. |
| 2026-05-19T17:51:15.794Z | Orchestrator | validating | stale | runtime.testing.browser_smoke | 000275 | Browser-smoke parent session became stale during long run; later steps still completed. Candidate for cfd-0029 parent/child heartbeat work. |
| 2026-05-19T17:51:30.708Z | Codex | diagnosis | completed | codex_hook.PreToolUse.shell_read | 000275 | Explicit browser proof read-only Codex hook visible. |
| 2026-05-19T17:51:31.437Z | Codex | diagnosis | completed | codex_hook.PermissionRequest.shell_read | 000275 | PermissionRequest hook visible. |
| 2026-05-19T17:51:55.978Z | Runtime Executor | runtime_tests | completed | runtime.testing.browser_smoke | 000275 | Browser proof final runtime test step completed. |
| 2026-05-19T17:51:55.999Z | Orchestrator | validating | completed | runtime.testing.browser_smoke | 000275 | Browser proof session completed. |
| 2026-05-19T17:51:56.015Z | Codex | planning | active | codex_hook.PreToolUse.shell_read | 000275 | Hook proof left an active Codex prompt-intent/session surface after read-only proof. Needs observation through 000276. |

## Current Gaps To Track Through 000276

- Runtime CLI work-contract fix: `validate` had a direct bypass because the CLI sent a raw socket batch instead of calling the self-registering Runtime API validation wrapper. The CLI now registers `runtime.cli.validate` before running validation.
- Runtime socket-work fix: generic Runtime CLI socket calls now create `runtime.cli.socket_request` work contracts for non-inspection methods. Pure inspection and work-registration methods are allowlisted to avoid health/read-model polling noise.
- Hosted non-Runtime tool calls after matcher changes still need direct proof that the runner invokes project hooks automatically, not only explicit bridge invocation.
- Browser-smoke parent/child work can show a stale parent session while child role steps continue; cfd-0029 should resolve parent heartbeat or parent/child display semantics.
- `exec_command` process saturation warnings continue; work-control report should note if saturation affects visibility, hook invocation, or validation timing.

## Runtime CLI Work-Contract Proof

| Time UTC | Role | Activity | Status | Source Action | Artifact | Notes |
| --- | --- | --- | --- | --- | --- | --- |
| 2026-05-19T18:05:20.843Z | Runtime Executor | validating | completed | runtime.cli.validate | runtime-validation | First proof that `node ai/runtime/dist/cli.js validate --tier fast --json` self-registered before running validation. |
| 2026-05-19T18:11:01.205Z | Runtime Executor | validating | completed | runtime.cli.socket_request | summary.validate | Generic CLI socket wrapper registered summary validation work. |
| 2026-05-19T18:11:01.246Z | Runtime Executor | validating | completed | runtime.summary_validate | 000275 | Runtime API summary validation wrapper also registered the underlying summary-validation step. |
| 2026-05-19T18:12:29.904Z | Runtime Executor | validating | completed | runtime.cli.socket_request | summary.validate | Recheck after allowlist tightening showed summary validation still registers. |
| 2026-05-19T18:12:29.944Z | Runtime Executor | validating | completed | runtime.summary_validate | 000275 | Underlying summary validation still registers. |
| 2026-05-19T18:14:48.266Z | Runtime Executor | validating | completed | runtime.cli.socket_request | summary.validate | Final recheck after summary step classification cleanup showed wrapper step activity as `summary_validation`. |
| 2026-05-19T18:14:48.304Z | Runtime Executor | validating | completed | runtime.summary_validate | 000275 | Final recheck showed the underlying Runtime summary validator still registered its own work contract. |
| 2026-05-19T18:29:xxZ | Runtime Executor | runtime_tests | completed | runtime-test | ai/runtime/test/runtime-test.mjs | Full Runtime test suite passed after daemon reload; includes CLI work-contract regression proof. |

Read-only health/snapshot commands were initially over-registered by the generic socket wrapper. The allowlist was tightened so browser/health polling remains inspection-only and does not create false work.

## YAML Summary

```yaml
schema_version: work-control-state-report-v1
capture:
  setup_start: "2026-05-19T17:20:00Z"
  primary_start: "2026-05-19T17:52:47.062Z"
  end: pending_chunk_000276_completion
chunks:
  - id: "000275"
    status: in_progress
    evidence:
      state_model_specs: passed
      connection_status_specs: passed
      app_connection_recovery_specs: passed
      runtime_hook_map_tests: passed
      browser_proof: browser-smoke-mpcx7vdq
    observed_roles:
      - Requirements
      - Requirements Review
      - Prompt Synthesizer
      - Consultant Checkpoint
      - Orchestrator
      - Chunk Planner
      - Developer
      - QA
      - Runtime Executor
      - Dispatcher
      - Operator
      - Runtime Supervisor
      - Codex
known_gaps:
  - id: cfd-0029
    summary: hosted non-Runtime tool hook invocation and long-running parent session visibility still need full proof
```
