carlos / platform Public

region ha: the catch-up hold's tests pin its CheckHeld refusal and its decision made again under the lock (L18 finding 3 review M1, M2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev b1aacf79441864256defc69b287199cac932f841 parent a092ddc
1 file changed, +97 −0
  • internal/hostbox/reconcile_relocation_catchup_test.go +97 −0

CI passed — run details

CI log
=== gate ===
cd launchctx && go vet ./... && go test ./... -count=1
ok  	amadan.net/carlos/platform.git/launchctx	0.012s
?   	amadan.net/carlos/platform.git/launchctx/controlname	[no test files]
?   	amadan.net/carlos/platform.git/launchctx/wireid	[no test files]
go vet ./...
gofmt -l .: clean
go test ./... -count=1 -timeout 30m
ok  	github.com/carlosframework/platform	323.037s
?   	github.com/carlosframework/platform/cmd/changelog	[no test files]
ok  	github.com/carlosframework/platform/cmd/console	3.144s
ok  	github.com/carlosframework/platform/cmd/moveprobe	93.179s
ok  	github.com/carlosframework/platform/internal/activator	217.653s
ok  	github.com/carlosframework/platform/internal/agentsock	0.016s
ok  	github.com/carlosframework/platform/internal/alerting	0.004s
ok  	github.com/carlosframework/platform/internal/analytics	0.019s
ok  	github.com/carlosframework/platform/internal/appconfig	2.251s
ok  	github.com/carlosframework/platform/internal/apperr	0.072s
ok  	github.com/carlosframework/platform/internal/applog	0.127s
ok  	github.com/carlosframework/platform/internal/awsinv	0.004s
ok  	github.com/carlosframework/platform/internal/boxchoice	0.004s
ok  	github.com/carlosframework/platform/internal/boxid	0.645s
?   	github.com/carlosframework/platform/internal/boxid/boxidtest	[no test files]
?   	github.com/carlosframework/platform/internal/boxid/internal/signtest	[no test files]
ok  	github.com/carlosframework/platform/internal/boxvolumes	0.008s
ok  	github.com/carlosframework/platform/internal/caps	0.011s
ok  	github.com/carlosframework/platform/internal/certwarm	0.002s
ok  	github.com/carlosframework/platform/internal/cgroup	0.190s
ok  	github.com/carlosframework/platform/internal/changelog	0.258s
ok  	github.com/carlosframework/platform/internal/clamd	0.054s
?   	github.com/carlosframework/platform/internal/cliflag	[no test files]
ok  	github.com/carlosframework/platform/internal/console	354.465s
?   	github.com/carlosframework/platform/internal/controlname	[no test files]
?   	github.com/carlosframework/platform/internal/controlsock	[no test files]
ok  	github.com/carlosframework/platform/internal/dbdoor	6.107s
ok  	github.com/carlosframework/platform/internal/dbdoor/dbdoortest	0.009s
ok  	github.com/carlosframework/platform/internal/dbverify	0.004s
ok  	github.com/carlosframework/platform/internal/dnsrec	0.004s
ok  	github.com/carlosframework/platform/internal/docsite	0.005s
ok  	github.com/carlosframework/platform/internal/domains	1.944s
ok  	github.com/carlosframework/platform/internal/doorkey	0.006s
ok  	github.com/carlosframework/platform/internal/economics	0.003s
ok  	github.com/carlosframework/platform/internal/edge	25.722s
?   	github.com/carlosframework/platform/internal/edgeproof	[no test files]
ok  	github.com/carlosframework/platform/internal/edgesfile	0.007s
ok  	github.com/carlosframework/platform/internal/fleetapi	0.130s
ok  	github.com/carlosframework/platform/internal/gate	1.656s
ok  	github.com/carlosframework/platform/internal/genselect	0.014s
ok  	github.com/carlosframework/platform/internal/geo	0.015s
ok  	github.com/carlosframework/platform/internal/geoip	0.029s
ok  	github.com/carlosframework/platform/internal/host	66.513s
ok  	github.com/carlosframework/platform/internal/hostactors	0.312s
ok  	github.com/carlosframework/platform/internal/hostbox	1.677s
ok  	github.com/carlosframework/platform/internal/hostclaim	0.429s
ok  	github.com/carlosframework/platform/internal/hostevidence	0.005s
ok  	github.com/carlosframework/platform/internal/hostexec	0.309s
ok  	github.com/carlosframework/platform/internal/hostfence	0.030s
ok  	github.com/carlosframework/platform/internal/hostfiles	10.363s
ok  	github.com/carlosframework/platform/internal/hostfloor	0.013s
ok  	github.com/carlosframework/platform/internal/hostguard	0.138s
ok  	github.com/carlosframework/platform/internal/hostops	1.372s
?   	github.com/carlosframework/platform/internal/hostops/fencerelease	[no test files]
ok  	github.com/carlosframework/platform/internal/hostops/internal/fencerelease	0.002s
ok  	github.com/carlosframework/platform/internal/hostquarantine	0.002s
ok  	github.com/carlosframework/platform/internal/hostrelocate	0.424s
ok  	github.com/carlosframework/platform/internal/hostresolve	0.143s
ok  	github.com/carlosframework/platform/internal/hostwrite	0.001s
ok  	github.com/carlosframework/platform/internal/infraview	0.002s
ok  	github.com/carlosframework/platform/internal/instancectl	1.701s
ok  	github.com/carlosframework/platform/internal/instanceexec	2.682s
ok  	github.com/carlosframework/platform/internal/instancefs	0.013s
ok  	github.com/carlosframework/platform/internal/instancekey	0.009s
ok  	github.com/carlosframework/platform/internal/instanceupdates	0.013s
ok  	github.com/carlosframework/platform/internal/layout	1.351s
ok  	github.com/carlosframework/platform/internal/lease	9.453s
ok  	github.com/carlosframework/platform/internal/lease/leasetest	0.013s
ok  	github.com/carlosframework/platform/internal/ledger	0.011s
ok  	github.com/carlosframework/platform/internal/mail	0.161s
ok  	github.com/carlosframework/platform/internal/maintenance	0.080s
ok  	github.com/carlosframework/platform/internal/maintenanceexec	5.496s
ok  	github.com/carlosframework/platform/internal/maintenanceguard	0.068s
ok  	github.com/carlosframework/platform/internal/metrics	0.004s
ok  	github.com/carlosframework/platform/internal/moves	20.971s
ok  	github.com/carlosframework/platform/internal/moves/archive	0.754s
ok  	github.com/carlosframework/platform/internal/objstore	0.171s
ok  	github.com/carlosframework/platform/internal/ops	0.152s
ok  	github.com/carlosframework/platform/internal/park	0.200s
ok  	github.com/carlosframework/platform/internal/privatefile	0.004s
ok  	github.com/carlosframework/platform/internal/provision	3.157s
ok  	github.com/carlosframework/platform/internal/publicrelease	0.006s
?   	github.com/carlosframework/platform/internal/regionname	[no test files]
ok  	github.com/carlosframework/platform/internal/registry	3.719s
ok  	github.com/carlosframework/platform/internal/relay	7.223s
ok  	github.com/carlosframework/platform/internal/release	17.835s
ok  	github.com/carlosframework/platform/internal/rollout	3.237s
ok  	github.com/carlosframework/platform/internal/rolloutwords	0.003s
ok  	github.com/carlosframework/platform/internal/rootaws	0.007s
ok  	github.com/carlosframework/platform/internal/s3compat	0.004s
ok  	github.com/carlosframework/platform/internal/safefile	0.003s
ok  	github.com/carlosframework/platform/internal/schedule	2.203s
ok  	github.com/carlosframework/platform/internal/sim/hostlife	2.324s
ok  	github.com/carlosframework/platform/internal/sim/litestreamfacts	4.181s
ok  	github.com/carlosframework/platform/internal/status	0.039s
ok  	github.com/carlosframework/platform/internal/steering	0.005s
ok  	github.com/carlosframework/platform/internal/stopevidence	0.215s
ok  	github.com/carlosframework/platform/internal/svcrole	0.005s
ok  	github.com/carlosframework/platform/internal/telemetry	0.004s
ok  	github.com/carlosframework/platform/internal/termfence	0.005s
ok  	github.com/carlosframework/platform/internal/tunnelclient	0.003s
ok  	github.com/carlosframework/platform/internal/unixdial	0.005s
ok  	github.com/carlosframework/platform/internal/updatewords	0.002s
ok  	github.com/carlosframework/platform/internal/usage	0.004s
ok  	github.com/carlosframework/platform/internal/version	0.002s
ok  	github.com/carlosframework/platform/internal/vet	1.543s
=== cross ===
--- shard 0 of 5 ---
cross-compiling darwin/arm64
go: downloading github.com/ncruces/go-strftime v1.0.0
--- shard 1 of 5 ---
cross-compiling darwin/amd64
go: downloading github.com/ncruces/go-strftime v1.0.0
--- shard 2 of 5 ---
cross-compiling linux/arm64
--- shard 3 of 5 ---
cross-compiling windows/amd64
go: downloading github.com/ncruces/go-strftime v1.0.0
--- shard 4 of 5 ---
cross-compiling windows/arm64
go: downloading github.com/ncruces/go-strftime v1.0.0
=== minio-contract ===
minio contract: arm64, minio RELEASE.2025-09-07T16-13-09Z, mc RELEASE.2025-08-13T08-35-41Z
  minio: cached, digest verified
  mc: cached, digest verified
  minio healthy on 127.0.0.1:20999
Added `local` successfully.
Bucket created successfully `local/contract-bucket`.
Bucket created successfully `local/denied-bucket`.
Created policy `contract-only` successfully.
Added user `scopeduser` successfully.
Attached Policies: [contract-only]
To User: scopeduser
  buckets and scoped user ready
=== RUN   TestDeliveredContractMinio
=== RUN   TestDeliveredContractMinio/put
=== RUN   TestDeliveredContractMinio/get_round-trips_the_body
=== RUN   TestDeliveredContractMinio/list_shows_the_key
=== RUN   TestDeliveredContractMinio/head_and_list_agree_on_the_version
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict
=== RUN   TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed
=== RUN   TestDeliveredContractMinio/delete_removes_it
=== RUN   TestDeliveredContractMinio/cross-bucket_denial
--- PASS: TestDeliveredContractMinio (0.02s)
    --- PASS: TestDeliveredContractMinio/put (0.00s)
    --- PASS: TestDeliveredContractMinio/get_round-trips_the_body (0.00s)
    --- PASS: TestDeliveredContractMinio/list_shows_the_key (0.00s)
    --- PASS: TestDeliveredContractMinio/head_and_list_agree_on_the_version (0.00s)
    --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload (0.00s)
    --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route (0.01s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict (0.00s)
        --- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed (0.00s)
    --- PASS: TestDeliveredContractMinio/delete_removes_it (0.00s)
    --- PASS: TestDeliveredContractMinio/cross-bucket_denial (0.00s)
PASS
ok  	github.com/carlosframework/platform/internal/objstore	0.022s
=== RUN   TestT4StorageProbeMinio
2026/10/12 16:49:54 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18DDD63F6DAD8212, HostID: 7c420053e0fbcd7f41653fdd92ffa2802c903d05303b1aa15adc2e8bb65d183f, api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
--- PASS: TestT4StorageProbeMinio (0.01s)
PASS
ok  	github.com/carlosframework/platform/internal/host	0.021s
minio contract: PASS
diff --git a/internal/hostbox/reconcile_relocation_catchup_test.go b/internal/hostbox/reconcile_relocation_catchup_test.go
index 14d381b95..47fc1e4a1 100644
--- a/internal/hostbox/reconcile_relocation_catchup_test.go
+++ b/internal/hostbox/reconcile_relocation_catchup_test.go
@@ -249,3 +249,100 @@ func TestReconcileCatchUpHoldReplayWritesNothing(t *testing.T) {
t.Fatalf("the replay changed the row: %+v (was %+v)", got, held)
}
}
+
+// Review M1: the catch-up hold is a hold only on this box's own existing
+// installation (CheckHeld, as for Task 10b). Through the production
+// adapter and the pass, a census that refuses (the source's row owned by
+// another incarnation, or an inventory of another enrollment) holds
+// nothing: the row stays exactly as it was. On the stubbed reconciler a
+// refusing CheckHeld is Install's error and HoldRow is never called.
+func TestReconcileCatchUpHoldNeedsCheckHeld(t *testing.T) {
+ t.Run("a row of another incarnation", func(t *testing.T) {
+ s := newSourceReconcile(t)
+ s.releasingThenInstalling(t)
+ s.completeFromInstalling(t)
+ stranger := *s.row(t)
+ stranger.ClaimIncarnation = "inc-other"
+ // Ownership is never rewritten in place: the row is replaced.
+ if err := s.reg.Delete(s.f.host); err != nil {
+ t.Fatal(err)
+ }
+ if err := s.reg.Upsert(stranger); err != nil {
+ t.Fatal(err)
+ }
+ before := *s.row(t)
+ s.pass(t)
+ if got := s.row(t); *got != before {
+ t.Fatalf("a row of another incarnation was held: %+v (was %+v)", got, before)
+ }
+ })
+ t.Run("an inventory of another enrollment", func(t *testing.T) {
+ s := newSourceReconcile(t)
+ before := *s.row(t)
+ s.releasingThenInstalling(t)
+ s.completeFromInstalling(t)
+ contradicting := *s.census
+ contradicting.Enrollment = "en-2"
+ s.adapter.Census = &contradicting
+ s.adapter.Configure(&s.cfg)
+ s.pass(t)
+ if got := s.row(t); *got != before {
+ t.Fatalf("a contradicting inventory was held: %+v (was %+v)", got, before)
+ }
+ })
+ t.Run("stubbed", func(t *testing.T) {
+ r, selected, holds, _ := relocationReconciler(t)
+ completedServing(t, r, selected.Host, "dst", "dst", parkLocal("box", "rel-1"))
+ r.CheckHeld = func(context.Context, hostclaim.Observed, RecordSelection) error { return ErrTypedInventory }
+ writes := 0
+ if err := r.Install(context.Background(), selected, func() error { writes++; return nil }); !errors.Is(err, ErrTypedInventory) || writes != 0 || len(*holds) != 0 {
+ t.Fatalf("a refusing CheckHeld: %v writes %d holds %v", err, writes, *holds)
+ }
+ })
+}
+
+// Review M2: holdOnly makes the catch-up decision again on the fresh read
+// under the host lock and holds nothing when it differs. Install's
+// decision is made, then (inside CheckHeld, which runs after the decision
+// and before the lock) the claim is rewritten to another completed
+// relocation, rel-2, which this box also owes a park-local for: the fresh
+// read is still in catch-up scope, but for rel-2, so the locked decision
+// no longer holds and nothing is held. In production this state is not
+// reachable while the row exists: CompleteRelocation queues no second
+// park-local for a box that already owes one, RelocationStartGuard refuses
+// a source that owes one, and once rel-1's park-local retires the row,
+// RegistryHoldRow finds none. The test pins the re-decision directly.
+func TestReconcileCatchUpHoldIsDecidedAgainUnderTheLock(t *testing.T) {
+ ctx := context.Background()
+ r, selected, holds, _ := relocationReconciler(t)
+ completedServing(t, r, selected.Host, "dst", "dst", parkLocal("box", "rel-1"))
+ done, err := json.Marshal(hostclaim.CompletedRelocation{Op: "rel-2", Stop: hostclaim.ProbeStop{Box: "dst", Session: 8, Receipt: "probe-fence-2", ReceiptSHA256: strings.Repeat("b", 64)}, Phase: hostclaim.PhaseRelocatingProbing})
+ if err != nil {
+ t.Fatal(err)
+ }
+ moved := false
+ r.CheckHeld = func(ctx context.Context, _ hostclaim.Observed, _ RecordSelection) error {
+ obs, err := hostclaim.Read(ctx, r.Claims, selected.Host)
+ if err != nil {
+ return err
+ }
+ _, err = hostclaim.Update(ctx, r.Claims, obs, func(c *hostclaim.Claim) error {
+ c.Op.Journal[hostclaim.JournalCompleted] = string(done)
+ c.Obligations = []hostclaim.Obligation{parkLocal("box", "rel-2")}
+ return nil
+ })
+ moved = err == nil
+ return err
+ }
+ writes := 0
+ if err := r.Install(ctx, selected, func() error { writes++; return nil }); !errors.Is(err, ErrChanged) || !moved || writes != 0 || len(*holds) != 0 {
+ t.Fatalf("a catch-up decision the locked read no longer makes: %v moved %v writes %d holds %v", err, moved, writes, *holds)
+ }
+ obs, err := hostclaim.Read(ctx, r.Claims, selected.Host)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if d, ok, err := r.completedHold(obs.Claim); err != nil || !ok || d != (RowDecision{Case: RowRetiring, HoldOp: "rel-2"}) {
+ t.Fatalf("the fresh read is not the rel-2 catch-up: %+v %v %v", d, ok, err)
+ }
+}