Skip to content

bug(tests): #1804 terminal-activity parity guard doesn't scan client_portal/, which now holds a terminal writer #2131

Closed

Description

@trinity-ability

Found while validating #2120.

The gap

tests/unit/test_1804_terminal_activity_parity.py enforces the #1804 contract — every writer that wins a terminal CAS on schedule_executions closes the paired agent_activities dispatch row. It walks the tree with:

_SCAN_DIRS = ("services", "routers")

client_portal/ is neither. That was harmless when the module was entitled and lived in the submodule, but ent#356 moved it into OSS core — and #2120 then added a terminal writer to it:

# src/backend/client_portal/service.py
def _fail_unstarted_execution(execution_id: str, reason: str) -> None:
    core_db.update_execution_status(execution_id, "failed", error=...)

update_execution_status is in the guard's own TERMINAL_WRITERS set. The guard simply never looks at the file.

This is not currently a bug

_fail_unstarted_execution only fires when the turn never reached execute_task, so no dispatch activity exists to close — the same justification the guard already allowlists for routers/chat.py::_raise_ephemeral_exhausted_410. Behaviour today is correct.

The defect is that the guard's coverage assumption has drifted: client_portal/ now holds execution-terminal logic, and the next writer added there gets no protection. That is precisely the recurrence the guard's own docstring argues against —

Companion to #429: [...] A per-site patch would be deleted with its host, leaving no owner. This guard survives, because it is anchored on terminal writes.

A guard that survives its hosts but not its directories has the same hole one level up.

Fix

Add client_portal to _SCAN_DIRS and give _fail_unstarted_execution an explicit ALLOWLIST entry with the lifecycle justification (the guard already asserts every entry carries one ≥60 chars and that the named function still exists).

Consider whether the scan should instead be "every package under src/backend that isn't test/migration scaffolding", so adopting a future module can't silently repeat this.

Acceptance criteria

  • client_portal/ is scanned
  • _fail_unstarted_execution allowlisted with a justification proving no dispatch activity exists at that point
  • The guard's four existing self-tests still pass, including test_allowlist_entries_all_still_exist
  • Removing the allowlist entry makes the guard fail (i.e. it genuinely covers the new directory)

Related: #1804, #2120

Activity

  1. added
    priority-p3
    type-bug
    theme-reliability
    complexity-low
    on Aug 12, 2026
  2. added a commit that references this issue on Aug 12, 2026
  3. added a commit that references this issue on Aug 12, 2026
  4. added
    status-in-dev
    on Aug 12, 2026
  5. added
    status-in-progress
    and removed
    status-in-dev
    on Aug 13, 2026
  6. self-assigned this
    on Aug 13, 2026
  7. added
    status-in-dev
    and removed
    status-in-progress
    on Aug 13, 2026
  8. removed
    status-in-dev
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-lowpriority-p3theme-reliabilitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions