Repository navigation
Commit c1dfa52
fix(spec): refuse a malformed actions array in the non-strict bound-action merge (#19815)
Fixes #19799
Clause-②: no (narrowing)
## What changed
`mergeActionsIntoObjects` (`packages/spec/src/stack.zod.ts`) — the merge
that ends every `defineStack` call and `composeStacks` step 7 — now
shape-guards every `actions` array it hands to `sortActionsByOrder`: the
top-level one and each object's own. A non-array, or an array holding a
non-object entry, is refused with `StackSchemaInvalidError`
(`STACK_SCHEMA_INVALID`, `status: 422`), the zod issues at the strict
parse's own paths, all findings in one refusal:
| site | non-array | non-object entry |
| :--- | :--- | :--- |
| top-level `actions` | `['actions']` | `['actions', index]` |
| an object's own `actions` | `['objects', i, 'actions']` | `['objects',
i, 'actions', index]` |
The non-array half reuses the shared `describeNonArrayCollection`
helper, so the top-level refusal is the line `composeStacks` step 3
already draws for a non-array `actions`. `undefined` is the one
non-array accepted (key absent). `sortActionsByOrder` is unchanged: its
callers now only ever hand it an array of objects.
Landing site: as expected — `mergeActionsIntoObjects`, plus a new test
file and a changeset. No other package.
## Readings (at `origin/main` `e7a8bd43a4`, built dist)
Before, `defineStack(config, { strict: false })`:
- top-level `actions: 5` / `'abc'`: `TypeError: actions.some is not a
function`, `code`/`status` undefined
- top-level `actions: [null]`: `TypeError` reading `order` of null;
`[5]`: accepted, entry handed on
- object `actions: 5` / `{}`: `TypeError: actions.some is not a
function`; `[null]`: `TypeError` reading `order`
The strict door on the same inputs: `STACK_SCHEMA_INVALID` / 422 at
`['actions']`, `['actions', 0]`, `['objects', 0, 'actions']`,
`['objects', 0, 'actions', 0]` — so the object-level path is refused by
the strict door, and this PR refuses it at the same path with the same
envelope. After this PR every row above answers exactly that.
## Tests
- New
`packages/spec/src/define-stack-non-strict-actions-shape-refusal.test.ts`:
16 cases — each malformed shape at both sites asserts `code` + `status`
+ issue paths + `invalid_type`/`expected`; strict-door parity; controls
(well-formed arrays merged and ordered by `order`, absent and empty
`actions` accepted).
- Ablation (fix removed by restoring `stack.zod.ts` from base, test
imports `src` directly so no dist leg): 11 failed / 5 passed (5
bare-TypeError rows read `code` undefined, 6 falsy/entry rows were
accepted); the 5 greens are the strict-door and control cases. Restore
proven by `git hash-object` equal to the HEAD blob and an empty `git
diff HEAD`.
- `pnpm --filter @objectstack/spec test`: 519 files passed / 1 skipped,
15249 tests passed. `pnpm --filter @objectstack/spec typecheck`: exit 0
(test-layer debt held).
- `dispatch-gates.mjs --commands`: 82 derived, 80 exit 0, 2 NOT MEASURED
(exit 3 PREREQUISITE NOT MET — `check:dual-build-cjs-loads` and
`check:type-check-debt` need the whole workspace built; CI's).
- eslint (narrowed): the 2 touched TS files, `--format json` count 2, 0
errors / 0 warnings; `eslint.config.mjs` never enables type-aware
linting, so this diff cannot move any untouched file's verdict.
## Acceptance notes
- `composeStacks` also ends in this merge, so a hand-built input stack
whose `actions` (top-level or on an object) carries a non-object entry
such as `5` is now refused at step 7 with the same code instead of being
carried into the artifact. The step-3 comment ("a non-object entry is
concatenated as-is") still describes step 3 itself.
- Out of scope, reported to the seat for filing: `composeStacks` over
two stacks still raises a bare `TypeError` before step 7 for a top-level
`actions: [null]` (reading `objectName`), an object's `actions: 5`
(`.entries is not a function`) and an object's `actions: [null]`
(reading `name`) — in `collectComposedActionKeyCollisions`, outside this
card's file surface.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01VWsFyWDp8Rjb2Ma6a3Cyo8)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c118524 commit c1dfa52
3 files changed
Lines changed: 243 additions & 0 deletions
File tree
- .changeset
- packages/spec/src
| 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 | + | |
| 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 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2996 | 2996 | | |
2997 | 2997 | | |
2998 | 2998 | | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
2999 | 3056 | | |
3000 | 3057 | | |
3001 | 3058 | | |
| |||
0 commit comments