8.2 The Bootstrap Sequence
Startup proceeds in seven phases, and either completes or fails
entirely. The phases group the work by concern rather than fixing its
order: eventd reads the boot ID (step 13) before it opens any store, so
that each shard can be searched for it as it is opened; it opens
eventd-meta.db (step 12) before the shards; and it binds each
ingestion socket as soon as its store is open, so the log socket
(step 18) is bound before metrics.db (step 11) is opened.
8.2.1 Phase 1 — configuration #
- Read every configuration key under
Machine\System\eventd\. The six required keys areEventStorePath,LogStorePath,MetricStorePath,QuerySocketPath,LogSocketPathandMetricSocketPath; a missing or invalid one fails startup.
2. Open and validate the three provisioned store directories without following symbolic links. A missing directory, unsafe component, or descriptor that is not equivalent to the protected platform default fails startup (§3.3). SQLite retains each validated directory handle in database and journal paths. It does not resolve that handle back to the configured pathname. Replacing the original directory path therefore cannot redirect an open store. The service needs no metadata-read grant on private ancestors that its traversal privilege permits it to pass through. 3. Read the optional keys and apply compiled-in defaults for those absent (§A). 4. Arm a persistent watch on the subtree, for runtime changes (§8.3).
8.2.2 Phase 2 — KMES attachment and shard sizing #
- Query the KMES logical slot count with
kmes_attach(KMES_ATTACH_QUERY_SLOTS, …), walk every slot, skipEINVALholes, and assign dense internal ordinals to successful logical CPU IDs (§2.2).
The calls require SeSecurityPrivilege in the effective token.
Discovering no buffers fails startup.
6. Map each per-CPU ring buffer.
7. Resolve the active shard count from StorageShards — the attached
KMES-buffer count when it is 0, the configured value otherwise.
8. Compute the shard-to-CPU assignment (§2.3).
8.2.3 Phase 3 — storage #
- Open or create each active event shard: verify the schema version,
open in WAL mode with
synchronous=FULL, create tables and indexes if new, and quarantine on reported corruption (§3.3).
Discover historical shards matching the naming pattern, and open those with a recognized schema read-only; exclude the rest from the query path.
10. Open or create logs.db in the log store directory — schema
verified, WAL, synchronous=NORMAL, quarantine on corruption
(§4.3).
11. Open or create metrics.db in the metric store directory, likewise
(§5.4).
<a class="citation-anchor" id="cite-bootstrap.metrics-db-is-opened-or-created-in-wal-mode-with-synchronous-normal" href="#cite-bootstrap.metrics-db-is-opened-or-created-in-wal-mode-with-synchronous-normal" data-citation="eventd *bootstrap.metrics-db-is-opened-or-created-in-wal-mode-with-synchronous-normal" title="eventd *bootstrap.metrics-db-is-opened-or-created-in-wal-mode-with-synchronous-normal" aria-label="Citation eventd *bootstrap.metrics-db-is-opened-or-created-in-wal-mode-with-synchronous-normal"><sup></sup></a>
The series cache starts empty and fills on demand.
<a class="citation-anchor" id="cite-bootstrap.the-series-cache-starts-empty" href="#cite-bootstrap.the-series-cache-starts-empty" data-citation="eventd *bootstrap.the-series-cache-starts-empty" title="eventd *bootstrap.the-series-cache-starts-empty" aria-label="Citation eventd *bootstrap.the-series-cache-starts-empty"><sup></sup></a>
- Open or create
eventd-meta.db.
<a class="citation-anchor" id="cite-bootstrap.eventd-meta-db-is-opened-or-created" href="#cite-bootstrap.eventd-meta-db-is-opened-or-created" data-citation="eventd *bootstrap.eventd-meta-db-is-opened-or-created" title="eventd *bootstrap.eventd-meta-db-is-opened-or-created" aria-label="Citation eventd *bootstrap.eventd-meta-db-is-opened-or-created"><sup></sup></a> Load the index counters and desired
set, load the sequence checkpoints for diagnostics only, and
discover each shard's material indexes from its schema (§3.5).
<a class="citation-anchor" id="cite-bootstrap.sequence-checkpoints-are-loaded-for-diagnostics-only" href="#cite-bootstrap.sequence-checkpoints-are-loaded-for-diagnostics-only" data-citation="eventd *bootstrap.sequence-checkpoints-are-loaded-for-diagnostics-only" title="eventd *bootstrap.sequence-checkpoints-are-loaded-for-diagnostics-only" aria-label="Citation eventd *bootstrap.sequence-checkpoints-are-loaded-for-diagnostics-only"><sup></sup></a>
<a class="citation-anchor" id="cite-bootstrap.each-shards-material-indexes-are-discovered-from-its-schema" href="#cite-bootstrap.each-shards-material-indexes-are-discovered-from-its-schema" data-citation="eventd *bootstrap.each-shards-material-indexes-are-discovered-from-its-schema" title="eventd *bootstrap.each-shards-material-indexes-are-discovered-from-its-schema" aria-label="Citation eventd *bootstrap.each-shards-material-indexes-are-discovered-from-its-schema"><sup></sup></a>
8.2.4 Phase 4 — the boot boundary #
- Read
/proc/sys/kernel/random/boot_id, require valid UUID text, and convert it to PCDS GUID layout. An unavailable or malformed value fails startup. - Read and merge every committed
receipt_rangesrow for that boot from every readable active and historical shard, grouped by logical CPU ID (§2.2, §3.1).
<a class="citation-anchor" id="cite-bootstrap.receipt-ranges-for-the-boot-are-merged-from-every-readable-shard-by-cpu" href="#cite-bootstrap.receipt-ranges-for-the-boot-are-merged-from-every-readable-shard-by-cpu" data-citation="eventd *bootstrap.receipt-ranges-for-the-boot-are-merged-from-every-readable-shard-by-cpu" title="eventd *bootstrap.receipt-ranges-for-the-boot-are-merged-from-every-readable-shard-by-cpu" aria-label="Citation eventd *bootstrap.receipt-ranges-for-the-boot-are-merged-from-every-readable-shard-by-cpu"><sup></sup></a>
- Search those shards for any committed row or receipt carrying the boot ID. None means the boot's first successful eventd start; otherwise this is a restart within the boot (§3.7).
<a class="citation-anchor" id="cite-bootstrap.a-boot-id-with-no-committed-row-or-receipt-marks-the-boots-first-start" href="#cite-bootstrap.a-boot-id-with-no-committed-row-or-receipt-marks-the-boots-first-start" data-citation="eventd *bootstrap.a-boot-id-with-no-committed-row-or-receipt-marks-the-boots-first-start" title="eventd *bootstrap.a-boot-id-with-no-committed-row-or-receipt-marks-the-boots-first-start" aria-label="Citation eventd *bootstrap.a-boot-id-with-no-committed-row-or-receipt-marks-the-boots-first-start"><sup></sup></a>
- Initialize each drain's recovery coverage from the merged receipts. It begins at the ring's oldest survivor, skips covered sequences, re-ingests uncovered survivors, and records as gaps only sequences in neither source (§8.5).
<a class="citation-anchor" id="cite-bootstrap.each-drains-recovery-coverage-is-initialised-from-the-merged-receipts" href="#cite-bootstrap.each-drains-recovery-coverage-is-initialised-from-the-merged-receipts" data-citation="eventd *bootstrap.each-drains-recovery-coverage-is-initialised-from-the-merged-receipts" title="eventd *bootstrap.each-drains-recovery-coverage-is-initialised-from-the-merged-receipts" aria-label="Citation eventd *bootstrap.each-drains-recovery-coverage-is-initialised-from-the-merged-receipts"><sup></sup></a>
8.2.5 Phase 5 — sockets #
- Create the query socket at
QuerySocketPath.
<a class="citation-anchor" id="cite-bootstrap.the-query-socket-is-created-at-querysocketpath" href="#cite-bootstrap.the-query-socket-is-created-at-querysocketpath" data-citation="eventd *bootstrap.the-query-socket-is-created-at-querysocketpath" title="eventd *bootstrap.the-query-socket-is-created-at-querysocketpath" aria-label="Citation eventd *bootstrap.the-query-socket-is-created-at-querysocketpath"><sup></sup></a> A stale pathname left
by a crash is unlinked first if it is an `AF_UNIX` socket; if the
path exists and is not a socket, startup fails.
<a class="citation-anchor" id="cite-bootstrap.a-stale-socket-at-a-socket-path-is-unlinked-first" href="#cite-bootstrap.a-stale-socket-at-a-socket-path-is-unlinked-first" data-citation="eventd *bootstrap.a-stale-socket-at-a-socket-path-is-unlinked-first" title="eventd *bootstrap.a-stale-socket-at-a-socket-path-is-unlinked-first" aria-label="Citation eventd *bootstrap.a-stale-socket-at-a-socket-path-is-unlinked-first"><sup></sup></a>
<a class="citation-anchor" id="cite-bootstrap.a-non-socket-at-a-socket-path-fails-startup" href="#cite-bootstrap.a-non-socket-at-a-socket-path-fails-startup" data-citation="eventd *bootstrap.a-non-socket-at-a-socket-path-fails-startup" title="eventd *bootstrap.a-non-socket-at-a-socket-path-fails-startup" aria-label="Citation eventd *bootstrap.a-non-socket-at-a-socket-path-fails-startup"><sup></sup></a> Its
inherited descriptor is replaced with the protected one that lets
every authenticated caller connect (§7.1).
<a class="citation-anchor" id="cite-bootstrap.the-query-socket-gets-the-authenticated-users-descriptor" href="#cite-bootstrap.the-query-socket-gets-the-authenticated-users-descriptor" data-citation="eventd *bootstrap.the-query-socket-gets-the-authenticated-users-descriptor" title="eventd *bootstrap.the-query-socket-gets-the-authenticated-users-descriptor" aria-label="Citation eventd *bootstrap.the-query-socket-gets-the-authenticated-users-descriptor"><sup></sup></a>
- Create the log socket at
LogSocketPath, then replace its inherited DACL with the protected deny-Service, allow-SYSTEM broker DACL, leaving it owned by eventd's service SID (§7.6).
<a class="citation-anchor" id="cite-bootstrap.the-log-socket-gets-the-deny-service-allow-system-broker-descriptor" href="#cite-bootstrap.the-log-socket-gets-the-deny-service-allow-system-broker-descriptor" data-citation="eventd *bootstrap.the-log-socket-gets-the-deny-service-allow-system-broker-descriptor" title="eventd *bootstrap.the-log-socket-gets-the-deny-service-allow-system-broker-descriptor" aria-label="Citation eventd *bootstrap.the-log-socket-gets-the-deny-service-allow-system-broker-descriptor"><sup></sup></a>
- Create the metric socket at
MetricSocketPath, then replace its inherited descriptor with the protected one that lets every authenticated caller send (§7.6). - Establish and verify the Security Descriptor on all three, before any of them accepts or receives anything (§7.6).
<a class="citation-anchor" id="cite-bootstrap.socket-descriptors-are-verified-before-any-socket-accepts-or-receives" href="#cite-bootstrap.socket-descriptors-are-verified-before-any-socket-accepts-or-receives" data-citation="eventd *bootstrap.socket-descriptors-are-verified-before-any-socket-accepts-or-receives" title="eventd *bootstrap.socket-descriptors-are-verified-before-any-socket-accepts-or-receives" aria-label="Citation eventd *bootstrap.socket-descriptors-are-verified-before-any-socket-accepts-or-receives"><sup></sup></a>
The stale-socket rule distinguishes the two cases deliberately. Unlinking a leftover socket is recovery from eventd's own crash; unlinking a regular file at a configured path would be destroying something that is not eventd's, and a path pointing at the wrong thing is a configuration error worth failing on.
Recognizing a leftover socket needs no right on it. If an operator has narrowed its descriptor so that eventd cannot delete it, eventd, which still owns it, first puts its own descriptor back, so a narrowed socket never stops the next start.
8.2.6 Phase 6 — threads #
- One writer thread per active shard.
- One drain thread per attached logical CPU, each beginning to reconcile and read its ring buffer.
- The log ingestion thread.
- The metric ingestion thread.
- The retention coordinator thread.
- The adaptive indexing policy thread.
8.2.7 Phase 7 — ready #
- Write and commit an
eventd.daemon.startedevent in the boot recording whether this start is a restart, the shard count and the per-CPU recovered coverage points (§3.2).
<a class="citation-anchor" id="cite-bootstrap.an-eventd-daemon-started-event-records-restart-shard-count-and-per-cpu-coverage" href="#cite-bootstrap.an-eventd-daemon-started-event-records-restart-shard-count-and-per-cpu-coverage" data-citation="eventd *bootstrap.an-eventd-daemon-started-event-records-restart-shard-count-and-per-cpu-coverage" title="eventd *bootstrap.an-eventd-daemon-started-event-records-restart-shard-count-and-per-cpu-coverage" aria-label="Citation eventd *bootstrap.an-eventd-daemon-started-event-records-restart-shard-count-and-per-cpu-coverage"><sup></sup></a>
The commit
happens before readiness is signaled.
<a class="citation-anchor" id="cite-bootstrap.the-startup-event-is-committed-before-readiness-is-signalled" href="#cite-bootstrap.the-startup-event-is-committed-before-readiness-is-signalled" data-citation="eventd *bootstrap.the-startup-event-is-committed-before-readiness-is-signalled" title="eventd *bootstrap.the-startup-event-is-committed-before-readiness-is-signalled" aria-label="Citation eventd *bootstrap.the-startup-event-is-committed-before-readiness-is-signalled"><sup></sup></a>
- Signal readiness to peinit.
<a class="citation-anchor" id="cite-bootstrap.readiness-is-signalled-to-peinit-last" href="#cite-bootstrap.readiness-is-signalled-to-peinit-last" data-citation="eventd *bootstrap.readiness-is-signalled-to-peinit-last" title="eventd *bootstrap.readiness-is-signalled-to-peinit-last" aria-label="Citation eventd *bootstrap.readiness-is-signalled-to-peinit-last"><sup></sup></a>
Committing before signaling is what makes the startup record trustworthy. A readiness signal sent before the commit could be followed by a crash that loses the record, leaving a boot in which eventd demonstrably ran and left no trace of having started.
8.2.8 Failure #
If any phase fails, eventd does not signal readiness.
It logs the failure to standard error where standard error exists, and exits non-zero. peinit's restart policy decides what happens next.
Partial startup is not permitted. There is no degraded mode in which eventd runs without one of its three stores, or without KMES. It either completes the sequence or fails.
The all-or-nothing rule is a simplification. A later revision might allow log and metric ingestion to proceed with KMES unavailable, but that means partial-failure state to manage in every subsequent path — what a query against a store that was never opened does, what happens when the missing subsystem returns — and the failure mode it protects against is one peinit already handles by restarting.
8.2.9 Failed socket setup #
Each newly bound socket pathname has a cleanup guard before later setup steps run. If socket security or another required setup step fails, the guard removes that pathname as the socket closes. A failed start therefore does not leave its own bound socket pathname behind.