Commit af6afda
committed
feat(spec)!: hooks and datasources reject unknown keys (#4001 data step)
Closes the last two ledger entries that still carried a provisional (p)
classification. The ledger's own rule for these was "verify before tightening",
and verification changed the answer for one of them.
CLASSIFICATION. Both types are authorable on the same evidence: they sit in
BUILTIN_METADATA_TYPE_SCHEMAS, so one shape backs defineStack() parsing,
/api/v1/meta/types/:type, and the Studio form. But the blanket `authorable (p)`
on hook.zod.ts was too wide — HookContextSchema in the same file is the RUNTIME
shape the engine hands a handler. It stays tolerant, and must: strictness there
would turn an engine-internal enrichment (as `provenance` was in #3712) into a
breaking change for anyone parsing a context they were given.
Strict now: HookSchema + retryPolicy; both hook-body branches; DatasourceSchema
+ pool/healthCheck/ssl/retryPolicy; ExternalDatasourceSettingsSchema + its
validation block; DatasourceCapabilities; DriverDefinitionSchema.
Still open, deliberately: HookContextSchema and its session/provenance/user
blocks; datasource `config` and `readReplicas` (per-driver by construction — the
driver's own configSchema validates them). That openness is exactly why the top
level had to close: a connection key written one level too high was stripped and
the datasource then connected on driver defaults rather than failing. Those keys
are prescribed into `config`; a top-level `password` is pointed at
`external.credentialsRef`, because relocating an inlined secret is not the fix.
CORRECTS AN ASSUMPTION THE EARLIER STEPS WERE WRITTEN UNDER. Strictness does not
change the published JSON Schema. build-schemas.ts converts with the default
io:'output', and in output mode zod emits additionalProperties:false for a
.strip() object too — the post-parse shape genuinely has no extra keys. Verified
by regenerating with and without these flips: Datasource.json is byte-identical.
So the JSON Schema had been advertising additionalProperties:false while the zod
parse quietly accepted and discarded unknown keys. These flips align the parse
with the contract already published rather than widening it. The approval note
in the ledger reads as though its flip carried strictness INTO the JSON schema;
it did not, and the ledger now says so.
SCOPE LIMIT, since it bounds who this reaches. There is no defineHook() factory —
it is referenced twice in object.zod.ts describe strings but does not exist,
unlike definePosition/defineTool/defineAgent/defineApp/defineView/
defineDatasource. Authors write `const H: Hook = {…}`, a bare type annotation
that never parses, so hook strictness bites at artifact/registry LOAD time, not
as they type. Datasource has its factory and so rejects at authoring time.
Adding defineHook() is a new API surface and belongs in its own change.
The metadata-authoring-lint coverage test failed on cue: lintables fell 16 → 14
because both types graduated out of lint coverage into parse coverage. That test
exists to force a human to confirm a shrink is a graduation and not a bug — so
`hook` moved out of the pinned-coverage list and both moved into the strict list.
Verified: full spec suite (7136) green; gen:schema clean (covers the #3746
toJSONSchema-on-strict-lazySchema hazard); authorable-surface, liveness,
empty-state, variant-docs, doc-authoring and changeset gates green; both
first-party example datasources parse under strict (no finding this time —
unlike the app step, these were already clean).
objectql has 26 pre-existing failures in protocol-data / protocol-unknown-query-
param (#4164/#4134 territory, untouched here). Confirmed pre-existing by
stashing these changes and re-running: identical 26 failed | 59 passed.
Refs #4001
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0147tNF4Snk7Ry1KGt4a5PY41 parent 8c2db68 commit af6afda
7 files changed
Lines changed: 524 additions & 22 deletions
File tree
- .changeset
- content/docs/releases
- docs/audits
- packages/spec/src
- data
- kernel
| 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 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
361 | 393 | | |
362 | 394 | | |
363 | 395 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | | - | |
218 | | - | |
| 216 | + | |
219 | 217 | | |
220 | 218 | | |
221 | 219 | | |
222 | | - | |
| 220 | + | |
223 | 221 | | |
224 | 222 | | |
225 | 223 | | |
| |||
241 | 239 | | |
242 | 240 | | |
243 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
244 | 265 | | |
245 | 266 | | |
0 commit comments