feat(server): tenant-aware write paths and pluggable tenant resolver (4/7)#182
Draft
abhinav-galileo wants to merge 1 commit intoabhi/rfc-1-1-pr3-runtime-resolutionfrom
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
24b421b to
55a647d
Compare
4d165f6 to
0c1787e
Compare
3 tasks
5222252 to
1f581f1
Compare
0c1787e to
2532c58
Compare
1f581f1 to
41e3d21
Compare
2532c58 to
0bc87a8
Compare
41e3d21 to
af42b84
Compare
Agent, control, and policy creation now read the effective tenant via a get_tenant_id dependency backed by a pluggable TenantResolver. Default resolver reads X-Tenant-Id header and falls back to DEFAULT_TENANT_ID so callers that omit the header continue to work. Association inserts into agent_policies and agent_controls record the owning agent's tenant_id. Deployments with their own tenant identity source can swap the resolver at startup via set_tenant_resolver. Read paths remain unscoped.
0bc87a8 to
5cb6d26
Compare
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.
Stacked on top of #181. Kept in draft until the full stack has been validated end-to-end.
Summary
TenantResolverProtocol andHeaderTenantResolverdefault implementation intenancy.py.set_tenant_resolver(...)lets deployments with their own tenant identity source (e.g. auth claims) swap in an alternative resolver at startup.initAgent), control (create_control), and policy (create_policy) creation now persist the resolved tenant explicitly instead of relying solely on the DB default.agent_policiesandagent_controlsrecord the owning agent'stenant_id, not the request-scoped one. This keeps association rows consistent with the parent agent under all tenant mechanisms.Design notes
resolve(x_tenant_id). This keeps the OSS code free of auth-specific types and lets extensions grow without forcing OSS code to adopt them.default-tenant.Intentional non-goals (deferred)
Agent.name,Control.name,Policy.name. Cross-tenant name collisions still apply. Tests use distinct names per tenant rather than depending on tenant-scoped uniqueness.Test plan
make checkclean locally (562 server tests including 9 new)X-Tenant-Idland in the resolved tenantagent_policies/agent_controlsrows inherit the agent'stenant_idTenantResolverProtocol is runtime-checkable