Latest state#
Small tables kept current on every insert so the checks never scan the audit store: each node’s newest record, and each boot’s first tamper total and when its newest record came first.
Schema: tools/backend/sql/30-latest.sql
Views, functions and jobs#
shirudo.keepalive_latest_mvmaterialized view, on insert.
checked → keepalive_latest for accepted rows.
shirudo.boot_first_mvmaterialized view, on insert.
checked → boot_first, aggregating per (ak_name, boot_id).
shirudo.boot_first_keep_mvrefreshable MV, every 1 hour, APPEND.
Rewrites the baseline of every node’s current boot with last_used = now(), so the TTL only removes boots a node has left.
shirudo.keepalive_latest#
The newest record of each node by the TPM’s own counters. A late record never replaces a newer one; the newest one received again replaces itself, with the time of the copy.
Read with FINAL.
Same columns as keepalive, minus quote, plus order_key.
- Engine:
ReplacingMergeTree(order_key)- Order by:
ak_name- Defined in:
tools/backend/sql/30-latest.sql- Written by:
keepalive_latest_mvon insert intochecked- Fires on insert:
nothing
- Queried by:
boot_first_keep_mvintoboot_first;latest(view);node_label_items(view);history_conflicts(view);node_ops_mvintonode_ops- Row size:
~1.5 KB per node (estimate: body plus its parsed columns; one row per node, so little cross-row compression).
- Scale:
Nodes after a merge. Before one, up to one row per record received since the last merge.
- Reference fleet:
≈ 15 MB
Columns (30)
Column |
Type |
Meaning |
|---|---|---|
|
|
Node identity; the sort key. |
|
|
reset_count << 40 | clock. Highest wins. |
|
|
When the backend received the record, or a copy of it. Retention counts from it. Freshness (check 2) does not: it reads newest_received of boot_first. |
|
|
The OTLP Timestamp the target put on the log record. Not trusted for ordering. |
|
|
host.name resource attribute: what the node claims to be called. Not an identity. |
|
|
The newest record’s signed body. |
|
|
TPM reset counter of the newest record. |
|
|
TPM clock of the newest record. |
|
|
Body schema. Must be shirudo.keepalive/1 or 1.x, else the record is rejected as schema. |
|
|
Identifies the boot that sent the record. Tamper baselines in boot_first are per boot. |
|
|
Build identifier of the shirudo binary: SHA-256 over its git commit (with -dirty), config.mk and Makefile.shirudo. Printed by shirudo version –version-id. Check 3 requires it to be in expected_builds. |
|
|
Digest of the node’s configuration. One of the keys that groups peers for check 7. |
|
|
Running kernel, e.g. 7.4.2. Groups peers (check 7) and is matched against kernel_vulns via kver(). |
|
|
OS image the node says it booted. Joins to sbom_images. |
|
|
Version of that image. |
|
|
Verity root of the image. When it matches the SBOM’s root the binding is verified. |
|
|
The node’s own overall verdict. Check 3 requires ok. |
|
|
Condition pairs, two bits each. Check 3 requires the low seven pairs to read 0x1555 (all OK). |
|
|
Bits 0–3 are faults and fail check 3 (bit 2: outcomes file damaged, bit 3: tamper counters unreadable). Bit 4: sync in progress. Bit 5: snapshot unsettled. |
|
|
Tamper counters. Their sum must not rise within a boot (check 3). Empty when unreadable. |
|
|
The upatch tree the node follows. NULL means no tree, and checks 4–7 are skipped. |
|
|
Publication generation of the tree the node has seen. |
|
|
The record’s window starts after this operation seq (exclusive). |
|
|
Last operation the node has applied (inclusive end of the window). |
|
|
Hash-chain root at base_seq, 64 hex digits. |
|
|
Hash-chain root after last_seq. Check 4 refolds the tree to reproduce it. |
|
|
Base64, two bits per operation in the window: 1 applied, 2 selector did not match, 3 attach module not loaded, 0 not reached. Decoded by mask_code(). |
|
|
Hash of the upatch set the node has loaded. Check 6 recomputes it. |
|
|
Number of upatches loaded. Shown as loaded in node_status. |
|
|
Reported by the node and stored. No check reads it. |
shirudo.boot_first#
Per node and boot, the tamper total of the first record that could read the counters. Check 3 fails if the current total is higher.
A record with empty tamper does not set the baseline (argMinStateIf … notEmpty(tamper)).
A TTL drops a row from its part regardless of newer parts. Without the hourly rewrite, a boot longer than the retention would lose its oldest row and its baseline would move later, hiding a rise. docs/boot-baselines.md explains it.
- Engine:
AggregatingMergeTree- Order by:
(ak_name, boot_id)- TTL:
last_used + INTERVAL 2592000 SECOND. The default ofboot_first_retention_secondsinsettings, set bytools/backend/sql/apply-retention.sh- Defined in:
tools/backend/sql/30-latest.sql- Written by:
boot_first_mvon insert intochecked;boot_first_keep_mv(refresh every 1 hour, append)- Fires on insert:
nothing
- Queried by:
boot_first_keep_mvintoboot_first;node_status_mvintonode_status- Row size:
~150 B (estimate).
- Scale:
Nodes × boots with a record in the last 30 days, plus each node’s current boot, which is kept indefinitely.
- Reference fleet:
~3 boots each: 30k rows ≈ 5 MB
Columns (6)
Column |
Type |
Meaning |
|---|---|---|
|
|
Node. |
|
|
Boot. |
|
|
order_key of the boot’s first record. |
|
|
arraySum(tamper) at the lowest order_key with readable counters. Read with argMinMerge. |
|
|
When the boot’s record with the highest order_key was first received. Check 2 reads the age of a node’s newest record here, so that a copy of it sent again does not make it fresh. Read with argMaxMerge. |
|
|
Last record received for the boot, or last time the hourly job found it to be the node’s current boot. |