{"record":{"id":"12fb32e464f13a00","repo":"gastownhall/beads","slug":"linking-proto-a-w","errorCode":null,"errorMessage":"linking proto A: %w","messagePattern":"linking proto A: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/mol_bond.go","lineNumber":350,"sourceCode":"\t\tLabels:      []string{MoleculeLabel},\n\t\tBondedFrom: []types.BondRef{\n\t\t\t{SourceID: protoA.ID, BondType: bondType, BondPoint: \"\"},\n\t\t\t{SourceID: protoB.ID, BondType: bondType, BondPoint: \"\"},\n\t\t},\n\t}\n\tif err := w.CreateIssue(ctx, compound, actorName); err != nil {\n\t\treturn nil, fmt.Errorf(\"creating compound: %w\", err)\n\t}\n\tcompoundID := compound.ID\n\n\t// Add parent-child dependencies from compound to both proto roots\n\tdepA := &types.Dependency{\n\t\tIssueID:     protoA.ID,\n\t\tDependsOnID: compoundID,\n\t\tType:        types.DepParentChild,\n\t}\n\tif err := w.AddDependency(ctx, depA, actorName); err != nil {\n\t\treturn nil, fmt.Errorf(\"linking proto A: %w\", err)\n\t}\n\n\tdepB := &types.Dependency{\n\t\tIssueID:     protoB.ID,\n\t\tDependsOnID: compoundID,\n\t\tType:        types.DepParentChild,\n\t}\n\tif err := w.AddDependency(ctx, depB, actorName); err != nil {\n\t\treturn nil, fmt.Errorf(\"linking proto B: %w\", err)\n\t}\n\n\t// For sequential/conditional bonding, add blocking dependency: B blocks on A\n\t// Sequential: B runs after A completes (any outcome)\n\t// Conditional: B runs only if A fails\n\tif bondType == types.BondTypeSequential || bondType == types.BondTypeConditional {\n\t\tdepType := types.DepBlocks\n\t\tif bondType == types.BondTypeConditional {\n\t\t\tdepType = types.DepConditionalBlocks","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/mol_bond.go#L332-L368","documentation":"After the compound is created, bondProtoProtoInto links proto A to it with a parent-child dependency; if w.AddDependency fails the bond aborts with this error naming proto A.","triggerScenarios":"w.AddDependency(ctx, depA, actorName) errors right after compound creation — driver write failure, lock contention, or the compound ID not yet visible to the writer.","commonSituations":"Database lock from a concurrent bd process mid-bond, or an earlier partial bond leaving inconsistent state the writer rejects.","solutions":["Check the wrapped inner error for the driver cause.","Close competing bd processes and retry the bond; note the compound may already exist from the failed attempt — check for it before re-running to avoid duplicates.","Verify the .beads storage is writable and healthy (bd doctor), then re-run."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify compound exists and is writable before linking deps\nif _, err := w.GetIssue(ctx, compoundID); err != nil {\n    return fmt.Errorf(\"compound %s not retrievable: %w\", compoundID, err)\n}","typeGuard":null,"tryCatchPattern":"if err := bond(ctx, w, a, b, bt, actor); err != nil {\n    if strings.Contains(err.Error(), \"linking proto A:\") {\n        // compound was created; look it up before retrying to avoid duplicates\n    }\n    return err\n}","preventionTips":["After a failed bond, check for an orphan compound issue before re-running.","Avoid concurrent bd operations during automation.","Keep .beads storage healthy (bd doctor) so AddDependency writes succeed."],"tags":["mol-bond","dependencies","storage","dolt"],"backgroundTag":"storage-write-failure","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}