Validate default literals against entity schema (drift) + rule 14c#46
Merged
Conversation
Follow-up to juxt/allium#43. Adds `check_default_field_schemas` (and the TypeScript `findDefaultFieldSchemaIssues`, which walks the front-end AST) validating `default Type x = { ... }` object literals against the declared schema of local entity/value types: - Gap B drift: a field the type does not declare is reported as `allium.default.unknownField`, recursing into nested object literals (so a stale field inside `predicate: { ... }` is caught against the nested type). - Rule 14c: an empty list literal whose target field is not a `List<T>` is reported as `allium.list.emptyListNoElementType` — it has no element type to infer. Empty lists in `List<T>` fields remain valid. Validation is keyed to local entity/value declarations. Qualified (imported) default types are skipped: their field schema is not visible to a single-module pass, and cross-module field plumbing would be CLI-multi-file-only. Verified zero new diagnostics across all checked-in example specs. Rust and TypeScript kept in parity; parity doc and diagnostic-code table updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
yavorpanayotov
added a commit
to juxt/allium
that referenced
this pull request
Jun 16, 2026
Adds validation rule 24b: every field in a `default` object literal must be declared on the named entity/value type, recursing into nested object literals, so field renames/removals surface as drift errors at check time. Complements the existing 24a (qualified-type schema resolution) and 14c (empty-list element type). Implemented in juxt/allium-tools#46. Refs #43 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 16, 2026
Merged
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.
Actions the two follow-ups identified during review of juxt/allium#43: Gap B drift detection and language-reference rule 14c.
What it does
A new
check_default_field_schemas(Rust) /findDefaultFieldSchemaIssues(TS, walks the front-end AST) validatesdefault Type x = { ... }object literals against the declared schema of local entity/value types:allium.default.unknownField: a field the type doesn't declare is flagged, recursing into nested object literals (so a stale field insidepredicate: { ... }is checked against the nested value type — matching the reporter's shape).allium.list.emptyListNoElementType: an empty[]whose target field isn't aList<T>has no element type to infer. Empty lists inList<T>fields stay valid.Scope / honesty
CrossModuleContext(like triggers) and would be CLI-multi-file-only (the single-file TS analyzer can't see other modules), so it's a deliberate follow-up rather than part of this PR..alliumspec in the repo.Tests
cargo test --workspacegreen; added 6 tests (unknown field, nested drift, known-fields-ok, empty-list-in-list-ok, empty-list-in-non-list-flagged, qualified-skip).npm run test330 pass (added 3);npm run lintclean.Parity doc + diagnostic-code table updated (
allium.default.unknownField,allium.list.emptyListNoElementType).Refs juxt/allium#43
🤖 Generated with Claude Code