System Invariants and Smoke Tests
Last Updated: 2026-02-28
Content-Type: Reference (operational)
Audience: Engineering + QA + On-call
Purpose
This document defines the “must always be true” invariants for the platform, plus a minimal smoke-test checklist to run after any PR affecting chat, tools, prompts, retrieval, or infra.
Invariants (must always hold)
Tool Platform invariants (backend)
- Central enforcement: all tool executions pass through the canonical tool executor path and are policy enforced.
- Policy completeness: access policies in tool catalog are fully enforced:
- protocol allowlists
- enablement (runtime overrides)
- target scopes:
self_only,explicit_user_selected, etc.
- No hidden tools: any callable tool is registered in the canonical tool catalog (even if marked internal).
- Observability: every tool execution emits an audit event and includes: toolId, userId, protocolId, allow/deny reason.
Prompt Contract invariants (backend)
- No brittle stripping: runtime must not depend on template section stripping to be correct.
- Structured runtime context is parse-safe: if a structured context channel exists, it must be explicitly delimited, schema validated, and fail closed (not silently).
Retrieval invariants (backend)
- One embedding per turn when chunk retrieval is enabled (unless a specific feature requests more).
- Conversation scoping: when structured history exists, retrieval must avoid re-injecting transcript chunks unless explicitly configured.
- No ingestion data loss: chunk ingestion must be atomic (never “delete all chunks then fail insert”).
Background work invariants (backend)
- Bounded concurrency: background jobs are globally capped and deduped by key.
- Time-bounded external calls: embedding/web fetch operations have explicit timeouts.
Frontend chat invariants (aso-portal)
- Single vs group correctness: UI sends to the correct transport and updates the correct history.
- No stuck state: on any upload/send failure, status resets from
thinkingtoerrororidleand UI surfaces a consistent error. - Payload parity: if the UI exposes preferences (web search toggles), those preferences are transmitted for both single and group or explicitly disabled.
Env/config invariants
- Single source-of-truth: env is loaded and validated once; other modules import typed
envrather than readingprocess.envdirectly. - Templates match reality:
.env.examplematches validation and actual usage. - No committed secrets: repo does not track any env-like “copy” files.
Smoke-test checklist (minimal)
Backend (runtime)
- [ ] Server starts cleanly with only
.env(or.env.example+ documented overrides). - [ ] Tool list endpoint works (if applicable) and reflects enablement + policy.
- [ ] Denied tool execution returns
403with a clear reason (policy/protocol/enablement). - [ ] Chat request completes with tools enabled and produces a response.
Backend (retrieval)
- [ ] One chat turn triggers at most one embedding generation (verify logs/metric).
- [ ] Chunk retrieval returns results and does not duplicate structured conversation history (if enabled).
Backend (ingestion)
- [ ] A memory ingestion run does not drop chunks on transient failure (transaction/UPSERT behavior).
Portal
- [ ] Single chat: send text, receive response; status transitions
idle → thinking → idle. - [ ] Single chat streaming (if enabled): placeholder message replaced; tool progress renders.
- [ ] Group chat: suggested prompt sends to group; message appears in group history.
- [ ] Group chat preferences: toggles affect requests, or toggles are hidden/disabled with a clear UI message.
- [ ] Upload failure and socket failure do not leave UI stuck in
thinking.
Docs/dev workflow
- [ ] Setup guide references
.env.exampleonly. - [ ] No env copy files tracked in git.