Skip to content

fix(import): clarify conflict diff behavior (#359)#362

Merged
luongnv89 merged 1 commit into
mainfrom
feat/359-import-force-diff
Jul 11, 2026
Merged

fix(import): clarify conflict diff behavior (#359)#362
luongnv89 merged 1 commit into
mainfrom
feat/359-import-force-diff

Conversation

@luongnv89

Copy link
Copy Markdown
Owner

Closes #359
Closes #360

Summary

Make import conflict behavior explicit and testable: asm import --force --diff now fails before reading or modifying a manifest, while the interactive and non-interactive conflict display paths have focused regression coverage.

Approach

Selected the minimum-risk validation approach. --force remains an unconditional overwrite mode with no conflict construction, and --diff remains a conflict-inspection mode; combining them is rejected as invalid CLI usage rather than changing importer contracts or silently ignoring --diff. The prompt and non-interactive renderer were extracted with injectable I/O seams so their existing behavior can be tested without a real TTY.

Decision Record

  • Root cause: Force imports bypass conflict construction, so the later non-interactive diff loop receives no conflict records and silently renders nothing; the prompt and rendering glue were nested inside cmdImport, leaving no practical unit-test seam.
  • Options considered: Option 1 — document that --diff is ignored with --force; Option 2 — reject the incompatible flags before import work; Option 3 — construct reporting conflicts during forced overwrites.
  • Options rejected: Option 1 preserves a surprising silent no-op; Option 3 changes importer behavior and risks rendering only after destructive writes.
  • Selected option: Option 2 — reject the incompatible flags and extract focused conflict UI seams.
  • Residual risk: A real pseudoterminal interaction is not exercised; prompt parsing, rendering, and callbacks are covered through the same functions used by cmdImport.

Analyzed at: feat/359-import-force-diff @ 1cdee2b (2026-07-11)

Changes

File Change
src/cli.ts Reject --force --diff before manifest I/O, document the incompatibility, and expose testable prompt/diff helpers.
src/cli.test.ts Cover k/u/s/d prompt choices, newer/older labels, interactive diff display, real non-interactive conflict diff output, and early incompatible-flag rejection.

Test Results

  • Unit/integration tests: 1,895 passed (npm test)
  • Focused CLI tests: 364 passed
  • Typecheck: passed
  • Build: passed
  • E2e node tests: passed in pre-push hook
  • Formatting: passed
  • QA cycles: 2

Acceptance Criteria Verification

Criterion Status Evidence
--force --diff no longer silently renders nothing pass CLI integration: import > import rejects --force with --diff before reading the manifest
Rejection occurs before import side effects pass The regression uses a nonexistent manifest and asserts the incompatibility error precedes file reading.
k/u/s prompt choices map to keep-local/use-imported/skip pass import conflict prompt > maps ... parameterized tests in src/cli.test.ts
d prints a diff and re-prompts pass import conflict prompt > shows a diff for d, then prompts again for a resolution
Newer/older sides are marked correctly pass import conflict prompt > marks the ... side newer and the other side older
Non-interactive --diff prints actual conflict output without overwriting pass CLI integration: import > import --diff prints a collected conflict in non-interactive mode

@luongnv89
luongnv89 merged commit 1da746e into main Jul 11, 2026
13 checks passed
@luongnv89
luongnv89 deleted the feat/359-import-force-diff branch July 11, 2026 06:22
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.

test: cover interactive import conflict-resolution prompt (cli.ts) import: --diff renders nothing when combined with --force

1 participant