Fix Tessa gate dead code and infinite loop risk (QA finding)
# MC-4307: Fix Tessa gate — dead code and infinite loop risk **Priority:** high **Assigned:** luci **Depends on:** MC-4303 (Tessa gate must exist first) ## What to do The QA ...
StateDoneNext ActionClosedOwnerLuciRuntimeClosedAge17d ago
Ticket is done; runtime is closed.·profile claude_opus_1m_medium · cwd /home/lucienne/workspace/mission-control · uptime 16d 14h · last activity 16d 11h ago
Description
MC-4316
# MC-4307: Fix Tessa gate — dead code and infinite loop risk
**Priority:** high
**Assigned:** luci
**Depends on:** MC-4303 (Tessa gate must exist first)
## What to do
The QA review found two critical issues with the Tessa gate (mc_tessa_gate.py):
**Issue 1 — `act_on_tessa_output` is dead code.**
The function exists and is tested but is never called from any production path. When Tessa reports DONE, nothing processes her ISSUES/APPROVED output.
**Issue 2 — Potential infinite Tessa dispatch loop.**
When Tessa reports DONE:
1. Harvest sets ticket to `done`
2. Shadow reviewer runs → verdict `pass` (reviewing the same code that already passed)
3. `act_on_verdict` → `gate_on_pass` → detects UI → dispatches to Tessa **again**
4. No guard prevents re-dispatching to a ticket that already went through Tessa
This could loop until `review_cycles` hits 3, or potentially forever if Tessa's worktree setup produces `sha=None` each time.
## Steps
### Part A: Wire `act_on_tessa_output` into the harvest path
1. Find where Tessa reports DONE in the harvest path (likely `ticket_runtime.py` or `mc_pickup.py`).
2. After the DONE sentinel is detected, check if the ticket has a Tessa verdict in the evidence/comments.
3. If Tessa verdict exists, call `mc_tessa_gate.act_on_tessa_output(ticket_id, tessa_output)`.
4. The function handles ISSUES (bump `review_cycles`, reopen to `todo`) and APPROVED (no-op, ticket stays done).
### Part B: Add a "Tessa already ran" guard
1. In `mc_tessa_gate.gate_on_pass`, before dispatching to Tessa, check if the ticket has already been through Tessa.
2. Detection options (pick one):
- Check `tessa_verdict` column (add it if needed — `TEXT`, values: `APPROVED` / `ISSUES` / `UNAVAILABLE`)
- Check comments for "Tessa" + "APPROVED" or "ISSUES" markers
- Check if `review_cycles > 0` AND the last shadow review was `pass` (implies Tessa already ran and looped back)
3. If Tessa already ran AND verdict was `APPROVED`, do NOT re-dispatch. Proceed to "gate to Elmar" check.
4. If Tessa already ran AND verdict was `ISSUES`, the ticket is already back in `todo` from `act_on_tessa_output`. Do NOT re-dispatch until the worker fixes it and reports done again.
### Part C: Track Tessa verdicts
1. Add a `tessa_verdict` column to the tickets table (or use a separate tracking table if migrations are complex).
2. When `act_on_tessa_output` runs, write the verdict (`APPROVED` / `ISSUES` / `UNAVAILABLE`).
3. Use this for the "already ran" guard in Part B.
### Part D: Test end-to-end
1. Create a dummy UI-touching ticket (tag it `ui` or touch a `.html` file).
2. Let the worker "do" it (dummy commit).
3. Let shadow reviewer pass.
4. Let Tessa gate dispatch.
5. Simulate Tessa APPROVED → verify ticket stays done, no re-dispatch.
6. Simulate Tessa ISSUES → verify ticket reopens, `review_cycles` increments, no infinite loop.
7. Post DB evidence on this ticket.
## Acceptance criteria
- `act_on_tessa_output` is called from the harvest path when Tessa reports DONE
- "Tessa already ran" guard prevents infinite re-dispatch
- `tessa_verdict` is recorded in the ticket evidence
- End-to-end test proves: Tessa APPROVED → ticket stays done; Tessa ISSUES → ticket reopens once, not infinitely
- No infinite loop when a UI ticket goes through the full cycle
## If blocked
- If the harvest path is complex and you can't find where Tessa's DONE is processed, add a comment to the ticket and escalate to Elmar.
- If adding `tessa_verdict` column requires a migration and migrations are complex, use a comment-based detection (grep for "Tessa verdict:" in ticket comments).
- Test with a real ticket before enabling the flag. If the loop risk is too high, keep `MC_ORCH_TESSA_GATE=0` until the fix is proven.
## What NOT to do
- Do not change the shadow reviewer (MC-4301)
- Do not change the review loop (MC-4302)
- Do not change the operator (MC-4304)
- Do not touch the inbox (MC-4305)
- Do not enable `MC_ORCH_TESSA_GATE` on live UI tickets until the fix is proven
Activity
done
INTERACTIVE
Luci is working...
Details —
Done
· High
· Luci
▼
SState
Done
Closed
PPeople
TTiming / Details▼
api (human)
Mission Control
17d ago
16d ago
Advanced / Operator evidence
RRouting owner
ROperator console
Ticket is done; runtime is closed.ticket_marked_doneprofile claude_opus_1m_medium · cwd /home/lucienne/workspace/mission-control · uptime 16d 14h · last activity 16d 11h agoMC is visibility-only. Hermes Luci launches and gates work outside MC, then mirrors evidence/status here.Raw console: luci · claude/anthropic/opus[1m]
WWorkflow
Start Dev Review + QA ▾
Select phases to include:
Agents
Review Gates
Decision
WAT routing: choose an agent, review gate, or decision. Buttons use the live runtime when one is attached.
START with Part B (the infinite loop guard) — that's the critical safety issue. Wire the 'Tessa already ran' check into gate_on_pass BEFORE fixing the harvest path. The current code is safe (Tessa output is ignored) but the loop risk is real. Fix the guard first, then wire act_on_tessa_output, then test end-to-end.
luci17d ago
Luci picking up this ticket (background worker).
luci17d ago
Ticket picked up by Luci via MC dispatcher.
MC-4316: Fix Tessa gate dead code and infinite loop risk (QA finding)
Work this ticket in the live tmux runtime. Use DONE:, REVIEW:, or QUESTION: when you need MC to reflect the next state.
luci17d ago
Ticket runtime send failed while dispatching.
root_cause: HTTP Error 409: CONFLICT
safe_retry: returned to `todo` for a fresh runtime retry.
human_input_required: no
system17d ago
RUNTIME TERMINAL STATE (MC-3482 contract)
status: warning
summary: Ticket runtime send failed; parked for automatic recovery.
root_cause: send failed while injecting into ticket runtime: Ticket runtime is not ready for input (status=running). Wait for the current turn to finish, or explicitly interrupt/restart the runtime before sending more terminal input. This message was not sent.
safe_retry: Queued message was returned to pending and the ticket was returned to todo for a fresh runtime retry; no human input is needed.
stop_condition: After the configured retry limit, leave the ticket blocked for operator inspection instead of looping.
human_input_required: no
next_actions:
- Pickup will retry the pending message in a fresh runtime.
- Inspect runtime/send only if the retry fails again.
artifacts:
- ticket:MC-4316
luci17d ago
Luci picking up this ticket (background worker).
luci17d ago
Ticket runtime send failed while dispatching.
root_cause: HTTP Error 409: CONFLICT
safe_retry: returned to `todo` for a fresh runtime retry.
human_input_required: no
system17d ago
RUNTIME TERMINAL STATE (MC-3482 contract)
status: warning
summary: Ticket runtime send failed; parked for automatic recovery.
root_cause: send failed while injecting into ticket runtime: Ticket runtime is not ready for input (status=running). Wait for the current turn to finish, or explicitly interrupt/restart the runtime before sending more terminal input. This message was not sent.
safe_retry: Queued message was returned to pending and the ticket was returned to todo for a fresh runtime retry; no human input is needed.
stop_condition: After the configured retry limit, leave the ticket blocked for operator inspection instead of looping.
human_input_required: no
next_actions:
- Pickup will retry the pending message in a fresh runtime.
- Inspect runtime/send only if the retry fails again.
artifacts:
- ticket:MC-4316
luci17d ago
Luci picking up this ticket (background worker).
luci17d ago
Ticket runtime send failed while dispatching.
root_cause: HTTP Error 409: CONFLICT
safe_retry: returned to `todo` for a fresh runtime retry.
human_input_required: no
system17d ago
RUNTIME TERMINAL STATE (MC-3482 contract)
status: error
summary: Ticket runtime send failed; parked for automatic recovery.
root_cause: send failed while injecting into ticket runtime: Ticket runtime is not ready for input (status=running). Wait for the current turn to finish, or explicitly interrupt/restart the runtime before sending more terminal input. This message was not sent.
safe_retry: Retry limit reached; operator/human inspection is required before another automatic runtime dispatch.
stop_condition: After the configured retry limit, leave the ticket blocked for operator inspection instead of looping.
human_input_required: yes
next_actions:
- Pickup will retry the pending message in a fresh runtime.
- Inspect runtime/send only if the retry fails again.
artifacts:
- ticket:MC-4316
luci17d ago
Luci picking up this ticket (background worker).
luci17d ago
[system]: Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
[system]: Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
[system]: Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
luci17d ago
Ticket runtime send failed while dispatching.
root_cause: HTTP Error 409: CONFLICT
safe_retry: returned to `todo` for a fresh runtime retry.
human_input_required: no
system17d ago
RUNTIME TERMINAL STATE (MC-3482 contract)
status: error
summary: Ticket runtime send failed; parked for automatic recovery.
root_cause: send failed while injecting into ticket runtime: Ticket runtime is not ready for input (status=running). Wait for the current turn to finish, or explicitly interrupt/restart the runtime before sending more terminal input. This message was not sent.
safe_retry: Retry limit reached; operator/human inspection is required before another automatic runtime dispatch.
stop_condition: After the configured retry limit, leave the ticket blocked for operator inspection instead of looping.
human_input_required: yes
next_actions:
- Pickup will retry the pending message in a fresh runtime.
- Inspect runtime/send only if the retry fails again.
artifacts:
- ticket:MC-4316
luci17d ago
Luci picking up this ticket (background worker).
luci17d ago
[system]: Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
[system]: Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
[system]: Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
[system]: Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
luci17d ago
Ticket runtime send failed while dispatching.
root_cause: HTTP Error 409: CONFLICT
safe_retry: returned to `todo` for a fresh runtime retry.
human_input_required: no
system17d ago
RUNTIME TERMINAL STATE (MC-3482 contract)
status: error
summary: Ticket runtime send failed; parked for automatic recovery.
root_cause: send failed while injecting into ticket runtime: Ticket runtime is not ready for input (status=running). Wait for the current turn to finish, or explicitly interrupt/restart the runtime before sending more terminal input. This message was not sent.
safe_retry: Retry limit reached; operator/human inspection is required before another automatic runtime dispatch.
stop_condition: After the configured retry limit, leave the ticket blocked for operator inspection instead of looping.
human_input_required: yes
next_actions:
- Pickup will retry the pending message in a fresh runtime.
- Inspect runtime/send only if the retry fails again.
artifacts:
- ticket:MC-4316
luci16d ago
Luci picking up this ticket (background worker).
luci16d ago
[failed_to_inject] runtime_busy: Ticket runtime is not ready for input (status=running). Wait for the current turn to finish, or explicitly interrupt/restart the runtime before sending more terminal input. This message
Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
luci16d ago
[failed_to_inject] runtime_busy: Ticket runtime is not ready for input (status=running). Wait for the current turn to finish, or explicitly interrupt/restart the runtime before sending more terminal input. This message
Ticket moved to Todo: Fix Tessa gate dead code and infinite loop risk (QA finding)
Workflow action `review_ready` applied. Work ready for review.
api16d ago
Closed (orchestrator). 39471fa FF-pushed to mission-control master. act_on_tessa_output now wired into harvest path (skips shadow review for Tessa worker, runs handler after update flow). Added tessa_verdict column + 'already ran' guard in gate_on_pass. APPROVED stamps verdict; ISSUES re-flips done→todo with cycle bump. 18 gate tests + 2 new harvest wiring tests + 121 related tests green. Shadow reviewer uncertain verdict was due to truncated diff; full diff verified manually.
luci-operator17d ago
Luci Operator: promoted this assigned `inbox` ticket to `todo` so pickup can run it.
luci-operator17d ago
Luci Operator corrected this ticket: `blocked` carried a runtime/worker failure with no unanswered worker `QUESTION:`, so it is back in `todo` for Luci/Larry/Tessa to handle.
luci-operator17d ago
Luci Operator corrected this ticket: `blocked` carried a runtime/worker failure with no unanswered worker `QUESTION:`, so it is back in `todo` for Luci/Larry/Tessa to handle.
luci-operator16d ago
Luci Operator corrected this ticket: `blocked` carried a runtime/worker failure with no unanswered worker `QUESTION:`, so it is back in `todo` for Luci/Larry/Tessa to handle.