* fix(is_blocked): cross-mode full recompute repair for stale is_blocked (bd-6dnrw.37) The post-pull is_blocked recompute (bd-6dnrw.3) is scoped to the merge diff and skips when a re-pull merges nothing (HEAD unchanged), so a recompute that failed AFTER its merge committed — or a conflicted pull resolved by hand (which skips the recompute) — left is_blocked stale with no repair: rerunning bd dolt pull merged nothing and recomputed nothing. bd ready trusts is_blocked, so stale values silently hide ready work or surface blocked work. Core (internal/storage/issueops/blocked_consistency.go): - RecomputeAllIsBlockedInTx: full mark/unmark fixpoint over every issue+wisp, returns rows corrected. Idempotent. Reuses the existing pass functions. - CountIsBlockedInconsistenciesInTx: read-only COUNT of stale rows for detection. Its predicate mirrors the mark/unmark templates and is pinned to the repair by the dolt-package lockstep tests (a converged DB counts 0; any counted row is one a recompute pass flips), so detection cannot silently drift from repair. Cross-mode repair: - storage.BlockedRecomputer capability; DoltStore + EmbeddedDoltStore RecomputeAllBlocked (stage issues-only, matching the post-pull recompute). - New 'bd recompute-blocked' command — works in BOTH embedded and server mode. bd doctor is server-mode only, so embedded users need a non-doctor entry point. - bd doctor (server mode) gains a read-only "Blocked State" check and a 'bd doctor --fix' dispatch running the same repair. Warn-only (does not fail OverallOK): new check shipping in a patch, is_blocked self-heals via the fix. Secondary item (server recomputeBlockedAfterPull commits via s.Commit, which can sweep a concurrent writer's changes) split to bd-6y5hx (P3, deferred): it is subtle (after an auto-resolved merge the working set holds the whole merge result, so a naive issues-only narrowing would drop merge results). The embedded path already stages issues-only; the new repair path stages issues-only too. Tests: 3 dolt lockstep tests (detect==repair, stuck-blocked, parent-child cascade) + embedded wiring test. Smoke-tested on a real ~2000-issue embedded DB: 0 false positives. build/vet/gofmt/golangci-lint all clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: regenerate CLI reference for `bd recompute-blocked` Run ./scripts/generate-cli-docs.sh + ./scripts/generate-llms-full.sh with the canonical CGO_ENABLED=0 gms_pure_go build to pick up the new `bd recompute-blocked` command. The adopted PR added the command but did not regenerate the CLI docs, failing the PR doc-flags freshness checks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(is_blocked): guard full recompute against dirty graph; pin doctor blocked-state last Maintainer adoption fixes for PR #4423 review (bd-6dnrw.37): - Refuse a full is_blocked recompute when the committable graph tables (issues, dependencies) carry uncommitted working-set changes, across the server, embedded, and doctor-fix paths. The recompute derives flags from the current graph and stages only `issues`, so running it dirty would sweep unrelated issue edits into the repair commit or publish is_blocked derived from uncommitted dependency state. Dolt-ignored wisp tables are deliberately excluded from the guard: they are never committed and show as perpetually modified in dolt_status, so guarding on them would refuse the recompute in any workspace that uses wisps. - Pin the doctor "Blocked State" fix to an explicit terminal priority so it provably runs after every graph-mutating fix (Dependency Keys, Orphaned/Child-Parent Dependencies, Cross-Table Duplicates) instead of relying on check-append order. This fixes a stale is_blocked left after `bd doctor --fix --fix-child-parent` removed a child-parent edge. - Surface (no longer swallow) the doctor-fix Dolt stage/commit errors, and tolerate only the benign nothing-to-commit case. Tests: dirty-issues and dirty-dependencies refusal, dirty-wisps still repairs, clean repair+commit idempotence (dolt server-mode); fix-ordering regression covering the --fix-child-parent case (cmd/bd); embedded wiring test now commits its seed to match the fresh-process clean-tree precondition. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Eddie the Engineer <ci@beads.test>
81 lines
2.9 KiB
Go
81 lines
2.9 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func fixNames(fixes []doctorCheck) []string {
|
|
out := make([]string, len(fixes))
|
|
for i, f := range fixes {
|
|
out[i] = f.Name
|
|
}
|
|
return out
|
|
}
|
|
|
|
// TestOrderDoctorFixes_BlockedStateRunsAfterGraphFixes guards bd-6dnrw.37: the
|
|
// full is_blocked recompute ("Blocked State") must be applied after every
|
|
// graph-mutating doctor fix so it recomputes from the corrected graph. The
|
|
// regression it pins: removing a child→parent dependency under
|
|
// `bd doctor --fix --fix-child-parent` unblocks the child, so a Blocked State
|
|
// recompute ordered before that cleanup would leave is_blocked stale.
|
|
func TestOrderDoctorFixes_BlockedStateRunsAfterGraphFixes(t *testing.T) {
|
|
// Append order that previously mis-ordered the recompute: Blocked State is
|
|
// appended before the dependency-graph fixes that can unblock issues.
|
|
fixes := []doctorCheck{
|
|
{Name: "Dependency Keys"},
|
|
{Name: "Blocked State"},
|
|
{Name: "Orphaned Dependencies"},
|
|
{Name: "Child-Parent Dependencies"},
|
|
{Name: "Cross-Table Duplicates"},
|
|
}
|
|
orderDoctorFixes(fixes)
|
|
|
|
pos := make(map[string]int, len(fixes))
|
|
for i, f := range fixes {
|
|
pos[f.Name] = i
|
|
}
|
|
for _, name := range []string{
|
|
"Dependency Keys",
|
|
"Orphaned Dependencies",
|
|
"Child-Parent Dependencies",
|
|
"Cross-Table Duplicates",
|
|
} {
|
|
if pos["Blocked State"] < pos[name] {
|
|
t.Errorf("Blocked State (pos %d) must run after %s (pos %d); order=%v",
|
|
pos["Blocked State"], name, pos[name], fixNames(fixes))
|
|
}
|
|
}
|
|
if got := fixes[len(fixes)-1].Name; got != "Blocked State" {
|
|
t.Errorf("Blocked State must be last among graph fixes, got last=%q order=%v",
|
|
got, fixNames(fixes))
|
|
}
|
|
}
|
|
|
|
// TestOrderDoctorFixes_BlockedStateStaysLastWhenGraphFixAppendedAfter pins the
|
|
// robustness that terminal-priority ordering buys over relying on check-append
|
|
// order: a graph-mutating fix appended *after* Blocked State (the original
|
|
// latent bug) must still run before the recompute.
|
|
func TestOrderDoctorFixes_BlockedStateStaysLastWhenGraphFixAppendedAfter(t *testing.T) {
|
|
fixes := []doctorCheck{
|
|
{Name: "Blocked State"},
|
|
{Name: "Future Graph Fix"}, // unlisted, shares the default priority
|
|
{Name: "Child-Parent Dependencies"},
|
|
}
|
|
orderDoctorFixes(fixes)
|
|
if got := fixes[len(fixes)-1].Name; got != "Blocked State" {
|
|
t.Errorf("Blocked State must remain last even when a graph fix is appended after it; got last=%q order=%v",
|
|
got, fixNames(fixes))
|
|
}
|
|
}
|
|
|
|
// TestOrderDoctorFixes_EarlyFixesStillSortFirst is a guardrail that pinning
|
|
// Blocked State terminal did not disturb the explicitly-ordered early fixes.
|
|
func TestOrderDoctorFixes_EarlyFixesStillSortFirst(t *testing.T) {
|
|
fixes := []doctorCheck{
|
|
{Name: "Blocked State"},
|
|
{Name: "Permissions"},
|
|
{Name: "Gitignore"},
|
|
}
|
|
orderDoctorFixes(fixes)
|
|
if fixes[0].Name != "Gitignore" || fixes[1].Name != "Permissions" {
|
|
t.Errorf("early ordered fixes must sort ahead of Blocked State; order=%v", fixNames(fixes))
|
|
}
|
|
}
|