Skip to content

fix(wiretap): avoid creating archives during dry runs - #195

Merged
steipete merged 2 commits into
mainfrom
sweep/discrawl-wiretap-dry-run
Sep 4, 2026
Merged

fix(wiretap): avoid creating archives during dry runs#195
steipete merged 2 commits into
mainfrom
sweep/discrawl-wiretap-dry-run

Conversation

@steipete

@steipete steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Wiretap opened and migrated a writable archive before parsing --dry-run. A preview consequently created a database, lock files and runtime directories; even a preview without coverage failed if an unrelated archive was malformed.

Parse flags after loading configuration, then select storage for the requested operation. Dry runs without statistics do not open the archive. --dry-run --stats reads an existing archive without migrations and reports empty coverage when absent. Actual imports keep the existing writer lock, and explicit --dry-run=false still imports. This covers wiretap, tap, cache-import, and watched previews.

SQLite read-only coverage can create WAL/SHM sidecars for an existing archive. Existing database contents remain unchanged, and normal SQLite locking keeps current WAL data visible. The command documentation records this limit.

Validation: full CLI package tests, focused Wiretap race tests, golangci-lint, module tidy/verification, vet, staticcheck, gosec, deadcode, govulncheck and docs build passed. Full independent P0–P2 review found no actionable issue. The latest main is integrated by a normal merge; the final tree exactly matches the combined source already tested with PR #190. New-head CI is pending at bf1599ecb1877f47991a9cb2d29fc2d6d69e9d7c.

Actual built CLI proof used synthetic cache files, isolated configuration, and real SQLite; no Discord credentials or network access. Eighteen invocations compared main with this candidate:

Command/scenario Before After
Each of wiretap, tap, cache-import, with and without --stats Created missing archive/runtime directories One previewed message; no new files or directories; empty coverage when requested
Existing archive, --dry-run --stats Writer initialization Coverage reports one stored message; database, config, lock and cache file hashes unchanged; only SQLite WAL/SHM sidecars appear
Malformed existing archive, no stats ping sqlite: file is not a database (26) Preview succeeds; archive bytes unchanged
--dry-run --dry-run=false Imports Still imports and creates the archive
--dry-run --stats --watch-every 1s Writer initialization Three samples with zero stored coverage; no filesystem changes; SIGTERM exits 0

The new regression tests first failed on the old dispatch path for all six alias/stat combinations and for malformed-archive previews, then passed with the fix. No schema, dependency, runtime floor or release change.

Curated actual CLI output at eecbab545664bea6a95d7ef47ec927f7aae53b8f for discrawl --config fixture.toml --json wiretap --path fixture-cache --dry-run --stats (selected fields; synthetic paths and timestamps omitted):

{
  "exit": 0,
  "import": {
    "files_scanned": 1,
    "messages": 1,
    "dry_run": true
  },
  "coverage": {
    "guilds": [],
    "totals": {
      "message_count": 0
    }
  }
}

Before: the same command creates archive/archive.db, writer-lock files, runtime-cache/ and runtime-logs/. After: a full recursive file/hash snapshot contains only the original fixture config and cache payload; all three runtime/archive directories remain absent. The watched invocation prints three such samples, with zero deltas after the first, and exits 0 on SIGTERM.

Integration with the landed retry fix preserves the original five-file dry-run change. The combined tree passes the CLI, importer and store suites plus the same 18-command actual dry-run proof. A fresh full P0–P2 review of the integrated candidate found no actionable issues.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 7:39 AM ET / 11:39 UTC.

ClawSweeper review

What this changes

The PR defers Wiretap archive setup until after flag parsing so dry-run previews do not create archives or runtime directories, while optional statistics use read-only archive access.

Merge readiness

Ready for maintainer review

The focused fix is correct and remains necessary because current main still initializes writable storage before Wiretap parses dry-run flags. Submitted built-CLI evidence and the new regression matrix support normal maintainer review.

Priority: P2
Reviewed head: eecbab545664bea6a95d7ef47ec927f7aae53b8f

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, well-covered fix with direct after-fix CLI proof and no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies an after-fix terminal trace from a built CLI and real SQLite: the changed dispatch and storage-selection path scans a synthetic cache, returns dry-run output, and leaves new archive and runtime directories absent.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies an after-fix terminal trace from a built CLI and real SQLite: the changed dispatch and storage-selection path scans a synthetic cache, returns dry-run output, and leaves new archive and runtime directories absent.
Evidence reviewed 5 items Introduced storage selection: The command dispatcher now loads configuration without opening the archive, and runWiretap selects no store for ordinary dry runs, read-only storage for dry-run statistics, and the existing locked writer for imports.
Read-only behavior: Read-only archive opening validates the current schema without invoking the writable migration path, which supports the stated dry-run boundary.
Regression coverage: The added tests cover all three command aliases with and without statistics, existing coverage, explicit false dry-run, and malformed archives that a no-stat preview must not open.
Findings None None.
Security None None.

How this fits together

Wiretap scans local Discord desktop cache artifacts and imports discovered message metadata into a local archive. The CLI layer parses options, selects read-only or writable storage, then returns import and coverage results as terminal or JSON output.

flowchart LR
  A[Desktop cache files] --> B[Wiretap command]
  C[Command flags] --> B
  B --> D{Requested mode}
  D -->|Dry run| E[Preview import]
  D -->|Dry run with statistics| F[Read-only archive coverage]
  D -->|Import| G[Writable archive]
  E --> H[Terminal or JSON output]
  F --> H
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Diff scope 5 files: 2 production, 1 test, 2 documentation/release-note files The patch is narrowly scoped to Wiretap command setup and its user contract.
Regression matrix 6 alias/stat combinations + 3 focused cases The tests cover aliases, absent and existing archives, explicit false dry-run, and malformed-archive isolation.

Technical review

Best possible solution:

Merge the deferred storage-selection path so all Wiretap aliases preserve dry-run preview semantics while retaining explicit read-only coverage for existing archives.

Do we have a high-confidence way to reproduce the issue?

Yes. The previous dispatcher unconditionally opened writable storage before flag parsing, and the submitted built-CLI comparison exercises the affected dry-run path against current main and the candidate.

Is this the best way to solve the issue?

Yes. Moving storage selection after parsing is the narrowest solution: ordinary previews use no archive, statistics use the existing read-only path, and real imports retain the established writer lock.

AGENTS.md: not found in the target repository.

Codex review notes: model internal, reasoning high; reviewed against b262f754180d.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a bounded local CLI preview side effect without evidence of urgent widespread impact.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies an after-fix terminal trace from a built CLI and real SQLite: the changed dispatch and storage-selection path scans a synthetic cache, returns dry-run output, and leaves new archive and runtime directories absent.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies an after-fix terminal trace from a built CLI and real SQLite: the changed dispatch and storage-selection path scans a synthetic cache, returns dry-run output, and leaves new archive and runtime directories absent.

Evidence

What I checked:

  • Introduced storage selection: The command dispatcher now loads configuration without opening the archive, and runWiretap selects no store for ordinary dry runs, read-only storage for dry-run statistics, and the existing locked writer for imports. (internal/cli/admin_commands.go:461, eecbab545664)
  • Read-only behavior: Read-only archive opening validates the current schema without invoking the writable migration path, which supports the stated dry-run boundary. (internal/store/store.go:148, b262f754180d)
  • Regression coverage: The added tests cover all three command aliases with and without statistics, existing coverage, explicit false dry-run, and malformed archives that a no-stat preview must not open. (internal/cli/wiretap_dry_run_test.go:31, eecbab545664)
  • Real behavior proof: The PR body provides an after-fix terminal trace from a built CLI using synthetic cache files and real SQLite: dry-run statistics scan one message, report empty coverage when no archive exists, and leave archive/runtime directories absent. (eecbab545664)
  • Feature history: Prior merged Wiretap coverage work appears in commit 454d1d9, establishing relevant history for the affected command path. (internal/cli/admin_commands.go:409, 454d1d97252e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-04T11:35:01.983Z sha eecbab5 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(wiretap): avoid creating archives during dry runs This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit 292602a into main Sep 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant