Skip to content

feat(bep): add the bep crate with the GitHub module and sealed envelope

Minimal Arch / arch-review failed Oct 19, 2026 in 0s

CONDITIONS

Governs: Gatehouse §6.10 (specs/authn-authz/gatehouse-spec.md). Sealed secret (line 817): a compact JWE, typ "gatehouse-sealed-secret+jwe" (§14.1 line 1977), binds the context {td, sub, node_id, upstream, mode, iat, exp, kid}. In that context mode is audit-only at redemption, and the plaintext is a member list. The un-enrolled bullet (line 839) seals to the helper's key "under the same envelope". Hardware-backed custody (line 837) names ECDH-ES P-256 for sealing, and spec BEP-059 makes the sealing key non-exportable. Redemption (line 823) refuses an expired blob. Module host sets (line 851) admits an authority in the blob's set ∩ the current set. Fixed deny set (line 849). This checkout has no arch-map.md, so I found these sections from the Gatehouse table of contents and by searching for seal, envelope, deny set and host set.

Ruling: The crate placement conforms. Spec 24 makes the proxy its own host-side crate, and §6.10 makes the node-local BEP a role of the host-side helper. The GitHub v1 host set at 443 matches line 851 exactly. Breadth in the authenticated plaintext, with a fail-closed refusal of an unknown breadth, matches line 817. The error names a field and no value, as the task's observability line asks. The envelope itself deviates. It is a custom minseal1_ binary format on X25519/HKDF/ChaCha20, and not the compact JWE the design names for both the hosted and the node-local BEP (C1). X25519 also cannot be the non-exportable P-256 sealing key that line 837 names. The context omits iat and kid (C2), and the plaintext is not the member list (C3). open() makes mode, host_set_version and expiry exact-match checks against a caller-supplied value. Line 817 makes mode audit-only. Line 851 admits an older-version blob within the intersection of the two sets. Line 823 refuses on a clock, and the redeemer cannot know the expected expiry before it opens the value (C4). The task's diagnostics line lists mode and expiry as fields that "differed". Where that line conflicts with lines 817 and 823, the design wins (rule 9). The plan must name only box id, host and module as mismatches. DENY_SET is the agent's own guess (the PR body says so) and is none of line 849's categories (C5). The deny set content for the un-enrolled CA is a design question, so I escalate it.

Precedent: No prior ruling in the ledger is on the BEP envelope or on spec 24. The entries are on networking and CI, so none applies, and this ruling does not depart from any of them.

Not checked: I did not compile or run the tests. I did not check that api.github.com returns 401 for a compact JWE. The proof under C1 settles that. td is in the design's context, but an un-enrolled host has no tenant. I left it out of C2, and the spec owner decides it with the JWE header. The committed proptest-regressions/seal.txt is outside the task's layers, as the PR body says. It is not a design matter.

Conditions

  • C1: crates/bep/src/seal.rs seal() emits, and open() reads, a compact JWE. Its protected header carries typ: "gatehouse-sealed-secret+jwe", alg: "ECDH-ES" on P-256, and the bound context, so the context is the JWE AAD. Remove PREFIX (minseal1_), FORMAT_VERSION, KDF_INFO and the length-prefixed binary layout (encode_context, decode_context, put_bytes, take_bytes). ProxyKey and ProxyPublicKey become P-256 keys. In crates/bep/Cargo.toml, replace x25519-dalek with a P-256 ECDH crate. Update the seal.rs module doc to match. Then run sealed_value_rejected_by_github again on the JWE form (BEP-027).
  • C2: crates/bep/src/seal.rs Context binds the two context fields the design names that it does not carry: iat (seconds since the Unix epoch, set at seal) and kid (the fingerprint of the proxy public key that the value is sealed to). Put both in the protected header. open() returns OpenError::NotOpenable when kid is not this ProxyKey's fingerprint, before it decrypts.
  • C3: crates/bep/src/seal.rs seal() encrypts the member list {"members": [{"breadth": ..., ...}], "default_owner"?} as JSON, with exactly one member in v1. Do not encrypt a length-prefixed breadth followed by raw secret bytes. Member is one list entry: breadth, exp, and the credential or sign-in reference as a field. open() keeps the fail-closed refusal (OpenError::UnknownBreadth) when breadth is missing or unknown. It also refuses a list whose length is not one.
  • C4: crates/bep/src/seal.rs open() compares only box_id, host and module with the expected value, and names the field on a mismatch. It does not compare mode, host_set_version or expiry for equality. It returns the carried Context with the Member, so the redeemer can read them. Add Context::is_expired(now: u64) -> bool (now >= expiry). Expiry is a clock check and not an equality check. mode is for audit only. The redeemer admits an authority in the intersection of the carried host_set_version's set and the current set. Change the crates/bep/src/module.rs module doc (lines 3-7) so it says this. Do not say that old members stop opening. Make sealed_context_binds_box_host_module_version_expiry assert a tag failure when any carried field changes, and a named mismatch only for box_id, host and module.
  • C5: Remove DENY_SET, is_denied and the deny_set_covers_zones_and_their_subtrees_only test from crates/bep/src/module.rs. Their content (localhost, local, home.arpa, internal) is none of the categories that §6.10 gives the fixed deny set. The deny set lands with the BEP-013 task after the escalation in this ruling has an answer.

Needs a design decision

  • §6.10 line 849 defines the fixed deny set for registered upstreams: the tenant issuer, the BEP/EGW/relay endpoints, the registry or build cache, the node-plane baseline set, and every deep module's host set. Line 839 (and BEP-013) subtract 'the fixed deny set' from the host-generated root CA's name constraints, which include the module host sets. Applied as written, the subtraction removes the GitHub module's own names from the constraints. On an un-enrolled host there is also no tenant issuer and no registry name to put in it. Which DNS names make up the fixed deny set when it is subtracted from the un-enrolled root CA's name constraints? Does it include local namespaces such as localhost, .local, home.arpa and .internal (the box-local min.internal zone and cloud metadata names)?

Ruled at 0c010b4 against gominimal/arch@3dab1097cda1 by claude-opus-5-5; arch_rulings 13, job 246593f6-23d1-479f-bdb0-c17d474e73e9.