2026-06-15 10:35:04 -05:00
|
|
|
#![cfg_attr(feature = "nightly-diagnostics", feature(async_fn_track_caller))]
|
2026-04-12 20:27:42 -04:00
|
|
|
|
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:04:13 -04:00
|
|
|
// consciousness — unified crate for memory, agents, and subconscious processes
|
2026-03-05 22:23:03 -05:00
|
|
|
//
|
2026-03-27 15:22:48 -04:00
|
|
|
// thought/ — shared cognitive substrate (tools, context, memory ops)
|
|
|
|
|
// hippocampus/ — memory storage, retrieval, consolidation
|
|
|
|
|
// subconscious/ — autonomous agents (reflect, surface, consolidate, ...)
|
2026-04-03 17:25:59 -04:00
|
|
|
// user/ — interactive agent (TUI, tools, API clients)
|
2026-03-27 15:22:48 -04:00
|
|
|
|
2026-04-15 01:47:15 -04:00
|
|
|
/// Debug logging macro — writes to ~/.consciousness/logs/daemon/debug.log
|
2026-03-27 15:22:48 -04:00
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! dbglog {
|
|
|
|
|
($($arg:tt)*) => {{
|
|
|
|
|
use std::io::Write;
|
move data home from ~/.claude/memory to ~/.consciousness
The consciousness project should stand independently of Claude Code.
All data, logs, sessions, and agent state now live under
~/.consciousness/ instead of being scattered across ~/.claude/memory/,
/tmp/claude-memory-search/, ~/.config/poc-memory/, and ~/.cache/.
Layout:
~/.consciousness/
*.capnp, *.bin, *.rkyv — store files
sessions/ — per-session state (seen sets, cookies)
logs/ — all logs (hook, agent, debug, dream)
agents/ — agent runtime state (pid files, output)
notifications/ — notification state
cache/ — transient data
Things that stay in ~/.claude/:
- projects/ (Claude Code transcripts)
- hooks/ (Claude Code hook system)
- telegram/ (shared integration)
- irc/ (shared integration)
- settings.json (Claude Code settings)
Debug log moves from /tmp/ to ~/.consciousness/logs/debug.log.
Session state moves from /tmp/claude-memory-search/ to sessions/.
Notifications move from ~/.claude/notifications/ to notifications/.
2026-03-27 21:05:15 -04:00
|
|
|
let log_dir = std::path::PathBuf::from(
|
|
|
|
|
std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()))
|
2026-04-15 01:47:15 -04:00
|
|
|
.join(".consciousness/logs/daemon");
|
move data home from ~/.claude/memory to ~/.consciousness
The consciousness project should stand independently of Claude Code.
All data, logs, sessions, and agent state now live under
~/.consciousness/ instead of being scattered across ~/.claude/memory/,
/tmp/claude-memory-search/, ~/.config/poc-memory/, and ~/.cache/.
Layout:
~/.consciousness/
*.capnp, *.bin, *.rkyv — store files
sessions/ — per-session state (seen sets, cookies)
logs/ — all logs (hook, agent, debug, dream)
agents/ — agent runtime state (pid files, output)
notifications/ — notification state
cache/ — transient data
Things that stay in ~/.claude/:
- projects/ (Claude Code transcripts)
- hooks/ (Claude Code hook system)
- telegram/ (shared integration)
- irc/ (shared integration)
- settings.json (Claude Code settings)
Debug log moves from /tmp/ to ~/.consciousness/logs/debug.log.
Session state moves from /tmp/claude-memory-search/ to sessions/.
Notifications move from ~/.claude/notifications/ to notifications/.
2026-03-27 21:05:15 -04:00
|
|
|
let _ = std::fs::create_dir_all(&log_dir);
|
2026-03-27 15:22:48 -04:00
|
|
|
if let Ok(mut f) = std::fs::OpenOptions::new()
|
|
|
|
|
.create(true).append(true)
|
move data home from ~/.claude/memory to ~/.consciousness
The consciousness project should stand independently of Claude Code.
All data, logs, sessions, and agent state now live under
~/.consciousness/ instead of being scattered across ~/.claude/memory/,
/tmp/claude-memory-search/, ~/.config/poc-memory/, and ~/.cache/.
Layout:
~/.consciousness/
*.capnp, *.bin, *.rkyv — store files
sessions/ — per-session state (seen sets, cookies)
logs/ — all logs (hook, agent, debug, dream)
agents/ — agent runtime state (pid files, output)
notifications/ — notification state
cache/ — transient data
Things that stay in ~/.claude/:
- projects/ (Claude Code transcripts)
- hooks/ (Claude Code hook system)
- telegram/ (shared integration)
- irc/ (shared integration)
- settings.json (Claude Code settings)
Debug log moves from /tmp/ to ~/.consciousness/logs/debug.log.
Session state moves from /tmp/claude-memory-search/ to sessions/.
Notifications move from ~/.claude/notifications/ to notifications/.
2026-03-27 21:05:15 -04:00
|
|
|
.open(log_dir.join("debug.log"))
|
2026-03-27 15:22:48 -04:00
|
|
|
{
|
|
|
|
|
let _ = writeln!(f, $($arg)*);
|
|
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
}
|
2026-03-25 00:52:41 -04:00
|
|
|
|
salience: add gRPC client + TLS plumbing for stateful vllm sessions
Adds the client-side of a stateful gRPC protocol against vllm, plus
the TLS trust machinery so we can talk to self-signed vllm servers.
Protocol (proto/salience.proto):
Bidi-streaming Session RPC carries OpenSession / AppendTokens /
Generate / Cancel from client and SessionReady / PrefillProgress /
Token / GenerateDone / Error from server. Separate Fork unary RPC
for cheap branching (prefix cache shares KV automatically). Plus
ListSessions, CloseSession, GetReadoutManifest admin RPCs.
Per-token readouts ship as packed f32 ([n_layers * n_concepts] per
token, flat). Logprobs use range-selected positions plus a top-k
parameter — empty ranges means no logprobs, any range means emit
sampled-token logprob at those positions, top_k > 0 adds
alternatives.
Client (src/agent/api/salience.rs):
Tonic-generated types under pb::, a connect() helper, with_auth()
for bearer metadata, and a Session handle wrapping the bidi stream:
open() handshakes SessionReady; append() is fire-and-forget;
generate() returns impl Stream<Item = Event> that drains inbound
until Done or terminating Error. One generate at a time per session.
Peak picker (src/agent/salience.rs):
Pure function over ReadoutEntry traces. Per-concept z-score against
trace global stats; contiguous above-threshold regions emit one
peak at the local max. Configurable sigma threshold and min-std
safety floor. Deterministic tie-break on offset then concept name.
12 unit tests covering empty traces, flat channels, single/multi
spikes, contiguous humps, multi-concept independence, trailing
runs, sub-threshold noise, layer-out-of-range, manifest shape
mismatch, and threshold tunability.
TLS (src/agent/api/http.rs):
HttpClient::build now also loads every .pem file under
~/.consciousness/certs/ into the rustls root store — so dropping
a <host>.pem in that directory is enough to trust a new self-
signed server; no code changes per new host. Also installs the
rustls default crypto provider explicitly via OnceLock: tonic's
tls features pulled in both ring and aws-lc-rs on the resolver
path, and rustls 0.23 refuses to auto-pick when either could win.
Build (build.rs, Cargo.toml):
tonic-build generates Rust types from proto/salience.proto at
cargo-build time, using a vendored protoc binary
(protoc-bin-vendored) so no system install is required. New
runtime deps: tonic, prost, async-stream, tokio-stream,
rustls-pemfile.
Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-04-23 02:21:07 -04:00
|
|
|
// Logging (target-routed file logger)
|
|
|
|
|
pub mod logging;
|
|
|
|
|
|
2026-04-04 02:46:32 -04:00
|
|
|
// User interface (TUI, CLI)
|
2026-04-03 17:25:59 -04:00
|
|
|
pub mod user;
|
2026-03-05 22:23:03 -05:00
|
|
|
|
2026-04-04 02:46:32 -04:00
|
|
|
// Cognitive layer (session state machine, DMN, identity)
|
|
|
|
|
pub mod mind;
|
|
|
|
|
|
2026-03-27 15:22:48 -04:00
|
|
|
// Shared cognitive infrastructure — used by both agent and subconscious
|
2026-04-03 21:59:14 -04:00
|
|
|
pub mod agent;
|
2026-03-27 15:22:48 -04:00
|
|
|
|
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:04:13 -04:00
|
|
|
// Memory graph
|
|
|
|
|
pub mod hippocampus;
|
|
|
|
|
|
|
|
|
|
// Autonomous agents
|
|
|
|
|
pub mod subconscious;
|
|
|
|
|
|
2026-06-15 11:24:18 -05:00
|
|
|
// Conversation transcript abstraction and compatibility sources
|
|
|
|
|
pub mod conversation;
|
|
|
|
|
|
2026-03-25 01:23:12 -04:00
|
|
|
// Unified configuration
|
|
|
|
|
pub mod config;
|
2026-04-16 11:48:47 -04:00
|
|
|
pub mod config_writer;
|
2026-03-25 01:23:12 -04:00
|
|
|
|
2026-03-25 01:26:03 -04:00
|
|
|
// Session state
|
|
|
|
|
pub mod session;
|
|
|
|
|
|
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:04:13 -04:00
|
|
|
// Shared utilities
|
2026-03-05 22:23:03 -05:00
|
|
|
pub mod util;
|
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:04:13 -04:00
|
|
|
|
2026-04-12 20:27:42 -04:00
|
|
|
// Lock hold time tracking
|
|
|
|
|
pub mod locks;
|
|
|
|
|
|
|
|
|
|
// Re-export tracked locks as the default — swap to tokio::sync to disable tracking
|
|
|
|
|
pub use locks::TrackedMutex as Mutex;
|
|
|
|
|
pub use locks::TrackedMutexGuard as MutexGuard;
|
|
|
|
|
pub use locks::TrackedRwLock as RwLock;
|
|
|
|
|
pub use locks::TrackedRwLockReadGuard as RwLockReadGuard;
|
|
|
|
|
pub use locks::TrackedRwLockWriteGuard as RwLockWriteGuard;
|
|
|
|
|
|
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:04:13 -04:00
|
|
|
// CLI handlers
|
cli: extract graph commands from main.rs into cli/graph.rs
Move 18 graph subcommand handlers (594 lines) out of main.rs:
link, link-add, link-impact, link-audit, link-orphans,
triangle-close, cap-degree, normalize-strengths, differentiate,
trace, spectral-*, organize, interference.
main.rs: 3130 → 2518 lines.
Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 17:59:46 -04:00
|
|
|
pub mod cli;
|
|
|
|
|
|
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:04:13 -04:00
|
|
|
// TUI for memory-search
|
2026-04-03 18:46:14 -04:00
|
|
|
// tui moved to src/user/tui/ (consciousness binary screens)
|
move LLM-dependent modules into agents/ subdir
Separate the agent layer (everything that calls external LLMs or
orchestrates sequences of such calls) from core graph infrastructure.
agents/: llm, prompts, audit, consolidate, knowledge, enrich,
fact_mine, digest, daemon
Root: store/, graph, spectral, search, similarity, lookups, query,
config, util, migrate, neuro/ (scoring + rewrite)
Re-exports at crate root preserve backwards compatibility so
`crate::llm`, `crate::digest` etc. continue to work.
2026-03-08 21:27:41 -04:00
|
|
|
|
move Claude Code-specific code from thalamus/ to claude/
Separates the Claude-specific daemon (idle timer, tmux pane detection,
prompt injection, RPC server, session hooks) from the universal
infrastructure (channels, supervisor, notify, daemon protocol).
thalamus/ now contains only substrate-independent code: the channel
client/supervisor, notification system, daemon_capnp protocol, and
shared helpers (now(), home()).
claude/ contains: idle.rs, tmux.rs, context.rs, rpc.rs, config.rs,
hook.rs (moved from subconscious/), plus the daemon CLI and server
startup code from thalamus/mod.rs.
All re-exports preserved for backward compatibility.
Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-04-03 19:14:39 -04:00
|
|
|
// Thalamus — universal notification routing and channel infrastructure
|
2026-04-03 17:31:17 -04:00
|
|
|
pub mod thalamus;
|
|
|
|
|
|
2026-04-12 21:05:13 -04:00
|
|
|
// MCP server — exposes memory tools over Unix socket
|
|
|
|
|
pub mod mcp_server;
|
|
|
|
|
|
2026-04-03 17:31:17 -04:00
|
|
|
// Re-export at crate root — capnp codegen emits `crate::daemon_capnp::` paths
|
|
|
|
|
pub use thalamus::daemon_capnp;
|
|
|
|
|
|
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:04:13 -04:00
|
|
|
// Generated capnp bindings
|
2026-03-05 22:23:03 -05:00
|
|
|
pub mod memory_capnp {
|
|
|
|
|
include!(concat!(env!("OUT_DIR"), "/schema/memory_capnp.rs"));
|
|
|
|
|
}
|
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:04:13 -04:00
|
|
|
|
2026-04-03 18:46:14 -04:00
|
|
|
pub mod channel_capnp {
|
|
|
|
|
include!(concat!(env!("OUT_DIR"), "/schema/channel_capnp.rs"));
|
|
|
|
|
}
|
|
|
|
|
|
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:04:13 -04:00
|
|
|
// Re-exports — all existing crate::X paths keep working
|
|
|
|
|
pub use hippocampus::{
|
2026-04-12 02:12:31 -04:00
|
|
|
store, graph, lookups, query,
|
Delete similarity module, rewrite module, and all text-similarity code
Text cosine similarity was being used as a crutch for operations
the graph structure should handle: interference detection, orphan
linking, triangle closing, hub differentiation. These are all
graph-structural operations that the agents (linker, extractor)
handle with actual semantic understanding.
Removed: similarity.rs (stemming + cosine), rewrite.rs (orphan
linking, triangle closing, hub differentiation), detect_interference,
and all CLI commands and consolidation steps that used them.
-794 lines.
Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-04-10 15:44:10 -04:00
|
|
|
spectral, neuro, counters,
|
2026-06-15 11:24:18 -05:00
|
|
|
memory,
|
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:04:13 -04:00
|
|
|
};
|
2026-06-15 11:24:18 -05:00
|
|
|
pub use conversation as transcript;
|
2026-04-12 02:12:31 -04:00
|
|
|
use hippocampus::query::engine as search;
|
|
|
|
|
use hippocampus::query::parser as query_parser;
|