beads/internal/workapi
CI Bot cf0a42cdae feat(delete): put bd delete behind the Deleter role and converge both routes (bd-x82so)
THE TWO ROUTES DISAGREED ABOUT WHAT --force MEANS on a destructive command.
On a local database `--force` deletes the named beads and orphans their
dependents; on a team server it deleted the whole dependent subtree, `--cascade`
was REFUSED outright ("not supported in proxied-server mode (delete always
cascades)") and Cascade was hardcoded true at both call sites. So there was no
way to delete one bead on a team server without taking everything under it, and
asking for the safer behaviour was an error.

Q1 ANSWERED IN THE ROLE. issueops.Deleter has one method, reached through
store.Deleter() and the provider's own accessor, and the three modes are request
fields: no flags refuses over a dependent the request did not name, Force
orphans it, Cascade deletes the closure. The guard is workapi's and the body's,
below every front door, for the reason Sweeper's require-a-filter gate is: a
second front door that inherited the capability without the guard would orphan a
workspace's graph by omission — which is exactly what this commit's HTTP
operation would otherwise have been.

IT IS A DIFFERENT ROLE FROM Sweeper, not a mode of it. Sweeper erases a set the
caller DESCRIBED; this erases rows the caller NAMED. That is what decides where
each one's safety lives: a description can be accidentally too wide, so Sweeper
carries a require-a-filter refusal; a list of ids cannot be, so this one's guard
is about the graph.

THE DEFECT. The direct route's batch path deleted the rows in one transaction
and then rewrote `[deleted:ID]` into the neighbours' text afterwards, discarding
every update error. A failure in the window left a workspace whose beads were
gone and whose descriptions still cited them by id. The existence probe, the
guard, the cascade expansion, the deletion and the rewrite are now one
transaction. WHAT THAT COSTS is written into the leaf beside the promise: the
transaction is as large as the deletion plus its neighbourhood, so a batch with
a very large neighbourhood fails whole. It is NOT Sweeper's trade (bd-hysee) —
the delete itself was already one transaction on every route — and the part that
is new is named rather than measured, which is recorded for sign-off.

TWO MORE DEFECTS the single call site removed. The one-id path held its own
transaction that removed each edge by hand, so it never reported labels, events
or orphans; and `domain.DeleteIssuesParams.EnforceCascadePolicy` and `.Force`
were declared, documented in fifteen lines describing exactly these three modes,
and READ BY NOTHING. They are deleted; the policy lives in the role now.

THE CONTRACT IS WHAT WAS DELETED, not what was reported.
backend/conformance/deleter_contract.go holds eleven cases, each citing the leaf
doc, run at all three backends with ZERO PARKS and zero divergences. Every case
that acts asserts row counts through QueryScalar rather than trusting the result
the delete reported about itself. They are TWO INDEPENDENT BODIES plus an engine
check: dolt and embeddeddolt share internal/storage/issueops.DeleteInTx and
differ only in how they reach a transaction, and the unit-of-work provider
reaches the same questions through the domain use cases. It does NOT duplicate
backend/conformance/audit_issue-lifecycle.go, which stays the right home for
`DeleteIssues` at the STORAGE seam: that suite's Factory hands back a bare
storage.DoltStorage, so the unit-of-work backend — where the guard did not exist
at all before this commit — can never run a case placed there.

`bd serve` gains POST /v0/beads/issues:delete, spec first. The dependents guard,
the all-or-nothing id resolution and the reference rewrite are the role's, so
the handler is argument validation and a projection. `cascade` and `force`
default false, which is the guarded mode; DeleteIssuesResult is not
x-go-type-pinned for the reason SweepResult is not, and a reflection test keeps
the projection honest. No page envelope, so nothing to pin in pinning.go.

USER-VISIBLE, and the CHANGELOG says so loudly: a team-server script relying on
the implicit cascade starts leaving orphans; `bd delete <one-id>` without
--force now refuses over an outside dependent, converging the direct route's
three paths onto the answer two of them already gave; the proxied `--json`
result gains `orphaned_issues`. Reasoning and the alternatives are in
/data/tmp/sd-server/AMBIGUITIES.md as A-del-1..6.

Verified: build, vet, gofmt clean; golangci-lint 0 issues; make api-check
(regenerate-and-diff plus the httpapi suite) green; TestDeleterContract 11/11 at
dolt, embeddeddolt and uow; the internal/workapi delete unit tests; the
internal/storage, internal/telemetry and root layering pins;
TestConformance/Audit/issue-lifecycle and the dolt TestDeleteIssues* family
(this commit refactors DeleteIssuesInTx's guard); TestEmbeddedDelete,
TestEmbeddedDeleteJSONDependencyErrorContract, TestBurnWisps,
TestWispGCProtectsActiveWisps and TestCLI_WispGCExcludeType under
BEADS_TEST_EMBEDDED_DOLT=1; TestProxiedServerDelete{,ForceOrphans,Wisp,
Concurrent}, TestProxiedServerMolBurn and TestProxiedServerWispGC under
BEADS_TEST_PROXIED_SERVER=1; and TestProxiedLookup*.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 02:59:08 +00:00
..
storecounter feat(issueops): put bd count behind the Counter role (bd-m8hn7) 2026-08-05 05:27:39 +00:00
storequerier feat(query): put bd query behind the Querier role and stop it dropping matches (bd-pohmh) 2026-08-05 16:36:05 +00:00
storereader feat(list): put bd list behind Reader.List and the new BlockingAnnotator role (bd-5k21g) 2026-08-06 02:56:57 +00:00
storereadycounter feat(ready): put bd ready's published total behind the ReadyCounter role (bd-s10oa) 2026-08-05 09:47:24 +00:00
storestats feat(issueops): put bd status behind the StatsReporter role (bd-4ze25) 2026-08-05 09:27:16 +00:00
storeversionreconciler feat(issueops): put the startup version reconciler behind the VersionReconciler role (bd-gkmft) 2026-08-05 16:35:01 +00:00
storeworkspaceconfig feat(config): put bd config's stored settings behind the WorkspaceConfig role (bd-kzepq) 2026-08-05 09:14:54 +00:00
testdata feat(list): put bd list's row cap and counts hydration on ListRequest (bd-b34o7) 2026-08-05 16:36:31 +00:00
count.go feat(issueops): put bd count behind the Counter role (bd-m8hn7) 2026-08-05 05:27:39 +00:00
count_test.go feat(issueops): put bd count behind the Counter role (bd-m8hn7) 2026-08-05 05:27:39 +00:00
delete.go feat(delete): put bd delete behind the Deleter role and converge both routes (bd-x82so) 2026-08-06 02:59:08 +00:00
delete_test.go feat(delete): put bd delete behind the Deleter role and converge both routes (bd-x82so) 2026-08-06 02:59:08 +00:00
detail.go feat(issueops): add the Reader role and wire both front doors through it 2026-07-31 18:37:25 +00:00
detail_test.go test(workapi): make the hard-error test pin the short-circuit, unexport isNotFound (bd-hc1) 2026-07-31 08:21:06 +00:00
doc.go refactor(show): share issue-detail assembly and normalize not-found (bd-hc1) 2026-07-31 07:58:46 +00:00
list.go feat(list): put bd list's row cap and counts hydration on ListRequest (bd-b34o7) 2026-08-05 16:36:31 +00:00
list_golden_test.go feat(list): put bd list's row cap and counts hydration on ListRequest (bd-b34o7) 2026-08-05 16:36:31 +00:00
list_status_test.go refactor(list): route both bd list paths through internal/workapi and delete list_filter.go (bd-fv4) 2026-07-31 06:01:48 +00:00
metadata.go fix(workapi): refuse an invalid metadata key where the builders can name it 2026-07-31 18:37:25 +00:00
page.go docs(workapi): say where the shared epilogue stops, and what limit 0 does 2026-07-31 23:35:16 +00:00
page_test.go docs(workapi): say where the shared epilogue stops, and what limit 0 does 2026-07-31 23:35:16 +00:00
query.go feat(query): put bd query behind the Querier role and stop it dropping matches (bd-pohmh) 2026-08-05 16:36:05 +00:00
query_test.go feat(query): put bd query behind the Querier role and stop it dropping matches (bd-pohmh) 2026-08-05 16:36:05 +00:00
race_detector_off_test.go feat(issueops): put bd purge and bd prune behind the Sweeper role (bd-pn231) 2026-08-05 16:40:26 +00:00
race_detector_on_test.go feat(issueops): put bd purge and bd prune behind the Sweeper role (bd-pn231) 2026-08-05 16:40:26 +00:00
ready.go feat(ready): put bd ready's published total behind the ReadyCounter role (bd-s10oa) 2026-08-05 09:47:24 +00:00
ready_count_test.go feat(ready): put bd ready's published total behind the ReadyCounter role (bd-s10oa) 2026-08-05 09:47:24 +00:00
ready_golden_test.go feat(issueops): add the Reader role and wire both front doors through it 2026-07-31 18:37:25 +00:00
ready_test.go feat(issueops): add the Reader role and wire both front doors through it 2026-07-31 18:37:25 +00:00
sort.go refactor(workapi): one execution epilogue for every list and ready read 2026-07-31 22:27:01 +00:00
stats.go feat(issueops): put bd status behind the StatsReporter role (bd-4ze25) 2026-08-05 09:27:16 +00:00
stats_test.go feat(issueops): put bd status behind the StatsReporter role (bd-4ze25) 2026-08-05 09:27:16 +00:00
sweep.go feat(issueops): put bd purge and bd prune behind the Sweeper role (bd-pn231) 2026-08-05 16:40:26 +00:00
sweep_test.go feat(issueops): put bd purge and bd prune behind the Sweeper role (bd-pn231) 2026-08-05 16:40:26 +00:00
versionreconcile.go feat(issueops): put the startup version reconciler behind the VersionReconciler role (bd-gkmft) 2026-08-05 16:35:01 +00:00
versionreconcile_test.go feat(issueops): put the startup version reconciler behind the VersionReconciler role (bd-gkmft) 2026-08-05 16:35:01 +00:00
workspaceconfig.go feat(config): put bd config's stored settings behind the WorkspaceConfig role (bd-kzepq) 2026-08-05 09:14:54 +00:00
workspaceconfig_test.go feat(config): put bd config's stored settings behind the WorkspaceConfig role (bd-kzepq) 2026-08-05 09:14:54 +00:00