Repository navigation
feat(metadata): add relative dates and case expressions to view loaders - #562
Merged
Merged
Conversation
Load and validate, in TypeScript, C#, Java (Kotlin through it) and Python:
- a relative date ({ now: ... }) in a projection's and an origin.first /
origin.aggregate's @filter, shape-checked where it is declared;
- case and now in an origin.computed expression, and a ref in it that names
another of the projection's own fields (never itself, never an aggregate)
before a base field.
error-relative-date-origin-host and error-relative-date-wrong-host are
removed: those hosts now accept the value. New fixtures:
projection-filter-relative-now, origin-filter-relative-now,
origin-computed-case-over-joined, error-origin-computed-case-mixed-types.
…e entry and @condition refusal note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
origin.first/origin.aggregate@filtervalues accept relative dates ({ "now": "-P7D" }, optionalstartOf). Loaders in TypeScript, C#, Java and Python check the shape and refuse a malformed value or a non-temporal target field. The earlier refusal fixtures for relative dates are removed.origin.computedexpressions acceptnowandcase(searched, or simple with anoperand). A ref can name another projection field, and acaseorcoalesceunifies literal andnowarms with the field types. Loaders refuse a non-boolean searchedwhen, mismatched result types, unknown expression keys, badnowdurations, and computed-field cycles (ERR_UNKNOWN_EXPR_NODEfor unknown keys).@conditionstill refusescaseandnow. Metamodel vocabulary (spec/metamodel,attrandoriginspecs, registry expectations, generated docs and site reference) is updated to match, andmetamodelVersionmoves to1.3as noted in CHANGELOG.Notes for reviewers
scripts/ci-local.shbefore the run: every lane green on all five ports. The first pass had three load timeouts (load average near 50). On a rerun of thegatesandts-slowsections they were green, except for one hung MySQL worker, and that file passes 5 of 5 on its own in 13 seconds.case'swhenvalues and onorigin.computedcomparisons, with its own shared error fixture.caseorcoalesce"unify a numeric literal with any numeric field" is now too broad. A fractional literal unifies only with double, float or decimal (error-origin-computed-literal-fractional).meta migrateleaves acase,nowor own-field computed column out of the generated view while the DTO still declares it. That PR should also make the extractor raise an error there rather than skip.Validation
Risk Assessment
✅ Low: The expression grammar, cycle check, relative-date shape check and condition refusal are implemented consistently in all four loaders and match shared fixtures; the only defect found is an inaccurate CHANGELOG sentence.
Testing
Loader behavior targeted by this PR is live-verified: the TypeScript CLI and Python loader accept the valid simple-case, integer-case, currency-coalesce and non-cycle chain projects, and refuse the mixed-key, misspelled-key, bad-duration, mutual-cycle, fractional-currency, relative-date-on-currency and validator-now cases. C# and Java shared conformance suites pass. The gate's no-go came from running the Python suite under the system interpreter without the integration extra; under
uv run --extra integrationthe full suite passes (4953 passed, 15 skipped). The full TypeScript suite passed per package in the full local CI run.bun testover server/typescript timed out at 1500s in the gate. The same suites ran green per package in the fullscripts/ci-local.shbefore the run (ts conformance, ts unit suites, integration-tests ts, migrate-ts and runtime-ts real-PG gates), and the gate's configuredts-fast+ts-unitlanes passed on the fixed head.uv run --extra integration pytest tests/ -n 8): 4953 passed, 15 skipped. The gate's first attempt used the systempython3without theintegrationextra, so 8 failed and 17 errored on missingpg8000and an uninstalledmetaobjectspackage.Evidence: TS CLI transcripts and summary per scenario
Evidence: TS CLI transcript, positive project
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/typescript/packages/metadata/src/core/attr/meta-attr-expression.ts:168- adaptsTo lets any numeric literal take any numeric type. That includes a fractional literal beside an integer-backed field. Example:coalesce(priceCents, 9.99)with priceCents a field.currency, orcase [{when: ..., then: {value: 1.5}}] else {field: statusId}with statusId a field.long, now unifies to currency or long and loads clean against a field.currency or field.long declaration. Before this change both were refused as (currency, double). The view CASE/COALESCE then yields a numeric 9.99 or 1.5 in a column the field declares as integer minor units or long. That breaks the currency wire rule (integer minor units, no float money) and gives the runtime a value its codec truncates or rejects, all with no load error. Narrower rule: an integer-valued literal (literalType int) adapts to any numeric subtype; a double literal adapts only to double, float and decimal. Same rule at server/csharp/MetaObjects/Core/Attr/ExpressionGrammar.cs:345 (AdaptsTo), server/java/metadata/src/main/java/com/metaobjects/attr/ExpressionAttribute.java:545 (adaptsTo) and server/python/src/metaobjects/loader/validation_passes.py:1296 (_adapts_to). Add a negative case, such as currency beside 9.99, to a shared error fixture.server/typescript/packages/codegen-ts/src/projection/extract-view-spec.ts:1296- Merge-order hazard between PR 1 and PR 2, not a defect in this PR. The loader now acceptscase,nowand refs to the projection's own fields in an origin.computed @expr. The unchanged view extractor's resolveExprNode returns undefined for all three (it finds only base.fields()), and the callercontinues. So until PR 2 lands,meta migratesilently omits that computed column from the view, while the DTO still declares it. The 1.3.0 hold covers releases, but main sits in this state between the two merges. PR 2 should also turn thatcontinueinto a thrown error so the loader/lowering gap can never be silent again.fixtures/conformance/ERROR-CODES.json:55- The ERR_BAD_ATTR_FILTER description still says a relative date is refused 'outside the @filter of a segment, measure.aggregate or object.report (F1)'. This change makes projection, origin.aggregate and origin.first @filters legal hosts too. This file is not in the changed set, so it was not edited inline. Reword it to list the six legal hosts, matching docs/features/reporting.md:972.server/typescript/packages/metadata/src/loader/reporting-validation.ts:1187- Inline fix: the F1 refusal message (still reachable on a dataGrid preset) said a relative date is 'legal only in the @filter of a segment, measure.aggregate or object.report'. That became stale when projections and origin.aggregate/first took relative dates. It now lists 'a segment, measure.aggregate, object.report, object.projection, origin.aggregate or origin.first'. Applied identically at server/python/src/metaobjects/loader/validate_reporting.py:1236, server/csharp/MetaObjects/Loader/ValidationPasses.Reporting.cs:1134 and server/java/metadata/src/main/java/com/metaobjects/loader/ReportingValidation.java:1219. No test asserts the old text.server/typescript/packages/metadata/src/loader/validation-passes.ts:1664- Inline fix: added the ADR-0039 sanctioned-case comments that the new own reads lacked. These are the computed-ref walk'so.ownAttr(ORIGIN_COMPUTED_ATTR_EXPR)(TS here, and C# at server/csharp/MetaObjects/Loader/ValidationPasses.cs:803) and the view-host branch'sownMetaAttrs()/OwnAttrs()(server/typescript/packages/metadata/src/loader/reporting-validation.ts:1173, server/csharp/MetaObjects/Loader/ValidationPasses.Reporting.cs:1109). Comments only; no behaviour change.🔧 Fix applied.
4 infos still open:
server/typescript/packages/codegen-ts/src/projection/extract-view-spec.ts:1296- Merge-order hazard between PR 1 and PR 2, not a defect in this PR. The loader now acceptscase,nowand refs to the projection's own fields in an origin.computed @expr. The unchanged view extractor's resolveExprNode returns undefined for all three (it finds only base.fields()), and the callercontinues. So until PR 2 lands,meta migratesilently omits that computed column from the view, while the DTO still declares it. The 1.3.0 hold covers releases, but main sits in this state between the two merges. PR 2 should also turn thatcontinueinto a thrown error so the loader/lowering gap can never be silent again.server/typescript/packages/metadata/src/loader/reporting-validation.ts:1187- Inline fix: the F1 refusal message (still reachable on a dataGrid preset) said a relative date is 'legal only in the @filter of a segment, measure.aggregate or object.report'. That became stale when projections and origin.aggregate/first took relative dates. It now lists 'a segment, measure.aggregate, object.report, object.projection, origin.aggregate or origin.first'. Applied identically at server/python/src/metaobjects/loader/validate_reporting.py:1236, server/csharp/MetaObjects/Loader/ValidationPasses.Reporting.cs:1134 and server/java/metadata/src/main/java/com/metaobjects/loader/ReportingValidation.java:1219. No test asserts the old text.server/typescript/packages/metadata/src/loader/validation-passes.ts:1664- Inline fix: added the ADR-0039 sanctioned-case comments that the new own reads lacked. These are the computed-ref walk'so.ownAttr(ORIGIN_COMPUTED_ATTR_EXPR)(TS here, and C# at server/csharp/MetaObjects/Loader/ValidationPasses.cs:803) and the view-host branch'sownMetaAttrs()/OwnAttrs()(server/typescript/packages/metadata/src/loader/reporting-validation.ts:1173, server/csharp/MetaObjects/Loader/ValidationPasses.Reporting.cs:1109). Comments only; no behaviour change.CHANGELOG.md:151- CHANGELOG.md:151-153 says a case's results and a coalesce's arguments "unify a numeric literal with any numeric field". After the R3-1 fix that is wrong for fractional literals. A fractional literal such as 9.99 or 1.5 unifies only with double, float or decimal, and is refused beside long, int or currency. The new fixtureerror-origin-computed-literal-fractionalgates this refusal but the entry never names it. Reword to say a whole-number literal unifies with any numeric field and a fractional one only with double, float or decimal, and list the fixture.cd server/typescript && bun test) hit the 1500s timeout (TS_EXIT=124) with no pass/fail summary, so regression status for TS is unknown beyond the baseline ts-fast/ts-unit lanes.python3 -m pytest tests -n 4): 8 failed, 17 errors, 4620 passed. Failures look environmental: ModuleNotFoundError pg8000 (12 tests),No module named metaobjects.cli/ PackageNotFoundError for metaobjects, and ruff/mypy-related tests. None were run against the base commit, so they are not proven pre-existing.bun testover server/typescript timed out at 1500s in the gate. The same suites ran green per package in the fullscripts/ci-local.shbefore the run (ts conformance, ts unit suites, integration-tests ts, migrate-ts and runtime-ts real-PG gates), and the gate's configuredts-fast+ts-unitlanes passed on the fixed head.uv run --extra integration pytest tests/ -n 8): 4953 passed, 15 skipped. The gate's first attempt used the systempython3without theintegrationextra, so 8 failed and 17 errored on missingpg8000and an uninstalledmetaobjectspackage.scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchainsscripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchains (baseline, green per context)bun server/typescript/packages/cli/bin/meta.ts verify --templates against 16 shared fixture inputs and 3 synthetic projects (live CLI)Python conformance_adapter.load_fixture on three synthetic projects (positive, currency filter, fractional currency)python3 -m pytest tests/conformance/test_conformance.py -q (471 passed)python3 -m pytest tests -q -n 4 (full suite: 8 failed, 17 errors, 4620 passed)dotnet test server/csharp/MetaObjects.Conformance.Tests --filter Conformance (2457 passed)mvn -o -q -pl metadata test -Dtest='*Conformance*' (ConformanceTest 934 passed)bun test in server/typescript (full suite, timed out at 1500s, no result)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.