Record template fingerprints in the database instead of placeholder automations (IFC-2167)
Summary
Implements the Jira epic IFC-2167, from the discovery idea INFP-441.
Today Infrahub creates one task manager automation per kind, and one more per branch whose schema differs from the default branch, for display labels, HFIDs and Jinja2 computed attributes. These automations never run: they only hold a fingerprint of the template, so that a schema update can detect a template change. According to INFP-441, one customer reached 11,000 automations, and the task manager UI lists only the first 200.
With this change:
- Infrahub records the template fingerprints of display labels and HFIDs as
TemplateFingerprintvertices in the database, one per family, branch and kind, and compares them on each schema update to decide which kinds to recompute. - Infrahub no longer creates an automation for a Jinja2 computed attribute that reads only its own node. The candidates and the default-branch comparison come from the schema.
- The upgrade carries the fingerprints held by existing placeholder automations over to records, then removes those automations, so the upgrade does not recompute every stored value.
- Deleting a branch removes its records.
Specification, plan and tasks: dev/specs/ifc-2167-placeholder-automations/.
Query plan of the fingerprint read
The setup flows read the records of one family with this query:
MATCH (f:TemplateFingerprint { family: $family })
RETURN f.branch AS branch,f.kind AS kind,f.fingerprint AS fingerprint
ORDER BY branch,kind
Measured on Neo4j 2026.10.1-enterprise (testcontainers), with the default branch and 3 other branches, and 480 records written through the repository (2 families, 4 branches, 60 kinds). The records were synthetic: no schema of 60 kinds was loaded. This does not change the plan, because the query reads only TemplateFingerprint vertices.
PROFILE, from the leaf up:
| Operator | Rows | Database hits |
|---|---|---|
NodeByLabelScan f:TemplateFingerprint | 480 | 481 |
Filter f.family = $family | 240 | 480 |
CacheProperties cache[f.branch], cache[f.kind] | 240 | 480 |
Projection | 0 | |
Sort branch ASC, kind ASC | 0 | |
Projection f.fingerprint | 240 | 480 |
ProduceResults | 240 |
EXPLAIN returns the same operators. The read scans every record of the label and filters on family, about 4 database hits per record. An index on family would only remove the filter on the other family's records, so no index is proposed.
Live scenarios and performance check
Run on 2026-11-20 with one Docker Compose stack (root docker-compose.yml, Neo4j 2026.10.1-community, 2 task workers). The stack first ran the 1.12.1 image, then an image built from this branch (commit e904b958c3; no backend change since then), and kept the same Neo4j and task manager volumes.
The test schema has these node kinds:
- 60
LiveThing<n>kinds, each with a display label template and an HFID. LiveRole.LiveDevice, with a display label that reads the name of itsLiveRolepeer, and a Jinja2 computed attributefqdnthat reads only its own node.
Nodes exist for LiveThing0 to LiveThing4 and LiveDevice. The branches br1, br2 and br3 each add an attribute to LiveThing59.
Upgrade from 1.12.1 (scenario 4)
- On
1.12.1, with the schema loaded onmainand the three branches, the task manager held 852 placeholder automations: 460 display label, 388 HFID and 4 Jinja2 computed attribute. - Deleting the
maindisplay label automation ofLiveThing7left 851. - After the switch to this branch's image,
infrahub upgradecompleted. No placeholder automation remained. 847TemplateFingerprintrecords existed (459 display label, 388 HFID), one per carried-over automation.mainhad no display label record forLiveThing7. - A later schema load on
mainthat changed no template started one recompute run:trigger-update-display-labelsforLiveThing7onmain. The same kind of load onbr1started none. - The upgrade also removed the branch-scoped peer automations (
display_label_jinja2::br*::LiveDevice::by::LiveRole) and branch profile automations. This branch did not change that step:trigger_configure_allreconfigures the automations from the default-branch triggers withforce_update=True. The next schema update recreated them.
No placeholder automation (scenario 1)
- After the upgrade and the schema loads that followed on
mainandbr1, no automation matched_trigger_placeholder. - The task manager held 4 display label automations and 8 HFID automations.
- Loading a new kind with a display label template and an HFID (
LiveThing60) onmainstarted onetrigger-update-display-labelsrun and onetrigger-update-hfidrun for that kind. The number of display label and HFID automations did not change. The only automation added was the profile automation of the new kind. - The automation for the peer display label of
LiveDeviceexisted onmainand on each branch.
Recompute only on a template change (scenario 2)
- Changing only the display label template of
LiveThing3onmainstarted onetrigger-update-display-labelsrun forLiveThing3onmain. No other display label, HFID or computed attribute recompute ran, and theLiveThing3nodes showed the new label. - Loading the same schema again changed no schema and started no run.
- On
br2, setting theLiveThing3template to themainvalue started no recompute run. Setting it to a different value started one run forLiveThing3onbr2.mainkept its labels.
Branch lifecycle (scenario 3)
- On
br3, after a template change onLiveThing5,MATCH (f:TemplateFingerprint {branch: "br3"}) RETURN count(f)returned 212. - After the branch was deleted, the same query returned 0.
- Recreating
br3and loading the same change started onetrigger-update-display-labelsrun forLiveThing5onbr3. It also started one run forLiveThing3, because the recreated branch started from themaintemplate ofLiveThing3(changed in scenario 2), and the loaded schema held the earlier template.
Duration of the setup flows (SC-005)
Each measurement is the run time of the setup flow started by a schema load that changes no template: it adds an optional attribute to LiveThing59. Every run has 62 test kinds, the core kinds, and 3 branches whose schema differs from main.
| Branch of the load | Flow | 1.12.1 (seconds) | This branch (seconds) |
|---|---|---|---|
main | display-labels-setup-jinja2 | 3.39, 3.46, 2.72 | 1.08, 1.95, 1.01 |
main | hfid-setup | 3.20, 3.39, 2.37 | 1.05, 1.96, 0.90 |
br1 | display-labels-setup-jinja2 | 4.82, 3.51 | 1.21, 0.57 |
br1 | hfid-setup | 4.51, 3.43 | 1.15, 0.51 |
On this stack, every setup run on this branch took less time than the fastest run of the same flow on 1.12.1.
š¤ Generated with Claude Code