Repository navigation
Commit a49e8ae
feat(spec): a refinement that never reaches the published JSON Schema now makes a noise (#18729)
Refs #18670 (item 1)
Clause-②: no
Triage on #18670 wrote the handoff order and reserved the second half
for the maintainer. This PR is **item 1 only**: census the refinements
whose rule never reaches the published JSON Schema, and make that fact
**make a noise**. It narrows no published shape, removes no refinement,
and adds no CI job — the ratchet lives inside
`packages/spec/scripts/build-schemas.ts`, which
`check:authorable-surface` already runs.
## The premises, re-measured — two reproduce, one does not
The card was filed by the dispatching seat, so every claim in it was
re-measured here with its own control.
**① `z.toJSONSchema` drops a refinement — REPRODUCES.** On zod **4.4.3**
(the version `packages/spec` resolves), a plain record, the same record
with a `.refine()`, and the same record with an **aborting** `.refine()`
project byte-identically. Lit control in the same run:
`z.string().min(1)` does move the bytes (`"minLength":1`), so the
instrument can see a projected constraint. Pinned in
`packages/spec/scripts/dropped-refinements.test.ts`.
**② `TraceSamplingConfig.condition.anyOf[0]` — REPRODUCES, byte for
byte.** The generated file reads
`{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}`.
**③ The consequence, as written — DOES NOT REPRODUCE at that slot.**
Measured against the live schema:
| claim | measured |
|---|---|
| the published `anyOf[0]` accepts `{dialect:'cel'}`, "which the runtime
refuses" | the **runtime accepts it too**. `condition` is
`z.union([z.record(z.string(), z.unknown()), ExpressionInputSchema])`;
the permissive record branch absorbs the object, so published and
runtime **agree** here |
| "the string branch carries no non-empty constraint" | it carries
**`minLength: 1`** |
| "the runtime requires non-blank after trim" | it does not — `" "` is
**accepted**; only `""` is refused, which `minLength: 1` refuses as well
|
So the tracing slot is not a specimen of the gap. **The gap itself is
real and the card's own dedupe words point straight at the right file**:
`ExpressionInputSchema` carries the refinement "Expression requires at
least one of `source` or `ast`", and the published
`packages/spec/json-schema/shared/ExpressionInput.json` states only
`"required": ["dialect"]`. `{"dialect":"cel"}` is **accepted by the
published file and refused by the runtime** — the card's sentence, one
file up from where it was written.
## The census
Measured by the generator itself, on this branch, at zod 4.4.3:
| reading | value |
|---|---|
| refinement call sites in `packages/spec/src/**` (excluding
`*.test.ts`) | **126** — `.refine(` 48 · `.superRefine(` 75 · `.check(`
3 |
| published schemas carrying at least one **dropped** refinement |
**240** |
| dropped refinement **sites** on published schemas | **688** |
| sites that **did** reach the published file | **0** |
| sites with no JSON form on either side to compare | **3** |
The fan-out between 126 and 688 is the point: one refinement on a shared
schema lands on every published file that embeds it. Per namespace: `ui`
123 · `api` 251 · `data` 102 · `system` 81 · `automation` 46 · `kernel`
32 · `ai` 14 · `shared` 13 · `security` 10 · `identity` 9 ·
`integration` 1.
1 parent 095c7f6 commit a49e8ae
6 files changed
Lines changed: 2780 additions & 15 deletions
File tree
- .changeset
- packages/spec
- scripts
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
0 commit comments