Wave 3: remove dead code and simplify error handling #1

Merged
macoun merged 9 commits from refactor/wave-3-cleanup into main 2026-10-15 14:22:07 +00:00
Owner

Cleanup after the code review. No user-facing behaviour changes except the
two status codes noted below.

What changes

  • CI: tests and the migrations check now run on pull requests into main.
    Images are still built only from main.
  • IO slots removed: IoSlotAssignments and IoComponents tables, the entities,
    seed and the inactive AllIoSlotsResolved rule. They were replaced by free
    configuration parameters (ADR-021) and nothing has used them since. History
    of older contracts still shows "IO pozice".
  • Actor rules removed from the flow engine: every rule was AnyMember and
    every team member may do everything (ADR-011). Drops the FlowActorRules table.
    An unknown required-field rule type now blocks instead of silently passing.
  • CLAUDE.md rule 4 rewritten: the flow changes only through a migration
    reviewed in a PR; state/operation ids and codes are never deleted or
    renumbered (set IsActive=false instead); contracts that would be stranded must
    be migrated and covered by a test. ADR-004 and contract-flow.md updated.
  • 25 single-implementation interfaces removed; services are injected as
    concrete classes. Interfaces that tests substitute or that mark a real
    boundary stay (portal clients, IFileStorage, ILoginAttemptGuard,
    INotificationChannel, IOutboxProcessor).
  • One place for exception-to-HTTP mapping: NotFound / Conflict /
    DomainValidation / PortalUnavailable exceptions are mapped only in
    GlobalExceptionHandler; 16 duplicated try/catch blocks in controllers removed.
  • Flow blocking messages moved to ErrorMessages; shared helper for the two
    portal list clients; stale comments fixed.

Behaviour changes

  • An unknown role or team member in a request body returns 422 instead of 404.
  • An upstream HTTP failure always returns 502 instead of echoing the portal's status.
  • Rejected flow operations always return 422 (403 could no longer happen).

Deployment

Two migrations drop tables (DropIoSlotTables, DropFlowActorRules).
Take a manual backup (POST /api/v1/admin/backup) before updating the stack.

Testing

  • 235 tests pass, migrations check clean, frontend build OK.
Cleanup after the code review. No user-facing behaviour changes except the two status codes noted below. ## What changes - **CI:** tests and the migrations check now run on pull requests into main. Images are still built only from main. - **IO slots removed:** IoSlotAssignments and IoComponents tables, the entities, seed and the inactive AllIoSlotsResolved rule. They were replaced by free configuration parameters (ADR-021) and nothing has used them since. History of older contracts still shows "IO pozice". - **Actor rules removed from the flow engine:** every rule was AnyMember and every team member may do everything (ADR-011). Drops the FlowActorRules table. An unknown required-field rule type now blocks instead of silently passing. - **CLAUDE.md rule 4 rewritten:** the flow changes only through a migration reviewed in a PR; state/operation ids and codes are never deleted or renumbered (set IsActive=false instead); contracts that would be stranded must be migrated and covered by a test. ADR-004 and contract-flow.md updated. - **25 single-implementation interfaces removed;** services are injected as concrete classes. Interfaces that tests substitute or that mark a real boundary stay (portal clients, IFileStorage, ILoginAttemptGuard, INotificationChannel, IOutboxProcessor). - **One place for exception-to-HTTP mapping:** NotFound / Conflict / DomainValidation / PortalUnavailable exceptions are mapped only in GlobalExceptionHandler; 16 duplicated try/catch blocks in controllers removed. - Flow blocking messages moved to ErrorMessages; shared helper for the two portal list clients; stale comments fixed. ## Behaviour changes - An unknown role or team member in a request body returns 422 instead of 404. - An upstream HTTP failure always returns 502 instead of echoing the portal's status. - Rejected flow operations always return 422 (403 could no longer happen). ## Deployment Two migrations drop tables (DropIoSlotTables, DropFlowActorRules). Take a manual backup (POST /api/v1/admin/backup) before updating the stack. ## Testing - 235 tests pass, migrations check clean, frontend build OK.
Pull requests into main now get the test and migrations-check jobs. build-and-push still runs only on a push to main, so a branch never publishes an image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IO slots were replaced by free configuration parameters (ADR-021) and nothing has read or written them since. Removes the IoSlotAssignment/IoComponent entities, their EF configuration and seed, the inactive AllIoSlotsResolved rule and dead error texts, and drops both tables in the DropIoSlotTables migration. History of older contracts still labels IoSlotAssignment entries. The .http examples use parameters and the new role codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every seeded actor rule was AnyMember and ADR-011 lets every team member do everything, so the grouping logic, role/creator rule kinds and the 403 path could never decide anything (AnyOfRole could not even pass). Removes FlowActorRule with its table (DropFlowActorRules migration), reduces FlowActor to the member id, returns 422 for every rejected operation, and makes an unknown required-field rule type block instead of silently passing.

CLAUDE.md rule 4 now describes how the flow really changes: seed edit, migration, tests and a pull request, with stable state/operation ids and codes and a data migration for contracts that would be stranded. ADR-004 and contract-flow.md are updated to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 service interfaces had exactly one implementation and no test substitutes them, so they only added a hop on every go-to-definition. Services are now registered and injected as concrete classes; interface member docs moved onto the classes. Interfaces that tests replace or that mark a real boundary stay: the portal clients, IFileStorage, ILoginAttemptGuard, INotificationChannel and IOutboxProcessor. Leftover files are removed and the contract exceptions live in ContractExceptions.cs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file only holds the flow result types now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eleven exception types (Contract*, Team*, three portal-unavailable ones) collapse into NotFoundException, ConflictException, DomainValidationException and PortalUnavailableException, mapped only in GlobalExceptionHandler (plus AttachmentTooLargeException for 413). The 16 try/catch blocks that duplicated that mapping in controllers are gone. An unknown role or team member in a request body now returns 422 instead of 404, and an upstream HTTP failure always returns 502 instead of echoing the portal's status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The three blocking reasons from FlowEngine move to Constants/ErrorMessages.cs (CLAUDE.md rule 8) and the repeated 'kdokoli z týmu' in NextStepResolver becomes one constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PortalCompanyClient and PortalDirectoryClient were line-for-line copies apart from the endpoint and result type. Both now call PortalAsCaller.GetListAsync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: fix the stale roles comment on ContractsController
All checks were successful
Build and publish Docker image / migrations-check (pull_request) Successful in 43s
Build and publish Docker image / test (pull_request) Successful in 1m43s
Build and publish Docker image / build-and-push (pull_request) Has been skipped
a39144c9f7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macoun merged commit 5fa265f304 into main 2026-10-15 14:22:07 +00:00
macoun deleted branch refactor/wave-3-cleanup 2026-10-15 14:22:07 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
STATOTEST/contract-microservice!1
No description provided.