Split received/case.py and received/actor.py into subpackages#941
Conversation
dbe725c to
96970a7
Compare
|
I’m requesting changes, not because CI is failing, but because this PR is meant to set the structural precedent for future use-case splits and it currently leaves two important expectations weaker than issue #881 requires.
What looks good: the new source submodules are under 500 lines, the public use-case classes are preserved through package re-exports, and CI is green. |
|
Follow-up / strengthening my second point above: this should be treated as blocking, not optional debt. The identity-spoofing constraint is real: a received-side use case must not run a BT as another actor. But that does not justify doing protocol-significant work procedurally in the use case. The correct architecture is: the receiving actor runs a BT as itself, and that BT contains the reusable leaf nodes/subtrees for the state it is authorized to record in its own DataLayer. So the direct DataLayer/domain mutations in received use-case
Per BT-06-001 and BT-06-006, use cases should be infrastructure glue only: construct the tree, set up blackboard/context, execute through |
Test split (AC-4, CS-18-004):
- Split test_create.py (807 lines) into three focused files:
- test_create.py: CBT-05-001..004 bootstrap use-case tests only
- test_bootstrap_participants.py: CBT-05-005/006 embedded-participant
storage and M4 regression (#561/#562/#563)
- test_helpers.py: CBT-05-006/007 _ensure_reporter_participant seeding
and RM.ACCEPTED upgrade (#589/#624)
- Split test_update.py: extract BT tree-structure assertions into
test_update_bt.py, keeping use-case behavior tests in test_update.py
BT-migration debt markers (BT-06-001, BT-15-001):
- AcceptInviteActorToCaseReceivedUseCase.execute(): replace comment
presenting inline RM transitions as the architectural solution with an
explicit TODO(#943) marking them as BT-migration debt
- _ensure_reporter_participant(): add TODO(#943) on direct
ParticipantStatus(rm_state=RM.ACCEPTED) creation/upgrade
- test_helpers.py: add class-level TODO(#943) notes so the tests document
the debt they cover
- Created tracking issue #943 for the BT migration work
3205 passed, 36 skipped in 42s
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Convert two large use-case modules (819 and 803 lines) into focused subpackages, each under 500 lines per submodule (CS-18-002). received/case/ submodules: - _helpers.py: private helper functions shared across the package - create.py: CreateCaseReceivedUseCase (bootstrap path) - update.py: UpdateCaseReceivedUseCase - engage_defer.py: EngageCaseReceivedUseCase, DeferCaseReceivedUseCase - lifecycle.py: AddReportToCaseReceivedUseCase, CloseCaseReceivedUseCase - validate.py: InvalidateCaseUseCase, CloseCaseUseCase, ValidateCaseUseCase - __init__.py: re-exports all public names (AC-3) received/actor/ submodules: - suggest.py: Suggest/Accept/Reject SuggestActorToCase - case_manager_role.py: Offer/Accept/Reject CaseManagerRole - ownership.py: Offer/Accept/Reject CaseOwnershipTransfer - invite.py: Invite/Accept/Reject InviteActorToCase - announce.py: AnnounceVulnerabilityCaseReceivedUseCase - __init__.py: re-exports all public names including _find_case_actor_id Test layout mirrors source split (AC-4): - test/core/use_cases/received/case/ (test_create, test_update, test_engage_defer) - test/core/use_cases/received/actor/ (test_invite, test_suggest, test_ownership, test_case_manager_role, test_announce) All 3205 unit tests pass. Black, flake8, mypy, pyright clean. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d received/actor.py into subpackages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…NINGS - Flat-to-subpackage test migration: remove old flat files instead of keeping both to avoid duplicate test collection - Parent conftest fixtures are inherited automatically; only the vocab registration side-effect import needs copying per subdirectory Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Test split (AC-4, CS-18-004):
- Split test_create.py (807 lines) into three focused files:
- test_create.py: CBT-05-001..004 bootstrap use-case tests only
- test_bootstrap_participants.py: CBT-05-005/006 embedded-participant
storage and M4 regression (#561/#562/#563)
- test_helpers.py: CBT-05-006/007 _ensure_reporter_participant seeding
and RM.ACCEPTED upgrade (#589/#624)
- Split test_update.py: extract BT tree-structure assertions into
test_update_bt.py, keeping use-case behavior tests in test_update.py
BT-migration debt markers (BT-06-001, BT-15-001):
- AcceptInviteActorToCaseReceivedUseCase.execute(): replace comment
presenting inline RM transitions as the architectural solution with an
explicit TODO(#943) marking them as BT-migration debt
- _ensure_reporter_participant(): add TODO(#943) on direct
ParticipantStatus(rm_state=RM.ACCEPTED) creation/upgrade
- test_helpers.py: add class-level TODO(#943) notes so the tests document
the debt they cover
- Created tracking issue #943 for the BT migration work
3205 passed, 36 skipped in 42s
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
AcceptInviteActorToCaseReceivedUseCase.execute() now delegates all protocol-significant work (RM transitions, participant creation, case events, outbox emit) to AcceptInviteActorToCaseBT via BTBridge. The BT runs as the CaseActor — not the invitee — preserving PCR-08-010 identity constraints. CreateCaseReceivedUseCase._handle_bootstrap() now calls BTBridge with EnsureReporterParticipantAtAcceptedNode instead of calling _ensure_reporter_participant() directly. New BT artifacts: - vultron/core/behaviors/case/accept_invite_tree.py: 5-node Sequence tree implementing the accept-invite protocol path (CheckInviteeNotAlreadyParticipantNode, CreateInviteeParticipantAtAcceptedNode, MaybeSignEmbargoConsentNode, PersistInviteeParticipantNode, EmitAnnounceCaseToInviteeNode) EnsureReporterParticipantAtAcceptedNode exported from vultron/core/behaviors/case/nodes/participant/. Removes all TODO(#943) markers — the BT-migration debt is resolved. Resolves #943. All 3205 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f19858c to
cc03908
Compare
The class was incorrectly re-added during conflict resolution of the rebase onto main (PR #942 had moved it to participant_tree.py). The duplicate referenced SeedParticipantAsSignatoryIfEmbargoActiveNode which is not imported in participant_add.py, causing F821/name-defined errors in flake8/mypy/pyright CI jobs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Splits two 800+ line use-case modules into focused subpackages, each
submodule under 500 lines, with re-exporting
__init__.pyfiles thatpreserve all existing import paths.
Addresses review feedback:
test_create.py(807 lines) andtest_update.py(559 lines) have been split into focused per-concernmodules that mirror the source submodule they exercise.
mutations in
AcceptInviteActorToCaseReceivedUseCaseand_ensure_reporter_participantare explicitly marked as debt withTODO(#943)comments. Comment language no longer presents inline as thearchitectural solution. Tracking issue: Migrate received use-case procedural protocol behavior to BT nodes (BT-06-001, BT-15-001) #943.
Changes
Source subpackages (unchanged from original split)
vultron/core/use_cases/received/case/(new package):_helpers.py,create.py,update.py,engage_defer.py,lifecycle.py,validate.py,__init__.py(re-exports all publicnames)
vultron/core/use_cases/received/actor/(new package):suggest.py,case_manager_role.py,ownership.py,invite.py,announce.py,__init__.py(re-exports all public names)BT-debt markers added
received/actor/invite.py:AcceptInviteActorToCaseReceivedUseCase— replaced inline-as-solution comment with
TODO(#943)on RM transitions,participant creation, case events, and
dl.savereceived/case/_helpers.py:_ensure_reporter_participant—added
TODO(#943)on directParticipantStatus(rm_state=RM.ACCEPTED)creation/upgrade
Test layout (per-concern split)
test/core/use_cases/received/case/test_create.py(reduced toCBT-05-001..004 bootstrap use-case tests only)
test/core/use_cases/received/case/test_bootstrap_participants.py(new): CBT-05-005/006 — embedded participant storage and M4 regression
(EngageCaseBT fails on finder replica: CheckParticipantExists cannot find vendor CaseParticipant #561/AddParticipantStatusBT fails on finder replica: vendor CaseParticipant UUID not in DataLayer #562/Two-actor demo M4 timeout: finder returns 404 for vendor vfd_state polling #563)
test/core/use_cases/received/case/test_helpers.py(new):CBT-05-006/007 —
_ensure_reporter_participantseeding and RM.ACCEPTEDupgrade (SvcAddParticipantStatusUseCase sends RM.START status after notify-published — vendor rejects as backwards transition #589/bug: vendor BT fails on inbound post-publish activity — M6/M7 timeout (EM not reaching EXITED) #624); includes
TODO(#943)class notestest/core/use_cases/received/case/test_update.py(reduced touse-case behavior tests only)
test/core/use_cases/received/case/test_update_bt.py(new):UpdateCaseBT tree-structure and no-post-BT-broadcast assertions
test/core/use_cases/received/actor/(unchanged): per-moduletest files migrated from flat files
Verification