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>
This commit is contained in:
parent
8dc1998214
commit
94ac5db320
2 changed files with 39 additions and 0 deletions
14
beads.go
14
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:
|
||||
//
|
||||
|
|
|
|||
25
export_dependency_add_options_test.go
Normal file
25
export_dependency_add_options_test.go
Normal file
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue