refactor(management): replace LangGraph with native PostgreSQL state runner #112

Closed
opened 2026-09-28 19:37:45 +00:00 by yuris · 0 comments
Owner

Acceptance Criteria

  1. Pin existing contracts: ensure apps/management/lib/bot/nodes/node-wiring.test.ts and rejection.test.ts stay green throughout.
  2. Drizzle migration: add bot_sessions table in apps/management/lib/db/schema.ts (columns: phone_number PK, state [IDLE|AWAITING_CONFIRM], pending_action jsonb, updated_at timestamp). Generate migration and include a step to DROP TABLE IF EXISTS checkpoints, checkpoint_blobs, checkpoint_writes, checkpoint_migrations.
  3. Native Engine: replace runner.ts, graph.ts, checkpointer.ts, and state.ts with a direct runner:
    • For read queries: call OpenRouter with tools directly, execute tools, reply.
    • For mutations: store pendingAction in bot_sessions, set state = AWAITING_CONFIRM, send confirmation prompt.
    • On 'ya': execute existing action nodes (executePurchaseNode, executeOrderNode, etc.), reset state to IDLE.
    • On session > 60m: reset state to IDLE.
  4. Cutover & Prune: delete the 6 packages from apps/management/package.json (@langchain/core, @langchain/langgraph, @langchain/langgraph-checkpoint-postgres, @langchain/openrouter, langchain, langfuse-langchain). Update lockfile with pnpm install --no-frozen-lockfile.
  5. Prove it works: run pnpm verify:management (all 19 test files pass, biome check clean).
### Acceptance Criteria 1. Pin existing contracts: ensure apps/management/lib/bot/nodes/node-wiring.test.ts and rejection.test.ts stay green throughout. 2. Drizzle migration: add `bot_sessions` table in apps/management/lib/db/schema.ts (columns: phone_number PK, state [IDLE|AWAITING_CONFIRM], pending_action jsonb, updated_at timestamp). Generate migration and include a step to DROP TABLE IF EXISTS checkpoints, checkpoint_blobs, checkpoint_writes, checkpoint_migrations. 3. Native Engine: replace runner.ts, graph.ts, checkpointer.ts, and state.ts with a direct runner: - For read queries: call OpenRouter with tools directly, execute tools, reply. - For mutations: store pendingAction in bot_sessions, set state = AWAITING_CONFIRM, send confirmation prompt. - On 'ya': execute existing action nodes (executePurchaseNode, executeOrderNode, etc.), reset state to IDLE. - On session > 60m: reset state to IDLE. 4. Cutover & Prune: delete the 6 packages from apps/management/package.json (@langchain/core, @langchain/langgraph, @langchain/langgraph-checkpoint-postgres, @langchain/openrouter, langchain, langfuse-langchain). Update lockfile with pnpm install --no-frozen-lockfile. 5. Prove it works: run pnpm verify:management (all 19 test files pass, biome check clean).
yuris closed this issue 2026-09-28 20:04:00 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
yuris/garage#112
No description provided.