Skip to main content

Definition changes

Configuration changes apply at restart. Census must never serve values computed under the old definition as valid under the new one, and should not fetch from every source for a change that stored data can answer. It decides with two hashes, computed from the configuration and stored in the cache.

Two hashes​

HashComputed fromWhen it changes
Collection hash, one per contributionconnection, the connection's type and endpoint, object_types, hfid, the attributes paths, the location pathsThe stored records were collected with other settings and may lack data Census now needs. Census deletes the contribution's records and sets its snapshot to none; the refresh at startup collects them again.
Resolution hash, one per inventoryThe fields (types, vocabularies, defaults, priorities), priority, freshness, the location levels, locations and priority, and each contribution's values, defaults and location_valuesThe stored observations are enough. Census marks the inventory rebuilding, normalizes every observation again from its original value, recomputes every entity, then marks it ready.

Settings in neither hash, such as description, entity_kind, refresh_interval, credentials, webhook_secret, external_base_url and external_base_url_fallback, apply with no data change.

Order at startup​

apply_definitions (crates/sync/src/redefine.rs) runs before any refresh:

  1. Deletes every inventory that the configuration no longer has.
  2. For each inventory, under its writer lock, deletes the records of contributions whose collection hash changed or that the configuration no longer has.
  3. If the resolution hash changed, or a previous rebuild did not finish, stores the status rebuilding and starts the rebuild in a background task. The rebuild holds the writer lock, so refreshes and webhooks for that inventory wait until it ends.
  4. Otherwise, if records were deleted, recomputes the inventory's entities.

While an inventory is rebuilding, its entity, lookup, location and diagnostics routes answer 503 inventory-rebuilding. Other inventories are served as usual.

Branch views left from a previous run are deleted at startup, before this comparison.

Cache layout version​

A third check covers changes to Census itself. The cache stores a layout version. When the build's version differs, ensure_ready deletes every node, and the cache refills from the sources. This replaces data migrations.

Background: research decisions D4 and D20 in specs/008-named-inventory-federation/research.md.