Skip to content

protocol.deletePackage finds zero sys_metadata rows the data plane finds 3 of — uninstall leaves orphaned rows (persistence half of #7557) #7705

Description

@os-help

Part of #7557 — transferred to the metadata lane per the cross-seat protocol, from the engine-core dispatch of that card (PR #7700's report located it and deliberately did not patch it from the consumer side).

Symptom (reproduced live on origin/main, 2026-08-11)

DELETE /api/v1/packages/:id reports persisted: { success: false, deletedCount: 0, failedCount: 0 } while the package's sys_metadata rows demonstrably exist and survive: with 3 rows carrying package_id = 'com.repro.b',

  • protocol.deletePackage finds 0 rows to delete;
  • the same predicate through the data plane finds 3: GET /api/v1/data/sys_metadata?filters=[["package_id","=","com.repro.b"]] → 3 records.

After PR #7700 the dispatcher no longer wraps this in a 200 — but that fix is invisible to THIS defect by construction (failedCount: 0 legitimately reads as success). The rows still orphan until the producer stops missing them.

Located mechanism (from PR #7700's verification)

packages/metadata-protocol/src/protocol.ts:11486-11488:

const where = { package_id: request.packageId };
if (request.organizationId) where.organization_id = request.organizationId;
const rows = await this.engine.find('sys_metadata', { where });

The where clause is not intrinsically wrong (the data plane returns 3 with it). The scoping the protocol's engine applies to it is the suspect — strongest candidate: strict organization_id equality against rows stored env-wide (organization_id IS NULL). This is the same defect class this package already fixed once at sys-metadata-repository.ts:887-901, where identical strict equality silently dropped env-wide drafts and was replaced by an $or over [{organization_id: oid}, {organization_id: null}] (the orphaned-draft bug). Re-check commands:

git grep -n "organization_id" origin/main -- packages/metadata-protocol/src/protocol.ts | sed -n '1,10p'
git show origin/main:packages/metadata-service/src/sys-metadata-repository.ts | sed -n '880,905p'

Adjacent, distinct

No domain:* label applied — routing labels are the triage seat's single-producer territory; filed with pm:queue per the transfer-via-target-queue protocol.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions