{"record":{"id":"d3f0a74ab938fa2c","repo":"gastownhall/beads","slug":"edge-d-spawner-id-q-must-match-to-id-q-the-wa","errorCode":null,"errorMessage":"edge %d: spawner_id %q must match to_id %q (the waits-for target is the spawner)","messagePattern":"edge (.+?): spawner_id %q must match to_id %q \\(the waits-for target is the spawner\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/graph_apply.go","lineNumber":635,"sourceCode":"\t\t\t}\n\t\t\tif edge.SpawnerKey != \"\" && edge.SpawnerID != \"\" {\n\t\t\t\treturn fmt.Errorf(\"edge %d: cannot specify both spawner_key and spawner_id\", i)\n\t\t\t}\n\t\t\tif edge.SpawnerKey != \"\" && !seenKeys[edge.SpawnerKey] {\n\t\t\t\treturn fmt.Errorf(\"edge %d: spawner key %q not found in plan\", i, edge.SpawnerKey)\n\t\t\t}\n\t\t\t// Gate evaluation reads the spawner from the dependency target\n\t\t\t// (depends_on_id), not metadata, so the spawner must equal the to\n\t\t\t// endpoint. Since to_id overrides to_key at apply time\n\t\t\t// (resolveEdgeRef), a key-named spawner can't be combined with to_id.\n\t\t\tif edge.SpawnerKey != \"\" && edge.ToID != \"\" {\n\t\t\t\treturn fmt.Errorf(\"edge %d: spawner_key %q cannot be combined with to_id %q (to_id overrides to_key as the waits-for target; use spawner_id)\", i, edge.SpawnerKey, edge.ToID)\n\t\t\t}\n\t\t\tif edge.SpawnerKey != \"\" && edge.SpawnerKey != edge.ToKey {\n\t\t\t\treturn fmt.Errorf(\"edge %d: spawner_key %q must match to_key %q (the waits-for target is the spawner)\", i, edge.SpawnerKey, edge.ToKey)\n\t\t\t}\n\t\t\tif edge.SpawnerID != \"\" && edge.SpawnerID != edge.ToID {\n\t\t\t\treturn fmt.Errorf(\"edge %d: spawner_id %q must match to_id %q (the waits-for target is the spawner)\", i, edge.SpawnerID, edge.ToID)\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := validateGraphApplyLocalCycles(plan, seenKeys); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// validateGraphApplyNodeFields checks the single-node fields added for\n// bd-create parity, mirroring the flag-shape checks `bd create` applies\n// (config-gated template linting is not run on graph plans).\nfunc validateGraphApplyNodeFields(node GraphApplyNode, customTypes, customStatuses []string, opts GraphApplyOptions) error {\n\tif node.ID != \"\" {\n\t\tif _, err := validation.ValidateIDFormat(node.ID); err != nil {\n\t\t\treturn fmt.Errorf(\"node %q: %w\", node.Key, err)","sourceCodeStart":617,"sourceCodeEnd":653,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/graph_apply.go#L617-L653","documentation":"Mirror of the spawner_key/to_key rule for ID-addressed edges: for waits-for edges carrying spawner_id, the spawner ID must equal to_id because gate evaluation reads the spawner from the dependency target. A mismatch is rejected at validation time.","triggerScenarios":"An edge with type waits-for where spawner_id = \"bd-42\" but to_id = \"bd-99\".","commonSituations":"Swapping edge direction without swapping spawner_id; generating IDs from a template that fills the wrong column; refactoring plans and renaming IDs inconsistently.","solutions":["Set spawner_id equal to to_id","Remove spawner_id if gate/spawner semantics aren't needed","Reverse or restructure the edge so the target is the actual spawner"],"exampleFix":"// before\n{\"type\": \"waits-for\", \"spawner_id\": \"bd-42\", \"to_id\": \"bd-99\"}\n// after\n{\"type\": \"waits-for\", \"spawner_id\": \"bd-99\", \"to_id\": \"bd-99\"}","handlingStrategy":"validation","validationCode":"if e.Type == \"waits-for\" && e.SpawnerID != \"\" && e.SpawnerID != e.ToID {\n  return fmt.Errorf(\"spawner_id must equal to_id for waits-for edges\")\n}","typeGuard":"func spawnerIDMatchesTarget(e Edge) bool { return e.SpawnerID == \"\" || e.SpawnerID == e.ToID }","tryCatchPattern":null,"preventionTips":["Fill spawner_id and to_id from the same source field in generators","Don't reverse edges by swapping only one endpoint field","Add ID consistency checks to plan CI linting"],"tags":["graph-plan","waits-for","spawner"],"backgroundTag":"spawner-target-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}