[P1] H02: Deliver persisted streamed chat turns with cancellation and response-time authorization #27

Open
opened 2026-10-21 20:29:30 +02:00 by amiryahaya · 0 comments
Owner

Backlog ID: H02 | Priority: P1 | Phase: M5 — Local inference and complete chat

Outcome and scope

Implement POST conversation turns and a typed SSE lifecycle backed by durable message records and authorized citations; propagate deadline/cancellation through retrieval and inference.

Dependencies and gates

Engineering prerequisites: #26 (H01), #25 (E02), #11 (F06), #30 (O01)

Synthetic-data development may proceed. Production use remains subject to the decision gates in the SRS.

Starting points

crates/api/src/routes/turns.rs; crates/conversations/src/turns/; migrations/; tests/integration/chat_stream.rs

These are current files or proposed responsibility boundaries; finalize a focused implementation plan before coding. Existing local scaffolding is uncommitted and is not evidence of completion.

Acceptance criteria

  • Stable request/message/event IDs associate tokens, citations, feedback and completion; terminal completion/cancellation/error are distinct and delivered at most once.
  • Disconnect/cancel/timeout releases resources and follows an explicit partial-answer persistence policy; no unmarked partial answer is committed.
  • Revalidate active authorization within the approved revocation bound and before emitting protected citations/final content; stop/suppress on revoked access.
  • Reconnect/retry behavior is idempotent and never launches duplicate inference or replays inaccessible content.
  • Record browser/server timing hooks without payload logging and retain authorized model/retrieval/policy provenance.

Verification

Integration tests cover happy path, revocation mid-stream, slow consumer, disconnect, duplicate/reconnect, timeout and runtime error; verify terminal event and cleanup counts.

Behavior changes follow Red → Green → Refactor. Run affected Rust shared contract/unit tests and real PostgreSQL/Qdrant/runtime integration tests where applicable; frontend changes run typecheck/build and the relevant browser tests. Record exact commands/results in the implementation PR. Documentation/decision tasks use recorded review evidence.

Requirements and design

FR-RAG-001, 004–009; FR-UX-001, 007; FR-PRIV-003; architecture §9.3

Sources: SRS, system design. Local planning context: docs/implementation-plan.md and docs/development-backlog.md (not published by this task).

Security impact: Use synthetic fixtures until approved for operational data. Preserve current authorization, markings, provenance and default-deny behavior; exclude protected payloads/secrets from operational telemetry. No classified-deployment or PQC-compliance claim is implied by closing this issue.

Parent roadmap: #1

**Backlog ID:** H02 | **Priority:** P1 | **Phase:** M5 — Local inference and complete chat ## Outcome and scope Implement POST conversation turns and a typed SSE lifecycle backed by durable message records and authorized citations; propagate deadline/cancellation through retrieval and inference. ## Dependencies and gates **Engineering prerequisites:** #26 (H01), #25 (E02), #11 (F06), #30 (O01) Synthetic-data development may proceed. Production use remains subject to the decision gates in the SRS. ## Starting points crates/api/src/routes/turns.rs; crates/conversations/src/turns/; migrations/; tests/integration/chat_stream.rs These are current files or proposed responsibility boundaries; finalize a focused implementation plan before coding. Existing local scaffolding is uncommitted and is not evidence of completion. ## Acceptance criteria - [ ] Stable request/message/event IDs associate tokens, citations, feedback and completion; terminal completion/cancellation/error are distinct and delivered at most once. - [ ] Disconnect/cancel/timeout releases resources and follows an explicit partial-answer persistence policy; no unmarked partial answer is committed. - [ ] Revalidate active authorization within the approved revocation bound and before emitting protected citations/final content; stop/suppress on revoked access. - [ ] Reconnect/retry behavior is idempotent and never launches duplicate inference or replays inaccessible content. - [ ] Record browser/server timing hooks without payload logging and retain authorized model/retrieval/policy provenance. ## Verification Integration tests cover happy path, revocation mid-stream, slow consumer, disconnect, duplicate/reconnect, timeout and runtime error; verify terminal event and cleanup counts. Behavior changes follow Red → Green → Refactor. Run affected Rust shared contract/unit tests and real PostgreSQL/Qdrant/runtime integration tests where applicable; frontend changes run typecheck/build and the relevant browser tests. Record exact commands/results in the implementation PR. Documentation/decision tasks use recorded review evidence. ## Requirements and design FR-RAG-001, 004–009; FR-UX-001, 007; FR-PRIV-003; architecture §9.3 Sources: [SRS](https://forgejo.primatekun.tech/primatekuntech/rag-rust/src/branch/main/docs/SRS.md), [system design](https://forgejo.primatekun.tech/primatekuntech/rag-rust/src/branch/main/docs/architecture.md). Local planning context: `docs/implementation-plan.md` and `docs/development-backlog.md` (not published by this task). **Security impact:** Use synthetic fixtures until approved for operational data. Preserve current authorization, markings, provenance and default-deny behavior; exclude protected payloads/secrets from operational telemetry. No classified-deployment or PQC-compliance claim is implied by closing this issue. **Parent roadmap:** #1
Sign in to join this conversation.
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.

Reference
primatekuntech/rag-rust#27
No description provided.