From 832ca35db55efb8f2080f64b0a0a19fe63dcaa5f Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sun, 2 Aug 2026 23:55:43 +0100 Subject: [PATCH] Remove dead resource_metadata table from unified resource store schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The resource_metadata table (canonical_id-keyed custom_url/custom_name/ notes/tags) had no readers or writers anywhere in pulse or pulse-enterprise; guest metadata is owned by the JSON-file store in internal/config/guest_metadata.go keyed by instance:node:vmid. Stop declaring the dead table and its index in fresh schemas. Deployed databases are left alone deliberately — no DROP TABLE migration, since a stale unused table is harmless. store_test.go now fails if a fresh store's sqlite_master reintroduces resource_metadata. --- .../internal/subsystems/unified-resources.md | 19 +++++++++++++++++++ internal/unifiedresources/store.go | 12 ------------ internal/unifiedresources/store_test.go | 3 +++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md index f2085b51a..81fc5c020 100644 --- a/docs/release-control/v6/internal/subsystems/unified-resources.md +++ b/docs/release-control/v6/internal/subsystems/unified-resources.md @@ -4334,3 +4334,22 @@ narrow. Shared resource adapters may admit explicit aliases such as `host`, through the canonical resource model, but unified-resource consumers must not reintroduce removed workload aliases or feature-local resource-type shims just to satisfy one table, drawer, or badge surface. + +### Resource store does not declare a resource_metadata table + +The SQLite resource store schema in `internal/unifiedresources/store.go` no +longer declares the `resource_metadata` table (canonical_id-keyed +custom_url/custom_name/notes/tags rows) or its +`idx_resource_metadata_canonical` index. The table had no readers or writers +anywhere in the codebase, including `pulse-enterprise`; guest metadata is +owned by the JSON-file store in `internal/config/guest_metadata.go`, keyed by +`instance:node:vmid`. The unified-resource store must not grow a competing +user-metadata surface — reintroducing a metadata table here would fork +metadata ownership across two stores with different keying models. + +Existing deployed databases are intentionally left alone: no `DROP TABLE` +migration is issued, because a stale unused table is harmless while a +destructive migration is not. The boundary is only that fresh schema creation +stops declaring dead tables. +`internal/unifiedresources/store_test.go` pins this by failing if a fresh +store's `sqlite_master` contains `resource_metadata`. diff --git a/internal/unifiedresources/store.go b/internal/unifiedresources/store.go index b0dbbafe3..6d3b71d4c 100644 --- a/internal/unifiedresources/store.go +++ b/internal/unifiedresources/store.go @@ -444,18 +444,6 @@ func (s *SQLiteResourceStore) initSchema() error { CREATE INDEX IF NOT EXISTS idx_resource_exclusions_a ON resource_exclusions(resource_a); CREATE INDEX IF NOT EXISTS idx_resource_exclusions_b ON resource_exclusions(resource_b); - CREATE TABLE IF NOT EXISTS resource_metadata ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - canonical_id TEXT NOT NULL UNIQUE, - custom_url TEXT, - custom_name TEXT, - notes TEXT, - tags TEXT, - updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, - updated_by TEXT - ); - CREATE INDEX IF NOT EXISTS idx_resource_metadata_canonical ON resource_metadata(canonical_id); - CREATE TABLE IF NOT EXISTS resource_changes ( id TEXT PRIMARY KEY, canonical_id TEXT NOT NULL, diff --git a/internal/unifiedresources/store_test.go b/internal/unifiedresources/store_test.go index 566a1ed45..d708ac3b1 100644 --- a/internal/unifiedresources/store_test.go +++ b/internal/unifiedresources/store_test.go @@ -60,6 +60,9 @@ func TestSQLiteResourceStoreDoesNotPersistRawOperationReceiptProtocolOrReplayAut if strings.Contains(lower, "operation_receipt_version") || name == "operation_receipts" { t.Fatalf("resource store acquired raw protocol or agent replay authority: table=%q schema=%q", name, schema) } + if name == "resource_metadata" { + t.Fatalf("resource store declares the dead resource_metadata table; guest metadata lives in the JSON-file store (internal/config/guest_metadata.go): schema=%q", schema) + } } if err := rows.Err(); err != nil { t.Fatal(err)