Commit graph

598 commits

Author SHA1 Message Date
ProofOfConcept
2615289672 idle nudge: always warm, append dream reminder when needed
Instead of two different messages (dreaming vs non-dreaming), always
start with the friendly autonomous time message and append the dream
nudge only when the threshold is exceeded.
2026-03-27 15:13:34 -04:00
ProofOfConcept
85302c11d4 provenance: track agent phase, use task_local + thread_local
Split TASK_PROVENANCE into TASK_AGENT (task_local, set once per agent
run) and TASK_PHASE (thread_local, updated between steps). Provenance
now reports "agent:surface-observe:observe" instead of just
"agent:surface-observe", making it possible to identify which pipeline
phase created a node.

Priority: task_local agent + thread_local phase > POC_PROVENANCE env
var > "manual".

Also includes memory_search catchup throttle and pipelining fixes
from the surface-observe refactor.
2026-03-27 15:11:17 -04:00
ProofOfConcept
b1efdf0b9a surface-observe: reduce duplicate creation, improve journal witnessing
- Add "different nodes should be about different things" guard to observe
- Clarify journal prompt: write about conscious self, not agent work
- Add "write about what happened and how it felt" instruction
- Simplify surface prompt focus guidance
2026-03-27 15:11:04 -04:00
ProofOfConcept
37acb9502d rename agent: fix tool calls and target override
- Add memory_rename tool (in-place rename, preserves content and links)
- Update rename.agent prompt to use memory_rename() instead of text output
- Fix {{rename}} placeholder to respect --target keys when provided
- Add format_rename_targets() for targeted rename runs
2026-03-27 15:10:55 -04:00
ProofOfConcept
bb2e3b9fbb session: add TranscriptInfo struct, consolidate transcript lookups
TranscriptInfo provides cached transcript metadata (path, size)
with a single read. Replaces scattered fs::metadata calls in
surface_observe_cycle, reflection_cycle, resolve_conversation,
and resolve_memory_ratio.

Session::transcript() resolves the path from transcript_path or
by searching projects dir, returning a TranscriptInfo.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 23:24:25 -04:00
ProofOfConcept
8ccc30d97e hook: catchup throttle and reflection agent
Catchup throttle: when the agent is >50% behind the conversation
window (>25KB of transcript growth since last spawn), block and
wait up to 30s for the current agent to finish. Prevents the agent
from falling behind during heavy reading/studying.

Reflection agent: runs every 100KB of transcript growth. Reads
walked nodes from surface-observe, follows links in unexpected
directions, outputs a short dreamy insight. Previous reflections
are injected into the conversation context.

Updated reflect.agent prompt to use {{input:walked}} from
surface-observe state dir and {{conversation:20000}} for lighter
context.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 22:09:44 -04:00
ProofOfConcept
27861a44e5 surface: tag recent nodes as (new) instead of hiding them
Links to nodes created after the conversation window start are
tagged with (new) in memory_render output. The surface prompt
tells the agent not to surface these — they're its own recent
output, not prior memories. Observe can still see and update them.

POC_MEMORIES_OLDER_THAN env var set from the oldest message
timestamp in the conversation window.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 21:19:19 -04:00
Kent Overstreet
7fc1d60113 Delete obsolete agents
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 20:13:10 -04:00
ProofOfConcept
5647842412 journal_new: separate name from title, dedup keys
- journal_new(name, title, body): name becomes the node key,
  title goes in the ## heading. Agent picks short searchable names.
- Auto-dedup: if the key exists, append -2, -3, etc.
- CLI journal write also requires a name argument now.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 19:24:19 -04:00
ProofOfConcept
8eaf4c5956 digest: use created_at instead of timestamp for date matching
Episodic entries should be grouped by creation date, not last
update date. Fixes digest generation potentially assigning
updated entries to the wrong day.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 19:18:14 -04:00
ProofOfConcept
eac59b423e journal: remove all stringly-typed key patterns, use NodeType
- journal_new: key is slugified title (agent names things properly)
- journal_tail: sort by created_at (immutable), not timestamp (mutable)
- journal_update: find latest by created_at
- {{latest_journal}}: query by NodeType::EpisodicSession, not "journal" key
- poc-memory journal write: requires a name argument
- Removed all journal#j-{timestamp}-{slug} patterns from:
  - prompts.rs (rename candidates)
  - graph.rs (date extraction, organize skip list)
  - cursor.rs (date extraction)
  - store/mod.rs (doc comment)
- graph.rs organize: filter by NodeType::Semantic instead of key prefix
- cursor.rs: use created_at for date extraction instead of key parsing

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 19:11:17 -04:00
ProofOfConcept
85fa54cba9 journal tools: use NodeType instead of string key matching
- journal_new: create EpisodicSession node with auto-generated key
- journal_tail: query by node_type, not by parsing a monolithic node
- journal_update: find latest EpisodicSession by timestamp
- No string key matching anywhere — all typed
- Fixes journal entries not appearing in 'poc-memory journal tail'
- Also: added --provenance/-p filter to 'poc-memory tail'
- Also: fix early return in surface_observe_cycle store load failure
- Also: scale max_turns by number of steps (50 per step)

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 18:41:10 -04:00
ProofOfConcept
41fcec58f0 main: replace giant match block with Run trait dispatch
Each subcommand enum (Command, NodeCmd, JournalCmd, GraphCmd,
CursorCmd, DaemonCmd, AgentCmd, AdminCmd) now implements a Run
trait. main() becomes `cli.command.run()`.

Standalone dispatch functions (cmd_cursor, cmd_daemon,
cmd_experience_mine) inlined into their enum's Run impl.
No functional changes.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 18:00:23 -04:00
ProofOfConcept
3e410347a2 api: retry transient connection errors, misc fixes
- Retry up to 5 times with exponential backoff (2s, 4s, 8s, 16s)
  on transient errors: IncompleteMessage, connection closed/reset/
  refused, timeouts. Non-transient errors fail immediately.
- tail command: print to stdout instead of stderr
- state_dir rename: output_dir → state_dir throughout knowledge.rs

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 17:48:44 -04:00
ProofOfConcept
5d803441c9 cleanup: kill dead code, fix signal handler safety
- Remove unused now_secs(), parse_json_response, any_alive, Regex import
- Signal handler: replace Mutex with AtomicPtr<c_char> for signal safety
  (Mutex::lock in a signal handler can deadlock if main thread holds it)
- PidGuard Drop reclaims the leaked CString; signal handler just unlinks
- scan_pid_files moved to knowledge.rs as pub helper
- setup_agent_state calls scan_pid_files to clean stale pids on startup

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 15:58:59 -04:00
ProofOfConcept
52703b4637 agents: bail script support, pid file simplification, cleanup
- Bail command moved from hardcoded closure to external script
  specified in agent JSON header ("bail": "bail-no-competing.sh")
- Runner executes script between steps with pid file path as $1,
  cwd = state dir. Non-zero exit stops the pipeline.
- PID files simplified to just the phase name (no JSON) for easy
  bash inspection (cat pid-*)
- scan_pid_files helper deduplicates pid scanning logic
- Timeout check uses file mtime instead of embedded timestamp
- PID file cleaned up on bail/error (not just success)
- output() tool validates key names (rejects pid-*, /, ..)
- Agent log files append instead of truncate
- Fixed orphaned derive and doc comment on AgentStep/AgentDef
- Phase written after bail check passes, not before

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 15:20:29 -04:00
ProofOfConcept
e20aeeeabe agents: phase tracking, pid files, pipelining, unified cycle
- AgentStep with phase labels (=== PROMPT phase:name ===)
- PID files in state dir (pid-{PID} with JSON phase/timestamp)
- Built-in bail check: between steps, bail if other pid files exist
- surface_observe_cycle replaces surface_agent_cycle + journal_agent_cycle
- Reads surface output from state dir instead of parsing stdout
- Pipelining: starts new agent if running one is past surface phase
- link_set upserts (creates link if missing)
- Better error message for context window overflow

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 14:48:42 -04:00
ProofOfConcept
11289667f5 agents: add surface-observe pipeline and agent definition
surface-observe.agent: three-step pipeline (surface → observe → journal)

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 14:27:14 -04:00
ProofOfConcept
84c78f7ae1 session: --session flag, journal agent cycle, conversation bytes config
- memory-search: add --session flag for multi-session support
- config: add surface_conversation_bytes option
- journal_agent_cycle: trigger journal agent every 10KB of conversation
- Session::from_id() constructor

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
2026-03-26 14:22:29 -04:00
ProofOfConcept
7c0c376e0f render: use backtick-quoted keys and tool call format in link footer
Links now display as \`key\` instead of bare text, and overflow
shows memory_links() tool call format instead of CLI command.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 14:22:21 -04:00
ProofOfConcept
1e1f17f775 store: link_set upserts instead of erroring on missing link
Creates the link if it doesn't exist, avoiding wasted agent turns
from the link_set/link_add confusion.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 14:22:12 -04:00
ProofOfConcept
e176639437 cli: add --state-dir flag to agent run
Override the agent output/input directory for manual testing.
Sets POC_AGENT_OUTPUT_DIR so output() writes there and
{{input:key}} reads from there.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 14:22:05 -04:00
ProofOfConcept
4b32716d3e tools: add output(), journal_tail/new/update tools
- output(key, value): write named results to agent state dir,
  readable via {{input:key}} placeholder
- journal_tail(count): read last N journal entries
- journal_new(title, body): start new ## timestamped entry
- journal_update(body): append to last entry

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 14:21:54 -04:00
ProofOfConcept
77d1d39f3f agents: multi-step agent support
Split agent prompts on === PROMPT === delimiter. Each step runs as
a new user message in the same LLM conversation, so context carries
forward naturally between steps. Single-step agents are unchanged.

- AgentDef.prompt -> AgentDef.prompts: Vec<String>
- AgentBatch.prompt -> AgentBatch.prompts: Vec<String>
- API layer injects next prompt after each text response
- {{conversation:N}} parameterized byte budget for conversation context

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 14:21:43 -04:00
ProofOfConcept
baf208281d tui: overlay screens via F-keys (F1=context, F2=agents)
Replaced debug_visible bool with an Overlay enum. F1 shows the
context/debug screen (Ctrl+D still works as alias), F2 shows the
agents screen (placeholder for now — will show surface, observe,
reflect, journal status). Esc closes any overlay.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 03:12:28 -04:00
ProofOfConcept
c5efc6e650 budget: identity = system prompt + personality, memory = loaded nodes
Personality is identity, not memory. Memory is nodes loaded during
the session via tool calls — things I've actively looked at.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 02:28:44 -04:00
ProofOfConcept
79672cbe53 budget: count personality + loaded nodes as memory tokens
mem% was always 0 because memory_tokens was hardcoded to 0. Now
counts personality context + loaded nodes from memory tool calls.
Also calls measure_budget + publish_context_state after memory tool
dispatch so the debug screen updates immediately.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 02:27:25 -04:00
ProofOfConcept
a865285313 tools: add memory_query for structured graph queries
Exposes the full query language as a tool: filtering, sorting, field
selection, neighbor walks. Examples:
  degree > 10 | sort weight | limit 5
  neighbors('identity') | select strength
  key ~ 'journal.*' | count

Also added query_to_string() in the parser so queries return strings
instead of printing to stdout. Updated memory-instructions-core to
list all current tools (added memory_query and journal, removed
CLI commands section and nonexistent memory_search_content).

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 02:22:07 -04:00
ProofOfConcept
9a09a665fb render: show plain node keys in link footer, not CLI commands
Links now show just the key name instead of `poc-memory render KEY`.
The agent uses memory_render tool calls, not bash commands.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 02:15:46 -04:00
ProofOfConcept
9127e61c69 identity: handle .md suffix in file-backed context group keys
Keys like "identity.md" were producing "identity.md.md" lookups.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 02:06:39 -04:00
ProofOfConcept
b88b05fe07 identity: load ContextSource::Store from graph, not flat files
ContextSource::Store was handled identically to File — reading .md
files from disk. Now uses MemoryNode::load() to read from the capnp
store. This is why personality wasn't showing correctly in poc-agent:
store-sourced context groups (cognitive-modes, stuck-toolkit,
instructions, memory-instructions-core) were being looked up as
flat files and silently missing.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 02:04:07 -04:00
ProofOfConcept
164a603c8e cleanup: simplify MemoryNode, deduplicate tool dispatch
- Removed write/search/mark_used static methods from MemoryNode —
  those are store ops, not MemoryNode concerns
- Removed SearchResult duplicate — use query::engine::SearchResult
- Simplified Link to (String, f32) tuple — inline detection moved
  to render()
- Collapsed tool definitions to one-liners
- Consolidated store-mutation tools into with_store() helper
- Supersede uses store directly instead of MemoryNode round-trip

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:59:13 -04:00
ProofOfConcept
10932cb67e hippocampus: move MemoryNode + store ops to where they belong
MemoryNode moved from agent/memory.rs to hippocampus/memory.rs — it's
a view over hippocampus data, not agent-specific.

Store operations (set_weight, set_link_strength, add_link) moved into
store/ops.rs. CLI code (cli/graph.rs, cli/node.rs) and agent tools
both call the same store methods now. render_node() delegates to
MemoryNode::from_store().render() — 3 lines instead of 40.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:55:21 -04:00
ProofOfConcept
4b97bb2f2e runner: context-aware memory tracking
Memory tools now dispatch through a special path in the runner (like
working_stack) instead of the generic tools::dispatch. This gives them
&mut self access to track loaded nodes:

- memory_render/memory_links: loads MemoryNode, registers in
  context.loaded_nodes (replace if already tracked)
- memory_write: refreshes existing tracked node if present
- All other memory tools: dispatch directly, no tracking needed

The debug screen (context_state_summary) now shows a "Memory nodes"
section listing all loaded nodes with version, weight, and link count.

This is the agent knowing what it's holding — the foundation for
intelligent refresh and eviction.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:48:15 -04:00
ProofOfConcept
2c61a3575d tools/memory: direct store calls instead of spawning poc-memory
Every memory tool call was spawning a poc-memory subprocess. Now uses
MemoryNode and direct Store API calls:
- memory_render: MemoryNode::load() + render()
- memory_write: MemoryNode::write() via store.upsert_provenance()
- memory_search: MemoryNode::search() via search engine
- memory_links: MemoryNode::load() + iterate links
- memory_link_add: store.add_relation() with Jaccard strength
- memory_link_set: direct relation mutation
- memory_used: store.mark_used()
- memory_weight_set: direct node.weight mutation
- memory_supersede: MemoryNode::load() + write() + weight_set()

No more Command::new("poc-memory") in this module.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:42:33 -04:00
ProofOfConcept
4cc4952234 agent: add MemoryNode for direct store access
MemoryNode is the agent's live view of a loaded memory node — key,
content, links, version, weight. Operations (load, write, search,
mark_used) go directly through the store API instead of spawning
poc-memory subprocesses.

This is the foundation for context-aware memory: the agent can track
which nodes are loaded in its context window, detect changes, and
refresh regions when nodes are updated.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:39:48 -04:00
ProofOfConcept
1399bb3a5e runner: call memory_search directly instead of spawning poc-hook
The agent was shelling out to poc-hook which shells out to memory-search.
Now that everything is one crate, just call the library function. Removes
subprocess overhead on every user message.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:32:54 -04:00
ProofOfConcept
a00d52214a session: extract Session from memory_search to src/session.rs
Generic session state (session_id, seen set, state directory) doesn't
belong in the memory search module. Now at crate root, re-exported
from memory_search for backwards compatibility.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:26:03 -04:00
ProofOfConcept
228815d807 config: unify memory and agent config into single module
Both hippocampus/config.rs and agent/config.rs read from the same
config file (~/.config/poc-agent/config.json5). Having two separate
implementations was a footgun — load_context_groups() was duplicated
three times across the codebase.

Merged into src/config.rs:
- Config (memory settings, global get()/reload())
- AppConfig (agent backend/model settings, figment-based loading)
- SessionConfig (resolved agent session, renamed from agent's Config)
- Single ContextGroup/ContextSource definition used everywhere

Eliminated: duplicate load_context_groups(), duplicate ContextGroup
definition in identity.rs, duplicate config file path constants.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:23:12 -04:00
ProofOfConcept
2f3fbb3353 subconscious: flatten agents/ nesting, move prompts in
agents/*.agent definitions and prompts/ now live under
src/subconscious/ alongside the code that uses them.
No more intermediate agents/ subdirectory.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:10:25 -04:00
ProofOfConcept
29ce56845d remove old poc-agent directory
Source merged into src/agent/ — these are dead copies.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:06:57 -04:00
ProofOfConcept
d5c0e86700 restructure: hippocampus/ for memory, subconscious/ for agents
hippocampus/ — memory storage, retrieval, and consolidation:
  store, graph, query, similarity, spectral, neuro, counters,
  config, transcript, memory_search, lookups, cursor, migrate

subconscious/ — autonomous agents that process without being asked:
  reflect, surface, consolidate, digest, audit, etc.

All existing crate::X paths preserved via re-exports in lib.rs.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-25 01:05:30 -04:00
ProofOfConcept
cfed85bd20 rename: poc-agent → agent, poc-daemon → thalamus
The thalamus: sensory relay, always-on routing. Perfect name for the
daemon that bridges IRC, Telegram, and the agent.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 01:03:51 -04:00
ProofOfConcept
998b71e52c flatten: move poc-memory contents to workspace root
No more subcrate nesting — src/, agents/, schema/, defaults/, build.rs
all live at the workspace root. poc-daemon remains as the only workspace
member. Crate name (poc-memory) and all imports unchanged.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 00:54:12 -04:00
ProofOfConcept
891cca57f8 merge poc-agent into poc-memory as agent/ module
Eliminates the circular dependency between poc-agent and poc-memory by
moving all poc-agent source into poc-memory/src/agent/. The poc-agent
binary now builds from poc-memory/src/bin/poc-agent.rs using library
imports. All poc_agent:: references updated to crate::agent::.

poc-agent/ directory kept for now (removed from workspace members).

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-03-25 00:52:41 -04:00
Kent Overstreet
01abd795ce Surface agent tweaks
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-25 00:21:41 -04:00
ProofOfConcept
9d84dde597 search: exclude seen set when running in agent session
Make Session::from_env() and Session::seen() the public API for
accessing session state. Internal callers converted to use session
methods. Search automatically filters already-surfaced nodes when
POC_SESSION_ID is set.
2026-03-24 23:50:23 -04:00
ProofOfConcept
5c3baeea80 memory-search: fix reflect/surface output parsing
Extract response after '=== RESPONSE ===' marker before parsing
for REFLECTION/NEW RELEVANT MEMORIES. The agent runner dumps the
full log (turns, think blocks) to stdout.
2026-03-24 20:33:50 -04:00
ProofOfConcept
e93e682359 memory-search: add surface/reflect subcommands
`memory-search surface` and `memory-search reflect` run the agent
directly, parse the output, and dump rendered results to stdout.
Useful for testing with `watch memory-search reflect`.
2026-03-24 20:31:21 -04:00
ProofOfConcept
f086815eaa memory: add temperature support to agent defs, update reflect prompt
Thread temperature parameter from agent def header through the API
call chain. Agents can now specify {"temperature": 1.2} in their
JSON header to override the default 0.6.

Also includes Kent's reflect agent prompt iterations.
2026-03-24 20:29:17 -04:00