Repository navigation
Commit 8fc50b7
Fixes #22042
Clause-②: no (narrowing)
A `conditional` validation rule's nested `then` / `otherwise` predicates
now meet the same `validateExpression` verdict as the rule's own
`condition` / `when`. That holds in `os build`
(`validateStackExpressions`), and so at the object save door, which has
given the build's verdict for validation predicates since #22032 pass 1
(PR #22041).
## What changes
- **`packages/lint/src/validate-expressions.ts`**, the validation-rule
loop.
- `rulePredicates` now tags each predicate with its `slot` (`condition`
or `when`) and its `depth` (0 is the rule itself). Its labels are
unchanged.
- The two top-level `check()` calls stay as they were, with the same
location and flags. The loop adds one `check()` for each nested yield
(depth 1 and below) and skips depth 0, so no predicate is judged twice.
- A nested finding is located at the label `rulePredicates` already
builds, which is the location the null-guard gate already gives that
predicate: `object 'OBJECT' · validation rule 'OUTER' then → 'INNER'`. A
nested `when` appends `when-predicate`. The top-level findings keep
`object 'OBJECT' · validation 'NAME'`.
- `traversalHydration` follows the evaluator per slot, as at the top
level. It is on for a nested `condition` and off for a nested `when` (H2
below).
- The new findings are emitted after the two top-level calls and before
the null-guard loop. So the order of every existing finding is
unchanged.
- **Tests:** 7 lint-level pins (build and door) and 6 pins through the
real `saveMetaItem` / `publishMetaItem`.
- **Changeset:**
`.changeset/22042-nested-validation-predicate-verdict.md` sets
`@objectstack/lint` and `@objectstack/metadata-protocol` to `minor`. It
carries `fix(lint)!`, `Clause-②: no (narrowing)`, a BREAKING section,
the remedy, and the ADR-0087 disposition `not-required
(no-migration-prescription)`.
Nothing else moves. There is no registry change in `authoring-rules.ts`
and no change in `runtime-gate.ts`.
## Measured before the change (the dispatch's H1–H6), at base
`54ace18c6`
- **H1, confirmed with positions re-read on this base.**
- `rulePredicates` is at `:489` and recurses into `then` / `otherwise`
at `:507`.
- The top-level calls are `check(where, rule.condition, …, true)` at
`:1891` and ``check(`${where} when`, …)`` at `:1896`.
- The `rulePredicates` loop is at `:1899` and fed `checkNullGuards`
alone.
- At head `36ea1e8f8` these are `:499`, `:1904`, `:1909`, and `:1924`
(the new nested `check()` loop) / `:1930` (the null-guard loop).
- **H2, hydration per nested slot: confirmed by code read plus an
existing pin.**
- ObjectQL's `checkConditional` (`rule-validator.ts:4226`) evaluates its
`when` against `ctx.merged`, with no `resolveTraversalScope`. It then
hands the chosen branch to `evaluateRule(branch, ctx)` (`:3469`).
- `evaluateRule` sends a `script` / `cross_field` branch to
`checkPredicate(rule, ctx.merged, …, ctx.related, ctx.fields)`. That is
the same call, with the same `related` binding, as a top-level rule.
- `collectPredicateRelationships` (`:530`) is what preloads `related`,
and it recurses into a `conditional`'s `then` / `otherwise` (its
`visit`). The `objectql` pin `reaches a predicate nested inside a
conditional` (`rule-relationship-traversal.test.ts:86`) covers that.
- So a nested `condition` is hydrated, and the traversal checks are ON
there. A nested `when` is evaluated by `checkConditional` without
hydration, so they are OFF, as at the top-level `when` site.
- **H3, location.** The rulePredicates label is used (triage: "with the
label it already builds"). The door's 422 and
`runAuthoringRules('build', …)` give it identically: `rule`, `where`,
`path`, `message` and `hint` are compared key by key in the protocol
`(d)` pin.
- **H4, no double report.** Pinned: a top-level `condition` gives
exactly one finding, at `validation 'NAME'` only. A faulting top-level
`when` beside a faulting nested `then` gives exactly two findings, one
at each location.
- **H5, no registry or `runtime-gate.ts` change was needed.**
`runtimeAuthoringRulesFor('object')` already lists
`validateStackExpressions` (pinned), and the loop is not fenced on an
object write. The protocol pins below reach the door through the built
`@objectstack/lint` `dist/` with no other edit.
- **H6, corpus first. The stop condition was not met.**
- The corpus is every `*.object.ts` under `packages/**` and
`examples/**`, plus the two `app-multi-package` sub-stacks: 111 files,
18 groups, 118 objects.
- It carries 21 validation rules, of which 1 is `conditional`. One rule
carries nested predicates: `examples/app-showcase`
`showcase_account.churn_reason_consistency`, with 2 nested `condition`s.
- The new check was run on the base build by lifting each nested
predicate to the top level: 0 errors, 0 warnings.
- At head, the nested locations gave 0 errors and 0 warnings at the
build (raw and `ObjectSchema.parse`d shapes, and through
`runAuthoringRules('build')`). The object door gave 0 errors and 0
advisories.
- Positive control, the card's body: 0 build and 0 door errors at base,
2 build and 2 door errors at head.
- A repo-wide `git grep` for a `conditional` rule outside tests finds
only that showcase rule and spec / skill doc examples. Those carry no
object, so they are not a stored corpus. The sibling `objectui` checkout
at `9990f9e` has none.
## Tests (all at head `36ea1e8f8`)
- `@objectstack/lint` `pnpm test`: `Test Files 123 passed (123)`, `Tests
5685 passed (5685)`.
- `typecheck` exit 0, including `check:test-typecheck` (`2 file(s) / 6
error(s) … held in test-typecheck-debt.json`, unchanged).
- `@objectstack/metadata-protocol` `pnpm test`: `Test Files 221 passed |
3 skipped (224)`, `Tests 28245 passed | 19 skipped (28264)`. `typecheck`
exit 0.
- `tsc --listFilesOnly` puts each touched test file inside its program:
lint's `tsconfig.test.json` and metadata-protocol's `tsconfig.json`.
- Consumers, against a rebuilt `@objectstack/cli...` and
`@objectstack/objectql...` closure (59 tasks, 11 cached):
- `@objectstack/objectql` `save-meta-response-conformance`,
`publish-meta-response-conformance`,
`publish-package-drafts-response-conformance` and
`engine-predicate-relationship`: 4 files, 80 tests passed.
- `@objectstack/cli` `authoring-rule-command-parity`,
`validate-field-predicate-traversal` and `verify-author-time-stage`: 3
files, 16 passed.
- The three cli `*.e2e.test.ts` files that read `expression-invalid` ran
under `OS_TEST_TIERS=nightly`: 3 files, 34 passed.
- **New pins.**
- In `packages/lint/src/runtime-gate.object-validation-writes.test.ts`:
- the fixtures are spec-valid (`ObjectSchema.safeParse` green);
- LIT: build, `then` `sqrt(record.amount) > 1` and `otherwise` `amont >
1`;
- LIT: the door equals the build;
- LIT: two levels, a nested `conditional`'s `when` plus a rule below it;
- CONTROL: valid nested predicates;
- judged ONCE;
- the traversal checks per slot;
- the differential.
- In
`packages/metadata-protocol/src/protocol.runtime-authoring-gate.test.ts`:
- (a) three active-save refusals, each a 422 `INVALID_METADATA` whose
`code`, `status`, `path` and `where` name the nested rule;
- (a) the draft promotion;
- (b) a valid nested rule saves `active`;
- (d) door equals build, key by key.
## Ablation (one-off, from committed head `b658c1a52`, with trap
restore)
- **The fix.** `scripts/ablation-replace.mjs` turned `if (p.depth === 0)
continue;` into `const ablation22042 = true; if (ablation22042 ||
p.depth === 0) continue;`.
- The anchor went from 1 to 0, and the blob went from `c9e828b47cee` to
`63a185602ce9`.
- Lint was rebuilt, and `ablation-dist-preflight` found the marker in 4
built files.
- Lint door file: 5 failed and 11 passed. Red were the 3 LIT pins,
"judged ONCE" and "traversal per slot". Green were the fixtures,
CONTROL, the differential and the 9 earlier pins.
- Protocol file (dist-mediated): 5 failed and 87 passed. Red were the 3
(a) saves, the promotion and (d). Green was (b).
- Restore: the blob equals HEAD `c9e828b47cee`, and `git diff HEAD` is
empty. After a rebuild, `preflight --absent` found the marker absent
from all 14 built files, with a clean tree. Back to green: 16/16 and
92/92.
- **The hydration flag, both directions**, on lint's source-run suite.
`p.slot === 'condition'` was set to `true` and then to `false`. Each
time exactly 1 test failed and 15 passed: "the traversal checks follow
the evaluator per slot". Each restore was proven by blob equality.
## Gates (at head `36ea1e8f8`)
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 63 commands. Each ran with its exit
code captured before any pipe, and all 63 ended at exit 0.
- One needed a re-run: `check:dual-build-cjs-loads` first exited 3
(PREREQUISITE NOT MET: some packages had no `dist/`). After `turbo run
build` (72 tasks, 71 cached) it exited 0.
- `--ran` reconciliation: "63 derived, 63 run, 0 NOT-MEASURED, 0 UNRUN",
exit 0.
- Changeset gates: `check-adr-0087-registration --base origin/main` exit
0 (`not-required (no-migration-prescription)` accepted),
`check-changeset-no-major --base origin/main` exit 0, and
`check-empty-changeset --base origin/main` exit 0.
- ESLint, narrowed and measured. `eslint --no-inline-config --format
json` over the 3 touched TS files gave 3 files, 0 errors and 0 warnings,
with none ignored. `--print-config` matches each file, and the config
enables no type-aware linting (`parserOptions.project` and
`projectService` unset). So this diff cannot move an untouched file's
verdict.
- CI runs the full farm and is not awaited here.
## Acceptance notes
- **Observation, not filed.** ObjectQL's `collectPredicateRelationships`
stops descending past depth 8 (`depth > 8`). So a nested `condition`
nine or more levels down is not hydrated, while lint opts it into the
traversal checks at every depth.
- The refusals agree at any depth: `checkPredicate` judges the conflict
shapes (`resolveTraversalScope` step 1) before, and independently of,
hydration.
- Only the evaluation of a valid one-hop read below depth 8 differs, at
a nesting depth no stored metadata here approaches.
- Carrier: none.
- `content/docs/data-modeling/formulas.mdx` "Build-time validation"
could say that the object save door gives the build's verdict, now
including nested validation predicates. This is a docs addition carried
over from #22032's passes, not a false line. Carrier: none.
- The contract review at `CONTRACT_REVIEW_TIER` is the seat's.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01RPo7FUd6bSnAfkWMAKi848)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent c8d06a9 commit 8fc50b7
4 files changed
Lines changed: 392 additions & 9 deletions
File tree
- .changeset
- packages
- lint/src
- metadata-protocol/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 | + | |
Lines changed: 158 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
33 | 45 | | |
34 | 46 | | |
| 47 | + | |
35 | 48 | | |
36 | 49 | | |
37 | 50 | | |
| |||
173 | 186 | | |
174 | 187 | | |
175 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
484 | 494 | | |
485 | 495 | | |
486 | 496 | | |
487 | 497 | | |
488 | 498 | | |
489 | | - | |
490 | | - | |
| 499 | + | |
| 500 | + | |
491 | 501 | | |
492 | 502 | | |
493 | 503 | | |
| |||
499 | 509 | | |
500 | 510 | | |
501 | 511 | | |
502 | | - | |
503 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
504 | 516 | | |
505 | 517 | | |
506 | 518 | | |
507 | | - | |
| 519 | + | |
508 | 520 | | |
509 | 521 | | |
510 | 522 | | |
| |||
1885 | 1897 | | |
1886 | 1898 | | |
1887 | 1899 | | |
1888 | | - | |
1889 | | - | |
1890 | | - | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
1891 | 1904 | | |
1892 | 1905 | | |
1893 | 1906 | | |
1894 | 1907 | | |
1895 | 1908 | | |
1896 | 1909 | | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
1897 | 1928 | | |
1898 | 1929 | | |
1899 | | - | |
| 1930 | + | |
1900 | 1931 | | |
1901 | 1932 | | |
1902 | 1933 | | |
| |||
0 commit comments