[P1] O01: Enforce bounded admission, inference scheduling and request resource budgets #30

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

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

Outcome and scope

Implement application and Engine budgets for requests, per-user concurrency/rate, queue depth/wait, prompt/output tokens, timeout and cancellation; preserve interactive capacity alongside ingestion.

Dependencies and gates

Engineering prerequisites: #15 (E01), #10 (F05), #12 (F07), #3 (D02)

Final capacity values follow D02/E02 measurements; this task defines the controls without inventing final hardware sizing.

Starting points

crates/api/src/limits/; crates/ai-engine/src/scheduling/; crates/conversations/; tests/load/admission/

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

  • All work queues, connection acquisitions and active slots have configured bounds and observable overload/timeout behavior.
  • Generation is not starved by bulk embeddings/reindexing; any batching is measured against the approved latency envelope.
  • Queue wait is included in TTFT and safe phase metrics; authorization/retrieval cannot be skipped to improve latency.
  • Cancel/disconnect/timeout promptly releases permits, jobs and slots without leaks or double release.

Verification

Deterministic scheduler tests and ten-client overload tests verify fairness, bounds, cancellation cleanup and no starvation under ingestion load.

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-008; NFR-PERF-002, 004–005; architecture §9.6

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:** O01 | **Priority:** P1 | **Phase:** M5 — Local inference and complete chat ## Outcome and scope Implement application and Engine budgets for requests, per-user concurrency/rate, queue depth/wait, prompt/output tokens, timeout and cancellation; preserve interactive capacity alongside ingestion. ## Dependencies and gates **Engineering prerequisites:** #15 (E01), #10 (F05), #12 (F07), #3 (D02) Final capacity values follow D02/E02 measurements; this task defines the controls without inventing final hardware sizing. ## Starting points crates/api/src/limits/; crates/ai-engine/src/scheduling/; crates/conversations/; tests/load/admission/ 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 - [ ] All work queues, connection acquisitions and active slots have configured bounds and observable overload/timeout behavior. - [ ] Generation is not starved by bulk embeddings/reindexing; any batching is measured against the approved latency envelope. - [ ] Queue wait is included in TTFT and safe phase metrics; authorization/retrieval cannot be skipped to improve latency. - [ ] Cancel/disconnect/timeout promptly releases permits, jobs and slots without leaks or double release. ## Verification Deterministic scheduler tests and ten-client overload tests verify fairness, bounds, cancellation cleanup and no starvation under ingestion load. 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-008; NFR-PERF-002, 004–005; architecture §9.6 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#30
No description provided.