Refactor Discord bot seams

This commit is contained in:
Meta Vens 2026-04-26 03:28:21 +01:00
commit 1856123451
8 changed files with 1192 additions and 1101 deletions

View file

@ -22,12 +22,13 @@ Git history and smoke artifacts carry routine proof. `state/evidence.jsonl` shou
- `.voidbot/` owns archives, artifacts, logs, status files, and backups.
- `owner_codex` and `local_llm` are the active reply lanes.
- 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`.
- 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 `apps/bot/src/discord-bot.ts` or `packages/core/src/interaction-memory-logic.ts`.
- The next good structural cut is probably `packages/core/src/interaction-memory-logic.ts` or `packages/core/src/state-storage.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

@ -5,7 +5,11 @@ This note is the source-grounded description of how the live VoidBot stack is sh
## Main Organs
- `apps/bot/src/discord-bot.ts`
- Discord gateway, commands, mention handling, permissions, provider selection, rate-limit gating, and context assembly entrypoint.
- Discord gateway shell: client bootstrap, provider wiring, event registration, and top-level orchestration.
- `apps/bot/src/discord-bot-handlers.ts`
- Prompt/command handling, provider dispatch, rate-limit gating, job approval/rejection, reindexing, and slash-command registration helpers.
- `apps/bot/src/discord-bot-support.ts`
- Discord-shape adapters, archive/source conversion helpers, ambient-memory ingestion helpers, source-grounding hint logic, and bot-side message formatting/rendering helpers.
- `apps/worker/src/index.ts`
- owner-job poller, provider execution, handoff packaging, and MCP wiring for the worker-side lane.
- `apps/worker/src/mcp-server.ts`
@ -35,12 +39,13 @@ This note is the source-grounded description of how the live VoidBot stack is sh
## Flow 1: Discord Request To Provider
1. `apps/bot/src/discord-bot.ts` receives a slash command or mention-driven request.
1. `apps/bot/src/discord-bot.ts` receives a slash command or mention-driven request and delegates prompt/command work into `apps/bot/src/discord-bot-handlers.ts`.
2. Permission checks run through `packages/core/src/permission-engine.ts`.
3. Void usage limits are applied through `packages/core/src/void-usage-rate-limiter.ts` backed by `packages/core/src/state-storage.ts`.
4. `packages/core/src/context-builder.ts` assembles request context, including recent interaction profile and any retrieval hints.
5. Provider selection goes through `packages/providers/src/index.ts`.
6. The bot either:
4. `apps/bot/src/discord-bot-support.ts` adapts Discord message/interaction shapes, ambient-memory events, and source-grounding hints.
5. `packages/core/src/context-builder.ts` assembles request context, including recent interaction profile and any retrieval hints.
6. Provider selection goes through `packages/providers/src/index.ts`.
7. The bot either:
- answers directly through `local_llm`, or
- queues an owner job for the worker / `owner_codex` path.

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: `apps/bot/src/discord-bot.ts`, `packages/core/src/interaction-memory-logic.ts`, or `packages/core/src/state-storage.ts`
- likely next cuts: `packages/core/src/interaction-memory-logic.ts` or `packages/core/src/state-storage.ts`
- keep behavior stable while moving concerns into smaller organs
### 5. The Still-Scaffolded Paths