Expand description
v0.45 actor contracts (the actors-foundations slice).
An actor declaration is a nominal boundary contract (ADR Q1): a closed,
compiler-known authentication Scheme plus an optional sealed identity. A
handler consumes an actor on its by clause; the boundary verifies the
scheme and mints the identity before the body runs (two-phase, fail-closed —
ADR Q5/Q2).
This module holds the compiler-known parts: the closed scheme set, the
prelude actors, the per-protocol default actors, and the admissible-scheme
sets. Foundations admits only the two zero-crypto schemes (None,
Internal); Bearer/Signature are reserved-and-rejected.
Structs§
- Actor
Decl - P6.49 (design/tracks/the-ir.md §6b), following P6.27’s
ExprIdprecedent: every reader in this module —bearer_seam_for,oidc_seam_for,signature_seam_for,sum_members_for,caller_binder_for— is already parameterised by&HashMap<String, ActorDecl>.bynk-emitclones and forwards this table (project.rs’sEmitProjectCtx::actors,emitter/workers.rs/workers_entry.rs’s ownactorsparameters) without ever reading anActorDeclfield itself — P6.34 investigated and declined resolving it earlier, sincebynk-emit’s ownlower_actor_seam_irneeds the raw declarations to do its own resolution; this re-export changes the import path, not that data flow. An actor declaration (v0.45 §3.7). An actor is a nominal contract type describing an external party at a boundary — not a runnable entity. A handler consumes an actor on itsbyclause; the boundary verifies the declaredauthscheme and mints a sealed identity (name.identity). - Bearer
Seam - v0.47: the data the emitter needs to lower a Bearer verification seam for a
handler — the
bybinder (v0.50:Nonefor the binder-less verify-and- discard form), the signing-secret env name, and the identity type to construct from the JWTsubclaim. Resolved only for a handler whosebyclause names a local Bearer actor; the checker guarantees the secret is present and the identity is a string-constructible local type. - Call
Admission - I3 (#1971): which verified callers an
on callhandler admits. Every call is authenticated before it reaches a handler (wire_format); this is what the handler then admits, in itsbyclause’s order. A Bynk context is admitted byCaller(the default with noby) or a localInternalactor; a foreign caller only by its ownForeignactor, never byCaller. - Contract
- A resolved actor contract: its scheme and the identity it yields.
- Foreign
Caller - I3 (#1971): a declared foreign caller, as a
callhandler admits it: the actor’s name, which the caller sends asX-Bynk-Caller, and the secret the callee verifies its signature under. - Oidc
Seam - v0.151: the data the emitter needs to lower an OIDC/JWKS verification seam —
the
bybinder (orNonefor the verify-and-discard form), the public trust parameters (issuer,audience,jwksURL), and the identity type to construct from the verifiedsubclaim. Resolved only for a handler whosebyclause names a localOidcactor. Unlike Bearer/Signature, the seam carries no secret env name — the trust root is the provider’s published public key set (jwks). - Signature
Seam - v0.51: the data the emitter needs to lower a Signature verification seam —
the signing-secret env name, the signature header, and an optional
timestamp header + tolerance window for replay defence. Resolved only for a
handler whose
byclause names a local Signature actor. - Signed
Cookie Seam - #3386: the data the emitter needs to lower a
SignedCookieverification seam: thebybinder, the actor’s name (the cookie’saud), the cookie’s name, the signing and previous-key env names, thettlin seconds and the identity type minted from the verifiedsub. Resolved only for a handler whosebyclause names a single localSignedCookieactor (it is never a sum member or a refinement base); the checker guarantees the secret andttlare present and the identity is a string-constructible local type. - SumMember
- v0.52: one resolved member of a multi-actor sum — the seam the emitter tries
at that position in the first-wins order.
actor_nameis the variant tag the body matches on.
Enums§
- BadCredential
- A reserved bad-credential principal (
by Forged, …): it names no actor and takes no identity, and thesystemdriver presents a credential the seam must refuse. - Call
Site Principal - What a call-site principal (
by <Name>[(<identity>)]) is: an actor, the reserved no-credential principalNobody(#706), or a reserved bad credential. The one classification of those reserved names; the checker records it on the clause (crate::checker::Callee::Principal) and every reader, checker and emitter, reads it. - Call
SumMember - I3 (#1971): one member of a
callhandler’s actor sum. - Caller
Predicate - #3890: the closed predicate vocabulary for a refinement over
Caller(actor Admin = Caller where IsContext(shop.admin)).IsContextis a fixed, compiler-known check (capitalised, asMatchesandNonEmptyare), decided at compile time against the project’s call graph, and again at run time on the caller the signature proved. The combinators are the claim predicates’, so!IsContext(shop.legacy)reads as a deny-list. - Claim
Predicate - v0.53: the closed claim-predicate vocabulary for a refinement actor’s
whereclause (actor Admin = User where hasClaim("admin")). Claims are untyped JSON, so the predicate is a closed set —hasClaim/claimEqualscomposed with&&/||/!— checked against the verified JWT claims at the boundary. A general typed-claims expression surface is a later slice. - Identity
- The identity a verified actor yields (ADR Q2). In Foundations this is
()for trivial actors, the built-in sealedCallerIdfor the cross-contextInternalchannel (Q7, folded in), or a context-owned declared type. - Scheme
- The authentication scheme — a closed, compiler-known set (ADR Q1). Sealed now, openable later by widening this enum.
- SumMember
Seam - The verification a sum member contributes.
None(a catch-all such asVisitor) always resolves, so it terminates the order. - Witness
Value - The value a witness claim is signed with.
Constants§
- CALLER_
ID - The built-in sealed identity type for the cross-context calling principal.
- SENDER_
IDENTITY - The first-party record
Senderyields (#3328):{ address: String, dmarc: DmarcVerdict }, exported bybynk.cloudflare. - SIGNED_
COOKIE_ DEFAULT_ NAME - The cookie name a
SignedCookieactor issues and reads whencookieis not given.
Functions§
- bearer_
seam_ for - by_
clause_ is_ bearer - Resolve a handler’s Bearer seam, if its
byclause names a local Bearer actor — or a refinement of one (v0.53), following the refinement to its base for the scheme/secret/identity and carrying the authorisation predicate. ReturnsNonefor non-Bearer handlers (prelude actors are never Bearer) — those emit unchanged. #706: whether abyclause names a Bearer-secured actor (following a refinement to its base). The routes for whichby Nobodycan drive the auth seam to a401— an unsecured (Visitor/None) orSignature/Oidcroute has no Bearer seam the test driver knows how to leave unauthenticated, soby Nobodythere is rejected (bynk.test.nobody_needs_secured_route). The scheme check mirrorsbearer_seam_for. - by_
clause_ is_ oidc - #3052: whether a
byclause names a single localOidcactor (anOidcactor is never a sum member or a refinement base), so thesystemdriver can mint a token for it and its seam refuses a bad one. - by_
clause_ is_ signed_ cookie - #3386: whether a
byclause names a single localSignedCookieactor (never a sum member), so thesystemdriver can mint a session cookie for it and its seam refuses a bad one. - call_
admission_ for - I3 (#1971): what an
on callhandler admits.Noneoff the call path. - caller_
binder_ for - v0.54: the binder of a cross-context
on call … by c: Callerhandler that captures a liveCallerId(the calling context’s name, Q7).Noneunless the handler binds an identity whose contract isCallerId— i.e. theCallerprelude actor (the only source ofCallerId). A binder-lesson call(or one inheriting theCallerdefault) captures nothing and is unaffected. - caller_
refinement - #3890: the predicate of a refinement over the prelude
Calleractor, orNonefor any other actor (a malformed predicate reads asNonetoo: the checker reports it). - claim_
witness - The claims, by name, that satisfy
pred— the data behindclaim_witness_js, shared withbynk tokenso a hand-minted token carries exactly the claims thesystemharness signs.Nonewhen no claim set satisfies the predicate. - claim_
witness_ js - #2019: a JavaScript object literal of JWT claims that satisfies a
refinement actor’s predicate, for the
system-tier test driver to sign next tosubwhen a case acts as that refinement (by Admin("root")):hasClaim("admin")→{ "admin": true },claimEquals("role", "ops")→{ "role": "ops" }. The Worker’s seam then checks the predicate against the verified claims exactly as it would a real token’s. ATruthyneed signstrue: a boolean is never===a string, so it also lies outside every excluded value. An absent claim meetsFalsyandNotEquals, so those sign nothing. The search is exact over the closed vocabulary, soNonemeans no claim set satisfies the predicate (hasClaim("a") && !hasClaim("a")). - default_
actor - The default actor a handler inherits when it omits
by, by protocol (ADR Q5). HTTP and WebSocket have no safe default —byis required there — and neither hascall(#3891, superseding ADR 0082’sCallerdefault). - dotted_
name - A qualified name written as an expression:
shop.adminis a field access on an identifier. - foreign_
caller_ of - I3 (#1971): the foreign caller an actor declaration describes, if it is a
Foreign-scheme actor with asecret. - oidc_
seam_ for - Resolve a handler’s OIDC seam, if its
byclause names a single localOidcactor. ReturnsNonefor non-Oidc handlers, for a multi-actorbyclause (Oidc is single-actor this slice), and for a refinement (refinement over Oidc is a later slice) — those follow the existing seam paths. The checker guaranteesissuer/audience/jwksare present and the identity is a string-constructible local type. - parse_
caller_ predicate - Recognise the
Callerpredicate vocabulary in a refinementwhereexpression.Err(span)points at the first sub-expression outside it (forbynk.actor.refinement_predicate_unsupported). - parse_
claim_ predicate - Recognise the closed claim-predicate vocabulary in a refinement
whereexpression.Err(span)points at the first sub-expression outside the set (forbynk.actor.refinement_predicate_unsupported). - prelude_
actor - The prelude actors — compiler-known boundary contracts available without a
declaration. They back the per-protocol defaults and let public HTTP routes
write
by v: Visitorwithout ceremony. - route_
has_ bearer_ seam - #2864: whether a
byclause’s route has aBearerseam thesystemdriver can forge or expire a token for — a lone Bearer actor (or a refinement of one), or an actor sum with a Bearer member and no open member (sum_has_open_member), whose seam never refuses a bad token. - route_
is_ secured - #2155: whether a
byclause’s route has a credential seam thesystemdriver can leave out (by Nobody): a Bearer actor (or a refinement of one), anOidcactor (#3052), aSignatureactor, or an actor sum with such a member and no open member (sum_has_open_member). - route_
refuses_ bad_ token - Whether a route’s seam refuses a forged or expired credential as a
401: aBearerroute’s token, or (#3386) aSignedCookieroute’s cookie. - scheme_
admissible - Whether
schemeis admissible onprotocol(the admissible-scheme-per- protocol check). HTTP admitsNone(public routes) andBearer(anAuthorizationheader is an HTTP concept); the internal protocols (call/cron/queue) admitInternal.Signatureis still reserved. - sender_
binder_ for - #3328: the binder of a
from emailhandler that captures the mintedSenderIdentity—by s: Sender, orNonefor a binder-less handler or a handler that inherits the default (which captures nothing).Senderis a prelude actor (a local actor of the same name is its own), and is admissible only onfrom email, so the handler kind decides. - signature_
seam_ for - Resolve a handler’s Signature seam, if its
byclause names a local Signature actor. The checker guaranteessecretandheaderare present. - signature_
seam_ for_ by - #2135:
signature_seam_forfrom thebyclause alone — the seam of its primary actor, when that is a local Signature actor. - signature_
seam_ of_ route - #2155: the
Signatureseam abyclause’s route is signed with at thesystemtier — its one actor’s, or an actor sum’s firstSignaturemember’s (whatby Forged/by Stalesign as).Nonewhen it has none, and for a sum with an open member (sum_has_open_member), whose seam never refuses a bad signature. - signed_
cookie_ seam_ for - Resolve a handler’s
SignedCookieseam, if itsbyclause names a single localSignedCookieactor. - signed_
cookie_ seam_ of - The seam of one
SignedCookieactor declaration (shared by the handler resolver and by an actor’sissue/expiremembers). - sum_
has_ open_ member - #2155: whether an actor sum has an open member —
Visitor, or a declared actor with no auth scheme. The sum’s seam resolves a request with a missing or bad credential as that member, so it never answers401:by Nobody,by Forgedandby Stalehave nothing to drive there. - sum_
members_ for - v0.52: resolve a handler’s
byclause into ordered sum members, if it names more than one actor.Nonefor a single-actor handler (those keep the existing seam paths). The checker has already validated peer/scheme/ reachability rules; this lowers the verified members for emission.