Skip to content

fix(init): wrap _step_memory_dir / _step_settings filesystem ops in fail_step (#664)#745

Merged
memtomem merged 2 commits intomainfrom
fix/664-step-fs-failures-fail-step
May 3, 2026
Merged

fix(init): wrap _step_memory_dir / _step_settings filesystem ops in fail_step (#664)#745
memtomem merged 2 commits intomainfrom
fix/664-step-fs-failures-fail-step

Conversation

@pandas-studio
Copy link
Copy Markdown
Collaborator

Summary

  • Both _step_memory_dir and _step_settings performed filesystem side effects (mkdir, write_text) without try/except. A read-only project root, full disk, or PermissionError would crash mm init with an uncaught stack trace and force the user to restart from the top.
  • Wraps the failing ops in the standard fail_step retry/back/quit pattern adopted by the Ollama branch in feat(wizard): explicit guardrails for failed init steps (closes #626) #661 — symmetric counterpart to that fix.
  • Pins the new behavior with six tests (three per step) shaped after the existing TestStepEmbeddingOllamaGuards: q cancels via WizardCancel, r retries the inner op without re-prompting earlier inputs, and a failed op does NOT silently advance to the next step.

The nested try is required because fail_step raises StepRetry from inside the except OSError handler — a sibling except StepRetry on the same statement would not catch it. Comment in code explains this.

Closes #664. Out-of-scope per the issue body: the warn-and-save patterns in _step_embedding (ONNX/Ollama/OpenAI client missing) and _step_language (kiwipiepy missing) are documented UX, not bugs.

Test plan

  • uv run pytest packages/memtomem/tests/test_init_cmd.py -k "TestStepMemoryDirFsGuards or TestStepSettingsFsGuards" — 6 passed
  • uv run pytest -m "not ollama" — 3997 passed, 7 skipped
  • uv run ruff check packages/memtomem/src && uv run ruff format --check packages/memtomem/src — clean
  • uv run mypy packages/memtomem/src/memtomem/cli/init_cmd.py — no issues

🤖 Generated with Claude Code

@memtomem memtomem force-pushed the fix/664-step-fs-failures-fail-step branch from a837835 to b07af36 Compare May 3, 2026 10:27
memtomem added a commit that referenced this pull request May 3, 2026
…FsGuards

HOME isn't honored by Path.home() on Windows (it resolves USERPROFILE
instead), so the three new TestStepSettingsFsGuards tests in #745 hit
the "~/.claude/ missing — Skipping" short-circuit before the guarded
write_text was reached, masking the assertions. Patch Path.home
directly via classmethod so the test runs the same on every platform.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
memtomem and others added 2 commits May 3, 2026 19:35
…ail_step (closes #664)

Both wizard steps performed filesystem side effects (`mkdir`, `write_text`)
without try/except. A read-only project root, full disk, or denied
permission would crash `mm init` mid-step with an uncaught Python stack
trace and force the user to restart from the top.

Mirror the Ollama-branch fail_step adoption from #661 so failures here
surface the standard retry/back/quit recovery path. The nested try is
required because `fail_step` raises `StepRetry` from inside the
`except OSError` handler — a sibling `except StepRetry` on the same
statement would not catch it.

Adds three tests per step pinning (a) `q` raises `WizardCancel`,
(b) `r` retries the failing op without re-prompting earlier inputs,
and (c) the wizard does NOT silently advance to the next step on
failure — the same invariant shape as the existing `_step_embedding`
guards in `TestStepEmbeddingOllamaGuards`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…FsGuards

HOME isn't honored by Path.home() on Windows (it resolves USERPROFILE
instead), so the three new TestStepSettingsFsGuards tests in #745 hit
the "~/.claude/ missing — Skipping" short-circuit before the guarded
write_text was reached, masking the assertions. Patch Path.home
directly via classmethod so the test runs the same on every platform.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@memtomem memtomem force-pushed the fix/664-step-fs-failures-fail-step branch from b07af36 to 553504b Compare May 3, 2026 10:35
Copy link
Copy Markdown
Owner

@memtomem memtomem left a comment

Choose a reason for hiding this comment

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

LGTM

@memtomem memtomem merged commit f851377 into main May 3, 2026
9 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wizard step audit: _step_memory_dir and _step_settings crash on filesystem failure (refs #626)

2 participants