ADR-0002: External Runner Seam, State-Machine Ownership, and OIDC App Authentication¶
- Status: Proposed
- Date: 2026-11-25
- Scope: External runner execution seam, CI DAG state-machine ownership, external CI integration tier, OIDC App authentication scope, and Git/Gate security hardening across Stravin Core, Stravin Review, Stravin Run, Stravin Gate, and Stravin Webhooks (
stravin-webhooks).
Context¶
ADR-0001 establishes Cilium (eBPF) sidecarless WireGuard/SPIFFE mTLS for internal service-to-service transport, NATS JetStream for internal async events, Stravin Webhooks (stravin-webhooks) for outbound customer HTTP delivery, and Temporal as the official durable workflow runtime for Stravin Run and Stravin Gate.
As Stravin opens Stravin Run to customer-hosted / externally hosted runners and third-party CI integrations, three architectural questions must be settled before Run, Core, Review, and Gate build against each other:
- Where is the external execution seam? Should external runners execute individual jobs leased from Run's Temporal DAG, or should Run delegate entire pipelines to external CI engines over outbound webhooks and a Checks API?
- Where does OIDC App authentication apply? Should first-party internal products (
Core,Review,Run,Index,Gate,Webhooks) also authenticate via OIDC App installations, or should OIDC Apps be scoped strictly to external/decoupled callers while internal RPCs stay on Cilium SPIFFE mTLS + short-lived internal service JWTs? - What security invariants protect Core and Gate once untrusted external compute enters the loop? External runners introduce SSRF/JWKS egress risks, long-lived token exposure, unrevocable presigned
bundle-uriURLs, cross-pool verdict poisoning (untrusted-prvs.protected/gate), and maliciousINFRA_ERRORself-assertion against Gate's merge queue.
Decision¶
We adopt a phased Hybrid Runner Seam paired with External-Only OIDC App Authentication and six non-negotiable security hardening invariants:
- Hybrid Runner Seam (Phased):
- Phase 1 (Primary — Job-Level Pull Lease): Stravin Run (Temporal) retains sole ownership of the CI pipeline DAG state machine—matrix fan-out/fan-in, heartbeats, retries, timeouts,
< 200 mscancellation,tree_oidverdict reuse/inheritance, andINFRA_ERRORclassification. External runners act as remote activity workers implementing a pull-based job-lease contract (lease,heartbeat,log-stream,report-result,cancel-poll) mapped 1:1 to Temporal Activities. - Phase 2 (Secondary / Degraded Tier — BYO-CI Pipeline-Level): External CI engines that own their own orchestrator (e.g., Buildkite, GitHub Actions) integrate via outbound
stravin-webhookstriggers plus anapp_id-bound Checks & Verdict API on the same external OIDC App control plane. This tier carries explicit limits: no unified step-level< 200 msrunner-kill guarantee (relying on Gate'stimeout_secondsand 30 s reconciliation backstop), no mixed hosted+external DAGs, and noINFRA_ERRORself-assertion.
- Phase 1 (Primary — Job-Level Pull Lease): Stravin Run (Temporal) retains sole ownership of the CI pipeline DAG state machine—matrix fan-out/fan-in, heartbeats, retries, timeouts,
- Auth Scope — OIDC Apps External-Only (Separate Trust Roots):
- Internal First-Party Products (
Core,Review,Run,Index,Gate,Webhooks,Auth,Notify): Remain on Cilium (eBPF) WireGuard/SPIFFE mTLS +CiliumNetworkPolicyallowlists + short-lived internal service JWTs (exp <= 5m, minted bystravin-authper ADR-0003) + mandatory constant-time app-leveltenant_idchecks. Internal product-to-product RPCs are never forced through external OIDC App installation flows. - External Runners, External CI & Third-Party Integrations: Authenticate via OIDC Apps hosted by
stravin-auth(ADR-0003) (App Registration + Tenant Installation + OIDC workload identity exchange -> short-lived, single-job/scoped tokens with zero static secrets). Both Phase 1 job-lease runners and Phase 2 Checks API CI apps share one external OIDC App control plane.
- Internal First-Party Products (
flowchart TB
subgraph InternalMesh["Internal Trust Root: Cilium eBPF SPIFFE mTLS + Service JWTs (exp <= 5m) + App tenant_id AuthZ"]
direction TB
Core["Stravin Core (stravin-edge / stravin-node)\nCommit-Pinned Tokens, jti Denylist, bundle-uri Gate"]
Review["Stravin Review\nPRs, Stacked Diffs, Annotations"]
Gate["Stravin Gate (Temporal)\nVerdict Tuple (+ app_id), Run-Only INFRA_ERROR"]
Run["Stravin Run (Temporal DAG Owner)\nFan-out/Fan-in, <200ms Cancel, tree_oid Reuse, Pool Isolation"]
Webhooks["Stravin Webhooks (stravin-webhooks)\nSigned Outbound HTTPS (Zero Embedded Git Tokens)"]
IAMProxy["IAM / STS Egress Proxy\n(SSRF-Hardened Safe Dialer for Dynamic IdP JWKS)"]
Run <-->|"Internal Service JWT + mTLS"| Core
Review <-->|"Internal Service JWT + mTLS"| Run
Gate <-->|"Internal Service JWT + mTLS"| Run
Run -.->|"NATS JetStream"| Webhooks
end
subgraph ExternalPlane["External Trust Root: OIDC Apps (Zero Static Secrets, aud/jti Pinned)"]
direction TB
OIDC["External OIDC App Control Plane\n(App Registration + Tenant Installation + Token Exchange)"]
Phase1["Phase 1: External Job-Lease Runners\n(Isolated Pools: untrusted-pr vs protected/gate)\nPull: lease / heartbeat / logs / result / cancel-poll"]
Phase2["Phase 2: BYO-CI External Engines (Degraded Tier)\n(Own DAG Orchestrator, No <200ms Cancel, No INFRA_ERROR)"]
IdP["External OIDC IdP\n(Pinned Keys or Dynamic JWKS)"]
end
Phase1 -->|"1. OIDC Assertion Exchange"| OIDC
Phase2 -->|"1. JIT OIDC Assertion Exchange"| OIDC
OIDC -.->|"Static Pinned Keys OR Proxy Refresh"| IAMProxy
IAMProxy -.->|"Safe-Dialer HTTPS"| IdP
Phase1 <-->|"2. 6-Tuple Job-Lease API + Run-Minted log_stream_url"| Run
Phase1 -->|"3. git:read (commit_oid-pinned, TTL <= 120s)"| Core
Webhooks -->|"Webhook Trigger (No Tokens)"| Phase2
Phase2 -->|"git:read (commit_oid-pinned, TTL <= 120s)"| Core
Phase2 -->|"app_id-Bound Checks API (check_name_prefix Allowlist)"| Run
Phase 1: Primary Job-Lease Seam¶
- Temporal Retains Sole DAG Ownership: Stravin Run executes every workflow DAG as a Temporal Workflow. Each job (including matrix shards and speculative Gate checks) maps 1:1 to a Temporal Activity whose worker may be a first-party hosted sandbox or an externally leased runner.
- Pull-Based Lease Protocol: External runners hold zero inbound ports. They authenticate via their pool-scoped OIDC App installation and long-poll Run's external ingress:
POST /v1/runner/leases— Claim a matching job for the runner's authorized(tenant_id, runner_pool). Returns a 6-tuple-bound lease token, job spec,commit_oid, Run-mintedlog_stream_url, and initialcommit_oid-pinnedgit:readtoken (TTL <= 120s).POST /v1/runner/leases/{lease_id}/heartbeat— Extends activity liveness, returns immediate cancel directives (cancel-poll), and refreshes the short-livedgit:readtoken only while the lease remains active.POST /v1/runner/leases/{lease_id}/result— Idempotently reports step status, annotations (capped at50/batch,1,000/run), and conclusion.
- Preserved Platform SLAs: Because Run owns the activity lease and server-side token revocation, Gate retains
< 200 mscancel acknowledgment, per-check fail-fast eviction, Review stacked-difftree_oidinheritance, and Run-managedINFRA_ERRORretries.
Phase 2: Secondary BYO-CI Seam (Degraded Tier)¶
- Trigger & Callback Flow: Teams bringing their own CI orchestrator install an OIDC App, subscribe to platform events (
core.ref.updated,review.pr.opened_or_updated,gate.queue.updated) viastravin-webhooks, exchange their OIDC workload assertion just-in-time for acommit_oid-pinnedgit:readtoken, run their own pipeline, and post terminal conclusions back to Run's publicapp_id-bound Checks & Verdict API. - Explicit Degraded-Tier Limits:
- No unified step-level
< 200 msrunner-kill guarantee; Gate falls back totimeout_secondsand its 30 s reconciliation backstop. - No mixed hosted+external DAGs within a single Run workflow.
- Cannot self-assert
INFRA_ERRORto trigger Gate requeues or queue pauses. - External
details_urlmust behttps://on the registered app's origin; Run never accepts runner-suppliedlog_stream_urlendpoints.
- No unified step-level
Security Hardening Invariants¶
All six invariants are mandatory across Core, Review, Run, Gate, and Webhooks:
- No Direct JWKS Egress from Run (SSRF Isolation):
stravin-webhooksremains the sole general outbound webhook egress service (ADR-0001).- Stravin Run MUST never fetch arbitrary tenant-supplied OIDC JWKS URLs directly. App registrations MUST use pre-pinned public keys / static JWKS, OR route dynamic IdP JWKS refreshes exclusively through a dedicated IAM/STS egress proxy enforcing the same safe-dialer private-CIDR, loopback, link-local (
169.254.169.254), and DNS-rebinding blocks asstravin-webhooks. - When jobs need credentials for external clouds (AWS, GCP, Azure), use Stravin-issued OIDC tokens outbound (zero outbound egress required from Run).
- Short-Lived,
commit_oid-Pinnedgit:readTokens & Active Revocation:- External job-lease and Checks API checkouts use
commit_oid-pinnedgit:readtokens withTTL <= 120s(matching exact-OID fetches and Core's 120 s checkout timeout), refreshed only through Run while the lease/job is active. - Never embed Git tokens or OIDC assertions in outbound
stravin-webhookspayloads. External CI engines exchange their OIDC assertion just-in-time immediately before checkout. - External runners default to
git:readonly and receive zero AWS IAM credentials.git:writeis permitted exclusively on explicitly configured protected release/tag pools with narrowref_globsand active server-sidejtirevocation atstravin-edge(Valkeyjtidenylist) on lease termination or cancel. - All external OIDC App tokens enforce strict
audpinning, shortexp, andjtireplay protection.
- External job-lease and Checks API checkouts use
- Strict Pool Isolation, 6-Tuple Lease Binding & Partitioned
tree_oidReuse:- Isolate
untrusted-prvs.protected/gaterunner_pools via pool-scoped OIDC claims so untrusted PR workloads can never lease Gate or release jobs. - Bind every job-lease token to the 6-tuple
(tenant_id, repo_id, runner_pool, job_id, attempt_id, runner_instance_id)and revoke server-side on< 200 mscancel orINFRA_ERRORretry. - Partition
tree_oidverdict reuse by(tenant_id, repo_id, tree_oid, check_name, app_id, runner_pool, policy_version)sountrusted-prpools or lower-trust external apps can never poison or satisfy protectedgateverdicts.
- Isolate
- Gate Verdict Binding & External Callback Hardening:
- Bind every Gate verdict to the 6-tuple
(tenant_id, repo_id, tree_oid, commit_oid, policy_version, app_id). - Bind each Phase 2 Checks API App installation to an explicit
(tenant_id, repo_id, check_name_prefix)allowlist matching an activebatch_run_id. - Run mints
log_stream_urltokens (never accept runner-supplied log URLs); restrict externaldetails_urltohttps://on the registered app's origin; enforce50/batchand1,000/runannotation caps and constant-timetenant_idchecks at the external ingress edge.
- Bind every Gate verdict to the 6-tuple
bundle-uriGating (git:bundle:read):- Require an explicit
git:bundle:readscope forbundle-uricapability advertisement and presigned S3 URL issuance—auto-granted to Cilium-attested internal pools and opt-in for authorized external OIDC leases/Apps. - Cap presigned S3 bundle URL TTL to
min(token_remaining_ttl, 120s). - Suppress
bundle-uriadvertisement completely for externalcommit_oid-pinned tokens lackinggit:bundle:read, preventing unrevocable S3 URLs from bypassingstravin-edgerate limits or exposing the full default-branchlatest.bundle.
- Require an explicit
INFRA_ERRORBoundary (Strictly Run-Only):INFRA_ERRORclassification is strictly Run-only (available to hosted and Phase 1 Run-managed runners where Run observes infrastructure/lease failures directly).- Phase 2 external Checks API callers can never self-assert
INFRA_ERRORto trigger automated Gate front-of-queue requeues or merge-queue pauses. Transient external CI failures map to a non-retrying conclusion (e.g.,external_infra_errororfailure) since external CI engines already own their own retry loops before posting terminal conclusions.
Alternatives Considered¶
| Alternative | Summary | Why Rejected |
|---|---|---|
| Pipeline-only Webhook + Checks API (no Job-Lease) | Replace Run's Temporal DAG with stravin-webhooks triggers and external Checks API callbacks for all external compute. |
stravin-webhooks has a 10 s per-attempt timeout + exponential backoff, breaking Gate's < 200 ms cancel SLA, per-check fail-fast eviction, Review stacked-diff tree_oid inheritance, and non-blame INFRA_ERROR requeue. |
| Job-Lease only (no Phase 2 Checks API) | Force every customer with existing Buildkite or GitHub Actions pipelines to rewrite pipelines as Stravin Run workflows. | Blocks adoption for teams with large existing CI orchestrators; adding a degraded-tier Checks API adapter on the same OIDC App control plane is purely additive and preserves Run's idempotent boundary. |
| Unified OIDC Apps for internal + external services | Force internal Core, Review, Run, Index, Gate, and Webhooks RPCs through OIDC App registrations and token exchanges. |
Collapses the internal/external trust boundary, adds unnecessary token-exchange hops and registration sprawl, and still requires the exact same app-level constant-time tenant_id check already paired with Cilium SPIFFE mTLS + exp <= 5m service JWTs. |
Allow bundle-uri on any git:read token |
Advertise presigned S3 latest.bundle URLs to all external runners holding git:read. |
Presigned S3 URLs bypass stravin-edge rate limits, cannot be revoked on < 200 ms cancel, and expose the full default-branch bundle beyond the pinned commit_oid. |
Allow capped external INFRA_ERROR self-assertion |
Permit external Checks API apps to report INFRA_ERROR with a per-app_id requeue cap. |
Even a capped external INFRA_ERROR lets a flapping or compromised third-party app amplify merge-queue retries and pollute Run's infra SLOs; external CI engines already control their own retries. |
Consequences¶
Positive¶
- Preserves Temporal DAG & Gate SLAs: Phase 1 external runners participate in
< 200 mscancellation, fail-fast eviction, stacked-difftree_oidinheritance, andINFRA_ERRORrecovery without duplicating orchestrator state. - Clean trust-root separation: Internal products keep zero-overhead Cilium SPIFFE mTLS +
exp <= 5mservice JWTs, while all external callers share one zero-static-secret OIDC App control plane. - Defense-in-depth against untrusted compute: Pool isolation, 6-tuple lease binding,
commit_oid-pinned<= 120stokens,git:bundle:readgating, partitionedtree_oidreuse, and Run-onlyINFRA_ERRORcontain compromised runners and flapping third-party apps. - Additive BYO-CI path: Phase 2 Checks API layers cleanly onto the same OIDC App control plane without weakening Phase 1 or Gate guarantees.
Negative / Risks¶
- Large monorepo clones
> 120son external runners withoutgit:bundle:read: External runners that cannot usebundle-urimust refresh theircommit_oid-pinned token via Run's active-lease refresh endpoint mid-clone; the runner's Git credential helper must handle seamless refresh without aborting packfile transfer. - Active
jtirevocation state onstravin-edge: Supportinggit:writeon protected external release pools requires a low-latency revocation store (e.g., Valkeyjtidenylist) instravin-edge, adding a small hot-path lookup strictly for external write tokens. - Dedicated IAM/STS JWKS egress component: Tenants using dynamic external IdPs (rather than pinned public keys / static JWKS) require standing up the SSRF-hardened IAM/STS egress proxy before dynamic OIDC federation can be enabled.
Undo / Rollback Path¶
- Reverting from Hybrid to Job-Lease-Only: Disable or omit the Phase 2 Checks API adapter endpoints and
app_idexternal-verdict route in Run; Core, Review, Gate, andstravin-webhookscontracts remain completely intact. - Relaxing
bundle-uriorINFRA_ERRORgates: Both are additive policy checks insidestravin-edge(git:bundle:readclaim check) andstravin-run(Checks API conclusion mapping)—changing either requires a single policy/schema update without breaking wire compatibility (N / N-1additive evolution per Interface Conventions). - Adopting internal OIDC later (if ever desired): Because internal service JWTs (
iss,sub,aud,tenant_id,scopes,exp <= 5m) already use standard signed JWT claims, internal services can adopt an internal OIDC issuer later without changing handler authorization logic.
Related Documents¶
- ADR-0001: Platform Transport, Internal Events, External Webhooks, and Durable Workflows — Cilium eBPF mesh, NATS JetStream,
stravin-webhooks, and Temporal workflow pillars. - ADR-0003: Platform IAM, Authentication, STS, and Pluggable SSO Seam (
stravin-auth) — Formally owns the external OIDC App control plane, STS token exchange, Valkeyjtideny-list, and SSRF-hardened JWKS egress proxy defined in this ADR. - Product-Stack Interface Overview & Matrix — Shared auth boundaries, scoped Git token rules, and canonical identifiers.
- Platform Products ⟷ Stravin Auth — Full meet-in-the-middle contract for
stravin-auth(JWKS, STS, SCIM 2.0,STRAVIN_AUTH). - Core ⟷ Run —
commit_oid-pinned<= 120stokens,git:bundle:readgating, andjtirevocation. - Review ⟷ Run — Phase 1 job-lease vs. Phase 2 Checks API, pool isolation, and external callback hardening.
- Run ⟷ Gate — Gate verdict tuple with
app_id, partitionedtree_oidreuse, and Run-onlyINFRA_ERROR. - External Webhooks — Phase 2 BYO-CI trigger delivery without embedded Git tokens and SSRF-hardened egress boundaries.