refactor(ports): delete dead broker completion staleness and job kind stringer
BrokerCompletionIsStale and its dedicated test had no production caller and no other test exercising the same behavior through a live path. RemoteJobKind.String is never invoked, directly or through %v formatting, in production or tests.
- commit
- 05bb4e9b6439a6196882c14e98b001338c51e037
- author
- brice · · 2026-09-23 01:54 UTC
- parent
- 5a12f4f
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +0 -55
M internal/ports/broker.go +0 -14
| @@ -336,20 +336,6 @@ func (s BrokerSnapshot) Supersedes(other BrokerSnapshot) bool { | |||
| 336 | 336 | return s.Revision > other.Revision | |
| 337 | 337 | } | |
| 338 | 338 | ||
| 339 | - | // BrokerCompletionIsStale reports whether a probe or operation completion | |
| 340 | - | // must be rejected: a different broker epoch, or a registration that no | |
| 341 | - | // longer exactly matches current authority (endpoint, incarnation, and | |
| 342 | - | // generation must all match). | |
| 343 | - | func BrokerCompletionIsStale(currentRegistration domain.RemoteRegistration, currentEpoch BrokerEpoch, completionRegistration domain.RemoteRegistration, completionEpoch BrokerEpoch) bool { | |
| 344 | - | if currentEpoch == 0 || completionEpoch == 0 { | |
| 345 | - | return true | |
| 346 | - | } | |
| 347 | - | if currentEpoch != completionEpoch { | |
| 348 | - | return true | |
| 349 | - | } | |
| 350 | - | return !currentRegistration.Equal(completionRegistration) | |
| 351 | - | } | |
| 352 | - | ||
| 353 | 339 | // BrokerStreamAdmission is the closed attachment-admission taxonomy | |
| 354 | 340 | // (Plan 001 P5.3a, contract-only until the admission slice wires it): | |
| 355 | 341 | // an attachment stream names exactly how the daemon must admit it. | |
| @@ -336,20 +336,6 @@ func (s BrokerSnapshot) Supersedes(other BrokerSnapshot) bool { | |||||
| 336 | return s.Revision > other.Revision | 336 | return s.Revision > other.Revision | ||
| 337 | } | 337 | } | ||
| 338 | 338 | ||||
| 339 | - | // BrokerCompletionIsStale reports whether a probe or operation completion | |||
| 340 | - | // must be rejected: a different broker epoch, or a registration that no | |||
| 341 | - | // longer exactly matches current authority (endpoint, incarnation, and | |||
| 342 | - | // generation must all match). | |||
| 343 | - | func BrokerCompletionIsStale(currentRegistration domain.RemoteRegistration, currentEpoch BrokerEpoch, completionRegistration domain.RemoteRegistration, completionEpoch BrokerEpoch) bool { | |||
| 344 | - | if currentEpoch == 0 || completionEpoch == 0 { | |||
| 345 | - | return true | |||
| 346 | - | } | |||
| 347 | - | if currentEpoch != completionEpoch { | |||
| 348 | - | return true | |||
| 349 | - | } | |||
| 350 | - | return !currentRegistration.Equal(completionRegistration) | |||
| 351 | - | } | |||
| 352 | - | ||||
| 353 | // BrokerStreamAdmission is the closed attachment-admission taxonomy | 339 | // BrokerStreamAdmission is the closed attachment-admission taxonomy | ||
| 354 | // (Plan 001 P5.3a, contract-only until the admission slice wires it): | 340 | // (Plan 001 P5.3a, contract-only until the admission slice wires it): | ||
| 355 | // an attachment stream names exactly how the daemon must admit it. | 341 | // an attachment stream names exactly how the daemon must admit it. | ||
M internal/ports/broker_test.go +0 -25
| @@ -326,31 +326,6 @@ func TestBrokerTombstoneFencing(t *testing.T) { | |||
| 326 | 326 | } | |
| 327 | 327 | } | |
| 328 | 328 | ||
| 329 | - | func TestBrokerCompletionStaleRejection(t *testing.T) { | |
| 330 | - | current := testBrokerRegistration("user@arch", 4, 2) | |
| 331 | - | tests := []struct { | |
| 332 | - | name string | |
| 333 | - | currentEpoch BrokerEpoch | |
| 334 | - | completion domain.RemoteRegistration | |
| 335 | - | completionEp BrokerEpoch | |
| 336 | - | wantStale bool | |
| 337 | - | }{ | |
| 338 | - | {name: "exact match applies", currentEpoch: 3, completion: current, completionEp: 3, wantStale: false}, | |
| 339 | - | {name: "epoch change stale", currentEpoch: 4, completion: current, completionEp: 3, wantStale: true}, | |
| 340 | - | {name: "generation bump stalls old", currentEpoch: 3, completion: testBrokerRegistration("user@arch", 4, 1), completionEp: 3, wantStale: true}, | |
| 341 | - | {name: "re-add incarnation stalls old", currentEpoch: 3, completion: testBrokerRegistration("user@arch", 5, 1), completionEp: 3, wantStale: true}, | |
| 342 | - | {name: "zero epoch stale", currentEpoch: 0, completion: current, completionEp: 3, wantStale: true}, | |
| 343 | - | {name: "zero completion epoch stale", currentEpoch: 3, completion: current, completionEp: 0, wantStale: true}, | |
| 344 | - | } | |
| 345 | - | for _, tt := range tests { | |
| 346 | - | t.Run(tt.name, func(t *testing.T) { | |
| 347 | - | if got := BrokerCompletionIsStale(current, tt.currentEpoch, tt.completion, tt.completionEp); got != tt.wantStale { | |
| 348 | - | t.Fatalf("BrokerCompletionIsStale() = %t, want %t", got, tt.wantStale) | |
| 349 | - | } | |
| 350 | - | }) | |
| 351 | - | } | |
| 352 | - | } | |
| 353 | - | ||
| 354 | 329 | func TestBrokerPolicyCompatibility(t *testing.T) { | |
| 355 | 330 | base := testBrokerPolicy() | |
| 356 | 331 | if err := base.Validate(); err != nil { | |
| @@ -326,31 +326,6 @@ func TestBrokerTombstoneFencing(t *testing.T) { | |||||
| 326 | } | 326 | } | ||
| 327 | } | 327 | } | ||
| 328 | 328 | ||||
| 329 | - | func TestBrokerCompletionStaleRejection(t *testing.T) { | |||
| 330 | - | current := testBrokerRegistration("user@arch", 4, 2) | |||
| 331 | - | tests := []struct { | |||
| 332 | - | name string | |||
| 333 | - | currentEpoch BrokerEpoch | |||
| 334 | - | completion domain.RemoteRegistration | |||
| 335 | - | completionEp BrokerEpoch | |||
| 336 | - | wantStale bool | |||
| 337 | - | }{ | |||
| 338 | - | {name: "exact match applies", currentEpoch: 3, completion: current, completionEp: 3, wantStale: false}, | |||
| 339 | - | {name: "epoch change stale", currentEpoch: 4, completion: current, completionEp: 3, wantStale: true}, | |||
| 340 | - | {name: "generation bump stalls old", currentEpoch: 3, completion: testBrokerRegistration("user@arch", 4, 1), completionEp: 3, wantStale: true}, | |||
| 341 | - | {name: "re-add incarnation stalls old", currentEpoch: 3, completion: testBrokerRegistration("user@arch", 5, 1), completionEp: 3, wantStale: true}, | |||
| 342 | - | {name: "zero epoch stale", currentEpoch: 0, completion: current, completionEp: 3, wantStale: true}, | |||
| 343 | - | {name: "zero completion epoch stale", currentEpoch: 3, completion: current, completionEp: 0, wantStale: true}, | |||
| 344 | - | } | |||
| 345 | - | for _, tt := range tests { | |||
| 346 | - | t.Run(tt.name, func(t *testing.T) { | |||
| 347 | - | if got := BrokerCompletionIsStale(current, tt.currentEpoch, tt.completion, tt.completionEp); got != tt.wantStale { | |||
| 348 | - | t.Fatalf("BrokerCompletionIsStale() = %t, want %t", got, tt.wantStale) | |||
| 349 | - | } | |||
| 350 | - | }) | |||
| 351 | - | } | |||
| 352 | - | } | |||
| 353 | - | ||||
| 354 | func TestBrokerPolicyCompatibility(t *testing.T) { | 329 | func TestBrokerPolicyCompatibility(t *testing.T) { | ||
| 355 | base := testBrokerPolicy() | 330 | base := testBrokerPolicy() | ||
| 356 | if err := base.Validate(); err != nil { | 331 | if err := base.Validate(); err != nil { | ||
M internal/ports/remote_runtime.go +0 -16
| @@ -20,22 +20,6 @@ const ( | |||
| 20 | 20 | RemoteJobCacheStore | |
| 21 | 21 | ) | |
| 22 | 22 | ||
| 23 | - | // String returns the stable lowercase token for a job kind. | |
| 24 | - | func (k RemoteJobKind) String() string { | |
| 25 | - | switch k { | |
| 26 | - | case RemoteJobRegistryRead: | |
| 27 | - | return "registry_read" | |
| 28 | - | case RemoteJobCacheLoad: | |
| 29 | - | return "cache_load" | |
| 30 | - | case RemoteJobCatalogObserve: | |
| 31 | - | return "catalog_observe" | |
| 32 | - | case RemoteJobCacheStore: | |
| 33 | - | return "cache_store" | |
| 34 | - | default: | |
| 35 | - | return "unknown" | |
| 36 | - | } | |
| 37 | - | } | |
| 38 | - | ||
| 39 | 23 | // RemoteJob is one admitted unit of remote work. Registration and Generation | |
| 40 | 24 | // fence the job: results bound to a superseded registration never apply. | |
| 41 | 25 | // Deadline bounds catalogue observation; Entries carries cache-store payload. | |
| @@ -20,22 +20,6 @@ const ( | |||||
| 20 | RemoteJobCacheStore | 20 | RemoteJobCacheStore | ||
| 21 | ) | 21 | ) | ||
| 22 | 22 | ||||
| 23 | - | // String returns the stable lowercase token for a job kind. | |||
| 24 | - | func (k RemoteJobKind) String() string { | |||
| 25 | - | switch k { | |||
| 26 | - | case RemoteJobRegistryRead: | |||
| 27 | - | return "registry_read" | |||
| 28 | - | case RemoteJobCacheLoad: | |||
| 29 | - | return "cache_load" | |||
| 30 | - | case RemoteJobCatalogObserve: | |||
| 31 | - | return "catalog_observe" | |||
| 32 | - | case RemoteJobCacheStore: | |||
| 33 | - | return "cache_store" | |||
| 34 | - | default: | |||
| 35 | - | return "unknown" | |||
| 36 | - | } | |||
| 37 | - | } | |||
| 38 | - | ||||
| 39 | // RemoteJob is one admitted unit of remote work. Registration and Generation | 23 | // RemoteJob is one admitted unit of remote work. Registration and Generation | ||
| 40 | // fence the job: results bound to a superseded registration never apply. | 24 | // fence the job: results bound to a superseded registration never apply. | ||
| 41 | // Deadline bounds catalogue observation; Entries carries cache-store payload. | 25 | // Deadline bounds catalogue observation; Entries carries cache-store payload. | ||