Repository navigation
Commit f7eb860
fix(verify): read a refused create's whole answer before calling it a hard failure (#24516)
Fixes #24498
Clause-②: no
Basis: the CRUD stage reads the same answer correctly. No accept set,
export or published shape moves.
## What changed
`packages/verify/src/verify.ts`, `runCrudVerification`, the
refused-create branch:
- The body is read once, in full. The verdict comes from a new private
helper, `isValidationAnswer(text)`.
- When the body is JSON with a string top-level `code`, a 400 is
`needs-fixture` exactly when that code is `VALIDATION_FAILED`.
- When the body is not JSON, or has no string `code`, the stage's
original pattern (`VALIDATION_FAILED|Validation failed`,
case-insensitive) is matched against the full text.
- The stored `detail` keeps its 280-character cut (`text.slice(0,
280)`), taken after the verdict.
- The rule is unchanged: a 400 validation answer is `needs-fixture`, and
anything else is `create-failed`. No other status value, exit-code rule
or verify stage is touched.
**The shape was measured, not guessed.** A real in-process stack
(`bootStack`, this branch, after the dependency closure was built)
answered a create refused by a script rule with `400` and a
755-character body whose keys are `["error","code","fields","object"]`.
The `"code":"VALIDATION_FAILED"` key starts at character 324. That is
the flat envelope `packages/types/src/data-error-classification.ts`
builds for the validation arm (`error` = the app's message, then `code`,
`fields`, `object`). It is also the top-level `code` that the sibling
stages already read off this same door (`reference-shape.ts`,
`delete-behavior.ts`, `unique-scope.ts`). The test fixture uses that
measured key order and `fields` entry shape.
## Before and after: the stored row for a long validation answer,
measured
The probe is a throwaway script, not committed. It boots one real stack
with one object whose script rule (CEL `true`, events insert and update)
refuses every create with a three-sentence message, like hotcrm's
forecast rule. It then runs `runCrudVerification` over that app.
"Before" imports `verify.ts` exactly as it is at base `6b42b6bc8`.
"After" imports it at `3024fa2b7`.
| run | `verify.ts` | status | code | `detail` length | summary |
|---|---|---|---|---|---|
| before | base `6b42b6bc8` | `create-failed` | 400 | 280 |
`createFailed: 1, needsFixture: 0` |
| after | `3024fa2b7` | `needs-fixture` | 400 | 280 | `createFailed: 0,
needsFixture: 1` |
The stored `detail` is byte-identical in both rows. It ends `...
reconcile the three amounts, th`, before the `code` key at character
324. Only the verdict moves.
The optional hotcrm re-run was **not done**. The hotcrm checkout has no
`node_modules`. Running `os verify` there with this branch's build means
installing its 18.0.0-next.3 dependency tree and building and wiring
`@objectstack/cli` from this branch, which is more than linking the
built package. The in-process probe above drives the same door and the
same stage.
## Ablation
The ablation restores today's cut-before-classify order with one
mutation in `verify.ts`. It goes through `node
scripts/ablation-replace.mjs` (WRAP mode, its own exit, INT and TERM
trap, plus a shell trap that runs `git checkout HEAD --` on the absolute
path):
- Before the mutation, the line read `const text = await
created.text();`. The mutation made it `const text = (await
created.text()).slice(0, 280);`.
- The anchor was hit 1 time and dropped to 0. The replacement count went
from 0 to 1. The blob moved from `d8fe2c05c833` to `d9528c3cad95`.
- With the mutation, `vitest run
src/verify.create-refusal-verdict.test.ts` gave **1 failed, 4 passed**.
The one red is the long-message case, `expected status "needs-fixture",
received "create-failed"`. All four controls stayed green.
- After the restore, the blob read `d8fe2c05c833`, which equals HEAD.
`git diff HEAD` was empty and `git status --porcelain` was empty.
The test imports `./verify.js` from source (a relative import, so there
is no `dist/` resolution), so no rebuild leg was owed.
## Controls
The new test file is
`packages/verify/src/verify.create-refusal-verdict.test.ts`. It uses a
stack double (`apiAs` only, the same double pattern
`reference-shape.test.ts` uses) and boots nothing. It has 5 cases, and
all pass on HEAD:
1. A 400 `VALIDATION_FAILED` whose message runs past 280 characters is
`needs-fixture`, and `detail` equals the first 280 characters of the
body. The fixture asserts its own precondition: the code key starts
after character 280.
2. Control: a short 400 `VALIDATION_FAILED` is `needs-fixture`.
3. Control: a 500 `INTERNAL_ERROR` is `create-failed`.
4. Control: a 400 `INVALID_FIELD` is `create-failed`.
5. Control: a 400 non-JSON `Validation failed: ...` body is
`needs-fixture`. This exercises the full-text fallback.
## Local verification (HEAD `3bcc4ae59`)
- `pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2`
(the whole package suite, under the shared lock) gave 44 test files and
376 tests passed, `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/verify typecheck` exited 0. It runs `tsc
--noEmit` and then `check:test-typecheck`, which reported "0 file(s) / 0
error(s)". `tsc -p tsconfig.test.json --listFiles` lists the new test
file (1 hit). For comparison it lists 44 verify test files and 100
`packages/core/src` files.
- eslint (`--no-inline-config`) over `verify.ts` and the new test exited
0, with 0 errors and 0 warnings. The JSON output confirms both files
were linted.
- `node scripts/pm/dispatch-gates.mjs --commands` derived 63 commands.
All 63 were run with each exit code captured before any pipe, and all
exited 0. `pnpm check:dual-build-cjs-loads` first answered `PREREQUISITE
NOT MET` (exit 3, unbuilt packages elsewhere in the tree). It was re-run
after a full `turbo run build` (75 of 76 tasks cached) and exited 0.
- The `--ran` reconciliation read: `63 derived, 63 run, 0 NOT-MEASURED,
0 UNRUN` (a derived zero, all 63 with recorded exit codes).
- `pnpm lint` (`eslint . --no-inline-config`), the full union, was run
at `3bcc4ae59` (the final commit) and exited 0 with no findings printed.
## Acceptance notes
- A JSON 400 whose top-level `code` is something other than
`VALIDATION_FAILED`, but whose prose contains "Validation failed", now
reads `create-failed`. The old pattern over the cut made it
`needs-fixture`. On the `/data` create door, the only producer that
writes that phrase into the flat envelope is the `VALIDATION_FAILED` arm
itself (`data-error-classification.ts`). The other producers of the
phrase are other doors: plugin-auth's adapter, the import runner, and
the CLI's own printers. So no answer the door gives today changes its
verdict except the long-message case.
- There are no out-of-scope findings. No other verify stage cuts a body
before it classifies it: the sibling stages parse the full text, and
their `clip` is applied to stored detail only.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01SYEJqDL3NXxrJRBVqaMu9T)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent cbe6d87 commit f7eb860
3 files changed
Lines changed: 134 additions & 3 deletions
File tree
- .changeset
- packages/verify/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 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 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
47 | 70 | | |
48 | 71 | | |
49 | 72 | | |
| |||
79 | 102 | | |
80 | 103 | | |
81 | 104 | | |
82 | | - | |
| 105 | + | |
83 | 106 | | |
84 | 107 | | |
85 | 108 | | |
86 | 109 | | |
87 | | - | |
| 110 | + | |
88 | 111 | | |
89 | 112 | | |
90 | 113 | | |
91 | 114 | | |
92 | | - | |
| 115 | + | |
| 116 | + | |
93 | 117 | | |
94 | 118 | | |
95 | 119 | | |
| |||
0 commit comments