beads/export_dependency_add_options_test.go
Julian Knutsen 94ac5db320
feat: export DependencyAddOptions from the root package (#4870)
* feat: export DependencyAddOptions from the root package

Transaction.AddDependencyWithOptions and Transaction.CycleThroughEdges
are both on the public Transaction interface, but the options type lived
only in internal/storage — so the designed bulk path (SkipCycleCheck per
edge + one whole-graph CycleThroughEdges pass before commit, bd-6dnrw.8)
was uncallable by embedders. Gas City's native graph-apply pours
molecule-sized batches (67 nodes / ~100 blocking edges) whose per-edge
recursive cycle queries cannot finish inside a 120s per-command budget
(observed 2026-07-17: the batch died at the deadline mid-edges twice,
then fell back to per-bead creates — a 9-minute pour).

Root-alias the type, with a compile-time proof that the alias satisfies
the Transaction method.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs(beads): mirror SkipCycleCheck whole-graph guardrail on public alias

The exported beads.DependencyAddOptions alias documented only the happy path,
dropping the imperative guardrail carried on the internal
storage.DependencyAddOptions it aliases. Mirror that contract on the public
surface: callers setting SkipCycleCheck MUST run Transaction.CycleThroughEdges
before commit and fail on new blocks/conditional-blocks/parent-child cycles, so
embedders reading the root-package doc do not skip the per-edge check with
nothing replacing it and silently commit cycles.

Maintainer review fixup for adopt-pr of PR #4870 (minor Contract & Interface
Fidelity finding). No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Test User <test@test.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 20:34:32 -07:00

25 lines
1,001 B
Go

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")
}
}