test(archied): age the apply-status fixture by the documented window

The clause-5 staleness reading aged its fixture by applystatus.StaleAfter, so
the fixture moved with the very constant the reader is supposed to honour and
the reading agreed with the reader by construction: mutating StaleAfter to
1000h left the test passing, which is a staleness assertion that never went
stale.

Age the row by the documented 90-second window (three 30-second re-stamps,
docs/prds/control-plane-apply-status.md) held as a fixture literal instead, so
a window that stopped expiring fails the reading, and say in the fresh half's
assertion that it is the other end of that age pair.

archie-core-eju6.
This commit is contained in:
sam committed 2026-09-21 23:12:24 +10:00
1 parent 3bbad40738
commit ac5aa317a8
1 file changed
+23 -8
@@ -40,6 +40,17 @@ var (
// control plane's executionSettingsDocument spells it.
const restartStoredDocument = `{"max_model_tool_steps": 25, "max_runtime_seconds": 3600, "max_consecutive_gate_failures": 4}`
// documentedStaleWindow is the window the operator-facing contract documents:
// every process re-stamps its records every 30 seconds, and "a record is stale
// once it is older than 90 seconds" (docs/prds/control-plane-apply-status.md,
// "What is reported"). It is a fixture literal on purpose. Reading
// applystatus.StaleAfter here would derive the aged row from the constant the
// reader is supposed to honour, so the fixture would move with any mutation of
// that constant and the reading below would agree with the reader by
// construction -- a test that passes for a window measured in hours is a test
// that never went stale at all.
const documentedStaleWindow = 90 * time.Second
// settingsDocument mirrors the stored document, so an assertion can read a
// revision's value back as the limits it means rather than as bytes.
type settingsDocument struct {
@@ -140,23 +151,27 @@ func TestControlPlaneSettingsChangeSurvivesProcessRestart(t *testing.T) {
}
// 5. The apply-status row for the restarted process reports the version it
// applied, and the settings page reads that row as current...
// applied, and the settings page reads that row as current: it was reported
// at now, which is the fresh half of the age pair the aged read below
// completes.
if row := reportedRow(t, admin, kind); row.AppliedVersion != 2 || row.Error != "" {
t.Fatalf("apply status after the restart = %+v, want version 2 and no error", row)
}
if state := applyStatusState(t, dashboard, kind); state != applyStateCurrentWire {
t.Fatalf("the settings page reads the freshly re-stamped row as %q, want %q", state, applyStateCurrentWire)
t.Fatalf("the settings page reads the row reported at now as %q, want %q", state, applyStateCurrentWire)
}
// ...and reads a row older than the staleness window as not reporting
// rather than as current. The row is re-stamped every 30 seconds by the
// process that wrote it, so a row that stopped being re-stamped is a
// ...and reads a row older than the documented staleness window as not
// reporting rather than as current. The row is re-stamped every 30 seconds
// by the process that wrote it, so a row that stopped being re-stamped is a
// process that stopped -- the reader must not present its last report as
// live. Ageing it through the same administrative surface is what the
// clock would have done to it.
// live. Ageing it through the same administrative surface is what the clock
// would have done to it, and the age is the documented 90 seconds rather
// than whatever the reader's own constant happens to be, so a window that
// stopped expiring really does fail the reading.
if err := admin.PutApplyStatus(t.Context(), storecontract.ApplyStatus{
Process: applystatus.Daemon, Kind: kind, AppliedVersion: 2,
ReportedAt: time.Now().UTC().Add(-applystatus.StaleAfter - time.Second),
ReportedAt: time.Now().UTC().Add(-documentedStaleWindow - time.Second),
}); err != nil {
t.Fatalf("age the apply status row: %v", err)
}