Skip to content

Declare the URLCode extension contract every package is built for (#844) - #906

Merged
jimhoyd merged 4 commits into
mainfrom
claude/descriptor-contract-compat
Sep 29, 2026
Merged

jimhoyd merged 4 commits into
mainfrom
claude/descriptor-contract-compat

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Closes the remaining #844 gaps found by the audit.

Extension contract

  • One integer: core exports extensionContract = 1 (also from @jimhoyd/urlcode/extensions).
    • It covers the urlcode.json format, defineExtension/composeHost, the registration and activation interfaces, and the extensions exports.
    • It changes only on a breaking change to that contract, never with core semver. It is an integer rather than a range, because there are no intermediate contracts to span.
  • Declared everywhere: every urlcode.json (extensions and artifacts) and every ExtensionDefinition must declare contract. build:addons writes it for first-party packages and refuses a mismatch.
  • Checked at:
    • extensions add / artifacts add, before any entry is imported, with rollback;
    • list --strict and static validate;
    • artifact inertness (list, inspect, upgrade);
    • defineExtension;
    • composeHost, before any host() runs.
  • The refusal names both numbers and says how to fix it.

Tests

  • A compatible fixture and a new incompatible fixture @example/urlcode-beyond (contract 2): refused at add with full rollback. If npm-installed by hand, it is caught by list --strict, validate and composeHost.
  • An artifact with contract 2, and a descriptor with no contract, are both refused.
  • Duplicate core: a package bundling its own @jimhoyd/urlcode is refused at add and reported by list --strict.
  • Upgrade: a locked independent package survives urlcode upgrade and a catalog change, and keeps its own version.

Docs

  • EXTENSIONS "The extension contract".
  • The stale "descriptor-only discovery is not a general third-party resolver" text is rewritten, as is the AI-tooling step that said add/remove don't manage third-party packages.
  • RIM-ADDON-001.

Evidence (macOS, Node 26)

Limits:

  • upgrade can't check independent packages against the target core's contract before switching; the new core's validate catches declared ones.
  • The descriptor and the definition are each checked against core, not directly against each other.

🤖 Generated with Claude Code

…built for (#844)

Core exports one integer extension contract (`extensionContract`, 1), bumped
only on a breaking change to the descriptor format, defineExtension/composeHost
or the registration and activation interfaces, never with core's semver. Every
urlcode.json descriptor (both kinds) and every defineExtension definition must
declare `contract`; any other value, or none, is refused naming both versions:

- extensions/artifacts add, from the installed descriptor before any entry is
  imported, with the usual rollback;
- list --strict and static validate for installed and declared extensions;
- the inert-artifact check (artifacts list, inspection, upgrade);
- defineExtension, and again composeHost before any host() runs.

build:addons writes each first-party extension's contract from its definition,
refuses one that differs from core's, and stamps first-party artifact
descriptors. A single integer instead of a range: the number moves only on
breaking changes, so a range could only claim compatibility with an untested
contract.

Tests: a compatible (greeting) and an incompatible (beyond, contract 2)
independent fixture through add, list --strict, validate and composeHost; an
independent package that bundles its own @jimhoyd/urlcode is refused at add and
reported by list --strict (the fake npm now locks bundled dependencies as npm
does); a locked independent package survives upgrade and a catalog change with
its own version; first-party descriptors carry the contract.

Docs: an "extension contract" section and descriptor field in EXTENSIONS.md,
the stale "descriptor-only discovery ... not a general third-party package
resolver" and "add/remove do not manage third-party packages" prose rewritten,
RIM-ADDON-001 updated. The core packed/unpacked budgets are raised with
measurements: main at 4a09546 is already over the packed budget in CI.

BREAKING CHANGE: urlcode.json and defineExtension definitions require
`contract`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 12:45
@jimhoyd
jimhoyd merged commit b42218c into main Sep 29, 2026
28 checks passed
@jimhoyd
jimhoyd deleted the claude/descriptor-contract-compat branch September 29, 2026 13:25
jimhoyd added a commit that referenced this pull request Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant