> 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/phases/phase_34/session_05_runtime_api_ownership.md).

# Session 05: Runtime API Ownership

**Session ID**: `phase34-session05-runtime-api-ownership` **Status**: Not Started **Estimated Tasks**: \~12-25 **Estimated Duration**: 2-4 hours

***

## Objective

Move AI Rogue run-state mutation into simulation-owned APIs and narrow runtime entrypoints before larger module refactors.

***

## Migrated Audit Source

* Former audit sessions: 2026-06-25 Sessions 03 Architecture Boundaries, 09 Types And Schemas, and 13 Refactor Map.
* Primary findings: AR-D1-001 and AR-D1-003, with related AR-D5-002 and AR-D8-001 prerequisites.
* AR-D1-001 evidence: renderer-local selected-upgrade and progression-loadout paths mutate run state before turn 0 instead of requesting simulation-owned transitions.
* AR-D1-003 evidence: `runtime/index.ts` re-exports broad simulation/content internals, fixtures, render-model APIs, and mount/controller APIs through one public barrel.
* Refactor order from the audit: first add characterization tests, then narrow runtime API and move pre-run mutation into simulation, then stabilize schema/persistence contracts. Do not begin large module splits in this session unless those prerequisites are already covered.
* Source details are preserved in `PRD_phase_34.md` Appendix A.

***

## Scope

### In Scope (MVP)

* Move selected-upgrade and pre-start loadout application out of renderer-local mutation paths.
* Add or update simulation-owned run creation/update APIs for pre-run progression state.
* Narrow `runtime/index.ts` so mounted runtime entrypoints, simulation internals, and testing fixtures are not all exposed through one broad barrel.
* Move combat fixture exports behind an explicit test-only or internal entrypoint as needed.
* Add import/API tests or static guards that reflect the narrowed boundary.

### Out of Scope

* Full split of `simulation.ts`, `renderer.ts`, or `runtime/types.ts`.
* Behavior changes beyond moving ownership of existing state transitions.
* Default enablement.

***

## Prerequisites

* [ ] Sessions 01 and 03 have covered high-risk simulation behavior.
* [ ] Existing import-boundary tests and e2e fixture hooks are identified.

***

## Deliverables

1. Simulation-owned APIs for pre-run selected upgrade and loadout state.
2. Renderer changes that request transitions instead of mutating run state directly.
3. Narrowed runtime entrypoint exports with tests or source guards.
4. Notes listing remaining oversized-module split prerequisites.

***

## Success Criteria

* [ ] Renderer no longer mutates core run state for selected upgrade/loadout outside simulation APIs.
* [ ] Runtime public surface separates mount/controller usage from simulation internals and fixtures.
* [ ] Typecheck and AI Rogue focused tests pass or record exact blockers.


---

# 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/phases/phase_34/session_05_runtime_api_ownership.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.
