masked_exit trips on a chunk-split log line — a successful activation failed on the fragment '[gateway] Failed to' #549

Closed
opened 2026-08-14 23:40:55 +00:00 by ben · 2 comments
Owner

Symptom

2026-08-14 cold proof drive, Activate the gateway system leg: the drive faulted with

clan: masked_exit on gateway: clan reported success but the log shows a real failure: [gateway] Failed to

The tripping "proof" line ends mid-sentence — [gateway] Failed to — and the deploy it failed was in fact SUCCESSFUL: the guest journal (live-tailed during the drive) shows switch-to-configuration completing cleanly, the post-activation hardening closed the root-SSH door on schedule, and all four forwarded service ports (22/8080/8443/443) came up and answered. The gateway converged; the detector failed the drive.

Cause

internal/clan/errors.go logSaysFailed scans the captured log per line and deliberately exempts "failed to reload" (switch-to-configuration prints Failed to reload <unit> warnings over SSH on genuinely successful updates — the 2026-08-05 Phase A false positive). But the scan runs over stream-chunked text: a chunk boundary that splits a line mid-sentence — [gateway] Failed to ⏎ reload dbus-broker.service … — leaves a fragment that the exemption cannot match while the generic "failed to" marker still does. The truncated proof line persisted in the fault is the smoking gun: logSaysFailed returns the exact line it scanned, and the line it scanned was a fragment.

Rule

Reassemble the stream into complete lines before logSaysFailed scans (buffer a trailing partial line until its newline arrives; flush at process exit). A proof line that ends exactly at a marker phrase (…Failed to, …error:, …cannot ) with nothing after it should be treated as suspect — at minimum, never classify masked_exit on a fragment that a known exemption could complete.

Proof

Unit test: feed the captured-log scanner the same content twice — once whole-lined, once chunk-split mid-line inside an exempted phrase (Failed to / reload dbus…) — the classification must be identical (clean) for both. The existing clan_test.go masked-exit table is the home.

Relates to #451 (evidence-free masked_exit) and #456 (benign-line false positives) — same detector, new false-positive class. Found on the 2026-08-14 cold-machine proof drive; the drive itself is otherwise the furthest cold run yet (mesh/public-entry/control-plane all green before this trip).

## Symptom 2026-08-14 cold proof drive, **Activate the gateway system** leg: the drive faulted with ``` clan: masked_exit on gateway: clan reported success but the log shows a real failure: [gateway] Failed to ``` The tripping "proof" line ends mid-sentence — `[gateway] Failed to` — and the deploy it failed was in fact SUCCESSFUL: the guest journal (live-tailed during the drive) shows switch-to-configuration completing cleanly, the post-activation hardening closed the root-SSH door on schedule, and all four forwarded service ports (22/8080/8443/443) came up and answered. The gateway converged; the detector failed the drive. ## Cause `internal/clan/errors.go` `logSaysFailed` scans the captured log **per line** and deliberately exempts `"failed to reload"` (switch-to-configuration prints `Failed to reload <unit>` warnings over SSH on genuinely successful updates — the 2026-08-05 Phase A false positive). But the scan runs over stream-chunked text: a chunk boundary that splits a line mid-sentence — `[gateway] Failed to` ⏎ `reload dbus-broker.service …` — leaves a fragment that the exemption cannot match while the generic `"failed to"` marker still does. The truncated proof line persisted in the fault is the smoking gun: `logSaysFailed` returns the exact line it scanned, and the line it scanned was a fragment. ## Rule Reassemble the stream into complete lines before `logSaysFailed` scans (buffer a trailing partial line until its newline arrives; flush at process exit). A proof line that ends exactly at a marker phrase (`…Failed to`, `…error:`, `…cannot `) with nothing after it should be treated as suspect — at minimum, never classify masked_exit on a fragment that a known exemption could complete. ## Proof Unit test: feed the captured-log scanner the same content twice — once whole-lined, once chunk-split mid-line inside an exempted phrase (`Failed to` / `reload dbus…`) — the classification must be identical (clean) for both. The existing clan_test.go masked-exit table is the home. Relates to #451 (evidence-free masked_exit) and #456 (benign-line false positives) — same detector, new false-positive class. Found on the 2026-08-14 cold-machine proof drive; the drive itself is otherwise the furthest cold run yet (mesh/public-entry/control-plane all green before this trip).
Author
Owner

Second occurrence + root-cause refinement (2026-08-14, same drive, recover-then-redrive)

The recover path (delete VM → fresh stand-up) reproduced the trip EXACTLY — same fragment [gateway] Failed to at the same leg. This is deterministic, not a chunking race, and the mechanism is now clear:

Activating the hardened gateway config kills the guest sshd mid-output. The activation succeeds and applies the no-root-ssh hardening, which tears down the SSH session clan is streaming its log through — so the stream truncates mid-line at the same byte-ish point every run. Clan exits 0 (the activation genuinely completed); the masked-exit scanner then reads the truncated tail, the "failed to reload" exemption cannot match the fragment, the generic "failed to" marker does. The line being chopped is almost certainly switch-to-configuration's benign Failed to reload <unit> warning — the exact class the exemption exists for.

Verified live: the guest journal (tailed during the drive) shows the switch completing cleanly; the SSH door closed immediately after (hardening on schedule); all four forwarded service ports came up and answered. Two independent runs, both genuinely-successful activations failed by the fragment.

Fix implication beyond line reassembly: a stream that ENDS mid-line because the remote side hung up is the expected shape of this leg (activation kills the transport it streams over). The scanner must treat an unterminated trailing fragment as unscannable/suspect — reassembly alone cannot complete a line whose remainder never arrives.

This blocks the cold-machine proof drive (ADR 0110/0171 trial-proof, #425 sign-off ride): every fresh drive trips here, and the retry path then hits the post-activation transport wall (filed separately). Prioritised accordingly; ruling recorded by Ben in-session — fix per the Rule in the body + this refinement.

## Second occurrence + root-cause refinement (2026-08-14, same drive, recover-then-redrive) The recover path (delete VM → fresh stand-up) reproduced the trip EXACTLY — same fragment `[gateway] Failed to` at the same leg. This is deterministic, not a chunking race, and the mechanism is now clear: **Activating the hardened gateway config kills the guest sshd mid-output.** The activation succeeds and applies the no-root-ssh hardening, which tears down the SSH session clan is streaming its log through — so the stream truncates mid-line at the same byte-ish point every run. Clan exits 0 (the activation genuinely completed); the masked-exit scanner then reads the truncated tail, the `"failed to reload"` exemption cannot match the fragment, the generic `"failed to"` marker does. The line being chopped is almost certainly switch-to-configuration's benign `Failed to reload <unit>` warning — the exact class the exemption exists for. Verified live: the guest journal (tailed during the drive) shows the switch completing cleanly; the SSH door closed immediately after (hardening on schedule); all four forwarded service ports came up and answered. Two independent runs, both genuinely-successful activations failed by the fragment. **Fix implication beyond line reassembly:** a stream that ENDS mid-line because the remote side hung up is the expected shape of this leg (activation kills the transport it streams over). The scanner must treat an unterminated trailing fragment as unscannable/suspect — reassembly alone cannot complete a line whose remainder never arrives. **This blocks the cold-machine proof drive** (ADR 0110/0171 trial-proof, #425 sign-off ride): every fresh drive trips here, and the retry path then hits the post-activation transport wall (filed separately). Prioritised accordingly; ruling recorded by Ben in-session — fix per the Rule in the body + this refinement.
Author
Owner

close-report for #549 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 549,
  "status": "success",
  "commits": [
    "265cb9113fc281bb5d8481a016f52b89ca0817bb"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/clan/clan_test.go",
    "internal/clan/errors.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/clan/ -count=1",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Unit test: feed the captured-log scanner the same content twice — whole-lined and chunk-split mid-line inside an exempted phrase — the classification must be identical (clean) for both": "TestClassify_ChunkSplitReloadNoiseIsNotMasked in internal/clan/clan_test.go: Classify(exit 0) on 'whole' and 'split' variants both return nil (clean); commit 265cb9113fc281bb5d8481a016f52b89ca0817bb",
    "Reassemble the stream into complete lines before logSaysFailed scans; never classify masked_exit on a fragment that a known exemption could complete": "internal/clan/errors.go logSaysFailed now splices a next line onto any line ending exactly at a marker (endsAtFailMarker + stripMachinePrefix) before the exemption checks; a fragment no exemption completes still trips verbatim (asserted by the test's real-failure case)"
  },
  "summary": "logSaysFailed reassembles a chunk-split fragment before the masked-exit exemptions judge it, so a split 'Failed to reload' warning no longer fails a converged gateway.",
  "blockers": []
}
**close-report** for #549 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 549, "status": "success", "commits": [ "265cb9113fc281bb5d8481a016f52b89ca0817bb" ], "changed_files": [ "STATUS.md", "internal/clan/clan_test.go", "internal/clan/errors.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./internal/clan/", "exit_code": 0 }, { "command": "go test ./internal/clan/ -count=1", "exit_code": 0 } ], "criteria": { "Unit test: feed the captured-log scanner the same content twice — whole-lined and chunk-split mid-line inside an exempted phrase — the classification must be identical (clean) for both": "TestClassify_ChunkSplitReloadNoiseIsNotMasked in internal/clan/clan_test.go: Classify(exit 0) on 'whole' and 'split' variants both return nil (clean); commit 265cb9113fc281bb5d8481a016f52b89ca0817bb", "Reassemble the stream into complete lines before logSaysFailed scans; never classify masked_exit on a fragment that a known exemption could complete": "internal/clan/errors.go logSaysFailed now splices a next line onto any line ending exactly at a marker (endsAtFailMarker + stripMachinePrefix) before the exemption checks; a fragment no exemption completes still trips verbatim (asserted by the test's real-failure case)" }, "summary": "logSaysFailed reassembles a chunk-split fragment before the masked-exit exemptions judge it, so a split 'Failed to reload' warning no longer fails a converged gateway.", "blockers": [] } ``` </details>
ben closed this issue 2026-08-14 23:58:57 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#549
No description provided.