test(cli): correct Linux collection and diagnostic guards

This commit is contained in:
pingqiu committed 2026-11-29 03:02:25 -08:00
1 parent 7b65aab75f
commit 9606a9c8f4
3 files changed
+15 -10

No files matched your search

@@ -245,8 +245,8 @@ func TestLogCollectChangedSourceCannotBlockAcquisition(t *testing.T) {
t.Fatal(err)
}
before, err := os.Lstat(path)
if err != nil {
t.Fatal(err)
if err != nil || !before.Mode().IsRegular() {
t.Fatalf("initial source is not regular: %v", err)
}
if err := os.Remove(path); err != nil {
t.Fatal(err)
@@ -273,8 +273,10 @@ func TestLogCollectChangedSourceCannotBlockAcquisition(t *testing.T) {
if statErr != nil {
t.Fatal(statErr)
}
if info.Mode().IsRegular() || os.SameFile(before, info) {
t.Fatal("substituted FIFO accepted as original regular file")
// Unlink/create may immediately reuse the same inode on ext4.
// SameFile alone is not a type check: production also checks IsRegular.
if info.Mode().IsRegular() || info.Mode()&os.ModeNamedPipe == 0 {
t.Fatal("replacement descriptor is not the expected non-regular FIFO")
}
}
if time.Since(started) > 500*time.Millisecond {
@@ -58,7 +58,7 @@ var headReaders = map[string]string{
"core/frontend/chunkstore/layout/head.go runTransition -> ReadHead": "refuses ErrHeadAbsent and writes nothing; no layout transition creates a HEAD (probe LayoutTransition)",
// above the chunk store: they read through the layout remote's GetHead, so an
// absent HEAD reaches them as ErrHeadAbsent, never as a zero HEAD (probe LayoutRemote)
"cmd/sw-block/chunk_b.go chunkShow -> ReadHead": "found=false: prints a null head (probe TestOpsChunk_AbsentVolume)",
"cmd/sw-block/chunk_b.go chunkShowContext -> ReadHead": "found=false: prints a null head, including via the chunkShow wrapper (probe TestOpsChunk_AbsentVolume)",
"cmd/sw-block/chunk_b.go chunkSnapshots -> ReadHead": "refuses volume_not_found (probe TestOpsChunk_AbsentVolume)",
"core/frontend/durable/provider_chunk.go GetHead -> GetHead": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
"core/frontend/durable/provider_chunk.go GetHeadRoot -> GetHead": "ErrHeadAbsent from the layout remote (probe LayoutRemote)",
+8 -5
View File
@@ -968,11 +968,14 @@ Notes:
| ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status |
|---|---|---|---|---|---|---|
| `INV-CLI-BUNDLE-REDACTION-001` | Recognized credentials are discovered across bounded sources before any artifact is written, and their opaque repeats are masked. Discovery precedes time filtering and aggregate-budget omission; exhausting the match bound refuses output. Bare prose does not seed global replacements; ordinary values are excluded. JSON counters retain exact integer values. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_redact.go`; `logBundle.write` | `TestLogCollectPlantedSecretsNeverLeaveTheBundle`, `TestLogCollectRecognizedCredentialFormsNeverLeaveTheBundle`, `TestLogCollectKeepsOrdinaryWordsAndGenerationsWhileRedactingTokens`, `TestLogCollectPreservesExactLargeJSONNumbers`, `TestLogCollectRefusesExhaustedCredentialDiscovery`, `TestLogCollectDiscoversCredentialsBeforeTheTimeWindow`, `TestLogCollectDiscoversCredentialsInSourcesBeyondTheArtifactBudget` | — (pure client sanitization) | ACTIVE |
| `INV-CLI-BUNDLE-LOCAL-RETENTION-001` | Selected local logs are collected before remote observations; an unresponsive master produces an incomplete bundle without discarding those logs. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect.go` `collectLogs` | `TestLogCollectKeepsLocalLogsWhenTheMasterDoesNotAnswer` | — (client ordering; no service-availability claim) | ACTIVE |
| `INV-CLI-BUNDLE-DEFAULT-UNITS-001` | Default unit discovery includes template holder instances even when no plain holder unit exists; discovery or collection failures remain explicit unavailable sources. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_local.go` `defaultBundleUnits` | `TestLogCollectDefaultIncludesEveryTemplateInstanceWithoutAPlainHolder` (`cmd/sw-block/log_collect_linux_test.go`; Linux qualification required) | — (local service discovery) | ACTIVE |
| `INV-CLI-BUNDLE-INVENTORY-001` | Bundle checks and per-volume artifacts use one observed inventory; a second read cannot hide truncation. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_status.go` `collectStatus`; `inspectionShell.checkObservation` | `TestLogCollectUsesOneInventoryForChecksAndVolumeArtifacts` | — (client observation reuse) | ACTIVE |
| `INV-CLI-BUNDLE-SOURCE-ACQUISITION-001` | Linux local-log acquisition cannot block on a substituted FIFO and does not follow a substituted link; the opened file must still be the inspected regular file. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_open_linux.go` `openBundleLog`; `readBundleLog` | `TestLogCollectChangedSourceCannotBlockAcquisition`, `TestLogCollectJournalDeadlineAndLinkedFileAreUnavailable` (`cmd/sw-block/log_collect_linux_test.go`; Linux qualification required) | — (local input acquisition) | ACTIVE |
| `INV-CLI-BUNDLE-REDACTION-001` | Recognized credentials are discovered across bounded sources before any artifact is written, and their opaque repeats are masked. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_redact.go`; `logBundle.write` | `TestLogCollectPlantedSecretsNeverLeaveTheBundle`, `TestLogCollectRecognizedCredentialFormsNeverLeaveTheBundle` | - (pure client sanitization) | ACTIVE |
| `INV-CLI-BUNDLE-DISCOVERY-001` | Credential discovery precedes time filtering and aggregate-budget omission; exhausting the match bound refuses all output. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect.go` `discover`, `add`, `readBundleLog`; `cmd/sw-block/log_collect_redact.go` `discoverText` | `TestLogCollectRefusesExhaustedCredentialDiscovery`, `TestLogCollectDiscoversCredentialsBeforeTheTimeWindow`, `TestLogCollectDiscoversCredentialsInSourcesBeyondTheArtifactBudget` | - (bounded discovery) | ACTIVE |
| `INV-CLI-BUNDLE-DIAGNOSTICS-001` | Bare prose does not seed global replacement; ordinary values are excluded so diagnostic words, dates and generations remain readable. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_redact.go` `remember`, `discoverText` | `TestLogCollectKeepsOrdinaryWordsAndGenerationsWhileRedactingTokens` | - (pure client sanitization) | ACTIVE |
| `INV-CLI-BUNDLE-NUMBERS-001` | Sanitizing structured JSON preserves exact integer evidence, including uint64 counters and positions above 2^53. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_redact.go` `bundleDecodeJSON` | `TestLogCollectPreservesExactLargeJSONNumbers` | - (pure client sanitization) | ACTIVE |
| `INV-CLI-BUNDLE-LOCAL-RETENTION-001` | Selected local logs are collected before remote observations; an unresponsive master produces an incomplete bundle without discarding those logs. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect.go` `collectLogs` | `TestLogCollectKeepsLocalLogsWhenTheMasterDoesNotAnswer` | - (client ordering; no service-availability claim) | ACTIVE |
| `INV-CLI-BUNDLE-DEFAULT-UNITS-001` | Default unit discovery includes template holder instances even when no plain holder unit exists; discovery or collection failures remain explicit unavailable sources. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_local.go` `defaultBundleUnits` | `TestLogCollectDefaultIncludesEveryTemplateInstanceWithoutAPlainHolder` (`cmd/sw-block/log_collect_linux_test.go`; Linux qualification required) | - (local service discovery) | ACTIVE |
| `INV-CLI-BUNDLE-INVENTORY-001` | Bundle checks and per-volume artifacts use one observed inventory; a second read cannot hide truncation. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_status.go` `collectStatus`; `inspectionShell.checkObservation` | `TestLogCollectUsesOneInventoryForChecksAndVolumeArtifacts` | - (client observation reuse) | ACTIVE |
| `INV-CLI-BUNDLE-SOURCE-ACQUISITION-001` | Linux local-log acquisition cannot block on a substituted FIFO and does not follow a substituted link; the opened file must still be the inspected regular file. | M9 read-only inspection; no state transition | `cmd/sw-block/log_collect_open_linux.go` `openBundleLog`; `readBundleLog` | `TestLogCollectChangedSourceCannotBlockAcquisition`, `TestLogCollectJournalDeadlineAndLinkedFileAreUnavailable` (`cmd/sw-block/log_collect_linux_test.go`; Linux qualification required) | - (local input acquisition) | ACTIVE |
### B.6 Workspace: chunk lifecycle, GC and delete