ADR-0023 — Workflow Execution Substrate (Temporal, adopted now, behind the Dispatcher seam — retired by Amendment 1, 2026-11-13)
- Status: Accepted (founder 2026-07-15; Ashik ratifies Phase-1 production deployment shape only) — amended 2026-11-13 (Amendment 1,
upsquad-ai/upsquad-core#4420): Temporal is retired as the workflow execution substrate; no migration of existing definitions; the Claude-native orchestrator on Postgres is the only engine. The substrate decision below is superseded; the moat split, the n8n ruling and the alternatives record stand. See Amendment 1. - Date: 2026-07-11 (drafted); accepted 2026-07-15
- Deciders: Vaisakh (founder — flipped the default 2026-07-11, ratified adopt-now 2026-07-15), Ashik (runtime ops — owns the Phase-1 production deployment-shape call), Principal Architect (technical validation)
- Numbering: ADR-0023, not 0022 — see the footnote at the end of this document.1
- Related:
- ADR-0015 — A2A communication model; establishes the Temporal-shaped dispatcher interface (
internal/bus/dispatcher.go) this decision sits behind. This ADR exercises the swap ADR-0015 pre-declared. - ADR-0013 — abstraction principle; the Temporal Cloud option is only admissible because it sits behind the Dispatcher/coordinator seam (open primitive we call, not a cloud service woven into the hot path).
- ADR-0012 — agnostic middleware positioning; the moat (governance choke-point + hash-chained audit) must remain ours regardless of substrate.
- PRD #623 (Temporal Adoption — Durable Agent Workflows) — this ADR resolves its open timing question: adopt now, not at a deferred tripwire.
- PRD #1783 ("Workflows — governed DAG execution on one engine") — the Workflow PRD this ADR is the written buy-vs-build ruling for.
- Build breakdown: WF issues #1791–#1800 — the adopt-now implementation, incl. #1791 (WF-05,
go.temporal.io/sdkdependency — cited by Appendix A) and #1792 (WF-06, dev-composetemporal-server+temporal-ui, the $0 Phase-0 local Temporal). - #1127 (workflow per-node cost rollup) — the cost seam the substrate feeds.
upsquad-ai/upsquad-core#4420— Amendment 1 (Temporal retired, no migration; tracker #4419);#4444(issue scoping the deletion-only retirement PR);#4423(W1 workflow service on Postgres); PRs#4449(internal/workflow/agentsgates) and#4450(internal/workflow/orchrt) — the first artefacts of the new engine.- ADR-0020 Amendment 1 — the Claude Agent SDK runtime the new engine runs on (same ruling).
- ADR-0015 — A2A communication model; establishes the Temporal-shaped dispatcher interface (
Context
Workflows is the next workstream. The front-end is founder-validated and already ported 1:1 into
the live app (16-RPC WorkflowService proto vendored, adapter-wired); the backend spine is
built-but-dormant. The scope anchor is the product contract at https://demo.upsquad.ai/workflows:
defs/instances tabs, a live DAG (trigger / agent / tool / branch / governance / terminal nodes),
approval gates that pause runs, per-node cost/timing, a 3-step create wizard, and the SDLC
13-node showcase. This is a wiring and projection problem, not a construction problem.
Ground truth verified in code:
internal/workflow/sequences but never executes —TriggerWorkflowcreates rows; nothing runs them ("synchronous MVP" by its own doc).internal/coordinator/is a complete async executor (govern → hash-chained audit → cost → bus dispatch; approval pause/resume already wired toApprovalService) — but dormant behind flags (BUS_ENABLED,COORDINATOR_ENABLED,HARNESS_ENABLEDall default off; never run in prod).- Timers do not exist.
timeout_minutesis validated and enforced by nothing. There is no trigger/schedule system.parallelis accepted by the validator but unimplemented. - The live-DAG UI streams from
workflow_actionsvia PGLISTEN/NOTIFY— anything that writes those rows lights the founder-validated UI for free.
The open question this ADR settles: what runs the workflow? Three families were on the table — finish the native engine on Redis Streams; adopt an external OSS workflow tool (n8n came up internally, hence this ADR exists); or adopt a durable-execution substrate (Temporal) behind the seam ADR-0015 already declared. ADR-0015 pre-committed to Temporal task-queues "as a backend swap, not a redesign" but left the timing open — interim Redis Streams now, Temporal "later (#623)." The founder's 2026-07-11 challenge flipped that default. This ADR records the flip honestly and closes the n8n discussion with a written ruling.
Decision
Native definitions / governance / UX, with Temporal as the execution substrate, adopted NOW —
behind the existing internal/bus/dispatcher.go seam per ADR-0015's original intent.
Amendment 1, 2026-11-13 — the substrate half of this decision is RETIRED (founder approval from his own account,
#4420comment6849892608; ruling text#4419comment6799098815). Temporal is retired as the workflow execution substrate; no migration of existing definitions; the Claude-native orchestrator on Postgres is the only engine. The ours half below — definition plane, governance choke-point, hash-chained audit, clearance, cost, validated UX — is exactly what the new engine keeps. The Temporal's half is re-supplied by the Claude Agent SDK session (defer+SessionStore, ADR-0020 Amendment 1) plus the durability edges in A1.2, which are ours to build on Postgres (W1/W2). Sequencing, contract PRs and what is deleted are in Amendment 1.
The split is deliberate and load-bearing:
- Ours (the moat, untouched): the workflow definition plane (CRUD, validation, listing,
streaming, pause/cancel intents in
internal/workflow); the governance choke-point and hash-chained audit in the Coordinator; clearance enforcement; cost accrual (llm_usage_eventsauthoritative); and the validated client UX (frozenWorkflowServicecontract, NOTIFY-driven live DAG). None of this moves to Temporal. - Temporal's (undifferentiated plumbing only): durable step-advance, retries, timers, schedules, replay-recovery. This is exactly the "hard durability" ADR-0015 said it wanted to defer to Temporal "rather than hand-built on raw pub/sub."
Why flip the default from tripwire-deferral to adopt-now (recorded honestly):
- The Redis Streams dispatch path was never-run-in-prod code. Its burn-in learning would be discarded at the eventual swap. We would be soaking a transport we had already decided to replace. The coordinator's governance/audit/cost choke-point logic survives the swap and is worth exercising early; the Redis dispatch soak is disposable.
- The MVP's own schedule trigger (W4) is a timer tripwire ~3–4 weeks in. The standing rule — nobody builds a timer-wheel on Redis — trips inside this very MVP, not in some hypothetical future. Deferral does not avoid the timer; it just guarantees we hit it mid-build with the wrong substrate underneath.
- Adopting once is cheaper than adopting twice. Adopt-now totals ≈ 13.5–18.5 eng-weeks once; the tripwire-deferral path totals ≈ 16–21 eng-weeks lifetime (native Redis glue + later Temporal migration + ~3 ew of discarded scaffolding). The price of adopting now is calendar, not total effort: MVP lands at ~7–9 calendar weeks instead of ~5. The founder accepts that trade.
- The swap touches only undifferentiated plumbing. Temporal replaces step-advance, retries, timers, and schedules. The governance choke-point, hash-chained audit, clearance, cost, and the validated UX are untouched. End-state under either path is identical — Temporal-under-our-moat. The founder's ruling just gets there without paying twice.
Adoption shape (staged, all behind existing seams): Temporal infra (W0.5) → TemporalDispatcher
behind internal/bus/dispatcher.go → a deterministic DSL-interpreter workflow hosted by the
Coordinator that walks the same JSON definitions (agent_action → activity on a role/team task
queue; approval_gate → durable signal from ResumeFromApproval with timeout_minutes as a
real timer; governance / audit / cost as wrapping activities) → Temporal Schedules API
replacing the hand-built W4 scheduler. Carried over untouched: the SessionExecutor→ExecuteStep
bridge (activity body verbatim), RunProjector, the definition plane, the frozen client contract,
the approval wiring, and the tenant model. This is consistent with ADR-0015's keystone ruling:
the Coordinator remains the sole executor and sole governance choke-point — Temporal is the
durable engine inside it, not a second brain beside it.
Deployment shape — the one open sub-item (Ashik's Phase-1 production call)
Closed as moot by Amendment 1 (2026-11-13). There is no Phase-1 production Temporal deployment to shape; neither option below is built. Kept as the record of what was weighed.
Temporal is decided; how we run it in production is not. Phase-0 dev is already settled — a $0 local Temporal via docker-compose (WF-06 / #1792). For Phase-1 production, two admissible options, both ADR-0013-compliant because both sit behind the Dispatcher/coordinator seam. This choice is assigned to Ashik — he owns runtime ops and carries the burden of whichever is chosen.
| Option | Shape | Cost (indicative) | Notes |
|---|---|---|---|
| A. Self-hosted | Helm on GKE, 4 Temporal services, Postgres persistence on a separate Cloud SQL instance — explicitly no Cassandra, no Elasticsearch at MVP scale | ~$400–900/mo infra + our ops time | Full control; a new stateful subsystem we operate; tighter data-residency story for enterprise/on-prem tenants (ADR-0002/ADR-0012 dual model). |
| B. Temporal Cloud | Managed namespaces; we run only workers | ~$100–500/mo entry, ~$0.0003–0.0005 per agent-step (actions-based) | Keeps the calendar tighter (no infra stand-up on the critical path); a new external dependency; still ADR-0013-compliant since it lives behind the seam. |
Multi-tenancy stance (applies to both): single Temporal namespace + per-tenant task queues, per Temporal's own SaaS multi-tenancy guidance. Namespace-per-tenant is reserved for enterprise isolation tiers (dedicated-namespace / on-prem customers), not the default. This mirrors the per-tenant-queue keying already in ADR-0015's bus model, so tenant attribution and backpressure are unchanged by the substrate choice.
n8n ruling — the reason this ADR exists
n8n came up in the internal discussion as a candidate embed/substrate. Two independent disqualifiers; either alone is fatal.
REJECTED as embed / execution substrate:
- Licensing. n8n ships under the Sustainable Use License, which prohibits offering n8n's
functionality to third parties as part of a paid/hosted service without the commercial Embed
program. Embedding it in UpsQuad's paid SaaS is exactly the prohibited use.
- Source: https://docs.n8n.io/sustainable-use-license/ and the repo
LICENSE.md. - The Embed program is reportedly ~$50k/yr entry per third-party sources — mark as unofficial; not a published price. Even at $0 this would still be rejected on (3).
- Source: https://docs.n8n.io/sustainable-use-license/ and the repo
- No first-class multi-tenancy. n8n's operational model is instance-per-customer; there is no supported single-instance multi-tenant isolation. That contradicts our tenant model (ADR-0015 per-tenant queues, single control plane) and multiplies ops cost linearly with tenants.
- Governance bypass — fatal regardless of licensing. Execution inside n8n workers runs outside
the Coordinator, which means it bypasses the governance choke-point + hash-chained audit —
the core moat (ADR-0012, ADR-0015). A workflow engine that can act without passing through
Governance.Checkand the audit chain is disqualifying on architecture alone. This is the decisive reason — the licensing point merely makes it moot to argue. - Stack fit. A TypeScript runtime fleet in a Go shop; a second worker runtime to operate and secure for zero differentiated benefit.
ADOPTED as a customer-edge pattern (zero cost, distribution upside): customers running their
own n8n is fully SUL-permitted. We publish documented integration recipes — inbound webhooks
(customer n8n → CreateTask / trigger a run) and outbound run events (run lifecycle → customer
n8n webhook). This turns n8n into a distribution channel with zero licensing exposure and no
governance bypass (the customer's n8n calls our governed API from outside; execution still happens
inside our Coordinator).
Alternatives considered and killed
Each killed with its single decisive disqualifier:
- Windmill — AGPL core, and the features we'd actually need (RBAC depth, multi-tenant controls) live in the EE tier. AGPL tarpit for a paid SaaS + paywalled essentials.
- Conductor / Orkes — JVM runtime; overlaps our engine without Temporal's durable-timer / replay depth. Overlap without the one capability we're adopting for.
- Argo Workflows — pod-per-step execution shape; wrong for cheap agent hops and for month-long paused approval gates (a pod cannot idle for a month waiting on a human).
- Prefect — Python-shaped orchestration; impedance mismatch with the Go Coordinator and its deterministic state machine.
- Dify — its license prohibits multi-tenant use; non-starter for our platform model.
- Flowise — no durable execution at all, and it duplicates the validated UX we already own. Nothing gained, a second UX to reconcile.
Status-quo+ (finish the native engine on Redis Streams) — documented as the retained fallback
(Option B in PRD #1783) in case the ops burden is rejected. Its failure ladder,
recorded so we don't relearn it: timers (no timer-wheel — timeout_minutes needs real durable
timers) → backoff/retry (hand-built at-least-once + DLQ semantics we'd own forever) →
fan-out (parallel join, sagas, compensation — the hardest to hand-roll correctly). The
standing rule holds: nobody builds a timer-wheel on Redis. If deferral is chosen, the schedule
trigger (W4) is the tripwire that forces this conversation again ~3–4 weeks in.
Consequences
Positive
- The hard durability is bought, not built — durable timers, replay recovery, retry policies, schedules, and (later) parallel/sagas come from Temporal instead of hand-rolled on raw pub/sub (ADR-0015's stated intent, now realised).
- The moat is untouched — governance choke-point, hash-chained audit, clearance, cost, and the
validated UX all remain ours; the swap is invisible to the client (frozen
WorkflowServicecontract; NOTIFY-driven live DAG unchanged). - We adopt once — no discarded Redis-dispatch scaffolding, no second migration; end-state is reached directly.
timeout_minutesbecomes real — approval gates pause on a durable timer-backed signal rather than an unenforced validation field.
Negative / trade-offs (accepted)
- Determinism discipline — workflow-definition-interpreter code must be deterministic (no wall clock, no un-seeded randomness, no non-deterministic map iteration in the workflow body). This is a new class of bug for the team; guarded by replay tests in CI.
- Worker-versioning discipline — activity/worker signatures must be versioned; a deploy runbook is required (W5 deliverable). Breaking an in-flight run's contract is a production hazard we now own.
- Continue-as-new for long histories — month-long paused runs will hit Temporal history limits;
the interpreter must
continue-as-newto bound history. Designed in from W1. - A new stateful subsystem OR a new external dependency — self-host adds a Temporal cluster + Cloud SQL we operate (HA, backups, upgrades); Temporal Cloud adds a vendor on the critical path. Either way, ops surface grows. This is the burden Ashik weighs in the Phase-1 production call.
- Calendar cost — MVP lands at ~7–9 weeks instead of ~5. Total effort is lower; wall-clock is higher.
What gets deleted / not-cloned later
- The
internal/busRedis Streams implementation demotes to a dev/local fallback behind the Dispatcher interface — kept for laptop dev and CI, not a production path. - The approval-scheduler lease-loop pattern is NOT cloned for workflows — the schedule trigger uses Temporal's Schedules API (no scheduler process, no lease loop). We do not hand-build a second scheduler.
- Any temptation to add a parallel definition→execution translator is foreclosed here — that is
the split-brain pattern that produced the
coordinator_tasks/tasksdivergence. One engine, one executor (ADR-0015 keystone).
Status and ratification
Amendment 1 (2026-11-13) supersedes this section's substrate ruling. The paragraphs below record the 2026-07-15 state and are kept for the audit trail; the one "scoped open sub-item" (Ashik's Phase-1 deployment shape) is closed as moot.
Accepted. The substrate decision — native definitions/governance/UX + Temporal as the
execution substrate, adopted now, behind the Dispatcher seam — is final. The founder flipped the
default on 2026-07-11 and ratified adopt-now on 2026-07-15; the build has started, with the WF
breakdown filed as #1791–#1800 (incl. #1791 WF-05 go.temporal.io/sdk, which Appendix A of this
document cites). A decision record whose downstream implementation issues are already filed and
referenced inside it is not "Proposed" — it is Accepted.
One scoped open sub-item remains, owned by Ashik:
- Phase-1 production deployment shape — self-hosted (Helm/GKE + separate Cloud SQL) vs Temporal
Cloud — plus ownership of worker-versioning / deploy-discipline thereafter. This is a deliberately
bounded operational choice within the accepted decision, not a re-litigation of it; an
explicitly-scoped open sub-question with a named owner is fully compatible with
Accepted.
Not open: the Phase-0 development substrate is a $0 local Temporal (docker-compose,
temporal-server + temporal-ui, WF-06 / #1792) — already decided and landing. Dev does not wait
on Ashik's Phase-1 call.
This ADR resolves the timing question left open by PRD #623 (adopt now, not at a deferred tripwire) and is the written buy-vs-build ruling — including the n8n answer — that PRD #1783 cross-references.
Appendix A — Verified license text (fetched from source repositories 2026-07-12; re-confirmed at adoption 2026-07-15)
Standing after Amendment 1 (2026-11-13): historical record. The MIT obligations attach to shipping the dependency; they end for UpsQuad when
go.temporal.io/*leavesgo.modin the deletion-only PR that issue#4444scopes. Nothing here is relied on for the new engine.
All Temporal components in scope are under The MIT License, verified directly from each repository's LICENSE file: temporalio/temporal (server), temporalio/sdk-go, temporalio/ui, temporalio/helm-charts. Operative text, verbatim (bold spans below are emphasis added, not present in the source):
The MIT License
Copyright (c) 2025 Temporal Technologies Inc. All rights reserved. Copyright (c) 2020 Uber Technologies, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software (emphasis added), and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Commercial/enterprise-use analysis (engineering due diligence):
- Selling a product/service built on the Software is expressly granted ("sublicense, and/or sell", "without restriction"). Operating Temporal inside UpsQuad's paid multi-tenant SaaS is within the license.
- SaaS operation distributes no copies to customers → the sole MIT condition (notice preservation) barely engages.
- On-prem/enterprise bundles that DO ship Temporal must include the notice above in the distribution — the entire obligation. No copyleft, no network/SaaS clause, no field-of-use restriction (contrast: n8n Sustainable Use License, Dify multi-tenant prohibition, AGPL network copyleft).
- License changes are not retroactive; adopted versions remain MIT permanently. Version + license text pinned in the dependency PR (WF-05 / core#1791) with a transitive-dependency license scan.
- Trademark ("Temporal" name/marks) is not granted by MIT — do not brand UpsQuad features with Temporal marks; describing the capability is fine.
- Temporal Cloud (if selected at Phase 1) is a commercial managed service under its own terms — a vendor contract matter, independent of this code license.
- For enterprise customer paper requiring license schedules, this appendix + the WF-05 scan are the source; specific contract language remains a counsel review item.
Amendment 1 — 2026-11-13 — Temporal retired, no migration; the Claude-native orchestrator on Postgres is the only engine (core#4420)
- Status: Accepted — founder approval from his own account,
upsquad-ai/upsquad-core#4420comment6849892608(2026-11-13T10:06:39Z,user.type == "User", bodyApproved, on the issue whose body enumerates this amendment). Ruling text as relayed by the coordinator:#4419comment6799098815(2026-11-11, founder in his authenticated coordinator session) — "Temporal is retired as the workflow execution substrate. No migration of existing definitions; the Claude-native orchestrator on Postgres is the only engine." — which replaces item 2 of the earlier paste-ready list in#4419comment6776135827("no longer the substrate for new workflows; existing definitions keep running until migrated; per-workflow engine field"). The revision was also posted on#4420itself as comment6799100475(2026-11-11), two days before the approval, and on 2026-11-13 the coordinator patched#4420's title and body to carry the governing text with a dated note; the revision governs. Tracker#4419; retirement issue#4444. - Provenance line: Founder ruling from his own account: #4420 comment 6849892608; text #4419 comments 6776135827 / 6799098815.
- Record: the engine itself — definition schema, run state machine, orchestrator service, resume subscriber, sweeper, scheduler, projection writer — is specified in W1
#4423and built from the two contract PRs named in A1.4. This amendment records the substrate ruling, what it keeps, what it deletes and in what order; it does not restate the engine. - Supersedes: (i) the Decision's substrate half ("Temporal as the execution substrate, adopted NOW") and its four "why flip the default" arguments — they argued adopt-once against adopt-twice, and the answer is now adopt-neither; (ii) the whole Deployment shape section (closed as moot); (iii) in What gets deleted / not-cloned later, the Temporal Schedules API as the schedule trigger — a cron-style schedule table replaces it, drained by the existing approvals-scheduler loop (a second table, not a second scheduler process), so that bullet's "we do not hand-build a second scheduler" clause is kept in substance; the two other bullets there (Redis Streams demoted; no parallel translator) stand; (iv) the retained fallback status-quo+ (finish the native engine on Redis Streams) — it is not the path either; (v) PRD
#623's timing question is now answered never, not now. Unchanged: the ours/Temporal's split as a statement of what the moat is; the n8n ruling (every disqualifier is about n8n, not Temporal); every entry in Alternatives considered and killed; ADR-0015's keystone (one engine, one executor, the governance choke-point is ours) — the one engine is now the Claude-native orchestrator.
A1.1 Decision
- Temporal is retired as the workflow execution substrate — outright, not only for new workflows. No per-workflow
enginefield, no dual-engine routing inTriggerWorkflow, no migration tooling. - No migration of existing definitions. Definitions and runs written by the Temporal engine are not carried over (dev DB at the ruling: 40 definitions, 131 runs, 0 running).
workflow_runs/workflow_actionsstay — as the projection the new engine writes into, lighting the same NOTIFY-driven live DAG. - The Claude-native orchestrator on Postgres is the only engine. One Claude Agent SDK session per run (ADR-0020 Amendment 1), hooks bridged to the existing governance ports (
Governor/Auditor/CostAccruer/ApprovalGate,internal/coordinator/ports.go), human gates asgovernance_approvalsrows opened by thePreToolUsehook and answered through the existingapproval.Service.RecordDecision→DecisionPublisherpath, state in Postgres. - The first workflow built on the new engine is the SDLC workflow (PM agent → architect agent → founder sign-off gate → coder step on a seat-bound engineer's Claude Code → reviewer agents under independent identities → CI wait → landing gate → landing). It is the slice 1/2 demo and the first entry of the template catalogue (
#4430).
A1.2 What replaces the "hard durability we bought"
The 2026-07-15 decision bought step-advance, retries, timers, schedules and replay-recovery. Under the new engine:
| Was Temporal's | Now |
|---|---|
| Step-advance, replay-recovery, month-long pause | The SDK session is the checkpoint: defer ends the session with compute released; SessionStore (Postgres) resumes it on any host. No DSL interpreter, no determinism discipline, no continue-as-new. |
Gate / prompt timeouts (timeout_minutes) | Net-new W2 work (#4424) — today the Temporal interpreter's own timer enforces gate timeouts (VoidApproval → approval.Service.VoidPending, service.go:1766, temporalwf/api/activities.go:1115, #2556); the approvals scheduler is only a backstop that drains a Redis ZSET and calls ExpireOverdue on an expires_at stamped now + 24h (approvalgate/gate.go:57) regardless of the gate's window, and ExpireOverdue never reaches a DecisionPublisher (it calls the ActionTypeHandler.Denied arm or pauser.Terminate). W2 therefore: stamps expires_at from GateTimeoutPolicy.timeout_minutes (1–10080, #4449) and re-stamps it on an escalation re-open; routes expiry of orchestrator-session gate rows to the session-resume subscriber, which resumes with timeout and lets GateTimeoutPolicy (fail / escalate) decide; and keeps the default pauser.Terminate arm from firing on those rows. The scope is recorded on #4424 (comment 6851308568, 2026-11-13) as three items: (a) stamp expires_at from the gate's timeout_policy window, (b) route expiry to the session-resume subscriber with the timeout outcome, (c) route those rows by the orchestrator-session approval source. #4450 at ccb060fef pins only the constant orchrt.ApprovalSource and the ApprovalMeta* keys (internal/workflow/orchrt/hook.go); the approvalgate variant that stamps it, the third arm in cmd/agent-orchestrator/temporaldecisionpublisher.go and the resume subscriber are still to be built, so that neither existing arm — temporal-workflow, or the coordinator fall-through, which no-ops every other source — handles them. Ownership is recorded twice and not identically: the orchrt README ("Pinned here, built by W1") assigns gate variant, mux arm and subscriber to W1 #4423; #4424's note lists (c) under W2. The boundary is settled when W1's composition root lands; until then read W1 as owner of the arm and the variant, W2 of the expiry routing into them. |
| Crash recovery | A sweeper (W2) resumes running runs whose orchestrator process is gone; idempotency = audit hop keys run:step@ordinal. A re-fired call is refused only when its post_tool_use was already recorded; between a tool executing and its post_tool_use reaching Go, delivery is at-least-once (#4450 README rule 4), so a crash in that window re-runs the call and gated and side-effecting tools must be idempotent on the hop key. |
| Exactly-once run start | W1 (#4423) will add UNIQUE (workflow_id, idempotency_key) on run creation and an idempotency field on TriggerWorkflowRequest — neither exists today (no migration; the request has no such field). |
| Schedules API | A cron-style schedule table (W2 #4424; does not exist today), drained by the existing approvals-scheduler loop rather than a second scheduler process; trigger_type stays manual | schedule, event triggers are workstream E. |
| Retries | The SDK's own tool-retry inside the session, bounded by the run envelope; there is no activity-retry policy to configure because there are no activities. |
The standing rule "nobody builds a timer-wheel on Redis" holds in the sense that matters: no new timer is built, on Redis or anywhere else. The one timer loop is the existing approvals scheduler — whose deadline queue is a Redis ZSET with Postgres as the source of truth — and both the gate deadlines and the schedule table ride on it.
A1.3 Sequencing — the portal must not go dark
Two consumers depend on the WorkflowService contract, both in upsquad-client: the client portal (src/: 18 files — 8 under workflows-redesign/*, the rest in agents-redesign, dashboard-redesign, quad-redesign, hooks/ and generated stubs) and the app/ SPA behind demo.upsquad.ai (about 21 WorkflowService RPCs through app/src/data/adapter/live.ts:596: trigger, list/get, the four streams, pause/resume/cancel, run prompt, tool catalog). The two-consumer gate is recorded on #4444 as the sequencing addendum (comment 6851308154, 2026-11-13): the deletion-only PR lands only after W1/W2 serve the RPCs both surfaces consume, otherwise demo.upsquad.ai goes dark on the day Temporal is removed. The app/ SPA is a consumer of the agents+gates contract itself, not only of the old RPCs: its vendored stubs come from the FILES list in app/scripts/vendor-gen.sh, so the client stub-refresh PR must add upsquad/workflow/v1/agents_gates_pb.ts at vendor-gen.sh:82 — Stub Drift's vendored step does not catch the omission, only the app's tsc/Vite build does (frontend-sme review 5888123956 F1 on #4449, which reproduced TS2307 ./agents_gates_pb with the script unchanged). No design follows from this; it widens the gate's consumer list by one. Therefore, in this order:
- The new workflow service takes over the
WorkflowServiceRPCs both consumers use (W1#4423, W2#4424, under tracker#4419), keeping the wire contract where it fits and adding fields only through contract PRs. For the portal team: after the deletion the typed-node DAG authoring (workflows-redesign/*wizard — conditional and tool nodes) has no runnable target and the 40 dev definitions disappear from lists; definition authoring is retargeted to agents + gates in the PRD delta (#4455) and the W-slices, and until cutover expect additive stubs only (agents_gates_pb.ts, stub-refresh PR) and no wire break. - Until step 1 is live, the Temporal path stays runnable in dev only. It is not deployed to any new target, it gains no features, and nothing new is routed to it.
- Then the Temporal engine is deleted in a separate, deletion-only PR, scoped by issue
#4444, whose body carries the measured footprint (internal/temporalwf133.gofiles / ~45,300 lines — 189 files including 55 JSON testdata files;internal/temporalclient;internal/temporalpin;internal/workflow/service_temporal.go; importers incmd/agent-orchestrator,cmd/reconciler,cmd/context-engine; compose servicestemporal+temporal-uiand thedocker-compose.tenant.ymlreferences;deploy/alerts/wf-reconcile-drift.yaml; theTemporal TestsCI lane;go.temporal.io/*ingo.mod). The companion briefdocs/architecture/temporal-architecture-and-licensing.mdis marked historical in that PR.
A1.4 First artefacts of the new engine
- PR
#4449—proto/upsquad/workflow/v1/agents_gates.proto(AgentsGatesDefinition,OrchestratorSpec/RunEnvelope,RosterEntry,GateSpecwithGatePlacementbefore_tool | before_agent | after_agent | on_request,GateAnswerableBy,GateTimeoutPolicy,WorkflowTrigger; enumsRunStaterunning | awaiting_approval | needs_input | completed | failed | cancelled andRunFailureReason), additive fields onWorkflow/WorkflowRun, andinternal/workflow/agentsgates— pure-Go validator, state machine and run-status mapping. Issue#4423. - PR
#4450—internal/workflow/orchrt: the runtime seam between R1/R2 and W1 —Session(Start/Resume/Events/Ack), event types (SubagentStarted,SubagentStopped,ToolDeferred,Usage{Cumulative},Stopped),HookBridge(PreToolUse→ allow | deny | defer;PostToolUse→Auditor;SubagentStart/Stop→Projection+CostAccruer;Stop→RunCompletion),IdempotencyKeyshapedrun:step@ordinal,NewGovernedHookBridgeover the existing coordinator ports plus four new ones W1 implements, andruntimetest.FakeDriver/FakePortsso W1 builds and tests without the SDK. Issue#4448.
Both were open contract PRs when this amendment was written; they are cited as the first artefacts, not as landed facts.
A1.5 Consequences
- Positive: one runtime for agents and workflows (ADR-0020 Amendment 1); no second DSL, no determinism/worker-versioning discipline, no Temporal cluster or vendor; the moat and the validated UX are untouched, as the 2026-07-15 decision promised for either substrate; the governance ports are exercised by a second non-Temporal caller, which is what they were for.
- Negative / accepted: the durability edges in A1.2 — gate-timeout stamping and expiry routing, the crash sweeper, exactly-once start, the schedule table — are ours to build and test (park/resume/exhaust/crash state-machine tests are W1/W2 acceptance); the orchestrator is Claude-only; the Temporal investment (
#1791–#1800and the WR2 wave) is written off except for what the projection and the approval wiring keep. The determinism criterion (pilot criterion 6) is met by fixed roster + hook-enforced gates + hard envelope, not by a replayable DAG — a different guarantee, stated honestly in the product record. - Product record: PRD
#1783's "one engine" is now the Claude-native orchestrator; the Product Manager amends the PRD as the v2.0 delta#4455, anddocs/PRD_REGISTRY.mdnames this amendment as a dated fact. A conflict between the PRD text and this amendment is resolved in favour of this amendment for the execution substrate only; requirement-vocabulary changes (FR-1 typed-node DAG, FR-4 "the DAG is the plan", FR-5tool_action, FR-7 CEL conditional, FR-14) are not ruled here — they land in the PRD delta and go back to the founder.