> 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/phase31-session04-extensions-and-agent-routes/code-review.md).

# Code Review and Repair Report

**Session ID**: `phase31-session04-extensions-and-agent-routes` **Reviewed**: 2026-06-24 **Scope**: All uncommitted changes in the working tree **Result**: RESOLVED

## Review Surface

**Files reviewed** (all uncommitted changes):

* `.spec_system/state.json` - tracked-modified
* `.spec_system/specs/phase31-session04-extensions-and-agent-routes/spec.md` - untracked
* `.spec_system/specs/phase31-session04-extensions-and-agent-routes/tasks.md` - untracked
* `.spec_system/specs/phase31-session04-extensions-and-agent-routes/implementation-notes.md` - untracked
* `src/components/hermes/claude-code-mission-page.tsx` - tracked-modified
* `src/components/hermes/hermes-read-only-page.tsx` - tracked-modified
* `src/components/hermes/hermes-status-bar.tsx` - tracked-modified
* `src/components/knowledge-graph/knowledge-graph-grounded-chat.tsx` - tracked-modified
* `src/components/knowledge-graph/knowledge-graph-page.tsx` - tracked-modified
* `src/components/openclaw/openclaw-read-only-page.tsx` - tracked-modified
* `src/components/openclaw/openclaw-status-bar.tsx` - tracked-modified
* `src/extensions/ai-rogue/__tests__/client.test.tsx` - tracked-modified
* `src/extensions/ai-rogue/runtime/simulation.ts` - tracked-modified during creview lint/encoding repair
* `src/extensions/ai-rogue/views/ledger-view.tsx` - tracked-modified
* `src/extensions/ai-rogue/views/play-view.tsx` - tracked-modified
* `src/extensions/ai-rogue/views/view-shell.tsx` - tracked-modified
* `src/extensions/trend-finder/__tests__/view-model.test.ts` - tracked-modified
* `src/extensions/trend-finder/__tests__/visibility-views.test.tsx` - tracked-modified
* `src/extensions/trend-finder/components/__tests__/evidence-asset-preview.test.tsx` - untracked
* `src/extensions/trend-finder/components/evidence-asset-preview.tsx` - tracked-modified
* `src/extensions/trend-finder/components/runtime-readiness-panel.tsx` - tracked-modified
* `src/extensions/trend-finder/engine-replay-model.ts` - tracked-modified
* `src/extensions/trend-finder/schema.ts` - tracked-modified
* `src/extensions/trend-finder/use-visibility-settings.ts` - tracked-modified
* `src/extensions/trend-finder/view-model.ts` - tracked-modified
* `src/extensions/trend-finder/views/engine-replay-view.tsx` - tracked-modified
* `src/extensions/trend-finder/views/sources-view.tsx` - tracked-modified
* `src/extensions/trend-finder/views/trends-view.tsx` - tracked-modified
* `src/hooks/__tests__/use-knowledge-graph.test.tsx` - tracked-modified during creview repair
* `src/hooks/use-knowledge-graph.ts` - tracked-modified
* `src/lib/__tests__/public-demo.test.ts` - tracked-modified
* `src/lib/__tests__/trend-finder-dashboard.test.tsx` - tracked-modified
* `src/lib/__tests__/trend-finder-engine-replay.test.tsx` - tracked-modified
* `src/lib/__tests__/trend-finder-schema.test.ts` - tracked-modified
* `src/lib/public-demo.ts` - tracked-modified
* `src/routes/__tests__/agents.test.tsx` - tracked-modified
* `src/routes/__tests__/extensions-routes.test.tsx` - tracked-modified
* `src/routes/__tests__/knowledge-graph.test.tsx` - tracked-modified
* `src/routes/__tests__/public-demo-routes.test.tsx` - untracked
* `.spec_system/specs/phase31-session04-extensions-and-agent-routes/code-review.md` - untracked report artifact

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

## Findings by Severity

### Critical

No findings.

### High

No findings.

### Medium

* `src/hooks/use-knowledge-graph.ts:585` - Manual `refetch()` could bypass disabled public-demo/live-query guards because React Query `refetch()` can execute disabled queries imperatively. This left a future bridge-request path available from any child that received `knowledgeGraph.refetch`. | Fix: Return early from `refetch()` when `liveQueriesEnabled` is false and add hook coverage that demo and hosted public-demo `refetch()` make no fetch calls. | Status: FIXED
* `src/lib/public-demo.ts:3` - `PublicDemoEnv` was too narrow for `import.meta.env` under `tsconfig.scripts.json`, causing `bun run typecheck:scripts` to fail. | Fix: Add an index signature to the env contract while preserving the existing public-demo flag parsing behavior. | Status: FIXED

### Low

* `src/hooks/use-knowledge-graph.ts:557` - Hosted public-demo Knowledge Graph copy was applied to every demo state, including local demo fixtures. | Fix: Scope hosted copy to `isBrowserPublicDemoMode()` and preserve local demo fixture wording otherwise; added regression coverage. | Status: FIXED
* `src/routes/__tests__/public-demo-routes.test.tsx:73`, `src/routes/__tests__/knowledge-graph.test.tsx:55`, `src/routes/__tests__/extensions-routes.test.tsx:40` - Public-demo route tests stubbed `fetch` and/or env without full cleanup, allowing cross-test state to mask bridge requests. | Fix: Add local `vi.unstubAllGlobals()` and env cleanup in the affected route suites. | Status: FIXED
* `src/extensions/ai-rogue/runtime/simulation.ts:1063` and `src/extensions/ai-rogue/runtime/simulation.ts:2930` - Full ESLint gate failed on unchanged `prefer-const` bindings. After the const-only repair made the file part of the changed set, the changed-file ASCII gate exposed existing non-ASCII dash/arrow punctuation in comments and event copy. | Fix: Split destructuring so only reassigned bindings remain `let`, changed `objective` to `const`, and converted non-ASCII punctuation in the touched file to ASCII equivalents. | Status: FIXED
* Multiple changed files - Prettier reported formatting drift after implementation and review edits. | Fix: Ran Prettier on the changed and untracked files only. | Status: FIXED

## Assumptions and Deliberate Non-Fixes

* The `src/extensions/ai-rogue/runtime/simulation.ts` edits were outside the original Session 04 deliverable list. They were made because `bun run lint` is a configured repository gate and the repair was behavior-preserving except for ASCII punctuation in user-visible event text. No unrelated logic was changed.

## Behavior Changes

* Knowledge Graph `refetch()` now no-ops whenever live graph queries are disabled, including hosted public-demo and local demo states. This prevents local bridge reads from being triggered imperatively.
* Knowledge Graph local demo copy again uses local fixture wording; hosted public-demo copy remains hosted/read-only.
* AI Rogue runtime event text uses ASCII hyphens instead of em dashes in several event messages. Semantics are unchanged.

## Verification

* Tests: `bun run test -- src/routes/__tests__/public-demo-routes.test.tsx src/routes/__tests__/agents.test.tsx src/routes/__tests__/knowledge-graph.test.tsx src/routes/__tests__/extensions-routes.test.tsx src/extensions/trend-finder/components/__tests__/evidence-asset-preview.test.tsx src/extensions/ai-rogue/__tests__/client.test.tsx src/hooks/__tests__/use-knowledge-graph.test.tsx` - PASS - 7 files, 91 tests
* Tests: `bun run test -- src/lib/__tests__/public-demo.test.ts src/routes/__tests__/public-demo-routes.test.tsx src/hooks/__tests__/use-knowledge-graph.test.tsx` - PASS - 3 files, 38 tests
* Tests: `bun run test` - PASS - 372 files, 4218 tests
* Linter: `bun run lint` - PASS
* Formatter: `bun run format:check` - PASS
* Type checker: `bun run typecheck` - PASS
* Script type checker: `bun run typecheck:scripts` - PASS
* Whitespace / ASCII / LF: `git diff --check HEAD && files=$(git ls-files --modified --others --exclude-standard); if [ -n "$files" ]; then LC_ALL=C rg -n '[^\x00-\x7F]' $files && exit 1 || test $? -eq 1; rg -n $'\r' $files && exit 1 || test $? -eq 1; fi` - PASS
* Final diff re-read: no remaining issues found

## Validation Repair Addendum

**Reviewed**: 2026-06-24 during `validate` **Additional files reviewed**:

* `src/components/hermes/hermes-status-bar.tsx` - validation repair
* `src/components/hermes/hermes-read-only-page.tsx` - validation repair
* `src/components/hermes/claude-code-mission-page.tsx` - validation repair
* `src/components/openclaw/openclaw-status-bar.tsx` - validation repair
* `src/components/openclaw/openclaw-read-only-page.tsx` - validation repair
* `src/routes/__tests__/agents.test.tsx` - validation repair coverage

**Finding**:

* Low - Hosted public-demo Hermes, Claude Code, and OpenClaw surfaces still rendered local telemetry, endpoint, bridge, or token wording in status/footer copy while public-demo mode forced demo behavior. | Fix: Added hosted-demo copy branches and route assertions that public-demo surfaces show curated sample/local-unavailable wording and omit the old bridge/token copy. | Status: FIXED

**Verification after validation repair**:

* Tests: `bun run test -- src/routes/__tests__/agents.test.tsx` - PASS - 1 file, 32 tests
* Tests: `bun run test` - PASS - 372 files, 4218 tests
* Tests: `bun run test -- src/routes/__tests__/public-demo-routes.test.tsx src/routes/__tests__/agents.test.tsx src/routes/__tests__/knowledge-graph.test.tsx src/routes/__tests__/extensions-routes.test.tsx src/extensions/trend-finder/components/__tests__/evidence-asset-preview.test.tsx src/extensions/ai-rogue/__tests__/client.test.tsx src/hooks/__tests__/use-knowledge-graph.test.tsx` - PASS - 7 files, 91 tests
* Linter: `bun run lint` - PASS
* Formatter: `bun run format:check` - PASS
* Type checker: `bun run typecheck` - PASS
* Script type checker: `bun run typecheck:scripts` - PASS
* Whitespace / ASCII / LF: `git diff --check HEAD && files=$(git ls-files --modified --others --exclude-standard); if [ -n "$files" ]; then LC_ALL=C rg -n '[^\x00-\x7F]' $files && exit 1 || test $? -eq 1; rg -n $'\r' $files && exit 1 || test $? -eq 1; fi` - PASS

## Summary

1. Reviewed the current uncommitted change set covering public-demo route guards, agent/read-only surfaces, Knowledge Graph, Trend Finder media and visibility, AI Rogue browser-local copy, session artifacts, the creview report, and validation repair edits.
2. Findings resolved: 0 critical, 0 high, 2 medium, 5 low.
3. Deliberately changed one already-committed AI Rogue runtime file only to satisfy configured lint and changed-file ASCII gates; no runtime logic was altered.
4. Verification is green across focused public-demo tests, full Vitest, lint, format, app typecheck, script typecheck, diff whitespace, ASCII, and LF checks.


---

# 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/phase31-session04-extensions-and-agent-routes/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.
