Skip to content

feat(compute-gateway): mount read-path masking PDP (policy veto + field masking + sealed decision) - #1157

Open
mdheller wants to merge 3 commits into
mainfrom
feat/compute-gateway-masking
Open

feat(compute-gateway): mount read-path masking PDP (policy veto + field masking + sealed decision)#1157
mdheller wants to merge 3 commits into
mainfrom
feat/compute-gateway-masking

Conversation

@mdheller

Copy link
Copy Markdown
Member

Mounts the masking moat (P1 #5→serving) on compute-gateway, the estate's one governed door — the smallest real increment from the A/B/C strategy read.

What

For read-effect kinds (graph-query/graph-stats), engine.execute passes the dispatched outputs through a field-level masking policy between dispatch and seal, so the existing Ed25519 receipt (receipts.seal/signing.attest) attests exactly what the caller received, and the masking decision itself is emitted as a sealed output — the verifiable-evidence property WKC-style dynamic masking does not produce.

  • compute_gateway/masking.py (new): off by default (no GATEWAY_MASKING_POLICY → exact passthrough, zero behaviour change on a live gateway); fail-closed when configured. Forbidden identity-mixture veto (no_health_adtech) withholds records; field schemes = compact read subset of tokenization-profile.v1 (hmac_pseudonym, one_way_hash, redact, suppress, generalize); unknown scheme → redact. Emits identity-prime.masking-decision.v1.
  • engine.py: import + one guarded call scoped to READ_KINDS. No change to receipts.seal/signing.

Tests

tests/test_masking.py — 6 tests, all green. Existing test_engine_seal + test_gateway (26) unaffected.

Scope

Serving mount only. Canonical primitives stay in the exodus reference engine; Chameleon algebraic re-keying / NIST FF1 / HSM-held keys swap in behind _transform with no PDP or caller change. Policy wiring to per-tenant entitlement is the next increment.

🤖 Generated with Claude Code

mdheller added 3 commits July 31, 2026 10:19
…ld masking + sealed decision)

Mounts the masking moat on the one governed door. For read-effect kinds
(graph-query / graph-stats), engine.execute now passes dispatched outputs through
a field-level masking policy BETWEEN dispatch and seal, so the Ed25519 receipt
attests exactly what the caller received and the masking decision rides the same
attestation (the verifiable-evidence property WKC-style dynamic masking lacks).

compute_gateway/masking.py (new)
  - OFF by default: no GATEWAY_MASKING_POLICY → exact passthrough (zero behaviour
    change on the live gateway). Fail-closed WHEN configured.
  - forbidden identity-mixture veto (e.g. no_health_adtech) → withholds records,
    returns only the deny decision.
  - field masking schemes (compact read subset of tokenization-profile.v1):
    hmac_pseudonym (domain-scoped, deterministic), one_way_hash, redact, suppress,
    generalize; unknown scheme fails closed to redact.
  - emits identity-prime.masking-decision.v1 as a ComputeOutput → sealed + attested.

engine.py
  - import masking; one guarded call between dispatch (raw) and seal, scoped to
    masking.READ_KINDS. ~8 lines, no change to receipts.seal / signing.

tests/test_masking.py (6 tests): off-by-default passthrough, field masking + sealed
decision shape, forbidden-mixture deny/withhold, deterministic pseudonym, unknown
scheme fail-closed, invalid-policy disables-off. Existing engine-seal + gateway
suites unaffected (26 pass).

Canonical desensitisation primitives remain in the exodus reference engine
(exodus_tokenize / exodus_mask); Chameleon algebraic re-keying + NIST FF1 + HSM keys
swap in behind _transform with no PDP or caller change.
…ution

Follow-up to the masking mount: policy is no longer a single global env value.
GATEWAY_MASKING_POLICIES is a table {selector: policy} resolved by project, then
entitlement, then a "*"/"default" fallback — so different tenants/entitlements carry
different masking rules through the one gateway. Legacy single GATEWAY_MASKING_POLICY
remains the global fallback. Still off-by-default and fail-closed.

Tests: per-tenant selection, entitlement selector, legacy-global fallback (9 total).
…ant leak)

Adversarial self-review before merge found a real defect in the masking mount:
the compute memo keys reads by (project,kind,backend,spec) and serves any matching
caller. Masking makes read results depend on actor/entitlement (per-tenant policy +
forbidden-mixture veto), so a memoized masked read could be served to a DIFFERENT
tenant — a cross-tenant data leak (under-masking) or wrong-policy masking.

Fix: read_memo_spec() folds actor+entitlement into the memo spec for maskable read
kinds, so masked reads are never shared across callers via the cache. Non-read kinds
keep cross-caller memoization. Test asserts read keys differ by caller, match within a
caller, and non-read keys are caller-independent. Full suite: 232 pass.
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.

1 participant