Skip to content

Fix PR #331 review feedback: hoist test imports, fix stale docs, improve health probe#333

Merged
ahouseholder merged 2 commits intotransitions-part-2from
copilot/sub-pr-331-again
Mar 24, 2026
Merged

Fix PR #331 review feedback: hoist test imports, fix stale docs, improve health probe#333
ahouseholder merged 2 commits intotransitions-part-2from
copilot/sub-pr-331-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

Addresses all reviewer comments from the PR #331 review thread: test import style, stale endpoint/docstring descriptions, and an unreliable readiness probe.

Test files — imports hoisted to module level

Four test files had imports inside helper functions and individual test methods. Moved all to module scope per CS-02-002:

  • test/core/use_cases/test_status_use_cases.py
  • test/core/use_cases/test_report_use_cases.py
  • test/core/use_cases/test_note_use_cases.py
  • test/core/use_cases/test_case_use_cases.py

trigger_report.py — endpoint descriptions corrected

Three endpoints (invalidate-report, reject-report, close-report) described persisting "offer status to TENTATIVELY_REJECTED/REJECTED", which no longer happens. Descriptions now reflect the actual side effect: a ParticipantStatus record with the corresponding RM state is persisted.

nodes.py — TransitionRMtoInvalid docstring corrected

Class docstring claimed the node transitions the offer to TENTATIVELY_REJECTED. The implementation only writes a ParticipantStatus with RM.INVALID. Docstring updated accordingly.

health.py — readiness probe made reliable

dl.read("") (empty string ID) always returns None without exercising real backend connectivity, making the 503 path unreachable. Replaced with a dedicated ping() method:

# DataLayer Protocol
def ping(self) -> bool: ...

# TinyDbDataLayer
def ping(self) -> bool:
    list(self._db.tables())  # real backend probe; raises if storage unavailable
    return True

/health/ready now calls dl.ping(), so a storage failure actually returns HTTP 503.


Please note: Pull request submissions are subject to our
Contribution Instructions


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…r descriptions, nodes docstring, health probe ping

Co-authored-by: ahouseholder <2594236+ahouseholder@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CERTCC/Vultron/sessions/2a977821-d19d-4e43-bfc9-23989471a5cc
Copilot AI changed the title [WIP] Update developer workflow documentation and automation Fix PR #331 review feedback: hoist test imports, fix stale docs, improve health probe Mar 24, 2026
Copilot AI requested a review from ahouseholder March 24, 2026 16:27
@ahouseholder ahouseholder marked this pull request as ready for review March 24, 2026 16:31
Copilot AI review requested due to automatic review settings March 24, 2026 16:31
@ahouseholder ahouseholder merged commit 6cfbb98 into transitions-part-2 Mar 24, 2026
2 checks passed
@ahouseholder ahouseholder deleted the copilot/sub-pr-331-again branch March 24, 2026 16:32
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 addresses follow-up review feedback from #331 by standardizing test import style, correcting stale endpoint/node documentation around report RM state persistence, and making the FastAPI readiness probe actually validate storage availability via a new DataLayer.ping() port method.

Changes:

  • Hoist imports to module scope in several core use-case test modules.
  • Update router and behavior-node docstrings/descriptions to reflect persisting ParticipantStatus RM state (not offer status).
  • Add DataLayer.ping() and use it in /health/ready to reliably detect storage failures.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vultron/core/ports/datalayer.py Extends the DataLayer port with a ping() method for readiness probing.
vultron/adapters/driven/datalayer_tinydb.py Implements ping() for TinyDB-backed storage.
vultron/adapters/driving/fastapi/routers/health.py Switches readiness check from read("") to dl.ping().
vultron/adapters/driving/fastapi/routers/trigger_report.py Fixes endpoint descriptions to match current persistence side effects (ParticipantStatus/RM).
vultron/core/behaviors/report/nodes.py Corrects TransitionRMtoInvalid docstring to match implementation behavior.
test/core/use_cases/test_status_use_cases.py Moves imports to module scope.
test/core/use_cases/test_report_use_cases.py Moves imports to module scope.
test/core/use_cases/test_note_use_cases.py Moves imports to module scope.
test/core/use_cases/test_case_use_cases.py Moves imports to module scope and renames local rehydration mocks for clarity.

"""Returns 200 if the service is ready to accept requests (OB-05-002)."""
try:
dl.read("")
dl.ping()
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

DataLayer.ping() is declared to return bool, and TinyDbDataLayer.ping() docstring suggests it may return False, but the readiness endpoint ignores the return value. If a DataLayer implementation returns False without raising, /health/ready will still return 200. Consider checking the return value and treating False as not-ready (or standardize ping() to raise on failure and document that contract).

Suggested change
dl.ping()
ok = dl.ping()
if not ok:
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail="Service unavailable",
)

Copilot uses AI. Check for mistakes.
Comment on lines +306 to +308
Performs a lightweight read of the database table list. Returns
``True`` if the storage backend responds normally; raises or returns
``False`` if the backend is unavailable.
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The ping() docstring says it may "raise or return False" when unavailable, but the implementation always returns True and never returns False. Please either adjust the docstring to match the actual behavior (raise on failure), or catch exceptions and explicitly return False so callers can rely on the boolean return contract.

Suggested change
Performs a lightweight read of the database table list. Returns
``True`` if the storage backend responds normally; raises or returns
``False`` if the backend is unavailable.
Performs a lightweight read of the database table list. Returns
``True`` if the storage backend responds normally; raises an exception
if the backend is unavailable.

Copilot uses AI. Check for mistakes.
Comment on lines 223 to +228
class TransitionRMtoInvalid(DataLayerAction):
"""
Transition report to RM.INVALID and offer to TENTATIVELY_REJECTED.
Transition report to RM.INVALID.

Updates report status (RM.INVALID) in the DataLayer.
Persists a ParticipantStatus record with RM.INVALID for the actor and
report in the DataLayer.
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The updated docstring describes transitioning only the report to RM.INVALID, but the node constructor still takes an offer_id and stores it even though it is unused in update(). Consider removing offer_id from TransitionRMtoInvalid (or explicitly documenting why it is kept) to avoid confusion and dead parameters.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants