beads/internal/storage/issueops
Steve Yegge 5a4c68a89c fix(leases): keep node_id off the committed config; tighten the replica guard (wy-jpd3.7)
Second adversarial review of the replica-aware lease work, against the opt-in
rewrite. One blocker, in the operating instruction rather than the code.

node_id was documented as "BEADS_NODE_ID, or node_id in config.yaml", and
`bd config set node_id` wrote the PROJECT .beads/config.yaml — a git-TRACKED
file (nothing in .beads/.gitignore excludes it). Commit "node_id: mini" and
every clone that pulls reads "mini", so every granted_node comparison matches
and the guard is at once fully ARMED and fully INERT: laptop reaps mini's
leases exactly as if they were local. That is the precise hazard the feature
exists to close, now happening while the operator believes they are protected
— strictly worse than the pre-feature state, where nobody thought they were.
node_id is per-machine state, the class .beads/.gitignore already excludes as
sync-state.json / push-state.json / redirect. It now routes to the user-global
~/.config/bd/config.yaml through a new exact-key arm of IsUserGlobalKey (the
prefix list only ever held "metrics."); viper already merges that file, so
config.NodeID() reads it straight back.

The docs also said to set it "on every replica sharing the queue", which on a
shared or remote dolt sql-server means every HOST — rebuilding the same
fail-closed regression this commit's parent removed the hostname fallback to
avoid. The load-bearing rule was never stated: node_id names the STORE, not
the host. Clients of one sql-server are ONE replica and must share a value or
leave it unset. Now said outright in federation.md and `bd reclaim --help`.

Also from the review:
- bd show claimed "reclaim will decline it" for any foreign node, but with an
  unnamed local node the guard is disarmed and reclaim reverts the lease
  happily. The annotation is now gated on config.NodeID() != "".
- TestNodeIDContextOverride's empty-override assertion had gone tautological
  when the hostname fallback went away: config.NodeID() is "" under test, so
  it passed whether or not WithNodeID worked at all. It now sets a non-empty
  fallback, asserts the fallback is what a no-override read returns, and only
  then asserts the empty override still beats it.
- The heartbeat backfill's bare `granted_node = ''` is COALESCE'd, matching
  the reclaim predicates; under NULL the IF took the else branch and the row
  was never backfilled. Unreachable today (0016 is NOT NULL DEFAULT ''), but
  the two sites disagreed about whether NULL was possible.
- The --any-replica audit line is skipped when localNode is "" rather than
  printing `not this node ("")`: nothing was overridden, the guard was never
  armed.
- reclaimReplicaSQL documents WHY granted_node stays unqualified — the DELETE
  splices it into a bare `DELETE FROM leases` with no alias to qualify with —
  and what to do if issues ever grows a column of that name.
- CHANGELOG entry, which this feature owed: a new flag, a new config key, two
  env vars, and two public struct fields shipped without one.
2026-07-25 02:32:31 -07:00
..
as_of.go /{cmd,internal}: bd show proxied-server mode 2026-06-17 13:29:24 -07:00
batching.go /{cmd,internal}: cleanup 2026-05-22 13:04:38 -07:00
batching_test.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
blocked.go /{cmd,internal}: bd ready proxied-server 2026-06-18 13:00:57 -07:00
blocked_consistency.go fix(is_blocked): cross-mode full recompute repair for stale is_blocked (bd-6dnrw.37) (#4423) 2026-06-19 23:14:09 -07:00
blocked_merge.go fix(is_blocked): cross-mode full recompute repair for stale is_blocked (bd-6dnrw.37) (#4423) 2026-06-19 23:14:09 -07:00
blocked_state.go fix(create): close review findings in --graph waits-for gates and validation 2026-07-18 11:52:37 -07:00
bulk_ops.go feat(leases): move leases to ephemeral dolt_ignored leases table (bd-lrgn1) 2026-07-17 01:02:29 -07:00
child_id.go /internal/storage: remove dual tx 2026-05-15 12:07:41 -07:00
claim.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
close.go feat(engine): guarded write ops — atomic metadata merge, row-version CAS, typed dep errors + events, bd close delegation (#4911) 2026-07-21 18:13:03 -07:00
comments.go feat(storage): keyset reads — comments page, issue-list cursor, IsBlocked filter (#4922) 2026-07-21 22:29:09 -07:00
commit_pending.go /{cmd,internal}: refactor again 2026-03-17 18:11:37 -07:00
compaction.go fix(compact): archive content before destructive compaction; make restore work (#4464) 2026-06-20 14:12:07 -07:00
config_helpers.go /{cmd,internal}: bd ready proxied-server 2026-06-18 13:00:57 -07:00
config_helpers_test.go feat(storage): honor .beads/config.yaml types.custom in server-side validation (#4024) (#4026) 2026-05-21 10:26:53 -07:00
config_metadata.go /{cmd,internal}: bd ready proxied-server 2026-06-18 13:00:57 -07:00
count.go more commands 2026-07-20 14:41:07 -07:00
create.go fix(import): allow children of deleted parents (#4964) 2026-07-22 21:20:37 -07:00
create_test.go fix(import): allow children of deleted parents (#4964) 2026-07-22 21:20:37 -07:00
cycles.go fix(deps): enforce combined cycles across storage paths 2026-07-13 13:50:07 -07:00
cycles_test.go fix(deps): bulk cycle gate blocks only cycles that traverse a new edge (bd-578h9.9) 2026-06-11 15:21:33 -04:00
delete.go feat(leases): move leases to ephemeral dolt_ignored leases table (bd-lrgn1) 2026-07-17 01:02:29 -07:00
dep_counts.go /{cmd,internal}: bd show proxied-server mode 2026-06-17 13:29:24 -07:00
dependencies.go feat(storage): events + dependents reads, batched blocked, public claim surface (#4926) 2026-07-22 07:41:47 -07:00
dependencies_test.go feat(errors): typed dependency error taxonomy on the public beads package (#4892) 2026-07-18 18:29:07 -07:00
dependency_queries.go feat(storage): events + dependents reads, batched blocked, public claim surface (#4926) 2026-07-22 07:41:47 -07:00
dependency_queries_test.go fix(storage): preserve mixed issue and wisp reads (#3991) 2026-05-21 06:50:42 -07:00
dependency_tree.go /{cmd,internal}: bd dep proxied-server 2026-06-18 15:44:45 -07:00
dependency_tree_test.go feat(leases): move leases to ephemeral dolt_ignored leases table (bd-lrgn1) 2026-07-17 01:02:29 -07:00
diff.go /internal/storage/{dolt,embeddeddolt,issueops}: implement methods 2026-03-20 11:46:28 -07:00
epic_closure.go more commands 2026-07-20 14:41:07 -07:00
errors.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
events.go feat(storage): events + dependents reads, batched blocked, public claim surface (#4926) 2026-07-22 07:41:47 -07:00
federation.go /{cmd,internal}: wip sync and data EmbeddedDoltStore methods 2026-03-24 12:01:16 -07:00
filters.go refactor(storage): extract shared SQL builders into internal/storage/sqlbuild (bd-6dnrw.46) 2026-06-12 15:56:23 -04:00
filters_test.go fix(filters): Dolt label-filter regression fix — LabelPattern + LabelRegex + JSON truncation hint suppression (#3971) 2026-07-24 00:17:02 -07:00
get_issue.go feat(leases): move leases to ephemeral dolt_ignored leases table (bd-lrgn1) 2026-07-17 01:02:29 -07:00
helpers.go Reapply "Simplify the supported backends: roll back the direct PostgreSQL and MySQL adapters" (#4857) 2026-07-18 02:43:56 +00:00
helpers_test.go feat(create): add status flag for initial issue status (#4536) 2026-07-05 11:15:48 -07:00
history.go more commands 2026-07-20 14:41:07 -07:00
labels.go feat(validate): typed length bounds for assignee, owner, and label (#4894) 2026-07-19 23:03:07 -07:00
lease.go fix(leases): keep node_id off the committed config; tighten the replica guard (wy-jpd3.7) 2026-07-25 02:32:31 -07:00
lease_replica_test.go fix(leases): keep node_id off the committed config; tighten the replica guard (wy-jpd3.7) 2026-07-25 02:32:31 -07:00
metadata.go feat(engine): guarded write ops — atomic metadata merge, row-version CAS, typed dep errors + events, bd close delegation (#4911) 2026-07-21 18:13:03 -07:00
metadata_test.go feat(engine): guarded write ops — atomic metadata merge, row-version CAS, typed dep errors + events, bd close delegation (#4911) 2026-07-21 18:13:03 -07:00
molecule.go /{cmd,internal}: remove depends_on_id 2026-05-19 10:17:49 -07:00
promote.go fix(import): stale-rejected rows no longer persist aux data or count as Created (bd-578h9.8) 2026-06-11 15:12:10 -04:00
ready_work.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
ready_work_counts.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
ready_work_test.go fix: prefer wisp on cross-table dup; add CGO-free duplicate check (be-iabdi) (#4163) 2026-06-19 10:49:30 -07:00
reopen.go /{cmd,internal}: reopen 2026-06-17 16:56:56 -07:00
scan.go feat(leases): replica-aware leases — record the granting node, refuse cross-replica reclaim (wy-jpd3.7) 2026-07-24 23:53:34 -07:00
search.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
search_counts.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
search_counts_test.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
search_test.go test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160) 2026-07-24 01:40:36 -07:00
stale.go more commands 2026-07-20 14:41:07 -07:00
statistics.go feat(stats): --no-blocked flag skips blocked-count computation; fix Blocked:0 red render (be-nnqp, be-4b63) (#4022) 2026-07-23 23:52:39 -07:00
unclaim.go more commands 2026-07-20 14:41:07 -07:00
update.go feat(validate): typed length bounds for assignee, owner, and label (#4894) 2026-07-19 23:03:07 -07:00
update_cas.go feat(update): conditional compare-and-set guards --if-assignee/--if-status (bd-wsqvw) (#5008) 2026-07-24 09:11:15 -07:00
update_test.go feat(leases): move leases to ephemeral dolt_ignored leases table (bd-lrgn1) 2026-07-17 01:02:29 -07:00
version.go feat(engine): guarded write ops — atomic metadata merge, row-version CAS, typed dep errors + events, bd close delegation (#4911) 2026-07-21 18:13:03 -07:00
wisp_filter_convert.go feat: add ListWisps method to Storage interface (fix-merge PR #2783) 2026-03-26 19:33:28 -07:00
wisp_routing.go /{cmd,internal}: bd close proxied-server 2026-06-17 15:05:41 -07:00
wisp_routing_test.go perf(storage): amortize per-ID wisp routing via WispIDSetInTx (#3453) 2026-04-24 13:39:42 -07:00