Skip to content

fix(skills): entity-framework cited the wrong CI job and a rule that cannot fail - #686

Merged
athvin merged 1 commit into
mainfrom
fix/entity-framework-skill-audit
Nov 6, 2026
Merged

athvin merged 1 commit into
mainfrom
fix/entity-framework-skill-audit

Conversation

@athvin

@athvin athvin commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

A /skill-audit pass over entity-framework against docs/agent-skills.md. All six lenses ran; overrides is not applicable (the skill is not in CLAUDE.md's override table). Twelve findings, all applied here.

The pattern. Every fact this skill borrowed from a neighbouring subsystem had rotted or was un-gated; every fact about its own entities/ tree — the generated entities-index.md — was current. It built a generator for the one inventory it owns, then hand-copied five it does not.

Would have misdirected a session

Was Is
er-entity verify runs in CI's lint job it runs in the entities job; lint is fmt + clippy + docs and never runs it
"V17 checks that shape" V17 is Severity::Warning — it prints and does not fail; gates.md called V15 "the current warning", implying V17 was an error

A reader debugging a red PR opened a log that never ran the gate, and a reader adding a dataset-scoped table believed a malformed one was blocked.

Also fixed

  • Tenancy was store-agnostic and should not be. V17 skips non-Postgres entities and V11 (error severity) refuses a references: or an index on a DuckLake entity, so the prescribed org_id + dataset_id shape is control-plane only. Now scoped, with the lake analogue stated (isolation is catalog separation — a sentence evals.md already had and the body never did).
  • tenant meant three things. migrate-tenants enqueues one lake_migrate job per active dataset, with an org-level job only for an org that has none (er-server/src/schema.rs). Defined once as an (org, dataset) lake position.
  • The E007/E008/E013 set was hand-copied twice while sql-analysis derives it from analyze.rs as a set difference. Now a pointer — implementing one of those codes can no longer leave this skill telling reviewers to ignore a live rule.
  • Counts out of prose: a "19-column RETURNING list" that is 27 columns today, a plan-vector count, and a make check gloss that had lost doc and skills-check.
  • er_schema::model::ddl_specs is private; points at the spec list and all_specs() instead.
  • Idiom duplication: the three SQL idioms sat in both body and reference with neither canonical, and the copies had already diverged (the body's chr(31) idiom omitted the caller-side join). statements.md is now pinned canonical; the body keeps only the trap.
  • Routing was one-sided. api-contract and er-server-control-plane each named this skill while it named neither, so it won their triggers as the incumbent — per the standard's step 6, one-way routing loses. Both tails added; both directions now closed.

Evals

Two scenarios added against the gaps, both hand-runnable:

  1. The dual-home trap — a lake column change must edit both entity.yaml and the S5 registry. This is the one failure in the skill with a shipped bug behind it: every gate goes green and the run dies on Binder Error: Referenced column "…" not found. It had no eval.
  2. Selection — "the generated TypeScript types are stale" must route to api-contract, not run er-entity gen. No scenario tested selection at all, which is the signal docs/agent-skills.md calls the most valuable.

Gate

make skills-check green — regen reports the generated references current, so the inventory tables are unaffected (the description's first em-dash clause, which feeds them, is untouched). Description is 993 of 1024 chars after trimming for headroom. No code paths touched.

🤖 Generated with Claude Code

…cannot fail

A /skill-audit pass over `entity-framework` found that every fact the skill
borrowed from a neighbouring subsystem had rotted, while every fact about its
own `entities/` tree — the generated index — was current. Twelve findings, one
cause: five borrowed identifiers with no generator behind them.

The two that would misdirect a session:

- `er-entity verify` runs in the `entities` job, not the `lint` job. Both the
  body and gates.md named `lint` (whose own name is `fmt + clippy + docs`), so
  a red PR sent the reader to a log that never ran the gate.
- "V17 checks that shape" described a rule at `Severity::Warning`, which prints
  and does not fail. gates.md compounded it by calling V15 "the current
  warning", implying V17 was an error. A malformed dataset-scoped table ships.

The rest:

- The tenancy section prescribed `org_id` + `dataset_id` with `references:` for
  any new table. V17 skips non-Postgres entities and V11 (error) refuses a
  reference or an index on a DuckLake entity, so the shape is control-plane
  only; it now says so, and states the lake analogue (catalog separation).
- `tenant` was used throughout for a mechanism whose granularity is the
  dataset: `migrate-tenants` enqueues one `lake_migrate` job per active dataset,
  with an org-level job only for an org that has none. Defined once.
- The E007/E008/E013 set was hand-copied in two places while sql-analysis
  derives it from `analyze.rs`. Replaced with a pointer, so implementing one of
  them cannot leave this skill telling reviewers to ignore a live rule.
- Dropped a "19-column RETURNING list" (it is 27), a plan-vector count, and a
  `make check` gloss that had lost `doc` and `skills-check`.
- `er_schema::model::ddl_specs` is private; point at the spec list and
  `all_specs()`.
- The three SQL idioms were duplicated in body and reference with neither
  canonical and the copies already diverged; statements.md is now pinned as the
  canonical copy and the body keeps only the trap.
- Two evals added: the registry/entity dual-home trap (every gate goes green
  and the run dies on `Binder Error`), and a selection scenario — "the
  generated TypeScript types are stale" must route to api-contract.
- Routing was one-sided: api-contract and er-server-control-plane each named
  this skill while it named neither, so it won their triggers as the incumbent.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit d72cda5 into main Nov 6, 2026
33 checks passed
@athvin
athvin deleted the fix/entity-framework-skill-audit branch November 6, 2026 05:06
athvin pushed a commit that referenced this pull request Nov 6, 2026
…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 added a commit that referenced this pull request Nov 6, 2026
…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: bmoore813 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
athvin pushed a commit that referenced this pull request Nov 6, 2026
Follow-up 1 from the entity-framework audit (#686). I flagged it as
"entity-framework has 31 chars of headroom"; measuring every skill showed that
was the wrong framing. **16 of 23 descriptions sit within 60 chars of the
1024-char cap, and `frontend-data-ui` has one.** entity-framework's 25 is
mid-pack.

The cause is structural rather than anyone's carelessness: closing a routing
overlap appends "For X see y" to BOTH descriptions, so a dozen unrelated audits
converge on the same lines. The cap is a cliff, and the first author to walk off
it is whoever happens to add the next tail — on a change that has nothing to do
with the descriptions already at 1023.

So the fix is not to trim one description, which only defers the cliff by a few
characters and costs trigger vocabulary. It is to make the approach visible
while there is still room to trim deliberately.

- `warn()`: reports without setting `fail`. A warning is right here and an error
  is not — most skills are already inside the band, so erroring would fail a
  clean tree.
- The headroom check fires in (964, 1024] and names the remaining budget.
- The lint summary carries the warning count, so it is not lost in the scroll.

Observed firing on all 16, exit 0; and mutation-tested the cap itself, which
still fails at 1040 with the warning correctly silent at that point.

Three structural assertions added to the regression suite, in the style of its
existing "no unbounded writer piped into grep -q" check, because the gate cannot
be pointed at a fixture tree: `warn()` must not set `fail`, the headroom check
must call `warn`, and the hard cap must still call `err`. Both the first two
were mutation-tested and fail when broken. The suite's header scopes it to
race-shaped bugs; this is not a race, but it is the same silent-breakage shape —
promoting the warning to an error turns a clean tree red on an unrelated change.

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

Follow-up 2 from the entity-framework audit (#686). That PR was a `.claude`-only
diff: every required context reported `skipped` behind a successful `detect`, so
the only job that exercised the change — `agent skills (lint + drift)` — was
non-required and could not block anything. Then the push-to-main `rust` run was
cancelled before creating a single job, so the authoritative check never ran
either. Evidence that the generated references were current had to be borrowed
from an unrelated later commit's full run.

`agent skills (lint + drift)` is now the 13th required context on `main`.

Preconditions verified rather than assumed:

- **It can never report `skipped`.** No `if:`, no `needs:` — asserted by parsing
  the workflow, not by reading it. A required context that skips or never
  reports blocks every PR forever, which is the trap `frontend.yml`'s missing
  `paths:` filter already exists to avoid.
- **It has been observed failing**, per `docs/frontend-testing.md`'s rule. A
  throwaway PR (#699, opened by a parallel session for exactly this) edited a
  projected `description` without regenerating and the drift half concluded
  `failure` at 05:42:03Z. Documented with the reproduction, so the precondition
  is auditable instead of asserted.
- **It blocks no open work.** All four open PRs were checked: the only one the
  new context blocks is #699 itself, which is designed to be red and will be
  closed unmerged. The other three are blocked on cargo and e2e contexts that
  predate this change.
- **No generated reference encodes the required set**, so nothing goes stale:
  `required-checks.md` states outright that branch protection is repository
  configuration and cannot be derived in-tree.

Branch protection was changed through the API, built programmatically from the
live config so no context could be dropped by transcription; `strict`, review
count, admin enforcement and force-push settings are unchanged. Revert is a PUT
of the 12-context payload.

The cargo job keeps its copy of the drift check. The old comment called the pair
redundant once this is required; it is not quite — it is the backstop if anyone
adds an `if:` or `needs:` here, or renames the job out of the required set. Both
comments now say which is primary.

One correction worth leaving in the doc: `rust.yml` already claimed both halves
had been observed failing while `docs/agent-skills.md` said they had not. I
acted on the comment and the independent observation landed in parallel, which
is luck rather than diligence — so the doc now says to get the run, not the
comment.

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

* feat(skills): warn before a description hits the cap, not after

Follow-up 1 from the entity-framework audit (#686). I flagged it as
"entity-framework has 31 chars of headroom"; measuring every skill showed that
was the wrong framing. **16 of 23 descriptions sit within 60 chars of the
1024-char cap, and `frontend-data-ui` has one.** entity-framework's 25 is
mid-pack.

The cause is structural rather than anyone's carelessness: closing a routing
overlap appends "For X see y" to BOTH descriptions, so a dozen unrelated audits
converge on the same lines. The cap is a cliff, and the first author to walk off
it is whoever happens to add the next tail — on a change that has nothing to do
with the descriptions already at 1023.

So the fix is not to trim one description, which only defers the cliff by a few
characters and costs trigger vocabulary. It is to make the approach visible
while there is still room to trim deliberately.

- `warn()`: reports without setting `fail`. A warning is right here and an error
  is not — most skills are already inside the band, so erroring would fail a
  clean tree.
- The headroom check fires in (964, 1024] and names the remaining budget.
- The lint summary carries the warning count, so it is not lost in the scroll.

Observed firing on all 16, exit 0; and mutation-tested the cap itself, which
still fails at 1040 with the warning correctly silent at that point.

Three structural assertions added to the regression suite, in the style of its
existing "no unbounded writer piped into grep -q" check, because the gate cannot
be pointed at a fixture tree: `warn()` must not set `fail`, the headroom check
must call `warn`, and the hard cap must still call `err`. Both the first two
were mutation-tested and fail when broken. The suite's header scopes it to
race-shaped bugs; this is not a race, but it is the same silent-breakage shape —
promoting the warning to an error turns a clean tree red on an unrelated change.

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

* chore(ci): make the agent-skills gate a required check, and record the run

Follow-up 2 from the entity-framework audit (#686). That PR was a `.claude`-only
diff: every required context reported `skipped` behind a successful `detect`, so
the only job that exercised the change — `agent skills (lint + drift)` — was
non-required and could not block anything. Then the push-to-main `rust` run was
cancelled before creating a single job, so the authoritative check never ran
either. Evidence that the generated references were current had to be borrowed
from an unrelated later commit's full run.

`agent skills (lint + drift)` is now the 13th required context on `main`.

Preconditions verified rather than assumed:

- **It can never report `skipped`.** No `if:`, no `needs:` — asserted by parsing
  the workflow, not by reading it. A required context that skips or never
  reports blocks every PR forever, which is the trap `frontend.yml`'s missing
  `paths:` filter already exists to avoid.
- **It has been observed failing**, per `docs/frontend-testing.md`'s rule. A
  throwaway PR (#699, opened by a parallel session for exactly this) edited a
  projected `description` without regenerating and the drift half concluded
  `failure` at 05:42:03Z. Documented with the reproduction, so the precondition
  is auditable instead of asserted.
- **It blocks no open work.** All four open PRs were checked: the only one the
  new context blocks is #699 itself, which is designed to be red and will be
  closed unmerged. The other three are blocked on cargo and e2e contexts that
  predate this change.
- **No generated reference encodes the required set**, so nothing goes stale:
  `required-checks.md` states outright that branch protection is repository
  configuration and cannot be derived in-tree.

Branch protection was changed through the API, built programmatically from the
live config so no context could be dropped by transcription; `strict`, review
count, admin enforcement and force-push settings are unchanged. Revert is a PUT
of the 12-context payload.

The cargo job keeps its copy of the drift check. The old comment called the pair
redundant once this is required; it is not quite — it is the backstop if anyone
adds an `if:` or `needs:` here, or renames the job out of the required set. Both
comments now say which is primary.

One correction worth leaving in the doc: `rust.yml` already claimed both halves
had been observed failing while `docs/agent-skills.md` said they had not. I
acted on the comment and the independent observation landed in parallel, which
is luck rather than diligence — so the doc now says to get the run, not the
comment.

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