Asset merge
Host Agent data enriches or creates Assets in the tenant/site scope. Implemented in ingestor/internal/domain/hostinventory/asset_merge.go (HostMergeService) — in the Ingestor repo, not Backend — called after a host_inventory snapshot is persisted. Ingestor writes directly to assets/asset_network_interfaces/asset_merge_review_queue in the same Azure SQL database Backend uses; Backend still owns those tables’ schema (migrations) and reads them for its own Assets UI, it just isn’t the one writing agent-merge data into them.
- For each snapshot, match
network_interfaces[].macagainstasset_network_interfacesfor existing Assets in the same tenant + site as the host agent. - Single match → update Asset fields:
has_agent: true,agent_host_id,agent_last_seen_at,agent_version. - No match → create a new Asset with
source: host_agent, using a defaultdevice_type(code = 'server') and the OS name as the asset name. - Multi-NIC conflict (MACs map to more than one existing Asset) → written to
asset_merge_review_queue— no silent merge.
Asset merge failures are logged but don’t fail the ingest request — a snapshot is still stored/acknowledged even if the merge step errors.
Sequence
Section titled “Sequence”sequenceDiagram
participant Host as Host Agent / Edge proxy
participant Ing as Ingestor
participant DB as Azure SQL
Host->>Ing: POST /v1/ingest (kind: host_inventory)
Ing->>DB: Store blob + upsert host_inventory_snapshots
Ing->>DB: Lookup asset_network_interfaces by MAC + tenant + site
alt Single match
Ing->>DB: UPDATE assets SET has_agent=1, agent_host_id, ...
else No match
Ing->>DB: INSERT assets (source='host_agent') + asset_network_interfaces
else Multi match
Ing->>DB: INSERT asset_merge_review_queue
end
Known gaps
Section titled “Known gaps”- The pre-existing single
assets.mac_addresscolumn and the newasset_network_interfacestable are not kept in sync — regular (non-host-agent) asset create/edit flows don’t populateasset_network_interfaces, so only host-agent-created/merged assets have it populated today. - No dedicated UI yet for reviewing
asset_merge_review_queueentries — check the table directly.
| Symptom | Check |
|---|---|
| Duplicate assets | Multi-NIC conflict — check asset_merge_review_queue |
| Asset not updating | Host’s site vs. Asset’s site mismatch (enrollment secret was generated for a different site) |
| New asset has wrong device type | Merge always defaults to device_types.code = 'server' — edit manually if wrong |