hub: review fix 5 — a window request the hub cannot read is 400; every answer says accepts_ended (version skew)

- POST /offsite/window-open answered 200 on a body it could not parse and
  decided the window on „count 0”; now 400 (the empty body of the oldest boxes
  is still „no count”).
- Every answer carries accepts_ended, granted or not: a box sends its end
  records only to a hub that said so, so a new box never sends a large request
  to an older hub that reads 4 KiB.

Carries the red-proof of both halves (the controller's is the next commit
there). Tests seen red; 3 hub mutations seen red, 1 after a redo.

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 14:57:24 +01:00
1 parent 6d2d4bd09d
commit 45848f6ee4
8 files changed
+168 -5

No files matched your search

@@ -0,0 +1,86 @@
FINDING 5 — version skew: a new box with an older hub can stall the weekly clean-up; an unreadable request was decided as count 0.
### RED, hub: the new tests before the fix (felhom.eu 6d2d4bd0)
=== RUN TestD84_WindowOpen_ABodyTheHubCannotReadIs400
d84_window_skew_test.go:37: cut in the middle (a read limit): HTTP 200, want 400 — the hub must not decide a window on a body it could not read
d84_window_skew_test.go:40: cut in the middle (a read limit): the window service was asked although the body could not be read
d84_window_skew_test.go:37: not JSON: HTTP 200, want 400 — the hub must not decide a window on a body it could not read
d84_window_skew_test.go:40: not JSON: the window service was asked although the body could not be read
d84_window_skew_test.go:37: a list, not an object: HTTP 200, want 400 — the hub must not decide a window on a body it could not read
d84_window_skew_test.go:40: a list, not an object: the window service was asked although the body could not be read
--- FAIL: TestD84_WindowOpen_ABodyTheHubCannotReadIs400 (0.05s)
=== RUN TestD84_WindowAnswerSaysTheHubUnderstandsEnded
d84_window_skew_test.go:56: the answer {"granted":false,"newest_allowed":"0001-01-01T00:00:00Z","reason":"not due"} does not say accepts_ended — a new box would never send its end records
d84_window_skew_test.go:56: the answer {"granted":true,"newest_allowed":"0001-01-01T00:00:00Z"} does not say accepts_ended — a new box would never send its end records
--- FAIL: TestD84_WindowAnswerSaysTheHubUnderstandsEnded (0.00s)
FAIL
FAIL gitea.dooplex.hu/admin/felhom-hub/internal/api 0.076s
FAIL
### RED, controller: the new tests before the fix (felhom-controller c7e4ec9)
=== RUN TestD84_ANewBoxWithAnOlderHub_NothingEndedIsSentAndTheCleanUpStillRuns
offbox_ended_skew_test.go:29: week 1: the box sent 1 end record(s) to a hub that never said it reads them — that hub reads 4 KiB and would stall
--- FAIL: TestD84_ANewBoxWithAnOlderHub_NothingEndedIsSentAndTheCleanUpStillRuns (0.00s)
=== RUN TestD84_OneRequestCarriesABoundedNumberOfIds
offbox_ended_skew_test.go:83: one request carried 5200 snapshot ids, want the limit 5000
--- FAIL: TestD84_OneRequestCarriesABoundedNumberOfIds (0.03s)
FAIL
FAIL gitea.dooplex.hu/admin/felhom-controller/internal/backup 0.050s
FAIL
### After the fix: mutations, hub
== MUTATION: a body that cannot be read is decided as count 0 again
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_WindowOpen_ABodyTheHubCannotReadIs400 (0.05s)
d84_window_skew_test.go:36: cut in the middle (a read limit): HTTP 200, want 400 — the hub must not decide a window on a body it could not read
d84_window_skew_test.go:39: cut in the middle (a read limit): the window service was asked although the body could not be read
d84_window_skew_test.go:36: not JSON: HTTP 200, want 400 — the hub must not decide a window on a body it could not read
== MUTATION: the answer does not say that the hub understands ended apps
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_WindowOpen_ABodyTheHubCannotReadIs400 (0.05s)
d84_window_skew_test.go:52: body "{\"count_before\":20}": the answer {"granted":false,"newest_allowed":"0001-01-01T00:00:00Z","reason":"not due","accepts_ended":false}
d84_window_skew_test.go:52: body "": the answer {"granted":false,"newest_allowed":"0001-01-01T00:00:00Z","reason":"not due","accepts_ended":false}
== MUTATION: the empty body of the oldest boxes is refused
*** NOT A RED-PROOF *** (mutant rc=1 built=False real rc=0)
FAIL gitea.dooplex.hu/admin/felhom-hub/internal/api [build failed]
3 mutations, 1 not a red-proof
### After the fix: mutations, controller
== MUTATION: the box sends its end records to any hub
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_ANewBoxWithAnOlderHub_NothingEndedIsSentAndTheCleanUpStillRuns (0.00s)
offbox_ended_skew_test.go:29: week 1: the box sent 1 end record(s) to a hub that never said it reads them — that hub reads 4 KiB and would stall
== MUTATION: the box does not remember the hub's answer
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_ANewBoxWithAnOlderHub_NothingEndedIsSentAndTheCleanUpStillRuns (0.00s)
offbox_ended_skew_test.go:49: the night the box LEARNS it: claims=0 learned=false — it must send none yet and remember the answer
== MUTATION: the box only ever learns „yes” (a rolled-back hub keeps getting end records)
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_ANewBoxWithAnOlderHub_NothingEndedIsSentAndTheCleanUpStillRuns (0.00s)
offbox_ended_skew_test.go:65: after a rolled-back hub's answer the box still sends end records: claims=0 learned=true
== MUTATION: no limit on the ids of one request
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_OneRequestCarriesABoundedNumberOfIds (0.03s)
offbox_ended_skew_test.go:84: one request carried 5200 snapshot ids, want the limit 5000
4 mutations, 0 not a red-proof
== MUTATION: the client does not read accepts_ended
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_WindowClient_SendsTheClaimsAndReadsTheAgreement (0.00s)
d84_window_client_test.go:63: accepts_ended of a not-granted answer was not read
== MUTATION: the client reads every hub as one that knows end records
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_WindowClient_SendsTheClaimsAndReadsTheAgreement (0.00s)
d84_window_client_test.go:44: an answer WITHOUT accepts_ended (an older hub) reads as a hub that knows end records
2 mutations, 0 not a red-proof
### the hub mutation done again
== MUTATION: REDO (the first mutant did not compile: `strings` unused): the empty body of the oldest boxes is refused
RED on the mutant, GREEN on the real file
--- FAIL: TestD84_WindowOpen_ABodyTheHubCannotReadIs400 (0.05s)
d84_window_skew_test.go:46: body "": HTTP 400, want 200
d84_window_skew_test.go:52: body "": the answer the window request could not be read (not JSON, or cut)
1 mutations, 0 not a red-proof