Files
harmony/.sqlx
Sylvain Tremblay feadb088c8
All checks were successful
Run Check Script / check (pull_request) Successful in 2m15s
fix(inventory): order physical_hosts by rowid, not version_id
`physical_hosts.version_id` is `Id::default().to_string()`, which
formats `{masked_hex_timestamp}_{rand7}`. Two problems for using that
as a "latest row" key:

  1. `format!("{:x}", v)` is variable-length. When the masked 24-bit
     clock crosses a hex-width boundary (every few days at most, ±18h
     or 12 days from cycle start), lexicographic comparison breaks:
     `'_'` (0x5F) > any digit, so "1234_…" sorts HIGHER than
     "123456_…" even though the latter was saved later.
  2. The timestamp is masked to 24 bits, wrapping every ~194 days.

Net effect: `MAX(version_id)` in get_all_hosts / get_latest_by_id /
save's dedupe lookup can return an OLD row instead of the most
recently inserted one — exactly the "stale IP in the Select" the user
reported after re-adding a previously-deleted node.

Fix: order by SQLite's implicit `rowid` instead — strictly monotonic
INSERT counter, always reflects real save order. physical_hosts is
not WITHOUT ROWID, so rowid is always there. The version_id column
stays on every row (useful in the UI / audit logs) but no longer
drives ranking.

Id::default() is untouched; it's used throughout the codebase and
fixing the format is a separate, wider change.

sqlx offline cache regenerated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 15:51:11 -04:00
..