moves: the target's cleaning removes the held render's unfinished temp (Task 9a fix round 5)
The flat renderer writes the rendered bytes to <host>.config.env.tmp and renames them over the path (appconfig syncexec.go:1416-1420). A crash between the two left the temp holding the rendered secrets, which the target's cleaning ignored. When the journal records a held render (pre_render), the cleaning's guarded work now removes that temp (removeRenderTemp): never parked, since it is not live config, only an unfinished write of this op's. Only a regular file is removed (Lstat'ed, never followed); anything else at the name is logged and left. The renderer's own write path is unchanged. The nested renderer's temps (instancefs.WriteAtomic's O_EXCL names) never hold a held render: a moved row is always flat (the cut refuses a nested row at preparing, and the landing refuses one at checking, RollbackLandingLayout). Test: TestRenderTempIsRemovedByCleaning (a crash after the temp write and before the rename, then a rollback: the temp is gone, nothing parked holds the rendered bytes, and config.env is as before: absent, or the earlier file kept). RED: "the renderer's temp is still there".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+87
−0
internal/host/movescarries_test.go+53 −0internal/host/movesrollback.go+34 −0
CI passed — run details
CI log
=== gate ===
go: downloading github.com/aws/aws-sdk-go-v2/service/sns v1.43.0
go: downloading github.com/oschwald/maxminddb-golang v1.13.1
go: downloading github.com/klauspost/compress v1.18.0
cd launchctx && go vet ./... && go test ./... -count=1
ok amadan.net/carlos/platform.git/launchctx 0.011s
? 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 299.247s
? github.com/carlosframework/platform/cmd/changelog [no test files]
ok github.com/carlosframework/platform/cmd/console 2.965s
ok github.com/carlosframework/platform/internal/activator 138.758s
ok github.com/carlosframework/platform/internal/agentsock 0.022s
ok github.com/carlosframework/platform/internal/alerting 0.005s
ok github.com/carlosframework/platform/internal/analytics 0.024s
ok github.com/carlosframework/platform/internal/appconfig 2.128s
ok github.com/carlosframework/platform/internal/apperr 0.133s
ok github.com/carlosframework/platform/internal/applog 0.223s
ok github.com/carlosframework/platform/internal/awsinv 0.007s
ok github.com/carlosframework/platform/internal/boxchoice 0.006s
ok github.com/carlosframework/platform/internal/boxid 0.759s
? 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.015s
ok github.com/carlosframework/platform/internal/caps 0.014s
ok github.com/carlosframework/platform/internal/certwarm 0.005s
ok github.com/carlosframework/platform/internal/cgroup 0.195s
ok github.com/carlosframework/platform/internal/changelog 0.322s
ok github.com/carlosframework/platform/internal/clamd 0.060s
? github.com/carlosframework/platform/internal/cliflag [no test files]
ok github.com/carlosframework/platform/internal/console 318.604s
? 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.471s
ok github.com/carlosframework/platform/internal/dbdoor/dbdoortest 0.012s
ok github.com/carlosframework/platform/internal/dbverify 0.005s
ok github.com/carlosframework/platform/internal/dnsrec 0.003s
ok github.com/carlosframework/platform/internal/docsite 0.006s
ok github.com/carlosframework/platform/internal/domains 1.945s
ok github.com/carlosframework/platform/internal/doorkey 0.006s
ok github.com/carlosframework/platform/internal/economics 0.004s
ok github.com/carlosframework/platform/internal/edge 25.631s
? github.com/carlosframework/platform/internal/edgeproof [no test files]
ok github.com/carlosframework/platform/internal/edgesfile 0.009s
ok github.com/carlosframework/platform/internal/fleetapi 0.131s
ok github.com/carlosframework/platform/internal/gate 1.655s
ok github.com/carlosframework/platform/internal/genselect 0.015s
ok github.com/carlosframework/platform/internal/geo 0.017s
ok github.com/carlosframework/platform/internal/geoip 0.036s
ok github.com/carlosframework/platform/internal/host 45.604s
ok github.com/carlosframework/platform/internal/hostactors 0.439s
ok github.com/carlosframework/platform/internal/hostbox 1.204s
ok github.com/carlosframework/platform/internal/hostclaim 0.226s
ok github.com/carlosframework/platform/internal/hostevidence 0.006s
ok github.com/carlosframework/platform/internal/hostexec 0.314s
ok github.com/carlosframework/platform/internal/hostfence 0.031s
ok github.com/carlosframework/platform/internal/hostfiles 4.071s
ok github.com/carlosframework/platform/internal/hostfloor 0.009s
ok github.com/carlosframework/platform/internal/hostguard 0.132s
ok github.com/carlosframework/platform/internal/hostops 1.216s
ok github.com/carlosframework/platform/internal/hostquarantine 0.003s
ok github.com/carlosframework/platform/internal/hostresolve 0.126s
ok github.com/carlosframework/platform/internal/hostwrite 0.002s
ok github.com/carlosframework/platform/internal/infraview 0.002s
ok github.com/carlosframework/platform/internal/instancectl 1.700s
ok github.com/carlosframework/platform/internal/instanceexec 2.684s
ok github.com/carlosframework/platform/internal/instancefs 0.005s
ok github.com/carlosframework/platform/internal/layout 1.296s
ok github.com/carlosframework/platform/internal/lease 9.443s
ok github.com/carlosframework/platform/internal/lease/leasetest 0.009s
ok github.com/carlosframework/platform/internal/ledger 0.015s
ok github.com/carlosframework/platform/internal/mail 0.158s
ok github.com/carlosframework/platform/internal/maintenance 0.078s
ok github.com/carlosframework/platform/internal/maintenanceexec 5.501s
ok github.com/carlosframework/platform/internal/maintenanceguard 0.075s
ok github.com/carlosframework/platform/internal/metrics 0.006s
ok github.com/carlosframework/platform/internal/moves 21.016s
ok github.com/carlosframework/platform/internal/moves/archive 0.725s
ok github.com/carlosframework/platform/internal/objstore 0.161s
ok github.com/carlosframework/platform/internal/ops 0.150s
ok github.com/carlosframework/platform/internal/park 0.175s
ok github.com/carlosframework/platform/internal/privatefile 0.005s
ok github.com/carlosframework/platform/internal/provision 3.003s
ok github.com/carlosframework/platform/internal/publicrelease 0.006s
ok github.com/carlosframework/platform/internal/registry 3.527s
ok github.com/carlosframework/platform/internal/relay 7.214s
ok github.com/carlosframework/platform/internal/release 19.421s
ok github.com/carlosframework/platform/internal/rollout 1.460s
ok github.com/carlosframework/platform/internal/rootaws 0.006s
ok github.com/carlosframework/platform/internal/s3compat 0.004s
ok github.com/carlosframework/platform/internal/safefile 0.004s
ok github.com/carlosframework/platform/internal/schedule 2.173s
ok github.com/carlosframework/platform/internal/sim/hostlife 2.253s
ok github.com/carlosframework/platform/internal/sim/litestreamfacts 3.409s
ok github.com/carlosframework/platform/internal/status 0.037s
ok github.com/carlosframework/platform/internal/steering 0.005s
ok github.com/carlosframework/platform/internal/stopevidence 0.136s
ok github.com/carlosframework/platform/internal/svcrole 0.002s
ok github.com/carlosframework/platform/internal/telemetry 0.004s
ok github.com/carlosframework/platform/internal/termfence 0.004s
ok github.com/carlosframework/platform/internal/tunnelclient 0.003s
ok github.com/carlosframework/platform/internal/unixdial 0.002s
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.001s
ok github.com/carlosframework/platform/internal/vet 1.549s
=== cross ===
--- shard 0 of 5 ---
cross-compiling darwin/arm64
--- shard 1 of 5 ---
cross-compiling darwin/amd64
--- shard 2 of 5 ---
cross-compiling linux/arm64
--- shard 3 of 5 ---
cross-compiling windows/amd64
--- shard 4 of 5 ---
cross-compiling windows/arm64
=== minio-contract ===
minio contract: arm64, minio RELEASE.2025-09-07T16-13-09Z, mc RELEASE.2025-08-13T08-35-41Z
minio: downloading https://github.com/minio/minio/releases/download/RELEASE.2025-09-07T16-13-09Z/minio.linux-arm64.RELEASE.2025-09-07T16-13-09Z
minio: downloaded, digest verified
mc: downloading https://github.com/minio/mc/releases/download/RELEASE.2025-08-13T08-35-41Z/mc.linux-arm64.RELEASE.2025-08-13T08-35-41Z
mc: downloaded, 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/11 09:32:33 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18DD6FCD26E9E873, 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.00s)
PASS
ok github.com/carlosframework/platform/internal/host 0.014s
minio contract: PASS
diff --git a/internal/host/movescarries_test.go b/internal/host/movescarries_test.go| index e59db67c9..4825ed410 100644 |
| --- a/internal/host/movescarries_test.go |
| +++ b/internal/host/movescarries_test.go |
| @@ -448,3 +448,56 @@ func TestReturnRenderRetriesStayBounded(t *testing.T) { |
| t.Fatalf("intended %v after the final render", pre.Intended) |
| } |
| } |
| + |
| +// TestRenderTempIsRemovedByCleaning (fix round 5): the renderer writes the |
| +// rendered bytes to <host>.config.env.tmp and renames them over the path |
| +// (appconfig syncexec.go). A crash between the two leaves the temp holding |
| +// the rendered secrets, an unfinished write of this op's. The target's |
| +// cleaning removes it (never parks it: it is not live config), and leaves |
| +// <host>.config.env as it was before the render: absent, or an earlier file |
| +// that is not the render's, kept. |
| +func TestRenderTempIsRemovedByCleaning(t *testing.T) { |
| + for _, earlier := range [][]byte{nil, []byte("EARLIER=1\n")} { |
| + t.Run(fmt.Sprintf("earlier %v", earlier != nil), func(t *testing.T) { |
| + h := &rollbackHarness{landingHarness: newLandingHarness(t)} |
| + h.flip(t) |
| + path := filepath.Join(h.tdir, p1Host+".config.env") |
| + if earlier != nil { |
| + if err := os.WriteFile(path, earlier, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + rendered := []byte("SECRET=landing\n") |
| + sum := sha256.Sum256(rendered) |
| + h.renderHook = func(before func(string) error) (appconfig.HeldRender, error) { |
| + if err := before(hex.EncodeToString(sum[:])); err != nil { |
| + return appconfig.HeldRender{}, err |
| + } |
| + if err := os.WriteFile(path+".tmp", rendered, 0o600); err != nil { |
| + return appconfig.HeldRender{}, err |
| + } |
| + return appconfig.HeldRender{}, errors.New("the agent died before the rename") |
| + } |
| + h.land(t) |
| + if _, err := os.Stat(path + ".tmp"); err != nil { |
| + t.Fatalf("fixture: no temp: %v", err) |
| + } |
| + h.cleanAfterRollback(t) |
| + if _, err := os.Lstat(path + ".tmp"); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("the renderer's temp is still there: %v", err) |
| + } |
| + got, err := os.ReadFile(path) |
| + switch { |
| + case earlier == nil && !errors.Is(err, os.ErrNotExist): |
| + t.Fatalf("a config appeared: %q %v", got, err) |
| + case earlier != nil && (err != nil || !bytes.Equal(got, earlier)): |
| + t.Fatalf("the earlier config was not kept: %q %v", got, err) |
| + } |
| + for name, body := range parkedLocally(t, h.tdir) { |
| + if bytes.Equal(body, rendered) { |
| + t.Fatalf("the rendered secrets were parked as %s", name) |
| + } |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/host/movesrollback.go b/internal/host/movesrollback.go| index 0eac0f8e1..a3e2a4242 100644 |
| --- a/internal/host/movesrollback.go |
| +++ b/internal/host/movesrollback.go |
| @@ -1371,6 +1371,11 @@ func (r *rollbackRun) parkLeftovers(ctx context.Context, j *moves.Journal, mark |
| if incarnation != r.g.Incarnation { |
| return fmt.Errorf("move %s: the claim names another incarnation", id) |
| } |
| + if _, rendered := j.Steps[landStepPreRender]; rendered { |
| + if err := removeRenderTemp(cfg.DataDir, host); err != nil { |
| + return err |
| + } |
| + } |
| _, err := parkLocalArtifacts(ctx, j, mark, localArtifactPark{DataDir: cfg.DataDir, Incarnation: incarnation, Host: host, |
| Op: id, Step: rbStepLocal, Paths: paths, NewID: obligationID, Fault: r.fault, Owns: owns}) |
| return err |
| @@ -1393,6 +1398,35 @@ func (r *rollbackRun) parkLeftovers(ctx context.Context, j *moves.Journal, mark |
| return g.RetireInstallationWith(ctx, host, hostguard.Captured{Incarnation: r.g.Incarnation, Stamp: f}, check, work) |
| } |
| +// removeRenderTemp removes the held renderer's temp sibling of |
| +// <host>.config.env (Task 9a fix round 5). The flat renderer writes the |
| +// rendered bytes to <path>.tmp and renames them over the path (appconfig |
| +// renderExecConfigBefore), so a crash between the two leaves the temp |
| +// holding the rendered secrets: never live config, only an unfinished write |
| +// of this op's, whose render the journal records (pre_render). It is |
| +// removed, never parked. Only a regular file is removed (Lstat'ed, never |
| +// followed); anything else at the name is logged and left. A moved row is |
| +// always flat (the landing refuses a nested row at checking), so the nested |
| +// renderer's temp (instancefs.WriteAtomic) never holds a held render. |
| +func removeRenderTemp(dataDir, host string) error { |
| + tmp := filepath.Join(dataDir, host+".config.env.tmp") |
| + fi, err := os.Lstat(tmp) |
| + switch { |
| + case errors.Is(err, os.ErrNotExist): |
| + return nil |
| + case err != nil: |
| + return err |
| + case !fi.Mode().IsRegular(): |
| + log.Printf("moves: %s: %s is not a regular file (%s); it is not the renderer's temp, and is left", host, tmp, fi.Mode()) |
| + return nil |
| + } |
| + if err := os.Remove(tmp); err != nil && !errors.Is(err, os.ErrNotExist) { |
| + return fmt.Errorf("remove the held render's temp: %w", err) |
| + } |
| + log.Printf("moves: %s: the held render's unfinished write %s is removed", host, tmp) |
| + return syncPath(dataDir) |
| +} |
| + |
| // rollbackOwnership is the record that this op created a path the target's |
| // cleaning may park (the final review's finding 1). The registered |
| // installation, the paths the landing listed under F, is park.Local's and is |