pub struct WorkflowService { /* private fields */ }Expand description
WorkflowService handles workflow orchestration
Discovers workflows from repositories, subscribes to events, and routes
job execution through WorkflowRunner (#527): jobs requesting
isolation via runs_on: are scheduled onto a sandbox through the #525 P2
admission engine (SandboxPool::acquire, see workflow::scheduler);
others run in-process over the VFS/Tcl bridge. There is no WorkerService
dependency here — WorkflowRunner talks to SandboxPool directly.
Implementations§
Source§impl WorkflowService
impl WorkflowService
Sourcepub fn new(transport: TransportConfig, signing_key: SigningKey) -> Self
pub fn new(transport: TransportConfig, signing_key: SigningKey) -> Self
Create a new WorkflowService
§Arguments
transport- Transport configuration for service bindingsigning_key- Signing key for message authentication
Sourcepub async fn register_repo_path(
&self,
repo_id: impl Into<String>,
path: PathBuf,
)
pub async fn register_repo_path( &self, repo_id: impl Into<String>, path: PathBuf, )
Register the filesystem root for a repo_id.
Once registered, scan_repo(repo_id) will glob
<root>/.github/workflows/*.yml to discover workflows.
Sourcepub async fn set_repo_mode(&self, repo_id: &str, mode: ParseMode)
pub async fn set_repo_mode(&self, repo_id: &str, mode: ParseMode)
Set the per-repo parse mode (#1432).
Acquires the per-repo serialization lock so that mode changes are
atomic with concurrent rescans. A gate that loads a repo in strict
mode records it here so that later rescans retain strict (the default
for an unregistered repo is [ParseMode::Legacy]). Typically called
by
GitHubActionsAdapter::load_repo_with.
Sourcepub fn set_namespace(&mut self, ns: Arc<Namespace>)
pub fn set_namespace(&mut self, ns: Arc<Namespace>)
Set the VFS namespace for workflow execution.
This creates a WorkflowRunner that resolves actions through /bin/
and evaluates scripts via TclShell, using default
crate::config::WorkflowConfig timeouts/concurrency and no job
scheduler (every job runs in-proc — see Self::set_job_scheduler).
Sourcepub fn set_namespace_with_config(
&mut self,
ns: Arc<Namespace>,
config: &WorkflowConfig,
)
pub fn set_namespace_with_config( &mut self, ns: Arc<Namespace>, config: &WorkflowConfig, )
Like Self::set_namespace, but honors config’s
max_concurrent_runs / job_timeout_secs / step_timeout_secs
(#521) instead of defaults.
Sourcepub fn set_job_scheduler(&mut self, scheduler: Arc<JobScheduler>)
pub fn set_job_scheduler(&mut self, scheduler: Arc<JobScheduler>)
Attach a JobScheduler (#527) so jobs whose runs_on: requests
isolation are placed onto a real sandbox through the #525 P2
admission engine, instead of always running in-proc. Must be called
after set_namespace/set_namespace_with_config; a no-op (with a
warning) if no runner has been configured yet.
Set the authorization callback for policy checks.
Sourcepub fn set_expected_audience(&mut self, audience: String)
pub fn set_expected_audience(&mut self, audience: String)
Set the expected JWT audience for envelope-verification-time validation
(mirrors WorkerService::set_expected_audience). Fed by the factory from
the OAuth issuer URL so JWT-authenticated IPC/QUIC requests are accepted
before the per-request policy check.
Sourcepub fn set_jwt_key_source(&mut self, src: Arc<dyn JwtKeySource>)
pub fn set_jwt_key_source(&mut self, src: Arc<dyn JwtKeySource>)
Set the JWT verification key source (local + federated). Fed by the factory from the cluster key source.
Inject a live MCP relay authorizer so accept_delegated_bearer
consults current MCP-scope authorization at call time (not a frozen
snapshot — retired keys are rejected, new keys accepted after factory
start). The factory typically passes a closure over the global trust
store’s is_authorized(key, "mcp"). None (never called) ⇒ fail-closed.
Sourcepub async fn initialize(&self) -> Result<()>
pub async fn initialize(&self) -> Result<()>
Initialize the service: scan all registered repos and register their workflows.
Sourcepub async fn start(self: Arc<Self>) -> Result<()>
pub async fn start(self: Arc<Self>) -> Result<()>
Start the event subscription loop
Subscribes to worker events and routes them to registered handlers.
This spawns a background task that runs until stop() is called.
Sourcepub async fn register_handler(&self, handler: Box<dyn EventHandler>)
pub async fn register_handler(&self, handler: Box<dyn EventHandler>)
Register an event handler
Sourcepub async fn list_workflows(&self) -> Result<Vec<WorkflowInfo>>
pub async fn list_workflows(&self) -> Result<Vec<WorkflowInfo>>
List registered workflows (returns wire-format types directly)
Sourcepub async fn rescan_repo(&self, repo_id: &str) -> Result<()>
pub async fn rescan_repo(&self, repo_id: &str) -> Result<()>
Rescan a repository for workflow changes (generic, non-persisting).
Resolves the per-repo parse mode and rescans in that mode, but does
not write the mode back to the store. This is the entry point used
by the event-triggered rescan path (HandlerResult::Rescan) and
initialize. Because it never persists, a concurrent generic rescan
that read a stale [ParseMode::Legacy] before a gate selected strict
cannot overwrite the newer strict selection (#1432 race fix): only the
explicit boundaries (Self::rescan_repo_with, load_repo_with)
write the mode.
Sourcepub async fn rescan_repo_with(
&self,
repo_id: &str,
mode: ParseMode,
) -> Result<()>
pub async fn rescan_repo_with( &self, repo_id: &str, mode: ParseMode, ) -> Result<()>
Rescan a repository with an explicit [ParseMode] (#1432 boundary).
Persists the mode per-repo (via Self::set_repo_mode) so that
later event-triggered rescans through the generic Self::rescan_repo
retain it. Both rescan_repo and this method hold the per-repo
serialization lock from mode decision through registry commit, making
the scan→commit window atomic per repo (#1432 race fix: a stale Legacy
scan cannot yield between its mode check and commit while a Strict
selection lands in between).
Sourcepub async fn start_adapter(
self: &Arc<Self>,
adapter: Box<dyn SubscriberAdapter>,
) -> CancellationToken
pub async fn start_adapter( self: &Arc<Self>, adapter: Box<dyn SubscriberAdapter>, ) -> CancellationToken
Start a subscriber adapter. Returns a CancellationToken to stop it.
The adapter runs in a background task that receives events and dispatches workflows. Cancel the returned token to stop the adapter.
Trait Implementations§
Source§impl RequestService for WorkflowService
impl RequestService for WorkflowService
Source§fn accept_delegated_bearer(&self, signer_pubkey: &[u8; 32]) -> bool
fn accept_delegated_bearer(&self, signer_pubkey: &[u8; 32]) -> bool
Accept delegated-bearer requests by consulting the live MCP relay
authorizer (#989 review). verify_claims calls this before policy; the
default false rejects all relayed caller tokens. We delegate to the
injected authorizer (which checks current MCP-scope authorization) —
fail-closed when no authorizer is set.
Source§fn decode_request_body(&self, signed_body: &[u8]) -> Result<DecodedRequestBody>
fn decode_request_body(&self, signed_body: &[u8]) -> Result<DecodedRequestBody>
Source§fn handle_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 EnvelopeContext,
body: &'life2 DecodedRequestBody,
) -> Pin<Box<dyn Future<Output = AnyhowResult<(Vec<u8>, Option<Continuation>)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 EnvelopeContext,
body: &'life2 DecodedRequestBody,
) -> Pin<Box<dyn Future<Output = AnyhowResult<(Vec<u8>, Option<Continuation>)>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn transport(&self) -> &TransportConfig
fn transport(&self) -> &TransportConfig
Source§fn signing_key(&self) -> SigningKey
fn signing_key(&self) -> SigningKey
Source§fn expected_audience(&self) -> Option<&str>
fn expected_audience(&self) -> Option<&str>
Source§fn jwt_key_source(&self) -> Option<Arc<dyn JwtKeySource>>
fn jwt_key_source(&self) -> Option<Arc<dyn JwtKeySource>>
Source§fn producer_reach_config_handle(
&self,
) -> Option<Arc<RwLock<RawRwLock, ProducerReachConfig>>>
fn producer_reach_config_handle( &self, ) -> Option<Arc<RwLock<RawRwLock, ProducerReachConfig>>>
Source§fn moq_origin_handle(
&self,
) -> Option<Arc<RwLock<RawRwLock, Option<MoqStreamOrigin>>>>
fn moq_origin_handle( &self, ) -> Option<Arc<RwLock<RawRwLock, Option<MoqStreamOrigin>>>>
Source§fn pq_signing_key(&self) -> Option<SigningKey<MlDsa65>>
fn pq_signing_key(&self) -> Option<SigningKey<MlDsa65>>
None makes process_request fail closed
before dispatch; it never selects an EdDSA-only response. The matching ML-DSA-65 public key
must be anchored in the client’s PQ trust store for Hybrid verification
to succeed (peer attestation). Read moreSource§fn verifying_key(&self) -> VerifyingKey
fn verifying_key(&self) -> VerifyingKey
Source§fn delegated_user_audience(
&self,
_signer_pubkey: &[u8; 32],
_untrusted_aud: Option<&str>,
) -> Option<&str>
fn delegated_user_audience( &self, _signer_pubkey: &[u8; 32], _untrusted_aud: Option<&str>, ) -> Option<&str>
expected_audience instead.Source§fn accept_delegated_resource_leaf(
&self,
_ctx: &EnvelopeContext,
_body: &DecodedRequestBody,
) -> bool
fn accept_delegated_resource_leaf( &self, _ctx: &EnvelopeContext, _body: &DecodedRequestBody, ) -> bool
Source§fn require_cnf_binding(&self) -> bool
fn require_cnf_binding(&self) -> bool
cnf key binding (jwk or jkt). Read moreSource§fn credential_revocation_store(&self) -> Option<&dyn CredentialRevocationStore>
fn credential_revocation_store(&self) -> Option<&dyn CredentialRevocationStore>
Source§fn jwt_verify_policy(&self) -> CryptoPolicy
fn jwt_verify_policy(&self) -> CryptoPolicy
Source§fn resolve_key_subject(&self, signer_pubkey: &[u8; 32]) -> Option<Subject>
fn resolve_key_subject(&self, signer_pubkey: &[u8; 32]) -> Option<Subject>
Source§fn cache_key_binding(
&self,
_verifying_key: VerifyingKey,
_subject: &str,
_jwt: &str,
_expires_at: i64,
)
fn cache_key_binding( &self, _verifying_key: VerifyingKey, _subject: &str, _jwt: &str, _expires_at: i64, )
Source§fn accept_deferred_federate_credential(&self) -> bool
fn accept_deferred_federate_credential(&self) -> bool
Source§fn admit_deferred_federate_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_body: &'life2 DecodedRequestBody,
_proof: &'life3 ParsedProof,
) -> Pin<Box<dyn Future<Output = Result<(VerifiedProof, [u8; 32], String, String, ProofReplayKey, u64), Error>> + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn admit_deferred_federate_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_body: &'life2 DecodedRequestBody,
_proof: &'life3 ParsedProof,
) -> Pin<Box<dyn Future<Output = Result<(VerifiedProof, [u8; 32], String, String, ProofReplayKey, u64), Error>> + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
commit_deferred_federate_request only after those gates pass.Source§fn commit_deferred_federate_request<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_resource: &'life2 str,
_operation: &'life3 str,
_replay_key: &'life4 ProofReplayKey,
_replay_expiry: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn commit_deferred_federate_request<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_resource: &'life2 str,
_operation: &'life3 str,
_replay_key: &'life4 ProofReplayKey,
_replay_expiry: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Source§fn verify_internal_work_bearer<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_token: &'life2 str,
_protected: &'life3 ProtectedHeader,
) -> Pin<Box<dyn Future<Output = Result<InternalWorkClaims, Error>> + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn verify_internal_work_bearer<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_token: &'life2 str,
_protected: &'life3 ProtectedHeader,
) -> Pin<Box<dyn Future<Output = Result<InternalWorkClaims, Error>> + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
iw+jwt internal execution work order presented as the
direct JWT (single-service Model→Inference boundary, user-approved D5). Read moreSource§impl WorkflowHandler for WorkflowService
impl WorkflowHandler for WorkflowService
Source§fn handle_scan_repo<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
repo_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_scan_repo<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
repo_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
scanRepo request.Source§fn handle_register<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
data: &'life2 WorkflowDefWire,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_register<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
data: &'life2 WorkflowDefWire,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
register request.Source§fn handle_list<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_list<'life0, 'life1, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
list request.Source§fn handle_dispatch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 EnvelopeContext,
_request_id: u64,
request: &'life2 DispatchRequest,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_dispatch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 EnvelopeContext,
_request_id: u64,
request: &'life2 DispatchRequest,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
dispatch request.Source§fn handle_subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
request: &'life2 SubscribeRequest,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
request: &'life2 SubscribeRequest,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
subscribe request.Source§fn handle_unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
sub_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
sub_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
unsubscribe request.Source§fn handle_get_run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
run_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_get_run<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
run_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
getRun request.Source§fn handle_list_runs<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
workflow_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle_list_runs<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 EnvelopeContext,
_request_id: u64,
workflow_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = AnyhowResult<WorkflowResponseVariant>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
listRuns request.Auto Trait Implementations§
impl !Freeze for WorkflowService
impl !RefUnwindSafe for WorkflowService
impl Send for WorkflowService
impl Sync for WorkflowService
impl Unpin for WorkflowService
impl UnsafeUnpin for WorkflowService
impl !UnwindSafe for WorkflowService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more