diff --git a/beads.go b/beads.go index d7dea43b9..76a0f7b8f 100644 --- a/beads.go +++ b/beads.go @@ -33,6 +33,20 @@ func configuredBackendUnavailable(backend string) error { // Use Storage.RunInTransaction() to obtain a Transaction instance. type Transaction = beads.Transaction +// DependencyAddOptions controls transaction-scoped dependency insertion for +// Transaction.AddDependencyWithOptions. Exported so embedders' bulk graph +// writers can set SkipCycleCheck per edge and run one whole-graph +// Transaction.CycleThroughEdges pass before commit (bd-6dnrw.8) instead of +// paying the recursive per-edge cycle query — which cannot finish inside a +// per-command budget on molecule-sized graphs (observed: a 67-node/100-edge +// batch blowing a 120s deadline mid-transaction, gascity 2026-07-17). +// +// Callers that set SkipCycleCheck MUST run Transaction.CycleThroughEdges before +// commit and fail on new blocks/conditional-blocks/parent-child cycles +// (waits-for is excluded); skipping the per-edge check trades per-edge cost for +// one whole-graph check, never graph integrity. +type DependencyAddOptions = storage.DependencyAddOptions + // RemoteStore provides dolt remote management and replication operations. // Use type assertion on a Storage value to access these methods: // diff --git a/export_dependency_add_options_test.go b/export_dependency_add_options_test.go new file mode 100644 index 000000000..191b789a6 --- /dev/null +++ b/export_dependency_add_options_test.go @@ -0,0 +1,25 @@ +package beads + +import ( + "context" + "testing" + + "github.com/steveyegge/beads/internal/types" +) + +// Compile-time proof that the exported alias is accepted by the Transaction +// interface's AddDependencyWithOptions. Embedders' bulk graph writers need to +// name this type to set SkipCycleCheck per edge and run one whole-graph +// Transaction.CycleThroughEdges pass before commit (bd-6dnrw.8); before this +// alias it lived only in internal/storage, so the designed batch path was +// uncallable from outside the module (a 67-node/100-edge molecule batch blew +// a 120s deadline on per-edge cycle queries, gascity 2026-07-17). +var _ = func(tx Transaction, dep *types.Dependency) error { + return tx.AddDependencyWithOptions(context.Background(), dep, "actor", DependencyAddOptions{SkipCycleCheck: true}) +} + +func TestDependencyAddOptionsIsExported(t *testing.T) { + if !(DependencyAddOptions{SkipCycleCheck: true}).SkipCycleCheck { + t.Fatal("SkipCycleCheck must round-trip through the exported alias") + } +}