Skip to content

feat(intent): rollup op: latest - keep a parent field equal to the newest child's value - #6350

Merged
delchev merged 1 commit into
masterfrom
feat/intent-rollup-latest
Jul 21, 2026
Merged

feat(intent): rollup op: latest - keep a parent field equal to the newest child's value#6350
delchev merged 1 commit into
masterfrom
feat/intent-rollup-latest

Conversation

@delchev

@delchev delchev commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Adds a third rollup aggregation alongside count/sum. op: latest copies the of value of the child row with the greatest by date/timestamp onto the parent field — the recurring "parent's headline value = its newest child's value" shape the DSL couldn't express (only count/sum).

rollups:
  - { name: latestRate, entity: CurrencyRate, via: Currency, field: rate, op: latest, of: rate, by: date }
  • RollupIntent.by = the child date/timestamp ordering field.
  • Parser: latest requires of + by; by must be date/timestamp; the parent field type must match of.
  • Emits create/update/delete handlers (any of those can change which row is latest / its value).
  • renderRollupAggregate latest branch tracks the max-by row type-agnostically (var + Objects.equals), copies its of with the usual change-guard; empty child set → parent field null.

Motivation: surfaced by a KeyFolders currencies review — Currency.rate was a dead field (nothing maintained it) because the DSL had no copy-latest-child-to-parent primitive.

Test: GlueRollupLatestTest (handlers + of/by/field mapping); full engine-intent suite green. Runtime proof is the currencies adoption (verified on regeneration there).

🤖 Generated with Claude Code

…west child's value

Adds a third rollup aggregation alongside count/sum: op: latest copies the
`of` value of the child row with the greatest `by` date/timestamp onto the
parent `field`. The recurring "keep the parent's rate equal to its latest
child rate" shape (e.g. Currency.rate <- newest CurrencyRate.rate) that the DSL
could not express before (only count/sum).

- RollupIntent gains `by` (the child date/timestamp ordering field).
- Parser: op: latest requires `of` + `by`, `by` must be date/timestamp, and the
  parent field type must match `of`.
- Generator emits create/update/delete handlers (a new/edited/removed child row
  can change which row is latest or its value).
- renderRollupAggregate's latest branch tracks the max-`by` row type-agnostically
  (`var` + Objects.equals), copies its `of` onto the parent field with the usual
  change-guard; an empty child set resets the parent field to null.

Unit: GlueRollupLatestTest (create/update/delete handlers + of/by/field mapping);
full engine-intent suite green. Runtime proof is the KeyFolders currencies
adoption (Currency.rate maintained from CurrencyRate), verified on regeneration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@delchev
delchev merged commit 19a1231 into master Jul 21, 2026
10 checks passed
@delchev
delchev deleted the feat/intent-rollup-latest branch July 21, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant