> 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/phase38-session01-tier-0-parity-fixes/code-review.md).

# Code Review and Repair Report

**Session ID**: `phase38-session01-tier-0-parity-fixes` **Reviewed**: 2026-06-29 **Scope**: All uncommitted changes in the working tree **Result**: RESOLVED

## Review Surface

**Files reviewed** (all uncommitted changes before this report was written):

* `.spec_system/state.json` - tracked-modified
* `package.json` - tracked-modified
* `scripts/seed-data.ts` - untracked
* `scripts/lib/__tests__/seed-data.test.ts` - untracked
* `scripts/lib/hermes-admin-bridge.ts` - tracked-modified
* `scripts/lib/__tests__/hermes-admin-bridge.test.ts` - tracked-modified
* `src/components/hermes/chat/chat-types.ts` - tracked-modified
* `src/hooks/use-hermes-admin.ts` - tracked-modified
* `src/hooks/__tests__/use-hermes-admin.test.tsx` - tracked-modified
* `src/lib/knowledge-graph-hermes-grounding.ts` - tracked-modified
* `src/lib/__tests__/knowledge-graph-hermes-grounding.test.ts` - tracked-modified
* `src/routes/memory.tsx` - tracked-modified
* `src/routes/__tests__/memory.test.tsx` - tracked-modified
* `.spec_system/specs/phase38-session01-tier-0-parity-fixes/spec.md` - untracked
* `.spec_system/specs/phase38-session01-tier-0-parity-fixes/tasks.md` - untracked
* `.spec_system/specs/phase38-session01-tier-0-parity-fixes/implementation-notes.md` - untracked
* `.spec_system/specs/phase36-session01-current-audio-balance-audit/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths
* `.spec_system/specs/phase36-session02-enemy-audio-metadata/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths
* `.spec_system/specs/phase36-session03-enemy-and-boss-sfx-pack/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths
* `.spec_system/specs/phase36-session04-theme-audio-routing-contract/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths
* `.spec_system/specs/phase36-session05-sector-theme-audio-pack/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths
* `.spec_system/specs/phase36-session06-adaptive-music-engine-expansion/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths
* `.spec_system/specs/phase36-session07-adaptive-stinger-pack/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths
* `.spec_system/specs/phase36-session08-final-audio-validation-and-docs/{IMPLEMENTATION_SUMMARY.md,code-review.md,implementation-notes.md,security-compliance.md,spec.md,tasks.md,validation.md}` - tracked-deleted; byte-identical copies reviewed under matching `.spec_system/archive/sessions/...` paths

**Inventory commands**: `git status`, `git diff HEAD`, `git diff --cached`, `git ls-files --others --exclude-standard`

**Archive relocation check**: 56 tracked-deleted Phase 36 files and 56 untracked archive files were compared byte-for-byte with `git show HEAD:<old-path> | cmp -s - <new-path>`; mismatches: 0.

## Findings by Severity

### Critical

* No findings.

### High

* No findings.

### Medium

* `scripts/seed-data.ts:57` - The initial seed-data implementation treated any existing target path as a successful no-op, including a directory named `src/data/live-data.json`. That diverged from the old `test -f` behavior and could hide an invalid generated-data path. | Fix: added `pathKind` regular-file detection, fail-fast target validation, and regression coverage in `scripts/lib/__tests__/seed-data.test.ts:65`. | Status: FIXED
* `scripts/seed-data.ts:68` - A directory at `src/data/live-data.example.json` was readable, so the script could reach `copyFile` and return a raw filesystem error instead of the actionable missing/unreadable source error required by the spec. | Fix: source validation now requires a regular readable file, with regression coverage in `scripts/lib/__tests__/seed-data.test.ts:91`. | Status: FIXED

### Low

* `src/routes/memory.tsx:197` - The Memory tile memo read the new available source count without an explicit dependency, producing a React Hooks lint warning and a stale-value risk if source availability changes. | Fix: introduced `availableSourceCount` and added it to the memo dependency list at `src/routes/memory.tsx:64` and `src/routes/memory.tsx:225`. | Status: FIXED

## Assumptions and Deliberate Non-Fixes

* The Phase 36 `.spec_system/specs` deletions are archive relocations, not content removals. Evidence: every untracked `.spec_system/archive/sessions/phase36-*` file is byte-identical to the corresponding `HEAD:.spec_system/specs/phase36-*` file.
* `bun run format:check` still fails on five unchanged committed `.spec_system` Markdown files: `.spec_system/CONSIDERATIONS.md`, `.spec_system/PRD/phase_38/PRD_phase_38.md`, `.spec_system/PRD/phase_38/session_04_dream_scheduling_and_setup.md`, `.spec_system/PRD/PRD.md`, and `.spec_system/SECURITY-COMPLIANCE.md`. These files are outside the uncommitted review surface, so they were not edited. A scoped Prettier check over all touched session files passed.

## Behavior Changes

* `bun run seed:data` now exits nonzero with stable, actionable errors when the target path exists but is not a file or when the source path is not a regular readable file.
* Session-intended behavior remains: Memory source counts are based on available source list length; Hermes chat `graph` and `yolo` options are validated and composed independently; Knowledge Graph grounding explicitly requests Graphify.

## Verification

* Analysis: `if [ -d ".spec_system/scripts" ]; then bash .spec_system/scripts/analyze-project.sh --json; else bash /home/aiwithapex/.codex/plugins/cache/apex-spec-system/apex-spec/2.1.3-codex/skills/apex-spec/scripts/analyze-project.sh --json; fi` - PASS - current session resolved to `phase38-session01-tier-0-parity-fixes`.
* Tests: `bun run test -- src/routes/__tests__/memory.test.tsx scripts/lib/__tests__/seed-data.test.ts scripts/lib/__tests__/hermes-admin-bridge.test.ts src/hooks/__tests__/use-hermes-admin.test.tsx src/lib/__tests__/knowledge-graph-hermes-grounding.test.ts` - PASS - 5 files, 85 tests.
* Tests: `bun run test` - PASS - 388 files, 4458 tests.
* Linter: `bun run lint` - PASS.
* Type checker: `bun run typecheck` - PASS.
* Script type checker: `bun run typecheck:scripts` - PASS.
* Formatter: `bun run format:check` - FAIL - unchanged committed `.spec_system` Markdown files listed above.
* Scoped formatter: `bunx prettier --check <touched session files>` - PASS.
* Whitespace: `git diff --check` - PASS.
* Encoding: scoped ASCII scan over touched session files - PASS.
* Line endings: scoped CRLF scan over touched session files - PASS.
* Seed smoke: `sha256sum src/data/live-data.json && bun run seed:data && sha256sum src/data/live-data.json` - PASS - hash stayed `6cd5d792f8bc7a011578fc17ac229695fbaae5e25e7fc5bde511b1f2c64386a9`.
* Final diff re-read: no remaining issues in the uncommitted review surface.

## Summary

1. Reviewed 128 uncommitted files: 11 tracked source/config/test modifications, 5 untracked Phase 38/script files, and 112 Phase 36 archive relocation paths.
2. Findings: 0 critical, 0 high, 2 medium, 1 low; all fixed.
3. Deliberately not fixed: pre-existing full-repo Prettier warnings in five unchanged `.spec_system` Markdown files, because they are outside the uncommitted review surface and the scoped touched-file formatter check passed.
4. Verification passed for targeted tests, full unit tests, lint, app typecheck, script typecheck, scoped formatting, whitespace, ASCII, LF, seed-data no-op smoke, and archive byte-identity.


---

# 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/phase38-session01-tier-0-parity-fixes/code-review.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.
