Repository navigation
Commit c5d6b2b
Fixes #20331
Clause-②: yes
`os validate` now runs the same view-container `name` check the boot
registrar runs, and reports the refusal in the boot registrar's own
words. Before this change it passed a stack at exit 0, and `os serve`
then refused that same stack at boot. The triage direction was "one
judge, not a second rule". The check moved out of
`ObjectQL.registerMetadataCollections` into one function, and boot and
`os validate` both call it. There is no lint twin and no new error code,
and boot's message and envelope are unchanged.
## Premise, measured on `origin/main` `862b6ce86` before any edit
The setup: the CLI's dependency closure was built, then `os init my-app
-t app --no-install`, `os g object order_line` and `os g view
order_line`. The view's `name` was then hand-edited to `'order_line'`,
bound to object `my_app_order_line`.
| step | exit | what it printed |
|---|---|---|
| `os validate` | **0** | `✓ Validation passed`, `UI: 1 Views` |
| `os serve --dev` | **1** | "Invalid `views:` container from manifest
'com.example.my-app': the container's own `name` is 'order_line', which
disagrees with the object key it binds to, 'my_app_order_line' …" |
| `os compile` | **0** | writes an artifact carrying `{ name:
'order_line', object: 'my_app_order_line' }` |
| `os serve`, booting that artifact (`dist/objectstack.json`, no config)
| **1** | the same message |
## What changed
1. **`@objectstack/objectql`: `viewContainerNameRefusal(container,
sourceLabel, ownerId)`** (new `src/view-container-name-refusal.ts`)
returns the refusal the boot registrar throws, or `undefined`. It
carries the same gate: the container branch
(`isAggregatedViewContainer`), and a `name` that is present and differs
from the derived key. It also carries boot's precondition for that gate:
a falsy derived key is boot's warn-and-skip, and the function answers
`undefined` for it. It uses the same message and the same
`VALIDATION_ERROR` / 400 envelope. It derives the key itself with
`deriveViewContainerObject`, which for a container is exactly what
`resolveMetadataItemName` returns. So no caller re-spells "which
derivation boot uses".
2. **`registerMetadataCollections`** keeps its `key === 'views'`
narrowing and throws what the function returns. Nothing else in
`engine.ts` moved.
3. **A new public export** from the `@objectstack/objectql` root entry:
`viewContainerNameRefusal` and its type `ViewContainerNameRefusal`. This
is the widening behind `Clause-②: yes`: `@objectstack/objectql` is
graded `minor`, and `@objectstack/cli` stays `patch`. The changeset
states it.
4. **`@objectstack/cli`: `findViewContainerNameRefusals(parsed)`** (new
`src/utils/view-container-names.ts`) owns the WALK only, and the verdict
is objectql's. It walks what the load path registers. With no
`packages[]`, that is the top-level `views`, under the manifest id:
`AppPlugin` hands `{ ...manifest, ...stack }` to the manifest service,
and the id is read through `artifactPackageId`. With `packages[]`, it is
each `packages[i].manifest.views`, under that package's id, and not the
top level, which `resolveArtifactPackageOrder` never registers.
5. **`os validate` step 2c** runs right after the schema parse. It exits
1. The text face prints the refusals as bullets. `--json` emits `errors:
[{ path, code, httpStatus, message }]` and carries `warnings` /
`conversions` like every other exit.
6. **`test/validate-build-gate-parity.test.ts`** gains a
`VALIDATE_ONLY_GATES` ledger. The closed roster had no honest place for
a gate wired into `validate.ts` alone: `SHARED_NON_REGISTRY_GATES`
asserts that both commands call it, and a `NOT_A_GATE` row would be a
false statement. The new row is pruned both ways: it goes stale if
`validate.ts` stops calling the gate, and it must move to
`SHARED_NON_REGISTRY_GATES` if `compile.ts` starts calling it.
## After the fix, on the same project (CLI from source,
`@objectstack/objectql` dist rebuilt)
- `os validate` exits 1 with `✗ The server would refuse this stack at
boot (1 view container)` and the boot message. `os validate --json`
exits 1 with `errors[0] = { path: 'views[0]', code: 'VALIDATION_ERROR',
httpStatus: 400, message }`. The `message` is **byte-equal** to the line
`os serve --dev` printed before the fix (`diff` is empty).
- Controls: `name: 'my_app_order_line'` gives exit 0, and deleting
`name` gives exit 0.
- `os serve --dev` still exits 1. Its message is byte-identical before
and after the refactor (`diff` of the two boot logs is empty).
## Tests
- `packages/objectql/src/view-container-name-refusal.test.ts` (new, 9
tests, with the falsy-derived-key control added in patch round 1): the
refusal and its envelope. The manifest seam AND the nested-plugin seam
throw exactly what the function returns. There are five controls (no
`name`, a matching `name`, a name-only container, a non-container, an
empty-string `name`), each also registered by boot.
- `packages/cli/src/utils/view-container-names.test.ts` (new, unit tier,
5 tests): the walk. Every row's message equals the judge's answer and is
never re-spelled. The `packages[]` bodies are judged under their own
ids, and the top level is not judged when `packages[]` is present.
- `packages/cli/test/validate-view-container-name.test.ts` (new,
integration tier: it spawns the CLI and constructs `ObjectQL`, 5 tests):
`--json` exits 1 and `errors[0].message` equals what
`ObjectQL.registerApp` throws for the same stack. The text face exits 1
with the same words. The matching control and the no-`name` control both
exit 0. A premise case asserts that boot refuses the divergent stack and
accepts both controls.
- The existing boot pins in
`view-container-divergent-name-registrars.test.ts` are unchanged and
green.
- Runs at `4e15d3cea`:
- `@objectstack/objectql`: `vitest run --project local`, four shards:
323 files, 5865 tests passed. Typecheck (`tsc --noEmit` ×2 plus
`check:test-typecheck`) exit 0.
- `@objectstack/cli`: `vitest run --project unit`, two shards: 232
files, 3315 tests passed. Typecheck exit 0. `--project integration` was
run locally for the new file only (5/5); the rest of the integration
tier is declared to CI.
- `tsc --listFilesOnly` confirms every new file is in a typecheck
program (`tsconfig.json` / `tsconfig.test.json` of each package).
- `pnpm lint` (full `eslint . --no-inline-config`) exit 0.
## Ablation (fix committed first; mutation through
`scripts/ablation-replace.mjs`)
- **Mutation:** an early `return undefined` at the top of
`viewContainerNameRefusal`, marker `__ABLATION_20331_NEVER_REFUSE`. The
tool reported anchor x1 to x0 and blob `07da29b9` to `ab52f626`. The
objectql build and `ablation-dist-preflight.mjs` found the marker in 4
built files.
- objectql: 5 of 20 red. These are the 3 new refusal cases and the 2
existing boot pins: "THE PIN (#14666): the boot loop REFUSES the
divergent container …" and "MEASURED CORRECTION … refuses, enveloped
(#7378 row 1)".
- cli: 6 of 10 red. These are the 3 walk cases, the premise case, THE
PIN (`--json`) and the text face. The controls stayed green.
- The direction is red, as expected.
- **Restore:** `git checkout HEAD --` on the absolute path, by the
tool's trap. The blob after the restore equals HEAD `07da29b9`, and `git
diff HEAD` is empty. After the rebuild, `ablation-dist-preflight
--absent` found the marker absent from all 14 built files and a working
tree clean against HEAD. objectql was then 20/20 green and cli 10/10
green.
## Gates at `4e15d3cea`
These were derived with `node scripts/pm/dispatch-gates.mjs --repo
objectstack-ai/objectstack --commands`, which gave 69 commands. `--ran`
reconciled them as 68 run, 1 NOT-MEASURED and 0 UNRUN. Every command
exited 0 except the one below:
```text
pnpm check:type-check-debt -> 3 NOT MEASURED (PREREQUISITE NOT MET)
```
`check:type-check-debt --re-measure` runs a whole-workspace `turbo run
build` inside itself. On this shared box that build did not fit the
foreground cap: the first attempt was SIGTERMed mid-build, and I rebuilt
`packages/spec` afterwards. Neither touched package carries a `DEBT` /
`TEST_DEBT` row. `lint.yml` runs it in CI.
Six gates first answered "prerequisite not met" or asked for deeper
history, and each was re-run after its prerequisite was met:
- `check:dual-build-cjs-loads`, `check:i18n`, `check:i18n-coverage` and
`check:i18n-walk-parity` exited 3 until the CLI, the examples and the
unbuilt packages were built, then 0.
- `check-engine-split-ratio.mjs --days 90` exited 2 until the history
was deepened with `--shallow-since`, then 0.
- `check-issue-citations.mjs` exited 2 on four added citations that no
longer resolve. Those were rephrased, and it then exited 0 with and
without `--base origin/main`.
## Patch round 1 (head `6b5895b97`, after the FAIL review of
`4e15d3cea`)
1. **Two red CI pins, and every fixture of the same shape.**
`test/union-fold-command-parity.test.ts` (PEDIGREE CONTROL) and
`test/validate-per-package-authoring-parity.test.ts` asserted exit 0 on
stacks the boot registrar refuses: each carried containers named
`*_list` bound to `*_account` / `*_order`. Each container now names its
bound object, and each pin's assertion is unchanged.
- **Census** of `packages/cli/test/`, `packages/cli/src/`,
`packages/qa/` and `examples/` (all 963 tracked `.ts`/`.js`/`.json`
files, the `.e2e` tier included). A structural scan read every object
literal carrying `name` plus a container arm
(`list`/`form`/`listViews`/`formViews`) and no `viewKind`, and derived
the key as boot does. It found 15 divergent containers in 9 files, all
fixed the same way: the 4 above,
`build-text-face-advisory-count.test.ts` (2), `format-zod-union.test.ts`
(1), `info-detail-package-fold.test.ts` (1),
`lint-handwritten-checks-package-fold.test.ts` (1),
`lint-label-case-localized.test.ts` (2),
`lint-per-package-authoring-parity.test.ts` (2),
`lint-per-package-authoring-seam.test.ts` (2). A rescan finds none,
apart from the docblock examples in this PR's own files. `examples/`:
`os validate` exits 0 on each of app-crm, app-multi-package,
app-showcase and app-todo, with 0 container refusals. `packages/qa/`: no
hit. `views` is not a map-form collection (`MAP_SUPPORTED_FIELDS`
excludes it), so no key-injected name can hide there.
2. **Semver:** `@objectstack/objectql` is now `minor` with `Clause-②:
yes`, for the two new root exports (`viewContainerNameRefusal`,
`ViewContainerNameRefusal`). `@objectstack/cli` stays `patch`. The
changeset states the widening.
3. **Boot's precondition moved with the gate.**
`registerMetadataCollections` warns about and skips an entry whose
derived key is falsy before the name check runs.
`viewContainerNameRefusal` now returns `undefined` for that entry too.
The derivation keeps `''` for `list: { data: { object: '' } }`, so
without this `os validate` would refuse a container that boot only
skips. A new control pins it: boot throws nothing and registers nothing,
and the function returns `undefined`. The docblock and the `engine.ts`
comment now say what moved: the message and the envelope moved byte for
byte, and the gate moved whole, precondition included.
4. The gate-parity remedy text names `VALIDATE_ONLY_GATES` too.
Runs at `6b5895b97`:
- `@objectstack/objectql`: `--project local` in 4 shards, 325 files /
6017 tests passed. Typecheck exit 0. The new test file is 9/9.
- `@objectstack/cli`: `--project unit` in 2 shards, 233 files / 3335
tests passed. `--project integration` IN FULL in 3 shards, 61 files /
512 tests passed and 1 skipped. Typecheck exit 0.
- `OS_TEST_TIERS=nightly`: the census touched no `.e2e` file, so the 13
nightly files that run `os validate` were run instead. 13 files / 129
tests passed.
- `pnpm lint` exit 0. `check-issue-citations --base origin/main` exit 0.
- `check-changeset-no-major` level axis: driven with `--event` on this
body with `Clause-②: yes`, it answers "✓ LEVEL AXIS …
`@objectstack/objectql: minor`" (exit 0).
- Gates: 69 derived, `--ran` reconciles 69 run, 0 NOT-MEASURED, 0 UNRUN,
every one exit 0. That includes `check:type-check-debt`: 4 entries
re-measured, none above its number.
- **Guard ablation:** `scripts/ablation-replace.mjs --delete` removed
the `if (!itemName) return undefined;` line (anchor x1 to x0, blob
`21af64e5` to `56d25d71`). Exactly the new control went red: the
function returned "Invalid `views:` container … binds to, ''" where
`undefined` was expected. The other 20 tests stayed green, the existing
boot pins among them. The restore gave a blob equal to HEAD `21af64e5`
and an empty `git diff HEAD`, then 21/21 green.
## Acceptance notes
- **`os compile` / `os build` does NOT reach the shared function.** It
is not the same code path as validate, and under this card's scope I did
not widen to it. It still exits 0 on this stack and writes an artifact
that `os serve` refuses when it boots it, as measured above. The
`VALIDATE_ONLY_GATES` row records that gap. I reported it to the seat as
an out-of-scope finding.
- **The artifact/HMR loader is not a second spelling of this function.**
`MetadataPlugin._parseAndRegisterArtifact`
(`packages/metadata/src/plugin.ts`, the container branch around
:1103-:1121) registers the container under
`deriveViewContainerObject(item)` through `this.manager.register('view',
viewObject, item)`. The refusal there comes from the GENERIC register
contract `assertMetadataRegisterContract`
(`packages/core/src/metadata-service-contract.ts`, #7378 row 1), in its
own words ("IMetadataService.register('view', …): data.name is …"). So
both registrars enforce the same rule through different mechanisms, and
boot's prose is its own on purpose. `packages/metadata/**` is untouched.
- **Edge, not measured at a public door (read-only inference):**
`ViewSchema.name` is `z.string().optional()`, so an empty-string
container `name` is spec-valid. The boot loop (and `os validate`, which
mirrors it) treats `''` as absent and registers the container. The
generic register contract at the artifact door refuses it, because `''
!== undefined` and `'' !== key`. No producer of `name: ''` was found.
- **Bound:** a nested `plugins[]` entry's `views` is registered by boot
under the label `nested plugin`, but `os validate` does not walk it. The
stack schema types `plugins` as `unknown[]`, and in an authored config
they are runtime plugin instances.
- **Upstream:** `origin/main` was merged at `b1cbd9277`, and again at
`0d7ed5a37` in patch round 1. It has since moved 6 commits. One of them,
#20368, touches `engine.ts` in the `engine.aggregate` hunks only, and a
`git merge-tree` probe merges cleanly, so I did not merge again.
- `packages/spec/**` and `packages/metadata/**` are unchanged. The diff
adds no lint rule and no error code, and it does not change boot's
message or envelope.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01UYBdGBzWSrAMzpW8ah3GbP)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent c745e2b commit c5d6b2b
19 files changed
Lines changed: 844 additions & 69 deletions
File tree
- .changeset
- packages
- cli
- src
- commands
- utils
- test
- objectql/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 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
328 | 332 | | |
329 | 333 | | |
330 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
331 | 380 | | |
332 | 381 | | |
333 | 382 | | |
| |||
| 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 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
0 commit comments