fix(cook): dedupe waits_for spawner in depends_on loop too (GH#3783)
collectDependencies pre-computes the waits_for spawner step ID and skips the redundant DepBlocks edge for it in the `needs` loop (the DepWaitsFor edge subsumes the blocking semantics for that target). The same collision was still possible from the `depends_on` loop: an explicit waits_for `from:` spawner that also appears in a step's `depends_on` list would hit the same "already exists with type blocks (requested waits-for)" storage rejection GH#3783 fixed for `needs`. Move the spawner pre-computation above both loops and apply the same skip in `depends_on`. This completes PR gastownhall/beads#3875 per review, but does not resolve the review's second, larger finding: waitsForGateBlockedSQL only blocks a waiter while its spawner has an open parent-child child, never merely because the spawner itself is still open, so dropping the blocks edge on needs/depends_on opens a pre-fanout window where the waiter can become ready before the spawner completes. Extending the gate to also block on "spawner still open" was attempted and reverted here: it makes TestIsBlocked_WaitsForDefaultGate fail, because that test documents the opposite semantics for the default (all-children) gate — the waiter must unblock once all children close, even while the spawner itself remains open. Resolving the pre-fanout window requires a design decision on whether that default-gate test's expectation is still correct, not a mechanical SQL change. Agent-Signature: claude-fable-5-medium on behalf of matt wilkie
This commit is contained in:
parent
027d448fa0
commit
52ba524a15
1 changed files with 24 additions and 19 deletions
|
|
@ -905,27 +905,13 @@ func cookFormula(ctx context.Context, s storage.DoltStorage, f *formula.Formula,
|
|||
func collectDependencies(step *formula.Step, idMapping map[string]string, deps *[]*types.Dependency) {
|
||||
issueID := idMapping[step.ID]
|
||||
|
||||
// Process depends_on field
|
||||
for _, depID := range step.DependsOn {
|
||||
depIssueID, ok := idMapping[depID]
|
||||
if !ok {
|
||||
continue // Will be caught during validation
|
||||
}
|
||||
|
||||
*deps = append(*deps, &types.Dependency{
|
||||
IssueID: issueID,
|
||||
DependsOnID: depIssueID,
|
||||
Type: types.DepBlocks,
|
||||
})
|
||||
}
|
||||
|
||||
// Pre-compute the waits_for spawner so we can dedupe against needs below.
|
||||
// When waits_for has no explicit `from:`, it infers its spawner from
|
||||
// needs[0] — and `needs` would otherwise emit a DepBlocks edge on the same
|
||||
// (source, target) pair that `waits_for` emits a DepWaitsFor edge on.
|
||||
// Storage rejects the duplicate. The DepWaitsFor edge subsumes the
|
||||
// blocking semantics, so we skip the redundant DepBlocks for that
|
||||
// specific target (GH#3783).
|
||||
// Pre-compute the waits_for spawner so we can dedupe against depends_on
|
||||
// and needs below. When waits_for has no explicit `from:`, it infers its
|
||||
// spawner from needs[0] — and `depends_on`/`needs` would otherwise emit a
|
||||
// DepBlocks edge on the same (source, target) pair that `waits_for`
|
||||
// emits a DepWaitsFor edge on. Storage rejects the duplicate. The
|
||||
// DepWaitsFor edge subsumes the blocking semantics, so we skip the
|
||||
// redundant DepBlocks for that specific target (GH#3783).
|
||||
var waitsForSpec *formula.WaitsForSpec
|
||||
var waitsForSpawnerStepID string
|
||||
if step.WaitsFor != "" {
|
||||
|
|
@ -938,6 +924,25 @@ func collectDependencies(step *formula.Step, idMapping map[string]string, deps *
|
|||
}
|
||||
}
|
||||
|
||||
// Process depends_on field
|
||||
for _, depID := range step.DependsOn {
|
||||
if depID == waitsForSpawnerStepID {
|
||||
// This target is also the waits_for spawner; the DepWaitsFor edge
|
||||
// emitted below subsumes the blocking semantics for this pair.
|
||||
continue
|
||||
}
|
||||
depIssueID, ok := idMapping[depID]
|
||||
if !ok {
|
||||
continue // Will be caught during validation
|
||||
}
|
||||
|
||||
*deps = append(*deps, &types.Dependency{
|
||||
IssueID: issueID,
|
||||
DependsOnID: depIssueID,
|
||||
Type: types.DepBlocks,
|
||||
})
|
||||
}
|
||||
|
||||
// Process needs field - simpler alias for sibling dependencies
|
||||
for _, needID := range step.Needs {
|
||||
if needID == waitsForSpawnerStepID {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue