@soleur/opencode 3.390.2 → 3.390.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -434,4 +434,52 @@ export const MANIFEST: ManifestEntry[] = [
434
434
  exempt_reason:
435
435
  "archive-reading repo-side feeder (scheduled-deadman-heartbeat-feeder.yml, hourly): it queries the Better Stack Logs archive for Inngest cron cost markers and beats only when one exists in the last 24 h, so the signal is independent of any single host and no host replace applies. Not dedicated-host-boot, so ADR-103's replace_target requirement correctly does not fire.",
436
436
  },
437
+ {
438
+ name: "host_kernel_web_1",
439
+ // #12007 - the per-host dead-man for the periodic SOLEUR_HOST_KERNEL marker (web-1). Fed by
440
+ // scripts/deadman-heartbeat-feeder.sh (target host-kernel-web-1, literal 36 h window) once the owner
441
+ // arms it; born paused. The feeder is NOT a workflow loop member yet (CTO ruling H1), so this row declares
442
+ // `none` and names the issue that owns the rollout and the arming change, which flips it to the cron form.
443
+ arming: "external-probe",
444
+ paused: true,
445
+ feeder: { kind: "none", url_secret: null, tracking_issue: 12386 },
446
+ exempt_reason:
447
+ "archive-reading repo-side feeder (scripts/deadman-heartbeat-feeder.sh target host-kernel-web-1): it queries the Better Stack Logs archive for this host's own SOLEUR_HOST_KERNEL row and beats only when one exists inside the 36 h window, so no host change and no host replace applies to the heartbeat itself (the emitter's delivery is a separate held step, #12386). Not dedicated-host-boot, so ADR-103's replace_target requirement correctly does not fire.",
448
+ },
449
+ {
450
+ name: "host_kernel_web_2",
451
+ // #12007 - the per-host dead-man for the periodic SOLEUR_HOST_KERNEL marker (web-2). Fed by
452
+ // scripts/deadman-heartbeat-feeder.sh (target host-kernel-web-2, literal 36 h window) once the owner
453
+ // arms it; born paused. The feeder is NOT a workflow loop member yet (CTO ruling H1), so this row declares
454
+ // `none` and names the issue that owns the rollout and the arming change, which flips it to the cron form.
455
+ arming: "external-probe",
456
+ paused: true,
457
+ feeder: { kind: "none", url_secret: null, tracking_issue: 12386 },
458
+ exempt_reason:
459
+ "archive-reading repo-side feeder (scripts/deadman-heartbeat-feeder.sh target host-kernel-web-2): it queries the Better Stack Logs archive for this host's own SOLEUR_HOST_KERNEL row and beats only when one exists inside the 36 h window, so no host change and no host replace applies to the heartbeat itself (the emitter's delivery is a separate held step, #12386). Not dedicated-host-boot, so ADR-103's replace_target requirement correctly does not fire.",
460
+ },
461
+ {
462
+ name: "host_kernel_inngest",
463
+ // #12007 - the per-host dead-man for the periodic SOLEUR_HOST_KERNEL marker (inngest). Fed by
464
+ // scripts/deadman-heartbeat-feeder.sh (target host-kernel-inngest, literal 36 h window) once the owner
465
+ // arms it; born paused. The feeder is NOT a workflow loop member yet (CTO ruling H1), so this row declares
466
+ // `none` and names the issue that owns the rollout and the arming change, which flips it to the cron form.
467
+ arming: "external-probe",
468
+ paused: true,
469
+ feeder: { kind: "none", url_secret: null, tracking_issue: 12386 },
470
+ exempt_reason:
471
+ "archive-reading repo-side feeder (scripts/deadman-heartbeat-feeder.sh target host-kernel-inngest): it queries the Better Stack Logs archive for this host's own SOLEUR_HOST_KERNEL row and beats only when one exists inside the 36 h window, so no host change and no host replace applies to the heartbeat itself (the emitter's delivery is a separate held step, #12386). Not dedicated-host-boot, so ADR-103's replace_target requirement correctly does not fire.",
472
+ },
473
+ {
474
+ name: "host_kernel_registry",
475
+ // #12007 - the per-host dead-man for the periodic SOLEUR_HOST_KERNEL marker (registry). Fed by
476
+ // scripts/deadman-heartbeat-feeder.sh (target host-kernel-registry, literal 36 h window) once the owner
477
+ // arms it; born paused. The feeder is NOT a workflow loop member yet (CTO ruling H1), so this row declares
478
+ // `none` and names the issue that owns the rollout and the arming change, which flips it to the cron form.
479
+ arming: "external-probe",
480
+ paused: true,
481
+ feeder: { kind: "none", url_secret: null, tracking_issue: 12386 },
482
+ exempt_reason:
483
+ "archive-reading repo-side feeder (scripts/deadman-heartbeat-feeder.sh target host-kernel-registry): it queries the Better Stack Logs archive for this host's own SOLEUR_HOST_KERNEL row and beats only when one exists inside the 36 h window, so no host change and no host replace applies to the heartbeat itself (the emitter's delivery is a separate held step, #12386). Not dedicated-host-boot, so ADR-103's replace_target requirement correctly does not fire.",
484
+ },
437
485
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleur/opencode",
3
- "version": "3.390.2",
3
+ "version": "3.390.3",
4
4
  "description": "Soleur AI organization plugin for OpenCode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -55,7 +55,7 @@ HOST_STATE="${CLAUDE_PLUGIN_ROOT}/skills/cve-exposure/scripts/host-state.sh"
55
55
  doppler run -p soleur -c prd_terraform -- "$HOST_STATE" image-findings <CVE-ID> <GHSA-ALIAS-IF-ANY>
56
56
  ```
57
57
 
58
- The helper ([host-state.sh](./scripts/host-state.sh)) prints one line per host role and ends with a `SOLEUR_CVE_HOST_STATE hosts=...` verdict line (image mode ends with `SOLEUR_CVE_HOST_STATE mode=image-findings ...`). A missing verdict line or any non-zero exit makes every host `unknown`; the stderr `degraded reason=<token>` line names the cause, and the exit code selects the remedy: 2 source dark, 3 credentials, 4 transport, parse or unverified reader, 64 bad arguments, 78 refused under tracing. Still run Steps 4-6. `marker_state=fresh` means log liveness only, never a kernel observation. The marker gap (most hosts report no kernel today; #12007 adds one) is named in the output as the cause, and no issue or comment is filed on it.
58
+ The helper ([host-state.sh](./scripts/host-state.sh)) prints one line per host role and ends with a `SOLEUR_CVE_HOST_STATE hosts=...` verdict line (image mode ends with `SOLEUR_CVE_HOST_STATE mode=image-findings ...`). A missing verdict line or any non-zero exit makes every host `unknown`; the stderr `degraded reason=<token>` line names the cause, and the exit code selects the remedy: 2 source dark, 3 credentials, 4 transport, parse or unverified reader, 64 bad arguments, 78 refused under tracing. Still run Steps 4-6. `marker_state=fresh` means log liveness only, never a kernel observation. `kernel_state` has three values: `observed` (the newest valid periodic kernel report for the host is at most 48 hours old, attributed by the host's transport identity), `stale` (a kernel and its age are visible but come from an older periodic report, from behind a newest report whose kernel was unreadable, or only from a failed-deploy diagnostic) and `unknown` (no valid kernel report). The cause differs per state, so name it: `unknown` or `silent` with no prior report means the periodic emitter has not reached that host yet (rollout pending, operator-reserved, tracked in #12386); the registry is expected to read `unknown` until the held registry emitter PR (#12386) merges. For `stale`: behind an unreadable newest report means the host reports but its kernel cannot be read; from a failed-deploy diagnostic row means no valid periodic kernel has been seen yet; from an older periodic row means the host went quiet, so read the `Querying SOLEUR_HOST_KERNEL` section of `knowledge-base/engineering/operations/runbooks/betterstack-log-query.md` and check the host's dead-man heartbeat. No issue or comment is filed on any of these.
59
59
 
60
60
  ## Step 4: Reachability
61
61
 
@@ -63,12 +63,12 @@ In this order: the Terraform firewall rules per host including protocol (ICMP to
63
63
 
64
64
  ## Step 5: Distro tracker
65
65
 
66
- Ubuntu `noble` JSON for host rows, the Debian tracker for runtime-image package rows ([component-map.md](./references/component-map.md) has the status mapping). Kernel comparison: the running kernel must share the fixed version's `major.minor.patch` and come from the same source package, else `unknown`; then compare the ABI number only. Running ABI below the fixed ABI is `yes`; equal is `unknown` (the build suffix is unobservable); above the fixed ABI is `unknown` with `observed-stale` when the kernel comes from the failed-deploy diagnostic (the only kernel source today), because `no` with `observed-fresh` is reachable only from a periodic, non-failed-deploy report at most 48 hours old, which no marker supplies yet (#12007 will). Print the caveat that a kernel fixed on disk but not booted is not fixed. An unmapped status, a missing `noble` row, or disagreement is `unknown` or the worse outcome. An image-findings `match=yes` is a finding; `match=unknown` is never `no`. Runtime and image-package rows: `no` also needs evidence that the digest the hosts RUN equals the pinned or scanned one; no helper reads the deployed digest, so these rows are `unknown` ("declared, deployment not observed") unless the operator supplies it. Pick the Debian release for image rows from the scan marker's distro or the Dockerfile `FROM` tag.
66
+ Ubuntu `noble` JSON for host rows, the Debian tracker for runtime-image package rows ([component-map.md](./references/component-map.md) has the status mapping). Kernel comparison: the running kernel must share the fixed version's `major.minor.patch` and come from the same source package, else `unknown`; then compare the ABI number only. Running ABI below the fixed ABI is `yes`; equal is `unknown` (the build suffix is unobservable); above the fixed ABI is `no` with `observed-fresh` only when the helper printed `kernel_state=observed` (a periodic report at most 48 hours old), and `unknown` with `observed-stale` when it printed `stale` (an older periodic report or a failed-deploy diagnostic): `stale` never grounds `no`. Print the caveat that a kernel fixed on disk but not booted is not fixed. An unmapped status, a missing `noble` row, or disagreement is `unknown` or the worse outcome. An image-findings `match=yes` is a finding; `match=unknown` is never `no`. Runtime and image-package rows: `no` also needs evidence that the digest the hosts RUN equals the pinned or scanned one; no helper reads the deployed digest, so these rows are `unknown` ("declared, deployment not observed") unless the operator supplies it. Pick the Debian release for image rows from the scan marker's distro or the Dockerfile `FROM` tag.
67
67
 
68
68
  ## Step 6: Output
69
69
 
70
- 1. Bottom line first: `cannot confirm: N of M components unknown`, per CVE id, where M is the number of components in that id's table section and N counts every component whose `Affected` is `unknown` (a host-os component whose kernel is not an observed periodic value is unknown whatever its `marker_state`; the helper's own `fresh=`/`unknown=` counts are marker states and are never N), the blockers, and one non-SSH next action per unknown (for example "ship #12007" or "the next web deploy refreshes the canary"). Label the whole output advisory.
71
- 2. The exposure table, session only, with the schema and rules in [disclosure-and-verdicts.md](./references/disclosure-and-verdicts.md). `Affected` and `Reachable` are `yes`/`no`/`unknown`; a silent, stale, unshipping or unmapped host is `unknown`; the overall verdict is worst-case per id and treats unknown `Reachable` as reachable. Never print "fresh" for a host without "kernel unknown" beside it when the kernel was not observed.
70
+ 1. Bottom line first: `cannot confirm: N of M components unknown`, per CVE id, where M is the number of components in that id's table section and N counts every component whose `Affected` is `unknown` (so, for host-os components, the hosts whose `kernel_state` is not `observed`, whatever their `marker_state`; the helper's own `fresh=`/`unknown=` counts are marker states and are never N), the blockers, and one non-SSH next action per unknown. For a host the emitter has not reached, the next action is to ask the operator to authorize the held rollout (#12386); this skill never applies, replaces or re-provisions a host. The read-only follow-up is to run the query in the runbook's `Querying SOLEUR_HOST_KERNEL` section and check the host's dead-man heartbeat; otherwise wait for the next report. Label the whole output advisory.
71
+ 2. The exposure table, session only, with the schema and rules in [disclosure-and-verdicts.md](./references/disclosure-and-verdicts.md). `Affected` and `Reachable` are `yes`/`no`/`unknown`; a silent, stale, unshipping or unmapped host is `unknown`; the overall verdict is worst-case per id and treats unknown `Reachable` as reachable. Never print "fresh" for a host without its `kernel_state` (`unknown` or `stale`) beside it when the kernel was not observed.
72
72
  3. Ask once whether there is any anomaly report. Map the answer to `--exploitation`: nothing reported and nothing observed is `none-found`; not asked, unsure, or the CVE is KEV-listed or known to be exploited with no evidence on Soleur's own hosts is `unknown` (draft only); any evidence of exploitation on Soleur's hosts is `present` (exit 5, nothing filed, breach-triage hand-off). State CISA KEV or exploitation in the wild as an urgency input, never as breach evidence. A question about whether a CVE is being exploited against Soleur is not this skill's: it routes to `legal-threshold`.
73
73
  4. Gap issues exist only through [file-gap-issue.sh](./scripts/file-gap-issue.sh), draft by default; it is the only place that composes public issue text. Offer one only when an id's overall `Affected` is `unknown` and the operator wants a public placeholder; never file one automatically, and run once per class. Print a draft:
74
74
 
@@ -30,14 +30,16 @@ No IaC pins a kernel: a mutable host's running kernel is known only from telemet
30
30
 
31
31
  | Role | Marker the helper reads | Gives | Does not give |
32
32
  |---|---|---|---|
33
- | web-1, web-2 | failed-deploy kernel diagnostic (`SOLEUR_CANARY_SANDBOX_DIAG`, section kernel) | a kernel string at the time of a failed deploy | anything on a healthy day: it is emitted by failure paths only |
33
+ | web-1, web-2, inngest | periodic kernel report (`SOLEUR_HOST_KERNEL v=1`, journald; identity is the shipper-stamped host name plus the fixed log identifier, the message role is only a cross-check) | running kernel, uptime; `observed` only when at most 48 hours old | anything about a host that has not been rolled out yet |
34
+ | registry | periodic kernel report (`SOLEUR_HOST_KERNEL v=1`, posted directly; identity is `role=registry` plus the registry `host=` field) | running kernel, uptime; `observed` only when at most 48 hours old | anything about a host that has not been rolled out yet; the registry emitter is held for a separate owner-approved PR (#12386), so expect `unknown` until it merges |
35
+ | web-1, web-2 | failed-deploy kernel diagnostic (`SOLEUR_CANARY_SANDBOX_DIAG`, section kernel) | a kernel string at the time of a failed deploy, shown as `stale` | anything on a healthy day: it is emitted by failure paths only, and never `observed` |
34
36
  | web-1 | inngest server probe (`host_role=web`) | uptime | kernel |
35
37
  | inngest | inngest server probe (`host_role=dedicated`) | uptime | kernel |
36
38
  | registry | `SOLEUR_PRIVATE_NIC` (uptime), `SOLEUR_ZOT_DISK` (`host=`) | uptime | kernel |
37
39
  | git-data | separate Better Stack source, not read | nothing | everything: always `unknown` |
38
40
  | grok-dogfood | none | host shipping logs only | kernel, uptime |
39
41
 
40
- A host that ships logs but carries no marker is `silent`. Kernel state is always labelled separately from marker state: a fresh uptime row never makes the kernel `observed-fresh`. A diagnostic row from a failed deploy is `observed-stale` evidence at best, so `Affected=no` on a mutable host cannot rest on it. The producer-contract block of [host-state.test.sh](../test/host-state.test.sh) fails in the PR that renames any of these markers.
42
+ A host that ships logs but carries no marker is `silent`. Kernel state is always labelled separately from marker state: a fresh uptime row never makes the kernel `observed-fresh`. The helper's `kernel_state` is `observed` (a valid periodic report at most 48 hours old), `stale` (an older periodic report, a report behind an unreadable newest periodic report, or only a failed-deploy diagnostic: kernel and age visible, `observed-stale` evidence at best) or `unknown`. `Affected=no` on a mutable host rests only on `observed`, never on `stale`. git-data and grok-dogfood have no periodic report and stay `unknown`. How to read these rows with the log query tooling is in the `Querying SOLEUR_HOST_KERNEL` section of [betterstack-log-query.md](../../../../../knowledge-base/engineering/operations/runbooks/betterstack-log-query.md). The producer-contract block of [host-state.test.sh](../test/host-state.test.sh) fails in the PR that renames any of these markers.
41
43
 
42
44
  ## Ubuntu status mapping (built from captured real responses)
43
45
 
@@ -14,13 +14,13 @@
14
14
  ## Rules
15
15
 
16
16
  - `Affected=no` on a mutable host requires `observed-fresh`. `declared-only` supports `no` only for immutable, digest-pinned artifacts.
17
- - A failed-deploy kernel row can never ground `Affected=no`: it is `observed-stale` at best (the helper reports its age as `kernel_age_hours`, up to 7 days), so it can support `yes` or `unknown` only. `no` on a mutable host needs a periodic, non-failed-deploy report at most 48 hours old, which no marker supplies today (#12007 will).
18
- - `marker_state=fresh` means a periodic log row exists; it says nothing about the kernel. Never print "fresh" for a host without "kernel unknown" beside it when the kernel was not observed.
17
+ - A failed-deploy kernel row can never ground `Affected=no`: it is `observed-stale` at best (the helper reports its age as `kernel_age_hours`, up to 7 days), so it can support `yes` or `unknown` only. `no` on a mutable host needs a periodic report at most 48 hours old (`kernel_state=observed`); `stale` (an older periodic report, a report behind an unreadable newest periodic report, or a failed-deploy row) never grounds `no`.
18
+ - `marker_state=fresh` means a periodic log row exists; it says nothing about the kernel. Never print "fresh" for a host without its `kernel_state` beside it when the kernel was not observed.
19
19
  - A silent, stale, no-marker, query-error, unshipping, unmapped or unread host is `unknown`, and so is a host whose kernel was not observed from a periodic report, whatever its `marker_state`.
20
20
  - Runtime and image-package rows: `Affected=no` also needs evidence that the digest the hosts run equals the pinned or scanned one. No helper reads the deployed digest, so these rows are `unknown` (declared, deployment not observed) unless the operator supplies it.
21
21
  - The overall verdict is worst-case per id and treats an `unknown` Reachable as reachable.
22
22
  - Evidence-state is granted per field: a fresh uptime row never makes the kernel `observed-fresh`.
23
- - The bottom line comes first, per CVE id: `cannot confirm: N of M components unknown`, where M is the number of components in that id's table section and N is every component whose `Affected` is `unknown`; the blockers; one non-SSH next action per unknown. The helper's `fresh=`/`unknown=` verdict counts are marker states and are never N.
23
+ - The bottom line comes first, per CVE id: `cannot confirm: N of M components unknown`, where M is the number of components in that id's table section and N is every component whose `Affected` is `unknown` (for host-os components, the hosts whose `kernel_state` is not `observed`); the blockers; one non-SSH next action per unknown. The helper's `fresh=`/`unknown=` verdict counts are marker states and are never N.
24
24
  - Output vocabulary is "unknown" and "no exposure found in the sources read, dated". Never a green "safe" framing or a one-line all-clear verdict.
25
25
 
26
26
  ## What may be written down
@@ -40,10 +40,29 @@
40
40
  # stale only an older periodic row, or only a failed-deploy kernel diag row, exists
41
41
  # silent the host ships logs (the global positive control saw it) but no marker row exists
42
42
  # unknown not observable: source not read, host not seen, or the read failed
43
- # kernel_state observed only when a decoded SOLEUR_CANARY_SANDBOX_DIAG section=kernel row inside the
44
- # 7-day window carries a kernel matching the anchored kernel shape; that row is emitted
45
- # by FAILED deploys only, so its age is reported separately in kernel_age_hours and is
46
- # never treated as a periodic report.
43
+ # kernel_state observed only when the NEWEST periodic SOLEUR_HOST_KERNEL v=1 row attributed to the host
44
+ # (see the identity rules below) carries a kernel matching the anchored kernel shape and is
45
+ # at most 48 hours old (FRESH_HOURS). A newest periodic row with an unreadable kernel caps the
46
+ # state at stale; it never grounds no. (An unreadable row wins a same-second tie with a valid
47
+ # one.) With an older valid row the stale state shows that row's kernel and age; with none the
48
+ # state falls to the failed-deploy row, then unknown. Only `observed` may ground a `no` answer.
49
+ # stale the kernel and its age are visible but never ground a `no`: an older periodic row
50
+ # (inside the 7-day window), or only a failed-deploy SOLEUR_CANARY_SANDBOX_DIAG
51
+ # section=kernel row (emitted by FAILED deploys only; never a periodic report).
52
+ # Precedence: fresh periodic, then the newest older periodic, then the failed-deploy row.
53
+ # unknown no valid kernel row for the host.
54
+ # Identity of a SOLEUR_HOST_KERNEL row (the message is self-declared and forgeable, so identity comes from the transport):
55
+ # journald hosts (web-1, web-2, inngest) Vector-stamped host_name from ROLE_TABLE + the exact
56
+ # SYSLOG_IDENTIFIER host-kernel-marker AND _SYSTEMD_UNIT host-kernel-marker.service; the
57
+ # message role= (web|inngest) is only a cross-check, and a journald-path row whose message
58
+ # contains the substring `host=` anywhere (empty value, after a newline or tab included) is rejected.
59
+ # registry no host_name and no SYSLOG_IDENTIFIER; role=registry AND host=REGISTRY_HOST_ID in the message
60
+ # (the identity the SOLEUR_ZOT_DISK rows carry), and the message contains exactly one `host=`
61
+ # substring (a second `host=` anywhere makes the row unmapped, whichever value comes first).
62
+ # A row that fails its rule is attributed to `unmapped`, never to a role; a version other than v=1, or no
63
+ # version, is ignored. A row dated up to 5 minutes ahead (now + 300 s) clamps to age 0; one further ahead is dropped.
64
+ # RESIDUAL (documented, accepted): freshness is measured on Better Stack ingestion time (dt), not on a producer
65
+ # timestamp; the line carries no ts= field. A host whose rows are delayed in transit therefore reads fresher than it is.
47
66
  set -uo pipefail
48
67
 
49
68
  case "$-" in
@@ -129,12 +148,18 @@ classify_host() { # $1 = role. Reads $FACTS (jq-validated), re-validates, prints
129
148
  (.age_hours // "unknown"|tostring), (.kernel // "unknown"), (.uptime_s // "unknown"|tostring),
130
149
  (.kernel_age_hours // "unknown"|tostring), (.source_marker // "none")] | @tsv' "$FACTS" 2>/dev/null); then :; fi
131
150
  case "$ms" in fresh|stale|silent|unknown) : ;; *) ms=unknown ;; esac
132
- case "$ks" in observed|unknown) : ;; *) ks=unknown ;; esac
151
+ case "$ks" in observed|stale|unknown) : ;; *) ks=unknown ;; esac
133
152
  [[ "$age" =~ ^[0-9]{1,6}$ ]] || age=unknown
134
153
  [[ "$kage" =~ ^[0-9]{1,6}$ ]] || kage=unknown
135
154
  [[ "$up" =~ $UINT_RE ]] || up=unknown
136
155
  [[ "$kernel" =~ $KERNEL_RE ]] || { kernel=unknown; ks=unknown; kage=unknown; }
137
- [ "$ks" = observed ] || { kernel=unknown; kage=unknown; }
156
+ # observed needs a known age no older than FRESH_HOURS (the decoder already enforces the exact bound; this is the
157
+ # chokepoint's own re-check). stale keeps the kernel and age visible; only unknown blanks them.
158
+ if [ "$ks" = observed ]; then
159
+ if [ "$kage" = unknown ]; then ks=unknown
160
+ elif [ "$kage" -gt "$FRESH_HOURS" ]; then ks=stale; fi
161
+ fi
162
+ [ "$ks" != unknown ] || { kernel=unknown; kage=unknown; }
138
163
  [[ "$src" =~ ^[A-Za-z0-9_,-]{1,80}$ ]] || src=none
139
164
  [[ "$role" =~ ^[a-z0-9-]{1,32}$ ]] || role=unmapped
140
165
  N_HOSTS=$((N_HOSTS + 1))
@@ -228,7 +253,7 @@ run_query() {
228
253
  # Each marker predicate requires the marker at the START of the decoded message (a log line that merely
229
254
  # mentions a marker name, such as a request path, is not a marker row) and, for the failed-deploy diag, the
230
255
  # kernel section only (the other ~15 sections must not crowd the kernel row out of LIMIT BY).
231
- MARKERS="(position(raw,'SOLEUR_INNGEST_SERVER_PROBE')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_INNGEST_SERVER_PROBE ')) OR (position(raw,'SOLEUR_CANARY_SANDBOX_DIAG')>0 AND position(raw,'section=kernel')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_CANARY_SANDBOX_DIAG: ')) OR (position(raw,'SOLEUR_PRIVATE_NIC')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_PRIVATE_NIC ')) OR (position(raw,'SOLEUR_ZOT_DISK')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_ZOT_DISK '))"
256
+ MARKERS="(position(raw,'SOLEUR_INNGEST_SERVER_PROBE')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_INNGEST_SERVER_PROBE ')) OR (position(raw,'SOLEUR_CANARY_SANDBOX_DIAG')>0 AND position(raw,'section=kernel')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_CANARY_SANDBOX_DIAG: ')) OR (position(raw,'SOLEUR_PRIVATE_NIC')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_PRIVATE_NIC ')) OR (position(raw,'SOLEUR_ZOT_DISK')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_ZOT_DISK ')) OR (position(raw,'SOLEUR_HOST_KERNEL')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_HOST_KERNEL v=1 '))"
232
257
 
233
258
  union_sql() { # $1 = window, $2 = extra predicate, prints the inner hot+archive union (archive arm ALWAYS included)
234
259
  printf "SELECT dt, raw FROM remote(\$BS_TABLE) WHERE dt > now() - INTERVAL %s AND (%s) UNION ALL SELECT dt, raw FROM s3Cluster(primary, \$BS_TABLE_S3) WHERE _row_type = 1 AND dt > now() - INTERVAL %s AND (%s)" \
@@ -282,7 +307,11 @@ if ! jq -se 'any(.[]; (.h | type == "string") and (.h | length) > 0 and ((.n | t
282
307
  degraded 2 control-returned-no-host-rows
283
308
  fi
284
309
 
285
- MARKER_SQL="SELECT dt, raw, multiIf(position(raw,'SOLEUR_INNGEST_SERVER_PROBE')>0,'probe',position(raw,'SOLEUR_CANARY_SANDBOX_DIAG')>0,'canary',position(raw,'SOLEUR_PRIVATE_NIC')>0,'nic','zot') AS k FROM ($(union_sql "$MARKER_WINDOW" "$MARKERS")) ORDER BY dt DESC LIMIT 6 BY k, JSONExtractString(raw,'host_name'), JSONExtractString(raw,'SYSLOG_IDENTIFIER') FORMAT JSONEachRow"
310
+ # LIMIT 6 BY keeps the newest 6 rows per (class, host_name, identifier, unit); the unit is in the key so rows that fail the
311
+ # journald unit rule (wrong _SYSTEMD_UNIT) cannot evict genuine rows that share a host_name and identifier. Eviction can only lose the OLDER kernel that the
312
+ # stale display would show; it can never create a false observed (the newest row always survives and decides, and an
313
+ # unreadable newest row caps the state at stale).
314
+ MARKER_SQL="SELECT dt, raw, multiIf(position(raw,'SOLEUR_INNGEST_SERVER_PROBE')>0,'probe',position(raw,'SOLEUR_CANARY_SANDBOX_DIAG')>0,'canary',position(raw,'SOLEUR_PRIVATE_NIC')>0,'nic',position(raw,'SOLEUR_HOST_KERNEL')>0,'kern','zot') AS k FROM ($(union_sql "$MARKER_WINDOW" "$MARKERS")) ORDER BY dt DESC LIMIT 6 BY k, JSONExtractString(raw,'host_name'), JSONExtractString(raw,'SYSLOG_IDENTIFIER'), JSONExtractString(raw,'_SYSTEMD_UNIT') FORMAT JSONEachRow"
286
315
  run_query marker "$MARKER_SQL"
287
316
 
288
317
  ROLES_JSON="$(printf '%s\n' "$ROLE_TABLE" | jq -R -s -c 'split("\n") | map(select(length > 0) | split("|") | {role: .[0], host: .[1]})')" || degraded 4 role-table
@@ -298,10 +327,11 @@ jq -n -c --argjson roles "$ROLES_JSON" --argjson seen "$HOSTS_SEEN" --argjson fr
298
327
  def kv($m; $k): ([$m | capture("(?:\\A| )" + $k + "=(?<v>[^ ]+)") | .v][0]);
299
328
  def uptime($m): (kv($m; "uptime_s") | select(. != null and test("\\A[0-9]{1,12}\\z")));
300
329
  def roleof($hn): ([ $roles[] | select(.host == $hn and .host != "-") | .role ][0] // "unmapped");
330
+ def kshape($k): if ($k | type) == "string" and ($k | test("\\A[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+-[a-z0-9-]+\\z")) then $k else null end;
301
331
  [ inputs | select(type == "object" and (.dt | valid_dt) and (.raw | type == "string"))
302
332
  | (.dt | ts) as $t | select($t <= now + 300)
303
333
  | (.raw | try fromjson catch null) as $d | select($d | type == "object")
304
- | {t: $t, si: ($d.SYSLOG_IDENTIFIER // ""), hn: ($d.host_name // ""), msg: ($d.message // "")}
334
+ | {t: $t, si: ($d.SYSLOG_IDENTIFIER // ""), hn: ($d.host_name // ""), su: ($d._SYSTEMD_UNIT // ""), msg: ($d.message // "")}
305
335
  | select((.si | type == "string") and (.hn | type == "string") and (.msg | type == "string")) ]
306
336
  | map(
307
337
  if .si == "inngest-server-probe" and (.msg | startswith("SOLEUR_INNGEST_SERVER_PROBE ")) then
@@ -317,6 +347,23 @@ jq -n -c --argjson roles "$ROLES_JSON" --argjson seen "$HOSTS_SEEN" --argjson fr
317
347
  { marker: "nic", t: .t, role: "registry", up: (uptime(.msg) // null) }
318
348
  elif .si == "" and .hn == "" and (.msg | startswith("SOLEUR_ZOT_DISK ")) then
319
349
  { marker: "zot", t: .t, role: (if kv(.msg; "host") == $regid then "registry" else "unmapped" end) }
350
+ elif .si == "host-kernel-marker" and (.msg | startswith("SOLEUR_HOST_KERNEL v=1 role=")) then
351
+ # journald path: identity is the Vector-stamped host_name plus the emitting unit; role= is only a cross-check, and
352
+ # ANY host= substring (empty value, after a newline or tab) is refused
353
+ (kv(.msg; "role")) as $mr
354
+ | roleof(.hn) as $hr
355
+ | { marker: "kern", t: .t, up: (uptime(.msg) // null), kernel: kshape(kv(.msg; "kernel")),
356
+ role: (if .su == "host-kernel-marker.service" and (.msg | contains("host=") | not) and (($mr == "web" and ($hr == "web-1" or $hr == "web-2")) or ($mr == "inngest" and $hr == "inngest"))
357
+ then $hr else "unmapped" end) }
358
+ elif .si == "" and .hn == "" and (.msg | startswith("SOLEUR_HOST_KERNEL v=1 role=")) then
359
+ # registry path: no transport identity, so identity is role=registry AND host=<registry id> in the message, with
360
+ # exactly one `host=` substring in the message (a repeated host= is refused, whichever value comes first)
361
+ { marker: "kern", t: .t, up: (uptime(.msg) // null), kernel: kshape(kv(.msg; "kernel")),
362
+ role: (if kv(.msg; "role") == "registry" and kv(.msg; "host") == $regid and ([.msg | match("host=";"g")] | length) == 1 then "registry" else "unmapped" end) }
363
+ elif (.msg | startswith("SOLEUR_HOST_KERNEL v=1 role=")) then
364
+ # a v=1 kernel row that fails both identity rules (wrong identifier, a stamped host_name without the journald
365
+ # identifier, an identifier without a host_name on the registry shape): surfaced, never attributed
366
+ { marker: "kern", t: .t, kernel: null, role: "unmapped" }
320
367
  else empty end)
321
368
  | . as $c
322
369
  | ($c | map(select(.role == "unmapped")) | length) as $unm_rows
@@ -327,6 +374,8 @@ jq -n -c --argjson roles "$ROLES_JSON" --argjson seen "$HOSTS_SEEN" --argjson fr
327
374
  | ($mine | map(select(.marker != "canary")) | sort_by(.t) | last // null) as $per
328
375
  | ($mine | map(select(.marker == "canary" and .kernel != null and (.kernel | test("\\A[0-9]+\\.[0-9]+\\.[0-9]+-[0-9]+-[a-z0-9-]+\\z"))))
329
376
  | sort_by(.t) | last // null) as $kern
377
+ | ($mine | map(select(.marker == "kern" and .kernel != null)) | sort_by(.t) | last // null) as $kp
378
+ | ($mine | map(select(.marker == "kern")) | sort_by([.t, (if .kernel == null then 1 else 0 end)]) | last // null) as $kn
330
379
  | ($mine | map(select(.marker == "canary")) | length > 0) as $anycanary
331
380
  | ($mine | map(select(.up != null and fresh_row(.t))) | sort_by(.t) | last // null) as $upr
332
381
  | ($r.host != "-" and ($seen | index($r.host)) != null) as $seen_host
@@ -338,7 +387,10 @@ jq -n -c --argjson roles "$ROLES_JSON" --argjson seen "$HOSTS_SEEN" --argjson fr
338
387
  {marker_state: "stale", age_hours: hrs(($mine | map(select(.marker == "canary")) | sort_by(.t) | last).t), source_marker: "canary"}
339
388
  elif $seen_host then {marker_state: "silent", source_marker: "none"}
340
389
  else {marker_state: "unknown", source_marker: "none"} end)
341
- + (if $kern != null and $r.role != "git-data" then {kernel_state: "observed", kernel: $kern.kernel, kernel_age_hours: hrs($kern.t)} else {} end)
390
+ + (if $r.role == "git-data" then {}
391
+ elif $kp != null then {kernel_state: (if $kn.kernel != null and fresh_row($kp.t) then "observed" else "stale" end), kernel: $kp.kernel, kernel_age_hours: hrs($kp.t)}
392
+ elif $kern != null then {kernel_state: "stale", kernel: $kern.kernel, kernel_age_hours: hrs($kern.t)}
393
+ else {} end)
342
394
  + (if $upr != null then {uptime_s: $upr.up} else {} end)
343
395
  ) })
344
396
  ) as $facts
@@ -8,6 +8,8 @@
8
8
  #
9
9
  # Set HOST_STATE_SUT_OVERRIDE to a path to run the suite against a mutated COPY of the helper (the
10
10
  # mutation protocol in the plan's Guard 1 matrix uses this; the helper itself has no such seam).
11
+ # shellcheck disable=SC2319
12
+ # (SC2319: the `x; check "label" "$?"` idiom below reads the exit status of a scenario function on purpose.)
11
13
  set -uo pipefail
12
14
  export LC_ALL=C TZ=UTC
13
15
 
@@ -116,7 +118,7 @@ put() { cat > "$TREE/fx/$1.rows"; }
116
118
  RUN_OUT=""; RUN_RC=0; RUN_ERR=""
117
119
  run_hs() { # run_hs [args] ; runs from inside the scratch tree, captures stdout/rc/stderr
118
120
  RUN_RC=0
119
- RUN_OUT="$(cd "$TREE" && STUB_FX="$TREE/fx" PATH="$PATH_SHIM" CURL_CA_BUNDLE=/nonexistent/ca SSL_CERT_FILE=/nonexistent/ca CURL_HOME=/nonexistent SSLKEYLOGFILE=/nonexistent/k https_proxy=http://127.0.0.1:9 bash "$TREE/h/host-state.sh" "$@" 2> "$WORK/err")" || RUN_RC=$?
121
+ RUN_OUT="$(cd "$TREE" && STUB_FX="$TREE/fx" PATH="$PATH_SHIM" CURL_CA_BUNDLE=/nonexistent/ca SSL_CERT_FILE=/nonexistent/ca CURL_HOME=/nonexistent SSLKEYLOGFILE=/nonexistent/k https_proxy=http://127.0.0.1:9 bash "${HS_BIN:-$TREE/h/host-state.sh}" "$@" 2> "$WORK/err")" || RUN_RC=$?
120
122
  RUN_ERR="$(cat "$WORK/err")"
121
123
  if [ -n "${HS_DEBUG:-}" ]; then printf '%s\n--- stdout:\n%s\n--- rc=%s\n' "$RUN_ERR" "$RUN_OUT" "$RUN_RC" >&2; fi
122
124
  }
@@ -146,8 +148,8 @@ eq "web-1 marker_state fresh (probe row)" "$(col web-1 2)" fresh
146
148
  eq "web-1 uptime from the probe row" "$(col web-1 6)" 20352602
147
149
  eq "web-1 kernel unknown (no kernel diag row for it)" "$(col web-1 3)" unknown
148
150
  eq "web-2 marker_state stale (failed-deploy diag only)" "$(col web-2 2)" stale
149
- eq "web-2 kernel_state observed" "$(col web-2 3)" observed
150
- eq "web-2 kernel value" "$(col web-2 5)" 9.9.9-1-generic
151
+ eq "web-2 kernel_state stale (a failed-deploy diag row never grounds observed)" "$(col web-2 3)" stale
152
+ eq "web-2 kernel value stays visible beside stale" "$(col web-2 5)" 9.9.9-1-generic
151
153
  eq "web-2 kernel_age reported separately" "$(col web-2 7)" 30
152
154
  eq "web-2 never fresh from a diag row" "$(col web-2 2)" stale
153
155
  eq "inngest fresh with uptime" "$(col inngest 6)" 119256
@@ -495,11 +497,12 @@ has "host_name '-' is unmapped, not git-data" "$RUN_OUT" "unmapped"$'\t'"unknown
495
497
  # SQL clause pins (the stub routes on substrings, so pin the clauses it does not execute)
496
498
  reset_fx; seed_control; : | put marker; run_hs
497
499
  SQLM="$(cat "$TREE/fx/marker.sql" 2> /dev/null)"
498
- has "marker SQL keeps newest-first ordering" "$SQLM" "ORDER BY dt DESC LIMIT 6 BY k, JSONExtractString(raw,'host_name'), JSONExtractString(raw,'SYSLOG_IDENTIFIER')"
499
- for mk in "startsWith(JSONExtractString(raw,'message'),'SOLEUR_INNGEST_SERVER_PROBE ')" "startsWith(JSONExtractString(raw,'message'),'SOLEUR_CANARY_SANDBOX_DIAG: ')" "startsWith(JSONExtractString(raw,'message'),'SOLEUR_PRIVATE_NIC ')" "startsWith(JSONExtractString(raw,'message'),'SOLEUR_ZOT_DISK ')" "position(raw,'section=kernel')>0"; do
500
+ has "marker SQL keeps newest-first ordering" "$SQLM" "ORDER BY dt DESC LIMIT 6 BY k, JSONExtractString(raw,'host_name'), JSONExtractString(raw,'SYSLOG_IDENTIFIER'), JSONExtractString(raw,'_SYSTEMD_UNIT') FORMAT"
501
+ for mk in "startsWith(JSONExtractString(raw,'message'),'SOLEUR_INNGEST_SERVER_PROBE ')" "startsWith(JSONExtractString(raw,'message'),'SOLEUR_CANARY_SANDBOX_DIAG: ')" "startsWith(JSONExtractString(raw,'message'),'SOLEUR_PRIVATE_NIC ')" "startsWith(JSONExtractString(raw,'message'),'SOLEUR_ZOT_DISK ')" "startsWith(JSONExtractString(raw,'message'),'SOLEUR_HOST_KERNEL v=1 ')" "position(raw,'section=kernel')>0"; do
500
502
  has "marker SQL requires: $mk" "$SQLM" "$mk"
501
503
  done
502
504
  has "marker SQL tags each class in k" "$SQLM" "'probe'"
505
+ has "marker SQL tags the kernel class in k" "$SQLM" "'kern'"
503
506
  SQLC="$(cat "$TREE/fx/control.sql" 2> /dev/null)"
504
507
  has "control SQL windows to 2 hours" "$SQLC" "INTERVAL 2 HOUR"
505
508
  has "control SQL groups by host and is bounded" "$SQLC" "GROUP BY h ORDER BY n DESC LIMIT 50"
@@ -556,6 +559,323 @@ eq "image-findings with a modified reader exits 4" "$RUN_RC" 4
556
559
  eq "image-findings with a modified reader never runs it" "$([ -f "$TREE/fx/ran" ] && echo yes || echo no)" no
557
560
  restore_reader
558
561
 
562
+ # ===========================================================================================================
563
+ # periodic SOLEUR_HOST_KERNEL rows (#12007, Guard 1): identity from the transport, 48 h freshness, stale for old
564
+ # evidence. Fixtures are synthesized kernels only; the host names are the ROLE_TABLE rows already used above.
565
+ # ===========================================================================================================
566
+ HN_W1=soleur-web-platform; HN_W2=soleur-web-2; HN_INN=soleur-inngest-prd; REGID=soleur-registry
567
+ SYSID=host-kernel-marker
568
+ kmsg() { # kmsg <role> <kernel> [uptime] [tail]
569
+ printf 'SOLEUR_HOST_KERNEL v=1 role=%s kernel=%s uptime_s=%s reboot_required=0 sec_updates=unknown%s' "$1" "$2" "${3:-4242}" "${4:-}"
570
+ }
571
+ obju() { jq -nc --arg si "$1" --arg hn "$2" --arg su "$3" --arg m "$4" '{SYSLOG_IDENTIFIER: $si, host_name: $hn, _SYSTEMD_UNIT: $su, message: $m}'; } # a journald-shaped object that carries the emitting unit
572
+ KJ_UNIT_OK=host-kernel-marker.service # the unit a genuine journald row carries; KJ_UNIT overrides it (set and empty means no unit field value)
573
+ kj() { row "$1" "$(obju "$SYSID" "$2" "${KJ_UNIT-$KJ_UNIT_OK}" "$(kmsg "$3" "$4" "${5:-}" "${6:-}")")"; } # kj <hours-ago> <host_name> <role> <kernel> [uptime] [tail]
574
+ kjm() { rowm "$1" "$(obju "$SYSID" "$2" "${KJ_UNIT-$KJ_UNIT_OK}" "$(kmsg "$3" "$4" "${5:-}" "${6:-}")")"; } # kjm <minutes-ago> ...
575
+ kjf() { jq -nc --arg dt "$(agof "$1")" --arg raw "$(obju "$SYSID" "$2" "${KJ_UNIT-$KJ_UNIT_OK}" "$(kmsg "$3" "$4" "${5:-}" "${6:-}")")" '{dt:$dt, raw:$raw, k:"x"}'; } # kjf <minutes-AHEAD> ...
576
+ kjat() { jq -nc --arg dt "$1" --arg raw "$(obju "$SYSID" "$2" "${KJ_UNIT-$KJ_UNIT_OK}" "$(kmsg "$3" "$4" "${5:-}" "${6:-}")")" '{dt:$dt, raw:$raw, k:"x"}'; } # kjat <exact dt> ... (tied timestamps)
577
+ kr() { # kr <hours-ago> <kernel> [role] [host|none] : the registry path (no host_name, no SYSLOG_IDENTIFIER, host= last)
578
+ local h=" host=${4:-$REGID}"; [ "${4:-}" = none ] && h=""
579
+ row "$1" "$(obj "" "" "SOLEUR_HOST_KERNEL v=1 role=${3:-registry} kernel=$2 uptime_s=88 reboot_required=unknown sec_updates=unknown$h")"
580
+ }
581
+ nunm() { grep -c -E "^unmapped"$'\t' <<< "$RUN_OUT" || true; }
582
+
583
+ # --- the happy path on every kernel-reporting host: a different build and ABI per host, extra trailing fields ---
584
+ reset_fx; seed_control
585
+ { kj 2 $HN_W1 web 9.9.9-1-generic 1001; kj 3 $HN_W2 web 9.9.9-2-generic 2002 ' extra=1'; kj 1 $HN_INN inngest 10.2.3-15-azure 3003; kr 4 9.9.9-3-generic; } | put marker
586
+ run_hs
587
+ eq "kern: exit 0" "$RUN_RC" 0
588
+ eq "kern: web-1 observed" "$(col web-1 3)" observed
589
+ eq "kern: web-1 kernel" "$(col web-1 5)" 9.9.9-1-generic
590
+ eq "kern: web-1 kernel age" "$(col web-1 7)" 2
591
+ eq "kern: web-1 fresh via the periodic row" "$(col web-1 2)" fresh
592
+ eq "kern: web-1 uptime from the kern row" "$(col web-1 6)" 1001
593
+ eq "kern: web-1 source marker names kern" "$(col web-1 8)" kern
594
+ eq "kern: web-2 observed (another build, a row with trailing fields)" "$(col web-2 3)" observed
595
+ eq "kern: web-2 kernel (different ABI)" "$(col web-2 5)" 9.9.9-2-generic
596
+ eq "kern: inngest observed" "$(col inngest 3)" observed
597
+ eq "kern: inngest kernel (different build family)" "$(col inngest 5)" 10.2.3-15-azure
598
+ eq "kern: registry observed (role=registry + host=registry id)" "$(col registry 3)" observed
599
+ eq "kern: registry kernel" "$(col registry 5)" 9.9.9-3-generic
600
+ eq "kern: registry fresh" "$(col registry 2)" fresh
601
+ eq "kern: git-data stays unknown (separate source, never read)" "$(col git-data 3)" unknown
602
+ eq "kern: grok-dogfood has no emitter: silent, kernel unknown" "$(col grok-dogfood 3)/$(col grok-dogfood 2)" "unknown/silent"
603
+ eq "kern: six role lines and no unmapped line" "$(nlines)/$(nunm)" "6/0"
604
+ has "kern: verdict counts the four kernel hosts fresh" "$RUN_OUT" "SOLEUR_CVE_HOST_STATE hosts=6 fresh=4 stale=0 silent=1 unknown=1"
605
+
606
+ # --- Guard 1 row 1: attribution is by the transport-stamped host_name ---
607
+ sc_attr() {
608
+ local rc=0
609
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-9-generic 5; } | put marker; run_hs
610
+ [ "$(col web-1 3)/$(col web-1 5)" = "observed/9.9.9-9-generic" ] && [ "$(col web-2 3)" != observed ] && [ "$(col inngest 3)" != observed ] || rc=1
611
+ reset_fx; seed_control; { kj 1 $HN_W2 inngest 9.9.9-9-generic 5; } | put marker; run_hs
612
+ [ "$(col web-2 3)" != observed ] && [ "$(col inngest 3)" != observed ] || rc=1
613
+ return $rc
614
+ }
615
+ sc_attr; eq "kern attribution: web-2's row under web-1's host_name feeds web-1 only (never web-2)" "$?" 0
616
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-9-generic 5; } | put marker; run_hs
617
+ eq "kern attribution: web-2 stays silent, not observed" "$(col web-2 3)/$(col web-2 2)" "unknown/silent"
618
+ eq "kern attribution: the row is not an unmapped one" "$(nunm)" 0
619
+ reset_fx; seed_control; { kj 1 $HN_W2 inngest 9.9.9-9-generic 5; } | put marker; run_hs
620
+ eq "kern role cross-check: a role=inngest message from web-2's host_name is not attributed to inngest" "$(col inngest 3)" unknown
621
+ eq "kern role cross-check: ...nor to web-2" "$(col web-2 3)" unknown
622
+ eq "kern role cross-check: ...and it surfaces as unmapped" "$(nunm)" 1
623
+ reset_fx; seed_control; { kj 1 $HN_W1 inngest 9.9.9-9-generic 5; kj 1 $HN_INN web 9.9.9-9-generic 5; kj 1 $HN_W1 registry 9.9.9-9-generic 5; } | put marker; run_hs
624
+ eq "kern role cross-check: swapped roles are never attributed (web-1)" "$(col web-1 3)" unknown
625
+ eq "kern role cross-check: swapped roles are never attributed (inngest)" "$(col inngest 3)" unknown
626
+ eq "kern role cross-check: swapped roles are never attributed (registry)" "$(col registry 3)" unknown
627
+ for hn in soleur-surprise-host - soleur-grok-dogfood; do
628
+ reset_fx; seed_control; { kj 1 "$hn" web 9.9.9-9-generic 5; } | put marker; run_hs
629
+ eq "kern: a row from host_name [$hn] attributes to no role" "$(col web-1 3)$(col web-2 3)$(col inngest 3)$(col git-data 3)$(col grok-dogfood 3)" "unknownunknownunknownunknownunknown"
630
+ eq "kern: a row from host_name [$hn] surfaces as unmapped" "$(nunm)" 1
631
+ done
632
+ # a kernel line under another SYSLOG_IDENTIFIER, or not at the start of the message, is not evidence
633
+ reset_fx; seed_control; { row 1 "$(obj doppler $HN_W1 "$(kmsg web 9.9.9-1-generic)")"; row 1 "$(obj "$SYSID" $HN_W2 "noise $(kmsg web 9.9.9-1-generic)")"; } | put marker; run_hs
634
+ eq "kern: another SYSLOG_IDENTIFIER is not evidence" "$(col web-1 3)/$(col web-1 2)" "unknown/silent"
635
+ eq "kern: a message that does not start with the marker is not evidence" "$(col web-2 3)/$(col web-2 2)" "unknown/silent"
636
+
637
+ # --- Guard 1 row 2: the 48 hour bound ---
638
+ check "kern: FRESH_HOURS is 48 in the helper" "$([ "$(sed -n 's/^readonly FRESH_HOURS=\(.*\)$/\1/p' "$SUT_SRC")" = 48 ]; echo $?)"
639
+ sc_fresh() {
640
+ local rc=0
641
+ reset_fx; seed_control; { kj 60 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
642
+ [ "$(col web-2 3)/$(col web-2 5)/$(col web-2 7)" = "stale/9.9.9-1-generic/60" ] || rc=1
643
+ reset_fx; seed_control; { kjm $((47 * 60)) $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
644
+ [ "$(col web-2 3)" = observed ] || rc=1
645
+ return $rc
646
+ }
647
+ sc_fresh; eq "kern freshness: 60 h stale, 47 h observed" "$?" 0
648
+ reset_fx; seed_control; { kjm $((48 * 60 + 30)) $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
649
+ eq "kern freshness: 48h30m is stale (the floor of the age must not admit it)" "$(col web-2 3)" stale
650
+ eq "kern freshness: ...with the kernel and its age still visible" "$(col web-2 5)/$(col web-2 7)" "9.9.9-1-generic/48"
651
+ eq "kern freshness: ...and the host's marker_state is stale too" "$(col web-2 2)" stale
652
+ eq "kern freshness: ...and a stale row's uptime is not reported" "$(col web-2 6)" unknown
653
+ reset_fx; seed_control; { kj 100 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
654
+ eq "kern freshness: a 100 h old valid row is stale, never observed" "$(col web-2 3)/$(col web-2 7)" "stale/100"
655
+ reset_fx; seed_control; { kj 150 $HN_W2 web 9.9.9-1-generic 5; kj 3 $HN_W1 web 9.9.9-1-generic 5; } | put marker; run_hs
656
+ eq "kern freshness: a stale row on one host does not taint the fresh one (second member after a compliant first)" "$(col web-1 3)/$(col web-2 3)" "observed/stale"
657
+
658
+ # --- Guard 1 row 3: the registry needs BOTH role=registry and host=<registry id> ---
659
+ sc_reg() {
660
+ local rc=0
661
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic registry soleur-someone-else; } | put marker; run_hs
662
+ [ "$(col registry 3)" != observed ] || rc=1
663
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic web "$REGID"; } | put marker; run_hs
664
+ [ "$(col registry 3)" != observed ] || rc=1
665
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic registry none; } | put marker; run_hs
666
+ [ "$(col registry 3)" != observed ] || rc=1
667
+ # the two transport conjuncts: a registry-shaped message with a stamped host_name and an empty identifier, and one with an
668
+ # identifier and an empty host_name, must each be refused AND surface as unmapped
669
+ reset_fx; seed_control; { row 1 "$(obj "" "$HN_W1" "$(kmsg registry 9.9.9-1-generic 88 " host=$REGID")")"; } | put marker; run_hs
670
+ [ "$(col registry 3)" != observed ] && [ "$(nunm)" = 1 ] || rc=1
671
+ reset_fx; seed_control; { row 1 "$(obj some-shipper "" "$(kmsg registry 9.9.9-1-generic 88 " host=$REGID")")"; } | put marker; run_hs
672
+ [ "$(col registry 3)" != observed ] && [ "$(nunm)" = 1 ] || rc=1
673
+ # exactly one host= substring: a repeated host= is refused whichever value comes first (and a glued or empty second one too)
674
+ local t
675
+ for t in "$REGID host=evil" "evil host=$REGID" "$REGID host=$REGID" "$REGID host="; do
676
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic registry "$t"; } | put marker; run_hs
677
+ [ "$(col registry 3)" != observed ] && [ "$(nunm)" = 1 ] || rc=1
678
+ done
679
+ reset_fx; seed_control; { row 1 "$(obj "" "" "$(kmsg registry 9.9.9-1-generic 88 " host=$REGID xhost=$REGID")")"; } | put marker; run_hs
680
+ [ "$(col registry 3)" != observed ] && [ "$(nunm)" = 1 ] || rc=1
681
+ return $rc
682
+ }
683
+ sc_reg; eq "kern registry: wrong host=, wrong role=, missing host=, a repeated host=, a stamped host_name, an identifier are each refused" "$?" 0
684
+ reset_fx; seed_control; { row 1 "$(obj "" "$HN_W1" "$(kmsg registry 9.9.9-1-generic 88 " host=$REGID")")"; } | put marker; run_hs
685
+ eq "kern registry: a registry-shaped row with a stamped host_name is not the registry, and is unmapped" "$(col registry 3)/$(col web-1 3)/$(nunm)" "unknown/unknown/1"
686
+ reset_fx; seed_control; { row 1 "$(obj some-shipper "" "$(kmsg registry 9.9.9-1-generic 88 " host=$REGID")")"; } | put marker; run_hs
687
+ eq "kern registry: a registry-shaped row with a shipper identifier is not the registry, and is unmapped" "$(col registry 3)/$(nunm)" "unknown/1"
688
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic registry soleur-someone-else; } | put marker; run_hs
689
+ eq "kern registry: role=registry with another host= is unmapped, registry unknown" "$(col registry 3)/$(col registry 2)/$(nunm)" "unknown/unknown/1"
690
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic web "$REGID"; } | put marker; run_hs
691
+ eq "kern registry: the right host= with role=web is not the registry (second member)" "$(col registry 3)/$(nunm)" "unknown/1"
692
+ eq "kern registry: ...and does not become web-1 either" "$(col web-1 3)" unknown
693
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic registry "evil host=$REGID"; } | put marker; run_hs
694
+ eq "kern registry: host=evil host=<id> is unmapped and registry stays unknown" "$(col registry 3)/$(col registry 2)/$(nunm)" "unknown/unknown/1"
695
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic registry "$REGID host=evil"; } | put marker; run_hs
696
+ eq "kern registry: host=<id> host=evil is unmapped and registry stays unknown" "$(col registry 3)/$(col registry 2)/$(nunm)" "unknown/unknown/1"
697
+ reset_fx; seed_control; { kr 1 9.9.9-1-generic registry "$REGID"; } | put marker; run_hs
698
+ eq "kern registry: exactly one host=<id> is observed (control for the repeated-host= rows)" "$(col registry 3)" observed
699
+ reset_fx; seed_control; { kr 6 9.9.9-1-generic registry "$REGID"; kr 1 9.9.9-2-generic registry soleur-someone-else; } | put marker; run_hs
700
+ eq "kern registry: a newer forged row does not shadow the older valid one" "$(col registry 3)/$(col registry 5)" "observed/9.9.9-1-generic"
701
+ reset_fx; seed_control; { row 1 "$(obj "$SYSID" "" "$(kmsg registry 9.9.9-1-generic 5 " host=$REGID")")"; } | put marker; run_hs
702
+ eq "kern registry: the journald identifier with an empty host_name is not the registry path" "$(col registry 3)" unknown
703
+
704
+ # --- Guard 1 row 4: a journald-path row carrying host= is rejected ---
705
+ sc_hostkw() {
706
+ local rc=0
707
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-1-generic 5 " host=$REGID"; } | put marker; run_hs
708
+ [ "$(col web-1 3)" != observed ] && [ "$(col registry 3)" != observed ] || rc=1
709
+ reset_fx; seed_control; { kj 1 $HN_W1 registry 9.9.9-1-generic 5 " host=$REGID"; } | put marker; run_hs
710
+ [ "$(col registry 3)" != observed ] && [ "$(col web-1 3)" != observed ] || rc=1
711
+ # ANY host= substring is refused: an empty value, glued to the previous field, after a newline, after a tab
712
+ local t
713
+ for t in ' host=' 'host=x' $'\nhost=x' $'\thost=x'; do
714
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-1-generic 5 "$t"; } | put marker; run_hs
715
+ [ "$(col web-1 3)" != observed ] && [ "$(nunm)" = 1 ] || rc=1
716
+ done
717
+ return $rc
718
+ }
719
+ sc_hostkw; eq "kern host=: a journald row carrying host=<registry id> never grounds a role" "$?" 0
720
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-1-generic 5 " host=$REGID"; } | put marker; run_hs
721
+ eq "kern host=: web role + host= is refused (web-1 unknown, host merely silent)" "$(col web-1 3)/$(col web-1 2)" "unknown/silent"
722
+ eq "kern host=: ...and does not feed the registry" "$(col registry 3)/$(col registry 2)" "unknown/unknown"
723
+ eq "kern host=: ...and is unmapped" "$(nunm)" 1
724
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-1-generic 5 ' host=anything'; } | put marker; run_hs
725
+ eq "kern host=: any host= value on the journald path is refused" "$(col web-1 3)" unknown
726
+ for t in ' host=' 'host=x' $'\nhost=x' $'\thost=x'; do
727
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-1-generic 5 "$t"; } | put marker; run_hs
728
+ eq "kern host=: the tail [$(printf '%s' "$t" | tr '\n\t' '~^')] on the journald path is refused and unmapped" "$(col web-1 3)/$(col web-1 2)/$(nunm)" "unknown/silent/1"
729
+ done
730
+
731
+ # --- Guard 1 row 4b: the journald path needs the emitting unit (a forged row with the right identifier and host_name) ---
732
+ sc_unit() {
733
+ local rc=0 u
734
+ for u in session-1.scope '' host-kernel-marker.service.evil xhost-kernel-marker.service host-kernel-marker; do
735
+ reset_fx; seed_control; { KJ_UNIT="$u" kj 1 $HN_W1 web 9.9.9-1-generic 5; } | put marker; run_hs
736
+ [ "$(col web-1 3)" != observed ] && [ "$(nunm)" = 1 ] || rc=1
737
+ done
738
+ reset_fx; seed_control; { row 1 "$(obj "$SYSID" $HN_W1 "$(kmsg web 9.9.9-1-generic 5)")"; } | put marker; run_hs
739
+ [ "$(col web-1 3)" != observed ] && [ "$(nunm)" = 1 ] || rc=1
740
+ return $rc
741
+ }
742
+ sc_unit; eq "kern unit: another _SYSTEMD_UNIT, an empty one, a missing one and the decoys (.service.evil suffix, x prefix, bare identifier) are each refused and unmapped" "$?" 0
743
+ reset_fx; seed_control; { KJ_UNIT=session-1.scope kj 1 $HN_W1 web 9.9.9-1-generic 5; } | put marker; run_hs
744
+ eq "kern unit: a forged row (right identifier, right host_name, session scope) never grounds web-1" "$(col web-1 3)/$(col web-1 2)/$(nunm)" "unknown/silent/1"
745
+ reset_fx; seed_control; { kj 1 $HN_W1 web 9.9.9-1-generic 5; } | put marker; run_hs
746
+ eq "kern unit: the genuine unit is observed (control for the rows above)" "$(col web-1 3)" observed
747
+
748
+ # --- Guard 1 row 5: v=2 and a missing v are ignored (role stays as it was, nothing is flagged) ---
749
+ sc_ver() {
750
+ local rc=0
751
+ reset_fx; seed_control
752
+ { row 1 "$(obj "$SYSID" $HN_W1 'SOLEUR_HOST_KERNEL v=2 role=web kernel=9.9.9-1-generic uptime_s=5')"
753
+ row 1 "$(obj "$SYSID" $HN_W2 'SOLEUR_HOST_KERNEL role=web kernel=9.9.9-1-generic uptime_s=5')"
754
+ row 1 "$(obj "$SYSID" $HN_INN 'SOLEUR_HOST_KERNEL v= role=inngest kernel=9.9.9-1-generic uptime_s=5')"
755
+ row 1 "$(obj "" "" "SOLEUR_HOST_KERNEL v=2 role=registry kernel=9.9.9-1-generic uptime_s=5 host=$REGID")"
756
+ row 1 "$(obj "" "" "SOLEUR_HOST_KERNEL role=registry kernel=9.9.9-1-generic uptime_s=5 host=$REGID")"; } | put marker
757
+ run_hs
758
+ [ "$(col web-1 3)$(col web-2 3)$(col inngest 3)$(col registry 3)" = "unknownunknownunknownunknown" ] || rc=1
759
+ return $rc
760
+ }
761
+ sc_ver; eq "kern version: v=2, v= and a missing v are never observed on either path" "$?" 0
762
+ eq "kern version: ignored rows leave the hosts silent (not stale, not fresh)" "$(col web-1 2)/$(col web-2 2)/$(col inngest 2)" "silent/silent/silent"
763
+ eq "kern version: ignored rows are not even flagged unmapped" "$(nunm)" 0
764
+ eq "kern version: ...and the registry stays unknown" "$(col registry 2)" unknown
765
+
766
+ # --- Guard 1 row 6: a failed-deploy kernel row and nothing periodic is stale, never observed ---
767
+ sc_canary() {
768
+ local rc=0
769
+ reset_fx; seed_control; { canary 3 soleur-web-2 9.9.9-1-generic; } | put marker; run_hs
770
+ [ "$(col web-2 3)/$(col web-2 5)/$(col web-2 7)" = "stale/9.9.9-1-generic/3" ] || rc=1
771
+ return $rc
772
+ }
773
+ sc_canary; eq "kern canary: a failed-deploy row 3 h old is stale with kernel and age visible" "$?" 0
774
+ reset_fx; seed_control; { canary 3 soleur-web-2 9.9.9-1-generic; } | put marker; run_hs
775
+ eq "kern canary: the host is not fresh either" "$(col web-2 2)" stale
776
+ # precedence: fresh periodic, then the newest older periodic, then the failed-deploy row
777
+ reset_fx; seed_control; { kj 20 $HN_W2 web 9.9.9-1-generic 5; canary 3 soleur-web-2 9.9.9-5-generic; } | put marker; run_hs
778
+ eq "kern precedence: a fresh periodic row beats a newer failed-deploy row" "$(col web-2 3)/$(col web-2 5)/$(col web-2 7)" "observed/9.9.9-1-generic/20"
779
+ reset_fx; seed_control; { kj 60 $HN_W2 web 9.9.9-1-generic 5; canary 3 soleur-web-2 9.9.9-5-generic; } | put marker; run_hs
780
+ eq "kern precedence: an older periodic row (stale) beats a newer failed-deploy row" "$(col web-2 3)/$(col web-2 5)/$(col web-2 7)" "stale/9.9.9-1-generic/60"
781
+ reset_fx; seed_control; { kj 1 $HN_W2 web unreadable 5; canary 3 soleur-web-2 9.9.9-5-generic; } | put marker; run_hs
782
+ eq "kern precedence: an unreadable periodic row falls through to the failed-deploy row as stale" "$(col web-2 3)/$(col web-2 5)" "stale/9.9.9-5-generic"
783
+
784
+ # --- Guard 1 row 8 (CTO ruling): the NEWEST periodic row decides; an unreadable newest row caps the state at stale ---
785
+ sc_prec() {
786
+ local rc=0 order
787
+ for order in new-first old-first; do
788
+ reset_fx; seed_control
789
+ if [ "$order" = new-first ]; then { kj 1 $HN_W2 web unreadable 5; kj 5 $HN_W2 web 9.9.9-1-generic 5; } | put marker
790
+ else { kj 5 $HN_W2 web 9.9.9-1-generic 5; kj 1 $HN_W2 web unreadable 5; } | put marker; fi
791
+ run_hs
792
+ [ "$(col web-2 3)/$(col web-2 5)/$(col web-2 7)" = "stale/9.9.9-1-generic/5" ] || rc=1
793
+ done
794
+ # six unreadable rows (the per-host LIMIT 6 BY) plus a valid row 40 h old: stale with the older kernel, never observed
795
+ reset_fx; seed_control
796
+ { for h in 1 2 3 4 5 6; do kj $h $HN_W2 web unreadable 5; done; kj 40 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
797
+ [ "$(col web-2 3)/$(col web-2 5)/$(col web-2 7)" = "stale/9.9.9-1-generic/40" ] || rc=1
798
+ return $rc
799
+ }
800
+ sc_prec; eq "kern newest-decides: an unreadable newest row over a valid 5 h old one is stale with the older kernel (both input orders), six unreadable rows over a 40 h old one too" "$?" 0
801
+ sc_tie() {
802
+ local rc=0 order T
803
+ T="$(ago 3)"
804
+ for order in unreadable-first valid-first; do
805
+ reset_fx; seed_control
806
+ if [ "$order" = unreadable-first ]; then { kjat "$T" $HN_W2 web unreadable 5; kjat "$T" $HN_W2 web 9.9.9-1-generic 5; } | put marker
807
+ else { kjat "$T" $HN_W2 web 9.9.9-1-generic 5; kjat "$T" $HN_W2 web unreadable 5; } | put marker; fi
808
+ run_hs
809
+ [ "$(col web-2 3)/$(col web-2 5)" = "stale/9.9.9-1-generic" ] || rc=1
810
+ done
811
+ return $rc
812
+ }
813
+ sc_tie; eq "kern newest-decides: tied timestamps (both input orders) let the unreadable row win, so the state is stale" "$?" 0
814
+ reset_fx; seed_control; { kj 1 $HN_W2 web unreadable 5; kj 5 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
815
+ eq "kern newest-decides: the host marker_state still reflects the newest row" "$(col web-2 2)/$(col web-2 4)" "fresh/1"
816
+ reset_fx; seed_control; { for h in 1 2 3 4 5 6; do kj $h $HN_W2 web unreadable 5; done; kj 40 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
817
+ eq "kern newest-decides: six unreadable rows plus a valid row 40 h old are never observed" "$(col web-2 3)" stale
818
+ reset_fx; seed_control; { kj 1 $HN_W2 web unreadable 5; } | put marker; run_hs
819
+ eq "kern newest-decides: an unreadable kernel alone is never observed (kernel and age unknown)" "$(col web-2 3)/$(col web-2 5)/$(col web-2 7)" "unknown/unknown/unknown"
820
+ eq "kern newest-decides: ...yet the host is a fresh reporter" "$(col web-2 2)" fresh
821
+ reset_fx; seed_control; { kj 1 $HN_W2 web 'rc-kernel;rm' 5; kj 1 $HN_W1 web $'9.9.9-1-generic\n' 5; } | put marker; run_hs
822
+ eq "kern shape: a kernel that is not the anchored shape is refused" "$(col web-2 3)" unknown
823
+ eq "kern shape: a kernel with a trailing newline does not satisfy the end anchor" "$(col web-1 3)" unknown
824
+ reset_fx; seed_control; { kj 1 $HN_W2 web 9.9.9-1-generic 5 $'\nweb-1\tfresh\tobserved\t0\t9.9.9-1-generic\t1\t0\tx'; } | put marker; run_hs
825
+ eq "kern injection: a smuggled host line leaves exactly six role lines" "$(nlines)" 6
826
+ eq "kern injection: web-1 stays silent" "$(col web-1 2)" silent
827
+
828
+ # --- Guard 1 row 9: clock skew mints no fresh ---
829
+ sc_skew() {
830
+ local rc=0
831
+ reset_fx; seed_control; { kjf 4 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
832
+ [ "$(col web-2 3)/$(col web-2 7)" = "observed/0" ] || rc=1
833
+ reset_fx; seed_control; { kjf 10 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
834
+ [ "$(col web-2 3)/$(col web-2 2)" = "unknown/silent" ] || rc=1
835
+ reset_fx; seed_control; { kjf 2880 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
836
+ [ "$(col web-2 3)" != observed ] || rc=1
837
+ return $rc
838
+ }
839
+ sc_skew; eq "kern skew: 4 minutes ahead clamps to age 0, 10 minutes and 2 days ahead are dropped (the bound is now + 300 s)" "$?" 0
840
+ reset_fx; seed_control; { kjf 2880 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
841
+ eq "kern skew: a row dated 2 days ahead leaves the host silent" "$(col web-2 3)/$(col web-2 2)" "unknown/silent"
842
+ reset_fx; seed_control; { kjf 2880 $HN_W2 web 9.9.9-2-generic 5; kj 60 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs
843
+ eq "kern skew: a far-future row does not upgrade an older stale one to observed" "$(col web-2 3)/$(col web-2 5)" "stale/9.9.9-1-generic"
844
+
845
+ # --- Guard 1 row 7: the SQL really asks for the kern class (the stub never executes SQL, so pin the text) ---
846
+ sc_sql() {
847
+ local rc=0 q
848
+ reset_fx; seed_control; : | put marker; run_hs
849
+ q="$(cat "$TREE/fx/marker.sql" 2> /dev/null)"
850
+ case "$q" in *"startsWith(JSONExtractString(raw,'message'),'SOLEUR_HOST_KERNEL v=1 ')"*) : ;; *) rc=1 ;; esac
851
+ case "$q" in *"position(raw,'SOLEUR_HOST_KERNEL')>0,'kern','zot') AS k"*) : ;; *) rc=1 ;; esac
852
+ [ "$(grep -o ') OR (position(raw,' <<< "$q" | grep -c .)" = 8 ] || rc=1
853
+ # the BY key carries the emitting unit: wrong-unit rows must not evict genuine rows that share host_name and identifier
854
+ case "$q" in *"LIMIT 6 BY k, JSONExtractString(raw,'host_name'), JSONExtractString(raw,'SYSLOG_IDENTIFIER'), JSONExtractString(raw,'_SYSTEMD_UNIT') FORMAT JSONEachRow"*) : ;; *) rc=1 ;; esac
855
+ return $rc
856
+ }
857
+ sc_sql; eq "kern SQL: the marker predicate, the kern class tag, the OR-chain length and the unit in the BY key are all present" "$?" 0
858
+ reset_fx; seed_control; : | put marker; run_hs
859
+ SQLM="$(cat "$TREE/fx/marker.sql" 2> /dev/null)"
860
+ check "kern SQL: the explicit kern arm sits before the zot default in the multiIf" "$([[ "$SQLM" == *"'nic',position(raw,'SOLEUR_HOST_KERNEL')>0,'kern','zot') AS k"* ]]; echo $?)"
861
+ eq "kern SQL: the archive arm also carries the kern predicate" "$(grep -c "_row_type = 1 AND dt > now() - INTERVAL 7 DAY AND ((position(raw,'SOLEUR_INNGEST_SERVER_PROBE')>0.*SOLEUR_HOST_KERNEL v=1 '))" <<< "$SQLM")" 1
862
+
863
+ # --- the helper's own identity literals: pinned so a rename is RED here ---
864
+ check "kern helper: the exact SYSLOG_IDENTIFIER literal" "$(grep -qF '.si == "host-kernel-marker"' "$SUT_SRC"; echo $?)"
865
+ check "kern helper: the v=1 token with the role= prefix is the decode anchor (journald, registry and the unmapped catch-all)" "$([ "$(grep -cF 'startswith("SOLEUR_HOST_KERNEL v=1 role=")' "$SUT_SRC")" -eq 3 ]; echo $?)"
866
+ check "kern helper: the registry path pins role=registry and the registry id" "$(grep -qF 'kv(.msg; "role") == "registry" and kv(.msg; "host") == $regid' "$SUT_SRC"; echo $?)"
867
+ check "kern helper: the registry path requires exactly one host= substring" "$(grep -qF 'and ([.msg | match("host=";"g")] | length) == 1 then "registry"' "$SUT_SRC"; echo $?)"
868
+ check "kern helper: the journald path rejects any host= substring" "$(grep -qF '(.msg | contains("host=") | not)' "$SUT_SRC"; echo $?)"
869
+ check "kern helper: the journald path requires the emitting unit" "$(grep -qF '.su == "host-kernel-marker.service"' "$SUT_SRC"; echo $?)"
870
+ check "kern helper: the journald path does not require _HOSTNAME" "$(grep -qF '_HOSTNAME' "$SUT_SRC"; [ $? -ne 0 ]; echo $?)"
871
+ check "kern helper: the classify chokepoint knows the stale value" "$(grep -qF 'case "$ks" in observed|stale|unknown)' "$SUT_SRC"; echo $?)"
872
+
873
+ # --- classify_host no longer blanks a stale kernel: kernel and age visible, state stale, never observed ---
874
+ reset_fx; seed_control; { kj 70 $HN_W1 web 9.9.9-1-generic 5; } | put marker; run_hs
875
+ eq "classify: a stale kernel keeps its value and age in the printed line" "$(col web-1 3)/$(col web-1 5)/$(col web-1 7)" "stale/9.9.9-1-generic/70"
876
+ reset_fx; seed_control; { kj 70 $HN_W1 web 9.9.9-1-generic 5; kj 1 $HN_W1 web 9.9.9-1-generic 5; } | put marker; run_hs
877
+ eq "classify: and a fresh newest valid row makes the same host observed" "$(col web-1 3)/$(col web-1 7)" "observed/1"
878
+
559
879
  # ===========================================================================================================
560
880
  # producer contract: every marker constant and key the helper reads still exists in its producer, so a rename
561
881
  # is RED in the renaming PR (a silent host is the failure this prevents).
@@ -580,10 +900,80 @@ if [ -f "$CI_DEPLOY" ] && [ -f "$INN" ] && [ -f "$REG" ] && [ -f "$IMG" ]; then
580
900
  check "producer: image report findings cap is 50" "$(grep -qF 'MAX_FINDINGS_IN_MARKER=50' "$IMG"; echo $?)"
581
901
  fi
582
902
 
903
+ # --- the periodic kernel marker's producer contract (#12007): collector line grammar, the unit's identifier, the vector
904
+ # allowlist entry (the registry emitter delivery is held for #12386 and is NOT asserted here), and the identity literals shared with the helper. Rows read the producer files
905
+ # directly and FAIL (never skip) when a file is absent, so a deleted or renamed producer is RED here. ---
906
+ KMDIR="$REPO_TOP/apps/web-platform/infra"
907
+ KM="$KMDIR/host-kernel-marker.sh"; KMSVC="$KMDIR/host-kernel-marker.service"; KMVEC="$KMDIR/vector.toml"
908
+ FEEDER="$REPO_TOP/scripts/deadman-heartbeat-feeder.sh"
909
+ HELPER_SI="$(sed -n 's/.*\.si == "\(host-kernel-marker\)".*/\1/p' "$SUT_SRC" | head -1)"
910
+ HELPER_REGID="$(sed -n "s/^readonly REGISTRY_HOST_ID='\(.*\)'$/\1/p" "$SUT_SRC")"
911
+ RT="$(sed -n "/^readonly ROLE_TABLE=/,/'\$/p" "$SUT_SRC" | sed "s/^readonly ROLE_TABLE='//; s/'\$//")"
912
+ rt_host() { awk -F'|' -v r="$1" '$1 == r { print $2; exit }' <<< "$RT"; }
913
+ check "producer kern: the helper's identifier and registry id were extracted" "$([ "$HELPER_SI" = host-kernel-marker ] && [ -n "$HELPER_REGID" ]; echo $?)"
914
+ check "producer kern: the collector exists" "$([ -f "$KM" ]; echo $?)"
915
+ # Whole-line comments are stripped before every grep below, so a comment that quotes a token cannot keep a row green after the
916
+ # code line that carries it is renamed; each row is anchored to the code shape.
917
+ nc() { grep -vE '^[[:space:]]*#' "$1" 2> /dev/null; }
918
+ nchas() { [ "$(nc "$1" | grep -cF -- "$2")" -ge 1 ]; } # nchas <file> <literal>: a non-comment line holds it (no grep -q: pipefail + SIGPIPE)
919
+ KM_CODE="$(nc "$KM")"
920
+ check "producer kern: the collector assigns the SOLEUR_HOST_KERNEL v=1 role= line" "$(grep -qE '^line="SOLEUR_HOST_KERNEL v=1 role=\$\{role\} kernel=' <<< "$KM_CODE"; echo $?)"
921
+ check "producer kern: the line grammar keeps kernel= before uptime_s= with reboot_required and sec_updates after" "$(grep -qE '^line="SOLEUR_HOST_KERNEL v=1 role=\$\{role\} kernel=\$\{kernel\} uptime_s=\$\{uptime_s\} reboot_required=\$\{reboot_required\} sec_updates=\$\{sec_updates\}"$' <<< "$KM_CODE"; echo $?)"
922
+ check "producer kern: the registry id is the constant the helper pins, and host= appends exactly that constant" "$(grep -qxF "readonly REGISTRY_HOST_ID='$HELPER_REGID'" <<< "$KM_CODE" && grep -qF 'line="${line} host=${REGISTRY_HOST_ID}"' <<< "$KM_CODE"; echo $?)"
923
+ # the arm is selected STRUCTURALLY (the non-default arm inside the collector's `case "$role" in`), not by a regex that already
924
+ # contains the role words, and its role set is compared whole
925
+ KM_ARM="$(awk '/^case "\$role" in/ {f=1; next} /^esac/ {f=0} f && /\) *:/ {print}' <<< "$KM_CODE")"
926
+ check "producer kern: the collector has one role-allowlist case arm" "$([ "$(grep -c . <<< "$KM_ARM")" -eq 1 ]; echo $?)"
927
+ KM_ROLES="$(sed 's/).*//' <<< "$KM_ARM" | tr '|' '\n' | tr -d ' \t' | sort | tr '\n' ' ')"
928
+ eq "producer kern: the collector's role allowlist arm is exactly web, inngest and registry" "$KM_ROLES" "inngest registry web "
929
+ check "producer kern: the unit exists" "$([ -f "$KMSVC" ]; echo $?)"
930
+ check "producer kern: the unit's SyslogIdentifier equals the helper's SYSLOG_IDENTIFIER literal" "$([ -n "$HELPER_SI" ] && [ "$(sed -n 's/^SyslogIdentifier=//p' "$KMSVC" 2> /dev/null)" = "$HELPER_SI" ]; echo $?)"
931
+ check "producer kern: the web unit runs the collector with --role web" "$(grep -qE '^ExecStart=.*host-kernel-marker\.sh .*--role web' "$KMSVC" 2> /dev/null; echo $?)"
932
+ check "producer kern: vector.toml allows the identifier in the include list and mirrors it in both journald exclusions (non-comment lines only)" "$([ "$(nc "$KMVEC" | grep -cF '"host-kernel-marker"')" -eq 3 ]; echo $?)"
933
+ # web-1's host_name (the web platform name) is too common a literal to prove anything in the feeder; the feeder suite's
934
+ # hk_identity_pin is the stricter check for it. web-2 and inngest are specific.
935
+ for _r in web-2 inngest; do
936
+ check "producer kern: the feeder predicate for [$_r] carries the same host_name literal as the role table (non-comment lines only)" "$(h="$(rt_host "$_r")"; [ -n "$h" ] && nchas "$FEEDER" "$h"; echo $?)"
937
+ done
938
+
939
+
940
+ # --- shared collector -> consumer, end to end: the REAL collector runs under its test seam with a PATH-shimmed uname, and its
941
+ # stdout is the journald/registry message the helper decodes (a grammar drift between producer and consumer is RED here) ---
942
+ if [ -f "$KM" ]; then
943
+ HKMSTUB="$WORK/hkm-stub"; mkdir -p "$HKMSTUB"
944
+ printf '#!/bin/sh\necho 9.9.9-1-generic\n' > "$HKMSTUB/uname"; printf '#!/bin/sh\nexit 0\n' > "$HKMSTUB/apt-get"; chmod +x "$HKMSTUB/uname" "$HKMSTUB/apt-get"
945
+ printf '4242.50 100.00\n' > "$WORK/hkm-uptime"
946
+ hkm_line() { # hkm_line <role> : the real collector's single stdout line
947
+ HKM_TEST=1 HKM_STUB_BIN_DIR="$HKMSTUB" HKM_PROC_UPTIME="$WORK/hkm-uptime" HKM_REBOOT_FILE="$WORK/hkm-no-such-dir/reboot-required" HKM_APT_TIMEOUT_S=5 bash "$KM" --role "$1" 2> /dev/null
948
+ }
949
+ HL_WEB="$(hkm_line web)"; HL_INN="$(hkm_line inngest)"; HL_REG="$(hkm_line registry)"
950
+ has "e2e collector: the web line carries the shimmed kernel" "$HL_WEB" "SOLEUR_HOST_KERNEL v=1 role=web kernel=9.9.9-1-generic uptime_s=4242 "
951
+ reset_fx; seed_control
952
+ { row 1 "$(obju "$SYSID" $HN_W1 "$KJ_UNIT_OK" "$HL_WEB")"; row 1 "$(obju "$SYSID" $HN_INN "$KJ_UNIT_OK" "$HL_INN")"; row 1 "$(obj "" "" "$HL_REG")"; } | put marker; run_hs
953
+ eq "e2e collector: web-1 is observed from the real collector's line" "$(col web-1 3)/$(col web-1 5)/$(col web-1 6)" "observed/9.9.9-1-generic/4242"
954
+ eq "e2e collector: inngest is observed from the real collector's line" "$(col inngest 3)/$(col inngest 5)" "observed/9.9.9-1-generic"
955
+ eq "e2e collector: the registry is observed from the real collector's line (role=registry plus the pinned host=)" "$(col registry 3)/$(col registry 5)" "observed/9.9.9-1-generic"
956
+ eq "e2e collector: nothing unmapped" "$(nunm)" 0
957
+ else
958
+ bad "e2e collector: the collector file is missing"
959
+ fi
960
+
583
961
  # ===========================================================================================================
584
962
  # host census: every hcloud_server block outside a rehearsal root has a role row; web expands by var.web_hosts.
585
963
  # ===========================================================================================================
964
+ # Canonical assert_fixture_dir - byte-identical copy (fixture-scan.py requires the verbatim body).
965
+ assert_fixture_dir() {
966
+ case "${1-}" in
967
+ "") printf 'FATAL: fixture dir is EMPTY; git -C "" would operate on %s\n' "$PWD" >&2; exit 2 ;;
968
+ */../*|*/..) printf 'FATAL: fixture dir %s contains ..; refusing\n' "$1" >&2; exit 2 ;;
969
+ /proc/*|/sys/*|/dev/*) printf 'FATAL: fixture dir %s is a synthetic-fs path; refusing\n' "$1" >&2; exit 2 ;;
970
+ /|//|/.) printf 'FATAL: fixture dir resolves to the filesystem root; refusing\n' >&2; exit 2 ;;
971
+ /*) : ;;
972
+ *) printf 'FATAL: fixture dir %s is RELATIVE; refusing\n' "$1" >&2; exit 2 ;;
973
+ esac
974
+ }
586
975
  INFRA="$REPO_TOP/apps/web-platform/infra"
976
+ assert_fixture_dir "$INFRA"
587
977
  if [ -d "$INFRA" ]; then
588
978
  TABLE_ROLES="$(awk '/^readonly ROLE_TABLE=/{t=1} t{ line=$0; sub(/^readonly ROLE_TABLE=./,"",line); sub(/.$/,"",line); if (line ~ /^[a-z0-9-]+\|/) { split(line,a,"|"); print a[1] } } /^grok-dogfood\|/{t=0}' "$TREE/h/host-state.sh" | sort -u | tr '\n' ' ')"
589
979
  eq "role table lists the six roles" "$TABLE_ROLES" "git-data grok-dogfood inngest registry web-1 web-2 "
@@ -598,6 +988,106 @@ if [ -d "$INFRA" ]; then
598
988
  done
599
989
  fi
600
990
 
991
+ # ===========================================================================================================
992
+ # Guard 3 (#12007): emitter census. Every hcloud_server block is classified as emitting the periodic kernel marker or as a
993
+ # tracked exemption (git_data, grok_dogfood, and registry: the registry emitter delivery is held for #12386, ratcheted by STALE-REGISTRY-EXEMPTION); every emitting class has its collector copy, a shipped identifier and a fresh-host enable line.
994
+ # The census is a function over an infra directory so the mutation rows below can run it against a mutated copy.
995
+ # ===========================================================================================================
996
+ nctf() { grep -vE '^[[:space:]]*(#|//)' "$1" 2> /dev/null; } # a .tf file with whole-line '#' and '//' comments stripped (count with grep -c downstream, never grep -q: pipefail + SIGPIPE)
997
+ vec_members() { # vec_members <vector.toml> <identifier> : sorted "<source>:<key>" per non-comment array entry equal to the identifier
998
+ grep -vE '^[[:space:]]*#' "$1" 2> /dev/null | awk -v si="\"$2\"" '
999
+ /^\[/ { sec = ($0 ~ /^\[sources\./) ? $0 : ""; sub(/^\[sources\./, "", sec); sub(/\].*/, "", sec); key = ""; next }
1000
+ /^[A-Za-z_.]+[[:space:]]*=/ { key = $1; next }
1001
+ { l = $0; gsub(/[[:space:]]/, "", l); if (sec != "" && (l == si "," || l == si)) print sec ":" key }' | sort
1002
+ }
1003
+ km_census() { # km_census <infra-dir> -> findings, one per line; empty means clean
1004
+ local d="$1" f b n
1005
+ local blocks=""
1006
+ for f in "$d"/*.tf; do
1007
+ case "$f" in *rehearsal*) continue ;; esac
1008
+ blocks="$blocks $(grep -hE '^resource[[:space:]]+"hcloud_server"[[:space:]]+"[a-z0-9_]+"' "$f" 2> /dev/null | sed -E 's/.*"hcloud_server"[[:space:]]+"([a-z0-9_]+)".*/\1/')"
1009
+ done
1010
+ n=0
1011
+ for b in $blocks; do
1012
+ n=$((n + 1))
1013
+ case "$b" in
1014
+ web | inngest) : ;; # emits
1015
+ registry) # exempt (#12386): delivering the registry emitter is a merge-triggered production host replace
1016
+ # (registry-host-replace-dispatch.yml, ADR-190), so it needs a separate owner-approved PR. The ratchet:
1017
+ # once cloud-init-registry.yml mentions the collector or the marker, the follow-up must flip this
1018
+ # exemption on purpose (class emits, with its copy and enable checks), not leave it exempt.
1019
+ [ -f "$d/cloud-init-registry.yml" ] || echo "NO-REGISTRY-CLOUD-INIT"
1020
+ grep -qE 'host-kernel-marker|SOLEUR_HOST_KERNEL' "$d/cloud-init-registry.yml" 2> /dev/null && echo "STALE-REGISTRY-EXEMPTION" ;;
1021
+ git_data) : ;; # exempt: separate Logs source, tracked in the git-data follow-up issue
1022
+ grok_dogfood) # exempt: default-off, no shipper; the exemption ends when the variable flips
1023
+ grep -qE 'default[[:space:]]*=[[:space:]]*false' < <(sed -n '/^variable "enable_grok_dogfood"/,/^}/p' "$d/variables.tf" 2> /dev/null) || echo "STALE-EXEMPTION grok_dogfood" ;;
1024
+ *) echo "UNCLASSIFIED $b" ;;
1025
+ esac
1026
+ done
1027
+ [ "$n" -ge 5 ] || echo "EMPTY-POPULATION n=$n"
1028
+ # whole-line '#' comments never satisfy a check below (a commented-out enable, bake or allowlist line must read as absent)
1029
+ local si; si="$(sed -n 's/^SyslogIdentifier=//p' "$d/host-kernel-marker.service" 2> /dev/null)"
1030
+ # the identifier must be a member of each of the three journald sources' arrays, counted PER [sources.*] section and key
1031
+ # (a total of three entries with one array doubled and another missing is not allowlisted): the Source 1 and Source 2 exclude
1032
+ # mirrors and the Source 4 include list, comments stripped
1033
+ local vs; vs="$([ -n "$si" ] && vec_members "$d/vector.toml" "$si")"
1034
+ [ "$vs" = "host_scripts_journald:include_matches.SYSLOG_IDENTIFIER
1035
+ inngest_journald:exclude_matches.SYSLOG_IDENTIFIER
1036
+ system_journald:exclude_matches.SYSLOG_IDENTIFIER" ] || echo "UNIT-NOT-ALLOWLISTED-IN-ALL-THREE-ARRAYS"
1037
+ # .tf files take both comment forms ('#' and '//'): a bake line commented out with // must read as absent too
1038
+ [ "$(nctf "$d/server.tf" | grep -cF -- '"host-kernel-marker.sh",')" -ge 1 ] || echo "NO-WEB-BAKE"
1039
+ nchas "$d/cloud-init.yml" 'enable --now host-kernel-marker.timer' || echo "NO-WEB-ENABLE"
1040
+ local copy; copy="$(sed -n "/<<.HKMSCRIPTEOF/,/^HKMSCRIPTEOF\$/p" "$d/inngest-bootstrap.sh" 2> /dev/null | sed '1d;$d')"
1041
+ [ -n "$copy" ] && [ "$copy" = "$(cat "$d/host-kernel-marker.sh" 2> /dev/null)" ] || echo "INNGEST-COPY-DRIFT"
1042
+ }
1043
+ if [ -d "$INFRA" ]; then
1044
+ eq "Guard 3: the live census is clean" "$(km_census "$INFRA")" ""
1045
+ CEN="$WORK/census"; rm -rf "$CEN"; mkdir -p "$CEN"
1046
+ cen_fresh() { rm -rf "$CEN/i"; mkdir -p "$CEN/i"; assert_fixture_dir "$INFRA"; cp "$INFRA"/*.tf "$INFRA/vector.toml" "$INFRA/host-kernel-marker.sh" "$INFRA/host-kernel-marker.service" "$INFRA/inngest-bootstrap.sh" "$INFRA/cloud-init.yml" "$INFRA/cloud-init-registry.yml" "$CEN/i/"; }
1047
+ cen_expect() { # <label> <expected-finding-prefix> : the mutated copy must report it
1048
+ has "Guard 3 mutation: $1" "$(km_census "$CEN/i")" "$2"
1049
+ }
1050
+ cen_fresh; printf 'resource "hcloud_server" "brand_new" {}\n' >> "$CEN/i/server.tf"; cen_expect "an unclassified hcloud_server" "UNCLASSIFIED brand_new"
1051
+ # vector.toml carries the identifier three times: the Source 1 exclude, the Source 2 exclude, the Source 4 include (in file order)
1052
+ cen_drop_nth() { python3 - "$CEN/i/vector.toml" "$1" <<'PY2'
1053
+ import sys
1054
+ p, n = sys.argv[1], int(sys.argv[2])
1055
+ s = open(p).read(); tok = '"host-kernel-marker",'; i = -1
1056
+ for _ in range(n):
1057
+ i = s.index(tok, i + 1)
1058
+ open(p, "w").write(s[:i] + s[i + len(tok):])
1059
+ PY2
1060
+ }
1061
+ cen_fresh; cen_drop_nth 1; cen_expect "the Source 1 exclude mirror deleted" "UNIT-NOT-ALLOWLISTED"
1062
+ cen_fresh; cen_drop_nth 2; cen_expect "the Source 2 exclude mirror deleted" "UNIT-NOT-ALLOWLISTED"
1063
+ cen_fresh; cen_drop_nth 3; cen_expect "the Source 4 include entry deleted (unit kept)" "UNIT-NOT-ALLOWLISTED"
1064
+ # a deleted entry replaced by a COMMENT that still names it must not satisfy the count
1065
+ cen_fresh; sed -i '0,/^ "host-kernel-marker",$/ s/^ "host-kernel-marker",$/ # "host-kernel-marker",/' "$CEN/i/vector.toml"; cen_expect "an allowlist entry commented out" "UNIT-NOT-ALLOWLISTED"
1066
+ cen_fresh; sed -i 's/^\([[:space:]]*\)"host-kernel-marker.sh",/\1# "host-kernel-marker.sh",/' "$CEN/i/server.tf"; cen_expect "the web bake line commented out" "NO-WEB-BAKE"
1067
+ cen_fresh; sed -i 's/^\([[:space:]]*\)\(.*enable --now host-kernel-marker.timer.*\)$/\1# \2/' "$CEN/i/cloud-init.yml"; cen_expect "the web enable line commented out" "NO-WEB-ENABLE"
1068
+ # an entry moved between arrays keeps the total at three but is not a member of every array
1069
+ cen_fresh; python3 - "$CEN/i/vector.toml" <<'PY3'
1070
+ import sys
1071
+ p = sys.argv[1]; s = open(p).read(); tok = '"host-kernel-marker",'
1072
+ i1 = s.index(tok); i2 = s.index(tok, i1 + 1)
1073
+ s = s[:i2 + len(tok)] + "\n " + tok + s[i2 + len(tok):]
1074
+ s = s[:i1] + s[i1 + len(tok):]
1075
+ open(p, "w").write(s)
1076
+ PY3
1077
+ cen_expect "an allowlist entry moved from one array into another (total still three)" "UNIT-NOT-ALLOWLISTED"
1078
+ cen_fresh; sed -i 's/^\([[:space:]]*\)"host-kernel-marker.sh",/\1\/\/ "host-kernel-marker.sh",/' "$CEN/i/server.tf"; cen_expect "the web bake line commented out with //" "NO-WEB-BAKE"
1079
+ cen_fresh; sed -i "/<<.HKMSCRIPTEOF/,/^HKMSCRIPTEOF\$/ s/role=\\\${role}/role=\\\${role} /" "$CEN/i/inngest-bootstrap.sh"; cen_expect "a drifted inngest collector copy" "INNGEST-COPY-DRIFT"
1080
+ cen_fresh; sed -i 's/^SyslogIdentifier=.*/SyslogIdentifier=renamed-marker/' "$CEN/i/host-kernel-marker.service"; cen_expect "a renamed SyslogIdentifier" "UNIT-NOT-ALLOWLISTED"
1081
+ cen_fresh; sed -i '/^variable "enable_grok_dogfood"/,/^}/ s/default *= *false/default = true/' "$CEN/i/variables.tf"; cen_expect "the grok exemption outliving its variable" "STALE-EXEMPTION"
1082
+ cen_fresh; sed -i -E 's/^resource[[:space:]]+"hcloud_server"/resource "null_resource"/' "$CEN"/i/*.tf; cen_expect "a census that sees zero hcloud_server blocks" "EMPTY-POPULATION"
1083
+ cen_fresh; sed -i '/host-kernel-marker.timer/d' "$CEN/i/cloud-init.yml"; cen_expect "the fresh-host enable line removed" "NO-WEB-ENABLE"
1084
+ cen_fresh; printf '# host-kernel-marker.sh --role registry\n' >> "$CEN/i/cloud-init-registry.yml"; cen_expect "the registry emitter delivered while the registry is still exempt (collector name)" "STALE-REGISTRY-EXEMPTION"
1085
+ cen_fresh; printf 'SOLEUR_HOST_KERNEL v=1\n' >> "$CEN/i/cloud-init-registry.yml"; cen_expect "the registry emitter delivered while the registry is still exempt (marker name)" "STALE-REGISTRY-EXEMPTION"
1086
+ cen_fresh; rm -f "$CEN/i/cloud-init-registry.yml"; cen_expect "the registry cloud-init file renamed or removed (the ratchet would go blind)" "NO-REGISTRY-CLOUD-INIT"
1087
+ cen_fresh; eq "Guard 3 must-pass: an untouched copy of the tree is clean" "$(km_census "$CEN/i")" ""
1088
+ cen_fresh; printf 'resource "hcloud_server" "git_data" {}\n' >> "$CEN/i/zzz-extra.tf"; eq "Guard 3 must-pass: a second block under an exempt class stays clean" "$(km_census "$CEN/i")" ""
1089
+ fi
1090
+
601
1091
  # ===========================================================================================================
602
1092
  # the helper's own surface: no tracing with a credential, no environment seam for the reader
603
1093
  # ===========================================================================================================
@@ -619,6 +1109,9 @@ if [ -f "$SKILLMD" ]; then
619
1109
  # the prohibited phrases appear only on the anchor line; no durable-text example asserts a safe status
620
1110
  STRAY_SAFE="$(grep -nEi 'not affected|unaffected|patched|not vulnerable|not exposed|mitigated|you are fine|you are safe|all clear' "$SKILLMD" "$HERE"/../references/*.md "$HERE"/../scripts/*.sh | grep -v 'PROHIBITED-PHRASES-ANCHOR' || true)"
621
1111
  eq "no safe-status phrase outside the anchor line" "$STRAY_SAFE" ""
1112
+ # stale wording from before the emitter existed must not return: the periodic report is a fact now, only its rollout is held
1113
+ STRAY_STALE_DOC="$(grep -nE 'no marker supplies|#12007 will' "$SKILLMD" "$HERE"/../references/*.md || true)"
1114
+ eq "no pre-emitter wording ('no marker supplies', '#12007 will') in the skill text" "$STRAY_STALE_DOC" ""
622
1115
  # no kernel-shaped example and no command-position remote-access step
623
1116
  STRAY_KERNEL="$(grep -nE '[0-9]+\.[0-9]+\.[0-9]+-[0-9]+-generic' "$SKILLMD" "$HERE"/../references/*.md "$HERE"/../scripts/*.sh || true)"
624
1117
  eq "no kernel-shaped example in the skill" "$STRAY_KERNEL" ""
@@ -704,8 +1197,9 @@ has "image SQL filters on the marker name" "$SQLI" "position(raw,'${IMG_MARKER}'
704
1197
  reset_fx; seed_control; : | put marker; run_hs
705
1198
  SQLM="$(cat "$TREE/fx/marker.sql" 2> /dev/null)"
706
1199
  has "marker SQL hot arm is windowed" "$SQLM" 'remote($BS_TABLE) WHERE dt > now() - INTERVAL 7 DAY'
707
- eq "marker SQL joins the four predicates with OR" "$(grep -o ') OR (position(raw,' <<< "$SQLM" | grep -c .)" 6
708
- has "marker SQL class tag is the full multiIf" "$SQLM" "multiIf(position(raw,'SOLEUR_INNGEST_SERVER_PROBE')>0,'probe',position(raw,'SOLEUR_CANARY_SANDBOX_DIAG')>0,'canary',position(raw,'SOLEUR_PRIVATE_NIC')>0,'nic','zot') AS k"
1200
+ eq "marker SQL joins the five predicates with OR (3 + 1 joins, hot arm and archive arm)" "$(grep -o ') OR (position(raw,' <<< "$SQLM" | grep -c .)" 8
1201
+ has "marker SQL class tag is the full multiIf (explicit kern arm BEFORE the zot default)" "$SQLM" "multiIf(position(raw,'SOLEUR_INNGEST_SERVER_PROBE')>0,'probe',position(raw,'SOLEUR_CANARY_SANDBOX_DIAG')>0,'canary',position(raw,'SOLEUR_PRIVATE_NIC')>0,'nic',position(raw,'SOLEUR_HOST_KERNEL')>0,'kern','zot') AS k"
1202
+ eq "marker SQL kern predicate appears in both arms" "$(grep -o "position(raw,'SOLEUR_HOST_KERNEL')>0 AND startsWith" <<< "$SQLM" | grep -c .)" 2
709
1203
 
710
1204
  # READER_FILES drift: the real reader and classifier source and exec nothing else, so verifying those two
711
1205
  # files verifies everything that runs. A new dependency in either is RED here.
@@ -728,12 +1222,83 @@ for k in 6.8.0-1-generic 9.9.9-1-generic 6.1.0-13-amd64 6.8.0-generic 6.8-1-gene
728
1222
  eq "kernel regex parity for [$(printf '%s' "$k" | tr '\n' '~')]" "$j" "$b"
729
1223
  done
730
1224
 
1225
+ # ===========================================================================================================
1226
+ # Guard 1 mutation rows and harness rows (#12007). Each mutation edits a COPY of the helper (the canonical one is
1227
+ # never touched), proves the mutant still works on a clean input (so a red cannot come from a crashed mutant), and
1228
+ # requires the matching scenario above to go RED. The harness rows edit THIS suite: a suite whose comparison helpers
1229
+ # were neutered, or that was truncated, must not exit clean.
1230
+ # ===========================================================================================================
1231
+ sc_happy() { reset_fx; seed_control; { kj 2 $HN_W2 web 9.9.9-1-generic 5; } | put marker; run_hs; [ "$(col web-2 3)/$(col web-2 5)" = "observed/9.9.9-1-generic" ]; }
1232
+ mut_red() { # mut_red <label> <scenario-fn> <from> <to>
1233
+ local label="$1" sc="$2" from="$3" to="$4" body rc=0
1234
+ body="$(cat "$TREE/h/host-state.sh")"
1235
+ printf '%s\n' "${body//"$from"/"$to"}" > "$TREE/h/host-state.mut.sh"
1236
+ if cmp -s "$TREE/h/host-state.sh" "$TREE/h/host-state.mut.sh"; then bad "mutation did not apply: $label"; return; fi
1237
+ HS_BIN="$TREE/h/host-state.mut.sh"
1238
+ sc_happy; check "mutation [$label]: the mutant still decodes a clean row (a crashed mutant proves nothing)" "$?"
1239
+ "$sc"; rc=$?
1240
+ HS_BIN=""
1241
+ rm -f "$TREE/h/host-state.mut.sh"
1242
+ check "mutation [$label]: RED under $sc" "$([ "$rc" -ne 0 ]; echo $?)"
1243
+ }
1244
+ sc_happy; check "mutation baseline: the canonical helper passes the clean row" "$?"
1245
+ mut_red "1 attribution by the message role instead of host_name" sc_attr 'roleof(.hn) as $hr' '(if kv(.msg; "role") == "web" then "web-2" else "inngest" end) as $hr'
1246
+ mut_red "2 FRESH_HOURS 48 -> 72" sc_fresh 'readonly FRESH_HOURS=48' 'readonly FRESH_HOURS=72'
1247
+ mut_red "3a registry host= check removed" sc_reg ' and kv(.msg; "host") == $regid and ' ' and '
1248
+ mut_red "3e registry single-host= count removed" sc_reg ' and ([.msg | match("host=";"g")] | length) == 1 then "registry"' ' then "registry"'
1249
+ mut_red "3c registry identifier-empty conjunct removed" sc_reg 'elif .si == "" and .hn == "" and (.msg | startswith("SOLEUR_HOST_KERNEL v=1 role="))' 'elif .hn == "" and (.msg | startswith("SOLEUR_HOST_KERNEL v=1 role="))'
1250
+ mut_red "3d registry host_name-empty conjunct removed" sc_reg 'elif .si == "" and .hn == "" and (.msg | startswith("SOLEUR_HOST_KERNEL v=1 role="))' 'elif .si == "" and (.msg | startswith("SOLEUR_HOST_KERNEL v=1 role="))'
1251
+ mut_red "3b registry role= check removed" sc_reg 'kv(.msg; "role") == "registry" and ' ''
1252
+ mut_red "4 journald host= rejection removed" sc_hostkw '(.msg | contains("host=") | not) and ' ''
1253
+ mut_red "4b journald host= rejection weakened to the spaced token (newline, tab, glued forms)" sc_hostkw 'contains("host=")' 'contains(" host=")'
1254
+ mut_red "4c journald unit requirement removed" sc_unit '.su == "host-kernel-marker.service" and ' ''
1255
+ mut_red "4d journald unit match loosened to a substring (decoy units)" sc_unit '.su == "host-kernel-marker.service" and ' '(.su | contains("host-kernel-marker")) and '
1256
+ mut_red "4e unit dropped from the LIMIT 6 BY key" sc_sql ", JSONExtractString(raw,'_SYSTEMD_UNIT') FORMAT" ' FORMAT'
1257
+ mut_red "5 version anchor loosened to the bare marker" sc_ver 'SOLEUR_HOST_KERNEL v=1 role=")' 'SOLEUR_HOST_KERNEL ")'
1258
+ mut_red "6 failed-deploy kernel promoted to observed" sc_canary 'kernel_state: "stale", kernel: $kern.kernel' 'kernel_state: "observed", kernel: $kern.kernel'
1259
+ mut_red "7 kern clause dropped from the marker SQL" sc_sql " OR (position(raw,'SOLEUR_HOST_KERNEL')>0 AND startsWith(JSONExtractString(raw,'message'),'SOLEUR_HOST_KERNEL v=1 '))" ''
1260
+ mut_red "8 restore discard-unreadable (an unreadable newest row is dropped, the older valid row decides)" sc_prec 'map(select(.marker == "kern")) | sort_by([.t, (if .kernel == null then 1 else 0 end)])' 'map(select(.marker == "kern" and .kernel != null)) | sort_by(.t)'
1261
+ mut_red "8b tie-break dropped (a valid row can win a same-second tie)" sc_tie 'sort_by([.t, (if .kernel == null then 1 else 0 end)])' 'sort_by(.t)'
1262
+ mut_red "9 future-dated rows admitted" sc_skew $'select($t <= now + 300)\n | (.raw | try fromjson catch null) as $d | select($d | type == "object")\n | {t: $t, si:' $'select(true)\n | (.raw | try fromjson catch null) as $d | select($d | type == "object")\n | {t: $t, si:'
1263
+
1264
+ # harness rows: edit the SUITE itself (a child run, never recursing), then require the child to exit non-zero
1265
+ if [ -z "${HOST_STATE_HARNESS_CHILD:-}" ]; then
1266
+ SELF_BODY="$(cat "${BASH_SOURCE[0]}")"
1267
+ child_red() { # child_red <label> <body-text> <expected-output-fragment>
1268
+ local label="$1" body="$2" frag="$3" out rc=0
1269
+ printf '%s\n' "$body" > "$WORK/child.test.sh"
1270
+ out="$(HOST_STATE_HARNESS_CHILD=1 timeout 300 bash "$WORK/child.test.sh" 2>&1)" || rc=$?
1271
+ check "harness [$label]: the edited suite exits non-zero" "$([ "$rc" -ne 0 ]; echo $?)"
1272
+ has "harness [$label]: and says why" "$out" "$frag"
1273
+ check "harness [$label]: and never prints PASS" "$(grep -qE '^host-state: PASS$' <<< "$out"; [ $? -ne 0 ]; echo $?)"
1274
+ }
1275
+ HERE_LINE='HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"'
1276
+ HERE_REP="HERE=\"$HERE\""
1277
+ PINNED="${SELF_BODY/"$HERE_LINE"/"$HERE_REP"}"
1278
+ check "harness: the child copy is pinned to the real suite directory" "$([ "$PINNED" != "$SELF_BODY" ]; echo $?)"
1279
+ # fail/check/eq/has stubbed to a no-op copy: the instrument self-test (the accounting-conservation check) must trip
1280
+ F_BAD='bad() { FAILS=$((FAILS + 1));'; T_BAD='bad() { :; }; bad_unused() { FAILS=$((FAILS + 1));'
1281
+ F_CHK=' if [ "$2" -eq 0 ]; then ok; else bad "$1"; fi'; T_CHK=' ok'
1282
+ F_EQ='else bad "$1 (want [$3] got [$2])"; fi'; T_EQ='else ok; fi'
1283
+ F_HAS='else bad "$1 (missing [$3])"; fi'; T_HAS='else ok; fi'
1284
+ child_red "bad() stubbed to a no-op" "${PINNED/"$F_BAD"/"$T_BAD"}" "instrument self-test"
1285
+ child_red "check() always ok" "${PINNED/"$F_CHK"/"$T_CHK"}" "instrument self-test"
1286
+ child_red "eq() never fails" "${PINNED/"$F_EQ"/"$T_EQ"}" "instrument self-test"
1287
+ child_red "has() never fails" "${PINNED/"$F_HAS"/"$T_HAS"}" "instrument self-test"
1288
+ # truncation: keep the head up to the dark-source section and the real floor tail; the floor must trip
1289
+ TR_HEAD="${PINNED%%$'\n'"# G1-2: dark"*}"
1290
+ TR_TAIL="# floor and ""verdict${PINNED#*"# floor and ""verdict"}"
1291
+ child_red "suite truncated before most assertions" "$TR_HEAD"$'\n'"$TR_TAIL" "assertions ran; floor"
1292
+ fi
1293
+
731
1294
  # ===========================================================================================================
732
1295
  # floor and verdict
733
1296
  # ===========================================================================================================
1297
+ # MIN_CASES is the exact assertion count of the current suite (a `-lt` bound, kept in that shape because scripts/guard-vacuity-floor.test.sh derives
1298
+ # it): one assertion fewer than this trips the floor, so a removed assertion is caught here; an ADDED assertion passes the `-lt` bound and is meant to be recorded by raising this literal in the same change.
734
1299
  SELFTEST_PASSES=1
735
1300
  REAL=$((PASSES - SELFTEST_PASSES))
736
- MIN_CASES=233
1301
+ MIN_CASES=433
737
1302
  if [ "$REAL" -lt "$MIN_CASES" ]; then
738
1303
  printf 'host-state: FAIL (only %s assertions ran; floor %s - the suite may have been truncated)\n' "$REAL" "$MIN_CASES"
739
1304
  exit 1
@@ -356,6 +356,7 @@ NEVER CODE! Just research and write the plan.
356
356
  - **A plan that waives, skips or reorders a gate step must grep for downstream steps whose own skip rests on "because X ran".** A sibling script's comment-level assumption (`grok-fidelity-gate.sh` skipping the AGENTS rule-budget lint because the affected gate ran test-all) silently loses coverage when X is waived, and the banner still says the other steps passed. **Why:** #12294 — found by one architecture seat, missed by design, plan review and the CTO ruling. See `knowledge-base/project/learnings/2026-11-07-a-waived-gate-step-took-a-sibling-steps-skip-optimization-with-it.md`.
357
357
 
358
358
  - **A plan sentence about an open sibling PR (its base, its diff, its counts) is a time-stamped observation: re-read it with `gh` at every re-sync and write the date next to it.** A cleanup PR that waits in review also owes every pinned count to a full suite run on the merged tree after each `origin/main` move. **Why:** #12306 — "#12292 is on a pre-retirement base" was wrong when written, and the PR merged mid-review; main moved three more times before the push. See `knowledge-base/project/learnings/workflow-patterns/2026-11-07-a-cleanup-pr-owes-its-counts-to-the-merged-tree-and-its-premises-to-a-fresh-read.md`.
359
+ - **A plan sentence about what a MERGE does to production must be derived from every workflow whose `on.push.paths` matches the changed files, not from the one apply workflow you read.** `grep -l` each changed infra basename across `.github/workflows/*.yml`, read each match's `on:` block and body, and write what it does on merge into the plan. A delivery dispatcher can fire a production host replace from the merge itself (`registry-host-replace-dispatch.yml`: any `cloud-init-registry.yml`/`zot-registry.tf`/`variables.tf` render change, no reviewer gate), which breaks a run's no-unauthorized-production-mutation constraint. **Why:** #12007/PR #12379 - three review rounds repeated 'a merge replaces nothing' before a fix-round seat read the dispatcher. See `knowledge-base/project/learnings/2026-11-08-a-merge-that-edits-registry-cloud-init-auto-replaces-the-registry-host-and-the-plan-checked-only-the-apply-workflow.md`.
359
360
 
360
361
  - **A producer check for a gated registration is evaluated over the REGISTERED population, not the system.** For a hook, guard or note registered under a predicate (a flag AND a capability such as web egress), write the producer check as rows of (cited fact, file, still true when the predicate holds?) and run the grep for each row; a predicate that turns on one capability can turn off the credential or tool the cited producer needs, and the two facts live in different files. **Why:** #12435 — the plan cited `GH_TOKEN` minted into the sandbox, true of the system and false in web-egress sessions where the env deny census removes it, so the hook registered only where `gh` fails at auth. See `knowledge-base/project/learnings/2026-11-09-a-producer-check-was-true-of-the-system-and-false-of-the-population-the-hook-registered-in.md`.
361
362
  - **A suite ledger's per-site cost is ARM cost (pristine + every mutant rep + the give_up boundary), not pristine cost — measure the pristine site before prescribing fixture surgery.** When the arm is expensive and pristine is cheap, the pathology is mutant-side runaway and the remedy is pacing (per-scan give_up that returns over-bound, cheapest-condemner ordering, a shrink-only per-invocation timeout), never smaller fixtures, which cut coverage to treat a cost the SUT never had. The same rule covers every bound a ruling asserts: derive caps/floors from a measured pristine rate, not arithmetic — a `12*len+5000` line-event cap was one event under pristine `hb`'s measured 485,001 events at 40,000 bytes (12.125/byte) and would have condemned the pristine run. **Why:** #12016/PR #12419 — `row_scan_ops` reported 47.3 s site cost; pristine was ~4.8 s. See `knowledge-base/project/learnings/performance-issues/mutant-side-runaway-read-as-pristine-site-cost-ci-replay-20261108.md`.