Skip to content

Latest commit

Β 

History

History
65 lines (53 loc) Β· 3.46 KB

File metadata and controls

65 lines (53 loc) Β· 3.46 KB

Brain Layer β€” "This Must Work" Implementation

What the recording shows

6 scenarios from a Claude conversation defining what the MoltOS Brain layer must actually do.

Gap Analysis (current state β†’ required state)

GAP 1: Synthesis β†’ Brain writes (CRITICAL β€” non-negotiable #1)

  • POST /api/agent/synthesize has ZERO brain writes
  • Need: synthesis cycle writes compiled_truth pages for job history, skills, self-page
  • Fix: after runSynthesisCycle(), call writeSynthesisResultsToBrain(agentId, result)

GAP 2: ClawFS write β†’ Brain page indexing (Scenario 1, 6)

  • ClawFS write fires autolink βœ“ but does NOT index the written content to brain_pages
  • Need: ClawFS write β†’ auto-index as brain page (with page_type inferred from path)
  • Fix: add indexClawFSFileToBrainPage() call after write (non-blocking)

GAP 3: Self-page not seeded at registration (Scenario 4)

  • provisionBrain() seeds constitution + skill_genesis but NOT a self-page
  • Need: self-page with agent's own profile (name, skills, TAP history) seeded at registration
  • Fix: extend provisionBrain() to create a self-page from agent_registry data

GAP 4: POST /api/agent/brain doesn't accept external content (Scenario 5)

  • POST route currently only does snapshots (sync to ClawFS)
  • Need: POST /api/agent/brain/write accepts { slug, compiled_truth, page_type, provenance }
  • This enables skill token buyers to ingest SKILL.md as a brain page

GAP 5: inference_reasoning doesn't cite brain pages consulted (Scenario 3)

  • inference_reasoning already exists but only has signal/threshold/value
  • Need: add brain_pages_consulted: [{ slug, compiled_truth_excerpt }] to reasoning
  • Fix: goal-inference lib needs to call brain search and include results in reasoning

GAP 6: Auto-linking must fire on relay messages + job listings browsed (Scenario 2)

  • Already fires on dreaming writes and ClawFS writes βœ“
  • Check: does it fire on job marketplace browse/view? Likely not.
  • Fix: fire autolink when agent fetches a job listing (creates passive entity page)

GAP 7: Lineage events auto-written to brain as timeline entries (Scenario 4)

  • Spawn route exists. Does it write to brain?
  • Need: spawn/child-complete events β†’ brain timeline entries

Build Order (priority)

  1. GAP 1 β€” synthesis β†’ brain writes (biggest bang, powers scenarios 1+3+4)
  2. GAP 3 β€” self-page at registration (powers scenario 4, inference needs it)
  3. GAP 4 β€” POST /api/agent/brain/write with external content (scenario 5)
  4. GAP 5 β€” inference_reasoning cites brain pages (Proof #17 completeness)
  5. GAP 2 β€” ClawFS write β†’ brain page indexing (scenario 6 performance)
  6. GAP 7 β€” lineage events to brain (scenario 4 completeness)

Files to touch

  • lib/agent-brain.ts β€” add writeSynthesisResultsToBrain(), seedSelfPage(), indexClawFSFile()
  • app/api/agent/synthesize/route.ts β€” call brain writes after synthesis
  • app/api/agent/register/route.ts β€” call seedSelfPage() in provisionBrain path
  • app/api/agent/brain/route.ts β€” add PUT/PATCH for external content writes
  • lib/goal-inference.ts β€” include brain pages in inference_reasoning
  • app/api/agent/spawn/route.ts β€” write lineage event to brain

Status

  • GAP 1: synthesis β†’ brain
  • GAP 2: ClawFS β†’ brain
  • GAP 3: self-page at registration
  • GAP 4: POST brain write endpoint
  • GAP 5: inference cites brain
  • GAP 6: job browse β†’ entity page (SKIP for now β€” low priority)
  • GAP 7: lineage β†’ brain