Grand Diomande Research · Full HTML Reader

DEP Audit V2 — Trajectory Search

**Date**: 2025-07-14 **Version**: 0.2.0 (changelog says 0.3.0 unreleased) **Stack**: Tauri v2 + React 19 + TypeScript 5.9 + Vite 7 **Scale**: 293 source files, ~42,253 lines TypeScript frontend, ~6,839 lines Rust backend

Agents That Account for Themselves technical note experiment writeup candidate score 36 .md

Full Public Reader

DEP Audit V2 — Trajectory Search

Date: 2025-07-14
Version: 0.2.0 (changelog says 0.3.0 unreleased)
Stack: Tauri v2 + React 19 + TypeScript 5.9 + Vite 7
Scale: 293 source files, ~42,253 lines TypeScript frontend, ~6,839 lines Rust backend

---

Overall Health Score: 5.2 / 10

Trajectory Search is an extraordinarily ambitious application that attempts to be a universal desktop UI for the entire CompCore/OpenClaw ecosystem. The breadth of features is impressive — 20+ views, motion choreography, 3D visualization, AI agent orchestration, calendar, notes, dream generation, research browser, terminal emulation, and more. But the codebase has outpaced its ability to compile, test, or ship. It's a prototype masquerading as a product.

---

1. Code Quality — 4/10

### TypeScript Strictness
- `strict: true` ✅ — good
- `noUnusedLocals: true` ✅ — enforced but violated 70+ times
- `noUnusedParameters: true` ✅ — enforced but violated
- `erasableSyntaxOnly: true` ✅ — blocks enum syntax in 2 files
- `verbatimModuleSyntax: true` ✅

The tsconfig is strict, which is the right call. But the codebase doesn't comply with its own config. 156 TypeScript errors currently (up from 127 in the handoff doc — regression).

### Error Breakdown
| Category | Count | Severity |
|----------|-------|----------|
| Missing type properties (TS2739) | ~30 | Medium — test fixtures & conflict detector |
| Property doesn't exist (TS2339) | ~15 | Medium — type drift |
| Unused variables (TS6133) | ~25 | Low — cleanup |
| Type assignment mismatch (TS2322) | ~12 | Medium — string/number confusion |
| Unused type declarations (TS6196) | ~8 | Low |
| Argument type mismatch (TS2345) | ~15 | Medium — ConflictResolutionSuggestion |
| Missing exports (TS2305) | ~3 | Medium — LatentState/MotionDescriptor |
| erasableSyntaxOnly (TS1294) | 2 | Low — pulse enum syntax |
| Implicit any (TS7053) | ~3 | Medium |
| Other | ~43 | Mixed |

### Hotspot Files (Most Errors)
1. `lib/calendar/__tests__/template-engine.test.ts` — 34 errors (test fixtures missing required properties)
2. `components/views/ArchitectureExplorer.tsx` — 22 errors
3. `components/views/ArchitectureViewPart2.tsx` — 12 errors
4. `hooks/useEvolutionBridge.ts` — 11 errors
5. `lib/calendar/conflict-detector.ts` — 9 errors
6. `components/views/SpineTimelineView.tsx` — 8 errors

### Component Patterns
- Hooks pattern used consistently ✅
- Context API for search state ✅
- No component library (all custom) — risky for maintenance
- Some components are very large: `ProjectsCard.tsx` at 1,503 lines (should be split)
- `App.tsx` is 300+ lines of keyboard shortcut handling — needs extraction

---

2. Architecture — 6/10

### Tauri v2 Integration
- Rust backend: 6,839 LOC across `commands.rs` (4,309), `agent_client.rs` (473), reminders module (~1,143), browser module (~416)
- Commands.rs is a monolith — 4,309 lines, all Tauri commands in one file
- Reminders have a proper module structure (types, service, scheduler, engine, store, commands)
- Browser has commands for webview management
- `agent_client.rs` wraps the cc-agent-sdk for Rust-side agent calls

Component Hierarchy

App.tsx (root)
├── CompactHeader (tab navigation + global search)
├── 20+ view components (tab-switched, all mounted)
│   ├── SearchView (core search)
│   ├── IdeasView, ChainsView, ClaimsView, ArtifactsView
│   ├── ActionsView, PromptsView, TimelineView
│   ├── ResearchBrowserView (embedded browser)
│   ├── NotesView (TipTap editor)
│   ├── DreamView (AI generation)
│   ├── Calendar (full calendar system)
│   ├── SkillsStoreView, AgentsView
│   ├── KineticTheaterView (motion choreography)
│   ├── DevicesView, PerspectivesView
│   ├── ArchitectureView, SpineTimelineView
│   └── more...
├── QueryBar (global bottom bar)
├── StatusBar + ServiceStatusBar
├── Modals (Compare, Synthesize, Collection, ChainMemory, NewIdea, etc.)
├── CommandPalette
├── ClaudeTerminalPanel
└── QuadTerminal

### State Management
- SearchContext — React Context for search state (good)
- Custom hooks — 47 hooks totaling 18,178 lines
- No global state management (no Redux, Zustand, Jotai) — each hook manages its own state
- Some hooks are massive: `useSkillsStore.ts` (1,072 lines), `useKnowledgeChains.test.ts` (1,078 lines)
- `localStorage` used heavily for persistence (chains, feedback, activity, queue state)
- Supabase client exists but only used for specific cloud features

Data Flow

User Input → Hook → Tauri invoke() → Rust Command → External Service
                                                      ├── RAG++ (semantic search)
                                                      ├── Orbit (projects)
                                                      ├── Graph Kernel (slicing)
                                                      ├── Pulse (health metrics)
                                                      └── Motion Server (choreography)

The architecture is sound conceptually but suffers from over-expansion. 20+ views all mounted simultaneously in the DOM is a performance concern (addressed below).

---

3. Performance — 3/10

### Bundle Concerns
- No code splitting — All 293 files compiled into a single bundle
- No React.lazy — Only 2 lazy-loaded components (motion perspectives)
- All 20+ views mounted simultaneously via CSS visibility toggling:

tsx
  <div className={`absolute inset-0 ${activeTab === 'search' ? '' : 'invisible pointer-events-none'}`}>

This means every view's hooks run on mount, making API calls, setting up intervals, etc.
- Three.js loaded eagerly — `@react-three/fiber` + `@react-three/drei` are massive (ChainMemoryView, LatentVisualizer)
- TipTap loaded eagerly — Full rich text editor stack (12 packages)
- Recharts loaded eagerly — Charting library
- xterm loaded eagerly — Terminal emulator (3 packages)
- No Vite manual chunks configured — Everything in one bundle

### Estimated Bundle Impact
| Dependency | Approx Size (min) |
|-----------|-------------------|
| Three.js + R3F + Drei | ~800KB |
| TipTap (12 packages) | ~300KB |
| Recharts | ~200KB |
| xterm (3 packages) | ~150KB |
| Framer Motion | ~100KB |
| html2canvas | ~50KB |
| Supabase client | ~100KB |
| Anthropic SDK | ~100KB |
| OpenAI SDK | ~80KB |
| Estimated total | ~2MB+ minified |

### Lazy Loading Opportunities
- DreamView (needs Three.js only if visited)
- Calendar (complex, rarely first view)
- KineticTheaterView (motion-specific)
- ResearchBrowserView (webview)
- NotesView (TipTap)
- ArchitectureView (charting)
- All modal components

---

4. UI/UX — 6/10

### Views Inventory (20 views)
| View | LOC | Status | Assessment |
|------|-----|--------|------------|
| SearchView | 554 | Functional | Core feature, works |
| IdeasView | 193 | Functional | CRUD works via hooks |
| ChainsView | 117 | Functional | Basic chain management |
| ClaimsView | 101 | Functional | Verify/falsify flow |
| ArtifactsView | 100 | Semi-stub | Lists artifacts, limited interaction |
| ActionsView | 16 | Stub | 16 lines — placeholder only |
| PromptsView | 635 | Functional | Prompt log browsing, verbose trace |
| TimelineView | 242 | Functional | Evolution event timeline |
| DevicesView | 334 | Functional | Motion device management |
| ArchitectureView | 782+913 | Broken | 34+ TS errors, won't compile |
| PerspectivesView | 193 | Semi-functional | Motion perspectives |
| SpineTimelineView | 661 | Broken | 8 TS errors |
| ResearchBrowserView | (complex) | Functional | Embedded webview browser |
| NotesView | 473 | Functional | TipTap rich text editor |
| DreamView | 720 | Functional | AI generation pipeline |
| Calendar | (complex) | Functional | Full calendar with chat sidebar |
| SkillsStoreView | 540 | Functional | Skill marketplace |
| AgentsView | 611 | Functional | Agent queue monitoring |
| KineticTheaterView | 668 | Functional | Motion visualization |
| CompareView | (modal) | Functional | Side-by-side comparison |

### Navigation
- Tab-based with keyboard shortcuts (Cmd+1 through Cmd+0 and beyond)
- Command palette (Cmd+K) for quick navigation
- CompactHeader with scrollable tab bar
- 19 tabs is too many — needs grouping/categorization

### Responsiveness
- Min width: 400px (Tauri config)
- Default: 600x700 window
- All views use absolute positioning with overflow — works but fragile
- No responsive breakpoints within views

---

5. Data Layer — 5/10

### Supabase
- Client configured at `lib/supabase.ts`
- Lazy initialization with env vars
- Used for cloud persistence (events, etc.)
- No auth layer visible — env-based anon key only

### Graph Kernel Integration
- `lib/graph-kernel-api.ts` (403 lines) — full REST client
- Supports: slice construction, batch slicing, token verification, policy listing, health checks
- Cloud Run deployment with env var URL override
- Proper error handling and retry logic

### Search Context
- `contexts/SearchContext.tsx` — React Context with useReducer
- Manages: query, results, filters, selection, loading state
- Selection chaining for multi-result operations
- Search persistence via `useSearchPersistence` hook

### Hooks Data Layer
Key data hooks:
- `useSearch` — core semantic search via Tauri invoke
- `useGraphKernel` — Graph Kernel slice operations
- `useIdeas` / `useLocalIdeas` — Idea Vault CRUD
- `useClaims` — Claim lifecycle management
- `useKnowledgeChains` — Local chain persistence
- `useCalendar` / `useCalendarChat` — Calendar operations + AI chat
- `useDream` — Dream generation pipeline
- `useSkillsStore` — Skill marketplace
- `useAgentQueue` — Agent execution queue
- `useKineticTheater` — Motion visualization data
- `usePulse` — Health metrics
- `useLedgerRealtime` — Real-time ledger feed

### Data Persistence Strategy
- Tauri invoke → Rust backend → External services (primary)
- localStorage → Client-side persistence (chains, feedback, settings, queue)
- Supabase → Cloud persistence (some features)
- No unified data layer — each hook manages its own caching/persistence

---

6. Testing — 2/10

### Test Files Found: 5
1. `src/components/EmbeddedTerminal.test.ts`
2. `src/hooks/useSynthesisAgent.test.ts` (819 lines)
3. `src/hooks/useKnowledgeChains.test.ts` (1,078 lines)
4. `src/lib/calendar/__tests__/template-engine.test.ts` (34 errors — broken)
5. `src/lib/dream/providers.test.ts` (783 lines)

### Coverage Assessment
- 5 test files out of 293 source files = 1.7
- `template-engine.test.ts` has 34 TypeScript errors — won't even compile
- Test infrastructure exists (vitest, @testing-library/react, jsdom)
- `src/test/setup.ts` and `__mocks__/agent-sdk.ts` configured
-
No CI/CD pipeline evidence** — tests likely haven't been run in a while
- No E2E testing (no Playwright/Cypress)
- No Tauri integration tests

---

7. Dependencies — 5/10

### Production Dependencies (37)
| Category | Packages | Notes |
|----------|----------|-------|
| Core | react 19.2, react-dom 19.2 | Latest ✅ |
| Desktop | @tauri-apps/cli 2.9.6 | Latest v2 ✅ |
| AI/LLM | @anthropic-ai/sdk, openai | Both needed for Dream/agents |
| 3D | three, @react-three/fiber, @react-three/drei | Heavy — 3 packages |
| Rich Text | TipTap (12 packages) | Very heavy but needed for NotesView |
| Terminal | @xterm/xterm, @xterm/addon-fit, @xterm/addon-web-links | 3 packages |
| Data | @supabase/supabase-js | Cloud persistence |
| Charts | recharts | Visualization |
| Animation | framer-motion | Throughout app |
| UI | lucide-react, tailwind-merge | Lightweight ✅ |
| Utility | use-debounce, html2canvas, tippy.js | Reasonable |
| Agent SDK | @comp-core/agent-sdk (file:) | Local monorepo link |

### Dev Dependencies (17)
| Category | Packages | Notes |
|----------|----------|-------|
| Build | vite 7.2, typescript 5.9, tailwindcss 4.1 | Latest ✅ |
| Lint | eslint 9.39, typescript-eslint | Latest ✅ |
| Test | vitest 4.0, @testing-library/react, jsdom | Latest ✅ |
| Types | @types/react, @types/react-dom, @types/three, @types/node | Current ✅ |

### Dependency Concerns
1. @types/three is in dependencies, should be devDependencies
2. @anthropic-ai/sdk and openai are browser-unfriendly (Node.js APIs) — marked external in Vite config
3. @comp-core/agent-sdk file reference — breaks if monorepo structure changes
4. html2canvas — last major update was 2022, may have issues
5. tippy.js — used for tooltips but framer-motion could handle this
6. No dependency vulnerability scan evidence
7. All deps appear relatively current — no severely outdated packages

### Missing Dependencies
- No router (react-router) — all navigation is tab-based state
- No form library (react-hook-form, formik) — all forms are manual
- No query/cache library (tanstack-query) — all caching is manual in hooks

---

8. Build Health — 3/10

### Current State
- 156 TypeScript errorsbuild fails (`tsc -b` exit code non-zero)
- Vite build may succeed (bundles despite TS errors) but type safety is broken
- Error count has increased from 127 (handoff doc) to 156 — active regression

### Error Distribution by Area
| Area | Errors | Nature |
|------|--------|--------|
| Calendar tests | 34 | Test fixtures missing properties |
| Architecture views | 34 | Heavy type issues |
| Evolution bridge | 11 | Type mismatches |
| Calendar lib | 15 | Conflict resolver types |
| Spine timeline | 14 | Bridge + parser issues |
| Motion/perspectives | 7 | Missing exports |
| Other (scattered) | 41 | Mixed unused vars + type issues |

### Build Time
- TypeScript check: ~8-12 seconds (fails before completing)
- Vite bundle: Not measurable until TS passes
- Tauri build: Rust compilation adds ~2-5 minutes (first build much longer)

### Fix Difficulty Assessment
- ~40 errors: Quick fixes (unused vars/imports — 30 min)
- ~50 errors: Type property additions (test fixtures, conflict resolver — 1-2 hours)
- ~35 errors: Architecture view rewrites (medium complexity — 2-3 hours)
- ~20 errors: Deep type investigations (kinetic theater, evolution bridge — 2-3 hours)
- ~11 errors: Miscellaneous (1 hour)
- Total estimate: 8-12 hours of focused work to reach 0 errors

---

9. Missing/Incomplete Features — 4/10

### Confirmed Stubs
1. ActionsView — 16 lines, pure placeholder
2. ArchitectureView suite — 3 files totaling 1,695 lines but 34+ TS errors make them non-functional

### Semi-Complete (UI exists, data not wired)
3. ArtifactsView — Renders artifact cards but limited CRUD
4. PerspectivesView — Motion perspectives exist but Glass Breaker/Hand Guard have TS errors
5. SpineTimelineView — 661 lines but 8 TS errors, spine parser has 4 more

### Functional but Disconnected
6. DreamView — Full generation pipeline but Dream → Idea Vault flow is minimal
7. Calendar — Rich system but calendar ↔ Orbit project integration incomplete
8. ResearchBrowserView — Webview exists but capture → search pipeline unclear
9. AgentsView — Shows agent queue but limited control/dispatch from UI

### Missing Entirely
10. Plans integration — `PlansCard.tsx` exists but no Plans management view
11. Session monitoring — No Clawdbot session visibility
12. Content Studio — Not present
13. Pulse dashboard — `usePulse` hook exists but no dedicated view
14. Graph Kernel visualization — API client exists but no visual graph rendering
15. Collection save — `handleSaveCollection` has a TODO comment: "Save to backend"

---

10. Integration — 5/10

### Graph Kernel
- Full REST client (403 lines) ✅
- Slice construction, token verification, batch operations ✅
- Health checks integrated into ServiceStatusBar ✅
- Gap: No visual graph rendering, no slice explorer UI

### RAG++
- Search via Tauri invoke → Rust backend → RAG++ service ✅
- Semantic search with trajectory coordinates ✅
- Source/era/depth filtering ✅
- Gap: No relevance feedback loop to RAG++

### Orbit
- Project listing via Tauri invoke ✅
- Project management with tags, collections, connections ✅
- Monorepo detection and hierarchy ✅
- Gap: Limited project ↔ calendar/idea cross-linking

### Dream Weaver
- Full generation pipeline (tasks → layout → images → script → rendering) ✅
- Multiple LLM providers (Anthropic, OpenAI, Groq, Gemini) ✅
- Template system (app, game, dashboard, story, canvas) ✅
- Gap: Dream artifacts don't flow back into knowledge graph

### Pulse
- API client exists at `lib/pulse/api-client.ts`
- Types defined at `lib/pulse/types.ts`
- `usePulse` hook exists
- Gap: No dedicated Pulse view, minimal UI integration

### Motion Server (Kinetic Theater)
- Full motion control integration ✅
- Device management, choreography moments ✅
- Phrase intelligence, memory replay, anticipation ✅
- Gap: Some type mismatches in phrase-intelligence.ts

### Agent SDK
- `@comp-core/agent-sdk` linked via file reference
- Mocked for browser (external in Vite)
- Rust-side `agent_client.rs` for actual execution
- Agent queue and scaffolding system ✅
- Gap: Browser mock means no agent testing in dev

---

Score Summary

DimensionScoreKey Issue
Code Quality4/10156 TS errors, strict config violated
Architecture6/10Sound design, over-expanded
Performance3/10No code splitting, all views mounted
UI/UX6/1020 views, too many tabs, good keyboard nav
Data Layer5/10No unified cache, scattered persistence
Testing2/105 test files, 1 broken, 1.7
Dependencies5/10Current but heavy, some misplaced
Build Health3/10156 errors, build fails
Missing Features4/10Several stubs, plans/sessions missing
Integration5/10APIs exist, UIs incomplete
Overall5.2/10Ambitious prototype, not shippable

---

Critical Path to Shippable

1. Fix 156 TypeScript errors → Clean build
2. Add code splitting → Reduce initial load from ~2MB to ~500KB
3. Lazy load views → Only mount active tab
4. Delete or complete stubs → No dead code
5. Add basic test coverage → At least hooks and data layer
6. Group tabs → 19 tabs is UX overload
7. Wire live data → Complete disconnected integrations

Promotion Decision

Attach run IDs, datasets, metrics, and reproduction commands.

Source Anchor

Comp-Core/apps/trajectory/trajectory-search/docs/DEP-AUDIT-V2.md

Detected Structure

Method · Evaluation · Figures · Code Anchors · Architecture