Commit graph

13 commits

Author SHA1 Message Date
ProofOfConcept
a9b0438c74 daemon: configurable LLM concurrency
New config field "llm_concurrency" (default 1) controls how many
concurrent model calls the daemon runs. Worker pool scales to match.
2026-03-05 22:56:16 -05:00
ProofOfConcept
e33fd4ffbc daemon: use CLAUDE_CONFIG_DIR for OAuth credential separation, fix shutdown
Replace agent_api_key (which didn't work — claude CLI uses OAuth, not
API keys) with agent_config_dir. When configured, sets CLAUDE_CONFIG_DIR
on claude subprocesses so daemon agent work authenticates with separate
OAuth credentials from the interactive session.

Fix daemon not shutting down on SIGTERM: use process::exit(0) after
cleanup so PR_SET_PDEATHSIG kills child claude processes immediately.
Previously the daemon hung waiting for choir threads/subprocesses to
finish. Restart now takes ~20ms instead of timing out.

Also: main.rs now uses `use poc_memory::*` since lib.rs exists.
2026-03-05 22:43:50 -05:00
Kent Overstreet
0c15002797 daemon: Unix socket for live status, simplify status display
The daemon now listens on daemon.sock — clients connect and get the
live status JSON immediately. `poc-memory daemon status` uses the
socket, so elapsed times and progress are always current. Falls back
to "Daemon not running" if socket connect fails.

Also: consolidate_full_with_progress() callback for per-step reporting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 22:19:58 -05:00
Kent Overstreet
b6c70c7734 daemon: per-job output log, daily dedup, absolute timestamps
- Jobs report progress via ctx.log_line(), building a rolling output
  trail visible in `poc-memory daemon status` (last 5 lines per task).
- consolidate_full_with_progress() takes a callback, so each agent step
  ([1/7] health, [2/7] replay, etc.) shows up in the status display.
- Persist last_daily date in daemon-status.json so daily pipeline isn't
  re-triggered on daemon restart.
- Compute elapsed from absolute started_at timestamps instead of stale
  relative durations in the status file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 22:16:17 -05:00
Kent Overstreet
cc7943cb50 daemon: add progress reporting to all jobs
Jobs now call ctx.set_progress() at key stages (loading store, mining,
consolidating, etc.), visible in `poc-memory daemon status`. The
session-watcher and scheduler loops also report their state (idle,
scanning, queued counts).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:57:53 -05:00
Kent Overstreet
cf5fe42a15 daemon: inline job functions instead of shelling out to poc-memory
Replace run_poc_memory() subprocess calls with direct function calls
to the library. Each job (experience-mine, fact-mine, decay, consolidate,
knowledge-loop, digest, daily-check) now runs in-process, fixing the
orphaned subprocess problem on daemon shutdown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 21:53:27 -05:00
ProofOfConcept
d0080698f3 cli: switch to clap, add notify-timeout, improve status display
Replace manual arg parsing with clap derive for the full command set.
Single source of truth for command names, args, and help text.

Add notify_timeout (default 2min) — controls how long after last
response before notifications inject via tmux instead of waiting
for the hook. Separate from idle_timeout (5min) which controls
autonomous prompts.

Improve `poc-daemon status` to show both timers with elapsed/configured
and block reason, replacing the terse one-liner.

Add new Status fields over capnp: idleTimeout, notifyTimeout,
sinceActivity, sinceUser, blockReason.

ExecStart in poc-daemon.service now uses `daemon` subcommand.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
2026-03-05 21:32:27 -05:00
ProofOfConcept
8662759d53 installer: add poc-daemon systemd service, multi-event hook setup
- Install poc-daemon.service alongside poc-memory.service
- Rewrite install_hook() to install hooks across multiple events:
  UserPromptSubmit: memory-search (10s) + poc-hook (5s)
  PostToolUse: poc-hook (5s)
  Stop: poc-hook (5s)
- Show elapsed time for running tasks in status display
- Deduplicate hook installation (idempotent ensure_hook helper)
- Still removes legacy load-memory.sh hooks

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
2026-03-05 21:17:43 -05:00
Kent Overstreet
8bb3a554cf init: install hooks + scaffold config; load-context: inline instructions
poc-memory init now:
- Creates the data directory
- Installs the memory-search hook into Claude settings.json
- Scaffolds a starter config.jsonl if none exists

load-context now prints a command reference block at the top so the
AI assistant learns how to use the memory system from the memory
system itself — no CLAUDE.md dependency needed.

Also extract install_hook() as a public function so both init and
daemon install can use it.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
2026-03-05 16:17:49 -05:00
Kent Overstreet
90d60894ed config-driven context loading, consolidate hooks, add docs
Move the hardcoded context priority groups from cmd_load_context()
into the config file as [context.NAME] sections. Add journal_days
and journal_max settings. The config parser handles section headers
with ordered group preservation.

Consolidate load-memory.sh into the memory-search binary — it now
handles both session-start context loading (first prompt) and ambient
search (subsequent prompts), eliminating the shell script.

Update install_hook() to reference ~/.cargo/bin/memory-search and
remove the old load-memory.sh entry from settings.json.

Add end-user documentation (doc/README.md) covering installation,
configuration, all commands, hook mechanics, and notes for AI
assistants using the system.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
2026-03-05 15:54:44 -05:00
ProofOfConcept
a8aaadb0ad config file, install command, scrub personal references
Add ~/.config/poc-memory/config.toml for user_name, assistant_name,
data_dir, projects_dir, and core_nodes. All agent prompts and
transcript parsing now use configured names instead of hardcoded
personal references.

`poc-memory daemon install` writes the systemd user service and
installs the memory-search hook into Claude's settings.json.

Scrubbed hardcoded names from code and docs.

Authors: ProofOfConcept <poc@bcachefs.org> and Kent Overstreet
2026-03-05 15:41:35 -05:00
ProofOfConcept
37e0ce96ea daemon: resource-gated scheduling, fact-mine integration, systemd
Daemon improvements:
- Use jobkit's new .resource(&pool) API instead of pool.acquire()
  inside closures — tasks wait in the pool's queue, not on worker
  threads
- LLM pool capacity 1 to control token burn rate
- Workers reduced from 7 to 4 (2 loops + 2 for jobs)
- Session watcher: per-tick stats logging (stale/mined/open/queued)
- Log rotation: truncate to last half when over 1MB
- Duration tracking and stderr capture for job failures
- Process uptime shown in status display
- Replace fuser subprocess with /proc/*/fd/ scan

Fact-mine integration:
- mine_and_store() writes extracted facts to store nodes
- fact-mine-store CLI subcommand for daemon to shell out to
- Chained as dependent task after experience-mine per session

Infra:
- systemd user service at ~/.config/systemd/user/poc-memory.service
- .cargo/config.toml: force frame pointers for profiling
2026-03-05 15:31:08 -05:00
ProofOfConcept
e37f819dd2 daemon: background job orchestration for memory maintenance
Replace fragile cron+shell approach with `poc-memory daemon` — a single
long-running process using jobkit for worker pool, status tracking,
retry, cancellation, and resource pools.

Jobs:
  - session-watcher: detects ended Claude sessions, triggers extraction
  - scheduler: runs daily decay, consolidation, knowledge loop, digests
  - health: periodic graph metrics check
  - All Sonnet API calls serialized through a ResourcePool(1)

Status queryable via `poc-memory daemon status`, structured log via
`poc-memory daemon log`. Phase 1: shells out to existing subcommands.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
2026-03-05 13:18:00 -05:00