Skip to content

oxidizer: migrate AIDecisionService.generateResponse to Rust cognition/generate-response #1385

@joelteply

Description

@joelteply

airc-queue card

Coordinates work via the AIRC queue substrate (airc#562). Edit this card by commenting OR by running airc queue claim/airc queue release/airc queue heartbeat (later PRs).

{
  "kind": "airc-queue-card-v1",
  "id": "#1385",
  "branch": "feat/rust-resource-admission-generate-response",
  "owner": "codex-main",
  "status": "merged",
  "env": "any",
  "evidence": "Focused Rust tests passed for rust_admission against continuum-core with metal,accelerate before commit; final precommit rerun pending after clippy import cleanup.",
  "next_action": "Land Rust ResourceAdmissionGate wiring around cognition/generate-response, open PR to canary, then remove temp worktree and surface governor WIP visibly.",
  "last_heartbeat": "2026-05-18T17:42Z @ edeafa48e"
}

Close this issue when the work is done (status=merged/abandoned).

Original issue body

Pre-adoption body

airc-queue card

Coordinates work via the AIRC queue substrate (airc#562).

```json
{
"kind": "airc-queue-card-v1",
"status": "claimed",
"owner": "airc-8a5e",
"next_action": "Ship PR-1 (pure types + build_response_messages port + identity-reminder template)."
}
```

Scope

Sibling to just-completed checkRedundancy oxidizer (#1375). The LAST remaining TS-side AI logic in AIDecisionService.ts is generateResponse (lines 316-396) + its buildResponseMessages helper (lines 439-540).

Method in AIDecisionService.ts State Oxidization
evaluateGating ✅ Rust IPC (cognition/should-respond) done
checkRedundancy ✅ Rust IPC (cognition/check-redundancy, #1375) done
generateResponse ❌ TS-side AIProviderDaemon.generateText + timeout race this card

After this card: AIDecisionService.ts contains only IPC shims + slot coordination (legitimate platform concerns per umbrella body).

PR sequence (mirrors checkRedundancy + rate_proposals)

PR-1 — pure types + prompt builder + identity-reminder template (~250 LOC + tests)

  • GenerateResponseRequest { context, model?, temperature?, max_tokens?, timeout_ms? } (ts-rs)
  • GenerateResponseResult { text, model, response_time_ms, timestamp, tokens_used? } (ts-rs)
  • TokenUsage { input, output, total } (ts-rs)
  • build_response_messages(&AIDecisionContext) -> Vec<ChatMessage> — pure port of TS buildResponseMessages, including:
    • System-prompt injection
    • Conversation history with [HH:MM] time prefix
    • Hour-gap markers ("⏱️ N hours passed - conversation resumed")
    • Final identity-reminder template (the ~50-line critical-topic-detection prompt)
  • IDENTITY_REMINDER_TEMPLATE Rust const string (formatted with persona_name + members + current_time)
  • Pure helper: extract_room_members(system_prompt: &str) -> &str (regex match for Current room members:)

PR-2 — async generate_response + IPC handler (~120 LOC + tests)

  • generate_response(request) -> Result<GenerateResponseResult, GenerateResponseError>
  • Composes build_response_messages → AI provider call (existing local Qwen router via global_registry) → result with timing
  • Timeout via tokio::time::timeout (replaces TS Promise.race)
  • CognitionModule command arm for cognition/generate-response

PR-3 — TS shim (~30 LOC)

  • AIDecisionService.generateResponse delegates to RustCoreIPCClient.cognitionGenerateResponse
  • Slot management stays on TS for now (separate concern)

PR-4 — delete dead TS (~250 LOC removed)

  • buildResponseMessages + the identity-reminder template
  • generateResponse inline body (after PR-3 shim is the only caller surface)

Refs

Status log

  • 2026-05-18T17:44Z — airc-8a5e-bc43 -> status=merged

  • 2026-05-18T17:42Z — heartbeat by codex-main -> status=review (PR feat(cognition,#1385): admit generate-response through Rust resource gate #1396 opened at edeafa4; focused Rust tests/precommit/prepush compile+tests passed; Docker image publish blocked by GPU-required slice-test environment)

  • 2026-05-18T17:42Z — airc-8a5e-bc43 -> status=review

  • 2026-05-18T17:30Z — heartbeat by codex-main -> status=in-progress (commit bb6fba3cb landed locally; focused Rust admission tests passed 3/3; precommit TS+clippy passed; browser/live tests skipped because core socket unavailable)

  • 2026-05-18TZ — created + claimed by airc-8a5e -> status=claimed. Starting PR-1 in isolated worktree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    airc-queueAIRC-backed agent work queue card

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions