> 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_39/session_06_boss_and_finale_contracts.md).

# Session 06: Boss And Finale Contracts

**Session ID**: `phase39-session06-boss-and-finale-contracts` **Status**: Complete **Estimated Tasks**: 20 **Estimated Duration**: 2-4 hours **Completed**: 2026-07-01

***

## Objective

Generalize Kernel Sentinel into the first boss spec and remove literal boss branching from render, audio, combat, and presentation paths.

***

## Scope

### In Scope (MVP)

* Introduce `AiRogueBossSpec` with kind ID, frame set, sprite scale, audio family, reveal behavior, telegraph behavior, shutdown behavior, and finale ownership.
* Add `isBossEnemyKind()` or `bossSpecForEnemyKind()`.
* Replace Kernel Sentinel-specific helper internals with boss-spec-based helpers while preserving current behavior.
* Replace hard-coded Kernel Sentinel checks in boss presentation, render model, renderer-audio adapter, effects, combat audio metadata, and related tests.
* Move final-defense display rules from raw `depth >= 3` to `levelSpec.isFinale` or a finale presentation spec.

### Out of Scope

* Adding a second boss or miniboss before Kernel Sentinel passes unchanged through the generalized path.
* Changing Kernel Sentinel gameplay logic, footprint, pathing, or win conditions.

***

## Detailed Plan Notes

* Boss behavior currently means `kernel-sentinel` literally. The kind appears in `runtime/boss-presentation.ts`, `runtime/render-model.ts:490`, `runtime/renderer-audio-adapter.ts:202`, `runtime/effects.ts`, and `runtime/combat.ts`.
* A second boss would require renderer, audio, combat, and presentation branches unless the boss contract becomes data-driven.
* `AiRogueBossSpec` should include kind ID, frame set, sprite scale, audio family, reveal behavior, telegraph behavior, shutdown behavior, and finale ownership.
* Replace `isKernelSentinelEntity()` and `selectKernelSentinelFrame()` internals with boss-spec-based helpers while preserving current behavior.
* Replace hard-coded Kernel Sentinel checks in render model, effects, renderer-audio adapter, combat audio metadata, and presentation tests with boss-spec helpers.
* Split final-defense display rules from raw `depth >= 3`; use `levelSpec.isFinale` or a finale presentation spec.
* Only add a second boss or miniboss after the generalized path passes the existing Kernel Sentinel tests unchanged.

***

## Prerequisites

* [x] Sessions 02 and 03 are complete.
* [x] Relevant frame metadata from Session 05 is available.

### Implementation Verification Notes

* Session 02 implementation notes report 20 / 20 tasks complete with no blockers; authored depth decisions route through level specs and `authoredLevelSpecForDepth()` is available for non-throwing lookups.
* Session 03 implementation notes report 16 / 16 tasks complete with no blockers; content registry validation and save-schema parity gates are in place for level references.
* Session 05 implementation notes report 18 / 18 tasks complete with no blockers; Kernel Sentinel has `bossFrameSet` metadata for idle, charge, telegraph, attack, shielded, hit, and shutdown frames.

***

## Deliverables

1. A reusable boss contract with Kernel Sentinel represented as the first boss spec.
2. Renderer, audio, effects, combat, and presentation code that reads boss metadata instead of checking one literal kind.
3. Finale display routing driven by level or finale specs.

***

## Success Criteria

* [x] Kernel Sentinel behavior remains unchanged.
* [x] `boss-presentation.test.ts`, `render-model.test.ts`, `renderer-audio-adapter.test.ts`, `audio.test.ts`, and `combat.test.ts` pass.
* [x] Adding another boss would require specs, frames, audio mapping, and tests rather than new renderer-specific branches.
* [x] Finale display routing is driven by level or finale specs rather than a raw depth comparison.


---

# 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_39/session_06_boss_and_finale_contracts.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.
