AstrBot-Desktop/docs/spikes/P00-04-event-log-and-read-only-diagnostics.md
YokiiroBW 353a439b41
一些检测仍在等待运行
ci / Portable quality checks (push) Waiting to run
ci / Windows Tauri build (push) Waiting to run
docs(p00): record spike results and unresolved boundaries
2026-07-18 21:00:49 +08:00

61 行
3.1 KiB
Markdown

# P00-04: Event Log and Read-Only Diagnostics
- Status: Passed for bounded local and loopback diagnostics
- Date recorded: 2026-07-18
- MVP gate: Required before exposing local diagnostic tools
## Objective
Verify bounded, read-only collection of Windows event summaries, process and foreground-window metadata, port occupancy, network-target reachability, authorized log tails, configuration parsing, and local redaction.
## Environment
- Host: Windows 11 x64
- Rust toolchain: rustc/cargo 1.97.1
- MSVC C++ build tools: verified by native builds
- Network targets: no production target authorized for this Spike
- Event-log scope: explicit provider and time range only
## Minimal validation implementation
Each diagnostic operation must have a typed argument schema and explicit limits. It must return structured summaries, not arbitrary command output or unrelated full logs.
File reads must require a user-authorized path token, enforce size limits, prefer log tails, reject binary content, and redact before any preview or upload.
## Required execution
1. Query a known provider over a short time window and return a bounded summary.
2. Apply provider, time, level, and optional process filtering.
3. Inspect one explicitly identified process without controlling it.
4. Check one port and one explicitly supplied network target.
5. Read the tail of a disposable authorized log fixture.
6. Parse JSON, YAML, TOML, and INI fixtures with limits.
7. Redact fake tokens, passwords, cookies, API keys, URL credentials, connection-string passwords, and PEM material.
8. Verify invalid provider, permission denial, timeout, malformed file, and oversized input errors.
## Actual execution result
Passed. Windows-native tests executed a bounded recent Event Log query, inspected the current process and foreground-window metadata, identified the owner PID of a test-created TCP listener, and exercised structured error handling.
Disposable local fixtures verified authorized log-tail reads, JSON/YAML/TOML/INI parsing limits, binary/oversized rejection, and redaction of fake bearer tokens, passwords, cookies, API keys, URL credentials, connection-string secrets, and PEM material.
Network reachability coverage is limited to explicit loopback fixtures; no production or user network target was contacted.
## Log summary
Commands: `cargo test --workspace` plus the Windows native-provider tests. Result: passed. Event content and fake secrets were not printed; only bounded result categories and test status were retained.
## Known limitations
- Some event channels require permissions unavailable to a standard user.
- Provider names and event schemas vary by installed software.
- Reachability is not proof that an application protocol is healthy.
- Parser support does not authorize arbitrary file access.
## Security impact
Overbroad queries can disclose unrelated personal or security information. Every diagnostic must be locally authorized, scope-limited, and redacted before leaving Rust.
## Recommendation
Implement independent typed tools rather than a generic diagnostics command. Keep all Windows queries read-only and return partial results with explicit access boundaries.