feat(git-hooks): report checks slower than one second#238
Merged
Conversation
### Summary Time every check launched by the common parallel pre-commit runner with a monotonic clock. Emit a self-identifying stderr warning only when execution is strictly longer than one second, while preserving full coverage, concurrency, ordinary output, exit status, and cancellation behavior. Keep generated hooks portable by installing a native helper in Flakebox shells and invoking it by stable command name. ### Details Add a dependency-free Rust helper for Linux and macOS that runs each exported Bash check in its own process group, measures only worker execution, forwards cancellation without signal-publication races, and mirrors normal or signal termination. Report captured durations at millisecond precision, with near-boundary values kept consistent with the strict raw threshold, and safely frame grouped concurrent warnings after unterminated stderr. Remove the no-op sentinel, retain valid zero-hook generation, and silence routine worktree and unavailable-Semgrep messages. Preserve tracked unstaged changes without touching the user stash stack: encode the full-index binary worktree diff as a Git blob under a CAS-created unique private recovery ref, restore the indexed worktree for checks, apply that exact patch on exit, and CAS-delete the private ref only after successful restoration. In colocated Jujutsu checkouts, avoid Git index manipulation and check the current Jujutsu tree directly. Behavioral coverage includes boundaries and display rounding, byte-exact output, concurrency, queue exclusion, statuses and signals, repeated patch OIDs, preservation of pre-existing stashes, restoration on success/failure/interruption, Jujutsu behavior, and empty configurations. ### Reviews Independent architecture, maintainability, style, and reliability reviews passed. The original review fixed host-specific generated paths, signal publication/shutdown/re-raise races, concurrent warning framing, exact-output and cleanup coverage, documentation, and code organization. Follow-up review exposed unsafe shared-stash attribution, identical stash OIDs, and Jujutsu incompatibility; the final private blob-ref flow avoids refs/stash, uses compare-and-swap recovery refs, retains recoverable data on failure, and bypasses Git worktree mutation for Jujutsu. Millisecond upward rounding and quiet output coverage were also strengthened. No change-specific findings remain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR published by Tau
Summary
Time every check launched by Flakebox's common parallel pre-commit runner and warn when a check takes strictly longer than one second. The warning identifies the check and reports the monotonic elapsed duration at millisecond precision, without reducing check coverage or changing concurrency and failure semantics.
Details
A small dependency-free Rust helper wraps each exported Bash check, measures execution after worker scheduling, preserves ordinary output and exit status, and mirrors Unix cancellation through a dedicated child process group. Flakebox installs the host-native helper in development and lint shells while generated hooks use a stable command name, keeping tracked projections portable across Linux and macOS.
The runner retains every configured check, removes only the no-op sentinel, and remains valid for an empty hook set. Successful hooks are quiet apart from meaningful slow-check warnings. On normal Git checkouts, tracked unstaged changes are stored as a full-index binary patch under a private recovery ref and restored without touching the user's stash stack; colocated Jujutsu checkouts inspect their current tree without manipulating Git's index. Unavailable or unconfigured Semgrep checks also skip silently.
Generated projections and technical documentation are updated. Behavioral coverage exercises threshold boundaries and rounding, concurrent warnings, queue-time exclusion, byte-exact output, exit statuses, signals, aggregate failures, worktree restoration and interruption cleanup, preservation of older stashes, Jujutsu behavior, and empty configurations.
Review guidance
The signal-state lifecycle and worktree patch/recovery flow are the most important areas to inspect. The timing change intentionally does not add CI gating, staged-check skipping, or change Cargo.lock validation.