carlos / platform Public

census wake-latency-3: record-write layer for buildStates.write; the conflict test counts the copy's try (Astra P2 x2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 9566001755e337393bd6d8ebabaa1f76d793b17a parent 1b54c70
3 files changed, +34 −3
  • internal/host/buildstate_test.go +5 −2
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/wake_latency_3_census_test.go +28 −0

CI passed — run details

diff --git a/internal/host/buildstate_test.go b/internal/host/buildstate_test.go
index e4d0aa2ef..0be283fcf 100644
--- a/internal/host/buildstate_test.go
+++ b/internal/host/buildstate_test.go
@@ -599,8 +599,11 @@ func TestAPersistentConflictIsAnError(t *testing.T) {
if _, err := b.update(ctx, "a.example.com", bump); !errors.Is(err, release.ErrCASConflict) {
t.Fatalf("err = %v; want a CAS conflict", err)
}
- if n != updateTries {
- t.Fatalf("tried %d times, want %d", n, updateTries)
+ // The put above left this agent a copy of the object, so the first try
+ // goes on that copy (buildStates.write) and every fresh read still gets
+ // its own: updateTries of them after it.
+ if n != updateTries+1 {
+ t.Fatalf("tried %d times, want %d (the copy's try and %d fresh ones)", n, updateTries+1, updateTries)
}
if after := copyOf(t, reg); after.Column() != before.Column() {
t.Fatalf("a lost update changed the copy: %+v -> %+v", before, after)
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index a16efb787..7a4016832 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) {
if len(got) < 100 {
t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root)
}
- inventory := serviceRunsWriteCensusInventory()
+ inventory := wakeLatency3WriteCensusInventory()
problems := append(censusDiff(inventory, got), censusPolicy(inventory)...)
if len(problems) > 0 {
t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n "))
diff --git a/internal/provision/wake_latency_3_census_test.go b/internal/provision/wake_latency_3_census_test.go
new file mode 100644
index 000000000..381314290
--- /dev/null
+++ b/internal/provision/wake_latency_3_census_test.go
@@ -0,0 +1,28 @@
+package provision
+
+// Record-write census entries for wake-latency-3, layered on
+// serviceRunsWriteCensusInventory. Reviewed by the branch author; the census
+// owner approves the card (census-ruling-wake-latency-3,
+// docs/superpowers/notes/census-proposal-wake-latency-3.md).
+// - buildStates.write's first try goes on the copy this agent last wrote,
+// conditioned on its etag. Its one Put, the build-state object, is the
+// same Put with the same condition rule (the etag the merge's state came
+// with); its class is unchanged: nonrecord.
+func wakeLatency3WriteCensusInventory() []censusEntry {
+ entries := append([]censusEntry(nil), serviceRunsWriteCensusInventory()...)
+ replacements := []censusEntry{
+ {"internal/host/buildstate.go", "buildStates.write", "nonrecord", "sel:Put", "0c6620f6c436457c18142203cee157e4d2104c79304d1cfd1f159bd4fea40797"},
+ }
+ for _, r := range replacements {
+ found := false
+ for i, e := range entries {
+ if e.File == r.File && e.Unit == r.Unit {
+ entries[i], found = r, true
+ }
+ }
+ if !found {
+ entries = append(entries, r)
+ }
+ }
+ return entries
+}