> 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/sessions/phase39-session06-boss-and-finale-contracts/implementation-notes.md).

# Implementation Notes

**Session ID**: `phase39-session06-boss-and-finale-contracts` **Started**: 2026-06-30 23:00 **Last Updated**: 2026-06-30 23:36

***

## Session Progress

| Metric              | Value     |
| ------------------- | --------- |
| Tasks Completed     | 20 / 20   |
| Estimated Remaining | 0 minutes |
| Blockers            | 0         |

***

## Task Log

### 2026-06-30 - Session Start

**Environment verified**:

* [x] Prerequisites confirmed
* [x] Tools available
* [x] Directory structure ready

**Checks**:

* `bash .spec_system/scripts/analyze-project.sh --json`
  * Result: PASS - current session resolved to `phase39-session06-boss-and-finale-contracts`; session directory exists with `spec.md` and `tasks.md`.
* `bash .spec_system/scripts/check-prereqs.sh --json --env`
  * Result: PASS - `.spec_system`, `jq`, and `git` are available.
* `bash .spec_system/scripts/check-prereqs.sh --json --tools "bun,bunx"`
  * Result: PASS - Bun and bunx are available at version 1.3.14.

***

### Task T001 - Verify Session 02, Session 03, and Session 05 prerequisites

**Started**: 2026-06-30 23:01 **Completed**: 2026-06-30 23:01 **Duration**: 1 minute

**Notes**:

* Confirmed Session 02 implementation notes report 20 / 20 tasks complete with no blockers.
* Confirmed Session 03 implementation notes report 16 / 16 tasks complete with no blockers.
* Confirmed Session 05 implementation notes report 18 / 18 tasks complete with no blockers and specifically landed Kernel Sentinel `bossFrameSet` metadata.
* Updated the Session 06 phase note prerequisites from unchecked to checked and recorded implementation-relevant prerequisite notes.

**Files Changed**:

* `.spec_system/PRD/phase_39/session_06_boss_and_finale_contracts.md` - Marked prerequisites complete and recorded prior-session source facts for implementation.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Added progress summary and marked T001 complete.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T001 evidence.

**Verification**:

* Command/check: `sed -n '1,220p' .spec_system/PRD/phase_39/session_02_depth_resolver_migration.md .spec_system/PRD/phase_39/session_03_registry_validation_and_save_parity.md .spec_system/PRD/phase_39/session_05_enemy_metadata_and_derived_asset_checks.md`
  * Result: PASS - Prior phase notes define the prerequisite depth resolver, registry validation, and enemy metadata scopes needed by this session.
  * Evidence: Session 02 owns level-spec depth routing; Session 03 owns registry validation; Session 05 owns enemy audio and Kernel Sentinel frame metadata.
* Command/check: `sed -n '1,220p' .spec_system/specs/phase39-session02-depth-resolver-migration/implementation-notes.md .spec_system/specs/phase39-session03-registry-validation-and-save-parity/implementation-notes.md .spec_system/specs/phase39-session05-enemy-metadata-and-derived-asset-checks/implementation-notes.md`
  * Result: PASS - Implementation artifacts confirm prerequisite sessions completed with no blockers.
  * Evidence: Session 02 reports 20 / 20 tasks, Session 03 reports 16 / 16 tasks, and Session 05 reports 18 / 18 tasks.
* UI product-surface check: N/A - Session artifact verification only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* N/A - No application code changed in this task.

***

### Task T002 - Inventory current Kernel Sentinel and final-defense literal callsites

**Started**: 2026-06-30 23:02 **Completed**: 2026-06-30 23:03 **Duration**: 1 minute

**Notes**:

* Located literal Kernel Sentinel checks in boss presentation, render model, renderer audio, effects, combat, world generation, content validation, and tests.
* Identified migration targets where boss identity is the only reason for the branch: `boss-presentation.ts`, `render-model.ts`, `renderer-audio-adapter.ts`, `effects.ts`, `combat.ts`, and `content/validate.ts`.
* Identified final-defense presentation ownership currently includes `snapshot.depth >= 3` in `shouldShowFinalDefensePresentation()`, while authored finale metadata marks depth 4 as final.
* Kept world-generation `kernel-sentinel` references out of scope because this session preserves current boss placement and pathing behavior.

**Files Changed**:

* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T002 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T002 callsite inventory evidence.

**Verification**:

* Command/check: `rg -n "kernel-sentinel|Kernel Sentinel|isKernelSentinel|selectKernelSentinel|depth >= 3|depth > 3|final-defense|finalDefense|isFinalAuthoredLevel|finale" src/extensions/ai-rogue/runtime .spec_system/PRD/phase_39/session_06_boss_and_finale_contracts.md`
  * Result: PASS - Current literal boss and finale callsites were inventoried before source edits.
  * Evidence: Runtime matches include `boss-presentation.ts`, `render-model.ts`, `render-hud.ts`, `renderer-audio-adapter.ts`, `effects.ts`, `combat.ts`, `content/types.ts`, and `content/validate.ts`.
* Command/check: targeted inspection of `src/extensions/ai-rogue/runtime/boss-presentation.ts`, `render-model.ts`, `render-hud.ts`, `renderer-audio-adapter.ts`, `effects.ts`, `combat.ts`, `content/types.ts`, and `content/validate.ts`
  * Result: PASS - Confirmed which branches are presentation/audio/combat identity routing versus placement or fixture assertions.
  * Evidence: Boss frame priority and raw final-defense depth fallback are centralized in `boss-presentation.ts`; downstream consumers call those helpers or use direct literal checks.
* UI product-surface check: N/A - Source inventory only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* N/A - No application code changed in this task.

***

### Task T003 - Confirm boss frame metadata and finale level metadata source facts

**Started**: 2026-06-30 23:03 **Completed**: 2026-06-30 23:04 **Duration**: 1 minute

**Notes**:

* Confirmed `AI_ROGUE_ENEMY_TEMPLATES["kernel-sentinel"]` owns `audioFamily: "boss"`, `spriteScale: 2`, and `bossFrameSet` values for idle, charge, telegraph, attack, shielded, hit, and shutdown.
* Confirmed `bossFrameSetForEnemyKind()` already exposes boss frame metadata from enemy templates.
* Confirmed `AI_ROGUE_LEVEL_SPECS` marks depth 4 `firewall-gauntlet` as `finale.isFinalAuthoredLevel: true`, `bossKind: "kernel-sentinel"`, and `requiresFloorObjectiveClear: true`.
* Confirmed depth 3 still places Kernel Sentinel as an exit guard but is not the authored finale, so final-defense presentation must not be owned by raw `depth >= 3`.

**Files Changed**:

* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T003 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T003 source-fact evidence.

**Verification**:

* Command/check: `sed -n '180,250p' src/extensions/ai-rogue/runtime/entities.ts`
  * Result: PASS - Kernel Sentinel template contains the boss metadata needed for the contract.
  * Evidence: The template includes boss audio family, sprite scale 2, shield-pierce behavior, and the seven boss frame groups.
* Command/check: `sed -n '1,180p' src/extensions/ai-rogue/runtime/content/levels.ts`
  * Result: PASS - Authored level specs contain the finale metadata needed for presentation routing.
  * Evidence: Depth 4 is the only `isFinalAuthoredLevel: true` level and owns the finale boss; depth 3 keeps Kernel Sentinel placement without finale ownership.
* Command/check: `rg -n "bossFrameSetForEnemyKind|standardEnemyFrameSetForKind|audioFamilyForEnemyKind|bossFrameSet|spriteScale|kernel-sentinel" src/extensions/ai-rogue/runtime/entities.ts src/extensions/ai-rogue/runtime/types-entities.ts src/extensions/ai-rogue/runtime/audio.ts`
  * Result: PASS - Existing lookup and metadata ownership points were identified.
  * Evidence: `bossFrameSetForEnemyKind()` returns template `bossFrameSet`; audio family routing still projects from enemy metadata.
* UI product-surface check: N/A - Source-fact verification only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Confirmed contract data sources before introducing the wrapper module, avoiding duplicated literal frame data in consumers.

***

### Task T004 - Create typed boss and finale contract helpers

**Started**: 2026-06-30 23:04 **Completed**: 2026-06-30 23:07 **Duration**: 3 minutes

**Notes**:

* Added `AiRogueBossSpec`, `AiRogueBossEnemyKind`, `AI_ROGUE_BOSS_ENEMY_KINDS`, `bossSpecForEnemyKind()`, and `isBossEnemyKind()`.
* Projected Kernel Sentinel from enemy template metadata, including boss frame set, presentation frames, sprite scale, boss audio family, reveal cue, telegraph cue, attack cue, hit cue, and shutdown cue.
* Added non-throwing finale helpers that use `authoredLevelSpecForDepth()` and return a presentation spec only for authored final levels.
* Kept the single boss kind literal inside the contract module so downstream runtime consumers can avoid local boss identity branches.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/boss-contracts.ts` - Added typed boss and authored-finale contract helpers.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T004 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T004 evidence.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - TypeScript accepted the new boss and finale contract module.
  * Evidence: `tsc --noEmit` completed successfully.
* Command/check: `bun -e "import { AI_ROGUE_BOSS_ENEMY_KINDS, bossSpecForEnemyKind, isBossEnemyKind, finalePresentationSpecForDepth } from './src/extensions/ai-rogue/runtime/boss-contracts.ts'; const spec = bossSpecForEnemyKind('kernel-sentinel'); console.log(JSON.stringify({ kinds: AI_ROGUE_BOSS_ENEMY_KINDS, isBoss: isBossEnemyKind('kernel-sentinel'), unknown: bossSpecForEnemyKind('errant-process'), spriteScale: spec?.spriteScale, idle: spec?.presentationFrameSet.idle, finaleDepth3: finalePresentationSpecForDepth(3), finaleDepth4: finalePresentationSpecForDepth(4)?.boss?.kind }));"`
  * Result: PASS - Boss lookup, unknown fallback, presentation idle frames, and finale gating behaved as expected.
  * Evidence: Output showed Kernel Sentinel as the only boss, `errant-process` as null, sprite scale 2, depth 3 finale null, and depth 4 finale boss `kernel-sentinel`.
* UI product-surface check: N/A - Runtime contract module only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: The boss contract reads enemy template and authored level metadata instead of duplicating frame, audio, or finale state in consumers.

***

### Task T005 - Implement boss-spec-based frame selection

**Started**: 2026-06-30 23:07 **Completed**: 2026-06-30 23:10 **Duration**: 3 minutes

**Notes**:

* Added generic `isBossEntity()` and `selectBossFrame()` helpers in `boss-presentation.ts`.
* Reworked Kernel Sentinel frame priority through `AiRogueBossSpec` presentation frames while preserving the existing shutdown, hit, shielded, attack, pending telegraph, charge, idle order.
* Kept legacy `isKernelSentinelEntity()` and `selectKernelSentinelFrame()` wrappers delegating to the generic helpers for compatibility until consumers migrate.
* Preserved unknown-kind fallback behavior by returning the default boss idle presentation frame.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/boss-presentation.ts` - Routed boss frame selection through boss specs and generic metadata matching.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T005 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T005 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts`
  * Result: PASS - Existing Kernel Sentinel frame and finale presentation tests passed.
  * Evidence: 1 test file passed; 6 tests passed.
* Command/check: `rg -n "kernel-sentinel|boss_kernel_sentinel|selectKernelSentinel|isKernelSentinel|depth >= 3" src/extensions/ai-rogue/runtime/boss-presentation.ts`
  * Result: PASS - Kernel Sentinel frame literals were removed from frame-selection internals; only compatibility wrapper names and the pre-existing final-defense depth gate remained.
  * Evidence: Matches were `isKernelSentinelEntity`, `selectKernelSentinelFrame`, and `snapshot.depth >= 3`.
* UI product-surface check: N/A - Runtime projection helper only; no route-visible UI changed.
* UI craft check: N/A - No UI layout or copy changed.

**BQC Fixes**:

* Contract alignment: Boss frame selection now reads the declared boss presentation contract instead of hard-coded Kernel Sentinel frame literals.

***

### Task T006 - Implement authored-finale display helpers

**Started**: 2026-06-30 23:10 **Completed**: 2026-06-30 23:11 **Duration**: 1 minute

**Notes**:

* Replaced the raw `snapshot.depth >= 3` final-defense presentation gate with `finalePresentationSpecForDepth(snapshot.depth)`.
* Removed floor-objective-only ownership from final-defense display routing so non-final authored floors with objectives do not show finale markers by default.
* Preserved non-throwing invalid-depth fallback behavior for synthetic snapshots that already contain won status or final-defense audio events.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/boss-presentation.ts` - Routed final-defense display gating through authored finale metadata.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T006 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T006 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts`
  * Result: PASS - Existing boss presentation suite remained green after the finale gate migration.
  * Evidence: 1 test file passed; 6 tests passed.
* Command/check: `bun -e "import { shouldShowFinalDefensePresentation } from './src/extensions/ai-rogue/runtime/boss-presentation.ts'; const base = { combatLog: [], floorObjective: { kind: 'purge-dumps', label: 'Purge', target: 2, progress: 0, isComplete: false }, status: 'active' }; console.log(JSON.stringify({ depth3: shouldShowFinalDefensePresentation({ ...base, depth: 3 }), depth4: shouldShowFinalDefensePresentation({ ...base, depth: 4 }), invalidWon: shouldShowFinalDefensePresentation({ ...base, depth: 99, status: 'won' }) }));"`
  * Result: PASS - Authored finale gating and invalid-depth fallback behaved as intended.
  * Evidence: Output was `{"depth3":false,"depth4":true,"invalidWon":true}`.
* UI product-surface check: N/A - Runtime projection gate only; route-visible smoke is deferred until render/HUD consumers migrate.
* UI craft check: N/A - No UI layout or copy changed.

**BQC Fixes**:

* Contract alignment: Final-defense display ownership now comes from authored finale metadata instead of an unrelated depth comparison.

***

### Task T007 - Update content finale boss typing

**Started**: 2026-06-30 23:12 **Completed**: 2026-06-30 23:13 **Duration**: 1 minute

**Notes**:

* Changed `AiRogueLevelFinaleSpec.bossKind` to use `AiRogueBossEnemyKind | null`.
* Kept the import type-only so content types do not add runtime renderer, route, bridge, telemetry, or save-shape dependencies.
* Did not add any persisted save fields; finale boss metadata remains derived from authored level specs.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/content/types.ts` - Replaced local boss extraction with the boss contract kind type.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T007 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T007 evidence.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - TypeScript accepted the content finale boss type migration.
  * Evidence: `tsc --noEmit` completed successfully.
* Command/check: `sed -n '1,40p' src/extensions/ai-rogue/runtime/content/types.ts`
  * Result: PASS - `AiRogueLevelFinaleSpec.bossKind` now uses the boss contract type through an `import type`.
  * Evidence: The file imports `AiRogueBossEnemyKind` and declares `bossKind: AiRogueBossEnemyKind | null`.
* UI product-surface check: N/A - Type-only content contract change; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Finale boss typing now depends on the declared boss contract instead of an independent local literal extraction.

***

### Task T008 - Update content registry finale boss validation

**Started**: 2026-06-30 23:13 **Completed**: 2026-06-30 23:15 **Duration**: 2 minutes

**Notes**:

* Removed the local finale boss set from `content/validate.ts`.
* Added `validateNullableBossReference()` so finale boss references are accepted only when `bossSpecForEnemyKind()` resolves a declared boss spec.
* Preserved existing safe issue mapping: malformed or unknown finale boss values still report `invalid-boss-reference` at the `finale.bossKind` path without echoing unsafe values.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/content/validate.ts` - Validates finale boss references through the boss contract.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T008 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T008 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts`
  * Result: PASS - Content registry validation tests passed.
  * Evidence: 1 test file passed; 7 tests passed.
* Command/check: `bun run typecheck`
  * Result: PASS - TypeScript accepted the validation import and helper.
  * Evidence: `tsc --noEmit` completed successfully.
* Command/check: `rg -n "AI_ROGUE_BOSS_ENEMY_KINDS|validateNullableBossReference|bossSpecForEnemyKind" src/extensions/ai-rogue/runtime/content/validate.ts`
  * Result: PASS - Local boss set was removed and validation now routes through `bossSpecForEnemyKind()`.
  * Evidence: Matches show the boss contract import and `validateNullableBossReference()` implementation only.
* UI product-surface check: N/A - Content validation logic only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Trust boundary enforcement: Finale boss references crossing from authored content into validation are checked with an explicit local schema/type guard and boss contract lookup.
* Contract alignment: Validation now depends on the same boss spec registry as runtime projection.

***

### Task T009 - Replace render-model boss and final-defense projection branches

**Started**: 2026-06-30 23:15 **Completed**: 2026-06-30 23:16 **Duration**: 1 minute

**Notes**:

* Replaced the render-model Kernel Sentinel entity check with `isBossEnemyKind()` and `selectBossFrame()`.
* Kept final-defense sprite projection behind `shouldShowFinalDefensePresentation()`, which now uses authored finale metadata.
* Confirmed projected final-defense labels remain product-facing labels such as "Final defense arena", "Objective progress", "Payload active", and "Win unlock".

**Files Changed**:

* `src/extensions/ai-rogue/runtime/render-model.ts` - Routed boss frames through boss helpers and retained authored-finale display gating.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T009 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T009 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts`
  * Result: PASS - Render model projection suite passed.
  * Evidence: 1 test file passed; 22 tests passed.
* Command/check: `rg -n "kernel-sentinel|selectKernelSentinel|depth >= 3|final-defense" src/extensions/ai-rogue/runtime/render-model.ts`
  * Result: PASS - No Kernel Sentinel literal branch or raw depth gate remains in render-model.
  * Evidence: Matches are only the product-facing final-defense sprite IDs.
* UI product-surface check: PASS - Source inspection of projected sprite labels confirmed normal render labels remain product-facing and contain no debug, seed, path, telemetry, or frame readouts.
* UI craft check: PASS - No layout, sizing, responsive behavior, or visible UI copy was changed; existing render projection tests remained green.

**BQC Fixes**:

* Contract alignment: Boss render frames now consume the boss contract helper instead of a local identity branch.
* Product surface discipline: Final-defense projection labels remain product-facing only.

***

### Task T010 - Replace HUD final-defense gating with authored finale helpers

**Started**: 2026-06-30 23:16 **Completed**: 2026-06-30 23:17 **Duration**: 1 minute

**Notes**:

* Verified `render-hud.ts` already routed final-defense HUD state through `shouldShowFinalDefensePresentation()` and `selectFinalDefensePresentation()`.
* T006 migrated that shared helper to authored finale metadata, so HUD objective icons and descriptors now inherit the authored finale gate without a redundant local edit.
* Confirmed HUD depth text remains run context copy, not final-defense ownership logic.

**Files Changed**:

* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T010 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T010 evidence.

**Verification**:

* Command/check: `rg -n "depth >= 3|snapshot.depth|shouldShowFinalDefensePresentation|selectFinalDefensePresentation|finalDefensePresentation" src/extensions/ai-rogue/runtime/render-hud.ts`
  * Result: PASS - HUD has no local raw final-defense depth gate and uses the shared authored-finale helper.
  * Evidence: Matches show helper calls at HUD projection and descriptor sites; `snapshot.depth` appears only in product-facing run context text.
* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts`
  * Result: PASS - Render model and HUD projection coverage remained green.
  * Evidence: 1 test file passed; 22 tests passed.
* UI product-surface check: PASS - Source inspection confirmed HUD labels remain product-facing and no debug, seed, path, telemetry, or frame readouts were introduced.
* UI craft check: PASS - No HUD layout, sizing, responsive behavior, or visible copy was changed.

**BQC Fixes**:

* Contract alignment: HUD final-defense display depends on the shared authored-finale gate instead of owning a separate condition.

***

### Task T011 - Replace renderer audio visible-boss reveal detection

**Started**: 2026-06-30 23:17 **Completed**: 2026-06-30 23:18 **Duration**: 1 minute

**Notes**:

* Replaced the renderer audio `kernel-sentinel` visibility check with `bossSpecForEnemyKind()` and `revealBehavior.isVisibleRevealTracked`.
* Preserved transition-only behavior by leaving the previous-snapshot to current-snapshot comparison unchanged.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/renderer-audio-adapter.ts` - Uses boss helper metadata for visible boss reveal detection.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T011 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T011 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts`
  * Result: PASS - Renderer audio adapter suite passed.
  * Evidence: 1 test file passed; 11 tests passed.
* Command/check: `rg -n "kernel-sentinel|stinger_boss_reveal|bossSpecForEnemyKind|hasVisibleBoss" src/extensions/ai-rogue/runtime/renderer-audio-adapter.ts`
  * Result: PASS - No boss-kind literal remains in renderer audio reveal detection.
  * Evidence: Matches show only the boss contract import and `hasVisibleBoss()` helper.
* UI product-surface check: N/A - Audio adapter behavior only; no route-visible UI changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Visible boss reveal audio now follows the declared boss reveal behavior instead of a local enemy-kind literal.

***

### Task T012 - Replace effects boss actor and target detection

**Started**: 2026-06-30 23:18 **Completed**: 2026-06-30 23:19 **Duration**: 1 minute

**Notes**:

* Replaced effects-layer Kernel Sentinel metadata checks with `isBossEnemyKind()` for actor and target enemy metadata.
* Preserved missing-metadata fallback behavior by keeping boss audio cue checks for charge, fire, hit, and shutdown events.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/effects.ts` - Uses boss helpers for boss actor and target detection.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T012 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T012 evidence.

**Verification**:

* Command/check: `bun run typecheck`
  * Result: PASS - TypeScript accepted the effects helper migration.
  * Evidence: `tsc --noEmit` completed successfully.
* Command/check: `rg -n "kernel-sentinel|isBossEnemyKind|boss_charge|boss_fire|boss_hit|boss_shutdown" src/extensions/ai-rogue/runtime/effects.ts`
  * Result: PASS - No boss-kind literal remains; cue fallbacks remain for missing metadata.
  * Evidence: Matches show `isBossEnemyKind()` and the existing boss cue checks.
* UI product-surface check: N/A - Effects routing only; no route-visible UI changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Effects boss actor/target detection now follows the shared boss kind contract while preserving cue-only fallback paths.

***

### Task T013 - Replace combat boss audio actor and boss cue branching

**Started**: 2026-06-30 23:19 **Completed**: 2026-06-30 23:23 **Duration**: 4 minutes

**Notes**:

* Added required boss actor and attack cue accessors to `boss-contracts.ts`.
* Routed `audioActorKindForEnemy()` through `isBossEnemyKind()` and `requiredBossAudioActorKindForEnemyKind()`.
* Routed enemy attack cue selection through `requiredBossAttackCueForEnemyKind()`.
* Also moved the combat alternate boss frame selection through `bossSpecForEnemyKind()` and `selectBossPresentationFrame()` so combat no longer owns a boss-kind literal.
* Preserved Kernel Sentinel shield-pierce behavior because that remains template metadata on the enemy state and was not changed.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/boss-contracts.ts` - Added required boss actor and attack cue accessors.
* `src/extensions/ai-rogue/runtime/combat.ts` - Uses boss helpers for boss audio metadata, attack cues, and alternate boss frame projection.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T013 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T013 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/combat.test.ts`
  * Result: PASS - Combat suite passed.
  * Evidence: 1 test file passed; 8 tests passed.
* Command/check: `bun run typecheck`
  * Result: PASS - TypeScript accepted the narrowed boss helper routing.
  * Evidence: `tsc --noEmit` completed successfully.
* Command/check: `rg -n "kernel-sentinel|boss_fire|requiredBoss|isBossEnemyKind|bossSpecForEnemyKind|selectBossPresentationFrame" src/extensions/ai-rogue/runtime/combat.ts`
  * Result: PASS - No boss-kind literal or direct boss cue branch remains in combat.
  * Evidence: Matches show only boss helper imports and calls.
* UI product-surface check: N/A - Combat metadata and frame routing only; no route-visible UI changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Combat boss metadata and cue routing now follows the boss contract, and the remaining boss alternate frame projection uses the same presentation contract as rendering.

***

### Task T014 - Ensure boss audio family cue routing remains metadata-backed

**Started**: 2026-06-30 23:23 **Completed**: 2026-06-30 23:25 **Duration**: 2 minutes

**Notes**:

* Verified `audio.ts` still resolves enemy cue families through `enemyAudioFamilyForKind()` and therefore through enemy template metadata.
* Verified Kernel Sentinel boss cue asset parity remains covered by the existing audio test suite.
* No `audio.ts` source edit was required because the intended metadata-backed routing already existed from Session 05 and remained compatible with the new boss contract.

**Files Changed**:

* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T014 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T014 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/audio.test.ts`
  * Result: PASS - Audio suite passed.
  * Evidence: 1 test file passed; 33 tests passed.
* Command/check: `sed -n '912,1010p' src/extensions/ai-rogue/runtime/audio.ts`
  * Result: PASS - Boss attack, telegraph, hit, and shutdown cue routing derives from `audioFamilyForEnemyKind()`, which calls `enemyAudioFamilyForKind()`.
  * Evidence: The inspected code maps the `"boss"` audio family to `boss_fire`, `boss_charge`, `boss_hit`, and `boss_shutdown`.
* Command/check: `rg -n "export function|function .*Cue|audioFamilyForEnemyKind|enemyAudioFamilyForKind|describe\\(\\\".*boss|boss_fire|boss_charge|boss_hit|boss_shutdown" src/extensions/ai-rogue/runtime/audio.ts src/extensions/ai-rogue/runtime/__tests__/audio.test.ts`
  * Result: PASS - Source and tests cover boss cue asset names and metadata-backed audio family routing.
  * Evidence: Matches include `enemyAudioFamilyForKind()` usage in `audio.ts` and audio tests covering boss charge, fire, hit, and shutdown asset filenames.
* UI product-surface check: N/A - Audio routing only; no route-visible UI changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Confirmed boss audio remains metadata-backed and unchanged for Kernel Sentinel cue parity.

***

### Task T015 - Add boss contract, frame parity, and finale gating coverage

**Started**: 2026-06-30 23:25 **Completed**: 2026-06-30 23:26 **Duration**: 1 minute

**Notes**:

* Added boss contract assertions for Kernel Sentinel spec lookup, standard enemy rejection, boss audio cues, sprite scale, and presentation frame parity.
* Switched boss-presentation frame assertions from the legacy Kernel Sentinel wrapper to generic `selectBossFrame()`.
* Added authored finale ownership assertions for depth 3, depth 4, invalid depth, won fallback, and compile-payload fallback.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts` - Added boss contract and authored finale gating coverage.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T015 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T015 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts`
  * Result: PASS - Boss presentation suite passed.
  * Evidence: 1 test file passed; 10 tests passed.
* Command/check: `rg -n "selectKernelSentinelFrame|bossSpecForEnemyKind|finalePresentationSpecForDepth|shouldShowFinalDefensePresentation|selectBossFrame" src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts`
  * Result: PASS - Tests assert the generic boss contract and no longer call the legacy frame wrapper.
  * Evidence: Matches show `bossSpecForEnemyKind`, `finalePresentationSpecForDepth`, `shouldShowFinalDefensePresentation`, and `selectBossFrame`; no `selectKernelSentinelFrame` match.
* UI product-surface check: N/A - Unit test coverage only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Added tests that lock boss contract lookup, frame projection, and authored finale gating to the declared runtime contracts.

***

### Task T016 - Update render model boss-spec and finale coverage

**Started**: 2026-06-30 23:26 **Completed**: 2026-06-30 23:27 **Duration**: 1 minute

**Notes**:

* Updated boss frame expectations to read from `bossSpecForEnemyKind("kernel-sentinel")`.
* Changed final-defense projection coverage to use authored finale depth 4.
* Added a negative case proving depth 3 objective floors do not project final-defense markers without authored finale ownership or explicit finale evidence.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts` - Added boss-spec frame and authored-finale projection coverage.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T016 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T016 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts`
  * Result: PASS - Render model suite passed.
  * Evidence: 1 test file passed; 23 tests passed.
* Command/check: `rg -n "bossSpecForEnemyKind|depth: 4|depth: 3|final-defense|Kernel Sentinel G5" src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts`
  * Result: PASS - Test coverage includes boss-spec frame assertions, depth 4 final-defense projection, and depth 3 non-finale negative coverage.
  * Evidence: Matches show the boss spec import, depth 4 finale projection, and the depth 3 no-final-defense assertion.
* UI product-surface check: PASS - Render model labels remain product-facing; no debug, telemetry, seed, or frame labels were introduced.
* UI craft check: PASS - Projection tests still validate deterministic ordering and HUD descriptor behavior; no layout or visual sizing code changed.

**BQC Fixes**:

* Contract alignment: Render tests now verify boss frames and final-defense projection against the declared boss and authored finale contracts.

***

### Task T017 - Update audio adapter, combat, and audio boss-helper tests

**Started**: 2026-06-30 23:27 **Completed**: 2026-06-30 23:31 **Duration**: 4 minutes

**Notes**:

* Updated renderer audio adapter reveal tests to use `bossSpecForEnemyKind()` for the boss kind and to assert reveal behavior is enabled by the boss spec.
* Updated combat metadata and cue tests to use boss contract kind and attack cue values.
* Updated audio metadata SFX tests to use boss contract kind values and assert Kernel Sentinel boss cue parity remains `boss_charge`, `boss_fire`, `boss_hit`, and `boss_shutdown`.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts` - Uses boss contract values for visible boss reveal tests.
* `src/extensions/ai-rogue/runtime/__tests__/combat.test.ts` - Uses boss contract values for boss metadata and cue tests.
* `src/extensions/ai-rogue/runtime/__tests__/audio.test.ts` - Uses boss contract values for boss metadata SFX tests and cue parity assertions.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T017 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T017 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts`
  * Result: PASS - Renderer audio adapter suite passed.
  * Evidence: 1 test file passed; 11 tests passed.
* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/combat.test.ts`
  * Result: PASS - Combat suite passed.
  * Evidence: 1 test file passed; 8 tests passed.
* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/audio.test.ts`
  * Result: PASS - Audio suite passed.
  * Evidence: 1 test file passed; 33 tests passed.
* Command/check: `rg -n "bossSpecForEnemyKind|kernel-sentinel|boss_fire|boss_reveal" src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts src/extensions/ai-rogue/runtime/__tests__/combat.test.ts src/extensions/ai-rogue/runtime/__tests__/audio.test.ts`
  * Result: PASS - Relevant boss helper tests now import the boss contract while retaining explicit Kernel Sentinel parity lookup values.
  * Evidence: Matches show `bossSpecForEnemyKind()` in all three suites and cue parity assertions in audio tests.
* UI product-surface check: N/A - Test-only task; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Contract alignment: Audio adapter, combat, and audio tests now verify boss routing against the declared boss contract while preserving Kernel Sentinel cue parity.

***

### Task T018 - Update content registry finale boss contract tests

**Started**: 2026-06-30 23:31 **Completed**: 2026-06-30 23:33 **Duration**: 2 minutes

**Notes**:

* Added a content registry test proving the authored finale boss resolves through `bossSpecForEnemyKind()`.
* Added explicit assertions that a standard enemy and unsafe reference both produce `invalid-boss-reference` at `finale.bossKind`.
* Kept existing unsafe-value redaction assertions intact.

**Files Changed**:

* `src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts` - Added finale boss contract validation coverage.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T018 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T018 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts`
  * Result: PASS - Content registry suite passed.
  * Evidence: 1 test file passed; 8 tests passed.
* Command/check: `rg -n "bossSpecForEnemyKind|validates finale boss references|invalid-boss-reference|errant-process|UNSAFE_REFERENCE_VALUE" src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts`
  * Result: PASS - Test file includes boss contract lookup, standard-enemy rejection, and unsafe-reference rejection coverage.
  * Evidence: Matches show `bossSpecForEnemyKind()`, the new finale boss test, and `invalid-boss-reference` cases.
* UI product-surface check: N/A - Content validation tests only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* Trust boundary enforcement: Added tests for invalid finale boss references crossing the authored content validation boundary.
* Contract alignment: Content validation tests now verify finale boss ownership against the shared boss contract.

***

### Task T019 - Run focused Vitest gate

**Started**: 2026-06-30 23:33 **Completed**: 2026-06-30 23:34 **Duration**: 1 minute

**Notes**:

* Ran the full focused session Vitest gate after implementation and focused test updates.
* Confirmed boss presentation, render model, renderer audio adapter, audio, combat, and content registry suites pass together.

**Files Changed**:

* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T019 complete and updated progress.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded T019 evidence.

**Verification**:

* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts src/extensions/ai-rogue/runtime/__tests__/audio.test.ts src/extensions/ai-rogue/runtime/__tests__/combat.test.ts src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts`
  * Result: PASS - Focused session test gate passed.
  * Evidence: 6 test files passed; 93 tests passed.
* UI product-surface check: N/A - Verification command only; no user-facing route changed.
* UI craft check: N/A - No UI changed.

**BQC Fixes**:

* N/A - Verification command task only.

***

### Task T020 - Run typecheck, route smoke, and ASCII/LF validation

**Started**: 2026-06-30 23:34 **Completed**: 2026-06-30 23:36 **Duration**: 2 minutes

**Notes**:

* Formatted touched source, test, JSON, and session Markdown files before final verification.
* Re-ran typecheck and the focused Vitest gate after formatting.
* Ran the AI Rogue runtime Playwright smoke because authored finale rendering behavior changed.
* The first Playwright command was blocked by an already-running app on `127.0.0.1:5189`; confirmed the app responded successfully, then reran with `PLAYWRIGHT_REUSE_EXISTING_SERVER=true`.
* Validated whitespace, ASCII, and LF requirements across touched session and AI Rogue runtime files.

**Files Changed**:

* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md` - Marked T020 and completion checklist complete.
* `.spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md` - Recorded final verification evidence.

**Verification**:

* Command/check: `bunx prettier --write .spec_system/PRD/phase_39/session_06_boss_and_finale_contracts.md .spec_system/state.json .spec_system/specs/phase39-session06-boss-and-finale-contracts/spec.md .spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md .spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md src/extensions/ai-rogue/runtime/boss-contracts.ts src/extensions/ai-rogue/runtime/boss-presentation.ts src/extensions/ai-rogue/runtime/render-model.ts src/extensions/ai-rogue/runtime/renderer-audio-adapter.ts src/extensions/ai-rogue/runtime/effects.ts src/extensions/ai-rogue/runtime/combat.ts src/extensions/ai-rogue/runtime/content/types.ts src/extensions/ai-rogue/runtime/content/validate.ts src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts src/extensions/ai-rogue/runtime/__tests__/combat.test.ts src/extensions/ai-rogue/runtime/__tests__/audio.test.ts src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts`
  * Result: PASS - Touched files were formatted.
  * Evidence: Prettier completed successfully for all listed files.
* Command/check: `bun run typecheck`
  * Result: PASS - TypeScript completed successfully.
  * Evidence: `tsc --noEmit` exited successfully.
* Command/check: `bunx vitest run src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts src/extensions/ai-rogue/runtime/__tests__/audio.test.ts src/extensions/ai-rogue/runtime/__tests__/combat.test.ts src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts`
  * Result: PASS - Focused gate still passed after formatting.
  * Evidence: 6 test files passed; 93 tests passed.
* Command/check: `bunx playwright test tests/e2e/ai-rogue-runtime.spec.ts`
  * Result: FAIL - Port `127.0.0.1:5189` was already in use and config does not reuse existing servers by default.
  * Evidence: Playwright exited before tests with `http://127.0.0.1:5189 is already used`.
* Command/check: `lsof -iTCP:5189 -sTCP:LISTEN -Pn || true` and `curl -I --max-time 5 http://127.0.0.1:5189`
  * Result: PASS - Confirmed an app was already listening on 5189 and responding with HTTP 200.
  * Evidence: `lsof` showed a listener on `127.0.0.1:5189`; `curl` returned HTTP 200.
* Command/check: `PLAYWRIGHT_REUSE_EXISTING_SERVER=true bunx playwright test tests/e2e/ai-rogue-runtime.spec.ts`
  * Result: PASS - AI Rogue runtime browser smoke passed.
  * Evidence: 16 tests passed.
* Command/check: `files=( .spec_system/PRD/phase_39/session_06_boss_and_finale_contracts.md .spec_system/state.json .spec_system/specs/phase39-session06-boss-and-finale-contracts/spec.md .spec_system/specs/phase39-session06-boss-and-finale-contracts/tasks.md .spec_system/specs/phase39-session06-boss-and-finale-contracts/implementation-notes.md src/extensions/ai-rogue/runtime/boss-contracts.ts src/extensions/ai-rogue/runtime/boss-presentation.ts src/extensions/ai-rogue/runtime/render-model.ts src/extensions/ai-rogue/runtime/render-hud.ts src/extensions/ai-rogue/runtime/renderer-audio-adapter.ts src/extensions/ai-rogue/runtime/effects.ts src/extensions/ai-rogue/runtime/combat.ts src/extensions/ai-rogue/runtime/audio.ts src/extensions/ai-rogue/runtime/content/types.ts src/extensions/ai-rogue/runtime/content/validate.ts src/extensions/ai-rogue/runtime/__tests__/boss-presentation.test.ts src/extensions/ai-rogue/runtime/__tests__/render-model.test.ts src/extensions/ai-rogue/runtime/__tests__/renderer-audio-adapter.test.ts src/extensions/ai-rogue/runtime/__tests__/combat.test.ts src/extensions/ai-rogue/runtime/__tests__/audio.test.ts src/extensions/ai-rogue/runtime/content/__tests__/levels.test.ts ); git diff --check -- "${files[@]}" && if rg -n --pcre2 '[^\x00-\x7F]' "${files[@]}"; then exit 1; else echo 'ASCII OK'; fi && if rg -n $'\r' "${files[@]}"; then exit 1; else echo 'LF OK'; fi`
  * Result: PASS - Whitespace, ASCII, and LF checks passed.
  * Evidence: Command printed `ASCII OK` and `LF OK`.
* UI product-surface check: PASS - Browser smoke covered AI Rogue runtime canvas, boss/final-defense presentation frames, HUD/end-screen surfaces, audio pack fetching, and route remount behavior without exposing debug or frame labels.
* UI craft check: PASS - Browser smoke verified nonblank canvas, keyboard/pointer input, high-contrast/reduced-motion readability, desktop/mobile audio paths, and route lifecycle behavior.

**BQC Fixes**:

* N/A - Final verification task only.

***

## Session Summary

* Completed all 20 implementation tasks for `phase39-session06-boss-and-finale-contracts`.
* Added `src/extensions/ai-rogue/runtime/boss-contracts.ts` as the typed boss and authored-finale contract owner.
* Migrated boss identity routing in presentation, render model, renderer audio, effects, combat, and content validation to boss/finale helpers while preserving Kernel Sentinel gameplay and cue parity.
* Updated focused tests for boss contract lookup, Kernel Sentinel frame parity, authored finale gating, render projection, audio adapter reveal behavior, combat metadata, audio cue parity, and content registry validation.
* Verification passed: focused Vitest gate, typecheck, AI Rogue runtime Playwright smoke, formatting, whitespace, ASCII, and LF checks.
* Remaining blockers: none.


---

# 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/sessions/phase39-session06-boss-and-finale-contracts/implementation-notes.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.
