> 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_36/session_02_enemy_audio_metadata.md).

# Session 02: Enemy Audio Metadata

**Session ID**: `phase36-session02-enemy-audio-metadata` **Status**: Complete **Estimated Tasks**: \~12-25 **Estimated Duration**: 2-4 hours

***

## Objective

Add the structured runtime metadata needed to route enemy-family audio without making audio selection part of deterministic game state.

***

## Scope

### In Scope (MVP)

* Add actor kind, enemy kind, or equivalent stable metadata to relevant simulation events.
* Replace fragile fallback message checks where typed metadata can express the same audio intent.
* Keep `renderer-audio-adapter` and sound selection as presentation-layer behavior.
* Add or update tests for stable dispatch and deterministic variant selection.

### Out of Scope

* Generating or committing new enemy SFX files.
* Changing simulation decisions, RNG, replay behavior, or save contracts for audio routing.

***

## Prerequisites

* [x] Session 01 balance findings are available.
* [x] Current audio event and simulation event contracts are understood.

***

## Deliverables

1. Typed event metadata for enemy attack, hit, defeated, sentry, and boss audio routing.
2. Updated audio dispatch logic that prefers typed metadata over message text.
3. Focused tests proving stable cue dispatch for equivalent events.

***

## Success Criteria

* [x] Equivalent events dispatch stable cue IDs.
* [x] Existing combat and simulation tests still pass.
* [x] No simulation state, RNG, replay behavior, or save data depends on audio routing.
* [x] The product outcome is proven end to end: enemy-related runtime events carry metadata through real dispatch paths, old fallback behavior still recovers safely, and tests prove equivalent events choose stable cues.

## Folded Source Detail Routed To This Session

### Source Findings Owned

* A7 says many high-value cues now use explicit `event.audioCues`, but some fallback paths still infer cues from broad event classes or message text.
* A7 says richer audio identity needs access to actor kind, protocol kind, objective state, status kind, and theme without introducing simulation side effects.
* A3 says enemy melee now has its own cue, but enemy-family identity still mostly collapses to shared attack, telegraph, status, and defeated sounds.
* A1 leaves open that more typed metadata could replace remaining fallback message checks.

### Metadata Needs From The Folded Source

* Actor kind for enemy-family cues.
* Protocol ID for protocol action cues.
* Status ID for status apply/expire/cleanse cues.
* Theme ID for ambience or music routing.
* Objective event kind for vault, terminal, key, compile, and final defense cues.

### Source Touchpoints

* `src/extensions/ai-rogue/runtime/combat.ts`
* `src/extensions/ai-rogue/runtime/entities.ts`
* `src/extensions/ai-rogue/runtime/protocols.ts`
* `src/extensions/ai-rogue/runtime/equipment.ts`
* `src/extensions/ai-rogue/runtime/status.ts`
* `src/extensions/ai-rogue/runtime/themes.ts`
* `src/extensions/ai-rogue/runtime/snapshot.ts`
* `src/extensions/ai-rogue/runtime/audio.ts`
* `src/extensions/ai-rogue/runtime/renderer-audio-adapter.ts`
* `src/extensions/ai-rogue/runtime/__tests__/audio.test.ts`

### Constraints

* Keep the audio adapter as presentation code.
* Do not let sound selection affect deterministic game state.
* Do not change simulation decisions, RNG, replay behavior, save data, or browser-local state for audio routing.
* Keep tests that prove equivalent events dispatch stable cue IDs.


---

# 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_36/session_02_enemy_audio_metadata.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.
