Skip to content

v1.11.0 — Functioned Tuple-to-Userset (.any() / .all())

Choose a tag to compare

@danhtran94 danhtran94 released this 09 May 11:12
· 21 commits to main since this release

Accepts SpiceDB's functioned arrow syntax — schemas using `.any(view)` and `.all(view)` now compile.

`.any()` is semantically equivalent to a regular arrow `parent->view`. `.all()` is the genuinely-new strict-intersection semantic: subject must reach the inner permission via every parent row, not just any one. Used in dual-control / multi-approver / cross-region patterns where intersection across the userset is required.

The codegen treats functioned arrows identically to regular arrows — function value (`FUNCTION_ANY` / `FUNCTION_ALL`) is server-side semantic enforced by SpiceDB at Check time. Generated method signatures byte-identical between forms.

Use cases for `.all()`

  • Dual-control / four-eyes — `permission deploy = approver_pool.all(approved)`
  • Multi-tenant compliance — `permission process = jurisdiction.all(compliant)`
  • Cross-region replication — `permission read = region.all(authorized_reader)`
  • Multi-team ownership — `permission merge = owning_team.all(reviewer)`

Single Check call against a single SpiceDB snapshot — vs the alternative of N Check calls intersected client-side, which has measurable round-trip cost, no atomic evaluation, and shifts the semantic into application code.

Added

  • Adapter in `internal/generator/adapter.go` — `lowerSetOperationChild` handles `FunctionedTupleToUserset` parallel to the existing `TupleToUserset` branch. Maps to `PermExprArrow`; function value read but not propagated.
  • Schema fixtures on `extsvc/folder`: `any_via`, `all_via`, `gated_all_via` (`.all()` + caveat combo), `mixed_all` (regular identifier + `.all()` arrow combo).
  • 2 adapter unit tests verifying `.any()` / `.all()` map to `PermExprArrow` correctly.
  • 8 e2e tests covering single-parent grant, two-parent both grant, one-parent-missing-deny (strict intersection), zero-parent vacuous-deny, `.all()` + caveat (matching + wrong tenant), mixed-expression direct-path and `.all()`-path grants.

Changed

  • README Schema Support table gains a row for functioned arrows marked ✓.

Verified

  • All 5 e2e packages pass.
  • Codegen idempotent at the new baseline.
  • Per-namespace `.gen.go` files unchanged for definitions without functioned-TTU usage.
  • `go build ./...` + `go vet ./...` clean.

Deferred

  • `_self` schema construct (`use self`) — reflexive permissions; less common pattern.
  • `_nil` graceful skip — internal compiler artifact.
  • `_this` — fully deprecated upstream; permanent rejection.