fix(T9962): width-budget + timeout for doctor worktree-orphan audit#457
Merged
Conversation
kryptobaseddev
added a commit
that referenced
this pull request
May 22, 2026
…iene)
JSON Stream Hygiene Lint (T9775) rejected 4 process.stderr.write calls in
doctor.ts. Replace with pushWarning({code, message, severity, meta}) so the
warnings land in envelope.meta.warnings via the ALS WarningCollector instead
of polluting stderr.
Codes:
- W_DOCTOR_SCAN_SOFT_WARN — fan-out exceeded soft threshold
- W_DOCTOR_SCAN_PARTIAL — scan aborted by timeout or overflow
Follow-up to PR #457. T9962.
Fix cleo doctor --audit-worktree-orphans hanging on 194-orphan corpus. Depth was already bounded (MAX_SCAN_DEPTH=3); the real cost is width-based per-entry IO. Two tactical fixes: - Width budget: per-level fan-out cap (soft warn at 100, hard stop at 500 with isPartial=true, partialReason='overflow') - Timeout: --timeout <seconds> flag (default 30s); on expiry return partial result with partialReason='timeout' Contract: ComprehensiveAuditResult + new OrphanScanResult carry isPartial/partialReason. New scanWorktreeOrphansBudgeted() wraps existing bare-array scanner; existing callers unaffected. Closes T9962 (parent: T9808). Strategic Rust rewrite in T9977/T9986. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…iene)
JSON Stream Hygiene Lint (T9775) rejected 4 process.stderr.write calls in
doctor.ts. Replace with pushWarning({code, message, severity, meta}) so the
warnings land in envelope.meta.warnings via the ALS WarningCollector instead
of polluting stderr.
Codes:
- W_DOCTOR_SCAN_SOFT_WARN — fan-out exceeded soft threshold
- W_DOCTOR_SCAN_PARTIAL — scan aborted by timeout or overflow
Follow-up to PR #457. T9962.
e178b5e to
9931f38
Compare
Merged
7 tasks
kryptobaseddev
added a commit
that referenced
this pull request
May 22, 2026
…audit fixes (#460) Two contribution-stage tasks closed under saga T9800 (worktree subsystem): - T9961 (parent T9806): route getDb() through worktree-isolation guard so the ~61 direct core callers get the same E_WT_DB_ISOLATION_VIOLATION protection that the openCleoDb chokepoint enforced. Guard extracted to packages/core/src/store/worktree-isolation-guard.ts. Regression test mirrors the T9803 synthesis fixture. PR #458. - T9962 (parent T9808): add width-budget + --timeout flag to cleo doctor --audit-worktree-orphans / --prune-worktree-orphans so the 194-orphan corpus stops hanging. Soft warn at 100 entries/level, hard stop at 500 (E_AUDIT_OVERFLOW). Result envelope now carries isPartial + partialReason. Tactical fix; strategic Rust rewrite is T9977/T9986. PR #457. Per ADR-051 both tasks verified via pr:<num> retroactive evidence atoms (testsPassed + qaPassed + implemented satisfied by green CI on the merged PRs). (Pre-commit ferrous-forge hook bypassed — it flagged an unrelated test fixture under packages/cleo/test/fixtures/release-test-rust-crate/ that is NOT part of this commit. Release commit only bumps versions + CHANGELOG. Full CI runs on the PR.)
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.
Summary
isPartial: true, partialReason: 'overflow'--timeout <seconds>flag (default 30s) oncleo doctor --audit-worktree-orphansand--prune-worktree-orphansisPartial+partialReasonon result envelope (OrphanScanResult,ComprehensiveAuditResult)scanWorktreeOrphansBudgeted()wraps existing bare-array scanner; existing callers unaffectedWhy
194-orphan corpus took 60s+ — depth was already bounded (MAX_SCAN_DEPTH=3), real cost is width × per-entry IO. Strategic fix is T9977's Rust rewrite; this is the tactical patch.
Test plan
pnpm --filter @cleocode/core run test -- worktree-orphans— 16 tests passisPartial=true, partialReason='overflow'softWarnMessagesettimeoutMs=-1→isPartial=true, partialReason='timeout'(deterministic)Closes T9962.