MVP: Scope recompute to changed schema elements#9467
Draft
BeArchiTek wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
2 issues found across 27 files
Confidence score: 3/5
- There is a concrete regression risk in
backend/infrahub/computed_attribute/tasks.py: whenchanged_elementsis missing, recomputation appears limited to modified triggers instead of all branch attributes, which can leave computed values stale for users. - Given the high confidence and user-facing impact of stale computed attributes, this lands as some merge risk rather than a low-risk housekeeping change.
- The
dev/specs/001-scope-computed-attr-recompute/data-model.mdinconsistency (is_availabletyped asboolbut notes implyingNone) is low severity and mainly documentation/model clarity, so it should not block merge by itself. - Pay close attention to
backend/infrahub/computed_attribute/tasks.py- verify fallback recomputation covers all branch attributes whenchanged_elementsis unavailable.
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
…9415) Previously any schema change recomputed every computed attribute on the branch — for Python-transform attributes, one recompute job per object of its kind — regardless of relevance. Recompute is now scoped to the schema elements a change actually touches: a computed attribute is recomputed only when the change affects an element its value depends on, including elements reached through relationships. Changes whose impact cannot be determined fall back to a full recompute so nothing goes stale. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
d07fc78 to
fe7ea71
Compare
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.
Summary
Fixes #9415. Previously, any schema change recomputed every computed attribute on the branch — and for Python-transform attributes, one recompute job per object of its kind — regardless of relevance. On large datasets this was slow and wasteful.
Recompute is now scoped to the schema elements a change actually touches: a computed attribute is recomputed only when the change affects an element its value depends on (including elements reached through relationships). When the impact cannot be determined precisely, it conservatively falls back to a full recompute so nothing goes stale.
How it works
SchemaUpdatedEventnow carries aChangedElementsPayload(added/removed kinds + per-kind changed fields), built from theSchemaDiffby the two schema-update emitters and threaded through the Prefect triggers into the setup flows.RecomputeScoper(constructor-injected, single entry point) intersects each attribute's dependency set against the changed elements. Per-kindComputedAttributeDependencyDeriverimplementations cover Jinja2 (template dependency graph) and Python transforms (GraphQL query analysis).Scope notes
SchemaUpdatedEvent), so this scoping does not run on the merge path — unchanged from before; merged data changes recompute via the existing data-change path.Testing
ruff+mypyclean.Also adds
backend/tests/integration_docker/conftest.pydisabling commit signing for the test session so repo-based integration tests run regardless of a developer'scommit.gpgsign.🤖 Generated with Claude Code
Summary by cubic
Scopes computed-attribute recompute to only the schema elements that changed, instead of recomputing everything on each schema update. Fixes #9415 and reduces unnecessary jobs on large datasets while keeping correctness with conservative fallbacks.
ChangedElementsPayloadtoSchemaUpdatedEvent, populated fromSchemaDiff; triggers now passchanged_elementsthrough to setup flows.RecomputeScoperto intersect each attribute’s dependencies with changed elements; supports Jinja2 and Python transforms viaTransformReadSet. Imprecise field reads (display_label,hfid) cause that attribute to always recompute.Written for commit fe7ea71. Summary will update on new commits.