Repository navigation
ref(issues): Replay derived features from action history - #126621
Conversation
1a3a167 to
3c04688
Compare
3c04688 to
7e187d3
Compare
| """The relevant action history is too large to replay inline.""" | ||
|
|
||
|
|
||
| def replay_feature_from_log[T]( |
There was a problem hiding this comment.
i did decide to avoid writing an opportunistic promotion feature, since it's not really what i want in the case of assignment summaries (just not high volume enough to be relevant imo). this one is just a scoped feature replay instead
| """Replay a feature's action history. This does not update stored derived data.""" | ||
| selected = Pipeline(resolve((feature,), pipeline.aggregators)) | ||
| query = GroupActionLogEntry.objects.filter(group_id=group_id).order_by("date_added", "id") | ||
| if not any(agg.scope is Scope.ALL for agg in selected.aggregators): |
There was a problem hiding this comment.
kinda want to have a scope() method on Pipeline just like
def scope(self) -> EffectiveScope:
result = set[int]()
for _, _, _, scope in self._steps:
if scope is Scope.ALL:
return Scope.ALL
result.update(scope)
return frozenset(result)
and then perhaps a
# maybe on the manager or queryset?
def scope_filter(q: QuerySet[GroupActionLogEntry], scope: EffectiveScope):
if scope is Scope.ALL:
return q
return q.filter(type__in=(scope))
so "filter this query by the pipeline scope" is trivial. We could generalize the existing GroupActionLogEntryManager methods to use it.
Not needed in this PR, just pondering what would make this PR less awkward to write. Pipeline scopes and being able to use that to query more efficiently is part of the design, but it's not really part of the API so it's not terribly discoverable.
| *, | ||
| history_limit: int = 2000, | ||
| ) -> T: | ||
| """Replay a feature's action history. This does not update stored derived data.""" |
| history_limit: int = 2000, | ||
| ) -> T: | ||
| """Replay a feature's action history. This does not update stored derived data.""" | ||
| selected = Pipeline(resolve((feature,), pipeline.aggregators)) |
There was a problem hiding this comment.
I initially imagined we may want to try to grab a subset of the Pipeline rather than pay the cost of resolve again, but in retrospect that's a little silly.
| raise FeatureHistoryLimitExceeded( | ||
| f"History for {feature.name!r} exceeds {history_limit} entries" | ||
| ) | ||
| if not entries: |
There was a problem hiding this comment.
This isn't even worth checking. run without entries or an initial state reduces to basically putting initial_value() in a dict and returning it.
In my original comment I had this fast-path because it'd avoid Pipeline construction altogether for cases that land on the default value, which may not be a meaningful optimization, but does risk only having the validation logic run once you have a meaningful history, which seems less ideal for ensuring correctness, so I think what we have here is good.
7e187d3 to
af898ff
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit af898ff. Configure here.
af898ff to
647763e
Compare
Resolve only the aggregators needed for the requested feature and its dependencies. Filter action history using their declared scopes and cap inline replay at 2,000 relevant entries, without persisting derived state. Skip the assignment summary when the limit is exceeded while allowing assignment to proceed. Co-authored-by: Codex <codex@openai.com>
647763e to
e41947f
Compare

Sometimes we'll really want fresh data for derived data, and don't want to wait for automatic regeneration to fix these problems. Add
replay_feature_from_logthat replays the GAL for a selected feature without persisting it, and use it in assignment summarization decisions.