Skip to content

fix(dry-run): gate explicit-ID mutation paths behind resolveDryRun#219

Merged
gfargo-horizon-agent[bot] merged 1 commit into
mainfrom
agent/localpress-928-localpress-190-dry-run-reaches-live-muta
Jul 17, 2026
Merged

fix(dry-run): gate explicit-ID mutation paths behind resolveDryRun#219
gfargo-horizon-agent[bot] merged 1 commit into
mainfrom
agent/localpress-928-localpress-190-dry-run-reaches-live-muta

Conversation

@gfargo-horizon-agent

@gfargo-horizon-agent gfargo-horizon-agent Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Every mutating command's explicit-ID path now routes through the shared resolveDryRun(parentOpts, default) helper, so a global --dry-run can no longer reach a live WordPress or SQLite mutation.

Why

Closes #190
Plane: OSS-928

--dry-run was silently ignored on several commands' explicit-ID paths — optimize 123 --dry-run, convert, resize, remove-bg, regenerate 123 --dry-run, undo --snapshot 17 --dry-run, and posts create --dry-run all executed live mutations despite the flag. rename --dry-run also wrote a local SQLite row before its dry-run guard. The existing honesty test only grepped for loose substrings (dryRun, parentOpts.apply), which any bulk-only or unrelated reference could satisfy, so it passed 13/13 while these gaps existed.

How

  • optimize.ts, undo.ts: replaced ad hoc isBulk && !parentOpts.apply checks with resolveDryRun(parentOpts, isBulk).
  • convert.ts, resize.ts, remove-bg.ts: added a dry-run gate (none existed before) ahead of the sharp preload / rembg check, so a preview doesn't even prompt to install native deps.
  • regenerate.ts: unified the previously --all-only dry-run check into one gate covering explicit IDs too; the --all id-listing (read-only) still runs first.
  • posts.ts: added the missing dry-run gate to posts create (update/delete already had it).
  • rename.ts: moved the db.upsertAttachment call inside the existing if (!dryRun) guard so a dry-run no longer writes a local row.
  • vision.ts, import.ts: routed through resolveDryRun instead of checking parentOpts.apply / parentOpts.dryRun directly — same defect class (an explicit --dry-run was silently ignored when combined with other flags).
  • dry-run-honesty.test.ts: now requires the literal resolveDryRun( call (no more loose substring matching) and covers convert/resize/remove-bg/references in addition to the existing commands.
  • Added dry-run-honesty-behavior.test.ts: behavioral tests that actually invoke posts create --dry-run (asserts fetch is never called) and rename --dry-run (asserts no SQLite row is written).

Testing

  • build passes
  • tests pass / added (bun test test/unit/ — 622 pass, 0 fail)
  • lint clean (bun run lint)
  • typecheck clean (bun run typecheck)
  • CI: pending

Closes #190

--dry-run reached live mutations in optimize/convert/resize/remove-bg/
regenerate/undo/posts-create because explicit-ID paths bypassed the
shared resolveDryRun helper (or, for vision/import, checked --apply or
--dry-run directly instead of routing through it). rename also wrote a
local SQLite row before its dry-run guard.

Also strengthens dry-run-honesty.test.ts to require the literal
resolveDryRun( call (instead of loose substrings like 'dryRun' or
'parentOpts.apply') and extends coverage to convert/resize/remove-bg/
references, plus adds behavioral tests asserting posts create and
rename issue no live mutation under --dry-run.

@gfargo-horizon-agent gfargo-horizon-agent Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔎 Agent review (sonnet) — LGTM

REVIEW: LGTM
RESOLVES: full

Every gap listed in OSS-928 (optimize, convert, resize, remove-bg, regenerate, undo, posts create, rename) is now routed through resolveDryRun exactly as the plan specified, with the honesty test tightened to require the literal call and new behavioral tests for the two highest-risk cases (posts create, rename). Typecheck, lint, and the full unit suite (622 pass) all succeed, and the diff stays tightly scoped to the defect class with no unrelated changes.

@gfargo-horizon-agent
gfargo-horizon-agent Bot merged commit af0c39d into main Jul 17, 2026
6 checks passed
@gfargo-horizon-agent
gfargo-horizon-agent Bot deleted the agent/localpress-928-localpress-190-dry-run-reaches-live-muta branch July 17, 2026 22:17
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.

--dry-run reaches live mutations in optimize/convert/resize/remove-bg/regenerate/undo/posts-create

0 participants