Skip to content

Feat/p3 tenant aware correlation - #21

Merged
fdidonato merged 2 commits into
mainfrom
feat/p3-tenant-aware-correlation
Jul 9, 2026
Merged

Feat/p3 tenant aware correlation#21
fdidonato merged 2 commits into
mainfrom
feat/p3-tenant-aware-correlation

Conversation

@fdidonato

Copy link
Copy Markdown
Owner

No description provided.

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.
@fdidonato
fdidonato merged commit b68659d into main Jul 9, 2026
6 checks passed
@fdidonato
fdidonato deleted the feat/p3-tenant-aware-correlation branch July 9, 2026 12:00
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants