feat(finance): add bulk MB Head force-unvalidate and regenerate lifecycle pipeline - #177
Merged
Merged
Conversation
Add the domain/infrastructure foundation for the Bulk MB Head Regenerate feature: Super Admin can re-trigger the VALIDATED->DRAFT->SUBMITTED-> VALIDATED lifecycle across many stuck-in-VALIDATED MB Head recipes at once, so downstream cost_product_master/cost_route_*/CAPP/CPP/MB Spin data regenerates after a formula/calc fix. - domain/mbhead: add canForceUnvalidate gate (VALIDATED-only, kept out of allowedTransitions since it collapses the normal 2-step unlock flow) and entity.ForceUnvalidate(reason), which unconditionally clears any lock/unlock-request state. - infrastructure/postgres: implement ForceUnvalidateTransition, nulling mbh_cost_product_id/mbh_cost_generated_at/mbh_cost_generated_by so a subsequent validate takes the full regeneration path instead of a short-circuited one. - domain/job: add TypeMBBulkTransition job type. - application/mbheadbulk: add RequestBulkTransitionHandler, a fan-out handler that creates one parent + N child job.Execution rows and publishes each child to RabbitMQ. Includes a later correctness fix (Phase G review) so a partial per-child publish failure no longer surfaces as an aggregated error on an otherwise durably-persisted job — callers now discover per-child failures via GetBulkMBHeadJobStatus/ListBulkMBHeadJobFailures instead. - infrastructure/rabbitmq: add the finance.jobs.mb_bulk_transition queue, JobMessage.MbhID field, and PublishMBBulkTransition. - migration 000500: widen job_execution.chk_job_type to allow the new mb_bulk_transition job type. - update mbhead/mb_head_* test doubles to satisfy the widened Repository interface (compile-only side effect of the new ForceUnvalidateTransition method). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Wire the bulk MB Head force-unvalidate/submit/validate job pipeline end to end: a RabbitMQ consumer processes fanned-out child jobs, and 5 new gRPC RPCs let a Super Admin kick off a bulk run and poll its status. - application/mbhead: add ForceUnvalidateHandler, a thin application-layer wrapper around the domain force-unvalidate transition. - worker: add mb_bulk_transition_handler.go, a RabbitMQ consumer that dispatches each child job by action (force_unvalidate/submit/ validate); wire it into cmd/worker/main.go as a sequential (concurrency 1) consumer on the new queue. - delivery/grpc: add mb_head_bulk_handlers.go with the 5 new RPCs (BulkForceUnvalidateMBHead, BulkSubmitMBHead, BulkValidateMBHead, GetBulkMBHeadJobStatus, ListBulkMBHeadJobFailures); extend mb_head_handler.go to chain the bulk transition handler in. - cmd/server/main.go: wire the new gRPC handlers, reusing the existing RabbitMQ publisher instance. - auth_interceptor.go: add permission-map entries for the 5 new RPCs. - permission_coverage_test.go: update the reachable/guarded RPC count ratchet to account for the 5 new RPCs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add finance.mb.head.bulkunvalidate/.bulksubmit/.bulkvalidate, following the same precedent as 000091's unrevoke permission: bulk force-unvalidate collapses the normal 2-step unlock-request flow into a single one-shot action across many rows at once, so it is gated to a new, dedicated permission set granted ONLY to SUPER_ADMIN (no menu entries, no other role). Widens chk_permission_action to allow the 3 new action_type values. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Cover the bulk MB Head force-unvalidate/submit/validate pipeline added in the preceding commits: - force_unvalidate_handler_test.go: application-layer wrapper. - request_bulk_transition_handler_test.go: fan-out handler, including the corrected contract for partial per-child RabbitMQ publish failures (Handle returns success with job info instead of an aggregated error when the parent and some children persisted durably). - mb_force_unvalidate_integration_test.go: real-DB coverage of the ForceUnvalidateTransition repository method. - mb_bulk_transition_handler_test.go: RabbitMQ consumer dispatch by action. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… in bulk MB Head Phase G review found that RequestBulkTransitionHandler.Handle returned an aggregated error whenever ANY child job failed to publish to RabbitMQ, even though the parent job and every successfully-published child were already durably persisted -- misleading the caller into thinking the whole bulk request failed when it had actually partially succeeded. Fix (landed together with the handler itself in the "add bulk MB Head force-unvalidate domain/infra/job layer" commit): Handle no longer returns an aggregated error for partial publish failures; a publishChildren helper was extracted, and a best-effort parent refresh via GetByID keeps the returned counters accurate. Callers now discover per-child publish failures via GetBulkMBHeadJobStatus/ListBulkMBHeadJobFailures instead of a bulk call-level error. This commit adds the gRPC-level regression test for that contract: TestBulkForceUnvalidateMBHead_PartialPublishFailure_StillReturnsSuccessWithJobInfo. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…RPCs Regenerate Go bindings, gRPC-gateway, and Swagger/OpenAPI output from finance/v1/yarn_master.proto after adding BulkForceUnvalidateMBHead, BulkSubmitMBHead, BulkValidateMBHead, GetBulkMBHeadJobStatus, and ListBulkMBHeadJobFailures to MBHeadService. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Description
Introduces the domain, infrastructure, async worker, and gRPC delivery layers for the Bulk MB Head lifecycle management and regeneration pipeline. This enables Super Admin users to trigger bulk state transitions (
VALIDATED -> DRAFT -> SUBMITTED -> VALIDATED) across stuck-in-VALIDATEDMB Head recipes so that downstream cost product master, cost route, CAPP, CPP, and MB Spin calculations regenerate properly following formula and calculation fixes.Type of Change
Service(s) Affected
Changes Made
canForceUnvalidategate andentity.ForceUnvalidate(reason)to bypass the normal 2-step unlock workflow and clear lock/unlock-request state.ForceUnvalidateTransitionin PostgreSQL repository, resettingmbh_cost_product_id,mbh_cost_generated_at, andmbh_cost_generated_byto null to ensure full downstream recalculation.TypeMBBulkTransitionjob type and migration000500wideningjob_execution.chk_job_type.finance.jobs.mb_bulk_transition, addedJobMessage.MbhID, and implementedPublishMBBulkTransition.RequestBulkTransitionHandlerfan-out handler managing 1 parent + N childjob.Executionrecords with RabbitMQ publishing.ForceUnvalidateHandlerand worker consumermb_bulk_transition_handler.go(sequential, concurrency 1) wired intocmd/worker/main.go.MBHeadService:BulkForceUnvalidateMBHead,BulkSubmitMBHead,BulkValidateMBHead,GetBulkMBHeadJobStatus, andListBulkMBHeadJobFailures.cmd/server/main.go.finance.mb.head.bulkunvalidate,finance.mb.head.bulksubmit,finance.mb.head.bulkvalidate) granted exclusively toSUPER_ADMIN.auth_interceptor.gopermission mappings and ratchet counts inpermission_coverage_test.go.force_unvalidate_handler_test.go,request_bulk_transition_handler_test.go,mb_force_unvalidate_integration_test.go,mb_bulk_transition_handler_test.go).TestBulkForceUnvalidateMBHead_PartialPublishFailure_StillReturnsSuccessWithJobInfo.finance/v1/yarn_master.proto.Related Issues
Fixes #
Related to #
API Changes (if applicable)
Proto Changes
Breaking Changes
Testing Performed
Unit Tests
Integration Tests
Manual Testing
Lint & Build
golangci-lint run ./...passesgo build ./...succeedsgo test -race ./...passesDatabase (if applicable)
Documentation
Rollback Plan
goapps-backendserver and worker instances.000500(and IAM action type seeds if needed).finance.jobs.mb_bulk_transitionqueue in RabbitMQ.Screenshots/Logs (if applicable)
Pre-merge Checklist
Reviewer Notes
SUPER_ADMIN.GetBulkMBHeadJobStatusandListBulkMBHeadJobFailures.