Refactor state storage seams

This commit is contained in:
Meta Vens 2026-04-26 03:49:19 +01:00
commit 965fb1d9da
12 changed files with 1007 additions and 991 deletions

View file

@ -24,12 +24,13 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou
- The owner Codex lane is no longer one swollen file; orchestration, runtime/parsing, rendering, and shared helpers are split under `packages/providers/src/owner-codex-*.ts`.
- The Discord bot lane is no longer one swollen entrypoint; gateway wiring remains in `apps/bot/src/discord-bot.ts` while command/prompt handlers and Discord-shape support helpers now live under `apps/bot/src/discord-bot-*.ts`.
- Interaction-memory logic is no longer one thousand-line slab; event/tone analysis, shared constants, and profile synthesis are split across `packages/core/src/interaction-memory-*.ts`.
- State storage is no longer one persistence omnibus; `packages/core/src/state-storage.ts` is now a thin factory over domain-specific Postgres/file store modules plus bootstrap/migration helpers.
- Ops health, backup verification, offsite sync, and dashboard surfaces already exist.
- The new state/notes surfaces are now the continuity spine for future nontrivial work.
## Likely Next Bounded Move
- The next good structural cut is probably `packages/core/src/state-storage.ts`, `apps/worker/src/mcp-server.ts`, or `packages/providers/src/local-llm-provider.ts`.
- The next good structural cut is probably `apps/worker/src/mcp-server.ts` or `packages/providers/src/local-llm-provider.ts`.
- Prefer the seam with the clearest concern split rather than chasing line count for its own sake.
- Do not broaden scope into a heroic "refactor everything" binge. One organ at a time.

View file

@ -15,7 +15,17 @@ This note is the source-grounded description of how the live VoidBot stack is sh
- `apps/worker/src/mcp-server.ts`
- read-only retrieval tools and resource surfaces for archived history, indexed repos, lore, and owner notifications.
- `packages/core/src/state-storage.ts`
- Postgres-backed durable state for jobs, audit events, interaction memory, and Void usage rate-limit counters.
- Thin state-storage factory that chooses file or Postgres backends and wires the domain stores together.
- `packages/core/src/state-storage-postgres-bootstrap.ts`
- Postgres schema bootstrap plus one-time legacy file-state import.
- `packages/core/src/state-storage-postgres-job-queue.ts`
- Postgres-backed job queue plus job row persistence helpers.
- `packages/core/src/state-storage-postgres-audit-log.ts`
- Postgres-backed audit log plus audit-event upsert helper.
- `packages/core/src/state-storage-postgres-interaction-memory.ts`
- Postgres-backed interaction-memory event storage and profile reconstruction.
- `packages/core/src/state-storage-rate-limit-stores.ts`
- File and Postgres implementations for Void usage rate-limit state.
- `packages/core/src/interaction-memory-analysis.ts`
- Event construction, tone/tag analysis, repetition detection, and persistence gating for remembered interactions.
- `packages/core/src/interaction-memory-profile.ts`
@ -104,3 +114,8 @@ This note is the source-grounded description of how the live VoidBot stack is sh
- backups and snapshots
The important scar is that these stores are split on purpose. Do not casually weld them back into one convenient blob and act surprised when it becomes a moon.
Within the Postgres path, the implementation is split on purpose now too:
- `state-storage.ts` chooses the backend
- `state-storage-postgres-bootstrap.ts` handles schema/bootstrap/import work
- per-domain modules own queue, audit, interaction-memory, and rate-limit behavior

View file

@ -28,7 +28,7 @@ Use the persistent project-state surfaces to keep future work source-grounded an
### 4. Legibility Hardening
- continue splitting oversized runtime files where concern boundaries are already obvious
- likely next cuts: `packages/core/src/state-storage.ts`, `apps/worker/src/mcp-server.ts`, or `packages/providers/src/local-llm-provider.ts`
- likely next cuts: `apps/worker/src/mcp-server.ts` or `packages/providers/src/local-llm-provider.ts`
- keep behavior stable while moving concerns into smaller organs
### 5. The Still-Scaffolded Paths