Skip to content

samskara MVP: minter/consolidator/firing loop wired into coordinator#13

Open
sysread wants to merge 6 commits intomainfrom
samskara
Open

samskara MVP: minter/consolidator/firing loop wired into coordinator#13
sysread wants to merge 6 commits intomainfrom
samskara

Conversation

@sysread
Copy link
Copy Markdown
Owner

@sysread sysread commented Apr 16, 2026

Summary

Introduces samskaras — small embedded JSON records of significant user reactions (corrections, approvals, pivots) that are fired back into the subconscious by cosine similarity on each new turn. Full loop lands here: mint → consolidate → fire → influence, with Perception extracted from Intuition and the Intuition/samskara seam wired from day one.

  • Plan: /root/.claude/plans/alright-let-s-plan-it-sleepy-deer.md (local).
  • Built blind (no Elixir toolchain in the dev sandbox); CI is the first real validation. samskara is on the workflow's allowlist so run-tests.yml triggers on push.

Components

  • AI.Agent.Perception — structured turn perception (intent/sentiment/entities/files/actions/observation); replaces Intuition's inline @perception.
  • AI.Agent.Intuition — now accepts %{perception, samskaras}; threads firings into drive reactions and synthesis.
  • AI.Agent.ReactionClassifier — hot-path classifier (SKIP vs MINT <label> <intensity>).
  • AI.Agent.SamskaraMinter — two-pass: extract gist/lessons/tags → embed → persist.
  • AI.Agent.SamskaraConsolidator — greedy cosine clustering of unconsolidated records into impressions; new fnord index phase "Consolidating samskaras".
  • Services.SamskaraReactor — GenServer, supervised via start_config_dependent_services, fans out mint work through Services.TaskSupervisor.
  • AI.Samskara.Firing + AI.Embeddings.cosine_similarity/2.
  • Store.Project.Samskara + Record — per-project JSON file store under ~/.fnord/projects/<name>/samskaras/; dir created by Store.Project.create/1.
  • AI.Agent.Coordinator.Samskara — bootstrap hook: perception → fire → observe turn → inject preamble system message before Intuition.
  • Cmd.Samskarafnord samskara status | list | show | fires.

Knobs

  • FNORD_DEBUG_SAMSKARA=1 — tracing at classifier verdict, minter record, firing top-k, consolidator cluster boundaries.
  • FNORD_SAMSKARA_DISABLED=1 — kill switch; reactor becomes a no-op.

Test plan

  • MIX_ENV=test mix compile is clean (blind build; likely the first thing to break).
  • mix test passes, including new AI.Embeddings.cosine_similarity/2 cases.
  • mix dialyzer — specs on new modules compile without warnings.
  • mix docs — no warnings in new module docs.
  • On a fresh project: fnord index shows the new "Consolidating samskaras" phase with zero records.
  • FNORD_DEBUG_SAMSKARA=1 fnord ask "…" — trace shows perception → empty firings → intuition.
  • Follow-up reactive turn ("no that's wrong, X not Y"): classifier reports correction, minter writes a record under samskaras/.
  • fnord samskara list shows the new record; fnord samskara fires "same topic" returns it with a high cosine score.
  • Third turn on the same topic: the samskara fires back into Intuition and appears in the coordinator preamble.
  • Seed duplicates → fnord index → consolidator collapses them; list shows consolidated_into links and a new impression.
  • LOGGER_LEVEL=warn without FNORD_DEBUG_SAMSKARA — no debug spam.

https://claude.ai/code/session_01SeTUBwDkaXd7e6ppCmzgaJ

claude added 6 commits April 16, 2026 20:16
Introduces samskaras — small embedded JSON records of significant user
reactions (corrections, approvals, pivots) that are fired back into the
subconscious by cosine similarity on each new turn. Delivers the full
loop end-to-end with Perception extracted from Intuition and wired
alongside samskara firings from day one.

Components:
  - AI.Agent.Perception: extracts structured observation (intent,
    sentiment, entities, files, actions, holistic observation) from a
    turn transcript; replaces the inline perception in Intuition.
  - AI.Agent.Intuition: accepts %{perception, samskaras} from the
    coordinator; threads firings into drive reactions and synthesis.
  - AI.Agent.ReactionClassifier: hot-path classifier that decides
    whether a turn warrants a samskara (label + intensity).
  - AI.Agent.SamskaraMinter: two-pass extractor (gist/lessons/tags ->
    embed -> persist).
  - AI.Agent.SamskaraConsolidator: clusters near-duplicates by cosine
    similarity and synthesizes impression records.
  - Services.SamskaraReactor: per-session GenServer that observes each
    user turn and asynchronously drives classifier -> minter under
    Services.TaskSupervisor.
  - AI.Samskara.Firing: cosine-similarity retrieval over stored records.
  - Store.Project.Samskara + Record: per-project JSON file store under
    ~/.fnord/projects/<name>/samskaras/, alongside conversations.
  - AI.Agent.Coordinator.Samskara: bootstrap hook that runs perception,
    fires samskaras, observes the turn, and injects a preamble system
    message into the coordinator conversation.
  - Cmd.Samskara: `fnord samskara status | list | show | fires <query>`.
  - fnord index phase "Consolidating samskaras" (consolidator called
    from Cmd.Index.index_project as a new phase_results entry).

Also adds AI.Embeddings.cosine_similarity/2, gates tracing behind
FNORD_DEBUG_SAMSKARA, and registers the samskara CLI in Fnord.spec.
- Remove unreachable nested-list flatten in AI.Samskara.Firing.embed
  (AI.Embeddings.get/1 only returns flat list(float)).
- Drop unreachable binary/wildcard clauses of perception_text in
  AI.Agent.Intuition; spec now matches the state type.
- Drop the dead {:error, _} branch of consolidate_samskaras in
  Cmd.Index (SamskaraConsolidator.run/1 never fails today).
Dialyzer infers that clauses 2 and 3 of perception_text completely cover
%AI.Agent.Perception.Result{}, making the empty-struct fallthrough dead.
Per AI.Agent.Perception.Result.t(), raw and observation are always
binaries — so the remaining clauses exhaust the type.
…ails

Temporary diagnostic to see the actual warning/error text on the PR page;
the grep is case-insensitive and previously only reported a generic
failure annotation, leaving the cause behind auth-gated job logs.
Two docs/compile warnings from CI:
- 'documentation references type AI.Agent.Perception.Result.t() but the
  module AI.Agent.Perception.Result is hidden' — drop @moduledoc false
  and give Result a proper moduledoc so cross-module type refs resolve.
- 'a struct for Store.Project.Samskara.Record is expected on struct
  update' — pattern-match %Record{} in Samskara.mark_consolidated so
  the compiler sees the struct at the %Record{record | ...} update site.
ExDoc auto-resolves `Module.fun/arity` backtick references and warns
when the target function has no @doc (which is default for @impl
behaviour callbacks). Rephrase the Perception.Result moduledoc to refer
to the agent by prose instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants