Skip to content

oxidizer: AIGenerateServerCommand → cognition/generate-response shim#1438

Merged
joelteply merged 1 commit into
canaryfrom
oxidizer/ai-generate-cognition-shim
May 25, 2026
Merged

oxidizer: AIGenerateServerCommand → cognition/generate-response shim#1438
joelteply merged 1 commit into
canaryfrom
oxidizer/ai-generate-cognition-shim

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

RAG-mode generation now delegates to Rust via `AIDecisionService` — the same IPC seam `PersonaUser`'s response path already uses. Rust owns:

  • Prompt assembly: system prompt + history with time prefixes + hour-gap markers + identity reminder
  • Provider routing + admission gating (`ResourceAdmissionGate`)
  • Timeout + token-usage stamping

All in `cognition/generate_response.rs::build_response_messages` + `build_response_generation_request`.

What stays TS-side

Mode Behavior Why
`roomId` (RAG) → `AIDecisionService.generateResponse` (Rust) Production hot path
`messages` (direct) → `AIProviderDaemon.generateText` Test/introspection — bypasses admission
`preview` Local mirror of Rust assembly Allows `--preview` without IPC

The preview-mode mirror is the only durable wet-code. If Rust prompt assembly drifts the fix is a `cognition/preview-request` IPC, not maintaining two copies.

Pattern

Mirrors #1421 (`should-respond` → `cognition/should-respond`) and #1426 (`validate-response` → `cognition/validate-response-decision`). The TS direct-message duplicate of `build_response_messages` is gone — Rust owns it.

Verification

  • `npm run build:ts` green
  • precommit suite green (TypeScript + chat-roundtrip)
  • ESLint baseline locked one lower (5431 < 5432)
  • Wire types unchanged (`GenerateResponseRequest` already ts-rs-generated, already consumed by `AIDecisionService`)

🤖 Generated with Claude Code

RAG-mode generation now delegates to Rust via AIDecisionService — the
same IPC seam PersonaUser's response path already uses. Rust owns
prompt assembly (system prompt + history + time prefixes + hour-gap
markers + identity reminder), provider routing, admission gating,
timeout, and token-usage stamping (build_response_messages +
build_response_generation_request in cognition/generate_response.rs).

Direct-message + preview modes stay TS-side:
- Direct mode is an introspection/test path that bypasses admission;
  Rust intentionally does not expose a "skip the gate" code path.
- Preview mode reconstructs the request Rust would build as a local
  mirror. Source of truth is the Rust path; if assembly drifts a
  `cognition/preview-request` IPC is the fix.

Mirrors the pattern from #1421 (should-respond) and #1426
(validate-response-decision). The 100-line of TS message-building
that duplicated build_response_messages now lives only in Rust.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelteply joelteply merged commit 7483132 into canary May 25, 2026
3 of 4 checks passed
@joelteply joelteply deleted the oxidizer/ai-generate-cognition-shim branch May 25, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant