Skip to content

finding(objectql): registerObject's cross-package ownership refusal throws a bare Error, so no rejection test on that path can assert an ADR-0112 envelope #14367

Closed

Description

@hotlong

Found while implementing ADR-0130 D1+D3 (#14163 / PR #14354). Out of that card's scope, filed rather than fixed.

The site

SchemaRegistry.registerObject refuses a second code package claiming an object name another package already owns:

// packages/objectql/src/registry.ts — registerObject, ownership: 'own'
throw new Error(
  `Object "${fqn}" is already owned by package "${existingOwner.packageId}". ` +
  `Package "${packageId}" cannot claim ownership. Use 'extend' to add fields.`
);

It is a real refusal on a real path — the metadata load path reaches it through registerApp — but it carries no code and no status, so it is not an ADR-0112 envelope like the sibling refusals around it (resolveArtifactPackageOrder's DUPLICATE_ARTIFACT_PACKAGE / INVALID_ARTIFACT_PACKAGE_ENTRY, and the DUPLICATE_ARTIFACT_OBJECT_NAME refusal PR #14354 adds one layer up).

Why it matters, measured rather than argued

While reverse-verifying #14163 I ablated the new install-time object-name check and re-ran the pairing suite. The assertion expect(refused).toBeDefined() stayed green through that ablation — because this bare Error fires one step later and looks, to a throw-shaped assertion, exactly like the refusal that had just been deleted. Only the envelope assertion (code + status) went red.

So any rejection test written against this ownership rule today can only be a bare toThrow(), which is precisely the assertion ADR-0112 and ADR-0130 D3 rule out by name: it stays green against an unrelated Error from anywhere else in the path.

Suggested shape (not prescriptive)

Give the refusal an envelope — an error class with code (SCREAMING_SNAKE, registered in the dispatcher error-code vocabulary with a reachability verdict, the way DUPLICATE_ARTIFACT_OBJECT_NAME is) and status: 422 — keeping the message text as-is so existing message-substring assertions are unaffected. Worth checking at the same time whether any current test asserts only that this path throws.

Note the neighbouring late-install branch (ADR-0029 D9 §6.1, tenant-authored sitting owner) is not a refusal and is not part of this.

Activity

  1. added
    bug
    priority:p2
    pm:queue
    needs:contract-review
    domain:engine
    on Sep 2, 2026
  2. added theissue type on Sep 2, 2026
  3. huangyiirene commented on Sep 2, 2026

    @huangyiirene
    Collaborator

    Triage: bug · priority:p2 · pm:queue · domain:engine (packages/objectql) · needs:contract-review · type Bug. Found by the full-backlog bare-card sweep — filed 03:17Z, never touched again.

    Verified on origin/main @ f7d92d3: the bare throw is at packages/objectql/src/registry.ts:1802. ✔

    Two location facts the card is right about but does not spell out, and which would otherwise cost the implementer a search:

    • The sibling codes DUPLICATE_ARTIFACT_PACKAGE / INVALID_ARTIFACT_PACKAGE_ENTRY live in packages/runtime/src/dispatcher-error-vocabulary.ts, ⛔ not in packages/spec/src/api/error-code-ledger.zod.ts (0 hits there). Registering the new code follows that file.
    • packages/objectql/src/artifact-packages.ts already registers into it from this package, so the cross-package pattern is established and needs no invention. ⇒ Anchor stays domain:engine: the refusal is objectql's, the vocabulary entry is the consequence.

    Why this is the bug lane and not the human floor. Adding a code to a published error vocabulary looks like widening the public surface, which would put it on the floor. It is not: ADR-0112 already declares that refusals carry envelopes, and ADR-0130 D3 already rules out bare-toThrow assertions by name. This site violates a declared contract; registering the code is how that contract gets satisfied, not a new capability. Restoration ⇒ dispatchable. needs:contract-review because the vocabulary itself moves.

    p2, and the card earns it with a measurement rather than an argument. The ablation result is the whole case: expect(refused).toBeDefined() stayed green while the install-time check it was testing had been deleted, because this bare Error fires one step later and is indistinguishable to a throw-shaped assertion. Only the envelope assertion went red. That is a test that cannot fail on the thing it names — the same class graded p2 twice already this shift (#14386, #14376), and it is worse here because it silently validated an ablation.

    Scope, as the card frames it, plus one instruction it implies:

    • Error class with code (SCREAMING_SNAKE) + status: 422, message text unchanged so existing substring assertions stay green — the card is right to fence that, and it is what makes this safe to land.
    • ⭐ Do the audit the card raises as a "worth checking" and treat it as part of the deliverable: find every current test that asserts only that this path throws, and upgrade it to the envelope. Leaving a bare toThrow() behind reproduces the exact false-green this card exists to remove.
    • ⛔ The neighbouring ADR-0029 D9 §6.1 late-install branch (tenant-authored sitting owner) is not a refusal and is not in scope. Do not give it an envelope.

    ⚠️ Serialisation, not a block. #14163 / PR #14354 adds DUPLICATE_ARTIFACT_OBJECT_NAME one layer up and is in flight. There is no hard dependency — the registration pattern already exists — but check that PR's state first and match its shape, so the two codes do not arrive with two spellings of the same idea.

    Size/model suggestion: S at CONTRACT_REVIEW_TIER.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdomain:enginepriority:p2

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions