feat(recompute): bulk-write derived values with coalesced chaining
Why
This is a follow-up to the merge and rebase recompute coalescing (IFC-2761). That work grouped the per-node process-flow dispatch into one pass. The dataset runs showed the time an instance stays busy after a large merge comes mostly from the next stage: one update flow plus one GraphQL write for each affected value. This change removes that stage.
What
The bulk write is now the only way we persist recomputed derived values. This is true for live edits and for merge and rebase.
-
Bulk write. A
BulkRecomputeWritersaves display labels, human-friendly ids and Jinja2 computed attributes for many nodes in bounded transactions on the task worker, which has database access. Before, there was one update flow per value. The process flow now renders and checks for a real change in place, because the reader query already returns the current values. This drops the per-value task fan-out, the per-value API calls and the repeated per-value reads. -
Coalesced chaining. A recompute write can feed a value that reads it. Those writes become a new change set that goes through the same coordinator, so the next level is one coalesced pass instead of one live event per written node. Each write still emits one node-update event per node for other consumers. On the coalesced pass the event is tagged with a
recomputeorigin, so the per-node recompute automations do not run again. -
Depth bound. For normal (acyclic) schemas the chain stops on its own once a level changes nothing. The bound is only there for a cyclic schema. It is derived from the schema: a chain cannot recompute more values than the schema defines, so the bound is the number of derived-value targets, with a floor. It never cuts a real chain short, and it still stops a cyclic one.
Scope
Jinja2 computed attributes, display labels and human-friendly ids, the same families as the coalescing work. Python-transform computed attributes stay on the per-node path. The per-value update flows and their workflow definitions are removed.
Correctness
The stored value does not change. Rendering, including custom Jinja2 filters, still runs on the worker. Only the way we persist changed, from a GraphQL mutation to a direct save. Component tests against a real database check the stored value for every impacted node across the three families. They also check no-op suppression (per node and per field), one event per node across transaction chunks, the origin tag, a single write chaining to exactly one coalesced next level, the depth bound, and a cyclic schema that stops at the bound. The value-based integration tests check the recomputed data is correct after live edits, merges and rebases.
Notes
- The number of events per written node is the same as before. We keep it for the non-recompute consumers. The win is removing the per-value task and write storm.
- Measured on a dedicated machine, the per-value update flow counts drop to zero (100 to 0 on a heavy merge, 300 to 0 on a rebase), and the derived values stay correct.
Summary by cubic
Bulk-write recomputed display labels, HFIDs, and Jinja2 computed attributes, and coalesce recompute chaining to cut fan-out and speed up recompute after merges and live edits. Removes per-value update flows and updates events/docs; follow-up to IFC-2761.
-
New Features
BulkRecomputeWritergroups writes per node, loads the full node, saves in bounded transactions with a dedicated DB session, includes cascaded fields in the change/event, and emits oneNodeUpdatedper node.- Coalesced chaining via
RecomputeChainSubmitterwith a schema-derived depth bound (floor 10); chained writes useNodeMutationOrigin.RECOMPUTEso per-node automations skip; dispatch only when values changed. - The bulk path is now the only recompute write for live edits, merges, and rebases; per-value workflows and their workflow definitions are removed; extracted
BulkRecomputeDispatcher/build_bulk_recompute_dispatcherand injected collaborators; dropped per-node flow-run tags.
-
Bug Fixes
- Preserve author attribution; tag runs as database-changing; skip no-op writes/events; tolerate branches deleted between read and persist; log remaining kinds/ids at the chain bound; note per-chunk commits are non-atomic.
- Load the whole node so same-node derived values (display label, HFID, computed siblings) refresh; include cascaded fields in the changelog and event so cross-node readers chain; docs and event metadata updated to add the
recomputeorigin.