From b3758e0f1b7c531c6f1af14681f7bf936c02b35b Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Wed, 21 Oct 2026 16:42:24 -0700 Subject: [PATCH] db: store observed node execution policy and its receipt time Add nullable execution-policy JSON and an independent receipt timestamp to node_status_snapshots. A NULL-pairing constraint keeps unknown evidence distinct from an observed policy, without a table scan or backfill. Older inventory-only writers cannot renew the policy receipt. Deploy the migration before policy readers and writers; roll those binaries back before dropping the columns. Both directions bound DDL lock and statement waits. Apply/revert integration testing remains with CI. Validation: rebased onto current main; locked offline Cargo metadata resolution passed for x86_64 Linux and aarch64 macOS. The dependency-only diff and commit text were reviewed for public disclosures, and the source secret scan passed. Earlier compile checks predate this rebase; full compilation, tests and Linux/KVM validation remain with CI. --- .../20261021130815_node_execution_policy.down.sql | 7 +++++++ .../20261021130815_node_execution_policy.up.sql | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 db/postgres/20261021130815_node_execution_policy.down.sql create mode 100644 db/postgres/20261021130815_node_execution_policy.up.sql diff --git a/db/postgres/20261021130815_node_execution_policy.down.sql b/db/postgres/20261021130815_node_execution_policy.down.sql new file mode 100644 index 000000000..957e88f61 --- /dev/null +++ b/db/postgres/20261021130815_node_execution_policy.down.sql @@ -0,0 +1,7 @@ +-- Roll back policy readers and writers before removing their columns. +SET LOCAL lock_timeout = '1s'; +SET LOCAL statement_timeout = '5s'; + +ALTER TABLE node_status_snapshots + DROP COLUMN execution_policy, + DROP COLUMN execution_policy_received_at; diff --git a/db/postgres/20261021130815_node_execution_policy.up.sql b/db/postgres/20261021130815_node_execution_policy.up.sql new file mode 100644 index 000000000..8cff86442 --- /dev/null +++ b/db/postgres/20261021130815_node_execution_policy.up.sql @@ -0,0 +1,14 @@ +SET LOCAL lock_timeout = '1s'; +SET LOCAL statement_timeout = '5s'; + +ALTER TABLE node_status_snapshots + ADD COLUMN execution_policy JSONB, + ADD COLUMN execution_policy_received_at TIMESTAMPTZ, + ADD CONSTRAINT node_status_execution_policy_observation CHECK ( + (execution_policy IS NULL) = (execution_policy_received_at IS NULL) + ) NOT VALID; + +COMMENT ON COLUMN node_status_snapshots.execution_policy IS + 'Validated execution eligibility observation; NULL means unknown policy, not an empty allowlist'; +COMMENT ON COLUMN node_status_snapshots.execution_policy_received_at IS + 'Control-plane receipt time for this policy; inventory-only reports from older writers do not refresh it';