Skip to content

[finding] Eight protocol test harnesses store every table in one row map, so a sys_metadata_history row is served back as an active sys_metadata row #16225

Description

@claude

Found while building a harness for #15950 (PR #16223), where it produced a
confidently wrong green that a passing assertion nearly hid.

The shape

Several metadata-protocol / objectql protocol test harnesses give the stub
engine ONE flat row map and discriminate tables by name in exactly one place:

async insert(_t: string, data: ROW_FIELDS) {   // ROW_FIELDS = the record type
    if (_t === 'sys_metadata_audit') return { id: 'audit_skip' };
    ...
    rows.set(keyOf(data), row);
}

find / findOne then ignore the table argument entirely and answer from that
same map. So every table the protocol writes that is NOT sys_metadata_audit
sys_metadata_history and sys_metadata_commit among them — lands in the map
that answers reads of sys_metadata.

Why it is not cosmetic

It was invisible for as long as nothing read sys_metadata as a table.
#16223 is the first change that does, and it surfaced immediately:

  • a DRAFT metadata save writes a sys_metadata_history row that carries no
    state;
  • the harness's insert defaulted an absent state to 'active' (modelling
    sys-metadata.object.ts's declared column default, correctly);
  • so the history row was served back as an ACTIVE sys_metadata row, and a
    dataset that existed only as a DRAFT resolved.

The test asserting "a draft must not satisfy a published board" failed for that
reason and no other. Had the assertion been written the other way round — or had
the harness been used to prove a store-reading change works — it would have
passed for a reason that exists nowhere but in the stub.

Population

8 files carry the exact flat-map form (git grep -l "if (_t === 'sys_metadata_audit') return"):

  • packages/metadata-protocol/src/protocol.dashboard-dataset-publish-gate.test.ts
  • packages/metadata-protocol/src/protocol.graft-folded-form-sections.test.ts
  • packages/metadata-protocol/src/protocol.package-closure-gate.test.ts
  • packages/metadata-protocol/src/protocol.platform-schedule-org-gate.test.ts
  • packages/metadata-protocol/src/protocol.runtime-authoring-gate.test.ts
  • packages/metadata-protocol/src/protocol.save-flow-canonicalization.test.ts
  • packages/objectql/src/protocol-save-meta-repo-path.test.ts
  • packages/objectql/src/protocol-view-identity-overlay.test.ts

45 files under those two packages mention sys_metadata_audit at all, so the
wider family is worth a look while someone is in there — the 8 above are only
the ones matching this exact spelling.

⛔ None of these 8 is known to be asserting anything false today: the flaw is
latent, and it bites the next harness that reads a table. Filing it as a finding
rather than a defect for that reason.

The fix that worked

packages/metadata-protocol/src/protocol.runtime-gate-stored-universe.test.ts
(added by #16223) keys the stub by table — one map from table NAME to that table's row
array, reached through a tableOf(name) accessor — and its header states the incident. It is a small
change to make and can be copied.


Generated by Claude Code

Activity

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

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions