drill: a move that closes inside a host's test is moving (#898 R1b)
Move is set only from prepare to close, so a whole move that began and closed between the bracket's two record reads was invisible to it. The drill-side identity now also carries a stamp of the record's LastMove (ID, outcome, close time, offline seconds), captured at the open and confirmed at the close. The same instance with another latest closed move is unverified, moving; a changed identity still outranks it. The stamp is the bracket's only: the published identity is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/ops/drillidentity.go+39 −12internal/ops/hibernate_verify.go+1 −1internal/ops/hibernate_verify_families_test.go+1 −1internal/ops/hibernate_verify_staging_test.go+40 −0internal/ops/hibernate_verify_test.go+7 −0
Intent
<task-notification> <task-id>a3f8adc202e230fa3</task-id> <tool-use-id>toolu_018HFE9LqCtBS21gN6Cz1fT5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ab362fc0-f177-4a7f-a92e-4a29ea210aad/tasks/a3f8adc202e230fa3.output</output-file> <status>completed</status> <summary>Agent "Fix 2a drill landing + read-only restore" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS. R1, R2 and R3 are fixed and committed on member-backups-2a-landing, not pushed. report.md was not written: the harness refuses report files from a subagent, so the full report (per item: changes, RED/GREEN commands and output) is ready to send when you ask. Commits: 4a9f46b4 R2 (restore read-only through the planner's listing), 2a6daefa R1 (drill checks for a staged copy under `moves/<host>/`, the same listing the first-wake promotion uses, at open and close; staged gives unverified/`moving`, an unreadable listing gives `storage_unavailable`), 06f609fe R3 (an empty region now means the home region; region matching stays exact), b6dd6e23 census proposal. Tests: RED was captured for each item (stale pass and false failed for R1, every level listed twice for R2, home box `NOT RUN` for R3); the targeted ops, lease and dbdoor tests now pass, gofmt and vet are clean, and the linux, darwin and windows builds pass. Census: proposal written (seal b130b2d6 → 677c2e52, one unit `hibernateRun.run` plus the ops, lease and dbdoor envelopes); TestPlan14RootReadCensus and TestPlan9B8RecordWriteCensus pass. Reviewer approval on #280 is still owed; I dispatched no reviewer. Concerns: 1. A partial staging delete after a promotion leaves the host `moving` every night, so the 3-run alert fires. I think that is the right signal, because a later cold wake would promote the leftover again. 2. A whole move that finishes inside one host's test is still invisible to both checks. It would take minutes against seconds per host; comparing `LastMove` in the bracket would close it. 3. The drill now lists `moves/` in the box's own data bucket. The activator already lists that prefix under the same role, but I did not test it live. Cost: a host now costs 12 LISTs instead of 20 (2 added by R1, 10 removed by R2), about 2,400 LISTs a night across the fleet. Every commit printed a `packed-refs.lock` "File exists" warning; the refs were written correctly, and the lock is another process's, so I left it.</result> <usage><subagent_tokens>245338</subagent_tokens><tool_uses>94</tool_uses><duration_ms>1008211</duration_ms></usage> </task-notification>
<task-notification> <task-id>ad34c2ecab73f571d</task-id> <tool-use-id>toolu_01Rh6ZJiB2F7T3brHXT7eDNh</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ab362fc0-f177-4a7f-a92e-4a29ea210aad/tasks/ad34c2ecab73f571d.output</output-file> <status>completed</status> <summary>Agent "Write slice 1b plan (download)" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>The plan now has 13 tasks (Task 0 to Task 12): the email task is gone and the MinIO witness and census tasks moved up to 11 and 12. It's still uncommitted. Changes beyond the two rulings: - **Where the preparing note lives:** the slice 1 copy record files `backups.preparing.note` under `internal/console/instancecopy.go`, not `internal/backupswords`, because only the page shows it. The new Task 0 Step 2 therefore updates the record's text, adds the 2026-11-12 re-approval note and keeps it pending. Task 10 then puts the string in `instancecopy.go`. - **Pinned test:** `approved_member_backups_copy_test.go` pins ids, not text, so the test itself doesn't change. The step just reruns it. - **Email leftovers removed:** the `notified` column is out of the `db_downloads` table, and email is gone from the copy drafts and Review Focus item 5. The URL constraint now says there are no download emails. - **Task 3 tests:** besides the two required proofs (`TestHomeScopeNeverQueryOrPull`, `TestNonHomeUnchanged`), the non-home proof also checks that `forwardable` still refuses home records. Its test command now includes `./internal/console` for that. - **Fable reviews Task 3 twice:** once as a task review before Task 4 starts, and again in the whole-branch review. - **Header:** "Decisions needed" is now "Paul's rulings (2026-11-12)", Task 0's step that put the decisions to Paul is gone, and the plan is marked rev 1.1.</result> <usage><subagent_tokens>315086</subagent_tokens><tool_uses>5</tool_uses><duration_ms>61321</duration_ms></usage> </task-notification>
diff --git a/internal/ops/drillidentity.go b/internal/ops/drillidentity.go| index 28da68058..e80ea90cd 100644 |
| --- a/internal/ops/drillidentity.go |
| +++ b/internal/ops/drillidentity.go |
| @@ -39,6 +39,28 @@ type drillRecord struct { |
| account, app, host, region string |
| created time.Time |
| moving bool |
| + lastMove string // moveStamp of the record's LastMove |
| +} |
| + |
| +// drillIdentity is what the bracket captures at its open and confirms at |
| +// its close: the instance's identity, which the verdict publishes, and a |
| +// stamp of the record's latest closed move, which only the bracket sees. |
| +// Move is set only from a move's prepare to its close, so a whole move |
| +// that began and closed between the two reads (R1b) is seen only because |
| +// its close left a new outcome in LastMove. |
| +type drillIdentity struct { |
| + dbreads.Identity |
| + lastMove string |
| +} |
| + |
| +// moveStamp is the record's latest closed move, every field of it ("" when |
| +// it has none): a different move, outcome or close time is a different |
| +// stamp. |
| +func moveStamp(m *provision.MoveOutcome) string { |
| + if m == nil { |
| + return "" |
| + } |
| + return fmt.Sprintf("%q %q %s %g", m.ID, m.Outcome, m.At.UTC().Format(time.RFC3339Nano), m.OfflineS) |
| } |
| // captureDrillIdentity is the opening half of the drill's bracket: the |
| @@ -49,23 +71,24 @@ type drillRecord struct { |
| // its placement); dbreads.CodeMoving, with the identity, when the instance |
| // is mid-move. detail says why for a code. err is a record that could not |
| // be read or whose identity cannot be computed. |
| -func captureDrillIdentity(ctx context.Context, s release.Store, region string, rt HibernatingRoute) (id dbreads.Identity, code, detail string, err error) { |
| +func captureDrillIdentity(ctx context.Context, s release.Store, region string, rt HibernatingRoute) (id drillIdentity, code, detail string, err error) { |
| rec, detail, err := readDrillRecord(ctx, s, rt) |
| if err != nil || detail != "" { |
| if detail != "" { |
| - return dbreads.Identity{}, codeNoRecord, detail, nil |
| + return drillIdentity{}, codeNoRecord, detail, nil |
| } |
| - return dbreads.Identity{}, "", "", err |
| + return drillIdentity{}, "", "", err |
| } |
| if rec.region != region { |
| - return dbreads.Identity{}, codeNoRecord, |
| + return drillIdentity{}, codeNoRecord, |
| fmt.Sprintf("its record places it in %q, not this box's %q", rec.region, region), nil |
| } |
| inc, err := provision.Incarnation(rec.account, rec.app, rec.host, rec.created) |
| if err != nil { |
| - return dbreads.Identity{}, "", "", fmt.Errorf("the record's identity: %w", err) |
| + return drillIdentity{}, "", "", fmt.Errorf("the record's identity: %w", err) |
| } |
| - id = dbreads.Identity{Account: rec.account, App: rec.app, Host: rec.host, Region: region, Incarnation: inc} |
| + id = drillIdentity{Identity: dbreads.Identity{Account: rec.account, App: rec.app, Host: rec.host, Region: region, Incarnation: inc}, |
| + lastMove: rec.lastMove} |
| if rec.moving { |
| return id, dbreads.CodeMoving, "", nil |
| } |
| @@ -73,16 +96,20 @@ func captureDrillIdentity(ctx context.Context, s release.Store, region string, r |
| } |
| // confirmDrillIdentity is the closing half: captureDrillIdentity again for |
| -// want's host, and dbreads.CodeRecordChanged unless it finds want. A record |
| -// that has gone (or left this region) since the bracket opened is |
| -// CodeRecordChanged, never codeNoRecord, and a change outranks a move. |
| -func confirmDrillIdentity(ctx context.Context, s release.Store, rt HibernatingRoute, want dbreads.Identity) (code string, err error) { |
| +// want's host, and dbreads.CodeRecordChanged unless it finds want's |
| +// identity. A record that has gone (or left this region) since the |
| +// bracket opened is CodeRecordChanged, never codeNoRecord, and a change |
| +// outranks a move. The same identity with another latest closed move is |
| +// dbreads.CodeMoving: a whole move ran inside the test (R1b). |
| +func confirmDrillIdentity(ctx context.Context, s release.Store, rt HibernatingRoute, want drillIdentity) (code string, err error) { |
| got, code, _, err := captureDrillIdentity(ctx, s, want.Region, rt) |
| switch { |
| case err != nil: |
| return "", err |
| - case code == codeNoRecord, got != want: |
| + case code == codeNoRecord, got.Identity != want.Identity: |
| return dbreads.CodeRecordChanged, nil |
| + case code == "" && got.lastMove != want.lastMove: |
| + return dbreads.CodeMoving, nil |
| } |
| return code, nil |
| } |
| @@ -99,7 +126,7 @@ func readDrillRecord(ctx context.Context, s release.Store, rt HibernatingRoute) |
| return drillRecord{}, "", err |
| } |
| return drillRecord{account: rec.Account, app: rec.App, host: rec.Host, region: rec.Region, |
| - created: rec.CreatedAt, moving: rec.Move != nil}, "", nil |
| + created: rec.CreatedAt, moving: rec.Move != nil, lastMove: moveStamp(rec.LastMove)}, "", nil |
| } |
| name, ok := sidecarName(rt.Host) |
| if !ok { |
diff --git a/internal/ops/hibernate_verify.go b/internal/ops/hibernate_verify.go| index 2dfcb76b3..ce0bd223d 100644 |
| --- a/internal/ops/hibernate_verify.go |
| +++ b/internal/ops/hibernate_verify.go |
| @@ -397,7 +397,7 @@ func (d Drill) drillOne(ctx context.Context, rt HibernatingRoute, now func() tim |
| } |
| return unverified(ReasonRecordUnreadable, err.Error()) |
| } |
| - v.Identity = dbverify.Identity(id) |
| + v.Identity = dbverify.Identity(id.Identity) |
| switch code { |
| case codeNoRecord: |
| // No record of the host's family in this region when the test |
diff --git a/internal/ops/hibernate_verify_families_test.go b/internal/ops/hibernate_verify_families_test.go| index 800a4eb2f..78f051ace 100644 |
| --- a/internal/ops/hibernate_verify_families_test.go |
| +++ b/internal/ops/hibernate_verify_families_test.go |
| @@ -228,7 +228,7 @@ func TestDrillIdentityLeavesTheDbReadRuleAlone(t *testing.T) { |
| } |
| id, code, _, err := captureDrillIdentity(context.Background(), fx.store, fxRegion, |
| HibernatingRoute{Host: "resident.example.com", Account: fxAccount, App: fxApp}) |
| - if err != nil || code != "" || dbverify.Identity(id) != idFor(t, "resident.example.com", fxRegion, fxCreated) { |
| + if err != nil || code != "" || dbverify.Identity(id.Identity) != idFor(t, "resident.example.com", fxRegion, fxCreated) { |
| t.Fatalf("captureDrillIdentity = %+v, %q, %v", id, code, err) |
| } |
| } |
diff --git a/internal/ops/hibernate_verify_staging_test.go b/internal/ops/hibernate_verify_staging_test.go| index 31831b3ef..7a0864a3a 100644 |
| --- a/internal/ops/hibernate_verify_staging_test.go |
| +++ b/internal/ops/hibernate_verify_staging_test.go |
| @@ -8,11 +8,13 @@ import ( |
| "os" |
| "path/filepath" |
| "testing" |
| + "time" |
| "github.com/carlosframework/platform/internal/activator" |
| "github.com/carlosframework/platform/internal/dbdoor" |
| "github.com/carlosframework/platform/internal/dbverify" |
| "github.com/carlosframework/platform/internal/lease" |
| + "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| @@ -262,3 +264,41 @@ func TestDrillStagingUnreadableIsNeverAPass(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +// R1b: the bracket carries the record's latest closed move (LastMove). A |
| +// LastMove already there when the test began is history and changes |
| +// nothing; one replaced by another move's outcome during the test means a |
| +// whole move ran inside it, which is moving. |
| +func TestDrillBracketSeesACompletedMove(t *testing.T) { |
| + const host = "a.example.com" |
| + earlier := &provision.MoveOutcome{ID: "mv_old", Outcome: "done", At: time.Date(2026, 10, 1, 0, 0, 0, 0, time.UTC)} |
| + for name, c := range map[string]struct { |
| + during *provision.MoveOutcome // LastMove written while the restore runs; nil leaves it |
| + result string |
| + reason string |
| + }{ |
| + "history at rest": {nil, dbverify.ResultPassed, ""}, |
| + "another move closed": {&provision.MoveOutcome{ID: "mv_new", Outcome: "done", At: time.Date(2026, 11, 12, 3, 0, 30, 0, time.UTC)}, |
| + dbverify.ResultUnverified, ReasonMoving}, |
| + "a move rolled back": {&provision.MoveOutcome{ID: "mv_new", Outcome: "rolled_back", At: time.Date(2026, 11, 12, 3, 0, 30, 0, time.UTC)}, |
| + dbverify.ResultUnverified, ReasonMoving}, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + fx := newDrillFx(t) |
| + fx.putRecord(fxAccount, host, fxCreated, func(r *provision.Record) { r.LastMove = earlier }) |
| + fx.stubVerify(func(context.Context, string, string, uint64) (uint32, error) { |
| + if c.during != nil { |
| + fx.putRecord(fxAccount, host, fxCreated, func(r *provision.Record) { r.LastMove = c.during }) |
| + } |
| + return 1, nil |
| + }) |
| + v := fx.run(context.Background(), fx.drill(), fx.routes(host), nil)[host] |
| + if v.Result != c.result || v.Reason != c.reason { |
| + t.Fatalf("verdict %s/%s, want %s/%s (%+v)", v.Result, v.Reason, c.result, c.reason, v) |
| + } |
| + if want := idFor(t, host, fxRegion, fxCreated); v.Identity != want { |
| + t.Fatalf("published identity %+v, want %+v: the move stamp is the bracket's, not the verdict's", v.Identity, want) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/ops/hibernate_verify_test.go b/internal/ops/hibernate_verify_test.go| index a0736fc92..f15c8074b 100644 |
| --- a/internal/ops/hibernate_verify_test.go |
| +++ b/internal/ops/hibernate_verify_test.go |
| @@ -629,6 +629,13 @@ func TestVerifyHibernatingBracket(t *testing.T) { |
| r.Move = &provision.MoveState{ID: "mv_x", To: "ie", State: "requested"} |
| }) |
| }, ReasonMoving}, |
| + // A whole move began and closed inside the test (R1b): Move was |
| + // never seen, but the close left its outcome in LastMove. |
| + "a move completed": {func(fx *drillFx) { |
| + fx.putRecord(fxAccount, host, time.Date(2026, 9, 1, 0, 0, 0, 0, time.UTC), func(r *provision.Record) { |
| + r.LastMove = &provision.MoveOutcome{ID: "mv_x", Outcome: "done", At: time.Date(2026, 11, 12, 3, 0, 30, 0, time.UTC)} |
| + }) |
| + }, ReasonMoving}, |
| } |
| outcomes := map[string]struct { |
| empty bool |