feat(gateway): org-scope enforcement with user/group principals - #15
Conversation
Context for the gateway stack (#15 → #16 → #17)This fork lands into the OSS gateway build ( All three sit on upstream Per-request pipeline (stable across all three):
What it actually doesBefore this PR, the engine understood only project-scoped rules with agent identities. Any This makes the gateway a genuine two-level evaluator:
Nothing changes about where the decision happens — still Why it existsThis turns the org RBAC from earlier in the stack into actual request-time enforcement. Without it, an org admin defining "block group Contractors from Slack" in the UI would do nothing. Reading order
What to scrutinise
Design decisions worth questioning
Test coverage realityCorrecting the PR description: "no test files" is misleading. There are 22 new test functions in this diff — 14 in What is genuinely unverified:
Highest-value test to add: a DB test seeding Reviewer orientation guide — produced by analysing this PR's diff and surrounding code, not the commit messages. Claims about line numbers and behaviour are worth spot-checking as you read; where it says something is untested or risky, that was verified against the tree rather than inferred. |
…44.0 Reconciliation Stage F. The OSS gateway now populates the org rule set and the user/group PrincipalSet that upstream shipped but never filled: a new loaders.rs adds the org published-rule loader and a principal CTE mirroring the API's resolvePrincipalSet (users direct and via granted groups, active members only; groups direct and inherited; fully org-fenced, agent-groups dropped). Two-level evaluation mirrors upstream's own evaluator including the hard-floor rule (a lone allow at one level cannot open the other level's default block), so an org guardrail can't be bypassed by a project allow. Fail-closed via upstream's anyhow refuse-CONNECT; our old org_degraded/Fallback/kill-switch scaffolding is deleted. Empty org fails OPEN. +21 tests, no agent-group, no signature changes to the call sites.
1b5a1fb to
ea822d1
Compare
Org-scope enforcement in the gateway, with user and group principals. 6 files, +1,080/−176 — 1,080 lines of code with 22 inline
#[cfg(test)]tests (14 inevaluate.rs, 3 each inenforce.rsandloaders.rs, 2 inassemble.rs). No separate test files, which is easy to mistake for no tests. What is genuinely untested isloaders.rs's SQL — the org-fencing CTE that is the actual trust boundary.Where the API-side RBAC from #11–#13 becomes actual request-time enforcement. Worth reading alongside
policy_enginerather than in isolation.Stack
Split out of the original 381-file #8. Upstream catch-up (v1.42.0 → v1.44.0) already landed as #10, so
mainis now v1.44.0 and everything below is our own code.Review and merge in order, top to bottom. Roughly half of each diff is tests.