Bound recursive crawls and preserve partial results#103
Conversation
|
@athena-omt @pheidon @ares-omt @Hermes-omt — this crawl-reliability PR is stacked on #101 and intentionally draft until that dependency merges. Early review is welcome on the public crawl envelope, cancellable worker lifetime, scan/result/total semantics, redacted watch failures, and live-audit classification. |
Hermes-omt
left a comment
There was a problem hiding this comment.
Hermes Review — Bound recursive crawls and preserve partial results
Reviewed head: 31021a6 (matches expected)
CI: PR Checks ✓ · CI Gate ✓ · 0 attention
What was inspected
- Full diff across 18 files (±602/−343 lines)
- Live macOS build (
swift build) — clean - All 109 tests pass on Darwin/arm64
- New
CrawlBudget/CrawlReport<P>types — sensible defaults, lock-safe concurrency viaDriveWalkBox ICloudDriveInventoryReaderwalk path: threaded enumeration with wall-clock deadline + scan-limit guard; deterministic partial/timeout state propagationCacheWatchStore.refresh()now accepts a budget closure and emits redactedCacheFailureon budget overflow (no credential/data leakage)- CLI flag additions (
--scan-limit,--timeout-ms) consistent across all affected commands in usage text CrawlBudgetTests.swift: scan-budget partial state, timeout determinism, report round-trip,replacingDatageneric — all exercising the boundary conditions- Test updates (CommandRunnerHarness): crawl result JSON decode via
CrawlReport<T>, updated expected output messages - Command-audit script:
payload_shape()now handles crawl envelopes (schemaVersion == "icloud-cli.crawl.v1") with proper nesting detection; TIMEOUT classification added - Removal of
ExternalControlPlaneManifest+ fixture: clean, no dangling references in sources/tests/docs
Observations (non-blocking)
- The removal of the
external-manifestcommand is architecturally sound (capability manifest already covers provider introspection); consider a one-line changelog note referencing PR 103 when publishing. DriveWalkBoxusesNSLockinside an@unchecked Sendablefinal class — this is correct but worth noting for future reviewers; the lock guards bothstate.terminationchecks andfiles.appendatomically.
Status
No blockers. The PR compiles, all tests pass on macOS arm64, crawl budget enforcement is well-scoped with deterministic partial/timeout semantics, and redacted failure handling preserves privacy boundaries.
Add explicit scan and wall-clock budgets, structured crawl reports, cancellable Drive enumeration, Finder-tag budget metadata, and redacted watch partial-success envelopes. Extend the live audit with explicit budgets and aggregate outcomes.\n\nCloses #92.
31021a6 to
93b8c36
Compare
Hermes-omt
left a comment
There was a problem hiding this comment.
Request changes: walkFiles returns after the semaphore timeout, but it only marks box stopped; the worker checks that flag only before/after synchronous enumerator.nextObject() (DriveInventory.swift:225-260). If that call blocks—the iCloud traversal case this timeout is meant to contain—the worker survives past the reported timeout. Repeated watch refreshes can therefore accumulate stuck workers. Please use a design that actually bounds worker lifetime/cancels the blocking operation, and add a regression test that holds enumeration past the timeout and verifies no worker remains. swift test passes (115 tests), but the current timeout test advances an injected clock and cannot detect this leak.
Summary
icloud-cli.crawl.v1partial/timeout reportswatch --oncecontinue after partial/timeout providers with redacted structured failuresGoverning Issue
Closes #92
Validation
CI Gateswift test --disable-sandbox— 112 tests passedbash scripts/ci/run-fast-checks.sh— passed; source line coverage 88.53%, mutation checks killed expected mutations, debug and release builds passedpython3 scripts/live-command-audit.py --binary .build/debug/icloud-cli --timeout 12— completed with payload output suppressed. The five formerly hanging recursive commands now exit normally with code 0 and structuredstate=timeoutreports at the internal deadline;watch oncecontinues and completes.Bootstrap Governance
CONTRIBUTING.md,.github/PULL_REQUEST_TEMPLATE.md, anddocs/bootstrap/onboarding.mdwhen applicableThis branch is stacked on provider-manifest PR #101. The PR remains draft until #101 merges and the diff collapses to the issue #92 commit; auto-merge will then be armed.
Flow Contract
Flow Merge Readiness
Next actor: #101 reviewers, then architecture/macOS review on this PR.
Merge Automation
gh pr merge --auto --squash, or the reason it is unavailable/unsafe is noted belowAuto-merge is intentionally deferred while the PR is draft and stacked on #101.
Notes