Add bounded AI Engine contracts and shared adapter test suite (E01, #15) #57
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
primatekuntech/rag-rust!57
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/15-engine-contracts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #15 (E01).
What this adds
A new
rag-ai-enginecrate: the app-owned contract between the RAG application and the AI Engine. It depends onrag-domainonly; a test enforces that.EmbedRequest,RerankRequest,CountRequest,GenerateRequest. Each carries aRequestScope(request ID, organization, policy version, optional marking, deadline, cancellation) and a permitted profile ID, and validates bounds in its constructor. No conversation, message, document or user identifiers.Debugon requests, scope, embeddings and stream tokens never prints text, vectors or marking values (sentinel tests).EmbeddingContract(profile, dimensions, tokenizer) fails withIncompatibleProfileorUnknownProfilebefore any work.GenerationProfile::fitsfails withContextTooLargebefore generation starts, with checked arithmetic. Embed inputs and rerank passages over the advertised token limit also fail before work; nothing is silently truncated.AiEngineClient: object-safe trait with boxed futures (embed, rerank, count_tokens, streamed generate, capabilities), a versioned contract (1.0) andCapabilities::require(streaming, cancellation, session isolation).ProfileIdinrag-domain;docs/operations/ai-engine-contract.md(contract, bounds, semantics, how a real adapter plugs in, deferrals); README link; the implementation plan.Not in this PR
InstantandCancellationstay on the client side.Embedder/Reranker/Generatorapplication traits (first consumers define them).Cancellation::cancelled(),Usageon errored streams, and per-message template overhead inGenerationProfileare listed as deferred in the docs.crates/ai-engine/tests/support); promote it to a shared crate when the first real adapter lands. Suite checks 6, 9, 10, 11 and 12 assume output derived from the prompt, so a real model adapter needs an echo or deterministic profile.Verification
bash scripts/coverage.sh rust(workspace tests plus the Postgres suites): exit 0, 93.83% line coverage (minimum 80%). New crate sources: 93-100%.cargo fmt --checkandcargo clippy --workspace --all-targets --locked -- -D warnings: clean.CountRequest.profile); all fixed and re-reviewed clean.rag-apiauthz unit test failed once in a workspace run and passed on three reruns; it is outside this change.🤖 Generated with Claude Code