hub v0.167.0 source (not built, not deployed): D31 — the F-14 PBS auto re-issue reads the newest deletion of a host that held a key, a keyless install between no longer blocks it (R-1205); D30 — the new key's handshake clears wg_tunnel_stale (pinned), wording; wire gate entry; Part 1 stray-copy 9202 evidence
gates / gates (push) Successful in 15m46s

This commit is contained in:
admin committed 2026-10-22 21:04:42 +02:00
1 parent 96ac07e168
commit 84751cb0ce
18 files changed
+517 -13

No files matched your search

+37
View File
@@ -281,3 +281,40 @@ func TestCountHostArtifacts(t *testing.T) {
t.Errorf("unknown host artifacts = %+v, want zero value", empty)
}
}
// D31 (R-1205): the F-14 gate's row is the newest deletion of a host that HELD A KEY; a later keyless install's
// un-acked deletion is skipped. RED-PROOF (2026-10-22 night): with the `AND escrow_acked = 1` filter removed, this
// fails (it returns the keyless gen2-host).
func TestLatestKeyHoldingHostDeletion_SkipsAKeylessInstall(t *testing.T) {
s := newTestStore(t)
seedHostWithArtifacts(t, s, "gen1-host", "cust-d31")
if err := s.DeleteHost("gen1-host", true); err != nil { // held a key → acked
t.Fatal(err)
}
if err := s.UpsertHost(&Host{HostID: "gen2-host", CustomerID: "cust-d31", APIKey: "k2"}); err != nil {
t.Fatal(err)
}
if err := s.DeleteHost("gen2-host", true); err != nil { // never made a key → un-acked even with the box ticked
t.Fatal(err)
}
rec, err := s.LatestKeyHoldingHostDeletion("cust-d31")
if err != nil || rec == nil {
t.Fatalf("LatestKeyHoldingHostDeletion = %+v, %v", rec, err)
}
if rec.HostID != "gen1-host" || !rec.EscrowAcked {
t.Errorf("row = %+v, want the key-holding gen1-host", rec)
}
if rec, err := s.LatestKeyHoldingHostDeletion("cust-never"); err != nil || rec != nil {
t.Errorf("no deletions → nil, got %+v, %v", rec, err)
}
s2 := newTestStore(t)
if err := s2.UpsertHost(&Host{HostID: "only-keyless", CustomerID: "cust-k", APIKey: "k"}); err != nil {
t.Fatal(err)
}
if err := s2.DeleteHost("only-keyless", true); err != nil {
t.Fatal(err)
}
if rec, err := s2.LatestKeyHoldingHostDeletion("cust-k"); err != nil || rec != nil {
t.Errorf("only a keyless deletion → nil (the manual path stays), got %+v, %v", rec, err)
}
}
+25
View File
@@ -3336,6 +3336,31 @@ func (s *Store) LatestHostDeletion(customerID string) (*HostDeletion, error) {
return &d, nil
}
// LatestKeyHoldingHostDeletion returns the customer's most recent deletion of a host that HELD A KEY — escrow_acked=1,
// the escrow-ack flow over a real escrow row (nil when there is none). D31 (operator 2026-10-22, R-1205): the F-14
// gate reads THIS row. An un-acked deletion is a host that never made a key (DeleteHost refuses a host with an escrow
// row unless acknowledged), so it orphaned no tenancy and must not block the re-issue for the next install — the
// escrow carry's own reasoning (escrow_carry.go). Pinned by TestLatestKeyHoldingHostDeletion_SkipsAKeylessInstall
// and TestPBSDR_D31_AKeylessInstallBetweenDoesNotBlockTheReissue.
func (s *Store) LatestKeyHoldingHostDeletion(customerID string) (*HostDeletion, error) {
var d HostDeletion
var deletedAt string
err := s.db.QueryRow(`
SELECT host_id, customer_id, deleted_at
FROM host_deletions WHERE customer_id = ? AND escrow_acked = 1
ORDER BY id DESC LIMIT 1`, customerID,
).Scan(&d.HostID, &d.CustomerID, &deletedAt)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, err
}
d.DeletedAt = parseSQLiteTime(deletedAt)
d.EscrowAcked = true
return &d, nil
}
// UpsertHost creates or updates a host identity (used by the admin mint). On
// conflict it updates only operator-settable identity fields + updated_at; it does
// NOT touch the reality columns (agent_version/last_report_at) or the inert intent