Skip to content

A test named "getObject should be shorthand for get('object', name)" never calls get('object', …) #6843

Description

@os-project-manager

Observation-class finding, filed per Prime Directive #10 while implementing #6745 (PR #6839). Unassigned, finding, deliberately not queued — nothing a user hits; the hazard is aimed at the next agent reading this area.

The fact (read on origin/main)

packages/metadata/src/metadata-service.test.ts:131-136:

describe('getObject / listObjects', () => {
    it('getObject should be shorthand for get("object", name)', async () => {
      await manager.register('object', 'account', { name: 'account', label: 'Account' });
      const result = await manager.getObject('account');
      expect(result).toEqual({ name: 'account', label: 'Account' });
    });

The case name states the getObject(n) = get('object', n) equivalence. The body never calls get — it compares getObject's answer against the object literal that was just registered. There is no pair in it, so it cannot go red on a divergence between the two members: rewrite getObject to resolve some other way and, as long as it still returns the registered document, this stays green.

Its sibling two cases down has the same shape (listObjects should be shorthand for list("object") asserts only toHaveLength(2)).

Why it is worth a line

This is the shape that makes a coverage claim without carrying it. #6745 exists because PR #6723 documented the getObject / get('object', …) equivalence on the contract and left it ungated; a reader grepping for prior art lands on this case name first and can reasonably conclude the equivalence is already pinned somewhere. It is not — the assertion under that name is about a different fact (that getObject returns what was registered).

Not a defect in shipped behaviour: the equivalence itself holds today in all three implementations, measured under #6745, and PR #6839 now gates it (packages/objectql/src/metadata-service-getobject-equivalence.test.ts, four subjects covering MetadataManager under both of its resolution paths, createMemoryMetadata and MetadataFacade).

Dispositions worth pricing (no recommendation forced)

  1. Rename the two cases to what they actually assert (getObject returns the registered document) — cheapest, removes the false prior-art signal, adds no coverage.
  2. Add the missing get('object', name) call and compare the pair, making the name true for this one implementation — note PR test(objectql): pin getObject(n) = get('object', n) across all three IMetadataService implementations #6839 already covers MetadataManager on both paths, so this would be a deliberate local duplicate rather than new coverage.
  3. Leave it and rely on test(objectql): pin getObject(n) = get('object', n) across all three IMetadataService implementations #6839 being discoverable — leaves a case whose name outruns its body.

Refs #6745, PR #6839, #6505, PR #6723.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions