Skip to content

Handler refactor#312

Merged
ahouseholder merged 13 commits intomainfrom
handler-refactor
Mar 4, 2026
Merged

Handler refactor#312
ahouseholder merged 13 commits intomainfrom
handler-refactor

Conversation

@ahouseholder
Copy link
Contributor

This PR

  • refactors handlers module into submodules
  • refactors vocab examples module into submodules
  • renames VulnerabilityCase.case_status to VulnerabilityCase.case_statuses to indicate that it is a list of status items, not a singular status
  • renames CaseParticipant.participant_status to CaseParticipant.participant_statuses for the same reason
  • updates project docs

Copilot Summary

This pull request updates planning and implementation documentation to reflect recent gap analysis, bug fixes, and ongoing architectural decisions. Key changes include a refreshed gap analysis, marking completed and outstanding tasks, and detailed implementation notes on logging, actor independence, triggerable behaviors, and model gaps.

Gap Analysis and Task Status Updates

  • Refreshed the gap analysis in plan/IMPLEMENTATION_PLAN.md to version Update CONTRIBUTING.md #10, updating the status of several tasks and marking CM-03-006 field rename as complete. New gaps and outstanding tasks are clearly listed, including triggerable behaviors, actor independence, broadcast requirements, missing domain models, embargo policy, and root logger side effects. [1] [2] [3] [4]

Implementation Notes and Architectural Decisions

  • Added detailed implementation notes in plan/IMPLEMENTATION_NOTES.md covering:
    • Logging configuration issues in vultron/api/v2/app.py and recommendations for test isolation.
    • Verification of initial vendor participant creation for cases (CM-02-008).
    • Design questions for exposing triggerable behaviors as API endpoints (PRIORITY 30).
    • Risks and options for actor independence and DataLayer partitioning (PRIORITY 100).
    • EmbargoPolicy model implementation gap and cross-references.
    • Docstring and markdown compatibility guidance for documentation.
    • Plan for refactoring and removing outdated vocabulary example scripts.

Documentation and Ideas Organization

  • Added a new plan/IDEAS.md file as a placeholder for project ideas.
  • Removed extensive project ideas and design notes from plan/IDEATION.md, likely to be relocated or reorganized for clarity.

Minor Bug Documentation

  • Improved formatting and clarity of documentation bug fixes in plan/BUGS.md, specifically for linkchecker errors.

ahouseholder and others added 9 commits March 2, 2026 16:16
Previously app.py mutated the root logger's handlers and level at import
time. Any test importing the module (directly or transitively) inherited
those handlers, which were closed on teardown and produced spurious
'ValueError: I/O operation on closed file.' noise in every pytest run.

Fix: wrap the Uvicorn-handler wiring in configure_logging(), called only
from a FastAPI lifespan context manager. The root logger is now left
untouched at import time; module-level code only creates the module logger.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace spurious print() calls in four test files:
- test/behaviors/test_performance.py: use logger.info/warning for timing output
- test/bt/test_case_states/test_conditions.py: remove leftover debug print
- test/as_vocab/test_vulnerability_report.py: remove debug print calls
- test/as_vocab/test_create_activity.py: remove debug print call

592 tests pass, no stdout noise in uv run pytest -s output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…3-006)

Rename VulnerabilityCase.case_status (list) -> case_statuses per CM-03-006.
Add read-only case_status property returning current_status (most recent).

Rename CaseParticipant.participant_status (list) -> participant_statuses.
Add read-only participant_status property returning most recent entry.

Update all callers in handlers, behaviors, demo scripts, and tests.
All 592 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ahouseholder ahouseholder self-assigned this Mar 4, 2026
Copilot AI review requested due to automatic review settings March 4, 2026 14:19
@ahouseholder ahouseholder added tech/backend Changes to modules, libraries, etc. content/semantic Content changes to add/remove/modify meaningful content (beyond just formatting changes) labels Mar 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the API v2 backend handler implementation and the ActivityStreams vocabulary example generator into smaller submodules, while also renaming status-history fields to pluralized names (case_statuses, participant_statuses) and updating tests/docs accordingly.

Changes:

  • Split vultron/api/v2/backend/handlers.py into a handlers/ package with focused submodules and a re-exporting __init__.py.
  • Split vultron/scripts/vocab_examples.py into vultron/as_vocab/examples/* and add a compatibility shim for the original import path.
  • Rename status-history list fields to case_statuses / participant_statuses, add “latest status” convenience properties, and update usages/tests.

Reviewed changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vultron/scripts/vocab_examples.py Converted to a compatibility shim re-exporting the new examples module.
vultron/demo/status_updates_demo.py Updated demo to use case_statuses.
vultron/behaviors/report/nodes.py Updated participant RM status history usage to participant_statuses.
vultron/as_vocab/objects/vulnerability_case.py Renamed case_status list to case_statuses; added case_status (latest) property.
vultron/as_vocab/objects/case_participant.py Renamed participant_status list to participant_statuses; added participant_status (latest) property.
vultron/as_vocab/examples/vocab_examples.py New entrypoint/re-export module composing the split example submodules.
vultron/as_vocab/examples/status.py New split-out status example builders.
vultron/as_vocab/examples/report.py New split-out report example builders.
vultron/as_vocab/examples/participant.py New split-out participant example builders.
vultron/as_vocab/examples/note.py New split-out note example builders.
vultron/as_vocab/examples/embargo.py New split-out embargo example builders.
vultron/as_vocab/examples/case.py New split-out case example builders.
vultron/as_vocab/examples/actor.py New split-out actor recommendation example builders.
vultron/as_vocab/examples/_base.py New shared helpers/constants for generating examples.
vultron/as_vocab/examples/init.py New package marker for examples module.
vultron/api/v2/backend/handlers/_base.py New shared verify_semantics decorator used by handler submodules.
vultron/api/v2/backend/handlers/init.py Re-exports handler functions from submodules for backward compatibility.
vultron/api/v2/backend/handlers/unknown.py New unknown/unrecognized activity handler.
vultron/api/v2/backend/handlers/status.py New status handlers split out from the former monolith.
vultron/api/v2/backend/handlers/report.py New report handlers split out from the former monolith.
vultron/api/v2/backend/handlers/participant.py New participant handlers split out from the former monolith.
vultron/api/v2/backend/handlers/note.py New note handlers split out from the former monolith.
vultron/api/v2/backend/handlers/embargo.py New embargo handlers split out from the former monolith.
vultron/api/v2/backend/handlers/case.py New case handlers split out from the former monolith.
vultron/api/v2/backend/handlers/actor.py New actor/invite/ownership handlers split out from the former monolith.
vultron/api/v2/backend/handlers.py Removed monolithic handlers module (replaced by handlers/ package).
vultron/api/v2/app.py Moved root-logger mutation into FastAPI lifespan startup to reduce test side effects.
test/bt/test_case_states/test_conditions.py Removed debug print() noise.
test/behaviors/test_performance.py Switched from print() to logger for perf output.
test/behaviors/report/test_prioritize_tree.py Updated tests to use participant_statuses.
test/as_vocab/test_vulnerability_report.py Removed debug print() noise.
test/as_vocab/test_vulnerability_case.py Updated tests to use case_statuses.
test/as_vocab/test_vocab_examples.py Updated tests to use participant_statuses.
test/as_vocab/test_create_activity.py Removed debug print() noise.
test/api/v2/routers/test_datalayer_serialization.py Updated expected JSON field name to caseStatuses.
test/api/v2/backend/test_handlers.py Updated tests and docstrings to use renamed status-history fields.
plan/PRIORITIES.md Updated planning doc content (removed completed PRIORITY 10/20 section text).
plan/IMPLEMENTATION_PLAN.md Updated implementation plan with refreshed gap analysis and task status.
plan/IMPLEMENTATION_NOTES.md Added implementation notes (logging side effects, design questions, gaps).
plan/IDEATION.md Removed large ideation document (replaced by placeholder).
plan/IDEAS.md Added placeholder “Project Ideas” doc.
plan/BUGS.md Reformatted/clarified linkchecker bug note.

ahouseholder and others added 4 commits March 4, 2026 09:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ahouseholder ahouseholder merged commit 6094ca1 into main Mar 4, 2026
6 checks passed
@ahouseholder ahouseholder deleted the handler-refactor branch March 4, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

content/semantic Content changes to add/remove/modify meaningful content (beyond just formatting changes) tech/backend Changes to modules, libraries, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants