8000 feat(diagnostics): add the diagnostics crate foundation by norrietaylor · Pull Request #803 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

feat(diagnostics): add the diagnostics crate foundation - #803

Merged
norrietaylor merged 3 commits into
mainfrom
feat/diag-unit1-crate
Jul 17, 2026
Merged

norrietaylor merged 3 commits into
mainfrom
feat/diag-unit1-crate

Conversation

@norrietaylor
Copy link
Copy Markdown
Member

Summary

Unit 1 of the diagnostics spec (#802, tracking #801): the app-agnostic machinery every later unit consumes.

  • bundle — BundleWriter<W: BundleSink = tokio::fs::File>, one writer, two modes (R1.2/R1.3): create() writes an owner-only (0600) file with entries under {root}/ and flush+fsyncs on finish; stream() writes rootless through any blessed sink (DuplexStream — the daemon shape) and flush+half-closes. Both append the same manifest.json as the final entry at the mode-specific path. BundleSink is sealed; its Sync supertrait is load-bearing (async_tar::Builder requires it).
  • No-follow file collection (R1.4): add_file_tail opens with O_NOFOLLOW plus a descriptor fstat regular-file check — no stat-then-open TOCTOU window — and bounds the read with take(cap) against live-log growth.
  • redact — the fail-closed key-based engine, unchanged from the reference implementation (compound public-key regressions included) (R1.5).
  • listing — now returns a structured Listing { text, truncated }; an unreadable root is an Err the caller records in its manifest instead of an empty-looking listing; the cap appends an explicit truncation marker (R1.6).
  • capture (new) — command_capture(cmd, args, timeout): stdin closed, kill_on_drop, and a timed-out child is killed with its partial stdout/stderr returned inside a typed CaptureError::Timeout — partial evidence from a hung tool is still evidence (R1.7). Replaces three private near-duplicates in the reference tree.
  • Curated API (R1.8): crate-root pub use, #[non_exhaustive] on the manifest types. Manifest field is version (producer-agnostic — the daemon emits manifests too). The reference tree's unused walkdir dependency is dropped.

Test plan

  • 20 unit tests: redaction compound keys, file-vs-stream round-trip identical modulo root with manifest last at the exact mode-specific path, 0600 archive mode, symlink refused at open, tail-cap bounding, listing truncation marker + unreadable-root error, capture timeout kills the child and retains partial output
  • cargo clippy -p diagnostics --all-targets --all-features -- -D warnings clean
  • cargo fmt clean

Spec: docs/specs/10-spec-diagnostics/ (Unit 1, R1.1–R1.8).

🤖 Generated with Claude Code

App-agnostic machinery for diagnostic support bundles, Unit 1 of the
diagnostics spec (docs/specs/10-spec-diagnostics). BundleWriter is
generic over a sealed BundleSink (default tokio::fs::File): create()
writes an owner-only file with entries under a root directory and
fsyncs on finish; stream() writes rootless through any blessed sink
(DuplexStream for daemons) and half-closes on finish. Both modes append
the same manifest.json last. Collected files open with O_NOFOLLOW plus
a descriptor fstat check instead of a racy stat-then-open. The listing
API returns a structured result so an unreadable root is an error
rather than an empty listing, and the new capture module provides one
timeout-bounded subprocess helper that kills timed-out children and
returns their partial output inside a typed error.

Refs: #801

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai
coderabbitai Bot commented Jul 17, 2026 •
Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76402dcb-e250-4c14-805d-c6eb7953871b

📥 Commits

Reviewing files that changed from the base of the PR and between 11daebe and 26d7c79.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • Cargo.toml
  • crates/diagnostics/Cargo.toml
  • crates/diagnostics/src/bundle.rs
  • crates/diagnostics/src/capture.rs
  • crates/diagnostics/src/lib.rs
  • crates/diagnostics/src/listing.rs
  • crates/diagnostics/src/manifest.rs
  • crates/diagnostics/src/redact.rs

Comment @coderabbitai help to get the list of available commands.

Replaces the hand-rolled stack-recursive walk with walkdir (already a
workspace dependency): a pathologically deep state dir can no longer
blow the collector's stack, symlinks stay unfollowed, and sibling
ordering stays sorted. Truncation is now exact — a listing that ends
precisely at the cap is complete, not truncated.

Refs: #801

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@norrietaylor
norrietaylor marked this pull request as ready for review July 17, 2026 17:17
@twitchyliquid64 twitchyliquid64 left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YESSSSS

@norrietaylor
norrietaylor merged commit 2d0e5e6 into main Jul 17, 2026
28 checks passed
@norrietaylor
norrietaylor deleted the feat/diag-unit1-crate branch July 17, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0