carlos / platform Public

host: a prepared replay's env object is read and verified, corrupt-object case (Task 6 fix round 3, platform-1e's ruling B)

404f81fa derives the expected replay from the prepared baseline and the
establishment's own operations and reads the env object at its key,
checking its digest and size (the mode is the entry's, held in the
field-for-field comparison). This adds the corrupt-object case beside
the missing-object and fabricated-sequence ones: the genuine manifest
with other bytes at the env object's key is refused. The behaviour
already held, so this commit is the regression alone.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 1b35a7ab6c595d6e69dc41123ef6f89689092930 parent c707325
1 file changed, +10 −3
  • internal/host/movesfiles_test.go +10 −3
diff --git a/internal/host/movesfiles_test.go b/internal/host/movesfiles_test.go
index 1bc735370..1e8f882c8 100644
--- a/internal/host/movesfiles_test.go
+++ b/internal/host/movesfiles_test.go
@@ -716,13 +716,20 @@ func TestEstablishRefusesAForeignEnvEntryOnPreparedReplay(t *testing.T) {
t.Fatalf("%s: the manifest was replaced: %s", name, cur)
}
}
- // The genuine bytes with their env object gone: refused too.
+ // The genuine bytes with their env object gone, or corrupt at its key
+ // (other bytes, the entry's digest and size no longer its own): refused
+ // too. The object is read and verified before a replay is accepted.
+ envObject := genuine.Platform[hostfiles.EnvItem].Object
x.bucket.Put("data", pm.Key, genuineRaw)
- x.bucket.BareDelete("data", genuine.Platform[hostfiles.EnvItem].Object)
+ x.bucket.BareDelete("data", envObject)
if err := x.f.Establish(ctx, o, in, x); err == nil {
t.Fatal("accepted a replay whose env object is gone")
}
- x.bucket.Put("data", genuine.Platform[hostfiles.EnvItem].Object, envBytes)
+ x.bucket.Put("data", envObject, []byte("K=corrupt\nCARLOS_INSTANCE_KEY=abc"))
+ if err := x.f.Establish(ctx, o, in, x); err == nil {
+ t.Fatal("accepted a replay whose env object is corrupt")
+ }
+ x.bucket.Put("data", envObject, envBytes)
// The genuine replay is accepted and writes nothing.
x.bucket.Put("data", pm.Key, genuineRaw)
seq1 := x.bucket.LatestID("data", pm.Key)