Skip to content

Commit 0b10896

Browse files
GitHub #96: Workflow: Business reporting and app read models (#519)
1 parent a7f90d3 commit 0b10896

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

docs/architecture/business-reporting-read-models.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ a workflow continues as new, the same app record keeps the same
8888
identifier. New app projection code should prefer `workflowId()` so the
8989
application vocabulary matches workflow authoring code.
9090

91+
The engine's durable column names are `workflow_instance_id` (foreign
92+
key from a run row to its parent instance row) and `workflow_run_id`
93+
(foreign key from child rows such as tasks, activities, signals,
94+
updates, child calls, and commands to the run row). Applications should
95+
not reference those engine columns directly. They exist for engine
96+
joins and operator queries, not as a stable app projection contract.
97+
Use the public API surfaces `Workflow::workflowId()`,
98+
`WorkflowStub::workflowId()`, and `CommandResult::workflowId()` for the
99+
logical id, and `Workflow::runId()`, `WorkflowStub::runId()`, and
100+
`CommandResult::runId()` for the generation id, then store them on
101+
business records as `workflow_id` and `run_id`.
102+
91103
## Milestone-Based Read-Model Pattern
92104

93105
Applications should update business read models at meaningful workflow
@@ -100,9 +112,10 @@ Recommended pattern:
100112
`claim_reviewed`, `case_escalated`.
101113
2. Cross each milestone through a deterministic workflow decision and a
102114
side-effect boundary that is legal under
103-
`docs/architecture/execution-guarantees.md`. Workflow code must not
104-
write external state directly; use an activity, command handler, or
105-
application event consumer to perform the read-model write.
115+
`docs/architecture/execution-guarantees.md`.
116+
Workflow code must not write external state directly; use an activity,
117+
command handler, or application event consumer to perform the
118+
read-model write.
106119
3. Upsert app read-model rows idempotently. Choose a key such as
107120
`(workflow_id, milestone)` for latest-state projections or
108121
`(workflow_id, run_id, milestone, sequence)` for append-only audit

docs/workflow/plan.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ explicitly reserved for a future contract before support is advertised.
301301
define the durable metadata and message-stream homes named above.
302302
- [`docs/architecture/platform-conformance-suite.md`](../architecture/platform-conformance-suite.md)
303303
defines how implementations prove the mapped surfaces conform.
304+
- [`docs/architecture/business-reporting-read-models.md`](../architecture/business-reporting-read-models.md)
305+
defines the split between technical workflow state and
306+
application-owned business state, and the milestone-based
307+
read-model pattern apps should use to build product reporting on
308+
stable `workflow_id` and `run_id` references rather than on
309+
Waterline, run summaries, or history exports.
304310

305311
## Changing This Contract
306312

0 commit comments

Comments
 (0)