Grand Diomande Research · Full HTML Reader

Evo Cubed — Trajectory Search Evolution Plan

**Date**: 2025-07-14 **Baseline**: DEP Audit V2 (5.2/10 overall health) **Target**: Universal UI for the OpenClaw/CompCore stack **Timeline**: Evo 1 (1-2 weeks) → Evo 2 (3-4 weeks) → Evo 3 (ongoing)

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

Full Public Reader

Evo Cubed — Trajectory Search Evolution Plan

Date: 2025-07-14
Baseline: DEP Audit V2 (5.2/10 overall health)
Target: Universal UI for the OpenClaw/CompCore stack
Timeline: Evo 1 (1-2 weeks) → Evo 2 (3-4 weeks) → Evo 3 (ongoing)

---

Evo 1: Fix & Stabilize

Goal: Clean build, zero TypeScript errors, no dead code, all views either functional or removed.
Target Health: 7.0/10

1.1 Fix All 156 TypeScript Errors

Priority-ordered by file cluster:

#### Phase 1A: Quick Wins (~40 errors, ~30 min)
- [ ] Remove unused imports across all files (lucide-react icons: Lock, Shield, Server, Radio, Network, etc.)
- [ ] Remove unused variables: `lowerText` (3x in nlp-patterns.ts), `fullContent` (2x in parser.ts), `headerPassed`, `parseEntityStatus`, `highPriority`, `currentWeight`, `state` (glass-shatter.ts)
- [ ] Remove unused type imports: `TemplateInstance`, `TemplateCategory`, `EnergyLevel`, `Idea` (2x)
- [ ] Prefix intentionally unused params with `_` where removal would break signatures

#### Phase 1B: Calendar Test Fixtures (~34 errors, ~1 hour)
- [ ] `lib/calendar/__tests__/template-engine.test.ts` — Add missing required properties to all test fixture objects:
- `TemplateEventPattern`: add `priority`, `tags`, `is_milestone`, `created_at`
- `CalendarEvent`: add `all_day`, `tags`, `agent_suggested`, `created_at`, `updated_at`
- `CalendarTemplate`: add `created_at`, `updated_at`
- [ ] Fix `.length` on number type (lines 278-279, 342-343) — likely `events_created` vs `generated_event_ids`
- [ ] Fix `conflicts_detected` property access — use correct TemplateApplicationResult property
- [ ] Fix implicit any indexing on Number type

#### Phase 1C: Conflict Detector (~9 errors, ~45 min)
- [ ] `lib/calendar/conflict-detector.ts` — Fix all `ConflictResolutionSuggestion` argument mismatches:
- Add `type` and `description` properties to all suggestion objects (6 instances)
- Map `action` string to the `type` union: `'reschedule' | 'shorten' | 'cancel' | 'adjust_priority'`
- [ ] Fix iterator on `CalendarEvent[] | undefined` — add null check or default
- [ ] Remove unused `highPriority` variable

#### Phase 1D: Architecture Views (~34 errors, ~2-3 hours)
- [ ] `components/views/ArchitectureExplorer.tsx` (22 errors) — Investigate and fix:
- Likely heavy type mismatches with Graph Kernel types
- May need partial rewrite if types have drifted significantly
- [ ] `components/views/ArchitectureViewPart2.tsx` (12 errors)
- [ ] `components/views/ArchitectureView.tsx` (5 errors)
- [ ] `components/views/ArchitectureViewPart3.tsx` (2 errors)
- [ ] Consider: merge 3-part architecture view into single component with sections

#### Phase 1E: Evolution Bridge + Spine (~19 errors, ~1-2 hours)
- [ ] `hooks/useEvolutionBridge.ts` (11 errors) — Fix type mismatches:
- `timestamp` property on EvolutionEvent (3x) — check if renamed to `created_at`
- `incompleteTasks` property (3x) — verify correct property name
- `null` vs `undefined` for Record types (3x)
- String vs number type mismatches (likely field mapping issues)
- [ ] `hooks/useSpineTimeline.ts` (6 errors)
- [ ] `components/views/SpineTimelineView.tsx` (8 errors)
- [ ] `lib/spine/parser.ts` (4 errors — unused vars, quick fix)

#### Phase 1F: Remaining Scattered Errors (~20 errors, ~1-2 hours)
- [ ] `lib/motion-perspectives/types.ts` — Fix missing exports `LatentState`, `MotionDescriptor` from `../types`
- [ ] `lib/motion-perspectives/effects/haptic-feedback.ts` — Fix readonly array assignment
- [ ] `lib/pulse/api-client.ts` — Convert enums to `as const` objects (erasableSyntaxOnly)
- [ ] `hooks/useTemplates.ts` (5 errors)
- [ ] `hooks/usePerspective.ts` (5 errors)
- [ ] `hooks/useCalendarChat.ts` (2 errors)
- [ ] `hooks/usePulse.ts` (1 error)
- [ ] `lib/agents/calendar.ts` (5 errors)
- [ ] `components/calendar/chat/SuggestionCard.tsx` (4 errors)
- [ ] `components/calendar/ReminderSettingsPanel.tsx` (1 error)
- [ ] `components/perspectives/*.tsx` (3 errors)
- [ ] `components/timeline/EvolutionTimeline.tsx` (2 errors)

Verification

bash
cd Desktop/Comp-Core/apps/trajectory/trajectory-search
npm run build 2>&1 | grep -c "error TS"
# Target: 0

1.2 View Audit — Stubs vs Functional

After TS fixes, audit each view:

ViewCurrent StateAction
ActionsView16-line stubRemove or implement
ArchitectureView (3 parts)34+ errorsFix in 1.1, then validate
ArtifactsViewSemi-functionalKeep, mark as "Phase 2"
SpineTimelineView8 errorsFix in 1.1, then validate
PerspectivesViewPartially brokenFix perspective errors, validate

Decision: No stub views allowed after Evo 1. Either implement minimally or remove from tab navigation.

1.3 Remove Dead Code

  • [ ] Audit all files for code marked `// TODO` that will never be done in current form
  • [ ] Remove `handleSaveCollection` TODO or implement localStorage fallback
  • [ ] Remove any components imported but never rendered
  • [ ] Clean up duplicate/redundant type definitions
  • [ ] Remove `@types/three` from dependencies → devDependencies

1.4 Update Dependencies

  • [ ] Run `npm audit` and fix vulnerabilities
  • [ ] Move `@types/three` to devDependencies
  • [ ] Evaluate removing `tippy.js` (use Radix Popover or Framer Motion instead)
  • [ ] Evaluate removing `html2canvas` if screenshot feature is unused
  • [ ] Pin all dependency versions (remove ^ for production app)

1.5 Performance Quick Wins

- [ ] Lazy load views — Convert all tab views to `React.lazy()`:

tsx
  const DreamView = lazy(() => import('./components/dream/DreamView'));
  const Calendar = lazy(() => import('./components/calendar/Calendar'));
  const KineticTheaterView = lazy(() => import('./components/kinetic-theater/KineticTheaterView'));
  // ... etc

- [ ] Conditional mounting — Replace CSS visibility with conditional rendering:

tsx
  // Before (all views always mounted, hooks always running)
  <div className={activeTab === 'search' ? '' : 'invisible'}>
    <SearchView />
  </div>

  // After (only active view mounted, Suspense for loading)
  <Suspense fallback={<Skeleton />}>
    {activeTab === 'search' && <SearchView />}
    {activeTab === 'dream' && <DreamView />}
  </Suspense>

- [ ] Vite manual chunks — Split heavy dependencies:

ts
  rollupOptions: {
    output: {
      manualChunks: {
        'three': ['three', '@react-three/fiber', '@react-three/drei'],
        'tiptap': ['@tiptap/core', '@tiptap/react', '@tiptap/starter-kit', ...],
        'terminal': ['@xterm/xterm', '@xterm/addon-fit', '@xterm/addon-web-links'],
        'charts': ['recharts'],
      }
    }
  }

### Evo 1 Exit Criteria
- [ ] `npm run build` exits with code 0 (zero TS errors)
- [ ] `npm run dev` launches without errors
- [ ] All visible tabs lead to functional (non-stub) views
- [ ] No `@ts-ignore` or `@ts-expect-error` added as fixes
- [ ] Bundle uses code splitting (verify with `npx vite-bundle-visualizer`)
- [ ] All tests pass (`npm run test`)

---

Evo 2: Complete & Polish

Goal: Every view wired to live data, new integrations for Plans, Sessions, and Content Studio.
Target Health: 8.5/10

2.1 Finish Incomplete Views

#### ActionsView (rewrite)
- [ ] Design: Action generation from selected search results
- [ ] Actions: Summary, Next Steps, Handoff, Weekly Review, Roadmap, Custom
- [ ] Wire to Tauri `generate_action` command
- [ ] Display history of generated actions
- [ ] One-click dispatch to Claude/Cursor terminal

#### ArtifactsView (complete)
- [ ] Full artifact listing with type filtering (code, experiment, dataset, figure, document)
- [ ] Artifact preview (code syntax highlighting, image thumbnails, document excerpts)
- [ ] Link artifacts to chains/ideas
- [ ] Reproducibility status indicators with details

#### ArchitectureView (consolidate)
- [ ] Merge 3-part architecture view into unified component with sections
- [ ] Fix all type issues from Evo 1
- [ ] Interactive architecture diagram (dependency graph visualization)
- [ ] Clickable nodes to navigate to relevant views

2.2 Wire Live Data

#### Graph Kernel Visualization
- [ ] Graph Explorer — Interactive node-edge visualization of knowledge graph
- [ ] Use `@react-three/fiber` for 3D graph or D3 force layout for 2D
- [ ] Show: turns as nodes, edges as connections, clusters as topics
- [ ] Click node → navigate to search result or chain
- [ ] Slice visualization: highlight which turns are in a given slice
- [ ] Admissibility token status indicators

#### RAG++ Search Enhancements
- [ ] Relevance feedback — Send rating data back to RAG++ for reranking
- [ ] Search suggestions — Use Graph Kernel to suggest related queries
- [ ] Trajectory heatmap — Visualize 5D coordinates across search results
- [ ] Saved searches — Persist and replay search queries with context

#### Orbit Projects (deep integration)
- [ ] Project dashboard — Activity timeline, recent dispatches, terminal sessions
- [ ] Project ↔ Calendar — Auto-schedule focus blocks for active projects
- [ ] Project ↔ Ideas — Link ideas to projects, show related ideas on project view
- [ ] Project health — Pulse scores per project (if available)
- [ ] Dependency graph — Visual project connections using ProjectGraphView

2.3 Plans Integration

New: Plans Management View

  • [ ] Create `PlansView` component
  • [ ] List all plans from `[home-path]` and `[home-path]`
  • [ ] Display: slug, title, source, task count, completion percentage
  • [ ] Plan detail view with markdown rendering
  • [ ] Create plans — Form to create new Claude Code plans directly from UI
  • [ ] Edit plans — In-app plan editor (use TipTap with markdown mode)
  • [ ] Track progress — Visual task completion tracking
  • [ ] Link to search — Show related search results for each plan
  • [ ] Link to prompts — Show prompt log entries associated with plan execution

2.4 Session Monitoring

New: Sessions View — Clawdbot Agent Visibility

  • [ ] Create `SessionsView` component
  • [ ] Display active Clawdbot sessions (main, sub-agents)
  • [ ] Session details: label, model, channel, duration, token usage
  • [ ] Real-time log streaming (if available via Clawdbot API)
  • [ ] Session history with search
  • [ ] Health indicators — Show which sessions are active, idle, or errored
  • [ ] Quick actions — Notify session, view context, link to terminal
  • [ ] Integration with `ClaudeTerminalPanel` for direct interaction

2.5 Content Studio Integration

  • [ ] Create `ContentStudioView` component or integrate into DreamView
  • [ ] Image generation pipeline (already exists in Dream)
  • [ ] Voice generation (ElevenLabs TTS via Clawdbot)
  • [ ] Video generation (Veo 3.0 / Kling when available)
  • [ ] Content library: organize generated assets by project/idea
  • [ ] Export pipeline: download, share, publish

2.6 Tab Organization

Reduce tab overload from 19 to organized groups:

┌─ Core ─────────────────────────────────────────────┐
│ Search │ Ideas │ Chains │ Plans │ Actions           │
├─ Create ───────────────────────────────────────────-┤
│ Notes │ Dream │ Content Studio                      │
├─ Monitor ──────────────────────────────────────────-┤
│ Prompts │ Sessions │ Agents │ Timeline              │
├─ Explore ──────────────────────────────────────────-┤
│ Architecture │ Graph │ Devices │ Theater             │
├─ Organize ─────────────────────────────────────────-┤
│ Calendar │ Projects │ Skills                         │
└─────────────────────────────────────────────────────┘
  • [ ] Implement tab groups in CompactHeader
  • [ ] Collapsible groups with expand/collapse
  • [ ] Command palette as primary navigation (Cmd+K)
  • [ ] Recent tabs quick-switch

2.7 Testing

  • [ ] Hook tests — Test all data hooks with mocked Tauri invoke
  • [ ] Component tests — Key views (SearchView, IdeasView, PlansView)
  • [ ] Integration tests — Search flow end-to-end with mocked backend
  • [ ] Target: 40
  • [ ] Fix existing broken test (`template-engine.test.ts`)
  • [ ] Add vitest coverage reporting to CI

2.8 Data Layer Improvements

  • [ ] Unified query layer — Consider TanStack Query for:
  • Automatic caching
  • Background refetching
  • Optimistic updates
  • Request deduplication
  • [ ] Tauri invoke wrapper — Type-safe wrapper with automatic error handling:
ts
  const { data, error, isLoading } = useTauriQuery('get_projects', { status: 'active' });

- [ ] Offline support — Queue mutations when Tauri services unreachable

### Evo 2 Exit Criteria
- [ ] Every tab view is functional with live data
- [ ] Plans view: create, read, edit plans from the UI
- [ ] Session monitoring shows active Clawdbot sessions
- [ ] Graph Kernel visualization renders knowledge graph
- [ ] Tab groups reduce cognitive load
- [ ] 40
- [ ] Build time < 15 seconds
- [ ] Bundle < 1MB initial load (with code splitting)

---

Evo 3: Transform

Goal: Trajectory Search becomes the universal UI for the entire OpenClaw stack. One app to rule them all.
Target Health: 9.0+/10

3.1 Universal UI Platform

Trajectory Search absorbs all standalone UIs in the ecosystem:

#### Replace Compass
- [ ] Audit Compass features (if it exists — currently not found at `apps/compass/`)
- [ ] Identify any unique Compass functionality not in Trajectory Search
- [ ] Implement missing features as views/panels
- [ ] Redirect Compass users to Trajectory Search
- [ ] Remove Compass from monorepo

#### Absorb Standalone Apps
- [ ] Idea Vault — Already merged (changelog v0.3.0) ✅
- [ ] Orbit Dashboard — Replace with Trajectory's Projects view
- [ ] Pulse Monitor — Replace with dedicated Pulse view in Trajectory
- [ ] Graph Kernel Explorer — Replace with Graph view in Trajectory
- [ ] Any future UI — Build as a Trajectory plugin, not a standalone app

3.2 Plugin Architecture

Transform Trajectory from monolithic app to extensible platform:

Plugin System Design

┌──────────────────────────────────────────────┐
│                 Trajectory Core                │
│  ┌─────────┐ ┌──────────┐ ┌──────────────┐   │
│  │ Search  │ │ Tab Mgr  │ │ Plugin Host  │   │
│  │ Engine  │ │          │ │              │   │
│  └─────────┘ └──────────┘ └──────┬───────┘   │
│                                   │           │
│  ┌────────────────────────────────┤           │
│  │    Plugin API                  │           │
│  │  - registerView()              │           │
│  │  - registerCommand()           │           │
│  │  - registerHook()              │           │
│  │  - getSearchContext()          │           │
│  │  - invokeBackend()             │           │
│  └────────────────────────────────┘           │
│                                               │
│  ┌─────────┐ ┌─────────┐ ┌─────────┐        │
│  │ Plugin: │ │ Plugin: │ │ Plugin: │        │
│  │ Dream   │ │Calendar │ │ Custom  │        │
│  │ Studio  │ │         │ │ View    │        │
│  └─────────┘ └─────────┘ └─────────┘        │
└──────────────────────────────────────────────┘

- [ ] Define Plugin API interface:

ts
  interface TrajectoryPlugin {
    id: string;
    name: string;
    version: string;
    views?: PluginView[];      // Register tab views
    commands?: PluginCommand[]; // Register command palette commands
    hooks?: PluginHook[];       // Register data hooks
    settings?: PluginSettings;  // Plugin configuration
    onLoad?: () => void;
    onUnload?: () => void;
  }

  interface PluginView {
    id: string;
    label: string;
    icon: string;
    group: 'core' | 'create' | 'monitor' | 'explore' | 'organize';
    component: React.LazyExoticComponent<React.ComponentType>;
    shortcut?: string;
  }
  • [ ] Plugin loader with lazy importing
  • [ ] Plugin settings in SettingsModal
  • [ ] Plugin marketplace (discover and install community plugins)
  • [ ] Plugin sandboxing (plugins can't access other plugins' state)

#### Core Plugins (refactored from current views)
Convert existing views into first-party plugins:
1. search-plugin — SearchView, QueryBar, Filters
2. ideas-plugin — IdeasView, ChainsView, ClaimsView, ArtifactsView
3. dream-plugin — DreamView, Content Studio
4. calendar-plugin — Calendar, templates, reminders
5. notes-plugin — NotesView (TipTap)
6. research-plugin — ResearchBrowserView
7. agents-plugin — AgentsView, SessionsView
8. motion-plugin — KineticTheaterView, DevicesView, PerspectivesView
9. terminal-plugin — EmbeddedTerminal, QuadTerminal, ClaudeTerminal
10. architecture-plugin — ArchitectureView, Graph Explorer

3.3 Mobile Companion

`trajectory-mobile` already exists in the monorepo. Define the sync protocol:

#### Mobile Feature Set
- [ ] Search — Semantic search from mobile
- [ ] Ideas — Quick capture ideas from phone
- [ ] Plans — View and check off plan tasks
- [ ] Sessions — Monitor Clawdbot sessions remotely
- [ ] Calendar — View/create events
- [ ] Notifications — Push notifications for agent completions, reminders

#### Sync Protocol
- [ ] Define sync API via Supabase Realtime or custom WebSocket
- [ ] Offline-first with conflict resolution
- [ ] Selective sync (don't sync 3D visualizations to mobile)
- [ ] Push notification integration (APNs/FCM)

#### Implementation
- [ ] React Native or Swift (TBD based on trajectory-mobile current state)
- [ ] Shared type definitions with desktop app
- [ ] Shared business logic (extract to `@comp-core/trajectory-shared`)

3.4 Advanced Features

#### AI-Native Interface
- [ ] Natural language navigation — "Show me ideas about graph theory" → filters and navigates
- [ ] Context-aware suggestions — Based on current view, suggest related views/actions
- [ ] Predictive search — Start typing → show results before hitting enter
- [ ] Voice control — Full voice navigation (building on existing VoiceInputButton)

#### Real-time Collaboration
- [ ] Shared sessions — Multiple users viewing same search results
- [ ] Collaborative chains — Build knowledge chains together
- [ ] Shared calendar — Team scheduling via Trajectory
- [ ] Uses Supabase Realtime for sync

#### Desktop Integration
- [ ] System tray — Quick capture, search, session status
- [ ] Global hotkey — Cmd+Space alternative for Trajectory Search
- [ ] Spotlight-like mode — Floating search bar overlay
- [ ] File system watcher — Auto-detect new plans, code changes
- [ ] Deep links — `trajectory://search?q=...` protocol handler

#### Analytics & Insights
- [ ] Usage patterns — What do you search for most? When?
- [ ] Knowledge gaps — Topics with few results → suggest exploration
- [ ] Productivity metrics — Plans completed, ideas resolved, focus time
- [ ] Evolution tracking — How your knowledge base grows over time

3.5 Infrastructure

Monorepo Integration

Comp-Core/
├── core/
│   ├── cc-agent-sdk/          # Shared agent SDK
│   └── trajectory-shared/     # NEW: Shared types & logic
├── apps/
│   ├── trajectory/
│   │   ├── trajectory-search/ # Desktop app (Tauri)
│   │   ├── trajectory-mobile/ # Mobile app
│   │   └── trajectory-web/    # NEW: Web version (optional)
│   └── [compass removed]
├── services/
│   ├── graph-kernel/
│   ├── rag-plusplus/
│   ├── orbit/
│   └── pulse/
└── packages/
    └── trajectory-plugins/    # NEW: Plugin registry
  • [ ] Extract shared types to `@comp-core/trajectory-shared`
  • [ ] Plugin registry at `packages/trajectory-plugins/`
  • [ ] CI/CD: Build → Test → Bundle analysis → Deploy
  • [ ] Auto-update via Tauri's built-in updater

#### Quality Gates
- [ ] TypeScript: 0 errors always (CI blocks merge)
- [ ] Tests: 60
- [ ] Bundle: < 800KB initial load
- [ ] Lighthouse: 90+ performance score (web version)
- [ ] Build: < 20 seconds TypeScript + Vite

### Evo 3 Exit Criteria
- [ ] Trajectory Search is the single UI for all CompCore interactions
- [ ] Plugin architecture allows custom views
- [ ] Mobile companion syncs with desktop
- [ ] All standalone apps absorbed or deprecated
- [ ] Real-time collaboration works
- [ ] 60
- [ ] Sub-second search latency
- [ ] Clean, consistent UX across all views

---

Migration Path

Current State (5.2/10)
    │
    ▼  Evo 1: Fix & Stabilize (1-2 weeks)
    │  - 0 TS errors
    │  - Code splitting
    │  - View audit
    │  - Dead code removal
    ▼
Mid State (7.0/10)
    │
    ▼  Evo 2: Complete & Polish (3-4 weeks)
    │  - All views functional
    │  - Plans + Sessions + Content Studio
    │  - Graph visualization
    │  - 40% test coverage
    │  - Tab groups
    ▼
Strong State (8.5/10)
    │
    ▼  Evo 3: Transform (ongoing)
    │  - Plugin architecture
    │  - Mobile companion
    │  - Compass absorbed
    │  - AI-native interface
    │  - Real-time collaboration
    ▼
Universal Platform (9.0+/10)

---

Risk Register

RiskImpactMitigation
Scope creep from Evo 3 featuresHighStrict Evo 1 → 2 → 3 ordering, no skipping
Performance degradation from feature additionsMediumBundle budget, lazy loading mandate
Plugin API instabilityMediumInternal plugins first, stabilize before opening
Mobile sync complexityHighStart with read-only mobile, add write later
Breaking changes in Tauri v2LowTauri v2 is stable, pin version
Supabase dependency for collab featuresMediumDesign offline-first, Supabase optional
Developer onboarding difficultyMediumPlugin architecture makes it modular

---

Commit Convention

All Evo work follows conventional commits:

feat(trajectory): Evo 1 — fix all TypeScript errors
feat(trajectory): Evo 1 — add code splitting and lazy loading
feat(trajectory): Evo 1 — view audit and dead code removal
feat(trajectory): Evo 2 — Plans management view
feat(trajectory): Evo 2 — Session monitoring view
feat(trajectory): Evo 2 — Graph Kernel visualization
feat(trajectory): Evo 2 — tab group navigation
feat(trajectory): Evo 3 — plugin architecture foundation
feat(trajectory): Evo 3 — mobile companion sync protocol

Promotion Decision

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

Source Anchor

Comp-Core/apps/trajectory/trajectory-search/docs/EVO3.md

Detected Structure

Method · Evaluation · Figures · Code Anchors · Architecture