Architectural Invariant Tests
Validates component boundaries, independence, and structural properties of the architecture.
ARCH-1: Memory Zero Dependencies
Validates: Principle 1 (Memory is the platform), foundation-spec §Your Memory
Setup:
- System running with data in Your Memory (files, conversations, preferences)
- All components operational
Procedure:
- Stop the Agent Loop process
- Stop the Gateway process
- Stop Auth
- Stop all tool servers / MCP processes
- Attempt to read Your Memory content using standard tools
Pass criteria:
- All files in Your Memory are readable with a text editor
- SQLite databases are readable with a standard SQLite viewer
- Git history is browsable with standard git commands
- No component needs to be running to access Your Memory
- Content makes sense to a human reader without the system
Failure indicators:
- Files are in a proprietary format that requires the system to decode
- Data is encrypted with keys that only the running system can access
- Content requires a specific tool or service to be readable
- Any file in Your Memory has a binary format without a standard reader
ARCH-2: Agent Loop Swap
Validates: D39 (Agent Loop is generic), FS-7 (Swap the Agent Loop)
Setup:
- System running with Agent Loop Implementation A
- Test conversation completing successfully
- Agent Loop Implementation B available (different codebase, same contract)
Procedure:
- Stop the system
- Replace Agent Loop A binary/container with Agent Loop B
- Keep all other components, config, Your Memory, tools unchanged
- Start the system
- Run the same test conversation
Pass criteria:
- Test conversation completes successfully with Agent Loop B
- Gateway operates identically — same conversation management
- Auth operates identically — same authentication/authorization
- Your Memory is unchanged — same files, same data
- Tools work identically — same tool calls succeed
- Clients connect identically — same Gateway API
- Only the Agent Loop binary/container was changed
Failure indicators:
- Gateway needed modification to work with Agent Loop B
- Auth needed modification
- Tool definitions or configurations needed changes
- Your Memory format was incompatible
- Clients needed updates
ARCH-3: Client Swap
Validates: D57 (clients are external), FS-5 (Swap the client)
Setup:
- System running with Client A (e.g., web app)
- Active conversation with history
Procedure:
- Build Client B (e.g., CLI) that speaks the Gateway API
- Connect Client B to the same Gateway
- Resume the existing conversation from Client B
Pass criteria:
- Client B connects successfully through the Gateway API
- Client B can list existing conversations
- Client B can resume the conversation started by Client A
- Full conversation history is available
- New messages from Client B are processed identically
- The system has no knowledge of which client is connected
- Zero changes to Gateway, Agent Loop, Auth, Your Memory, or tools
Failure indicators:
- The Gateway needed to know about Client B
- Client-specific logic exists in any component
- Conversation history was not available to the new client
- The system behaved differently based on which client was connected
ARCH-4: Schema Conformance
Validates: D16 (zero custom protocols), canonical contract definitions
Setup:
- System running with active traffic (messages, tool calls, responses)
- Canonical schemas available in
../../../specs/openapi/and../../../specs/schemas/
Procedure:
- Capture all Gateway API requests and responses
- Capture all Model API requests and responses
- Capture all Gateway ↔ Agent Loop requests and SSE events
- Validate each payload against the corresponding canonical schema
Pass criteria:
- Every Gateway API request validates against
gateway-api.yaml - Every Gateway API response validates against
gateway-api.yaml - Every Agent Loop request validates against
gateway-engine.yaml - Every SSE event validates against the event schemas in
gateway-engine.yaml - Every Model API request validates against
model-api.yaml - Every Model API response validates against
model-api.yaml - No payload contains fields not defined in the schemas (no undocumented extensions)
Failure indicators:
- Custom fields added outside the schema
- Provider-specific data leaking through the internal contract
- Client-specific formats in the Gateway API
- Missing required fields defined in the schemas
ARCH-5: Error Taxonomy Compliance
Validates: gateway-engine-contract.md §Mid-Stream Errors, engine-spec.md §Error output
Setup:
- System running with active traffic
- Ability to trigger provider failures, tool failures, and context overflow conditions
Procedure:
- Trigger a model/network failure (e.g., invalid provider URL)
- Trigger an unrecoverable tool execution failure (e.g., tool executor crash)
- Trigger a context overflow (e.g., send messages exceeding model context window)
- Capture the SSE error events emitted in each case
Pass criteria:
- Provider/network failure emits
provider_error - Unrecoverable tool failure emits
tool_error - Context overflow emits
context_overflow - No catch-all error code used for all failure types
- Recoverable tool failures (tool returns an error result) go back to the model as
tool-resultevents, not as stream-fatalerrorevents
Failure indicators:
- All errors emit the same code regardless of cause
- Tool execution errors that the model could recover from terminate the stream
- Context overflow is reported as
provider_error
ARCH-6: Error Message Sanitization
Validates: gateway-engine-contract.md §Security Requirements, security-spec.md
Setup:
- System running with various failure conditions triggerable
Procedure:
- Trigger errors that would produce stack traces, file paths, or credential references internally
- Capture the SSE error events
- Inspect the
messagefield of each error event
Pass criteria:
- No SSE error event
messagecontains file system paths - No SSE error event
messagecontains stack traces - No SSE error event
messagecontains credentials, tokens, or API keys - All error messages are safe for display to end users
- Raw diagnostic detail is available in structured stdout logs (not in the stream)
Failure indicators:
- Error messages contain
/home/...,/usr/..., or similar paths - Error messages contain
at Object.<anonymous>or similar stack frames - Error messages contain API keys or tokens
ARCH-7: Memory Export
Validates: memory-spec.md §Export, security-spec.md §Owner Data Rights
Setup:
- System running with data in Your Memory (files, conversations, preferences, version history)
Procedure:
- Invoke the
memory_exporttool (or equivalent export mechanism) - Stop the system
- Inspect the exported archive with standard tools
Pass criteria:
- Export produces a complete archive of all owned Memory data
- Archive is in an open format (tar, zip, or equivalent)
- Files are readable with a text editor
- Version history is included or reproducible
- Conversations are included in the export
- Auth credentials are NOT included in the export
- Archive is readable without the system running
Failure indicators:
- Export is missing files, conversations, or version history
- Export contains credentials or secrets
- Export format requires the system to decode
ARCH-8: Auth Tool Surface
Validates: auth-spec.md §Minimal Tool Surface
Setup:
- System running with Auth configured (any mode, including local owner)
Procedure:
- Call
auth_whoamitool - Call
auth_checktool with a known resource/action - Call
auth_exporttool
Pass criteria:
-
auth_whoamireturns current actor identity (type, ID) -
auth_checkreturns a permission decision (allow/deny) for the given resource/action -
auth_exportreturns auth configuration without credentials - All three tools are registered and discoverable alongside memory tools
Failure indicators:
- Any of the three tools is missing from the tool registry
auth_whoamireturns empty or errorauth_exportincludes credentials or secrets
ARCH-9: Version History Reliability
Validates: memory-spec.md §Guarantees, security-spec.md §Version History
Setup:
- Fresh system install (no prior data)
Procedure:
- Start the system for the first time
- Write a file to Your Memory
- Modify the file
- Call
memory_historyon the file - Request a previous state using the returned version identifier
Pass criteria:
- System starts successfully on first run with version history initialized
-
memory_historyreturns at least two change records (create + modify) - Previous state is retrievable and matches the original file content
- If version history cannot be initialized at startup, the system fails with a clear error (not a warning)
Failure indicators:
- System starts but version history silently fails
memory_historyreturns only metadata without access to previous states- First-run initialization produces warnings instead of deterministic setup
DEPLOY-5: Default Bind Address
Validates: Security-spec.md §Network Boundaries
Setup:
- Fresh system install with default configuration
Procedure:
- Start the system with no bind address configuration changes
- Check the listening address of the Gateway HTTP server
Pass criteria:
- Gateway binds to
127.0.0.1only by default - Gateway does NOT bind to
0.0.0.0unless explicitly configured - Changing bind address to
0.0.0.0requires an explicit configuration change (not just removing a restriction)
Failure indicators:
- Default install listens on all interfaces
- Docker configuration maps the port to the host by default