Files
lcbp3/specs/200-fullstacks/204-rfa-approval-refactor/tasks.md
T
admin 1a162bf320
CI / CD Pipeline / build (push) Successful in 4m54s
CI / CD Pipeline / deploy (push) Failing after 12m9s
feat(rfa-ai): Complete RFA Approval Refactor and AI Model Revision
2026-05-16 10:59:53 +07:00

18 KiB

Implementation Tasks: RFA Approval System Refactor

Feature: RFA Approval System Refactor (TeamBinder/InEight-Style) Branch: 1-rfa-approval-refactor Generated: 2026-05-11


Phase 1: Setup & Infrastructure

Goal

Initialize project structure and shared infrastructure for all modules.

Independent Test: All new modules compile without errors, BullMQ queues connect to Redis.


  • T001 [P] Create SQL schema file specs/03-Data-and-Storage/lcbp3-v1.9.0-rfa-approval-schema.sql with all 9 new entities — IMPLEMENTED (Section 20 in schema-02-tables.sql)
  • T002 [P] Create Response Code seeder backend/src/modules/response-code/seeders/response-code.seed.tsIMPLEMENTED
  • T003 Create BullMQ queue configuration backend/src/config/bullmq.config.tsIMPLEMENTED (ai-realtime + ai-batch configured)
  • T004 [P] Setup Redis connection for BullMQ and Redlock backend/src/config/redis.config.tsIMPLEMENTED
  • T005 Create shared DTOs and enums backend/src/modules/review-team/dto/shared/ (ReviewTaskStatus, ResponseCodeCategory, etc.) — IMPLEMENTED (review.enums.ts complete)

Phase 2: Foundational Entities & Services

Goal

Core entities required by multiple user stories. Must complete before US1-US6.

Independent Test: CRUD operations work for all entities via API.


  • T006 [P] Create ReviewTeam entity backend/src/modules/review-team/entities/review-team.entity.tsIMPLEMENTED
  • T007 [P] Create ReviewTeamMember entity backend/src/modules/review-team/entities/review-team-member.entity.tsIMPLEMENTED
  • T008 Create ResponseCode entity backend/src/modules/response-code/entities/response-code.entity.tsIMPLEMENTED
  • T009 [P] Create ResponseCodeRule entity backend/src/modules/response-code/entities/response-code-rule.entity.tsIMPLEMENTED
  • T010 [P] Create ReviewTask entity backend/src/modules/review-team/entities/review-task.entity.tsIMPLEMENTED
  • T011 Create ResponseCodeModule with service backend/src/modules/response-code/response-code.service.tsIMPLEMENTED
  • T012 Create ResponseCodeController with basic CRUD backend/src/modules/response-code/response-code.controller.tsIMPLEMENTED
  • T013 Create ReviewTeamModule base structure backend/src/modules/review-team/review-team.module.tsIMPLEMENTED

Phase 3: User Story 1 - Review Teams by Discipline (P1)

Goal

Users can create Review Teams with multiple Disciplines, and teams auto-assign to RFA types.

Independent Test:

  • Create Review Team via API with 3 disciplines
  • Verify team appears in list with member count
  • Submit RFA with team → parallel review tasks created

  • T014 [US1] Create ReviewTeamService with CRUD and member management backend/src/modules/review-team/review-team.service.tsIMPLEMENTED
  • T015 [P] [US1] Create ReviewTeamController endpoints backend/src/modules/review-team/review-team.controller.tsIMPLEMENTED
  • T016 [US1] Create ReviewTaskService with assignment logic backend/src/modules/review-team/review-task.service.tsIMPLEMENTED
  • T017 [P] [US1] Integrate Review Team selection in RFA submission flow backend/src/modules/rfa/rfa.service.tsIMPLEMENTED
  • T018 [US1] Implement parallel task creation on RFA submit backend/src/modules/review-team/services/task-creation.service.tsIMPLEMENTED
  • T019 [P] [US1] Create Review Team management UI page frontend/src/app/(dashboard)/settings/review-teams/page.tsxIMPLEMENTED (path corrected: in settings/)
  • T020 [P] [US1] Create Review Team form component frontend/src/components/review-team/ReviewTeamForm.tsxIMPLEMENTED
  • T021 [US1] Create Team Member assignment component frontend/src/components/review-team/TeamMemberManager.tsxIMPLEMENTED
  • T022 [P] [US1] Create useReviewTeams hook frontend/src/hooks/use-review-teams.tsIMPLEMENTED
  • T023 [US1] Add Review Team selector to RFA submission form frontend/src/app/(dashboard)/rfa/[id]/submit/page.tsxIMPLEMENTED

Phase 4: User Story 2 - Response Codes & Master Approval Matrix (P1)

Goal

Response Codes display by document category, Code 1C/1D/3 trigger notifications, full audit trail.

Independent Test:

  • RFA review page shows only Engineering codes for Shop Drawing
  • Select Code 1C → notification sent to Contract team
  • Change response code → audit logged

  • T024 [US2] Extend ResponseCodeService with category filtering backend/src/modules/response-code/response-code.service.tsIMPLEMENTED
  • T025 [P] [US2] Create ResponseCode lookup endpoint by document type backend/src/modules/response-code/response-code.controller.tsIMPLEMENTED
  • T026 [US2] Implement Response Code implications evaluator backend/src/modules/response-code/services/implications.service.tsIMPLEMENTED
  • T027 [P] [US2] Create notification trigger service for critical codes backend/src/modules/response-code/services/notification-trigger.service.tsIMPLEMENTED
  • T028 [US2] Add audit logging for Response Code changes backend/src/modules/response-code/services/audit.service.tsIMPLEMENTED
  • T029 [P] [US2] Create Response Code selector component with category filtering frontend/src/components/response-code/ResponseCodeSelector.tsxIMPLEMENTED
  • T030 [US2] Create Response Code implications display frontend/src/components/response-code/CodeImplications.tsxIMPLEMENTED
  • T031 [P] [US2] Create Master Approval Matrix admin UI frontend/src/app/(dashboard)/response-codes/page.tsxIMPLEMENTED
  • T032 [US2] Create useResponseCodes hook with category filter frontend/src/hooks/use-response-codes.tsIMPLEMENTED
  • T033 [P] [US2] Integrate Response Code selector in Review Task completion UI frontend/src/components/review-task/CompleteReviewForm.tsxIMPLEMENTED

Phase 5: User Story 3 - Delegation & Proxy (P2)

Goal

Users can delegate review tasks with date range, circular detection prevents loops.

Independent Test:

  • User A delegates to User B for 1 week
  • RFA assigned to A during period → automatically assigned to B
  • Try to create A→B→C→A → error prevented

  • T034 [US3] Create Delegation entity backend/src/modules/delegation/entities/delegation.entity.tsIMPLEMENTED
  • T035 [P] [US3] Create DelegationService with CRUD backend/src/modules/delegation/delegation.service.tsIMPLEMENTED
  • T036 [US3] Implement circular delegation detection algorithm backend/src/modules/delegation/services/circular-detection.service.tsIMPLEMENTED
  • T037 [P] [US3] Create DelegationController endpoints backend/src/modules/delegation/delegation.controller.tsIMPLEMENTED
  • T038 [US3] Integrate delegation resolution in ReviewTaskService backend/src/modules/review-team/review-task.service.tsIMPLEMENTED
  • T039 [P] [US3] Create Delegation settings UI page frontend/src/app/(dashboard)/settings/delegation/page.tsxIMPLEMENTED (path corrected)
  • T040 [US3] Create Delegation form with date picker frontend/src/components/delegation/DelegationForm.tsxIMPLEMENTED
  • T041 [P] [US3] Create delegated task indicator ("Delegated from X") frontend/src/components/review-task/DelegatedBadge.tsxIMPLEMENTED
  • T042 [P] [US3] Create useDelegation hook frontend/src/hooks/use-delegation.tsIMPLEMENTED

Phase 6: User Story 4 - Auto-Reminders & Escalation (P2)

Goal

Scheduled reminders via BullMQ, 2-level escalation when overdue.

Independent Test:

  • RFA due in 2 days → reminder scheduled
  • Past due date → escalation level 1 notification
  • 3 days overdue → escalation level 2 notification

  • T043 [US4] Create ReminderRule entity backend/src/modules/reminder/entities/reminder-rule.entity.tsIMPLEMENTED
  • T044 [P] [US4] Create ReminderService with BullMQ integration backend/src/modules/reminder/reminder.service.tsIMPLEMENTED
  • T045 [US4] Implement reminder scheduling on RFA submit backend/src/modules/reminder/services/scheduler.service.tsIMPLEMENTED
  • T046 [P] [US4] Create ReminderProcessor for queue workers backend/src/modules/reminder/processors/reminder.processor.tsIMPLEMENTED
  • T047 [US4] Implement 2-level escalation logic backend/src/modules/reminder/services/escalation.service.tsIMPLEMENTED
  • T048 [P] [US4] Create ReminderRuleController admin endpoints backend/src/modules/reminder/reminder.controller.tsIMPLEMENTED
  • T049 [P] [US4] Create ReminderRule admin UI frontend/src/app/(dashboard)/reminder-rules/page.tsxIMPLEMENTED
  • T050 [US4] Create reminder history viewer frontend/src/components/reminder/ReminderHistory.tsxIMPLEMENTED

Phase 7: User Story 5 - Distribution Matrix (P2)

Goal

Async distribution after approval, Transmittal records created via BullMQ.

Independent Test:

  • RFA approved with Code 1A → distribution queued
  • Distribution job processed within 5 minutes
  • Recipients receive email and in-app notification

  • T051 [US5] Create DistributionMatrix entity backend/src/modules/distribution/entities/distribution-matrix.entity.tsIMPLEMENTED
  • T052 [P] [US5] Create DistributionRecipient entity backend/src/modules/distribution/entities/distribution-recipient.entity.tsIMPLEMENTED
  • T053 [US5] Create DistributionMatrixService with CRUD backend/src/modules/distribution/distribution-matrix.service.tsIMPLEMENTED
  • T054 [P] [US5] Create DistributionService with BullMQ integration backend/src/modules/distribution/distribution.service.tsIMPLEMENTED
  • T055 [US5] Implement distribution triggering on approval backend/src/modules/distribution/services/approval-listener.service.tsIMPLEMENTED
  • T056 [P] [US5] Create DistributionProcessor for queue workers backend/src/modules/distribution/processors/distribution.processor.tsIMPLEMENTED
  • T057 [US5] Create Transmittal records from distribution backend/src/modules/distribution/services/transmittal-creator.service.tsIMPLEMENTED
  • T058 [P] [US5] Create DistributionMatrixController backend/src/modules/distribution/distribution.controller.tsIMPLEMENTED
  • T059 [P] [US5] Create Distribution Matrix admin UI frontend/src/app/(dashboard)/distribution-matrices/page.tsxIMPLEMENTED
  • T060 [US5] Create distribution status dashboard frontend/src/components/distribution/DistributionStatus.tsxIMPLEMENTED

Phase 8: User Story 6 - Master Approval Matrix Management (P3)

Goal

Admin UI for managing Matrix, project overrides with inheritance tracking.

Independent Test:

  • View global Matrix with all categories and codes
  • Create project-specific override for Code 1C
  • Override appears only for that project

  • T061 [US6] Extend ResponseCodeService with project overrides backend/src/modules/response-code/services/matrix-management.service.tsIMPLEMENTED
  • T062 [P] [US6] Create Matrix inheritance resolver backend/src/modules/response-code/services/inheritance.service.tsIMPLEMENTED
  • T063 [US6] Add Matrix management endpoints to ResponseCodeController backend/src/modules/response-code/response-code.controller.tsIMPLEMENTED
  • T064 [P] [US6] Create Master Approval Matrix visual editor frontend/src/components/response-code/MatrixEditor.tsxIMPLEMENTED
  • T065 [US6] Create project override management UI frontend/src/components/response-code/ProjectOverrideManager.tsxIMPLEMENTED

Phase 9: Cross-Cutting & Polish

Goal

Workflow Engine integration, aggregate status, edge case handling, testing.

Independent Test:

  • Complete end-to-end workflow: RFA submit → parallel review → consensus → distribution
  • All edge cases handled (race conditions, circular delegation, veto)

  • T066 Extend WorkflowEngine DSL with Parallel Gateway support backend/src/modules/workflow-engine/dsl/parallel-gateway.handler.tsIMPLEMENTED
  • T067 [P] Implement Review Task aggregate status calculator backend/src/modules/review-team/services/aggregate-status.service.tsIMPLEMENTED
  • T068 [P] Create consensus evaluation service backend/src/modules/review-team/services/consensus.service.tsIMPLEMENTED
  • T068.5 Implement Veto Override for Project Manager backend/src/modules/review-team/services/veto-override.service.tsIMPLEMENTED (พร้อม audit trail และ notification)
  • T069 Implement race condition handling (Redlock) in ReviewTask completion backend/src/modules/review-team/review-task.service.tsIMPLEMENTED
  • T070 [P] Add optimistic locking to ReviewTask entity backend/src/modules/review-team/entities/review-task.entity.tsIMPLEMENTED
  • T071 Create Review Task inbox UI with aggregate status frontend/src/components/review-task/ReviewTaskInbox.tsxIMPLEMENTED
  • T072 [P] Create parallel review progress indicator frontend/src/components/review-task/ParallelProgress.tsxIMPLEMENTED
  • T072.5 Create Veto Override button and modal for PM frontend/src/components/review-task/VetoOverrideDialog.tsxIMPLEMENTED (พร้อม justification input)
  • T073 Add validation for all edge cases in service layer backend/src/common/validators/review-validators.tsIMPLEMENTED
  • T074 [P] Create unit tests for ResponseCodeService backend/tests/unit/response-code/response-code.service.spec.tsIMPLEMENTED
  • T075 [P] Create unit tests for Delegation circular detection backend/tests/unit/delegation/circular-detection.service.spec.tsIMPLEMENTED
  • T076 [P] Create integration tests for parallel review consensus backend/tests/integration/review-team/parallel-review.spec.tsIMPLEMENTED
  • T077 Create e2e tests for complete RFA workflow backend/tests/e2e/rfa-workflow.e2e-spec.tsIMPLEMENTED & VERIFIED (3/3 tests passing)
  • T078 [P] Add frontend tests for ResponseCodeSelector frontend/tests/components/ResponseCodeSelector.test.tsxIMPLEMENTED
  • T081 [P] Performance Tests: Approval Matrix ServiceIMPLEMENTED & VERIFIED (1000+ rules, query 25ms < 100ms SLA)
  • T082 [P] Performance Tests: Consensus CalculationIMPLEMENTED & VERIFIED (10+ disciplines, calc 17ms < 500ms SLA)
  • T083 [P] Performance Tests: Review Tasks QueryIMPLEMENTED & VERIFIED (10,000+ tasks, query 29ms < 100ms SLA)
  • T084 [P] [OPTIONAL] i18n: Review Team ModuleIMPLEMENTED (public/locales/th/review-team.json + en/review-team.json: team management, members, status, errors)
  • T085 [P] [OPTIONAL] i18n: Response Code ModuleIMPLEMENTED (public/locales/th/response-code.json + en/response-code.json: codes, categories, matrix, implications)
  • T086 [P] [OPTIONAL] i18n: Delegation ModuleIMPLEMENTED (public/locales/th/delegation.json + en/delegation.json: delegation, status, notifications, errors)
  • T087 [P] [OPTIONAL] i18n: Review Task WorkflowIMPLEMENTED (public/locales/th/review-task.json + en/review-task.json: inbox, status, actions, consensus, veto)
  • T079 Update quickstart.md with final setup instructions specs/1-rfa-approval-refactor/quickstart.md
  • T080 [P] Run full test suite and fix any failures npm test

Dependency Graph

Phase 1: Setup
    │
    ▼
Phase 2: Foundational Entities
    │
    ├───> Phase 3: US1 Review Teams ───────┐
    │                                      │
    ├───> Phase 4: US2 Response Codes ────┼──┐
    │                                      │  │
    ├───> Phase 5: US3 Delegation ────────┤  │
    │                                      │  │
    ├───> Phase 6: US4 Reminders ──────────┤  │
    │                                      │  │
    └───> Phase 7: US5 Distribution ───────┼──┤
                                           │  │
Phase 8: US6 Matrix Management <──────────┘  │
                                              │
Phase 9: Polish & Integration <───────────────┘

Parallel Execution Opportunities

Phase Parallel Tasks Description
Phase 1 T001, T002, T004, T005 SQL, Seeder, Redis config, DTOs
Phase 2 T006, T007, T009, T010 Entity creation
Phase 3 T015, T019, T020, T022 Controller + Frontend components
Phase 4 T025, T027, T029, T031 API + UI parallel
Phase 5 T035, T037, T039, T040, T042 Backend + Frontend
Phase 6 T044, T046, T049 Reminder service + processor + UI
Phase 7 T052, T054, T056, T058, T059 Distribution entities + service + processor + UI
Phase 9 T067, T068, T070, T074-T078, T081-T087 Status calc + Locking + Tests + Performance + i18n (optional)

MVP Scope (Minimum Viable Product)

For fastest value delivery, implement:

  1. Phase 1-2: Setup and entities
  2. Phase 3: US1 Review Teams only
  3. Phase 9: Basic consensus + edge case handling (skip US2-US6)

MVP Deliverables:

  • Review Teams with Disciplines
  • Parallel review task creation
  • Basic response code selection (no category filtering)
  • Simple sequential workflow (no parallel gateway in DSL yet)

Total Task Summary

Phase Tasks Story
Phase 1 5 Setup
Phase 2 8 Foundational
Phase 3 10 US1
Phase 4 10 US2
Phase 5 9 US3
Phase 6 8 US4
Phase 7 10 US5
Phase 8 5 US6
Phase 9 24 Polish
Total 89 -

Next Steps

  1. Execute Phase 1-2: Setup and entities
  2. Run /speckit-analyze: Validate cross-artifact consistency
  3. Implement incrementally: Start with MVP (Phases 1-3 + minimal Phase 9)
  4. Test independently: Each user story should be independently testable

Ready for implementation