This repository has been archived on 2026-06-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
nerve/packages/store
xiaoju cee65bbd87 refactor(workflow): move IPC, worker, manager from daemon to @uncaged/workflow
- Move workflow IPC types (StartThread, ResumeThread, etc.) to workflow/ipc.ts
- Move workflow-worker.ts, workflow-manager.ts, workflow-manager-support.ts
- Move worker-runtime.ts and worker-signals.ts (shared infrastructure)
- Daemon now imports workflow runtime from @uncaged/workflow
- Export WORKFLOW_WORKER_PATH for daemon to spawn workers

Phase 3+4 of #320, Testing: #322
2026-05-05 10:41:59 +00:00
..

@uncaged/nerve-store

Persistent storage for the nerve daemon — append-only structured logs, optional JSONL cold archive, and content-addressable blobs.

LogStore (createLogStore, log-store.ts)

  • Append-only log table — rows with source, type, refId, payload, ts (string payloads for ad hoc fields)
  • SQLite WALDatabaseSync from node:sqlite
  • Workflow run tracking — materialized workflow_runs table plus helpers to list active runs, upsert status transitions, and read thread messages / role rounds for CLI and crash recovery
  • Meta key-value — small meta table (e.g. archive watermarks)

Public exports include LogStore, LogEntry, LogQuery, WorkflowRun, WorkflowRunStatus, ThreadRoundRow, GetThreadRoundsParams, and archive-related types re-exported from log-archive.

WorkflowRunStatus

Runs progress through a small state machine. Typical paths:

  1. queuedstarted when a worker picks up the thread
  2. startedcompleted | failed | crashed | interrupted | dropped

Semantics in the daemon/store layer:

  • completed / failed — normal terminal outcomes from the workflow worker
  • crashed — worker exited unexpectedly; manager may respawn and resume-thread eligible started runs
  • interrupted — e.g. hot-reload drain killed an in-flight thread after timeout
  • dropped — concurrency overflow: drop rejected a new run, or overflow: queue evicted an queued item when the queue was full

LogArchive (log-archive.ts)

  • archiveLogs / helpers — export eligible UTC days of old rows to data/archive/logs/YYYY-MM-DD.jsonl, delete archived rows from SQLite, optional VACUUM
  • Used by nerve store archive in @uncaged/nerve-cli

BlobStore (createBlobStore, blob-store.ts)

  • Content-addressable storagewrite returns lowercase sha256 hex; files live under data/blobs/<2-hex>/<62-hex>
  • read / exists — path must match digest on disk (tamper detection)

Install

pnpm add @uncaged/nerve-store

Requires Node.js ≥ 22.5 (same as the rest of the stack).

License

MIT