Repository navigation
Validate bulk create previews before approval - #703
Merged
thomasluizon merged 2 commits intoOct 5, 2026
Merged
Conversation
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed bulk-create preview validation, approval enforcement, revision recovery, and append-only contract compatibility across all changed files.
- Preview validation: Uses the existing bulk parser and command validator to attach item-specific errors and expose missing invalid fields for editing.
- Approval enforcement: Rechecks validator eligibility before confirmation and execution, including pending operations without stored preview fingerprints.
- Contract compatibility: Adds optional
validationErrorswhile preserving valid-item serialization and fingerprints; checked the sibling consumer's existing pending-item schema. - Regression coverage: All 90 focused preview, revision, controller, and contract tests passed locally. The full test suite was not rerun during this review.
gpt-6.1-sol | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




An invalid bulk create batch previously showed a clean pending preview and failed after approval. The preview now carries each item's validator errors, and confirmation and execution reject the batch until its invalid items are corrected or removed.
Closes thomasluizon/orbit-tickets#1220
Changes
PendingOperationChangePreviewer.csbuilds the command with the existing bulk tool parser and runsBulkCreateHabitsCommandValidator. It maps failures to the matching item and offers missing invalid fields for editing. Batch-level failures apply to every item.BulkCreateHabitsTool.cspermits the preview parser to retain an empty title so the existing validator can report it. Execution parsing keeps its existing behavior. The quantity default from #1215 is not changed here.AgentContracts.csappends optionalvalidationErrorsentries containingfield,errorCode, anderror. The field is omitted for valid items, preserving their serialized shape and preview fingerprint.src/Orbit.Api/openapi.jsoncontains the generated optional contract.PendingOperationRevisionService.csrecomputes approval eligibility.AiController.cschecks it before issuing a confirmation token and before dispatching execution, including requests without a stored preview fingerprint.This keeps validation rules in the existing validator and preserves the append-only response contract.
Assumptions
validationErrorslist rather than a single error, preserving every failure returned by the validator.Habits[1].FrequencyQuantity, so errors identify the editable preview field.Test evidence
Unchanged test with the preview defect present:
env -u LANG LC_ALL=en_US.UTF-8 dotnet test tests/Orbit.Application.Tests --filter FullyQualifiedName~PendingOperationChangePreviewerTests.PreviewAsync_Create_UsesStableInputIndexes --verbosity minimalPassed: 1 test. It did not exercise an invalid item.
New regression with the defect still present:
env -u LANG LC_ALL=en_US.UTF-8 dotnet test tests/Orbit.Application.Tests --filter FullyQualifiedName~PendingOperationChangePreviewerTests.PreviewAsync_Create_InvalidItemCarriesValidatorFieldError --verbosity minimalFailed: 1 test, because the second item's serialized preview lacked
validationErrors. The test uses the real parser and validator, not a mocked validation response. FluentValidation 12.1.1 returnedPropertyName = Habits[1].FrequencyQuantityandErrorCode = GreaterThanValidator; the passing test also verifies that the preview'serrorequals the real failure'sErrorMessage. These are the external fields the implementation reads, and this command re-derives their values.The unchanged
AiControllerTests.ConfirmPendingOperation_ReturnsConfirmationTokenalso passed before the approval fix as part of the first focused run. The stronger approval regression ran before that fix:env -u LANG LC_ALL=en_US.UTF-8 dotnet test tests/Orbit.Infrastructure.Tests --filter FullyQualifiedName~AiControllerTests.PendingOperation_InvalidBulkCreateCannotConfirmOrExecute --verbosity minimalFailed: all 4 cases returned
OkObjectResultinstead of rejecting the invalid batch. Cases cover confirmation and execution, with and without a stored fingerprint.After both fixes:
Passed: all 90 focused tests, including both regressions and valid approval paths.
Final verification:
env -u LANG LC_ALL=en_US.UTF-8 dotnet build Orbit.slnx env -u LANG LC_ALL=en_US.UTF-8 dotnet testBuild: 0 errors. Tests: 9,395 passed, 0 failed, 0 skipped across all four projects. Existing build warnings remain. Git hooks passed, and changed C# files contain no bare narration comments.