H3-M6: stamp staged moves the rule checked; record the move sentences
Astra's census-round P1: the staging exemption trusted any staged move to the same destination, including one an older console staged over a deleted record's moves/<host>/. The stage door now stamps the move (MoveState.StageChecked, through StageTarget.Checked) with the destination the shared rule just passed for, and only a stamped move's own staging prefix is exempt at restage and start. An unstamped staged move into this console's sight is refused: abort and stage again. CI: the rule is split into dataTransferVerdict and its wordings. The move doors word their refusals whole in moveleftovers.go, now in movesScanFiles, with pending rows MV-O205 to MV-O211 in the moves copy record (recorded, not approved). The create rail passes a transferRec, so it builds no provision.Record literal (TestCopySincePathInventory).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 files changed,
+204
−74
approved_moves_copy_test.go+3 −0docs/superpowers/plans/2026-10-06-moves-phase1-copy.md+14 −0internal/console/apiinstancemove.go+2 −2internal/console/apiinstancemove_offline.go+6 −2internal/console/createleftovers.go+1 −2internal/console/datatransfer.go+90 −49internal/console/datatransfer_guard_test.go+5 −4internal/console/fleets.go+2 −2internal/console/moveleftovers.go+41 −12internal/console/moveleftovers_h3m6_test.go+25 −0internal/provision/offline_move.go+7 −1internal/provision/provision.go+8 −0
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go| index 908f5f610..b16d82f30 100644 |
| --- a/approved_moves_copy_test.go |
| +++ b/approved_moves_copy_test.go |
| @@ -114,6 +114,7 @@ var movesCopyIDs = []string{ |
| // #339: refused while the instance still serves, and status after an |
| // abort from staging. |
| "MV-O200", "MV-O202", "MV-O203", "MV-O204", |
| + "MV-O205", "MV-O206", "MV-O207", "MV-O208", "MV-O209", "MV-O210", "MV-O211", |
| // carlos move offline run (plans/2026-11-15-offline-move-run.md, Task 5; |
| // deck docs/drafts/offline-move-run/copy-review/strings.json). |
| "OR01", "OR02", "OR03", "OR04", "OR05", "OR06", "OR07", |
| @@ -1235,6 +1236,8 @@ var movesScanFiles = []string{ |
| "internal/console/movesrecovery.go", |
| "internal/console/apiinstancemove_offline.go", |
| "internal/console/apiinstancemove_offline_facts.go", |
| + // Hunt H3-M6: the move doors' sentences for the shared data-transfer rule. |
| + "internal/console/moveleftovers.go", |
| "internal/console/claim_runtime.go", |
| "internal/alerting/alerting.go", |
| "internal/hostops/move_log_writer.go", |
diff --git a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md| index 6333b4509..1ea6a8e6b 100644 |
| --- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| +++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| @@ -825,3 +825,17 @@ Sentences the fixes for Astra's whole-branch review of `offline-move-run` (round |
| | OR75 | move.go | Copy failed | approved | |
| | OR76 | move_offline_run.go | Stopped staging after <tries> tries without starting a round. <host> keeps serving and nothing went offline. | approved | |
| | OR77 | docs/site/cli.md | refused before anything was written: by the console, at the first status read or the first stage (`--resume` included), or by `carlos` itself (run as root, or with no console) | approved | |
| + |
| +## Moves: the shared data-transfer rule (hunt H3-M6) |
| + |
| +The move doors' refusals from the shared data-transfer rule (`internal/console/moveleftovers.go`, branch `sec-h3-m6-leftover-host`). The legacy and Phase 1 requests and the offline start and stage all ask it before their first write. `<host>` is the instance and `<to>` the destination's label. MV-O205 is a destination in this console's sight whose bucket already holds data for the host (it may be the instance's own earlier copy). MV-O206 is the 503 when that bucket cannot be read. MV-O207 to MV-O210 are out of sight: the history is not active, it can never be completed on this console, the destination was not examined or has changed, and the history or roster cannot be read. MV-O211 is a staged move that an older console staged without the rule's check. These rows are pending copy review; recording them is not approval. |
| + |
| +| id | file | text | status | |
| +|---|---|---|---| |
| +| MV-O205 | internal/console/moveleftovers.go | <host> can't move to <to>: <host> already has data in <to>. An operator has to look at it before this can go ahead. | pending | |
| +| MV-O206 | internal/console/moveleftovers.go | <host> can't move to <to>: the data in <to> could not be checked. Try again. | pending | |
| +| MV-O207 | internal/console/moveleftovers.go | <host> can't move to <to>: this console can't check <to> for data a deleted record left under <host>. An operator can allow it by completing the hostname history (console hosts-used) with <to> scanned. | pending | |
| +| MV-O208 | internal/console/moveleftovers.go | <host> can't move to <to>: this console can't check <to> for data a deleted record left under <host>, and its hostname history can't be completed while host claims or Phase 1 moves are on. | pending | |
| +| MV-O209 | internal/console/moveleftovers.go | <host> can't move to <to>: <to> was not scanned when the hostname history was completed, or its boxes or data bucket have changed since. An operator can allow it by completing the history again with <to> scanned. | pending | |
| +| MV-O210 | internal/console/moveleftovers.go | <host> can't move to <to>: the hostname history, or what <to> runs on, could not be read. Try again. | pending | |
| +| MV-O211 | internal/console/moveleftovers.go | <host> was staged for <to> before this console checked <to> for data left under it. Abort the move and stage it again. | pending | |
diff --git a/internal/console/apiinstancemove.go b/internal/console/apiinstancemove.go| index bb08ad0d0..ce1625430 100644 |
| --- a/internal/console/apiinstancemove.go |
| +++ b/internal/console/apiinstancemove.go |
| @@ -474,7 +474,7 @@ func (s *Server) legacyHandleAPIInstanceMoveRequest(w http.ResponseWriter, r *ht |
| } |
| // The shared data-transfer rule (H3-M6, datatransfer.go). |
| if ref := s.moveTransferRefusal(r.Context(), "api instance move "+acct.Sqid+"/"+app, rec, to); ref != nil { |
| - jsonError(w, ref.Status, ref.Msg) |
| + writeRefusal(w, ref) |
| return |
| } |
| // The armed gate is MANDATORY for moves — unlike create there is no |
| @@ -672,7 +672,7 @@ func (s *Server) handleAPIInstanceMoveRequest(w http.ResponseWriter, r *http.Req |
| // The shared data-transfer rule (H3-M6, datatransfer.go), before any policy |
| // read or claim write. |
| if ref := s.moveTransferRefusal(ctx, "api instance move "+acct.Sqid+"/"+app, rec, to); ref != nil { |
| - jsonError(w, ref.Status, ref.Msg) |
| + writeRefusal(w, ref) |
| return |
| } |
| // Both policy reads fail closed (round-4 finding 13): an unreadable |
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go| index 6cd57f288..72449c02b 100644 |
| --- a/internal/console/apiinstancemove_offline.go |
| +++ b/internal/console/apiinstancemove_offline.go |
| @@ -678,7 +678,7 @@ func (s *Server) offlineBeginChecks(w http.ResponseWriter, r *http.Request, d of |
| } |
| // The shared data-transfer rule (H3-M6, datatransfer.go): start and stage alike. |
| if ref := s.moveTransferRefusal(ctx, "offline move "+d.acct.Sqid+"/"+d.app, rec, to); ref != nil { |
| - jsonError(w, ref.Status, ref.Msg) |
| + writeRefusal(w, ref) |
| return "", offlineFleet{}, false, false |
| } |
| m, err := provision.GetManifest(ctx, s.cfg.Releases, d.acct.Sqid, d.app) |
| @@ -855,7 +855,11 @@ func (s *Server) handleAPIInstanceOfflineStage(w http.ResponseWriter, r *http.Re |
| return |
| } |
| } |
| - st := provision.StageTarget{Stager: moves.OfflineStager(names), Bucket: tgt.DataBucket, Region: tgt.DataBucketRegion} |
| + // Checked stamps the move with the destination the shared |
| + // data-transfer rule just passed for in offlineBeginChecks (H3-M6): |
| + // its own staging prefix is then exempt at restage and start, and no |
| + // unstamped move's is. |
| + st := provision.StageTarget{Stager: moves.OfflineStager(names), Bucket: tgt.DataBucket, Region: tgt.DataBucketRegion, Checked: to} |
| s.offlineBegin(w, r, d, createOnly, func(id string) func(*provision.Record) error { |
| return provision.OfflineStage(id, d.rec.Region, to, d.addr, st, time.Now()) |
| }) |
diff --git a/internal/console/createleftovers.go b/internal/console/createleftovers.go| index 72f73f82d..e9de8ce28 100644 |
| --- a/internal/console/createleftovers.go |
| +++ b/internal/console/createleftovers.go |
| @@ -45,7 +45,6 @@ import ( |
| "github.com/carlosframework/platform/internal/activator" |
| "github.com/carlosframework/platform/internal/dbdoor" |
| "github.com/carlosframework/platform/internal/lease" |
| - "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/registry" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| @@ -289,7 +288,7 @@ func (s *Server) leftoverReplicaRefusal(parent context.Context, c leftoverCreate |
| } |
| return s.dataTransferRefusal(ctx, dataTransfer{ |
| logTag: c.logTag, |
| - recs: []provision.Record{{Host: c.host, Pool: c.pool}}, |
| + recs: []transferRec{{c.host, c.pool}}, |
| to: c.region, |
| what: func(place string) string { return subject + " can't be created in " + place }, |
| taken: func(string) string { return c.taken }, |
diff --git a/internal/console/datatransfer.go b/internal/console/datatransfer.go| index e7271cf95..aefc5003e 100644 |
| --- a/internal/console/datatransfer.go |
| +++ b/internal/console/datatransfer.go |
| @@ -16,7 +16,7 @@ import ( |
| // on storage it was not on (a create, a move's start or stage, an app's |
| // placement onto a fleet or back home) can hand that record another |
| // owner's data unless the destination is proved free of it. Every such |
| -// door calls dataTransferRefusal before its first write; |
| +// door calls the rule (dataTransferVerdict) before its first write; |
| // TestEveryDataTransferDoorAsksTheSharedRule fails a door that does not. |
| // |
| // The rule, per record, by where the destination's data lives: |
| @@ -46,17 +46,27 @@ import ( |
| // |
| // A transfer with no data-kind record admits at once. |
| +// transferRec is one data-kind record the door binds: its host and pool. |
| +type transferRec struct{ host, pool string } |
| + |
| // dataTransfer is one door's request, as the rule needs it. |
| type dataTransfer struct { |
| logTag string |
| - // recs are the data-kind records the door binds at to: Host and Pool |
| - // are read. A create passes the record it would write. |
| - recs []provision.Record |
| + // recs are the data-kind records the door binds at to. A create |
| + // passes the record it would write. |
| + recs []transferRec |
| // to is the destination in the record's Region form ("" home, |
| // "fleet/<name>"). |
| to string |
| - // what opens every refusal: "acme can't move to uk", given the |
| - // destination's label. |
| + // ownStaging is a move whose record carries an offline move staged to |
| + // this destination by a stage door that passed this rule |
| + // (MoveState.StageChecked): its own pre-copy at moves/<host>/ is not a |
| + // leftover, so that one prefix is not counted. The replica prefix and |
| + // its generations still are. |
| + ownStaging bool |
| + // what opens every refusal dataTransferRefusal words: "acme can't be |
| + // created in ie", given the destination's label. The move doors word |
| + // their own (moveTransferRefusal). |
| what func(place string) string |
| // taken and unsure, when set, replace the in-sight answers (the create |
| // doors' approved sentences). |
| @@ -66,84 +76,115 @@ type dataTransfer struct { |
| // that is not active (the place door: completing the history would not |
| // admit a place, which an active history refuses outright). |
| unchecked func(place, host string) string |
| - // ownStaging is a move whose record already carries an offline move |
| - // staged to this destination: its own pre-copy at moves/<host>/ is not |
| - // a leftover, so that one prefix is not counted. The replica prefix and |
| - // its generations still are. |
| - ownStaging bool |
| } |
| -func (s *Server) dataTransferRefusal(ctx context.Context, t dataTransfer) *doorRefusal { |
| +// transferVerdict is the rule's answer. |
| +type transferVerdict int |
| + |
| +const ( |
| + transferAdmitted transferVerdict = iota |
| + transferHeld // 409: in sight, data at the host's prefixes |
| + transferUnsure // 503: in sight, the bucket could not be read |
| + transferUnchecked // 409: out of sight, history not active |
| + transferNeverChecked // 409: out of sight, claims or Phase 1 on |
| + transferUncovered // 409: out of sight, not examined or not covered |
| + transferUnreadable // 503: out of sight, history or roster unreadable |
| +) |
| + |
| +// transferOutcome is the verdict, the host it is about, and the |
| +// destination's label. |
| +type transferOutcome struct { |
| + verdict transferVerdict |
| + host, place string |
| +} |
| + |
| +// dataTransferVerdict is the rule itself. Every door reaches it, through |
| +// dataTransferRefusal or moveTransferRefusal. |
| +func (s *Server) dataTransferVerdict(ctx context.Context, t dataTransfer) transferOutcome { |
| if len(t.recs) == 0 { |
| - return nil |
| + return transferOutcome{} |
| } |
| place := s.offlinePlace(t.to) |
| - what := t.what(place) |
| outOfSight := "" |
| for _, rec := range t.recs { |
| switch { |
| - case s.leftoverCheckApplies(t.to, rec.Pool): |
| - held, err := s.hostHoldsReplicaData(ctx, rec.Host) |
| + case s.leftoverCheckApplies(t.to, rec.pool): |
| + held, err := s.hostHoldsReplicaData(ctx, rec.host) |
| if t.ownStaging { |
| - held, err = s.hostHoldsReplicaDataBesideStaging(ctx, rec.Host) |
| + held, err = s.hostHoldsReplicaDataBesideStaging(ctx, rec.host) |
| } |
| if err != nil { |
| - log.Printf("console: %s: leftover replica check for %s: %v", t.logTag, rec.Host, err) |
| - msg := what + ": the data in " + place + " could not be checked. Try again." |
| - if t.unsure != "" { |
| - msg = t.unsure |
| - } |
| - return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msg} |
| + log.Printf("console: %s: leftover replica check for %s: %v", t.logTag, rec.host, err) |
| + return transferOutcome{transferUnsure, rec.host, place} |
| } |
| if held { |
| - log.Printf("console: %s: refused: %s still holds replica data from a deleted record (H3-M6)", t.logTag, rec.Host) |
| - msg := msgTransferHeld(what, rec.Host, place) |
| - if t.taken != nil { |
| - msg = t.taken(rec.Host) |
| - } |
| - return &doorRefusal{Status: http.StatusConflict, Msg: msg} |
| + log.Printf("console: %s: refused: %s still holds replica data (H3-M6)", t.logTag, rec.host) |
| + return transferOutcome{transferHeld, rec.host, place} |
| } |
| - case s.leftoverOutOfSight(t.to, rec.Pool): |
| + case s.leftoverOutOfSight(t.to, rec.pool): |
| if outOfSight == "" { |
| - outOfSight = rec.Host |
| + outOfSight = rec.host |
| } |
| } |
| } |
| if outOfSight == "" { |
| - return nil |
| + return transferOutcome{} |
| } |
| - return s.outOfSightTransfer(ctx, t, what, place, outOfSight) |
| -} |
| - |
| -// outOfSightTransfer is the out-of-sight half: an active history that |
| -// examined and still covers the destination, or a refusal. |
| -func (s *Server) outOfSightTransfer(ctx context.Context, t dataTransfer, what, place, host string) *doorRefusal { |
| - unreadable := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgTransferUnreadable(what, place)} |
| mode, err := s.hostsMode(ctx) |
| if err != nil { |
| log.Printf("console: %s: read the hostname history's mode: %v", t.logTag, err) |
| - return unreadable |
| + return transferOutcome{transferUnreadable, outOfSight, place} |
| } |
| if mode != provision.HostsModeActive { |
| - log.Printf("console: %s: refused: %s's data would be in %q, out of this console's sight, and the hostname history is %s (H3-M6)", t.logTag, host, t.to, mode) |
| + log.Printf("console: %s: refused: %s's data would be in %q, out of this console's sight, and the hostname history is %s (H3-M6)", t.logTag, outOfSight, t.to, mode) |
| if s.cfg.HostClaim || s.cfg.MovesEnabled { |
| - return &doorRefusal{Status: http.StatusConflict, Msg: msgTransferNeverChecked(what, place, host)} |
| - } |
| - if t.unchecked != nil { |
| - return &doorRefusal{Status: http.StatusConflict, Msg: t.unchecked(place, host)} |
| + return transferOutcome{transferNeverChecked, outOfSight, place} |
| } |
| - return &doorRefusal{Status: http.StatusConflict, Msg: msgTransferUnchecked(what, place, host)} |
| + return transferOutcome{transferUnchecked, outOfSight, place} |
| } |
| for _, check := range []func(context.Context, string) *doorRefusal{s.hostsTargetRefusal, s.hostsCoverageRefusal} { |
| if ref := check(ctx, t.to); ref != nil { |
| if ref.Status == http.StatusServiceUnavailable { |
| - return unreadable |
| + return transferOutcome{transferUnreadable, outOfSight, place} |
| } |
| log.Printf("console: %s: refused: %q was not examined, or is not covered as recorded, by the active hostname history (H3-M6)", t.logTag, t.to) |
| - return &doorRefusal{Status: http.StatusConflict, Msg: msgTransferUncovered(what, place)} |
| + return transferOutcome{transferUncovered, outOfSight, place} |
| + } |
| + } |
| + return transferOutcome{} |
| +} |
| + |
| +// dataTransferRefusal is the rule worded for the create and place doors: |
| +// nil when admitted, else the refusal. |
| +func (s *Server) dataTransferRefusal(ctx context.Context, t dataTransfer) *doorRefusal { |
| + o := s.dataTransferVerdict(ctx, t) |
| + if o.verdict == transferAdmitted { |
| + return nil |
| + } |
| + what := t.what(o.place) |
| + switch o.verdict { |
| + case transferHeld: |
| + if t.taken != nil { |
| + return &doorRefusal{Status: http.StatusConflict, Msg: t.taken(o.host)} |
| + } |
| + return &doorRefusal{Status: http.StatusConflict, Msg: msgTransferHeld(what, o.host, o.place)} |
| + case transferUnsure: |
| + if t.unsure != "" { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: t.unsure} |
| + } |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: what + ": the data in " + o.place + " could not be checked. Try again."} |
| + case transferUnchecked: |
| + if t.unchecked != nil { |
| + return &doorRefusal{Status: http.StatusConflict, Msg: t.unchecked(o.place, o.host)} |
| } |
| + return &doorRefusal{Status: http.StatusConflict, Msg: msgTransferUnchecked(what, o.place, o.host)} |
| + case transferNeverChecked: |
| + return &doorRefusal{Status: http.StatusConflict, Msg: msgTransferNeverChecked(what, o.place, o.host)} |
| + case transferUncovered: |
| + return &doorRefusal{Status: http.StatusConflict, Msg: msgTransferUncovered(what, o.place)} |
| + default: |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgTransferUnreadable(what, o.place)} |
| } |
| - return nil |
| } |
| // The rule's sentences. what is the door's opening ("acme can't move to |
diff --git a/internal/console/datatransfer_guard_test.go b/internal/console/datatransfer_guard_test.go| index 3eefab381..e3acf6bc1 100644 |
| --- a/internal/console/datatransfer_guard_test.go |
| +++ b/internal/console/datatransfer_guard_test.go |
| @@ -2,7 +2,8 @@ package console |
| // The guard for the shared data-transfer rule (H3-M6, datatransfer.go): no |
| // console door may bind a data-kind record to storage without asking |
| -// dataTransferRefusal. It reads the package's own source. A function that |
| +// dataTransferVerdict (directly, or through dataTransferRefusal or |
| +// moveTransferRefusal). It reads the package's own source. A function that |
| // rewrites a record's region (SetRecordRegion) or builds a move's start |
| // (MoveRequest, MoveStartTransition, OfflineStart, OfflineStage) must reach |
| // the rule through this package's calls, and so must every door named in |
| @@ -35,7 +36,7 @@ var transferDoors = []string{ |
| "placeAppTarget", |
| } |
| -const transferRule = "dataTransferRefusal" |
| +const transferRule = "dataTransferVerdict" |
| // transferGraph is each declared function's (or method's, by name) set of |
| // referenced names, and the sinks it calls. |
| @@ -151,8 +152,8 @@ func (s *Server) openDoor() { provision.SetRecordRegion(nil, nil, "", "", "", "" |
| func (s *Server) helperDoor() { s.rewrite() } |
| func (s *Server) rewrite() { provision.OfflineStart("", "", "", "", 0) } |
| func (s *Server) goodDoor() { if s.check() == nil { provision.MoveRequest("", 0) } } |
| -func (s *Server) check() *doorRefusal { return s.dataTransferRefusal(nil, dataTransfer{}) } |
| -func (s *Server) dataTransferRefusal(any, any) *doorRefusal { return nil } |
| +func (s *Server) check() *doorRefusal { s.dataTransferVerdict(nil, dataTransfer{}); return nil } |
| +func (s *Server) dataTransferVerdict(any, any) transferOutcome { return transferOutcome{} } |
| ` |
| dir := t.TempDir() |
| p := filepath.Join(dir, "x.go") |
diff --git a/internal/console/fleets.go b/internal/console/fleets.go| index 697197222..f585d8a62 100644 |
| --- a/internal/console/fleets.go |
| +++ b/internal/console/fleets.go |
| @@ -1035,10 +1035,10 @@ func (s *Server) placeAppTarget(ctx context.Context, acct *Account, app, target |
| // and back to "" home), and a data-kind record there could inherit a |
| // deleted record's data under its host. An app whose changed records |
| // are all exempt kinds (static, service) places as before. |
| - var moving []provision.Record |
| + var moving []transferRec |
| for _, rec := range changed { |
| if rec.DataKind() { |
| - moving = append(moving, rec) |
| + moving = append(moving, transferRec{rec.Host, rec.Pool}) |
| } |
| } |
| if ref := s.dataTransferRefusal(ctx, dataTransfer{ |
diff --git a/internal/console/moveleftovers.go b/internal/console/moveleftovers.go| index cfa5ed2eb..5e2d6dd52 100644 |
| --- a/internal/console/moveleftovers.go |
| +++ b/internal/console/moveleftovers.go |
| @@ -2,6 +2,8 @@ package console |
| import ( |
| "context" |
| + "fmt" |
| + "net/http" |
| "github.com/carlosframework/platform/internal/provision" |
| ) |
| @@ -25,21 +27,48 @@ import ( |
| // pooled records never reach here (moveGate refuses both). |
| // moveTransferRefusal is nil when a move of rec to the region code to may |
| -// start, else the shared rule's refusal. |
| -func (s *Server) moveTransferRefusal(ctx context.Context, logTag string, rec *provision.Record, to string) *doorRefusal { |
| - var recs []provision.Record |
| - if rec.DataKind() { |
| - recs = []provision.Record{*rec} |
| +// start, else the shared rule's refusal, worded here whole for the moves |
| +// copy record (approved_moves_copy_test.go reads these sentences). |
| +// |
| +// An offline move already staged to this destination (start, restage) |
| +// finds its own pre-copy at moves/<host>/ in the target bucket |
| +// (internal/host movesoffline_stage.go). That one prefix is exempt only |
| +// for a move the stage door stamped after the rule passed with it empty |
| +// (MoveState.StageChecked). An unstamped staged move into this console's |
| +// sight was staged by an older console, maybe over a deleted record's |
| +// staging: it is refused, and staged again from scratch. |
| +func (s *Server) moveTransferRefusal(ctx context.Context, logTag string, rec *provision.Record, to string) *offlineRefusal { |
| + if !rec.DataKind() { |
| + return nil |
| } |
| - // An offline move already staged to this destination (start, restage) |
| - // finds its own pre-copy at moves/<host>/ in the target bucket |
| - // (internal/host movesoffline_stage.go): that one prefix is exempt. |
| + host := rec.Host |
| mv, staged := offlineStaged(rec) |
| - return s.dataTransferRefusal(ctx, dataTransfer{ |
| + own := staged && mv.To == to |
| + if own && mv.StageChecked != to && s.leftoverCheckApplies(to, rec.Pool) { |
| + place := s.offlinePlace(to) |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s was staged for %s before this console checked %s for data left under it. Abort the move and stage it again.", host, place, place)} |
| + } |
| + o := s.dataTransferVerdict(ctx, dataTransfer{ |
| logTag: logTag, |
| - recs: recs, |
| + recs: []transferRec{{host, rec.Pool}}, |
| to: to, |
| - what: func(place string) string { return rec.Host + " can't move to " + place }, |
| - ownStaging: staged && mv.To == to, |
| + ownStaging: own && mv.StageChecked == to, |
| }) |
| + p := o.place |
| + switch o.verdict { |
| + case transferAdmitted: |
| + return nil |
| + case transferHeld: |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s can't move to %s: %s already has data in %s. An operator has to look at it before this can go ahead.", host, p, host, p)} |
| + case transferUnsure: |
| + return &offlineRefusal{status: http.StatusServiceUnavailable, msg: fmt.Sprintf("%s can't move to %s: the data in %s could not be checked. Try again.", host, p, p)} |
| + case transferUnchecked: |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s can't move to %s: this console can't check %s for data a deleted record left under %s. An operator can allow it by completing the hostname history (console hosts-used) with %s scanned.", host, p, p, host, p)} |
| + case transferNeverChecked: |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s can't move to %s: this console can't check %s for data a deleted record left under %s, and its hostname history can't be completed while host claims or Phase 1 moves are on.", host, p, p, host)} |
| + case transferUncovered: |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s can't move to %s: %s was not scanned when the hostname history was completed, or its boxes or data bucket have changed since. An operator can allow it by completing the history again with %s scanned.", host, p, p, p)} |
| + default: |
| + return &offlineRefusal{status: http.StatusServiceUnavailable, msg: fmt.Sprintf("%s can't move to %s: the hostname history, or what %s runs on, could not be read. Try again.", host, p, p)} |
| + } |
| } |
diff --git a/internal/console/moveleftovers_h3m6_test.go b/internal/console/moveleftovers_h3m6_test.go| index 761e2fcda..030d1b0e5 100644 |
| --- a/internal/console/moveleftovers_h3m6_test.go |
| +++ b/internal/console/moveleftovers_h3m6_test.go |
| @@ -25,6 +25,12 @@ import ( |
| func moveWhat(host, place string) string { return host + " can't move to " + place } |
| +// msgStagedUnchecked is moveTransferRefusal's refusal of a staged move with |
| +// no StageChecked stamp. |
| +func msgStagedUnchecked(host, place string) string { |
| + return host + " was staged for " + place + " before this console checked " + place + " for data left under it. Abort the move and stage it again." |
| +} |
| + |
| // moveFixture is leftoverFixture (a data bucket, this console in ie) with |
| // titogo's acme created in ie, where the rail checked it clean. |
| func moveFixture(t *testing.T, code string) (*leftoverFx, string) { |
| @@ -242,3 +248,22 @@ func TestH3M6StagingWithoutAStagedMoveRefuses(t *testing.T) { |
| msgTransferHeld(moveWhat(offlineHost, "uk"), offlineHost, "uk")) |
| } |
| } |
| + |
| +// A staged move with no StageChecked stamp (staged by a console from before |
| +// the rule) may sit on a deleted record's staging: its restage and start |
| +// are refused with the abort-and-stage-again sentence, nothing written. A |
| +// fresh stage carries the stamp (TestH3M6StagedMoveIntoTheConsolesRegionIsNotItsOwnLeftover). |
| +func TestH3M6UnstampedStagedMoveIsRefused(t *testing.T) { |
| + w := newOfflineWorld(t, oneEach...) |
| + w.fx.srv.cfg.HibernateBucket, w.fx.srv.cfg.Region = "data-uk", "uk" |
| + root := fileReplicas(t, w.fx.srv) |
| + w.ok("/stage", `{"region":"uk"}`, provision.OfflineStaging) |
| + if got := w.record().Move.StageChecked; got != "uk" { |
| + t.Fatalf("a fresh stage stamped %q, want uk", got) |
| + } |
| + w.edit(func(rec *provision.Record) error { rec.Move.StageChecked = ""; return nil }) |
| + leaveStaged(t, root, offlineHost) // the older stage's copy, or a deleted record's |
| + for _, path := range []string{"", "/stage"} { |
| + w.refused(http.MethodPost, path, `{"region":"uk"}`, http.StatusConflict, msgStagedUnchecked(offlineHost, "uk")) |
| + } |
| +} |
diff --git a/internal/provision/offline_move.go b/internal/provision/offline_move.go| index 9176e8f99..8396619c9 100644 |
| --- a/internal/provision/offline_move.go |
| +++ b/internal/provision/offline_move.go |
| @@ -157,7 +157,12 @@ func OfflineStart(id, from, to, by string, now time.Time) func(*Record) error { |
| // StageTarget is what a stage fixes for the whole move: the one box that |
| // copies (Stager) and where the copy goes (Bucket, the target's data |
| // bucket, in Region). |
| -type StageTarget struct{ Stager, Bucket, Region string } |
| +type StageTarget struct { |
| + Stager, Bucket, Region string |
| + // Checked is MoveState.StageChecked: the destination the stage door's |
| + // shared data-transfer rule passed for, or "". |
| + Checked string |
| +} |
| // OfflineStage is OfflineStart into offline-staging: the same refusals and |
| // the same stamps, plus staged_at, the stager and the staging destination |
| @@ -173,6 +178,7 @@ func OfflineStage(id, from, to, by string, st StageTarget, now time.Time) func(* |
| return err |
| } |
| rec.Move.Stager, rec.Move.StageBucket, rec.Move.StageRegion = st.Stager, st.Bucket, st.Region |
| + rec.Move.StageChecked = st.Checked |
| return nil |
| } |
| } |
diff --git a/internal/provision/provision.go b/internal/provision/provision.go| index 2a5998dba..21ed6e166 100644 |
| --- a/internal/provision/provision.go |
| +++ b/internal/provision/provision.go |
| @@ -1349,6 +1349,14 @@ type MoveState struct { |
| // Additive and omitempty. |
| StageBucket string `json:"stage_bucket,omitempty"` |
| StageRegion string `json:"stage_region,omitempty"` |
| + // StageChecked is the destination for which the stage door's shared |
| + // data-transfer rule (console datatransfer.go, hunt H3-M6) passed |
| + // before this move was written: in this console's sight, with the |
| + // destination's moves/<host>/ prefix empty. Only a staged move carrying |
| + // it for its own destination may count that prefix as its own pre-copy |
| + // at restage and start; one staged by an older console may sit on a |
| + // deleted record's staging. Additive and omitempty. |
| + StageChecked string `json:"stage_checked,omitempty"` |
| // Seq is the record's move_seq as the transition that produced this |
| // state left it (self-serve moves plan 1 Task 7, offline_move.go): the |
| // hold's for a held row, open's for the target, the abort's for the |