Skip to content

Derive addressable-source coverage from the vocabulary - #186

Merged
patchstackdave merged 1 commit into
mainfrom
fix/derive-coordinate-coverage-from-vocabulary
Aug 27, 2026
Merged

patchstackdave merged 1 commit into
mainfrom
fix/derive-coordinate-coverage-from-vocabulary

Conversation

@patchstackdave

Copy link
Copy Markdown
Contributor

Fixes the P3 from #183's review, and a second instance of the same defect found while doing it.

The completeness assertion asserted nothing

expect(new Set(cases.map((c) => c.space))).toEqual(new Set(['body', 'query', 'cookie', 'header', 'file']));

One hard-coded set against another hard-coded set — the file agreeing with itself. A sixth addressable source would not have failed it, which is the gap it was written to close.

The root cause was that the vocabulary could not be asked. InputSource was a bare type union, and a union cannot be enumerated at runtime, so a test wanting "every source the map can address" had no option but to restate the list. Every sibling vocabulary in capabilities.ts is a runtime array with its type derived from it; this one was the exception.

Now INPUT_SOURCES is that array and InputSource derives from it. The assertion computes its expectation from production: a source is addressable when runtimeCoordinate yields a parameter, and every addressable source must have a case driven through the real engine.

Two supporting assertions so the grouping can't hide anything:

  • the body-shaped sources are asserted to collapse to post.<path>, not assumed to;
  • the unaddressable ones are asserted to stay unaddressable with a stated reason — a coordinate appearing for a route parameter would compile a rule the resolver cannot resolve.

Verified by adding a sixth addressable source (trailer → server.TRAILER_*): the new assertion fails, the old one passed.

A second instance, found on the way

Adding INPUT_SOURCES to CAPABILITY_MANIFEST did not put it in capabilities.json — emit-capabilities.mjs assembles the JSON from its own restated list of vocabulary names.

And emit-capabilities --check reported "up to date" throughout, because both sides omitted the field, so they agreed. A vocabulary could be declared, typed, used, and never ship, with the check built to catch exactly that saying nothing.

Demonstrated directly — with the emitter's line removed:

emit --check says:  capabilities.json is up to date.
the new guard says: Tests  1 failed | 31 passed (32)

The new guard asserts over the source: every exported as const vocabulary must reach the manifest with the same members. That is the only form of the assertion that cannot be satisfied by two files agreeing to be wrong together. It carries a floor on how many vocabularies it found, so an empty match cannot pass either.

State

Capability version 1.1.0 → 1.2.0; check-capability-version reads it as "additive change with a minor bump — added: field inputSources".

Full suite: 1670 passed, 6 skipped; typecheck, template typecheck and emit-capabilities --check clean.

🤖 Generated with Claude Code

…stated list

The round-trip suite's completeness assertion compared one hard-coded set against another hard-coded set,
so it asserted that the file agreed with itself. A sixth addressable source would not have failed it —
which is the gap it was written to close.

The root cause was that the vocabulary could not be asked. `InputSource` was a bare type union, and a
union cannot be enumerated at runtime, so a test wanting "every source the map can address" had no option
but to restate the list. Every sibling vocabulary in `capabilities.ts` is a runtime array with its type
derived from it; this one was the exception.

`INPUT_SOURCES` is now that array and `InputSource` is derived from it, so the two cannot disagree. The
assertion computes its own expectation: a source is addressable when `runtimeCoordinate` yields a
parameter for it, and every addressable source must have a case driven through the real engine. The
body-shaped sources are asserted to collapse to `post.<path>` rather than assumed to, so a divergence
cannot hide behind the grouping, and the unaddressable ones are asserted to stay unaddressable with a
stated reason — a coordinate appearing for a route parameter would compile a rule the resolver cannot
resolve.

Verified by adding a sixth addressable source: the new assertion fails, the old one passed.

## A second instance of the same defect, found on the way

Adding `INPUT_SOURCES` to `CAPABILITY_MANIFEST` did not put it in `capabilities.json`, because
`emit-capabilities.mjs` assembles the JSON from its OWN restated list of vocabulary names. And
`emit-capabilities --check` reported "up to date" throughout: both sides omitted the field, so they agreed.
A vocabulary could be declared, typed, used, and never ship, with the check built to catch exactly that
saying nothing.

The emitter now emits it, and a test asserts over the SOURCE that every exported `as const` vocabulary
reaches the manifest with the same members — the only form of this assertion that cannot be satisfied by
two files agreeing to be wrong together. It has a floor on the number of vocabularies found, so an empty
match cannot pass either.

Verified the same way: with the emitter's line removed, `--check` still says "up to date" and the new
guard fails.

Capability version 1.1.0 → 1.2.0; the version check reads it as additive, as it should.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderbuds

coderbuds Bot commented Aug 27, 2026

Copy link
Copy Markdown

Adds comprehensive input-source vocabulary integration with robust manifest and tests.

🎯 Quality: 100% Elite · 📦 Size: Medium

📈 This month: Your 145th PR — above team average · Averaging Excellent

See how your team is trending →

@patchstackdave

Copy link
Copy Markdown
Contributor Author

/review

@patchstackdave
patchstackdave merged commit 3d970a7 into main Aug 27, 2026
6 checks passed
@patchstackdave
patchstackdave deleted the fix/derive-coordinate-coverage-from-vocabulary branch August 27, 2026 08:56
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.

2 participants