Admin Control Plane Workflow Monitors
Internal Admin Endpoints
Admin Control Plane Workflow Monitors
Internal-only admin contract that lets the Cloudflare control plane load due workflow monitors and execute monitor ticks through the existing shared workflow facade.
POST
Admin Control Plane Workflow Monitors
These routes are the first concrete migration seam from
Load runnable monitor rows from the canonical workflow-monitor repository.
Request body:
Response:
Notes:
Execute one monitor tick through
Notes:
Validate a terminal execution ref and forward it into the Cloudflare-owned
Response:
Notes:
Forward a centralized trigger-match event directly into the Cloudflare-owned
monitor workflow lane without going through
Response:
Notes:
Replay a stale or orphaned monitor wait through the Cloudflare-owned runtime.
Request body:
Response:
Notes:
apps/engine
workflow-monitor orchestration into Cloudflare Workflows.
The ownership split is:
- Cloudflare
agent-control-planeowns due scanning cadence and durable workflow instances platform-apiowns the thin authenticated admin surfaceWorkflowsFacade.tickMonitor(...)remains the deterministic shared mutation path
Scope
- Internal-only
- Protected by
ADMIN_AUTH_SECRET_TOKEN - Intended for
apps/agent-control-plane, not browser traffic
Endpoints
POST /v1/admin/control-plane/workflow-monitors/due
Load runnable monitor rows from the canonical workflow-monitor repository.
Request body:
requestIdis the stable idempotency key Cloudflare should preserve when creating its own workflow instanceworkerIdis the stable worker identity passed through totickMonitor(...)- due selection stays authoritative in the shared workflow repository for now
POST /v1/admin/control-plane/workflow-monitors/tick
Execute one monitor tick through WorkflowsFacade.tickMonitor(...).
Request body:
triggerEvent is optional. The current accepted kinds are:
market_pricemarket_candlesapproval_pending_countaccount_buying_power_usdaccount_cash_usdportfolio_nav_usdportfolio_cash_pctportfolio_drift_from_targetportfolio_concentrationportfolio_held_asset_performanceportfolio_held_asset_metrics
userIdis resolved from the canonical linked wallet address when available- Cloudflare uses
userIdpluslinkedPortfolioIds[0]to mirror the monitor tick intoUserAgent/PortfolioAgent - this route is intentionally thin; it does not invent a new monitor execution model
POST /v1/admin/control-plane/workflow-monitors/notify-execution
Validate a terminal execution ref and forward it into the Cloudflare-owned
enqueue-tick seam.
Request body:
- this route is the event-driven companion to
dueplustick - it can resolve the owning workflow from canonical
workflow_execution_refsusingoperationId,runId,executionRequestId, andeventId - it also resolves the primary linked
portfolioIdso the Cloudflare worker can look up an already waiting monitor session onPortfolioAgent - if no execution ref matches, it returns
202withenqueued: falseinstead of treating the callback as an error - it forwards into
POST /api/workflow-monitors/enqueue-tickon the Cloudflare worker instead of mutating workflow state locally
POST /v1/admin/control-plane/workflow-monitors/notify-trigger-match
Forward a centralized trigger-match event directly into the Cloudflare-owned
monitor workflow lane without going through due.
Request body:
- this is the first explicit ingress for a future centralized trigger matcher
platform-apistill validates the workflow and owner viaWorkflowsFacade.get(...)- the optional
triggerEventpayload now supports authoritative fact packets formarket_price,market_candles,approval_pending_count,account_buying_power_usd,account_cash_usd,portfolio_nav_usd,portfolio_cash_pct,portfolio_drift_from_target,portfolio_concentration,portfolio_held_asset_performance, andportfolio_held_asset_metrics - it resolves the primary linked
portfolioIdso Cloudflare can mirror the resulting monitor workflow state intoPortfolioAgent/UserAgent - today it forwards into the same
POST /api/workflow-monitors/enqueue-tickseam usingreason: "trigger_match" - this is intentionally narrower than the future global matcher fabric; it is just the authenticated trigger-delivery seam
POST /v1/admin/control-plane/workflow-monitors/recover
Replay a stale or orphaned monitor wait through the Cloudflare-owned runtime.
Request body:
- this is an operator/admin replay surface, not a normal callback path
- Cloudflare recovery is intentionally narrow and safe:
- replay an active
execution_completedortrigger_matchedwait on the same workflow instance when possible - start a fresh authoritative tick only when no active instance is registered
- fail closed when the active workflow is only sleeping on time instead of waiting on an event
- replay an active
- optional
triggerEventfact packets can be supplied when recovery should replay a matcher-driven wake with authoritative dependency data
Runtime Behavior
The current flow is:- Cloudflare calls
due - Cloudflare creates
WorkflowMonitorTickWorkflowinstances with the returned ids - Each Cloudflare workflow calls
tick platform-apidelegates toWorkflowsFacade.tickMonitor(...)- Cloudflare mirrors the resulting state into durable user/portfolio actors
- engine persists a terminal execution update with canonical execution refs
- engine calls
notify-execution platform-apiresolves the owning workflow from canonical execution refsplatform-apiforwards into Cloudflareenqueue-tickwith the linkedportfolioId- Cloudflare tries to route the callback directly into the active waiting
WorkflowMonitorTickWorkflowsession viasendEvent("execution_completed") - if no active waiting session is registered, Cloudflare falls back to the
previous
create -> tickpath - the workflow calls
tick - Cloudflare mirrors the resulting state into durable user/portfolio actors
- a centralized matcher or other authoritative producer detects a match
- it calls
notify-trigger-match platform-apivalidates the workflow and ownerplatform-apiforwards into Cloudflareenqueue-tickwithreason: "trigger_match"- Cloudflare starts the durable
WorkflowMonitorTickWorkflowwithout waiting for a global due scan - the workflow calls
tick - Cloudflare mirrors the resulting state into durable user/portfolio actors