fix(summary-maintenance): enforce lifecycle legality and raw fallback - #317
Merged
Merged
Conversation
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 30, 2026 18:21
fa3781f to
47bc52b
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 30, 2026 18:21
9806c0a to
495b664
Compare
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 30, 2026 18:30
47bc52b to
c188ea7
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 30, 2026 18:30
495b664 to
4015f26
Compare
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 30, 2026 18:35
c188ea7 to
26a9fbd
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 30, 2026 18:35
4015f26 to
944df5d
Compare
This was referenced Aug 30, 2026
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 30, 2026 18:46
26a9fbd to
65b03da
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 30, 2026 18:46
944df5d to
621fb5e
Compare
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 30, 2026 19:03
65b03da to
5749311
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 30, 2026 19:03
621fb5e to
5adb5f1
Compare
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 30, 2026 21:22
5749311 to
cc53386
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 30, 2026 21:22
5adb5f1 to
158002a
Compare
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 30, 2026 21:27
cc53386 to
d2584ef
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 30, 2026 21:27
158002a to
3df3599
Compare
zzylol
force-pushed
the
feat/summary-lifecycle-alternatives
branch
from
August 31, 2026 12:04
d2584ef to
7a2f232
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
2 times, most recently
from
August 31, 2026 12:17
c9334fc to
5e564bd
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 31, 2026 12:35
5e564bd to
8db7940
Compare
zzylol
force-pushed
the
fix/summary-lifecycle-legality
branch
from
August 31, 2026 12:45
8db7940 to
27296e7
Compare
Contributor
Author
|
@milindsrivastava1997 This relates to what you said about adding constraints to the edges between nodes for their capability and schema checking. |
zzylol
changed the base branch from
feat/summary-lifecycle-alternatives
to
main
September 2, 2026 00:55
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.
Stacked on #316.
Why
#316 enumerates lifecycle alternatives, but enumeration alone is not enough: a lifecycle must be rejected when its bound consumers, timing, data arrival, summary operations, or evidence cannot support the physical guarantee it promises.
This PR makes those checks explicit and fail-closed before lifecycle cost ranking.
Exact mechanism implemented
1. Bind lifecycle demand to the consumers of this target
plan_summary_maintenance_lifecyclesnow receivesWorkloadDemand { workload, entry_indices }instead of treating every entry in the workload as a consumer of every materialized target.The binding is validated before planning:
EmptyWorkloadDemand;InvalidWorkloadEntry; andDuplicateWorkloadEntry.Only the bound entries contribute invocation counts, recurring reads, evaluation rate, preparation eligibility, and time-scope requirements. This prevents unrelated workload entries from manufacturing reuse for a summary.
2. Derive conservative workload facts
For the bound entries,
workload_factscomputes:Scheduled recurrence counts only executions inside
[now, now + horizon]. Unknown recurrence or stale evidence remains unknown instead of being converted to zero.3. Enforce prepared-state timing
Prepared state is offered only when every bound consumer is a predictable one-time query with both
known_atandexecute_at.For each consumer the planner requires:
The emitted activation time is:
Across several eligible consumers, the deployment uses the earliest valid activation and latest execution as its preparation window. Consequently, the planner cannot emit a prepared deployment whose activation or retirement is already in the past, and retention/maintenance cost is charged only from the current planning time forward.
If any bound consumer is ad hoc, repeated, unknown, incompletely scheduled, or expired, the prepared alternative is rejected with
RequiresPredictableOneTimeQuery.4. Ask the concrete summary what operations it supports
The
CostModelgains:SummaryMaintenanceCapabilitiesrecordsincremental_update,merge, anddelete. Its default is deliberately conservative: all capabilities arefalse.In this PR, lifecycle legality consumes the update and deletion flags:
incremental_update;lookbackpresent, no fixedas_of) additionally requiresdelete; andSummaryDoesNotSupportIncrementalUpdatesorSummaryDoesNotSupportDeletionbefore cost ranking.The
mergecapability is part of the capability contract for composed summaries, but this PR does not add a separate merge-legality rule.Ephemeral state is not subjected to these retained-state update/delete requirements because it is rebuilt for each invocation.
5. Preserve the maintenance mode on rejected alternatives
Every alternative—including rejected ones—retains the mode it would use:
DirectBuild;DirectBuild; andIncremental.This keeps rejection explanations physically meaningful instead of losing whether the refused plan required a direct build or incremental maintenance.
6. Add summary and raw cost-accounting hooks
The plan now records:
expected_reads;summary_total_costfor the selected lifecycle of every deployment;raw_recompute_total_cost; andselected_raw_recompute.The
CostModelalso gainsraw_query_recompute_cost(target), whose conservative default isNone.This PR establishes the data and extension points needed for raw fallback. It does not perform the final materialization-time summary-vs-raw comparison; #318 wires these fields into global selection/materialization and performs that fallback.
Lifecycle checks by alternative
EphemeralPreparedSharedContinuouslyMaintainedAfter these checks, only alternatives with no rejection and a complete total cost are selectable. Missing information never makes a long-lived lifecycle win.
Rejection reasons added
SummaryDoesNotSupportIncrementalUpdatesSummaryDoesNotSupportDeletionExisting rejection reasons continue to represent unsupported runtime lifecycle shapes, unsuitable predictability, insufficient reads, missing horizon, incompatible arrival mode, stale ingestion evidence, and missing cost evidence.
Tests added
Coverage verifies that:
Verification
cargo test -p asap-aware-mapping summary_maintenance_lifecycle --no-fail-fastcargo clippy -p asap-aware-mapping --all-targets -- -D warningsStack
Base: #316. Next: #318.