Skip to content

fix(skills): api-contract named a deleted client and a gate that never fires - #688

Merged
athvin merged 1 commit into
mainfrom
fix/api-contract-skill-drift
Nov 6, 2026
Merged

athvin merged 1 commit into
mainfrom
fix/api-contract-skill-drift

Conversation

@athvin

@athvin athvin commented Nov 6, 2026

Copy link
Copy Markdown
Owner

A /skill-audit of api-contract returned twelve findings. Two of them would mislead a session into doing the wrong thing rather than merely confusing it; the rest are claims that were asserted as fact and are false against the current tree. Every correction below was verified by reading the source it describes.

The two that matter

The server-only client it named does not exist. src/lib/api/erserver.ts was deleted in #434, which consolidated five hand-built upstream paths into lib/bff/upstream.ts so that traceparent could be attached to every one of them. The skill still routed a reader there from the pipeline diagram, the two-clients table and the whole of eval 4 — and upstream.ts's own header anticipates the consequence: "a path with no callers is still a path the next person can revive." Following the skill was a route back to the dead sixth path.

every_generated_entity_schema_is_registered does not enforce its name. It asserts the size of ApiDoc's hand-written registration list, so it is blind to entities/. Add an entity, never register its schema, and the size is unchanged and the test stays green. The skill called it "the one that catches the quiet mistake: adding an entity and forgetting to register its schema" — precisely the mistake it cannot see. Now stated plainly, with the gap as its own row in the gate table and a new eval scenario.

The durable fix for that gate is a set difference against entities/ rather than a count, which is the shape docs/agent-skills.md recommends. Left as follow-up: which entities belong on the control lane is a design decision, not a doc edit.

Corrected, each previously asserted as fact

Claim Reality
er-openapi-check runs in the Rust lint job it is a step in the entities job, and only on pull requests — a push to main has no base and it examines nothing
"the utoipa doc paths in lib.rs" there are no utoipa::path attributes in er-server; the route shape is the axum router's hand-written .route(...) calls
mock_contract.rs holds the mock to the router "in both directions" one direction: the mock may serve no route the router lacks. A router route the mock does not serve passes
the regeneration command as written could not work from either directory — the cargo workspace root is rust/, so the redirect must be relative to it
the chain ends in typed frontend call sites nothing in frontend/src imports schema.d.ts and openapi-fetch has no call sites. The gates prove the document and the types agree with the Rust structs; they prove nothing about frontend call sites
"Both outputs are eslint-ignored" only schema.d.ts is listed, and ESLint does not read JSON. Deleted — nothing followed from it

Routing

Per the standard's both-ways rule, entity-framework never named api-contract, so it won the trigger on "add a column and expose it in the API" and answered only the entity half. Its description now routes onward, and api-contract gained the frontend-bff tail that eval 4 always assumed.

Also

The reference is now canonical for the gate and breaking-change tables — the duplication is how two of the corrections above came to be wrong in two files at once. Eval 1 gained a selection check (does this skill fire at all on a phrasing entity-framework also matches), and eval 6 is new.

Gate

bash scripts/skills-check.sh all green with the command last in the pipeline, so the exit code is its own. Descriptions are 848 and 971 characters against the 1,024 cap; SKILL.md is 162 lines; the reference keeps its ## Contents. No generated block changed — both description edits append past the first em-dash clause the inventory tables derive from. No Rust or frontend code is touched, so detect should skip the compile jobs.

🤖 Generated with Claude Code

…r fires

A /skill-audit of `api-contract` found twelve findings, two of which would
mislead a session into doing the wrong thing rather than merely confusing it.

**The server-only client it named does not exist.** `src/lib/api/erserver.ts`
was deleted in #434, which consolidated five hand-built upstream paths into
`lib/bff/upstream.ts` so `traceparent` could be attached to every one of them.
The skill still routed a reader there from the pipeline diagram, the two-clients
table and the whole of eval 4 — and `upstream.ts`'s own header anticipates the
consequence: "a path with no callers is still a path the next person can
revive". Following the skill was a route back to the dead sixth path.

**`every_generated_entity_schema_is_registered` does not enforce its name.** It
asserts the *size* of `ApiDoc`'s hand-written registration list, so it is blind
to `entities/`: add an entity, never register its schema, and the size is
unchanged and the test is green. The skill called it "the one that catches the
quiet mistake: adding an entity and forgetting to register its schema", which is
precisely the mistake it cannot see. Stated plainly now, with the gap in the
gate table and a new eval scenario; the durable fix is a set difference against
`entities/`, left as follow-up because which entities belong on the control lane
is a design decision, not a doc edit.

Verified against source and corrected, each previously asserted as fact:

- `er-openapi-check` runs in the Rust `entities` job, not `lint` (two places),
  and only on pull requests — on a push to `main` it has no base and examines
  nothing.
- "the utoipa doc paths in `lib.rs`" named annotations that do not exist; there
  are no `utoipa::path` attributes in `er-server`. The route shape is the axum
  router's hand-written `.route(...)` calls.
- `mock_contract.rs` holds the mock to the router in **one** direction (the mock
  may serve no route the router lacks), not both.
- The regeneration command could not work from either directory: the cargo
  workspace root is `rust/`, so the redirect has to be relative to it.
- Nothing in `frontend/src` imports `schema.d.ts`, and `openapi-fetch` has no
  call sites. The gates prove the document and the types agree with the Rust
  structs; they prove nothing about frontend call sites, and the skill now says
  so instead of implying the opposite.

Routing, per the standard's both-ways rule: `entity-framework` never named
`api-contract`, so it won the trigger on "add a column and expose it in the API"
and answered only the entity half. #686 landed that direction while this was
open, so what remains here is the other one — `api-contract` gained the
`frontend-bff` tail that eval 4 always assumed.

Also deduplicated: the reference is canonical for the gate and breaking-change
tables, which is how two of the corrections above came to be wrong in two files
at once.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin force-pushed the fix/api-contract-skill-drift branch from 61dd5e3 to dbb7d75 Compare November 6, 2026 05:06
@athvin
athvin merged commit fbc8f5d into main Nov 6, 2026
33 checks passed
@athvin
athvin deleted the fix/api-contract-skill-drift branch November 6, 2026 05:24
athvin pushed a commit that referenced this pull request Nov 6, 2026
Found doing a consistency sweep after #688, which asserted the opposite of what
these two documents say. Both describe intent in the present tense, so a reader
hitting the skill and the design doc could not tell which was current.

**`entity-framework-design.md` has the control lane typed through
`openapi-fetch` and `schema.d.ts`.** It is not: nothing under `frontend/src`
imports `schema.d.ts`, `openapi-fetch` has no call sites, and the document
carries no `paths` — `schema.d.ts` opens with
`export type paths = Record<string, never>`, so there is nothing for a typed
client to type a route against. The types that reach components come from
`bindings/<Entity>.ts`. Marked as design-not-state at the load-bearing
paragraph rather than rewritten, because the design is still the intent; the
narrative passages later in the document are left alone deliberately.

**`batch-orchestration-design.md` cited a schema count twice**, as "12 → 13",
against a document that carried 14 before this branch — the stale-count failure
the entity-framework skill was itself fixed for. Both now name the condition
(`TaskInstance` declares `wire: [json]`, so a schema is required) instead of a
number that moves whenever anyone registers one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin pushed a commit that referenced this pull request Nov 6, 2026
… unseen

`every_generated_entity_schema_is_registered` asserted `schemas.len() == 14`
against `ApiDoc`'s own hand-written registration list. That cannot see an entity
arriving unregistered, because the count does not change — so the test's name
promised a gate that did not exist. #688 documented the defect; this fixes it.

The invariant was already declared and already derivable. `Wire::Json`'s own doc
comment said "the OpenAPI component schema is emitted", and `generate.wire` in
each `entity.yaml` says which entities cross the JSON wire. Deriving that set
from the catalog and subtracting the registered schemas shows **15 entities
declare `wire: [json]` with no component schema**: candidate_key,
column_profile, entity_link, ingest_batch, matching_model, metric_snapshot,
metric_snapshot_source, pair_label, profile_finding, profile_run,
record_quality, s3_ingest_cursor, tag, tagging, webhook_delivery. The drift the
count could not see had already happened 15 times.

So the replacement is a set difference pinned to that list:

- `every_json_wire_entity_has_a_schema_or_a_declared_gap` — a new `wire: [json]`
  entity fails until it is registered or named in `JSON_WIRE_WITHOUT_SCHEMA`,
  and a **stale** entry fails too, so the list cannot accumulate names and hide
  the next real gap.
- `no_schema_is_registered_for_an_entity_that_is_not_on_the_json_wire` — the
  other direction, which holds today and would otherwise rot silently.

Registering the 15 is deliberately **not** done here. Each becomes a documented
schema that `er-openapi-check` then tracks for breaking changes, which is a
public-API decision rather than a formality; the gate's job is to force the
decision at the point an entity is added, not to make it.

Two supporting changes, each the smallest version of itself. `er-entity-gen`'s
`casing` module becomes public so the test maps an entity name to its struct
name with the generator's own function rather than a second copy that could
disagree — the mapping is the one thing a hand-rolled duplicate would get wrong.
And `Wire::Json`'s doc comment now says it declares rather than emits, because
asserting the invariant was how the gap stayed invisible.

Both new tests guard their own derivation (a catalog that came back empty, or a
json-wire set that came back small, fails loudly) — a vacuous gate is the exact
failure being replaced.

The `api-contract` skill is updated in the same commit: it documented the old
test by name, and in two places promised that nothing would catch a forgotten
registration. Leaving that would recreate the drift #688 existed to remove.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin pushed a commit that referenced this pull request Nov 6, 2026
Found doing a consistency sweep after #688, which asserted the opposite of what
these two documents say. Both describe intent in the present tense, so a reader
hitting the skill and the design doc could not tell which was current.

**`entity-framework-design.md` has the control lane typed through
`openapi-fetch` and `schema.d.ts`.** It is not: nothing under `frontend/src`
imports `schema.d.ts`, `openapi-fetch` has no call sites, and the document
carries no `paths` — `schema.d.ts` opens with
`export type paths = Record<string, never>`, so there is nothing for a typed
client to type a route against. The types that reach components come from
`bindings/<Entity>.ts`. Marked as design-not-state at the load-bearing
paragraph rather than rewritten, because the design is still the intent; the
narrative passages later in the document are left alone deliberately.

**`batch-orchestration-design.md` cited a schema count twice**, as "12 → 13",
against a document that carried 14 before this branch — the stale-count failure
the entity-framework skill was itself fixed for. Both now name the condition
(`TaskInstance` declares `wire: [json]`, so a schema is required) instead of a
number that moves whenever anyone registers one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin pushed a commit that referenced this pull request Nov 6, 2026
… unseen

`every_generated_entity_schema_is_registered` asserted `schemas.len() == 14`
against `ApiDoc`'s own hand-written registration list. That cannot see an entity
arriving unregistered, because the count does not change — so the test's name
promised a gate that did not exist. #688 documented the defect; this fixes it.

The invariant was already declared and already derivable. `Wire::Json`'s own doc
comment said "the OpenAPI component schema is emitted", and `generate.wire` in
each `entity.yaml` says which entities cross the JSON wire. Deriving that set
from the catalog and subtracting the registered schemas shows **15 entities
declare `wire: [json]` with no component schema**: candidate_key,
column_profile, entity_link, ingest_batch, matching_model, metric_snapshot,
metric_snapshot_source, pair_label, profile_finding, profile_run,
record_quality, s3_ingest_cursor, tag, tagging, webhook_delivery. The drift the
count could not see had already happened 15 times.

So the replacement is a set difference pinned to that list:

- `every_json_wire_entity_has_a_schema_or_a_declared_gap` — a new `wire: [json]`
  entity fails until it is registered or named in `JSON_WIRE_WITHOUT_SCHEMA`,
  and a **stale** entry fails too, so the list cannot accumulate names and hide
  the next real gap.
- `no_schema_is_registered_for_an_entity_that_is_not_on_the_json_wire` — the
  other direction, which holds today and would otherwise rot silently.

Registering the 15 is deliberately **not** done here. Each becomes a documented
schema that `er-openapi-check` then tracks for breaking changes, which is a
public-API decision rather than a formality; the gate's job is to force the
decision at the point an entity is added, not to make it.

Two supporting changes, each the smallest version of itself. `er-entity-gen`'s
`casing` module becomes public so the test maps an entity name to its struct
name with the generator's own function rather than a second copy that could
disagree — the mapping is the one thing a hand-rolled duplicate would get wrong.
And `Wire::Json`'s doc comment now says it declares rather than emits, because
asserting the invariant was how the gap stayed invisible.

Both new tests guard their own derivation (a catalog that came back empty, or a
json-wire set that came back small, fails loudly) — a vacuous gate is the exact
failure being replaced.

The `api-contract` skill is updated in the same commit: it documented the old
test by name, and in two places promised that nothing would catch a forgotten
registration. Leaving that would recreate the drift #688 existed to remove.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin added a commit that referenced this pull request Nov 6, 2026
… unseen (#711)

* docs: two design-doc claims the frontend never actually implemented

Found doing a consistency sweep after #688, which asserted the opposite of what
these two documents say. Both describe intent in the present tense, so a reader
hitting the skill and the design doc could not tell which was current.

**`entity-framework-design.md` has the control lane typed through
`openapi-fetch` and `schema.d.ts`.** It is not: nothing under `frontend/src`
imports `schema.d.ts`, `openapi-fetch` has no call sites, and the document
carries no `paths` — `schema.d.ts` opens with
`export type paths = Record<string, never>`, so there is nothing for a typed
client to type a route against. The types that reach components come from
`bindings/<Entity>.ts`. Marked as design-not-state at the load-bearing
paragraph rather than rewritten, because the design is still the intent; the
narrative passages later in the document are left alone deliberately.

**`batch-orchestration-design.md` cited a schema count twice**, as "12 → 13",
against a document that carried 14 before this branch — the stale-count failure
the entity-framework skill was itself fixed for. Both now name the condition
(`TaskInstance` declares `wire: [json]`, so a schema is required) instead of a
number that moves whenever anyone registers one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(api): the schema-coverage gate was a count, so the gap grew to 15 unseen

`every_generated_entity_schema_is_registered` asserted `schemas.len() == 14`
against `ApiDoc`'s own hand-written registration list. That cannot see an entity
arriving unregistered, because the count does not change — so the test's name
promised a gate that did not exist. #688 documented the defect; this fixes it.

The invariant was already declared and already derivable. `Wire::Json`'s own doc
comment said "the OpenAPI component schema is emitted", and `generate.wire` in
each `entity.yaml` says which entities cross the JSON wire. Deriving that set
from the catalog and subtracting the registered schemas shows **15 entities
declare `wire: [json]` with no component schema**: candidate_key,
column_profile, entity_link, ingest_batch, matching_model, metric_snapshot,
metric_snapshot_source, pair_label, profile_finding, profile_run,
record_quality, s3_ingest_cursor, tag, tagging, webhook_delivery. The drift the
count could not see had already happened 15 times.

So the replacement is a set difference pinned to that list:

- `every_json_wire_entity_has_a_schema_or_a_declared_gap` — a new `wire: [json]`
  entity fails until it is registered or named in `JSON_WIRE_WITHOUT_SCHEMA`,
  and a **stale** entry fails too, so the list cannot accumulate names and hide
  the next real gap.
- `no_schema_is_registered_for_an_entity_that_is_not_on_the_json_wire` — the
  other direction, which holds today and would otherwise rot silently.

Registering the 15 is deliberately **not** done here. Each becomes a documented
schema that `er-openapi-check` then tracks for breaking changes, which is a
public-API decision rather than a formality; the gate's job is to force the
decision at the point an entity is added, not to make it.

Two supporting changes, each the smallest version of itself. `er-entity-gen`'s
`casing` module becomes public so the test maps an entity name to its struct
name with the generator's own function rather than a second copy that could
disagree — the mapping is the one thing a hand-rolled duplicate would get wrong.
And `Wire::Json`'s doc comment now says it declares rather than emits, because
asserting the invariant was how the gap stayed invisible.

Both new tests guard their own derivation (a catalog that came back empty, or a
json-wire set that came back small, fails loudly) — a vacuous gate is the exact
failure being replaced.

The `api-contract` skill is updated in the same commit: it documented the old
test by name, and in two places promised that nothing would catch a forgotten
registration. Leaving that would recreate the drift #688 existed to remove.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(skills): polling.md's intro still counted six false greens, and there are seven

#705 added a seventh case and #709 added the warning not to reason from the
list's length, but the intro paragraph above both still said "the six ways the
obvious reading is wrong". Drops the number, which is the fix the standard
prescribes and the one that cannot go stale again.

This is all that survives of a larger change this branch originally carried.
#709 landed the same `conclusion` correction first and better — it normalises
with `(.conclusion // "") == ""` rather than testing two branches, and it also
fixed the main assertion block and `post-merge.md`, neither of which this branch
had touched. The zero-job disambiguation is dropped too: `action_required` and
the starved `steps: []` case are each already documented in their own sections,
and a third paragraph tying them together would be the duplication an audit
should flag rather than add.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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