Record template fingerprints in the database instead of placeholder automations (IFC-2167)

Draft
PO
12d ago
+12921-1798

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 TemplateFingerprint vertices 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:

OperatorRowsDatabase hits
NodeByLabelScan f:TemplateFingerprint480481
Filter f.family = $family240480
CacheProperties cache[f.branch], cache[f.kind]240480
Projection0
Sort branch ASC, kind ASC0
Projection f.fingerprint240480
ProduceResults240

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 its LiveRole peer, and a Jinja2 computed attribute fqdn that 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 on main and the three branches, the task manager held 852 placeholder automations: 460 display label, 388 HFID and 4 Jinja2 computed attribute.
  • Deleting the main display label automation of LiveThing7 left 851.
  • After the switch to this branch's image, infrahub upgrade completed. No placeholder automation remained. 847 TemplateFingerprint records existed (459 display label, 388 HFID), one per carried-over automation. main had no display label record for LiveThing7.
  • A later schema load on main that changed no template started one recompute run: trigger-update-display-labels for LiveThing7 on main. The same kind of load on br1 started 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_all reconfigures the automations from the default-branch triggers with force_update=True. The next schema update recreated them.

No placeholder automation (scenario 1)

  • After the upgrade and the schema loads that followed on main and br1, 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) on main started one trigger-update-display-labels run and one trigger-update-hfid run 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 LiveDevice existed on main and on each branch.

Recompute only on a template change (scenario 2)

  • Changing only the display label template of LiveThing3 on main started one trigger-update-display-labels run for LiveThing3 on main. No other display label, HFID or computed attribute recompute ran, and the LiveThing3 nodes showed the new label.
  • Loading the same schema again changed no schema and started no run.
  • On br2, setting the LiveThing3 template to the main value started no recompute run. Setting it to a different value started one run for LiveThing3 on br2. main kept its labels.

Branch lifecycle (scenario 3)

  • On br3, after a template change on LiveThing5, MATCH (f:TemplateFingerprint {branch: "br3"}) RETURN count(f) returned 212.
  • After the branch was deleted, the same query returned 0.
  • Recreating br3 and loading the same change started one trigger-update-display-labels run for LiveThing5 on br3. It also started one run for LiveThing3, because the recreated branch started from the main template of LiveThing3 (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 loadFlow1.12.1 (seconds)This branch (seconds)
maindisplay-labels-setup-jinja23.39, 3.46, 2.721.08, 1.95, 1.01
mainhfid-setup3.20, 3.39, 2.371.05, 1.96, 0.90
br1display-labels-setup-jinja24.82, 3.511.21, 0.57
br1hfid-setup4.51, 3.431.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