Feat/p3 tenant aware correlation - #21
Merged
Merged
Conversation
BEHAVIOR_DOC_MAP referenced docs/TRACES/* but the tracked directory is docs/traces/* (lowercase), so the case-sensitive match made the guard structurally unsatisfiable for moralstack/server/ and moralstack/compliance/ changes. Align the four entries to the real paths so the gate enforces the intended documentation updates again.
Key the proxy ConversationCorrelationStore lineage map by (principal, canonical_history_hash) so byte-identical histories from different tenants no longer collide onto one conversation_id. The two hash functions stay byte-for-byte unchanged; an empty principal reproduces the prior behavior exactly, preserving existing single-turn and history-based multi-turn correlation. Bound the store with TTL lazy-expiry + a max-entries FIFO cap (defaults 3600s / 20000, overridable via MORALSTACK_CORRELATION_TTL_SECONDS and MORALSTACK_CORRELATION_MAX_ENTRIES), removing the unbounded-growth risk. Derive the principal per request: X-Moralstack-Tenant-Id header, else HMAC-SHA256 of an Authorization Bearer token (MORALSTACK_PRINCIPAL_HMAC_SECRET, read per request; raw token and digest never logged), else empty sentinel. Add an optional create_app(correlation_store=) parameter. resolve() is best-effort on the TTL/eviction path (PROJECT_SPEC section 5 invariant #6): a helper failure never propagates into the request handler and a valid msconv-* id is always minted. Defer ConversationLockManager._locks bounding (TODO P3-followup). No P0 decision/governance invariant is affected. Validated end-to-end against a live proxy reproducing the COMPL-AI call patterns (history-list multi-turn, tenant/HMAC isolation, explicit conversation-id header) plus the full offline suite (2214 passed) and pre-commit.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.