Skip to content

Soft delete Astra habits through the habit command - #611

Merged
thomasluizon merged 2 commits into
mainfrom
fix/ticket-781-astra-soft-delete
Sep 27, 2026
Merged

thomasluizon merged 2 commits into
mainfrom
fix/ticket-781-astra-soft-delete

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

Fixes thomasluizon/orbit-tickets#781.

Change

  • Route DeleteHabitTool through DeleteHabitCommand. The command enforces ownership, runs validation, soft deletes the full subtree, updates streaks, and invalidates caches. The tool keeps its existing success fields and lookup error response.
  • Build a bulk created parent and its children before adding any of them. This removes the remaining direct Habits.Remove call from normal habit flows when child validation fails.
  • Add tool parity and scheduler regression coverage in DeleteHabitToolTests.cs and SchedulerProjectionTests.cs. Add failed child validation coverage in BulkCreateHabitsCommandHandlerTests.cs.

Assumptions

  • Keep the tool's current not found response from its ownership scoped lookup; rejected replacing that caller response with the command's generic failure text.

Test evidence

  • Before changing the test or implementation, dotnet test tests/Orbit.Application.Tests --filter 'FullyQualifiedName~DeleteHabitToolTests' -v normal passed all 5 existing tests, including SuccessfulDelete_ReturnsSuccessAndRemovesHabit, with the hard delete present.
  • With the hard delete still present, dotnet test tests/Orbit.Application.Tests --filter 'FullyQualifiedName~DeleteHabitToolTests.SuccessfulDelete_ReturnsSuccessAndSoftDeletesHabit' --no-restore -v quiet failed because the habit was not soft deleted.
  • With the hard delete still present, dotnet test tests/Orbit.Infrastructure.Tests --filter 'FullyQualifiedName~ReminderTick_AstraDeleteAndReplacement_RefreshesCandidates' -v quiet failed: the scheduler sent Old reminder and did not send New reminder.
  • With the old bulk create removal present, dotnet test tests/Orbit.Application.Tests --filter 'FullyQualifiedName~Handle_InvalidLaterSubHabit_DoesNotAddAnyPartOfItem' -v quiet failed because the parent and first child were added before the later child failed validation.
  • After the changes, dotnet test tests/Orbit.Application.Tests --filter 'FullyQualifiedName~DeleteHabitToolTests|FullyQualifiedName~BulkCreateHabitsCommandHandlerTests' -v quiet passed 21 tests. The scheduler regression passed as well.
  • dotnet build Orbit.slnx -v quiet passed with 0 errors. dotnet test -v quiet passed all 6,751 tests. git grep for habitRepository.Remove and Habits.Remove under src and tests found no matches.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes in the two-commit PR against main:

  • Astra deletion: DeleteHabitTool delegates to DeleteHabitCommand, preserving its lookup response while using the existing soft deletion, cascade, streak and cache behavior.
  • Bulk creation: Parent and children are built before repository insertion so a failed child does not leave part of the item staged.
  • Regression coverage: Tool, failed child creation and reminder scheduler tests exercise the affected paths.

Pullfrog  | View workflow run | Using GPT Sol | 𝕏

@sonarqubecloud

Copy link
Copy Markdown

@thomasluizon
thomasluizon merged commit b953e5d into main Sep 27, 2026
25 checks passed
@thomasluizon
thomasluizon deleted the fix/ticket-781-astra-soft-delete branch September 27, 2026 04:10
thomasluizon added a commit that referenced this pull request Sep 27, 2026
* Soft delete Astra habits through the habit command (#611)

* Route Astra habit deletion through soft delete command

* Avoid direct habit removal during bulk create validation

(cherry picked from commit b953e5d)

* fix: increment habit reminder probe atomically (#612)

(cherry picked from commit 43d847e)
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.

1 participant