> For the complete documentation index, see [llms.txt](https://faction-os.gitbook.io/faction-os-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/phases/phase_10/session_03_server_ingest_codex_lifecycle.md).

# Session 03: Server Ingest Codex Lifecycle

**Session ID**: `phase10-session03-server-ingest-codex-lifecycle` **Packages**: apps/server, packages/protocol **Status**: Not Started **Estimated Tasks**: \~16-24 **Estimated Duration**: 2-4 hours

***

## Objective

Normalize Codex lifecycle fields in server ingest so Codex sessions materialize as first-class heroes and missions.

***

## Scope

### In Scope (MVP)

* Normalize Codex fields in server ingest.
* Persist `cli: "codex-cli"` to spawned heroes and mission events.
* Add server tests for Codex lifecycle, `apply_patch`, permission requests, subagent events, and unknown event fallback.
* Keep existing Claude lifecycle tests passing unchanged.

### Detailed Requirements

* Recognize `SubagentStart` with `type: "subagent_spawn"`.
* Normalize `toolName` and Codex `tool_name` to the existing `tool` field.
* Normalize `turnId` and Codex `turn_id` only as bounded metadata where needed.
* Preserve current `eventName ?? hook` dispatch behavior.
* Keep unknown Codex named events as bounded opaque `mission_event` frames.
* Ensure `cli: "codex-cli"` is accepted as a first-class CLI value.
* Use a full lifecycle fixture: `SessionStart -> UserPromptSubmit -> PreToolUse Bash -> PreToolUse apply_patch -> PermissionRequest -> SubagentStart -> SubagentStop -> Stop`.

### Out of Scope

* Web labels and filters.
* Hook installation behavior.
* Hosted ingestion or external telemetry.

***

## Prerequisites

* [ ] Session 02 complete.
* [ ] Protocol Codex identifiers available.
* [ ] Existing server ingest lifecycle tests reviewed.
* [ ] Codex hook fixture shape available from Phase 09.

***

## Deliverables

1. Codex event normalization in server ingest.
2. Hero and mission persistence for `codex-cli`.
3. Server tests for lifecycle, tool use, permission, subagent, and unknown events.
4. Regression tests showing Claude ingest remains stable.

***

## Success Criteria

* [ ] A fixture-driven Codex lifecycle materializes a `codex-cli` hero and mission.
* [ ] Unknown Codex events become bounded opaque mission events.
* [ ] Existing Claude lifecycle tests pass unchanged.


---

# 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://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/phases/phase_10/session_03_server_ingest_codex_lifecycle.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.
