Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -6,8 +6,7 @@ that triggered them. Without it, a crash between `DB COMMIT` and "call
|
||||
mailer" leaves the DB updated but the side-effect lost.
|
||||
|
||||
This document describes how to publish and consume outbox events in this
|
||||
codebase. See `docs/improvement-plan/03-scaling-infrastructure/outbox-pattern.md`
|
||||
for the broader design rationale.
|
||||
codebase.
|
||||
|
||||
## When to publish
|
||||
|
||||
@@ -15,7 +14,7 @@ Publish **inside** a Prisma `$transaction` block whenever a successful DB
|
||||
write should fan out an asynchronous side-effect.
|
||||
|
||||
```ts
|
||||
import { publishOutboxEvent } from "@toolctrl/db/outbox";
|
||||
import { publishOutboxEvent } from "@hivegrid/db/outbox";
|
||||
|
||||
await prisma.$transaction(async (tx) => {
|
||||
const subscription = await tx.subscription.update({
|
||||
@@ -27,7 +26,7 @@ await prisma.$transaction(async (tx) => {
|
||||
tenantId: subscription.tenantId,
|
||||
type: "billing.subscription.updated",
|
||||
payload: { subscriptionId: subscription.id, status: "active" },
|
||||
dispatchKey: `stripe:${stripeEvent.id}`, // optional idempotency key
|
||||
dispatchKey: `legacyProvider:${legacyProviderEvent.id}`, // optional idempotency key
|
||||
});
|
||||
});
|
||||
```
|
||||
@@ -74,14 +73,13 @@ gap is the current `waitForInput` boundary. Candidates that fail preflight are
|
||||
skipped or recorded as rejected.
|
||||
`apps/worker/src/jobs/workflow-trigger-store.ts` provides the worker-native
|
||||
Prisma lookup/preflight port. Application events publish
|
||||
`workflow.trigger.event` through `EventsService`. The route-backed row mutation
|
||||
producers for `row.created`, `row.updated`, and `row.deleted` record the row
|
||||
write, application event, and workflow outbox event in the same transaction
|
||||
before post-commit notifications/webhook callouts run. Internal mutations
|
||||
without a request context remain intentionally eventless unless the caller opts
|
||||
into an event context. Workflow row blocks pass a `workflow` event context so
|
||||
requestless `rowCreate`, `rowUpdate`, and `rowDelete` blocks still publish row
|
||||
events without enabling external webhook callouts. A source-inventory test guards the current execution
|
||||
`workflow.trigger.event` through `EventsService`. The generic entity-builder's
|
||||
route-backed `row.created` / `row.updated` / `row.deleted` outbox producers were
|
||||
**removed with the entity-builder** (R-P6B-β, AD-2): typed fachentities (CRM
|
||||
`Kontakt` etc.) write their own audit/activity trail, and workflow row blocks
|
||||
address typed models through the typed model registry
|
||||
(`apps/web/app/services/typed-model-registry`) rather than emitting generic
|
||||
`row.*` outbox events. A source-inventory test guards the current execution
|
||||
boundary: manual and tenant API runs must publish
|
||||
`workflow.execution.requested` instead of executing inline, non-stream
|
||||
continuations must publish `workflow.execution.continue.requested`, only the
|
||||
@@ -102,7 +100,7 @@ mail delivery workers. Production-like Coolify stacks need a persistent
|
||||
`worker-general` (`WORKER_QUEUE_GROUP=general`) for the dispatcher and
|
||||
`outbox.workflow`, plus a persistent `worker-mail`
|
||||
(`WORKER_QUEUE_GROUP=mail`) for `outbox.mail`, `outbox.webhook`,
|
||||
`outbox.marketing`, and `toolctrl.email` work. A green outbox row does not prove
|
||||
`outbox.marketing`, and `hivegrid.email` work. A green outbox row does not prove
|
||||
that both services exist or that the downstream BullMQ job finished.
|
||||
|
||||
### Non-durable exception: stream runs
|
||||
@@ -125,10 +123,10 @@ workflow trigger outbox event, claims and routes it through the production
|
||||
dispatcher seam, then executes a live safe-core workflow through the native
|
||||
worker runner and verifies idempotent re-delivery. It also verifies the
|
||||
`workflow.executed` plugin hook path by routing `plugin.hook.workflow.executed`
|
||||
through `outbox.plugin-hook` fanout into `toolctrl.plugin-invoke`. A paired
|
||||
through `outbox.plugin-hook` fanout into `hivegrid.plugin-invoke`. A paired
|
||||
failure-path fixture forces an unsupported native block, verifies terminal
|
||||
`status: "error"` persistence, then routes `plugin.hook.workflow.failed`
|
||||
through the same fanout boundary into `toolctrl.plugin-invoke`.
|
||||
through the same fanout boundary into `hivegrid.plugin-invoke`.
|
||||
|
||||
The canonical non-browser readiness gate for this path is
|
||||
`pnpm run verify:workflow-outbox-native`. It composes the existing focused
|
||||
@@ -174,7 +172,7 @@ processed the job, the provider call succeeded, or a domain state machine
|
||||
reached a terminal success state. For workflow events, operators must also
|
||||
watch the `outbox.workflow` BullMQ job state and the associated
|
||||
`WorkflowExecution` status. For mail/webhook events, also watch the
|
||||
`worker-mail` subscriber queues and the `toolctrl.email` job state.
|
||||
`worker-mail` subscriber queues and the `hivegrid.email` job state.
|
||||
|
||||
The dispatcher is enabled by `OUTBOX_DISPATCHER_ENABLED=true`. Defaults to
|
||||
**off** in dev so a missing Redis URL does not crash the worker.
|
||||
@@ -200,8 +198,8 @@ BullMQ delivery is at-least-once: a receiver crash between
|
||||
`withOutboxIdempotency` so duplicate deliveries are a no-op.
|
||||
|
||||
```ts
|
||||
import { withOutboxIdempotency } from "@toolctrl/db/outbox-receiver";
|
||||
import { createIdempotencyStore } from "@toolctrl/shared-store";
|
||||
import { withOutboxIdempotency } from "@hivegrid/db/outbox-receiver";
|
||||
import { createIdempotencyStore } from "@hivegrid/shared-store";
|
||||
|
||||
const idempotencyStore = createIdempotencyStore({
|
||||
store: sharedStore,
|
||||
@@ -230,14 +228,14 @@ Alert when > 1000 for > 5 minutes — that means the dispatcher is behind.
|
||||
|
||||
Outbox `DONE` counts are not sufficient for worker health. Alert separately on
|
||||
target BullMQ queue depth, failed jobs, and stalled jobs for `outbox.workflow`,
|
||||
`outbox.mail`, `outbox.webhook`, `outbox.marketing`, and `toolctrl.email`.
|
||||
`outbox.mail`, `outbox.webhook`, `outbox.marketing`, and `hivegrid.email`.
|
||||
Workflow incidents must include the `WorkflowExecution` terminal status because
|
||||
`workflow.execution.requested` can be handed to BullMQ successfully while the
|
||||
execution later fails, stalls, or remains queued behind a missing bridge.
|
||||
|
||||
### Re-queueing failed events
|
||||
|
||||
Use `toolctrl-cli outbox requeue` after fixing the underlying receiver.
|
||||
Use `hivegrid-cli outbox requeue` after fixing the underlying receiver.
|
||||
The CLI supports single-row and filtered bulk requeues, `--dry-run`, JSON
|
||||
output, and guardrails that avoid replaying `PENDING` / `PROCESSING`
|
||||
rows. Prefer it over raw SQL so `processedAt`, `lastError`, retry state,
|
||||
|
||||
Reference in new issue
Block a user