Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
version: 1
capability:
id: harness_failure_recovery
name: Harness per-Session failure recovery
canonical_tests:
- tests/test_agent_backend_alive.py
- tests/test_agent_service.py
- tests/test_scheduled_tasks.py
- tests/test_dispatcher_stream_chunk.py
- tests/test_message_dispatcher_result_fallback.py
- tests/test_agent_stop_settlement.py
- tests/test_harness_live_status.py
shared_harness: []
status_legend:
covered: deterministic scenario or contract coverage exists
manual: validated in the local Incus black-box environment
scenarios:
- id: HFR-001
name: failure before backend acceptance releases ownership
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_agent_service.py::test_agent_service_releases_gate_when_exception_terminal_emit_fails
- id: HFR-002
name: accepted backend generation death releases owner and dispatches successor once
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_dead_accepted_owner_converges_run_session_and_persisted_fifo
- id: HFR-003
name: queued but unstarted Run remains queued behind its live Session owner
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_drain_serializes_executions_per_session
- id: HFR-004
name: >-
restart recovers a Delivery-owned Run once, and never sends user-owned queue input
or a Run queued behind a stopped user head
status: covered
kind: restart
layer: scenario
backend: shared
test:
- tests/test_scheduled_tasks.py::test_restart_recovers_delivery_owned_run_without_unrelated_run_arbitration
- tests/test_scheduled_tasks.py::test_restart_does_not_flush_user_queue_ahead_of_held_agent_run
- tests/test_scheduled_tasks.py::test_restart_does_not_auto_send_pure_user_queue
- id: HFR-005
name: live long-running owner is never stolen by age
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_agent_service.py::test_agent_service_never_steals_live_or_unknown_long_running_owner
- id: HFR-006
name: transient or unknown liveness does not release ownership
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_agent_service.py::test_agent_service_requires_dead_backend_after_grace_before_recovery
- id: HFR-007
name: late terminal cannot release or settle a successor
status: covered
kind: idempotency
layer: contract
backend: shared
test: tests/test_agent_service.py::test_late_terminal_from_recovered_owner_cannot_release_successor
- id: HFR-008
name: cancel and restart remain idempotent
status: covered
kind: idempotency
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_failed_run_records_error_and_enqueues_one_terminal_callback
- id: HFR-009
name: turn that ends without a terminal result settles its Run
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_agent_run_settles_failed_when_sink_released_without_terminal_result
- id: HFR-010
name: refused concurrent turn settles its Run instead of stranding it
status: covered
kind: failure
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_agent_run_settles_when_dispatch_refuses_a_concurrent_turn
- id: HFR-011
name: cancel landing mid-settlement stays canceled
status: covered
kind: idempotency
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_agent_run_cancel_racing_settlement_keeps_canceled
- id: HFR-012
name: user-stopped Run settles canceled, not failed
status: covered
kind: cancellation
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_agent_run_stopped_by_user_settles_canceled
- id: HFR-013
name: running Run whose owner vanished is swept terminal
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_terminalizes_orphaned_running_run
- id: HFR-014
name: Run owned by a live out-of-band turn is never swept
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_skips_running_run_owned_by_workbench_turn
- id: HFR-015
name: unknown ownership fails closed instead of sweeping
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_fails_closed_when_ownership_is_unknown
- id: HFR-016
name: queued Run stranded by a dead transport ages out with an explanation
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_terminalizes_queued_run_stranded_by_a_dead_transport
- id: HFR-017
name: queued Run merely waiting on a busy Session is never swept
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_leaves_a_queued_run_whose_session_is_merely_busy
- id: HFR-018
name: leaked Session lock is released without freeing a live one
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_releases_a_leaked_session_lock
- id: HFR-019
name: finishing predecessor cannot steal a successor's Session lock owner
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_execution_completion_does_not_steal_a_later_lock_owner
- id: HFR-020
name: staleness evidence stamp does not self-feed the drain loop
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_stranded_queued_run_does_not_trigger_repeated_metadata_writes
- id: HFR-021
name: stale transport evidence never fails a run that is deliverable now
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_spares_a_stale_transport_stamp_once_the_platform_is_back
- id: HFR-022
name: unknown queue deliverability disables the transport class
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_skips_transport_class_when_deliverability_is_unknown
- id: HFR-023
name: terminal result cannot overwrite an acknowledged stop's settlement reason
status: covered
kind: idempotency
layer: contract
backend: shared
test: tests/test_dispatcher_stream_chunk.py::test_result_does_not_overwrite_an_acknowledged_stop_stamp
- id: HFR-024
name: transport TTL is measured from the outage, not the enqueue
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_ages_a_transport_failure_from_when_it_started
- id: HFR-025
name: a transport reason with no timestamp is never acted on
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_never_terminalizes_a_transport_reason_with_no_timestamp
- id: HFR-026
name: only explicit Turn attribution owns running work; queue-hold metadata owns nothing
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_legacy_hold_metadata_does_not_change_turn_or_run_ownership
- id: HFR-027
name: gate-owned Workbench turn settles its own Run when no result arrives
status: covered
kind: failure
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_workbench_turn_settles_its_agent_run_when_no_result_arrives
- id: HFR-028
name: cancelling a Delivery-owned Run retires its queued Delivery
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_canceling_a_delivery_owned_run_retires_its_exact_queue_row
- id: HFR-029
name: backend runtime refresh settles its Run as a refresh, not a user stop
status: covered
kind: failure
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_backend_refresh_settles_its_run_as_a_refresh_not_a_user_stop
- id: HFR-030
name: terminal output that keeps the Run elsewhere is stamped turn-only
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_message_dispatcher_result_fallback.py::MessageDispatcherResultFallbackTests::test_turn_only_terminal_release_does_not_claim_the_run
- id: HFR-031
name: turn lane leaves an Activity-owned Run running
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_turn_only_result_leaves_an_activity_owned_run_alone
- id: HFR-032
name: drain lane leaves an Activity-owned Run running
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_drain_lane_leaves_a_run_whose_turn_released_without_claiming_it
- id: HFR-033
name: a recovered transport gives the next outage its own full TTL
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_grants_a_second_outage_its_own_ttl_after_a_recovery
- id: HFR-034
name: a hold parked behind a live session turn is spared
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_spares_a_hold_parked_behind_a_live_session_turn
- id: HFR-035
name: unknown live turns disable the hold class instead of failing holds
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_sweep_skips_hold_class_when_live_session_turns_are_unknown
- id: HFR-036
name: a stop's synthetic result records no run terminal
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_message_dispatcher_result_fallback.py::MessageDispatcherResultFallbackTests::test_stop_output_release_names_the_stop_and_records_no_run_terminal
- id: HFR-037
name: a stopped run settles canceled rather than succeeded
status: covered
kind: failure
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_a_stopped_run_settles_canceled_not_succeeded
- id: HFR-038
name: stop output ends the turn while preserving the request's output policy
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_agent_stop_settlement.py::AgentStopSettlementTests::test_stop_output_ends_the_turn_without_owning_the_run
- id: HFR-039
name: a backend's live stop path emits stop semantics
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_agent_stop_settlement.py::AgentStopSettlementTests::test_every_backend_stop_emits_stop_semantics
- id: HFR-040
name: no backend stop may use the terminal-turn default
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_agent_stop_settlement.py::AgentStopSettlementTests::test_every_backend_stop_emits_stop_semantics
- id: HFR-041
name: every Harness run records its terminal result text, not just agent_run
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::HarnessRunResultTextTests::test_scheduled_run_records_result_text_on_an_already_terminal_row
- id: HFR-042
name: an already-terminal run is given its missing result text without re-settling
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::HarnessRunResultTextTests::test_terminal_backfill_never_overwrites_a_real_terminal_result
- id: HFR-043
name: a recovered Activity in a suppressed Session records the result on its real Run
status: covered
kind: failure_recovery
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::HarnessRunResultTextTests::test_recovered_activity_in_a_suppressed_session_records_result_on_its_run
- id: HFR-044
name: a Harness turn attributes its background Activity to that turn's Run
status: covered
kind: failure_recovery
layer: contract
backend: claude
test: tests/test_claude_agent_initiated_turn.py::ActivityRunAttributionTests::test_scheduled_turn_attributes_its_activity_to_its_run
- id: HFR-045
name: a late result never dresses up a canceled run
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::HarnessRunResultTextTests::test_backfill_refuses_a_canceled_run
- id: HFR-046
name: a late failure never attaches an error to a succeeded run
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::HarnessRunResultTextTests::test_backfill_refuses_an_error_on_a_succeeded_run
- id: HFR-047
name: a failed harness run still receives its diagnostic result text
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::HarnessRunResultTextTests::test_backfill_still_diagnoses_a_failed_run
- id: HFR-048
name: a late success body never lands on a swept failed run
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::HarnessRunResultTextTests::test_backfill_refuses_success_text_on_a_failed_run
- id: HFR-049
name: clearing a session pauses bound definitions instead of orphaning them
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_session_archive.py::test_delete_agent_sessions_reclaims_bound_definitions
- id: HFR-050
name: shared reclaim keeps archive terminal while /new stays recoverable
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_session_archive.py::test_archive_still_soft_deletes_bound_definitions
- id: HFR-051
name: models declare the (scope, anchor) session invariant
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_sqlite_sessions_store.py::test_models_declare_scope_anchor_unique_index
- id: HFR-052
name: a same-anchor row owned by another backend is adopted, not collided with
status: covered
kind: failure_recovery
layer: contract
backend: shared
test: tests/test_sqlite_sessions_store.py::test_ensure_agent_session_id_adopts_row_owned_by_other_backend
- id: HFR-053
name: find-then-create loses the session-row race gracefully
status: covered
kind: idempotency
layer: contract
backend: shared
test: tests/test_agent_run_target.py::test_resolve_agent_run_target_tolerates_concurrent_row_insert
- id: HFR-054
name: an unresolvable pinned session notifies on its first failure and pauses its definition after three
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_execute_task_notifies_then_pauses_after_three_unresolvable_failures
- id: HFR-055
name: a create_once definition rebinds instead of failing forever
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_create_once_rebinds_when_session_deleted
- id: HFR-056
name: a rebind preserves the deleted session's agent and model
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_rebind_preserves_model_of_the_deleted_session
- id: HFR-057
name: superseding a bound session preserves its thread routing
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_superseding_a_bound_row_keeps_its_thread_routing
- id: HFR-058
name: a paused watch is given watch commands, not task commands
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_command_handler_user_names.py::CommandHandlerUserNameTests::test_new_command_gives_watches_their_own_recovery_commands
- id: HFR-059
name: a prefix clear does not hard-delete a superseded row
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_sqlite_sessions_store.py::test_prefix_clear_does_not_delete_a_superseded_row
# PR6 — P6 make failure visible. Range HFR-060…074 reserved in the plan's §10.7
# after PR1 and PR5 collided by picking ranges independently.
- id: HFR-060
name: an ordinary completion does not clobber an already-settled success
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_complete_does_not_clobber_an_already_terminal_run
- id: HFR-061
name: >-
Turn settlement does not clobber an already-settled success, a Stop that lands under
a settlement writer stays canceled with no failure notice, and an uncancelled run
still settles failed with its notice
status: covered
kind: safety
layer: contract
backend: shared
# PR6 review round 12 (#1072). THE DELIBERATE FALL-THROUGH THIS ID ESTABLISHED IS
# ALSO A HOLE. HFR-061 stopped the coalesced completer clobbering an already-SETTLED
# row by skipping terminal statuses, but it deliberately let ``canceled`` fall through
# so a cancel-requested row keeps being normalized. That exemption read
# ``cancel_requested`` from a batch snapshot and never re-asserted it, and ``cancel_run``
# is a separate transaction: pysqlite starts no transaction for the read, so the
# snapshot is genuinely older than the write and a Stop landing in the gap is
# overwritten by a ``failed`` the writer decided on BEFORE the user pressed it.
# ``settle_run_terminal`` has the reachable half of the same defect from the other
# side: it scopes its UPDATE to ``queued|running``, which catches a cancel of a QUEUED
# row because ``cancel_run`` flips that status directly -- but on a RUNNING row
# ``cancel_run`` sets only the flag, the status predicate still matches, and the write
# lands ``failed`` over the Stop. A running turn is what a user actually presses Stop
# on.
# THE DAMAGE IS TWO-LAYERED, and the second layer is why this belongs to PR6 rather
# than to the settlement lane alone: the run reads ``failed`` when the user cancelled
# it, so the Stop silently did nothing; AND a ``failed`` transition stamps an owed
# failure notice, so the drain then tells the user their task is broken because they
# cancelled it -- "a notice nobody can act on, in the lane this whole feature exists
# to make trustworthy."
# FIX: ``cancel_requested`` joins the terminal CAS as ``cancel_not_requested()``, a
# module-level SQL helper under the same ``coalesce``/``CAST`` shape
# ``owed_notice_state_unchanged`` uses -- ``coalesce`` because a NULL column reads as
# "not requested" on the Python side and NULL is not false in SQL, ``CAST`` because
# untyped storage means a text ``'0'`` must not read as truthy. The asymmetry IS the
# fix: the ``canceled`` branch keeps ``canceled`` in its status list and falls through,
# while the ``succeeded``/``failed`` branch re-asserts ``cancel_not_requested()`` and
# DROPS ``canceled`` from its list. Both halves are needed -- the status predicate stops
# the write landing on a row already flipped to ``canceled``, the flag predicate stops
# it landing on a running row where only the flag moved.
# ONE RE-READ ON A REFUSED WRITE, NEVER A LOOP, and the reason one suffices is not
# lock acquisition: a refusal means the row moved under the snapshot, so the decision
# is remade from what the row NOW says -- "otherwise a run the user cancelled
# mid-flight is simply left ``running`` and nothing ever settles it, which trades a
# wrong status for a zombie." The retry's own snapshot already sees the cancel, and
# this runs on the Workbench completion path where an unbounded retry is its own
# outage. ``settle_run_terminal`` now also RETURNS what it actually wrote rather than
# what it first decided.
# Three subordinate tests carry this id, one per writer plus the control. The cancel
# goes through the production ``cancel_run`` on a second store over the same file, not
# a hand-written UPDATE, "so what the test races against is what the Stop button
# does", and each asserts the race actually fired before judging the outcome.
# ``test_a_cancel_landing_under_the_coalesced_completer_is_not_overwritten`` and
# ``test_a_cancel_landing_under_settle_run_terminal_is_not_overwritten`` require
# ``canceled`` AND no stamped notice; red on ``a2829d3b`` for both writers, where the
# row ends ``failed`` with a notice attached.
# ``test_the_cancel_cas_does_not_leave_an_uncancelled_run_unsettled`` is the negative
# control, and it is not optional: "a ``cancel_requested`` predicate is the kind of
# guard that quietly refuses writes nobody raced -- and here that would mean a failed
# turn never settling and never owing its notice, which is a D1 loss dressed as a
# safety fix."
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test:
- tests/test_harness_failure_visibility.py::test_turn_participant_settlement_does_not_clobber_an_already_succeeded_run
- tests/test_harness_failure_visibility.py::test_a_cancel_landing_under_the_coalesced_completer_is_not_overwritten
- tests/test_harness_failure_visibility.py::test_a_cancel_landing_under_settle_run_terminal_is_not_overwritten
- tests/test_harness_failure_visibility.py::test_the_cancel_cas_does_not_leave_an_uncancelled_run_unsettled
- id: HFR-062
name: one success does not erase recent failure history in the CLI
status: covered
kind: failure
layer: contract
backend: shared
# The locator named ``test_task_last_status_does_not_report_succeeded_while_failures_are_in_window``,
# which no longer exists: #1061 demoted ``last_status`` to a compatibility field
# that never determines lifecycle, so the test was rewritten onto the
# ``health``/``recent_failures`` axis and renamed with it, and this line was left
# pointing at the old name -- a scenario id that collects nothing is an id nobody
# is testing. Repointed at the node that carries the assertion (its docstring
# self-identifies as HFR-062) rather than renaming the test back.
test: tests/test_harness_failure_visibility.py::test_definition_health_reaches_the_cli_list_after_a_success
- id: HFR-063
name: the brief task list carries the error that says why a task failed
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_brief_task_payload_carries_last_error
- id: HFR-064
name: the interruption-class vocabulary cannot drift between core and storage
status: covered
kind: safety
layer: unit
backend: shared
test: tests/test_harness_failure_visibility.py::test_storage_interruption_reasons_mirror_the_settlement_vocabulary
- id: HFR-065
name: a dead-lettered canonical notice promotes the next pending row
status: covered
kind: failure
layer: unit
backend: shared
test: tests/test_harness_failure_visibility.py::test_dead_lettered_canonical_notice_promotes_the_next_pending_row
- id: HFR-066
name: derived health survives a success after repeated failures
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_one_success_does_not_erase_recent_failure_history
- id: HFR-067
name: a result-less settlement still counts toward definition health
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_result_less_settlement_still_counts_toward_health
- id: HFR-068
name: cancellations do not bury a failure in the bounded health window
status: covered
kind: safety
layer: contract
backend: shared
# PR6 review round 10 (#1072). The window this id is named for was advertised and
# not ENFORCED. ``HEALTH_WINDOW_RUNS`` promises "the last ten verdicts", but
# ``_health_rows`` made SQLite assign ``row_number()`` to every verdict in the
# definition's entire 72 h window before the outer ``position <= HEALTH_WINDOW_RUNS``
# could discard any of them: the settled-time index narrows by time and cannot stop
# early, because the window function needs every row to rank. Measured on a 400-run
# history the plan was ``SEARCH agent_runs USING INDEX ix_agent_runs_definition_settled
# (definition_id=? AND <expr>>?)`` -- the seek is there -- followed by
# ``SCAN (subquery-3)``, ``SCAN anon_1`` and ``USE TEMP B-TREE FOR ORDER BY``, with no
# ``LIMIT`` anywhere to stop it. So a high-frequency definition walked its whole
# recent history to return ten rows.
# WHERE IT IS PAID, stated correctly because the first framing of this finding was
# wrong about it: NOT the 2 s drain tick, which does not read health at all. It is
# every Harness list, show and mutation enriched read -- the surfaces HFR-097/098
# collapsed onto ``_enrich_definitions`` -- so the cost lands on interactive reads
# once per page rather than on a background loop.
# THE OBVIOUS FIX WAS REVERTED, AND THE REVERT IS THE INTERESTING PART. A
# per-definition seek in a loop bounds the work perfectly and reintroduces exactly
# the per-row query #1033 removed; the master-owned page-budget invariant
# ``test_a_page_costs_a_fixed_number_of_queries``
# (``tests/test_harness_definition_lifecycle.py``, #1033) caught it, which is the
# invariant doing its job on a change that had every appearance of being an
# optimization. One statement per page and a bounded seek per definition pull in
# opposite directions, and both are load-bearing.
# FIX: the one shape that satisfies both, SQLite having no ``LATERAL``. The id list
# travels as ONE json parameter iterated as a ``json_each`` virtual table, and each
# id is answered by a CORRELATED scalar subquery that seeks
# ``ix_agent_runs_definition_settled (definition_id=? AND <expr>>?)`` in
# ``(settled DESC, id DESC)`` -- the index's own order, so it early-exits -- with
# ``LIMIT HEALTH_WINDOW_RUNS`` applied BEFORE anything ranks. There is no ranking
# step left at all, which is the literal ask. Results are aggregated with
# ``json_group_array`` and RE-SORTED IN PYTHON, because that aggregate promises no
# order: the inner ``ORDER BY`` is what bounds the seek, not what orders the array,
# and relying on its incidental order is a badge that flips between reads with no
# write in between. Ten entries per definition, so the sort is free. Bound parameters
# are now CONSTANT in the number of definitions, so the unpaged harness list also
# collapses to a single statement where an ``IN`` list previously had to be chunked
# one statement per 400 ids by ``_id_batches``.
# THE HONEST FRAMING OF THE TRADE, since N seeks remain: the budget invariant counts
# STATEMENTS because statement dispatch was the per-row cost #1033 removed. N bounded
# seeks are the irreducible work of answering N health questions -- what changed is
# that each is a <=10-row early exit instead of a full-window rank, paid inside one
# dispatch.
# Two subordinate tests carry this same id.
# ``test_the_health_read_is_bounded_before_it_is_ranked`` asserts BOTH properties,
# and would be wrong without either: one statement for three definitions, and a
# plan with a ``LIMIT``, no ``TEMP B-TREE``, no ``SCAN agent_runs``, and both index
# terms constrained. Asserted on the CONSTRAINED TERMS rather than an index name,
# which is the HFR-086/095 lesson -- a plan can name the index while the term that
# matters stays a per-row filter. The two residual SCANs are named and excused in
# place (the ``json_each`` id list, and the already-limited ten-row co-routine),
# because a bare ``SCAN`` assertion would have been unsatisfiable in this shape.
# Red on b3986fde with ``assert 'LIMIT' in ...`` over the windowed statement.
# ``test_the_bounded_health_read_matches_the_ranked_health_read`` is a randomized
# parity oracle keeping the replaced algorithm in the test module, the HFR-096
# pattern: the bounded read must return the SAME ten verdicts. It is GREEN ON BOTH
# SIDES by construction -- at b3986fde it compares the ranked form against its own
# reference -- so it is a no-regression oracle for the rewrite, not a detector of
# the defect.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 11 (#1072). The round-10 paragraph named the parity oracle's own
# blind spot and then relied on it anyway: the 72 h boundary. Parity is the wrong
# instrument for the window predicate, and the reason is now pinned rather than
# asserted. Measured both ways: flipping the product's ``settled >= cutoff`` to ``>``
# leaves the parity test GREEN even though the oracle keeps its own ``>=`` -- because
# the randomised fixture straddles the cutoff without ever landing ON it (its
# arithmetic floors the day, and ``now - 72 h`` is midnight), so no row exercises the
# comparison; and flipping BOTH lanes leaves it green for the second reason, that the
# two readers move together. Either way a definition whose only verdict settled
# exactly on the boundary would silently report as never-run.
# ``test_the_health_window_includes_a_verdict_settled_on_the_cutoff`` therefore
# asserts ABSOLUTELY, against a literal expected mapping, with two definitions of one
# row each: one settled at exactly ``now - HEALTH_WINDOW_HOURS`` (computed from the
# same ``now`` the read is given, so it cannot drift from the constant) which must be
# PRESENT, and one a single second older which must be ABSENT -- so an over-wide
# comparison or a cutoff with the wrong sign fails too. It also guards its own
# fixture, which is what stops it becoming a tautology: the boundary instant is
# asserted to survive the write byte-for-byte (a normalizing writer added later would
# otherwise move the row off the boundary silently), the ISO shape is checked because
# the comparison is lexicographic in SQLite, and a wider ``now`` proves the exclusion
# is a WINDOW exclusion rather than an unreadable row. Parity is kept only as the
# weaker second witness. Red by mutation (``>=`` -> ``>``), which is the honest label:
# the predicate was already correct, so this is a pin, not a fix.
# The plan test above also grew a LEXICAL bound on the LIMIT, and that is a real
# tightening rather than tidying: "a LIMIT exists" is satisfied by an OUTER
# ``LIMIT 10`` over the whole batched result, which would answer the page with ten
# rows TOTAL instead of ten per definition -- silently wrong health for every
# definition after the first. It now requires exactly one ``LIMIT``, closing inside
# the correlated per-definition subquery, and rendering before the ``FROM`` over the
# id list.
# And the parity fixture's own coverage claims were made true first, because three of
# them were false and each one silently removed a row class from the oracle: the
# legacy ``completed`` spelling was normalized to ``succeeded`` by ``enqueue_run`` on
# the way in (so the legacy lane both readers exist to honour was never exercised --
# it is now written past the front door and asserted to survive in the column), the
# ``watch_runtime`` heartbeat was written without the ``watches`` wrapper
# ``write_watch_runtime`` reads and so wrote NOTHING, and the docstring's claim to
# cover rows sitting on the cutoff was untrue -- corrected to say it straddles the
# cutoff but never lands on it, and to defer the boundary to the absolute test above.
# A fixture that claims coverage it does not have is worse than one that claims less,
# because the claim is what stops the next reviewer looking.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header) -- see the round-11
# note under HFR-099 for the re-drawn allocation.
test: tests/test_harness_failure_visibility.py::test_cancellations_do_not_bury_a_failure_in_the_bounded_window
- id: HFR-069
name: the watch supervisor heartbeat does not reset consecutive failures
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_watch_runtime_heartbeat_does_not_reset_consecutive_failures
- id: HFR-070
name: a nonterminal execution does not displace the newest verdict
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_nonterminal_execution_does_not_displace_the_newest_verdict
- id: HFR-071
name: the health window ages out on its own after the time bound
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_health_window_ages_out_after_the_time_bound
- id: HFR-072
name: one malformed metadata row does not blank health for every definition
status: covered
kind: safety
layer: contract
backend: shared
# PR6 review round 12 (#1072). THE GUARD THIS ID ESTABLISHED WAS BEING READ AS A
# CLAIM IT NEVER MADE. ``INTERRUPT_REASON_SQL``'s ``CASE json_valid`` wrapper exists
# to stop ONE bad blob failing the whole statement -- "it was never a claim that the
# row is classifiable". But a malformed blob makes that CASE yield NULL, and
# ``_not_an_out_of_band_interruption`` admits NULL, so an unreadable row was admitted
# to the health window as an ORDINARY VERDICT and counted as whatever its ``status``
# column happened to say. A definition whose history could not be read got a confident
# ``failing`` or ``healthy`` badge -- and a wrongly-CLEAN bill is the failure mode this
# whole capability exists to remove, contradicting ``HEALTH_UNKNOWN``'s own docstring
# ("a health signal that cannot be computed must not read as a clean bill").
# FIX: readability travels as a fourth element of the SAME correlated statement -- not
# as a second read, because the page-budget invariant holds this lookup to one
# statement and the round-10/11 plan tests pin the window predicates byte-identical.
# The expression is ``json_valid(coalesce(nullif(metadata_json, ''), '{}'))``, and the
# wrapper is load-bearing rather than defensive: a NULL or empty column is VALID -- an
# absent blob is not an unreadable one -- while ``json_valid(NULL)`` is NULL and
# ``json_valid('')`` is 0, either of which would otherwise mark every metadata-free run
# unreadable. It is carried as a VALUE rather than raised, because the window is per
# definition and one bad row must not take the page down, which is this id's own rule.
# ONE UNREADABLE ROW ANYWHERE IN THE WINDOW DEGRADES THE WHOLE DEFINITION TO
# ``HEALTH_UNKNOWN`` rather than being skipped, and the reasoning is worth keeping
# because skipping looks like the conservative choice and is not: "both answers this
# function can give are claims over the WHOLE window -- ``failing`` reads the newest
# verdict and ``healthy`` asserts the absence of a failure across all of them -- so a
# window with a hole in it cannot support either." The counters go out as ``(0, 0)``,
# the same shape ``definition_health_batch`` already reports when the read itself
# raises, so a caller rendering "N consecutive failures" beside an unknown badge cannot
# print a number that was never computed. The degrade is scoped to the WINDOW, not the
# lifetime -- otherwise one ancient bad blob would blank a definition's badge forever.
# THE ASSERTION ON THIS ID'S OWN TEST WAS ALSO TIGHTENED, and the loosening it
# replaces is instructive: it read ``health in {"failing", "unknown"}``, a disjunction
# that was green on the broken code. It is now an equality on ``unknown``, so this
# entry's semantics strengthen without its locator moving.
# One subordinate test carries this id --
# ``test_a_malformed_history_row_reports_unknown_rather_than_a_verdict`` -- with three
# definitions: the unreadable row newest (so "the latest run failed" is unknowable),
# inside the window but not newest (so ``degraded`` is not answerable either), and aged
# out of the window by eleven later successes, which must still read ``healthy`` and is
# the negative control for the scoping claim.
# It takes no id of its own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_one_malformed_metadata_row_does_not_blank_health_for_every_definition
- id: HFR-073
name: a second failure in one streak is skipped rather than notified
status: covered
kind: failure
layer: unit
backend: shared
test: tests/test_harness_failure_visibility.py::test_second_failure_in_streak_is_skipped_not_notified
- id: HFR-074
name: a second failure defers while the streak's first notice is still pending
status: covered
kind: failure
layer: unit
backend: shared
test: tests/test_harness_failure_visibility.py::test_second_failure_defers_while_first_notice_is_still_pending
# PR6 review round 2 (#1072). PR6's reserved range ends at HFR-074, which the
# entries above consume in full, so these four BORROW from PR2's HFR-075…089
# block. Flagged rather than taken silently — §10.7 exists because PR1 and PR5
# picked ranges independently. PR2 must start at HFR-079, or the plan should
# extend PR6's range to 078 and PR2's block move up.
- id: HFR-075
name: the duplicate short-circuit reports its receipt as delivery evidence
status: covered
kind: failure
layer: contract
backend: shared
# PR6 review round 7 (#1072). A subordinate test carries this same id --
# ``test_the_duplicate_short_circuit_receipt_acks_a_workbench_rung`` -- because
# once the workbench target class may acknowledge ONLY on a persisted receipt,
# "which evidence does the dedup path report" stops being a bookkeeping detail
# and becomes the difference between a redelivery loop and a correct ack. The
# short-circuit fires when ``agent_message_exists`` already sees the notice's
# idempotency key: nothing is re-sent, so if that path reported ``delivery_only``
# an avibe notice whose row is already durable would be refused on every pass,
# burn its attempts and dead-letter a receipt the user demonstrably has.
# NO PRODUCT FIX WAS NEEDED: the short-circuit already fills
# ``DeliveryEvidence.persisted_row`` with a ``duplicate_short_circuit`` receipt,
# so it classifies as ``receipt`` and satisfies the strict source. The test pins
# that in the terms the policy is written in -- it asserts the target's declared
# ack source IS the receipt-only one and that ``_rung_acknowledges`` accepts the
# evidence -- so a later refactor of the dedup branch cannot silently downgrade
# it. Verified red by dropping the ``persisted_row`` assignment: both this and the
# original test then fail on ``'delivery_only' == 'receipt'``.
# It takes no id of its own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_the_duplicate_short_circuit_reports_its_receipt
- id: HFR-076
name: a raising delivery rung consumes an attempt instead of retrying forever
status: covered
kind: safety
layer: contract
backend: shared
# PR6 review round 6 (#1072), F8. A second, subordinate test carries this same
# id -- ``test_a_stale_drain_pass_cannot_overwrite_a_newer_acknowledgement`` --
# the same bound attacked from the other side of the clock. During a service-lock
# handoff an old drain can stay suspended in the awaited send while the new owner
# reads the same pending notice and delivers it; the late pass's
# read/modify/write was keyed by run id alone and guarded only on the notice
# still EXISTING, so it could rewrite ``sent`` back to ``pending`` -- re-sending
# a delivered notice -- or forward to ``failed``, a dead letter burying a real
# receipt. Ownership is checked once at the top of the pass and never re-checked
# across the await, which is the check-then-act gap.
# FIX: every drain write re-asserts the ``(state, attempts)`` it was decided
# from inside ``update_owed_failure_notice`` (as a Python comparison in this round;
# see round 8 below, which moved it into the UPDATE's WHERE clause) -- the
# same write-re-asserts-its-read idiom as ``DefinitionWriteExpectation``, without
# reusing the class, whose predicate is over ``run_definitions`` lifecycle
# columns rather than a blob in ``agent_runs.metadata_json``. ``attempts`` is in
# the predicate so two passes reading the same value cannot both consume the
# increment, and ``updated_at`` deliberately is NOT: a fresh stamp does not carry
# it, which would make the guard refuse every write. The losing pass no-ops
# silently rather than raising, because it has nothing to repair and the next 2 s
# tick reads the winner's state; raising would log an exception on every handoff.
# It takes no id of its own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 7 (#1072) audited that guard for TOTALITY rather than for the
# one write the finding named, because a CAS that covers four of five writes
# protects nothing. Every production transition of a notice AFTER the drain's read
# now passes the expectation: the deferral (backoff + ``defer_reason``), the skip,
# the ack, the dead letter and the retry -- five call sites, one read, one
# ``expect``. The deferral is the easy one to miss, since it consumes no attempt,
# but it does move ``next_attempt_at`` and would have shadowed a newer pass's ack
# behind a fresh backoff. Two neighbouring writers were audited and deliberately
# left unguarded: ``_merge_owed_failure_notice``'s four call sites are terminal
# STAMPS folded into the same UPDATE that transitions ``agent_runs.status``, and
# ``_owed_failure_notice_for_transition`` refuses to overwrite an existing notice
# at all. That half still holds: both ride the transition itself, so there is no gap
# and an expectation there would have nothing to compare against. The remaining
# unguarded calls are test-only backoff rewinds.
# CORRECTED IN ROUND 9. The same audit also excused ``stamp_binding_change_notice``
# as "likewise a pre-read stamp inside its own guarded read/modify/write ... not a
# post-read transition, so an expectation there would have nothing to compare
# against". That was right about the ORDER and wrong about the CONNECTION: the
# excuse only covers a competing pass on the same statement, and cyhhao
# demonstrated it fails across connections. The stamp reads a LIVE run and runs
# before ``complete()``, so a second connection can settle that row -- ``failed``
# (stamping its own notice) or ``canceled`` -- between its SELECT and its UPDATE,
# exactly the gap this id's own guard was moved into SQL to close.
# FIX: the stamp now carries a CAS of its own in the UPDATE's WHERE clause -- the
# status the SELECT saw, verbatim, plus ``owed_notice_absent()`` plus ``json_valid``
# over the same expression -- and writes through ``json_set`` rather than a composed
# blob. See HFR-099's round-9 paragraph for both damage directions and the tests.
# PR6 review round 8 (#1072) found the guard itself was a CHECK-THEN-ACT: it read
# the row, compared ``(state, attempts)`` in Python, then issued its UPDATE, and
# under pysqlite a bare SELECT emits no ``BEGIN`` (the same fact
# ``upsert_definition_in_connection`` documents), so no lock spans that gap and the
# write lock is first taken by the UPDATE. Two passes could both read
# ``(pending, N)``, both pass the comparison, and both write -- the round-6 guard
# narrowed the window from a whole awaited send to sub-millisecond without closing
# it, and the losing write is the terminal ``failed`` dead letter.
# FIX: the predicate moved into the UPDATE's WHERE clause
# (``owed_notice_state_unchanged``), evaluated by SQLite in the same statement that
# writes, with the loss read off ``rowcount`` -- the ``DefinitionWriteExpectation``
# idiom now in full, not just in shape. Two subordinate tests carry this same id:
# ``test_a_notice_write_refuses_a_race_settled_after_its_own_read`` commits the
# winner from a second connection INSIDE that gap (a
# ``before_cursor_execute`` hook on the loser's UPDATE), which only an SQL-level
# predicate survives, and
# ``test_the_notice_expectation_reads_the_same_in_python_and_in_sql`` pins the cost
# of the move -- ``notice_write_expectation`` and its new SQL twin must normalize a
# missing/null/string/non-integer ``attempts`` identically, or the guard would
# refuse writes nobody raced.
# They take no id of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 8 (#1072), SECOND FINDING: that CAS is a write guard, and the
# duplicate it prevents is a duplicate ROW, not a duplicate MESSAGE. It correctly
# stops a stale pass from overwriting a newer acknowledgement, but it does not
# stop the stale pass from DELIVERING. Both owners can read ``pending``, both then
# await ``_emit_failure_notice``, and only after the external send does either
# attempt the CAS -- so the loser is refused at the database having already spoken
# to the user. ``MessageDispatcher.emit_agent_message`` checks
# ``agent_message_exists`` before ``send_message`` and persists after it, so two
# concurrent drain owners both pass the pre-send lookup and both send before
# either receipt exists; the unique persisted ``(platform, native_message_id)``
# row resolves only the later database race and cannot recall the duplicate
# message already delivered.
# FIX: the attempt is CONSUMED BEFORE the external send, as a guarded claim
# through the existing CAS (``expect=(pending, N)`` evaluated by SQLite in the
# UPDATE's WHERE clause), so exactly one of any number of passes that read
# ``(pending, N)`` wins and every loser returns WITHOUT SENDING.
# ``next_attempt_at`` doubles as the recovery lease
# (``CLAIM_LEASE_SECONDS = 600.0``, chosen above both the worst-case five-rung
# ladder walk at ~30-60 s adapter HTTP timeouts and the 512 s backoff cap), so a
# claimant that dies mid-send is reclaimed after a bounded delay instead of
# stalling forever -- no SQL text change and no migration, since the lease rides
# the column the eligibility index already ranges on. The post-read guard in
# ``_deliver_one_failure_notice`` widens from a bare ``state == pending`` check to
# full eligibility (``owed_notice_eligible``, factored in ``storage/background.py``
# and shared with ``list_owed_failure_notices``' own Python re-check so the two
# copies cannot drift). That half is not optional: the claim ALONE is insufficient,
# because an owner that listed before the claim would re-read ``(pending, 1)`` and
# send a duplicate anyway.
# Two further subordinate tests carry this same id.
# ``test_two_owners_reading_one_pending_notice_deliver_it_exactly_once`` runs two
# services over one SQLite file on two connections, suspends the first exactly at
# the IM adapter's send boundary, lets the second take ownership and run to
# completion, and asserts exactly one outbound send and one durable receipt --
# red on 93c1b379 with "got 2".
# ``test_a_dead_claimants_lease_expires_into_exactly_one_recovered_delivery``
# cancels the claimant while it holds the lease, rewinds the lease, and requires
# recovery to deliver once while consuming its OWN claim, so ``attempts == 2``.
# THE RESIDUAL IS AT-LEAST-ONCE DELIVERY, AND MUST NEVER BE DESCRIBED AS
# EXACTLY-ONCE. A duplicate now requires the claimant to die (or stall past the
# lease) AFTER the transport accepted the send and BEFORE
# ``persist_agent_message`` committed; a crash after the receipt persisted is
# absorbed by the HFR-075 duplicate short-circuit, which reports the found row as
# a receipt and acks. Before this fix duplicate delivery was SYSTEMATIC -- every
# concurrent-owner race duplicated, with a window the full width of a send and no
# crash required. What remains is irreducible without a transport-honoured
# idempotency key, which Slack/Discord/Telegram plain sends do not offer.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 9 (#1072). The claim bounds a competing owner, and by lease
# expiry it bounds an owner that DIES. Neither bounds an owner that never RETURNS. A
# transport that accepted the request and hung -- a half-open socket, a platform that
# stopped answering, an adapter with no timeout of its own -- leaves the pass
# suspended inside the send, the row ineligible for as long as the lease holds, and
# nothing anywhere reporting it: the drain is not crashed, it is STOPPED, so this
# notice and every notice behind it are owed indefinitely.
# FIX, in two halves that are both required.
# (a) ``NOTICE_DELIVERY_TIMEOUT_SECONDS = 300.0`` bounds ONE delivery -- the whole
# ladder walk, not one rung. The worst legitimate five-rung walk (each rung able to
# sit on an adapter's 30-60 s HTTP timeout) comes to AT MOST this same 300 s, so
# the bound MATCHES the worst case rather than exceeding it: a walk that saturates
# every rung's timeout is consumed as an ordinary failed attempt, retried on the
# declared backoff, and a rung that had already persisted its receipt is absorbed
# by the duplicate short-circuit on the retry. The deadline also stays strictly
# BELOW ``CLAIM_LEASE_SECONDS``' 600 s, so a timed-out claimant is cancelled and its
# backoff durably written while its OWN lease still holds and a replacement claimant
# can never coexist with a transport coroutine that is still unwinding. The deadline
# CONSUMES the claim rather than rewinding it: the attempt was already made durable
# before the send, so the timeout takes the ordinary retry path under the claim's own
# ``expect`` and arms the declared interval. Rewinding ``attempts`` instead would let
# a transport that hangs every time retry without bound and never dead-letter --
# precisely the unbounded loop this id exists to prevent, reached by a different
# road. ``asyncio.wait_for`` cancels the inner task and AWAITS that cancellation
# before raising, so no detached transport coroutine survives the deadline.
# (b) The drain is no longer awaited by ``_watch_store``; it is dispatched as a
# SINGLE-FLIGHT background task. The deadline alone would only shorten the stall to
# 300 s, and a deadline short enough to hold a 2 s tick would cancel legitimate
# deliveries -- and the watch is one coroutine running every periodic pass in
# sequence, so a wedged notice stalled request draining, callbacks, vault callbacks
# and the stale-run sweep too. Single-flight rather than a task per tick, which would
# replace a stalled loop with an unbounded pile of coroutines each re-reading and
# re-claiming: a tick that finds the previous pass still running simply skips, since
# eligibility is re-read from the row every pass. The dispatched task's exception is
# retrieved in a done callback, because a fire-and-forget pass has no reader and a
# drain that has been failing every tick for a week would otherwise surface only as
# an asyncio "never retrieved" warning at collection time.
# SAME ROUND, THE SEQUENCE ITSELF WAS OFF BY ONE. ``BACKOFF_SECONDS`` declares five
# intervals, and the arming indexed on the INCREMENTED attempt number: the first
# failed attempt armed ``BACKOFF_SECONDS[1]``, so the 2 s rung was never used, the
# 512 s cap was never reachable, and the ladder ran 8/32/128/512 and dead-lettered a
# rung early. Not cosmetic -- ``CLAIM_LEASE_SECONDS`` is justified as exceeding
# ``BACKOFF_SECONDS[-1]``, an invariant about an interval the code could not arm.
# FIX: the Nth failed attempt arms ``BACKOFF_SECONDS[N - 1]``, one interval per
# consumed attempt in order, and ``MAX_ATTEMPTS`` is DERIVED as
# ``len(BACKOFF_SECONDS) + 1`` rather than chosen, because N attempts are separated
# by N-1 waits plus the attempt that finds no interval left. Total ladder time moves
# 680 s to 682 s.
# Four subordinate tests carry this same id.
# ``test_a_wedged_delivery_times_out_into_one_durably_retryable_claim`` wedges the
# send, requires the delivery to RETURN, and asserts the row comes back as ONE
# durably retryable claim: the attempt consumed, the declared interval armed, no
# second send.
# ``test_a_wedged_notice_delivery_does_not_stall_the_store_watch`` wedges one notice
# and requires an unrelated periodic pass to keep ticking -- red on 93c1b379 by
# hanging until the test's own deadline, which IS the defect.
# ``test_backoff_spaces_attempts_and_terminates_in_a_dead_letter`` is strengthened
# from "the spacing increases" to the exact sequence, plus both exhaustion edges:
# every declared interval armed exactly once in order, and the attempt that finds
# none left dead-letters. Red on 93c1b379 with ``[8, 32, 128, 512] != [2, 8, 32,
# 128, 512]``.
# ``test_the_notice_timing_constants_bound_each_other_as_documented`` pins the
# arithmetic both prose arguments rest on, so retuning one constant cannot silently
# invalidate the other's justification.
# THE RESIDUAL IS UNCHANGED, AND MUST STILL NEVER BE DESCRIBED AS EXACTLY-ONCE.
# Cancel-after-transport-accept is a SECOND ENTRANCE to the at-least-once window
# ``CLAIM_LEASE_SECONDS`` already documents, not a new one: a claimant cancelled
# after the transport accepted its request has delivered without acknowledging,
# which is the state a dying claimant leaves. And the deadline's bound is a STATED
# ASSUMPTION about our adapters rather than a proof -- none of them swallow
# ``CancelledError``, but one that did would hang the deadline too and re-wedge the
# dispatched drain task, though no longer the store watch. That is what half (b) buys
# on top of half (a): it confines the failure to notice delivery instead of stopping
# every periodic pass.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 12 (#1072), THREE FINDINGS on this id.
# (D) THE CAS WAS INCOMPLETE, AND THE ROUND-8 PARAGRAPH ABOVE DESCRIBES IT AS
# ``(state, attempts)`` BECAUSE THAT IS WHAT IT WAS. Eligibility is decided from THREE
# fields -- ``owed_notice_eligible`` reads ``state`` and ``next_attempt_at``,
# ``next_attempt`` reads ``attempts`` -- and the one left out is the only field a
# DEFERRAL writes. A deferral touches neither ``state`` nor ``attempts``, so a claimant
# that read before a concurrent owner's deferral still matched its own expectation, won
# the CAS, and ERASED the deferral: two notices per streak in the stale-cutoff lane, and
# a ``DEFERRAL_RECHECK_SECONDS`` that any stale claimant could cancel -- which is the
# starvation the durable deferral exists to prevent.
# FIX: ``notice_write_expectation`` returns ``(state, attempts, next_attempt_at)`` and
# ``owed_notice_state_unchanged`` gains the third predicate, reusing
# ``OWED_NOTICE_NEXT_ATTEMPT_SQL`` verbatim rather than retyping it -- "a divergent copy
# of an indexed expression is exactly how the eligibility index was built and silently
# ignored twice." ``next_attempt_at`` and NOT ``updated_at``, which
# ``DefinitionWriteExpectation`` deliberately refuses: a row-version marker refuses
# benign writes and a freshly stamped notice carries none, whereas ``next_attempt_at`` is
# stamped unconditionally by every stamper and a legacy notice predating the field reads
# ``""`` identically on both sides. Deliberately NOT stripped on the Python side, unlike
# ``owed_notice_eligible``, because SQLite does not strip and stripping here would refuse
# a write over a padded instant nobody raced. A completion of round 8's value-CAS to the
# decision's full read-set, not a reversal of it.
# THE ROUND-8 KNOWN-BY-DESIGN SENTENCE IS RETRACTED. Round 8 recorded, as a deliberate
# non-guarantee, that two owners deferring one notice from the same read BOTH land. They
# no longer do: the first moves the field the second re-asserts, so the second LOSES.
# That is correct under the new contract rather than a benign-refusal regression, and the
# distinction is the observable state -- "the refused write was refused because the world
# had already moved to the state it was trying to establish". The outcome is
# observationally identical: the notice is deferred either way, no attempt is consumed
# either way, and the two recheck instants differ by the microseconds between two owners
# reading the clock. Pinned by
# ``test_a_second_identical_deferral_loses_the_cas_without_changing_the_outcome``, beside
# ``test_a_stale_claim_cannot_overwrite_a_concurrent_deferral``. Two pre-existing tests
# were widened in place rather than renamed: the race test now asserts ``expect[:2]``
# plus the live instant rather than a literal that would pin a wall clock, and the
# Python/SQL parity test grows five ``next_attempt_at`` shapes and a third "wrong
# neighbour" tuple, "because a predicate that silently ignored the third element would
# pass every other assertion in this test".
# (F) A MALFORMED ``attempts`` WEDGED THE BATCH INSTEAD OF DEGRADING. ``next_attempt``
# did ``int(notice.get("attempts") or 0)``, which raises on a nonnumeric string or a
# container. Nothing crashes -- the drain's per-row handler catches it -- "and that is
# precisely what makes it bad": the exception escapes BEFORE the claim, so it writes NO
# state, the row keeps its malformed value, stays eligible, and re-occupies a slot in the
# batch of ten on every 2 s tick. Every notice behind it starved, with a log line per
# tick and a drain that looks busy rather than broken. FIX: ``_attempts_read`` degrades
# to 0. Not a fresh choice -- ``notice_write_expectation`` already normalizes this field
# the same way for the CAS predicate, and SQLite's
# ``CAST(coalesce(json_extract(...), 0) AS INTEGER)`` reads a nonnumeric value as 0 too,
# so all three readings agree, "which is what lets the guarded write MATCH and the row
# advance through claim, backoff and -- if it keeps failing -- the visible dead letter. A
# different degraded value here would refuse the claim on every pass and reach the same
# wedge by a quieter road." Three subordinate tests:
# ``test_a_malformed_attempts_value_degrades_instead_of_raising`` over six shapes,
# ``test_the_python_and_sql_readings_of_a_malformed_attempts_agree`` for the three-way
# agreement, and ``test_a_malformed_attempts_row_advances_instead_of_occupying_the_batch``
# for the consuming outcome -- the batch slot released, not re-occupied forever.
# (L) ONE PASS COULD HOLD THE WHOLE BACKLOG -- and the obvious diagnosis is REFUTED
# FIRST, which is why this paragraph is worth reading twice. A wedged batch does NOT
# re-select itself forever: ``list_owed_failure_notices`` orders by ``next_attempt_at
# ASC``, least-recently-deferred first, so the fresh backoff instants a slow pass just
# armed sort BEHIND a notice stamped while it was working, and the newcomer is picked up
# next pass. Starvation by re-selection was already closed by that ordering. What IS the
# defect is the SERIAL COST of one pass: deliveries within a pass run one at a time
# deliberately -- row #2 of a streak only observes row #1's ``sent`` because the passes
# are ordered, so parallelising them reopens the same-streak duplicate window that
# serialization closes -- but a batch of ten each legitimately sitting on
# ``NOTICE_DELIVERY_TIMEOUT_SECONDS`` is 3000 s, fifty minutes, before the pass so much
# as returns, and a notice stamped one second in waits behind all of it. So the fix is a
# BUDGET, not concurrency: ``NOTICE_DRAIN_PASS_BUDGET_SECONDS``, declared derivationally
# as ``2 * NOTICE_DELIVERY_TIMEOUT_SECONDS`` rather than as a literal 600.
# Two-sided, like every other constant on this id: at least ONE full worst-case delivery,
# or a pass could spend its budget before finishing the notice it started and make no
# progress at all; and small enough that a fresh notice's wait is a function of the
# budget rather than of the batch size -- worst wait becomes budget plus one delivery
# instead of ten deliveries, and stops growing when the batch limit does. Checked BETWEEN
# notices and never mid-delivery: "cancelling a delivery already on the wire would trade
# a slow pass for a duplicate, and the walk already has its own deadline." A truncated
# pass costs the rows it did not reach NOTHING -- never claimed, no attempt consumed, no
# backoff armed, and the ASC ordering puts the oldest of them first. Two subordinate
# tests: ``test_one_pass_stops_at_its_fairness_budget_instead_of_holding_the_backlog``
# and ``test_the_pass_budget_admits_one_full_worst_case_delivery``, the lower side of the
# argument as an assertion.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_a_raising_delivery_consumes_an_attempt_instead_of_retrying_forever
- id: HFR-077
name: a drained failure notice does not become a live auth prompt
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_the_drain_does_not_turn_an_owed_notice_into_a_live_auth_prompt
- id: HFR-078
name: the owed-notice lookup is bounded in SQL and does not scan settled history
status: covered
kind: safety
layer: contract
backend: shared
# PR6 review round 12 (#1072). The eligibility lookup was bounded here, and HFR-095
# bounded the streak read, but ONE read on the same 2 s tick was still deciding in
# Python what the index could decide for it: ``earliest_unsettled_run_before``
# selected every ``queued``/``running`` row for the definition and applied both the
# anchor position and the staleness cap as a Python ``continue``. So a definition
# holding a large nonterminal backlog -- a paused ``create_per_run`` task, a queue
# drained slower than it fills -- paid that whole backlog per notice per tick "to
# answer a question whose answer is at most one row".
# FIX: both filters become SQL TERMS. The anchor is a ROW VALUE
# (``(created_at, id) < (?, ?)``) for the reason ``failure_streak_decision`` spells
# out -- ``created_at`` alone is not a position, because several writers stamp a whole
# batch with one value, and a row value keeps the tie-break IN the comparison where
# SQLite can constrain it with the index. The staleness cap becomes a lexicographic
# ``created_at >= cutoff``, and ``LIMIT 1`` states in the statement what the docstring
# already claimed. Served by ``ix_agent_runs_definition_streak``
# (``definition_id, created_at, id``): under the older two-column index SQLite
# decomposes the row value into a weaker scalar range and recovers the tie-break with
# ``USE TEMP B-TREE FOR LAST TERM OF ORDER BY``, which defeats the ``LIMIT 1``'s early
# exit -- so the third key is what makes the bound real, not tidiness.
# ONE DIVERGENCE IS DOCUMENTED RATHER THAN HIDDEN, and it is a deliberate behaviour
# change: the Python filter asked ``_parse_iso_instant`` and SKIPPED the staleness test
# when the answer was ``None``, so a row whose ``created_at`` cannot be parsed read as
# fresh and blocked the notice for as long as it stayed nonterminal -- "a wait nothing
# can bound". A lexicographic cutoff has no such escape and may class the same value as
# stale, treating it as settled. That is the duplicate-not-lost direction the cap
# itself already chose, so it is the acceptable side to land on. The boundary is
# preserved exactly: ``>=``, because the Python test skipped on
# ``> stale_after_seconds`` and a row exactly at the cap was kept.
# Three subordinate tests carry this id.
# ``test_the_predecessor_read_is_bounded_and_seeks_rather_than_scans`` asserts the
# RESULT-SET SIZE separately from the plan, which is the reusable lesson: "a read that
# filters in Python passes both a statement-count budget and a plan that names an
# index while still materialising an unbounded population."
# ``test_the_sql_predecessor_read_matches_the_python_filtered_one`` is the parity
# oracle against ``_python_earliest_unsettled_before``, byte-for-byte the production
# algorithm as of ``3578f2b6``.
# ``test_an_unparseable_created_at_reads_as_stale_rather_than_as_a_blocker`` pins the
# divergence above as intended rather than accidental.
# A fourth names the two cases the randomised fixture only SAMPLES --
# ``test_the_predecessor_read_breaks_created_at_ties_by_id_and_stays_bounded_on_no_match``
# -- because "reproducible is not the same as named": nothing in a seeded fixture fails
# if the tie-break regresses for a reason its row pool stops generating. It pins both
# failure directions of the tie (a scalar ``<`` drops the whole tied group and loses a
# real blocker, the duplicate direction; a scalar ``<=`` admits the anchor itself and
# defers every notice behind its own run forever) and requires the ``None`` answer to
# stay bounded too, since ``None`` is what RELEASES the notice and is the common case
# on a healthy definition. Red on ``b43837f7``: the no-match read handed Python 2 rows.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_the_owed_notice_lookup_does_not_scan_settled_history
# PR6 review round 5 (#1072). HFR-079 was the one id left unused when the round-3
# block started at 080; the block is PR6's up to 099, so it is taken here rather
# than skipped.
- id: HFR-079
name: a replayed failure notice reaches the user without touching the live lifecycle
status: covered
kind: safety
layer: contract
backend: shared
# The drain replayed a historical failure through the LIVE emitter and then
# neutralized its live behaviour one argument at a time: a non-settling output,
# an auth-recovery bypass, an explicit failure id. ``settle_terminal_failure``
# still ran in a ``finally``, so the replay stayed inside the live turn
# lifecycle with a defused payload — and four review rounds found a settlement,
# an auth and an identity defect in the gaps between those switches.
# FIX: ``core/backend_failure.py::emit_replayed_backend_failure`` — one visible
# ``notify`` built from ``backend_failure_notification_output`` and nothing else.
# No ``result``, so no turn settlement, no status-bubble teardown and no
# runtime-turn release can be reached at all; no auth recovery; an identity that
# is authoritative by construction. The run is terminal by construction too: a
# notice is owed only once the row is settled.
# Asserted at both ends over a real dispatcher and a migrated state DB: the user
# gets the persisted notify row and the notice acks on that receipt, AND the live
# emitter is unreachable (patched to raise under both module spellings, with the
# drain's import proven absent), exactly one emission and it is the notify, the
# output settles neither turn nor run, no live-turn hook fires, and the
# controller's auth service raises on any attribute read.
# PR6 review round 6 (#1072), F7. Two further subordinate tests carry this same
# id -- ``test_a_workbench_addressed_notice_lands_as_a_durable_inbox_row`` and
# ``test_an_avibe_rung_does_not_ack_on_a_synthetic_send_id`` -- because "reaches
# the user" never held for a workbench-addressed rung. This test set
# ``deliver_key="slack::channel::C123"`` and so only ever exercised rung (1);
# every ``avibe::project::...`` target -- the bound session's scope, the creator
# scope, and rung (5) itself -- was parsed with ``parse_session_key``, which
# rejects the ``project`` scope type, and ``_add`` swallowed the error. For an
# Avibe-only definition the ENTIRE ladder was empty, so its failures exhausted
# their retries and dead-lettered instead of notifying.
# FIX: ``_add`` falls back to ``parse_scope_id`` for three-part scope ids -- five
# part ``::thread::`` keys stay on the strict parser, which is the only one that
# can express a thread -- and an avibe rung acknowledges on the persisted
# ``messages`` receipt ONLY. That second half is not optional:
# ``AvibeBot.send_message`` mints a synthetic id whether or not anything durable
# landed, so a ``delivery_only`` ack would have flipped "nowhere to write the
# row" from a visible dead letter into a permanent false ``sent`` -- strictly
# worse than the bug. Receipt-gating one platform in turn forces PER-RUNG
# evidence, since a single ``DeliveryEvidence`` latches ``delivered`` on the
# first ``delivered_id`` and one rejected rung would otherwise vouch for every
# later one.
# The delta rung (5) really buys is an ARCHIVED session: ``_session_row`` has no
# status filter where ``resolve_session_id_target`` refuses archived, so rung (2)
# is gone and rung (5) still delivers. A run whose session row is gone entirely,
# and a definition that never had one, still dead-letter VISIBLY -- the
# workspace-level inbox scope that would close that is product surface, not a bug
# fix. They take no ids of their own because PR6's block is full at 099 and 100+
# is contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# RETRACTED IN ROUND 12 -- and it is the sentence directly above that is wrong, so
# read it as history rather than as contract. "A run whose session row is gone
# entirely, and a definition that never had one, still dead-letter VISIBLY" was
# recorded as Known-By-Design across four rounds, on the reasoning that the
# workspace-level inbox scope which would close it "is product surface, not a bug
# fix". THE PLAN DISAGREES, IN WRITING AND BY NAME. #1044 merged carrying two dated
# corrections that assign exactly this to PR6:
# "Rung (5) is mandatory, not an implementation check (corrected 2026-07-27)" --
# which names the earlier conditional framing as "a way to ship PR6 with the failure
# still silent" -- and "'Widen the push helper' was not a mechanism (corrected
# 2026-07-29, review)", which specifies the synthetic workspace-notifications session
# and says outright "This is in PR6's scope, not a follow-up, because without it rung
# (5) is as empty as the four above it" (docs/plans/harness-run-reliability.md
# :3170-3174, :3196-3222, with the D5 body requirement at :3165-3168).
# THE POPULATION THIS WAS LOSING is not exotic: a definition created by a plain
# ``vibe task add`` records no caller provenance at all
# (``_definition_creation_metadata_from_caller`` returns ``{}`` for a null caller
# context), so rungs (3) and (4) are empty; with no deliver key and no session
# binding, rungs (1), (2) and the session-derived rung (5) candidate are empty too.
# EVERY rung empty meant the notice could only dead-letter -- visible to somebody who
# goes looking, which is precisely the population D1 is about.
# FIX (round 12): the blocker was a missing HOME, not a missing writer.
# ``persist_agent_message`` declines to write only when an avibe context resolves
# neither a scope nor a session row, so rung (5) now resolves-or-creates ONE reserved
# workspace-notifications session (``resolve_workspace_notice_session`` in
# ``storage/agent_session_rows.py``) and addresses it exactly like any other avibe
# session: the same ``avibe::project::<session id>`` candidate, the same
# ``_session_row`` lookup, the same receipt-only ack policy the paragraph above
# forced, and the same inbox / unread / realtime / Web Push machinery. Nothing
# downstream learns a new row shape, which is the whole point -- the rejected
# alternative was a sessionless inbox row, and the plan's own correction records why
# that fails: the inbox is per-session by construction at four layers, so widening
# the push helper alone "creates nothing -- there is no row to notify about".
# THREE IMPLEMENTATION CHOICES DIVERGE FROM THE PLAN'S SKETCH, each for a reason
# worth keeping, because the plan asked for a row "hidden from ordinary session
# lists, exempt from ``/new`` clears and eviction".
# * NOT hidden. ``visibility='background'`` is filtered out of
# ``list_inbox_sessions``, so hiding the row would hide the inbox card rung (5)
# exists to show -- the plan's own requirement defeats itself. The row is
# ``foreground`` and named through ``vibe/i18n`` instead
# (``harness.notice.workspaceSession``).
# * NOT exempt. Durability is by lazy RECREATION rather than by exemption, so no
# ``/new`` clear path and no eviction code learns a special case (no PR5 file is
# touched); if the row is removed, the next notice simply makes it again.
# * Idempotence rests on the PRIMARY KEY, not on a lock alone:
# ``WORKSPACE_NOTICE_SESSION_ID`` is spelled outside ``SESSION_ID_ALPHABET``, so
# ``new_session_id`` can never mint it, and the create re-decides under
# ``reserve_write_lock`` so two racing drain owners produce one row. The row
# carries NO scope, because every avibe project scope is a row in
# ``list_projects`` and a reserved one would mint a fake sidebar project.
# The old pin is INVERTED rather than deleted --
# ``test_a_session_less_definition_dead_letters_rather_than_going_silent`` is now
# ``test_a_session_less_definition_now_reaches_the_workspace_inbox`` -- and the
# plan's two owed tests exist by name:
# ``test_a_caller_less_cli_definition_still_delivers_its_failure_notice``, built with
# ``caller_context=None`` so the emptiness is STRUCTURAL rather than mocked, and
# ``test_workspace_notification_session_is_created_once_and_reused``.
# RESIDUALS, three, stated because none of them is closed: the session appears in
# ordinary session lists (the direct cost of choosing foreground over hidden); its
# ``agent_backend`` is empty, since it has no backend and no turns; and D5's
# remaining body item -- the creation channel/thread with a deep link -- is NOT
# implemented, only the failure class and last-success lines are (see HFR-094's
# round-12 paragraph). That half awaits the plan's numbered-deferral mechanism rather
# than being claimed here.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header) -- and the offer to
# take §10.7's re-drawn HFR-280...319 block is WITHDRAWN as of round 14, for two
# independent reasons. The first is a ruling: cyhhao declined to consume an id for this
# round, so the subordinate tests documented throughout this file stay subordinate by
# DECISION, not merely because the block was full. The second is stronger and outlives
# the ruling: THAT BLOCK IS ALREADY DEAD. Master landed HFR-280 in ``807d1eee``
# (``feat(search): opt-in include-archived``) -- an unrelated PR that took the first id
# of the block §10.7 had just re-drawn for PR6 -- and §10.7's own rule is explicit:
# "an overflow block is dead the moment a landed catalog occupies any of it; reassign
# from above the highest landed ID, never reuse or straddle." So this is the THIRD
# occurrence of the exact failure §10.7 was written to prevent (after PR1/PR5 both
# claiming 041...048, and PR5's overflow landing across blocks promised to
# PR6/PR2/PR3), and it arrived the same way each previous one did: silently, visible
# only on comparing branches by hand. Any future assignment for these tests must be
# re-drawn above the highest landed id rather than taken from 280...319. Round 11's
# note under HFR-099 should be read with both facts attached.
# RETRACTED IN ROUND 14, THREE CLAIMS, and two of them are claims this block made
# about its own fix rather than about the code it replaced -- so read the marked
# sentences above as history.
# (a) "The delta rung (5) really buys is an ARCHIVED session: ``_session_row`` has no
# status filter where ``resolve_session_id_target`` refuses archived, so rung (2) is
# gone and rung (5) still delivers." REVERSED (round-13 P1, review thread
# 3676292667). The mechanism is real and still is; the CONCLUSION was wrong. An
# archived ``agent_sessions`` row is "a WRITABLE row that is not a VISIBLE surface":
# ``persist_agent_message`` resolves the scope through ``_session_row``, which has no
# status filter, so the write lands; a persisted receipt is the workbench class's ack
# source, so the rung ACKS and the notice is stamped ``sent`` and never retried; but
# ``list_inbox_sessions`` and ``get_inbox_session`` exclude archived sessions, so
# there is no inbox card, no ``inbox.session.updated`` patch for an open browser, and
# no Web Push. "The user is told nothing and the system believes it told them --
# worse than a dead letter, which at least says so." And the receipt-only ack policy
# this same block introduced CANNOT catch it: it is blind here precisely because the
# write really does happen.
# FIX: ``_rung_five_session_id`` reads the row's status and REROUTES rung (5) to
# ``WORKSPACE_NOTICE_SESSION_ID`` when it is ``archived``, keyed on that single
# literal "not on a whitelist of good ones, so a new status is treated as deliverable
# until somebody teaches the read paths otherwise", and failing OPEN (an unreadable
# DB returns the original id rather than hijacking the notice). ROUTING, NOT HEALING,
# and the asymmetry with round 12 is deliberate: the reserved row may never be
# archived at all, so an archived one is corruption and repairing it in place restores
# the invariant -- whereas an ordinary session was archived by its owner ON PURPOSE.
# "The session is not broken; the ADDRESS is. So the notice moves." Pinned by
# ``test_an_archived_ordinary_session_is_rerouted_instead_of_acked_into``, which
# asserts the ACK FIRST -- "it passes either way, which is what makes the bug silent"
# -- then the surface it claims to have reached, and which also requires the archived
# row to stay archived: delivering a notice may not un-archive a session the user
# archived deliberately, and the ``failure_id`` stays the bare run id because
# rerouting changes the address, never the identity.
# (c) "NOT hidden ... The row is ``foreground``" and the reasoning that a hidden row
# "would need a schema change this round does not take". SUPERSEDED. The impasse was
# real and was mis-diagnosed as a schema problem: ordinary session lists filter
# POSITIVELY on ``visibility == 'foreground'``, and so did the inbox -- which is why
# ``background`` hid the card as well as the row. The resolution is a THIRD value,
# ``visibility='system'``, and a vocabulary split rather than a migration:
# ``SESSION_VISIBILITIES`` widens to what may be STORED while
# ``ASSIGNABLE_SESSION_VISIBILITIES`` (foreground/background) stays what a CALLER may
# choose, and ``INBOX_SESSION_VISIBILITIES = ("foreground", "system")`` admits the row
# to ``list_inbox_sessions`` explicitly. The session lists needed NO change at all --
# a positive equality filter excludes an unrecognized value for free -- and
# ``suppress_delivery`` keys on ``== 'background'`` alone, so realtime and Web Push
# are untouched. ``unread_counts_by_session`` had to be edited even though its answer
# is the same shape, because its predicate is the NEGATIVE form and "has to name every
# visibility the inbox admits or the badge would disagree with the feed it is supposed
# to count". Message search deliberately keeps ``== 'foreground'``, narrower than the
# inbox. The Agents run graph is excluded EXPLICITLY, because its own filter was
# ``!= 'background'``, which admits by default.
# NO ALEMBIC MIGRATION, and the reason is worth keeping because it is unusual: "this
# row exists in no release (this PR created it), so there is nothing deployed to
# migrate." ``_workspace_notice_session_is_usable`` now requires ``system`` EXACTLY
# rather than accepting either value, so a round-12/13 development row is converted in
# place by the next notice, under the same write lock the create takes -- "the heal is
# also the migration". The naive alternative is kept as a PERMANENT REFUTATION rather
# than a comment: ``test_background_would_hide_the_card_which_is_why_system_exists``
# flips the row to ``background`` by direct SQL and asserts both halves of the cost in
# one failure -- the card disappears while the notice row is still persisted and still
# stamped ``sent``, and the badge stops counting it.
# (d) THE RESIDUALS ARE NOW TWO, NOT THREE. "The session appears in ordinary session
# lists" is closed by (c). "D5's remaining body item -- the creation channel/thread
# with a deep link -- is NOT implemented" is closed by round 14's origin contract; see
# HFR-094's round-14 paragraph, which also retracts the matching sentence there. What
# remains: the row's ``agent_backend`` is empty, since it has no backend and no turns;
# and it is still one ``DELETE /api/sessions/ses-workspace-notices`` from anyone
# holding the id, which the inbox card carries -- "hiding the row from the lists
# narrows the blast radius; it does not replace this guard, which is why both exist",
# and a delete HEALS on the next notice rather than being exempted.
# The system-surface behaviour has its own file, ``tests/test_workspace_system_session.py``,
# so only the doctrine is recorded here.
# THE ALWAYS-APPEND DOCTRINE (round 14, gate item 2; review thread 3676292675). Round
# 12's rule was that the workspace rung fires only for an otherwise-empty ladder, and
# that rule was "too narrow by exactly the case #1060 reported (maintainer note
# 5120451508): a NON-EMPTY ladder is not a DELIVERABLE one." A watch bound to a
# HARD-DELETED session builds a ladder whose every candidate resolves to nothing: each
# attempt sends, the receipt-only ack source correctly refuses it, the ``if not rungs``
# gate NEVER FIRES, all six attempts burn, and the notice dead-letters with nothing
# written anywhere. That silent dead letter is the 3.5 hours of silence in #1060's
# field evidence.
# TWO DESIGNS ARE RETIRED, named so neither comes back. (i) Round 12's "only when
# nothing else resolved". (ii) Round 13's FINAL-ATTEMPT fallback (``ce695b42``), which
# appended the same rung last but only on attempt ``MAX_ATTEMPTS``; it closed (i)'s
# hole and was overruled anyway -- "correct about the mechanism and overruled on the
# trade". It never shipped: the history was rebuilt and that commit is not an ancestor
# of the branch, so the catalog never documented it as landed and should not now.
# FIX: the workspace rung is appended UNCONDITIONALLY, once, last. "What survives of
# round 12's argument is ORDER, and it does the work a condition used to" -- a healthy
# preferred rung wins every walk because it comes first, not because a gate suppressed
# the fallback. The reviewer's ruling is quoted verbatim in the code rather than
# paraphrased: "Append one distinct workspace-notifications target after every
# person/context target, even when earlier candidates exist but are stale, unavailable,
# or fail delivery. It cannot be conditional on rungs being empty."
# THE REROUTE AND THE APPEND COLLAPSE TO ONE RUNG, and that is a property of the
# ``_add`` seen-set rather than of a special case: ``_rung_five_session_id`` returns the
# bare ``WORKSPACE_NOTICE_SESSION_ID`` constant, so an archived row's rerouted rung (5)
# and the unconditional append are byte-identical ``(parsed key, session id)`` tuples
# and dedupe for free. Pinned ladder-only by
# ``test_an_archived_session_ladder_holds_exactly_one_workspace_rung``, with a live
# rung (1) present so it covers POSITION as well as count.
# THE TRADE IS RECORDED, WITH ITS ACCEPTANCE, because it is a real behaviour change:
# any walk in which every preferred rung fails to deliver now reaches this rung on THAT
# walk, delivers, and acks -- so a preferred rung that failed TRANSIENTLY (a platform
# blip on attempt 1) permanently routes that one notice to the workspace inbox, and the
# user's own channel never receives the copy it would have got a minute later. Accepted
# explicitly by the maintainer in the ruling above ("...or fail delivery"), "on the
# judgement that a misrouted notice a user can find beats a notice nobody receives".
# Scope of the residual is ONE notice, not the definition: the next failure builds a
# fresh ladder and the recovered preferred rung wins it again.
# THE RESERVED ROW IS NOT MINTED ON HEALTHY INSTALLS, which is the cost the append
# would otherwise carry. The rung is appended at ladder-build time but RESOLVED at the
# walk, so ``_workspace_notice_session_id`` is only called when the walk actually
# reaches it -- the call is made "for its WRITE, not for its return".
# ``test_a_healthy_preferred_rung_never_reaches_the_workspace_inbox`` is the negative
# pin nothing else in the file carried: one live rung (1) wins, no workspace
# ``messages`` row exists, and no reserved session row is created at all.
# The unwritable-DB residual MOVED rather than disappeared: from "nothing to append" to
# "the rung is skipped", with the walk logging it and preserving a preferred rung's own
# refusal rather than overwriting it with the resolve failure. Still a visible dead
# letter, pinned by ``test_an_unwritable_workspace_inbox_still_dead_letters_visibly``.
# Two further subordinate tests, both renamed from the retired design so no locator
# points at a name that never shipped:
# ``test_a_walk_whose_preferred_rungs_all_fail_lands_in_the_workspace_inbox`` (was
# ``test_the_final_attempt_falls_back_to_the_workspace_inbox``) pins the ladder before
# any send, the send ORDER, exactly one workspace row, and the round-14 delta --
# ``attempts == 1`` on ONE drain pass, where the retired design needed six; and
# ``test_replaying_the_workspace_walk_reuses_the_persisted_receipt`` (was
# ``test_replaying_the_final_walk_reuses_the_persisted_workspace_receipt``), which is
# explicitly a pin rather than a red-first case -- HFR-075's machinery already makes it
# green, and its red half is the mutation at the end: delete the persisted row and the
# same replay delivers again.
# ``attempt`` is no longer threaded into the walk. It used to be, only because the
# workspace rung's presence depended on the attempt number; with the rung unconditional
# the parameter had no other reader, and ``MAX_ATTEMPTS``, the backoff ladder and
# ``LADDER_ACK_SOURCES`` are untouched by all of this.
# PR6 review round 7 (#1072) closed the CLASS instead of the third symptom of it.
# Three rounds had each found one more target acking on evidence that proved
# nothing, because "who may ack on what" lived as a predicate reading a platform
# name -- so every new rung, platform or scope type inherited a permissive answer
# by default and nothing failed until a user lost a notice.
# FIX: ``core/scheduled_tasks.py`` states the policy DECLARATIVELY, as
# ``LADDER_ACK_SOURCES``: a total table over (platform kind, scope type) -> the one
# evidence source that may acknowledge there. External IM conversations may ack on
# their native delivery id; every workbench class, the ``project`` scope type and
# any UNREGISTERED platform require a persisted receipt, and
# ``UNDECLARED_LADDER_ACK_SOURCE`` makes receipt-only the default an undeclared
# class would fall back to, so the unsafe direction is never the implicit one.
# ``_rung_acknowledges`` is now one lookup plus one membership test.
# A third subordinate test carries this id --
# ``test_every_ladder_target_class_declares_its_acknowledgement_source`` -- and it
# is STRUCTURAL: it derives both axes from the code (the ``kind`` of every
# ``PLATFORM_REGISTRY`` descriptor; the scope-type vocabularies the two ladder
# parsers actually enforce, asserted parseable rather than hand-copied) and
# requires the table's domain to equal their product exactly -- no missing class,
# no stale one. A future rung introducing a platform kind or a scope type cannot
# ship without declaring its acknowledgement source. Verified red both ways: adding
# a ``workspace`` scope type reports the three missing classes, and renaming a
# platform kind reports the stale ones.
# The two consuming directions are now both asserted end to end. Direction 1 (the
# workbench inbox row) also proves the notice never enters the LIVE
# ``emit_backend_failure`` lifecycle, by the same technique as the replay guard
# above -- patched to raise under both module spellings, with the drain's import
# proven absent from a ``hasattr`` snapshot taken BEFORE the ``raising=False``
# patch would have created it -- plus one emission, no turn or run settlement, no
# live-turn hook and an auth service that raises on any read. Direction 2 (the
# synthetic send id) is driven through TWO drain passes: with the bound session row
# DELETED both rungs send and neither persists, so the notice stays ``pending``
# with no ``ack_evidence``, one attempt consumed and an error naming the missing
# receipt rather than "produced no evidence"; then, with the row restored ARCHIVED
# and the backoff rewound, the same still-owed notice is delivered by rung (5),
# receipts, and acks with the attempt count carried forward. That second pass is
# what makes "walks on and stays retryable" an assertion instead of a claim.
# CORRECTED IN ROUND 14: pass 2's SUBJECT changed, though its shape did not. It was
# written in round 9 to assert that rung (5) delivers INTO the archived row, on the
# premise that an archived row is a valid delivery surface; the premise was wrong (see
# the round-14 retraction (a) above), so the test's own docstring now records the
# reversal and pass 2 pins the REROUTE instead: the still-owed notice is delivered to
# the workspace-notifications session, receipts there, and acks with the attempt count
# carried forward. What survives of the round-9 claim is narrower and still worth
# having -- "the surviving delta rung (5) buys over rung (2) is a DELIVERY at all, not
# a delivery into that particular row" -- and pass 1 additionally has to SUPPRESS the
# now-mandatory workspace rung to keep testing what it was written to test.
# PR6 review round 8 (#1072) named the ONE premise that table cannot check for
# itself, since totality over an axis says nothing about the axis VALUE being
# right: ``kind == "im"`` is a claim that the id a send returns was minted by a
# platform that reached a person, and it is what entitles ("im", channel|user) to
# the permissive rows. ``PlatformDescriptor.kind`` DEFAULTS to ``"im"``, so a
# transport added to ``PLATFORM_REGISTRY`` without stating its kind would inherit
# that entitlement silently -- and the structural test above would stay green,
# because no new kind appeared. If such a transport minted its own id the way
# ``AvibeBot.send_message`` does, this whole finding class would reopen with
# nothing failing.
# FIX (no product behaviour change): the premise is now WRITTEN DOWN where the
# claim is made -- a contract comment on ``PlatformDescriptor.kind`` and one beside
# ``LADDER_ACK_SOURCES`` -- all five IM descriptors state ``kind="im"`` explicitly
# instead of inheriting it, and a fourth subordinate test carries this id:
# ``test_a_platform_descriptor_cannot_inherit_the_im_kind``. The test-audit follow-up
# replaced the original registry-AST guard by removing the dataclass default
# outright: ``PlatformDescriptor`` now refuses construction without ``kind``, so
# the enforcement is the constructor itself and the test pins that refusal.
# It takes no id of its own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 12 (#1072), TWO COUPLED FINDINGS -- and the coupling is the point:
# they ship in one round because each one alone would make the other worse.
# (G) A RAISING RUNG KILLED THE WALK. The per-rung ``try/except`` covered
# ``_build_context`` alone; the ``emit_replayed_backend_failure`` call one line below was
# unwrapped, so any raise from a rung's delivery -- a platform whose settings manager is
# gone, a client lookup that fails, an adapter that throws before the transport --
# escaped the ``for`` body, unwound through the walk's ``finally``, and landed in the
# handler that consumes the attempt and arms the backoff. The next pass restarted the
# SAME ladder at rung (1) and raised again, so the notice burned every attempt on one
# broken rung and dead-lettered WITHOUT EVER TRYING rung (2). The inconsistency is what
# makes it a defect: every other way a rung can fail to deliver already continues --
# ``_build_context`` raising, a stale synthetic candidate, an un-acked send -- and round
# 7's accepted contract is that an unresolvable or stale candidate continues the walk.
# "A raising one is the same class of unusable and must be treated the same way."
# FIX: the delivery call is wrapped, the rung records ``error_stage = "deliver"``, the
# walk ``continue``s, and the first raising rung's error is copied onto the aggregate
# evidence when the winning rung carries none -- recorded purely for diagnosis, "the same
# way a post-delivery stream error is, and -- like that one -- must never be read as a
# delivery failure". ``Exception`` and deliberately NOT ``BaseException``: the walk-level
# deadline cancels this coroutine, and cancellation must unwind the walk rather than
# advance it past the bound it was cancelled to respect. Pinned both ways --
# ``test_a_raising_ladder_rung_does_not_abandon_the_rest_of_the_walk`` requires the later
# rung to be attempted, to ack on its receipt, to consume ONE attempt, and to carry the
# skipped rung's error for diagnosis; ``test_the_walk_deadline_still_cancels_through_a_rung``
# pins the one-letter distinction, and its assertion is that rung (2) is NEVER attempted,
# "which is what distinguishes cancellation from the raise above".
# THE HONEST RESIDUAL, and it is why (B) is in the same round: a rung that raises AFTER
# its transport accepted the send, leaving no evidence behind, now delivers again on the
# next rung. That is a duplicate this fix introduces, and it is only acceptable because
# the state that manufactures it is being removed at the source in the same round.
# (B) THE ADAPTERS WERE MANUFACTURING EXACTLY THAT STATE. Threaded Slack and Feishu sends
# ran ``sessions.mark_thread_active`` AFTER the transport call but BEFORE returning the
# native message id, unguarded -- and "the transport call is the point of no return: once
# it succeeds the user HAS the message." A raise there REPLACED the return value, so the
# dispatcher's blanket handler recorded a send failure with no delivery evidence for a
# message the user already had, and the fallback ladder re-sent it. "That is a systematic
# duplicate per bookkeeping failure, not the crash-only at-least-once residual" this id's
# family documents elsewhere.
# FIX AT THE ADAPTER, and the layer is forced rather than chosen: ``modules/im/discord.py``
# already wrapped the identical call, so Slack (four send paths) and Feishu (two) now
# match its shape exactly. It "cannot be papered over in ``core/message_dispatcher.py``:
# the id is destroyed inside the adapter before it can ever escape." Slack's inbound event
# handlers keep their unguarded calls deliberately -- they return no native id and are not
# send paths. Behaviour-preserving on the success path; only the already-delivered failure
# path changes. Red-first: six adapter cases fail without the change.
# THE NOTICE-LEVEL CONSUMER IS PINNED SEPARATELY, because adapter and dispatcher coverage
# do not answer the question this id asks -- whether the DRAIN's ack/retry decision comes
# out right for an adapter whose transport succeeded and whose bookkeeping blew up.
# ``test_a_notice_acks_when_the_adapters_post_send_bookkeeping_raises`` drives a real
# ``SlackBot`` with only the HTTP call stubbed ("real adapter and not a shaped stub,
# because the subject IS the adapter's own ordering: transport, bookkeeping, return")
# through the real drain, and requires the notice to ACK rather than resend. It is GREEN
# FROM BIRTH, since the fix landed in the same round, so the red half lives in the same
# file: ``test_the_pre_guard_adapter_shape_resends_an_already_delivered_notice``
# reintroduces the pre-fix shape and asserts BOTH consequences, "because either alone
# would understate the defect" -- the notice is not acknowledged AND, now that a raising
# rung continues the walk, the same body is pushed onto the next rung.
# ``test_a_real_send_failure_is_still_undelivered`` is the negative control that keeps the
# guard honest: it only ever runs after the transport returned, "otherwise the guard would
# have converted every failed send into a silent success, which is the failure mode the
# whole durable notice exists to prevent."
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header). The adapter-level cases
# live in ``tests/test_im_post_send_bookkeeping.py`` and the dispatcher-level ones in
# ``tests/test_message_dispatcher_scheduled.py`` as platform unit pins, which is why only
# the notice-level consumer is documented here.
test: tests/test_harness_failure_visibility.py::test_a_replayed_notice_reaches_the_user_without_touching_the_live_lifecycle
# PR6 review round 3 (#1072). Range extended to HFR-084 by the maintainer; PR2
# moves to 085. This block is now full — do not go past 084 without extending.
# SUPERSEDED (round 11): both numbers above are historical. The plan merged as #1044
# records the range being widened again, 15 -> 20 -> 25 -> 40, so PR6's main block is
# HFR-060...099 and PR2 starts at 100, not 085
# (docs/plans/harness-run-reliability.md §10.7). The "do not go past 084" instruction
# was overtaken by later review rounds and is left in place only as the record of what
# was true when it was written.
- id: HFR-080
name: a replayed failure notice does not finalize a live unrelated turn
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_a_replayed_notice_does_not_finalize_a_live_unrelated_turn
- id: HFR-081
name: the drain reuses the identity the live failure path would have used
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_the_drain_reuses_the_identity_the_live_path_would_have_used
- id: HFR-082
name: an interruption notice keeps an identity distinct from an ordinary failure
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_an_interruption_keeps_an_identity_distinct_from_an_ordinary_failure
- id: HFR-083
name: the owed-notice lookup seeks on an index rather than scanning failed history
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_the_owed_notice_lookup_seeks_rather_than_scans
- id: HFR-084
name: a malformed metadata row stays writable under the eligibility index
status: covered
kind: safety
layer: contract
backend: shared
# PR6 review round 12 (#1072). "STILL WRITABLE" WAS TRUE AND NOT ENOUGH: the four
# terminal writers were writable over a malformed row by DESTROYING it.
# ``_merge_owed_failure_notice`` took a pre-DECODED dict and fell back to ``{}`` for
# anything that was not one, and every terminal writer handed it
# ``_json_loads(row["metadata_json"], {})`` -- so settling a row whose blob is
# unparseable, or valid JSON that is not an object, REPLACED the column with just the
# notice. Whatever those bytes were (a truncated write, a value another component owns,
# the context an operator would need to diagnose it) "is not this feature's to
# destroy", and it went on all four writers.
# WHAT MAKES IT A DEFECT RATHER THAN A POLICY is that it was already inconsistent with
# every other reader on this head: the binding stamp refuses malformed rows through
# ``json_valid`` (round 9), ``update_owed_failure_notice`` returns ``None`` when the
# metadata is not a dict, and ``list_owed_failure_notices`` excludes them outright. One
# writer out of four chose repair-by-replacement while three chose refusal.
# FIX: the parameter becomes ``row_metadata_json`` and takes the RAW COLUMN, "because
# the decode is a decision this choke point has to make rather than inherit". An
# undecodable or non-object blob logs and RETURNS EARLY without setting
# ``metadata_json``, so the caller's ``status``/``error``/``completed_at`` UPDATE still
# commits -- the run settles, only the column is left alone. This completes the
# refuse-don't-repair rule the binding stamp adopted in round 9: it is now TOTAL across
# all four terminal writers rather than true of one.
# RESIDUAL, stated rather than hidden: such a row settles ``failed`` and never owes a
# notice, so its failure is visible in the run list and in derived health but is never
# delivered as a message. That was ALREADY true -- the eligibility query excludes
# malformed rows, so a notice written here would have been durable and unreachable --
# and it is the direction every other reader on this path chose.
# One subordinate test carries this id --
# ``test_a_terminal_writer_never_rewrites_unparseable_metadata`` -- a matrix over four
# blob shapes and all four writers, asserting the raw column byte-identical while the
# run still settles ``failed`` with its error. The ``settle_run_terminal`` leg passes a
# caller-supplied ``interrupt_reason`` on purpose: a sibling field must not be the lever
# that rewrites the column either.
# It takes no id of its own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_a_malformed_metadata_row_is_still_writable_under_the_expression_index
# PR6 review round 4 (#1072). Block widened to HFR-099 by the maintainer; PR2
# moves to 100+.
- id: HFR-085
name: a backed-off streak does not starve other definitions' failure notices
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_one_backed_off_definition_does_not_starve_every_other_notice
- id: HFR-086
name: the eligibility lookup stays bounded when every notice is backed off
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_the_eligibility_lookup_is_bounded_when_everything_is_backed_off
- id: HFR-087
name: a backend-supplied failure id and the drain agree for harness runs
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_the_drain_and_a_backend_supplied_identity_agree_for_harness_runs
- id: HFR-088
name: the eligibility index migration and the query use identical expressions
status: covered
kind: safety
layer: unit
backend: shared
test: tests/test_harness_failure_visibility.py::test_the_index_migration_and_the_query_use_the_same_expressions
- id: HFR-089
name: a notice with no backoff field is still reachable by the drain
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_a_notice_stamped_without_a_backoff_field_is_still_reachable
# Rebase onto #1061's definition read projection.
- id: HFR-090
name: a watch reports processing health without poisoning waiter health
status: covered
kind: failure
layer: contract
backend: shared
test: tests/test_harness_failure_visibility.py::test_a_watch_reports_processing_health_separately_from_waiter_health
- id: HFR-091
name: the drain preserves an authoritative interruption identity
status: covered
kind: failure
layer: contract
backend: shared
# ``_failure_identity`` honours an explicit id outright only when the caller says
# it is AUTHORITATIVE; otherwise the harness run-id override wins, which is what
# aligns a backend's own turn id with the drain's replay (HFR-087). The drain
# passed its explicit ``failure_id`` WITHOUT that flag, so the interruption
# identity ``interrupt:{run}:{reason}`` — stamped precisely so a D1 interruption
# cannot be swallowed by the dedup for an ordinary failure on the same execution
# — collapsed back to the bare run id at the one call site that reads it off a
# durable row. HFR-082 and HFR-087 both call
# ``backend_failure_notification_output`` directly and so could not see it.
# FIX: ``emit_replayed_backend_failure`` passes
# ``failure_id_authoritative=True`` unconditionally and exposes no way to say
# otherwise, so the authority is a property of the emitter rather than an
# argument a call site can forget. Driven through the REAL drain and asserted on
# the durable ``messages`` row's ``native_message_id`` and metadata, which is
# what the dedup lookup actually reads.
test: tests/test_harness_failure_visibility.py::test_the_drain_preserves_an_authoritative_interruption_identity
- id: HFR-092
name: a suppressed-lane reason never takes the interruption identity or copy
status: covered
kind: failure
layer: contract
backend: shared
# ``interrupt_reason`` is the general marker for "terminalized by something other
# than its own backend result", and its commonest values are ordinary per-fire
# verdicts that belong in the SUPPRESSED failure lane: ``no_terminal_result``,
# ``refused_concurrent_turn``, ``transport_unavailable``, ``queue_hold_expired``.
# The lane is membership in ``RUN_INTERRUPTION_REASONS``
# (``failure_notices.is_interruption``), but two places asked by PRESENCE: the
# stamp minted ``interrupt:{run}:{reason}`` for any non-empty reason, and the
# notice copy rendered the "was interrupted, nothing is wrong with the definition
# itself" headline for any non-empty reason. The first is a duplicate
# notification per failure once the drain's id is authoritative (HFR-091); the
# second tells a user their definition is fine when the definition is the problem.
# FIX: both gate on membership, and the reason stays recorded as the copy selector
# it is.
test: tests/test_harness_failure_visibility.py::test_a_suppressed_lane_reason_never_takes_the_interruption_identity_or_copy
- id: HFR-093
name: the drain and the live path agree for a suppressed-lane reason
status: covered
kind: failure
layer: contract
backend: shared
# A live Turn owns its backend failure message. Its durable Run notice remains
# pending until the drain observes the Turn's delivery evidence, then records a
# skip without replaying the same error. Separate Turns remain separate failures.
test: tests/test_harness_failure_visibility.py::test_the_drain_and_the_live_path_agree_for_a_suppressed_lane_reason
- id: HFR-094
name: a failed watch notice renders watch commands
status: covered
kind: failure
layer: contract
backend: shared
# ``_failure_notice_body`` resolved the definition through
# ``ScheduledTaskStore.get_task`` ALONE — the scheduled-task mirror — and then
# appended ``vibe task run {id}`` / ``vibe task show {id}`` for every definition.
# A watch is in neither: it got named by its raw id and handed two commands that
# cannot address it, and there is no ``vibe task run`` for a definition that is
# not scheduled at all. FIX: discriminate on ``run_type`` / the watch definition
# row, resolve the name through the watch read path
# (``get_watch_definition``), and render watch copy
# (``harness.notice.watchPaused`` / ``harness.notice.watchShow`` →
# ``vibe watch resume`` / ``vibe watch show``). Asserted through the REAL
# translator, because the defect is in the command strings a user reads.
# PR6 review round 9 (#1072). That discrimination still assumed the definition
# EXISTS. A run outlives its definition -- the notice is stamped by the terminal
# transition and drained later, and the retry ladder above makes that window minutes
# wide -- and the archetypal case is ordinary: a user deletes a task whose last fire
# failed and has not been reported yet. Both bodies then named commands that resolve
# to nothing. The failure body appended ``harness.notice.rerun`` unconditionally
# ("Re-run it now with: ``vibe task run <id>``") and ``harness.notice.show``; the
# binding body offered ``vibe task update <id> --session-id ...`` to pin back a row
# that cannot be pinned. Each PARSES and then fails at runtime with "not found",
# which is this id's own defect one noun over: copy naming an action the user cannot
# take, and worse than silence because it reads as a working recovery path.
# FIX: when neither read path resolves the definition (``get_task`` and
# ``get_watch_definition`` both empty), the body says the definition is gone
# (``harness.notice.definitionDeleted``) and names only RUN-LEVEL recovery --
# ``vibe runs show <run id>``, the one row that does still exist -- dropping the
# definition-scoped pair entirely. The binding body got the same treatment and keeps
# the news itself: the old and new session ids are still reported, because "your
# pinned session was replaced" is true whether or not the definition survived.
# Validated by parsing EVERY command the body prints through the real
# ``build_parser()``, which is the HFR-099 copy-test discipline, because a
# hand-written expectation drifts with the CLI.
# Two subordinate tests carry this same id:
# ``test_a_deleted_definition_notice_names_only_run_level_recovery`` and
# ``test_a_deleted_definition_binding_notice_drops_the_repin_command``.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 12 (#1072), TWO FINDINGS on this copy family.
# FIRST: AN INTERRUPTION REASON IS A WIRE VALUE, NOT USER-VISIBLE COPY.
# ``harness.notice.interrupted`` renders its ``reason=`` INSIDE the sentence, so
# whatever is substituted there is product copy whether or not anyone treated it as
# such -- and the drain interpolated the wire value. A Chinese user was told
# ``被中断(backend_refresh)``: an internal identifier, untranslated, mid-sentence, for
# every one of the six reasons in ``RUN_INTERRUPTION_REASONS``. FIX:
# ``NOTICE_REASON_I18N_KEYS`` maps each lane reason to a label key, with
# ``NOTICE_REASON_UNKNOWN_I18N_KEY`` as the fallback, both locales filled.
# An EXPLICIT MAP rather than an f-string key, "so the settlement vocabulary stays free
# to change without a renamed value silently degrading into a raw key in the middle of
# a translated sentence" -- and the obvious ``.get(reason, reason)`` spelling is called
# out as the original defect again, reachable in exactly the window between a reason
# joining the lane and CI noticing it has no label. These are LABELS, deliberately not
# the long-form ``harness.run.interrupted.*`` family, which is the run's ``error``
# column printed on its own line.
# Four subordinate tests: ``test_an_interruption_notice_never_prints_the_raw_wire_reason``
# loops the whole lane through the REAL translator (a ``_t`` that echoes keys reports
# which key was chosen, not what the user reads);
# ``test_an_unmapped_interruption_reason_renders_a_localized_fallback`` empties the map
# rather than inventing a reason, because ``is_interruption`` gates the branch on lane
# membership so an unmapped reason is only reachable as a map/lane disagreement; and two
# drift guards in ``tests/test_i18n_backend_keys.py`` require the map's key set to equal
# the lane exactly and every label to resolve in every supported language -- "if that
# key were missing the notice would print the dotted path instead, a worse leak than the
# raw reason it replaced."
# SECOND: the D5 body requirement, PARTIALLY. Two of the plan's named body items were
# missing on the per-fire FAILED lane, and the diagnosis corrects a conflation:
# ``interrupt_reason`` is NOT a synonym for "interrupted" -- master stamps it for
# ``no_terminal_result`` / ``refused_concurrent_turn`` / ``transport_unavailable`` /
# ``queue_hold_expired``, which recur on every fire and so stay in the failure lane by
# design. But the interrupted HEADLINE was the only place any reason was rendered, so on
# the failed lane the class was dropped and the user saw only whatever text the ``error``
# column held. The last success had no read at all, on any lane.
# FIX: ``PER_FIRE_INTERRUPT_REASONS`` is DERIVED by subtracting the interruption lane
# from the settlement and sweep vocabularies -- "that subtraction is the same
# discriminator ``is_interruption`` applies, so the two cannot disagree about which lane
# a reason belongs to" -- and ``NOTICE_FAILURE_CLASS_I18N_KEYS`` labels exactly that set,
# asserted DISJOINT from the interruption map: one reason, one lane, one label. The last
# success comes from ``last_success_settled_at``, one bounded indexed seek sharing
# ``_SETTLED_AT``, the succeeded status vocabulary and the ``settled DESC, id DESC``
# tie-break BY NAME rather than retyped, with ``watch_runtime`` excluded -- without that
# term a permanently broken watch would report a fresh "last succeeded" instant on every
# service restart.
# THE TWO OMISSION CHOICES ARE OPPOSITE ON PURPOSE, and this is the part worth keeping:
# ``notice_failure_class_i18n_key`` returns ``None`` rather than a generic, "the opposite
# choice from ``notice_reason_i18n_key``'s. There the reason is rendered INSIDE a
# sentence that is printed either way, so a missing label has to degrade to something
# readable. Here the label IS the line: with nothing real to name, the honest rendering
# is no line at all rather than 'Class: unknown'." The last-success line is likewise
# omitted rather than rendered as "never" for a definition that has never succeeded.
# Three subordinate tests, plus two more drift guards:
# ``test_the_failed_lane_names_its_class_and_when_it_last_succeeded`` runs both locales
# through the real translator and requires the LATEST success rather than the earliest;
# ``test_a_failed_lane_body_omits_both_lines_when_neither_is_real``; and
# ``test_the_last_success_read_is_one_bounded_indexed_seek``, asserted on the CONSTRAINED
# TERMS rather than only the index name, which is the HFR-086/095 lesson.
# NOT IMPLEMENTED, AND NOT CLAIMED: D5's remaining body item -- where the task was
# created, channel/thread with a deep link (plan :3165-3168). Only the failure class and
# last-success lines landed this round. No i18n key for a creation location or deep link
# exists, and the commits state no reason for the omission, so this is recorded as an
# open gap against the plan rather than as a documented deferral.
# CLOSED IN ROUND 14 (gate item 3). The gap above is the last item of D5 and it is now
# implemented end to end, so the paragraph stands only as the record of what was open.
# THE DEFECT, precisely: a failure notice "is context-free by construction -- an owner
# DM or a workspace card, delivered hours after the fire -- so the conversation that
# asked for the definition was unrecoverable from the notice." And the reason it could
# not simply be rendered: the ids had never been captured, and no permalink builder
# existed anywhere in the codebase.
# CAPTURE. ``CallerContext`` gains six fields -- ``platform``, ``user_id``,
# ``channel_id``, ``session_key``, ``message_id``, ``workspace_id`` -- each with its own
# ``AVIBE_CALLER_*`` env var, because the subprocess env is the ONLY channel available:
# an IM-created definition is created by an Agent run executing ``vibe task add``, so
# the env is the only hop between the conversation that asked and the row that records
# it. ``channel_id`` and ``session_key`` are both kept and are not redundant --
# ``session_key`` is the ADDRESS in the grammar ``parse_session_key`` speaks, while
# ``channel_id`` is the LOCATION a permalink needs; for a DM the session key's scope id
# is the USER id, and a permalink built from it would be fabricated.
# THE KEY NAMES ARE LOAD-BEARING, and this is the part that lights up the ladder:
# ``to_metadata`` writes exactly the names the ladder has always read --
# ``caller["session_key"]`` / ``caller["scope_id"]`` for rung (3) and
# ``caller["platform"]`` / ``caller["user_id"]`` for rung (4), the owner DM. "Writing
# them under any other name would leave them dormant." So rungs (3) and (4) become
# reachable for NEW definitions and D5's designed ladder shape finally exists in
# practice. The reading logic was never broken -- verified at ``3578f2b6``, where the
# rungs resolve fine from hand-written metadata; "nothing ever wrote it."
# THE HONESTY TABLE, in the new ``core/origin_links.py``: one public function,
# ``origin_link``, and "one rule: LINK OR ``None``, never a fabricated URL. A failure
# notice that offers a link the user cannot follow is worse than a notice that offers
# none -- it moves the failure from 'I do not know where this came from' to 'Avibe told
# me where and it was wrong', and the second is the one that costs trust." Linkable only
# when every id that platform's permalink grammar requires is present: ``slack``
# (channel + ts), ``discord`` (guild + channel + message -- and NEVER ``@me``, which
# "would read as a working link while being unfollowable for anyone else, including the
# workspace inbox, which is not a person at all"), ``telegram`` (a ``-100`` supergroup id
# + message). Named but never linked: ``lark`` and ``wechat`` have no stable public
# message permalink, and ``avibe`` has an addressable location whose only URL form is the
# local setup host -- "a ``http://127.0.0.1:<port>/...`` link pasted into a Slack DM or a
# phone push is not honestly reachable from where the notice is read." An unrecognised
# platform gets nothing, because "guessing a URL shape for it is the fabrication this
# whole module exists to prevent." Matching is exact on the wire value, and the wire
# value is ``lark`` rather than ``feishu`` -- keying the map on the product name would
# have made every Feishu origin unnameable.
# THREE INDEPENDENT REFUSALS, each yielding FEWER lines rather than vaguer ones: no
# provenance at all (every definition created before this round) takes no line and there
# is "no backfill and no migration, because the ids were never recorded and inventing
# them is the one thing a provenance line may not do"; an unmapped platform takes no
# line rather than leaking its wire value; and an unlinkable origin still renders the
# TEXT and drops only the link. The omission rule is the same judgement
# ``notice_failure_class_i18n_key`` already made -- "'Created in: unknown' would be copy
# about nothing on the lane that already carries the most lines."
# THE CLAUDE-PATH RESIDUAL, stated as a residual because it is one.
# ``SessionHandler`` is the sole caller passing ``session_stable_only=True``, and it is
# not a shortcut: that env "is baked into a Claude SDK client at spawn and is also the
# value compared to decide whether a cached client may be reused", so ``message_id``
# would respawn the Agent on every turn, and ``user_id`` -- which changes with the author
# on a deliberately shared channel session -- "would attribute a definition created by
# one participant to whoever happened to speak first, and the owner-DM rung would then
# notify the wrong person, which is worse than not notifying anybody." What survives is
# what the SESSION owns, so a Claude-created definition names its conversation and lights
# rung (3) but gets no owner-DM rung and no deep link: "an omission, not a wrong URL."
# Codex and OpenCode rewrite their caller env per turn and keep the full origin; a DM
# loses nothing either way, since its session key carries the person in the scope itself.
# Subordinate tests, none taking an id. The body half is
# ``test_the_notice_names_where_the_definition_was_created_and_links_to_it`` (both
# locales, red at ``3578f2b6`` where the body was four lines with no channel, no thread
# and no URL), with ``test_a_definition_with_no_captured_origin_gets_no_origin_line``,
# ``test_an_origin_that_cannot_be_linked_is_still_named`` and
# ``test_an_unmappable_origin_platform_takes_no_line_rather_than_leaking_itself`` for the
# three refusals. The capture half is
# ``test_the_creation_origin_survives_the_env_hop_into_created_by_caller``, also red at
# ``3578f2b6``. ``test_a_captured_origin_lights_up_the_scope_and_owner_dm_rungs`` has NO
# red of its own and says so -- overlaid at ``3578f2b6`` the ladder already resolved
# those rungs from hand-written metadata, which is the evidence for "the reading logic
# was never dead". ``test_the_workspace_card_carries_the_creation_origin`` is red at
# ``d2c3bf31`` rather than at ``3578f2b6``, a deliberately SPLIT baseline: it imports
# round-12+ symbols, and an ``ImportError`` is not evidence of a defect. The new
# ``tests/test_origin_links.py`` states the same discipline for itself -- "There is
# deliberately no red baseline for this file. It characterises a new pure module, so at
# any earlier commit it would only raise ``ImportError``."
# PR6 review round 14 (#1072), #1060's FIELD CASE, CONSUMED. A dead delivery target had
# no name of its own: a ``once`` watch pinned with ``--session-id`` to a session that
# later ceased to exist failed its follow-up delivery, retired, and "the only cause
# recorded anywhere was ``last_exit_code = 75`` -- the user's own ``--retry-exit-code``,
# i.e. the waiter's HEALTHY 'nothing new yet' signal", so "anyone debugging from exit 75
# starts by investigating a working waiter". The reporter's ask was literally "a cause
# field distinct from the last exit code".
# FIX: ``INTERRUPT_REASON_DELIVERY_TARGET_MISSING = "delivery_target_missing"``, grouped
# in a THIRD source vocabulary ``DISPATCH_FAILURE_REASONS`` "because it has a third
# origin", labelled ``harness.notice.class.deliveryTargetMissing`` in both locales, and
# threaded from ``_execute_claimed_request``'s ``UnresolvableSessionTarget`` handler into
# ``complete(interrupt_reason=...)`` -- as ONE named keyword rather than a general
# metadata dict, because "a wide-open passthrough at a completion site is how an
# unrelated key comes to overwrite ``interrupt_reason`` or the notice blob itself". The
# ordering is load-bearing: ``extra_metadata`` is applied BEFORE
# ``_owed_failure_notice_for_transition`` reads the reason, "so the notice is born
# already carrying its class. A second UPDATE afterwards would be too late."
# ONLY ``reason == "missing"`` IS CLASSIFIED, and the restraint is the interesting part:
# ``archived`` is left unclassified on purpose, because "an archived session's row still
# exists, and the honest description of that failure is 'the session is inert', not 'it
# no longer exists' ... A wrong class is worse than no class" -- and its notice is
# deliverable anyway, via the reroute in retraction (a) above.
# IT IS ON THE PER-FIRE LANE AND DELIBERATELY NOT AN INTERRUPTION, which is a routing
# decision with three consequences the docstring spells out: a definition pinned to a
# deleted session fails on EVERY fire, so admitting it to ``RUN_INTERRUPTION_REASONS``
# would give it an unsuppressed notice per fire, mint an ``interrupt:{run}:{reason}``
# identity the live path never uses, and take it out of the health window -- "reporting a
# permanently broken watch as healthy while notifying about it forever". Because it stays
# out of that set, ``failure_id`` remains the bare run id, the live path's dedup finds it,
# the streak collapses to one canonical notice, and derived health still reads
# ``failing``. Drift-pinned by a DIRECTION test rather than by the existing equality --
# ``test_a_dispatch_failure_class_joins_the_per_fire_lane_and_not_the_interrupted_one`` --
# because "the pin above is an equality between two sets that both grow, so it stays
# green for a reason added correctly AND for one added to the wrong source vocabulary".
# RETIRED IS NOT PAUSED. A processing-failure fallback for a normally retired Watch
# names event processing and omits both lifecycle copy and resume affordances: retirement
# did not cause the failure. A genuinely paused Watch still carries ``vibe watch resume``.
# Interruption notices may still explain retirement because that lifecycle is their subject.
# THE FIELD CASE IS DRIVEN END TO END, which no previous test did: every existing layer
# test stubbed one of the four steps. ``test_a_watch_that_outlives_its_delivery_target_dies_visibly``
# asserts the maintainer note's five outcomes in labelled blocks -- (a) the terminal row
# is not indistinguishable from a pause or a retirement, checked through the real CLI
# payload; (b) the recorded cause is the delivery failure, never the retry sentinel, with
# the negative asserted on the definition too; (c) the terminal timestamps are coherent,
# re-read from a fresh store for durability; (d) exactly ONE actionable notice, in the
# workspace inbox, reachable only via the mandatory rung because every preferred rung
# names a session row that no longer exists; (e) a replay through a THIRD owner may
# neither duplicate nor erase it. ``test_a_forever_watch_repeating_the_field_failure_notifies_once``
# takes the repetition half with a real waiter subprocess exiting 75/0/0/75 "so the LAST
# recorded cycle is the sentinel -- the state #1060's row was actually read in", and pins
# that the sentinel never retires the watch, the projection reads ``waiting`` with
# healthy waiter state while ``processing_health`` reads ``failing``, and the
# downstream streak still collapses to one notice.
# WHAT WAS FOUND ALREADY COHERENT IS RECORDED TOO, "because the plan predicted
# otherwise": ``mark_cycle_result`` already writes ``retired_at``,
# ``last_finished_at`` and ``last_event_at`` in one guarded stamp, so (c) and half of (a)
# needed no change in ``core/watches.py`` at all -- #1060's row predates that stamp. They
# are asserted anyway, "the preconditions the rest of the case rests on, and a regression
# in them reopens the field bug by a different road".
# A third subordinate test,
# ``test_a_disabled_watchs_notice_copy_distinguishes_retired_from_paused``, covers the
# copy half in both locales through the real translator. All three are consuming tests
# for the fix in the preceding commit, so they are green at this head and were red before
# it; the honest framing is that they consume a fix rather than drive one.
# They take no ids of their own because PR6's block is full at 099, 100+ is contracted to
# PR2 by the merged plan, and cyhhao declined to consume an id from §10.7's HFR-280...319
# block for this round.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_a_failed_watch_notice_renders_watch_commands
- id: HFR-095
name: the streak read is bounded by the streak, not by the definition's lifetime
status: covered
kind: safety
layer: contract
backend: shared
# ``failure_streak`` is asked once per pending owed notice on the same 2 s tick
# HFR-078/083/086 bounded the eligibility lookup for — and it was the last read
# in that path that was still unbounded. ``_definition_verdict_rows`` selected a
# definition's ENTIRE settled lifetime ordered by ``(created_at, id)``,
# materialised every row and JSON-decoded each one to drop interruptions, then
# sliced out a streak that is almost always two or three rows. Measured on a
# 5000-row history: 5000 metadata blobs decoded to return 6 rows, under
# ``SEARCH ... ix_agent_runs_definition_created (definition_id=?)`` plus
# ``USE TEMP B-TREE FOR LAST TERM OF ORDER BY``.
# FIX: two ``LIMIT 1`` seeks for the successes bracketing the run by
# ``(created_at, id)``, then only the rows between them —
# ``SEARCH ... ix_agent_runs_definition_streak
# (definition_id=? AND (created_at,id)>(?,?) AND (created_at,id)<(?,?))``, 6
# blobs decoded. Asserted on the plan's CONSTRAINED TERMS rather than on an
# index name, which is the HFR-086 lesson: a plan can name an index while the
# term that matters stays a per-row filter.
# PR6 review round 12 (#1072). BOTH CLAIMS ABOVE ARE SUPERSEDED, one on cost and one
# on correctness, and the second is the serious one.
# THE BOUND WAS ON THE ANSWER, NOT ON THE WORK. The seek-based replacement fixed the
# plan and kept HANDING THE STREAK'S ROWS BACK; its decode budget was written as
# ``2 * len(streak) + 2``, which is a bound on the ANSWER and therefore only a bound
# when the answer is small. On a definition that has never succeeded the streak IS
# its lifetime, and that is not a corner case -- it is every definition that has been
# failing since it was created. Measured on a 1500-run never-succeeded history: 4
# statements, 1500 rows into Python, 1500 blobs decoded, per pending notice, per 2 s
# tick. So the "6 blobs decoded" figure above describes a bracketed history only; it
# was never the worst case. Now 1 statement, 1 row, 0 blobs -- on both shapes.
# THE THREE READS SAW A MOVING HISTORY, and the previous paragraph's safety argument
# was the wrong argument. It reasoned that three statements are not three snapshots
# "because every row they read is already SETTLED" -- true of each row individually,
# and silent about which rows the WINDOW contains. The boundaries are what moves.
# pysqlite opens no transaction for reads, so the boundaries were seeked at one
# instant and the rows read at a later one; a success settling in that gap left the
# boundary saying "no success before this run", the row read swept in the PREVIOUS
# outage, and that outage's ``sent`` notice made ``decide`` answer SKIP for a live
# one. ``skipped`` is durable and nothing revisits it, so the outage is never
# reported: a lost notice, the D1 direction. The old conclusion that holding the
# write lock "would buy nothing" is retired too -- the fix takes one snapshot without
# taking any lock.
# FIX: ``failure_streak_decision`` replaces ``failure_streak``, which is DELETED
# rather than deprecated (no production callers remain). It answers the three facts
# ``decide`` actually needs -- ``in_streak``, ``has_sent_elsewhere``,
# ``earliest_pending_id`` -- in ONE statement, which is one SQLite read snapshot, so
# the boundaries and the rows inside them come from the same database. The drain never
# wanted a streak: returning the rows is what made the read cost the streak's LENGTH
# and forced the caller to redo the classification in Python. The notice state is
# compared INSIDE SQLite (``OWED_NOTICE_STATE_SQL`` referenced, never retyped), which
# is why zero blobs are decoded, and ``id != run_id`` on the ``has_sent_elsewhere``
# term keeps it evidence of delivery by SOMEBODY ELSE -- this row's own ``sent`` state
# is not evidence that it is a duplicate.
# AN ABSENT BOUNDARY IS A DERIVED SENTINEL, NOT A DROPPED PREDICATE, and this is the
# subtle part. The three-statement form knew at build time whether a seek had found
# anything and omitted the term when it had not; one statement cannot, and spelling it
# ``(boundary IS NULL OR position > boundary)`` would make the term a DISJUNCTION,
# which SQLite cannot use as an index constraint -- the plan would name the index
# while the range stayed a per-row filter, which is the exact failure ``20260728_0040``
# shipped and HFR-086 pinned. Below every position is the empty string; above every
# position is the definition's own last ``created_at`` with ``'x'`` appended, DERIVED
# by the same ``LIMIT 1`` seek rather than a magic high constant, "because a constant
# would have to out-sort every possible ``created_at`` byte string and nothing
# guarantees that, while ``X < X || 'x'`` holds for every ``X`` under BINARY
# collation". Anchor membership is itself a window term, because without it a
# ``run_id`` that is not a verdict of this definition leaves both boundaries NULL,
# both sentinels apply, and the "window" becomes the definition's entire history.
# Two subordinate tests carry this id. The locator above is repointed at
# ``failure_streak_decision`` and now pins ONE statement, ZERO blobs on BOTH shapes
# (bracketed and never-succeeded), and the plan's constrained terms with both
# row-value boundary seeks -- allowing ``SCAN CONSTANT ROW`` deliberately, since the
# outer projection has no FROM at all.
# ``test_a_success_settling_mid_read_cannot_merge_two_streaks`` is the correctness
# half: a second connection commits the recovery from the third ``agent_runs`` SELECT
# onward, which is a point a multi-statement read reaches with its boundaries already
# taken and its rows not yet read -- and a one-statement read never reaches at all.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_the_streak_read_is_bounded_and_seeks_rather_than_scans
- id: HFR-096
name: the bounded streak read is the same streak the materialized one computed
status: covered
kind: safety
layer: contract
backend: shared
# Parity for HFR-095 against the algorithm it replaces, kept in the test module
# as an oracle. Randomised histories carry every row class that decides the
# answer: verdicts and non-verdicts, interruptions inside and outside
# ``RUN_INTERRUPTION_REASONS``, ``watch_runtime`` heartbeats, and runs sharing a
# ``created_at`` so the ``id`` tie-break decides ordering — and every run in the
# history is asked for, not just the failures. The first cut compared boundaries
# on ``created_at`` alone and this caught it immediately: a bare scalar range
# both drops rows tied with the boundary and can leave a SUCCESS inside the
# window, which merges two streaks and skips the second one's notice as a
# duplicate. The comparison is a ROW VALUE for that reason.
# PR6 review round 12 (#1072). REPOINTED, and the oracle is now a COMPOSITION. The
# locator above named ``test_the_sql_streak_matches_the_materialized_streak``, which
# no longer exists: the read it checked stopped returning a streak, so the test was
# renamed with it. The parity claim is stronger than a rename suggests.
# ``_materialized_streak`` survives unchanged -- still byte-for-byte the pre-SQL
# production algorithm -- and a new ``_facts`` helper is byte-for-byte the derivation
# ``decide`` used to perform inline on the rows it was handed. Their COMPOSITION is
# the full old behaviour end to end, and that is what the one-statement read is
# checked against: "a parity test against a reimplementation of the new code would
# prove nothing." Six seeded histories of 40 runs, every run asked for plus the
# literal ``run-does-not-exist``, because a missing anchor is the case that could turn
# the window into the definition's whole history.
# A second subordinate test carries this id --
# ``test_the_facts_decide_exactly_what_the_streak_rows_decided`` -- which pins the
# CONSUMER against ``_legacy_decide`` (``decide`` as of ``467b7c80``, taking rows)
# over an asserted 1100-case matrix, comparing ``(action, reason)`` rather than
# action alone: the reasons are written into the row as ``skip_reason`` /
# ``defer_reason`` and read back by operators, and ``canonical_pending:<id>`` names a
# specific run. Moving a derivation into SQL is only safe if no outcome moved with
# it, and that is a claim about the OLD code, so the old code has to be present to
# check against.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
test: tests/test_harness_failure_visibility.py::test_the_sql_streak_facts_match_the_materialized_streak
# Collapse the CLI's second health read model into the one projection.
- id: HFR-097
name: the CLI is a projection consumer, not a second health read model
status: covered
kind: safety
layer: contract
backend: shared
# This change's own first draft added _task_health_map/_task_health to vibe/cli.py
# and a ScheduledTaskStore.definition_health_batch delegator that existed for no
# other caller: a SECOND read model over agent_runs beside _enrich_definitions,
# which every list, show and Workbench read already passes through. Two read models
# over one table is how the same definition comes to have two answers, and it did --
# task mutations answered from the CLI-side query, watch mutations (which never grew
# one) answered with no health at all.
# FIX: delete both helpers and the delegator; mutations read the row back through
# get_scheduled_task / get_watch. Guarded two ways, because either alone is
# escapable: the source of vibe/cli.py and core/scheduled_tasks.py may not mention
# definition_health_batch or _task_health, AND every definition_health_batch call
# made while task add / pause / update run must have _enrich_definitions on its
# stack -- so the query cannot be reintroduced under a different name.
test: tests/test_harness_health_projection.py::test_the_cli_is_a_projection_consumer_not_a_second_health_read_model
- id: HFR-098
name: task and watch mutations answer with the enriched projection
status: covered
kind: failure
layer: contract
backend: shared
# The consuming end of HFR-097. A create/pause/resume/update response is the first --
# and for an agent, often the only -- thing anyone sees, so a definition that is
# already failing has to say so there. Watch mutations carried no health, no
# lifecycle_state and no failure counts at all; task mutations carried a separately
# queried copy of health and still no lifecycle fields.
# FIX: all seven mutation responses (task add / set_enabled / update, watch add /
# set_enabled / update, and the watch startup-failure details) build their payload
# from the row read back through _enrich_definitions. Asserted by seeding a real
# two-run failure streak in agent_runs and comparing each response against the
# show that immediately follows it -- immediately, because lifecycle_state
# legitimately changes with each pause and resume.
test: tests/test_harness_health_projection.py::test_task_and_watch_mutations_return_the_enriched_projection
- id: HFR-099
name: a successful rebind is delivered through the retried notice path
status: covered
kind: failure
layer: contract
backend: shared
# The one binding transition nobody hears about. A create_once definition whose
# pinned session is hard-deleted rebinds and retries; when the retry SUCCEEDS the
# run settles succeeded with error=None, so _owed_failure_notice_for_transition
# stamps nothing (it stamps only on failed) and _notify_binding_change is a
# log-only seam. The user's pinned session was replaced -- possibly onto different
# Agent/model settings -- and the only trace was a logger.warning.
# FIX: _emit_binding_change stamps a durable notice on the succeeded run row, once
# per transition (immediately after the binding_recovery marker lands, and only for
# action == "rebound" with a run that did not fail, so a rebind whose retry failed
# keeps its ordinary failure notice). Identity is binding:{task_id}:{signature} --
# SessionBindingChange's own "one broken binding, one notification" key -- and the
# kind/binding fields are additive, so no migration and no change to the
# eligibility index expressions HFR-088/089 pin. failure_notices.decide grows a
# deliver-always lane beside is_interruption, and the drain asks
# bypasses_suppression rather than is_interruption at the streak gate: reading the
# streak off a SUCCEEDED anchor would sweep in the definition's surrounding
# failures and defer the notice forever. list_owed_failure_notices widens its
# status predicate to both terminal verdicts (free: the index covers state and
# next_attempt_at, never status).
# Asserted on the real path end to end -- one SQLite file for the fire, the drain
# and the messages receipt -- and the second half is the point: the first delivery
# is killed, which must consume an attempt and arm the backoff rather than
# re-firing, and the next eligible tick delivers with a receipt. A one-shot emit
# beside the log line would satisfy "a message appeared" and fail that half.
# A second, subordinate test carries this same id --
# ``test_the_binding_notice_copy_only_names_commands_the_cli_has`` -- which parses
# every command the binding copy prints with the REAL ``build_parser()`` in both
# locales. It takes no id of its own because the PR6 overflow range this block was
# written against (250-274) was already occupied by #1064's landed HFR-240...279.
# Re-truthed in round 11: the plan merged as #1044 re-drew that allocation
# (docs/plans/harness-run-reliability.md §10.7, "Re-drawn 2026-07-29 against the
# merged catalog"), so PR6's overflow is now HFR-280...319 -- see the round-11 note
# under HFR-099 for why these subordinate ids are still unassigned.
# PR6 review round 9 (#1072). ``stamp_binding_change_notice`` is the ONE owed-notice
# writer with no terminal transition to ride: it runs on a LIVE run, before
# ``complete()``, so its read and its write are two statements with no lock across
# the gap -- pysqlite emits no ``BEGIN`` for a bare SELECT, the fact
# ``update_owed_failure_notice`` and ``upsert_definition_in_connection`` both
# document. Round 7 (see HFR-076) audited this writer and excused it as "a pre-read
# stamp"; right about the order, wrong about the connection, and there were two
# damage directions, both user-visible.
# * A second connection settles the row ``failed`` and stamps its OWN failure notice
# in the same UPDATE (``_merge_owed_failure_notice``). The whole-blob write put the
# binding blob over the top, so the user was told their session was swapped and
# NEVER told the run failed -- the notice this whole capability exists to deliver,
# overwritten by the one added last.
# * The row settles ``canceled``. A ``pending`` notice then sat on a status
# ``list_owed_failure_notices`` excludes by design: durable and undeliverable
# forever, the silent-drop shape HFR-088/089 exist to prevent. ``canceled`` is
# reserved for explicit stop semantics, so the correct outcome is NO notice at all
# rather than a deferred one -- a user who pressed Stop outranks the rebind news.
# FIX: the SELECT's status is re-asserted VERBATIM in the UPDATE's WHERE clause
# beside ``owed_notice_absent()``, with the loss read off ``rowcount`` -- the
# ``DefinitionWriteExpectation`` idiom, the same one HFR-076 moved the drain's guard
# into. The write is a ``json_set`` of the single key this method owns rather than a
# composed blob, for the atomicity reason one level down: the run is LIVE, so sibling
# metadata keys are being written concurrently (the sweep's ``interrupt_reason``, the
# settler's ``ok`` marker), and a status+notice CAS over a whole-blob write would
# still clobber whichever of those landed in the gap. ``json_valid`` over the same
# ``coalesce``d expression makes a MALFORMED blob a refusal-and-log rather than a
# ``malformed JSON`` raised out of the rebind path -- refused, never
# repaired-by-replacement, which is exactly what the old whole-blob write did to an
# unreadable blob.
# Four subordinate tests carry this same id.
# ``test_a_binding_stamp_refuses_a_failure_terminalized_inside_its_gap`` commits the
# terminal failure from a SECOND connection inside the gap (the loser's UPDATE
# hooked, as HFR-076's round-8 test does) and asserts the stamp reports it wrote
# nothing while the failure's own notice survives BYTE-INTACT.
# ``test_a_binding_stamp_never_lands_on_a_run_canceled_inside_its_gap`` does the same
# with a cancel and requires no notice at all.
# ``test_a_binding_stamp_on_a_malformed_metadata_row_is_refused_not_raised`` and
# ``test_a_binding_stamp_writes_only_its_own_metadata_key`` pin the two costs of the
# move: an unreadable blob is left alone rather than replaced, and a sibling live-run
# metadata key written in the gap survives.
# They take no ids of their own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 10 (#1072). That CAS had a THIRD damage direction, and its two
# tests could not see it because both raced the stamp against a status the guard is
# RIGHT to refuse. The winner can also terminalize ``succeeded`` -- which is not an
# edge case but the ORDINARY outcome of the rebind this notice exists for, a
# create_once definition whose pinned session was hard-deleted, rebound, and retried
# successfully. Refusing there is not a deferral, it is a PERMANENT SILENT LOSS, for
# two reasons that compound: a successful settlement writes no notice of its own, so
# nothing else ever fills the slot; and ``_emit_binding_change`` has already
# persisted the ``binding_recovery`` dedup marker through
# ``record_binding_recovery`` BEFORE it calls the stamp, so every later fire
# short-circuits on that marker and no retry is ever attempted. The user's pinned
# session was replaced, possibly onto different Agent/model settings, and the only
# trace is a logger.warning -- which is verbatim the bug THIS ID WAS OPENED TO
# CLOSE, reintroduced by the guard added to protect it. ``succeeded`` is also
# precisely why ``list_owed_failure_notices`` was widened to both terminal verdicts
# above: this catalog's own words, "the one notice a succeeded run can owe". The
# slot is not merely empty, it is legitimately owed and deliverable.
# FIX: a lost CAS re-reads the row ONCE, inside the same transaction, and retries
# the stamp exactly once when the winner normalizes to ``succeeded``, the metadata
# parses, and the notice slot is still empty. The retry re-asserts the RE-READ
# status and keeps ``owed_notice_absent()``/``json_valid`` unchanged, so it is the
# same compare-and-swap over a fresher observation rather than a weakened one. The
# other directions are unchanged and now stated as a total policy over terminal
# statuses: ``failed`` refuses (its own failure notice owns the slot and outranks
# this news), ``canceled`` refuses (Stop outranks the rebind news, and the drain
# excludes the status so a notice there would be durable and undeliverable), and
# anything else refuses (still live, slot occupied, or unreadable). No outcome falls
# through to an accidental default, which is the round-7 lesson about auditing a
# guard for TOTALITY rather than for the one case a finding named.
# EXACTLY ONE RETRY, AND THE REASON IS CONVERGENCE RATHER THAN LUCK -- explicitly
# NOT an argument from lock acquisition, since an UPDATE matching zero rows may
# never escalate to RESERVED. ``succeeded`` is terminal and every terminal writer in
# the module is guarded on a non-terminal status, so once the re-read sees it the
# status can never move again and the retry's predicate cannot go stale a second
# time. The slot is equally settled: ``record_binding_recovery`` is a guarded write
# admitting a single stamper per transition, so no second binding stamp exists to
# race and no terminal transition remains to stamp a failure notice. The only writer
# that can still touch the row is a sibling-key ``json_set`` (the sweep's
# ``interrupt_reason``), which moves neither the status nor the slot. A second loss
# would mean an invariant broke, not that a third attempt would help -- so there is
# no loop.
# One subordinate test carries this same id:
# ``test_a_binding_stamp_survives_a_success_settled_inside_its_gap`` reuses the
# round-9 failed-race interleaving with a SUCCESSFUL settlement as the racing write,
# and asserts ``interleaved`` first so a stamp that simply never raced cannot pass.
# Red on b3986fde with ``stamped is None``. The round-9 failed/canceled/malformed/
# sibling-key tests are untouched and still green, which is what makes this an
# ADDITION to the policy rather than a relaxation of it.
# It takes no id of its own because PR6's block is full at 099 and 100+ is
# contracted to PR2 by the merged plan (docs/plans/harness-run-reliability.md
# §10.7; landed in #1044, PR2 not started per its status header).
# PR6 review round 11 (#1072). The round-10 retry answered "is the notice LOST?" and
# was silent on "is it DUPLICATED?", which is the obligation a retry incurs. The
# follow-up asked for proof that exactly one durable binding notice reaches the user
# and that later fires do not add another, and no test carried it: the success-race
# test stops at store level and never calls ``_emit_binding_change``, so the
# ``binding_recovery`` marker that gates every later fire does not exist in its
# world -- and that marker is exactly what the round-10 second stamp attempt runs
# against.
# ``test_one_rebind_that_wins_its_race_still_notifies_exactly_once`` closes it end to
# end on one store, in three steps: the race driven THROUGH ``_emit_binding_change``
# so the marker is persisted before the stamp as in production; a later fire of the
# same definition against the same signature, on a REAL second ``agent_runs`` row
# (reusing the first would be refused by the occupied slot and would prove the wrong
# layer), which must not reach the store at all -- asserted on every stamp ATTEMPT,
# since the store's contents cannot distinguish a short-circuit from a refused
# attempt; and the drain through the real dispatcher landing exactly ONE durable
# message, with a second pass landing nothing.
# A GREEN-FROM-BIRTH PIN, said plainly: both dedup layers already existed and are
# each exercised elsewhere, so nothing here is a red-first fix -- what was missing
# was putting them together on the path round 10 touched. RED BY MUTATION instead:
# neutering the signature short-circuit makes the later fire stamp a second notice,
# and the attempt list comes back with the same signature twice.
# It takes no id of its own for the reason above -- but the allocation itself has
# moved, and this is the note the other blocks point at. The plan merged as #1044
# RE-DREW §10.7 against the merged catalog ("an overflow block is dead the moment a
# landed catalog occupies any of it"), and PR6's overflow is now HFR-280...319, with
# PR2 at HFR-100...129. §10.7 says so explicitly: "#1072 currently carries
# review-round tests that took no ID because its block was full and its old overflow
# was occupied -- the 280...319 block above is where they belong." So the ~20
# subordinate tests documented throughout this file now HAVE a home, and assigning
# them is real outstanding work rather than a documentation nicety. It is left
# undone here deliberately: it changes the catalog's id SET, which is the one
# property every round of this review has verified as unchanged, so it is a scoped
# follow-up for the plan owner and not a close-out edit.
test: tests/test_harness_failure_visibility.py::test_a_successful_rebind_is_delivered_through_the_retried_notice_path
- id: HFR-100
name: direct in-flight cancellation terminalizes the exact Run and releases ownership
status: covered
kind: cancellation
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_direct_inflight_cancellation_terminalizes_the_exact_run
- id: HFR-101
name: service stop terminalizes an in-flight Run so restart cannot replay it
status: covered
kind: restart
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_service_stop_terminalizes_inflight_run_without_replay
- id: HFR-102
name: every canceled task execution projects a result and only scheduler one-shots retire
status: covered
kind: cancellation
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_canceled_task_execution_projects_every_result_and_only_retires_scheduler_one_shots
- id: HFR-103
name: every service teardown settles the transferred scheduled Turn without draining held work
status: covered
kind: cancellation
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_service_teardown_terminalizes_transferred_turn_without_starting_queued_work
- id: HFR-104
name: restart recovery fails executed Runs and preserves separately owned rows
status: covered
kind: restart
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_restart_recovery_terminalizes_started_rows_and_preserves_other_owners
- id: HFR-105
name: every teardown entry point and state surface cell has evidence or an explicit owner
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_every_teardown_settlement_surface_is_reached_or_explicitly_owned_elsewhere
- id: HFR-106
name: user Stop cause wins when graceful shutdown cancels the same non-durable Run
status: covered
kind: cancellation
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_service_stop_preserves_non_durable_user_stop_cause
- id: HFR-130
name: one explicit SQLite snapshot prevents mixed ownership generations
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_130_hfr_138_snapshot_prevents_torn_run_to_delivery_handoff
- id: HFR-131
name: an open head wakes exact Session recovery and survives runtime reclamation
status: covered
kind: recovery
layer: scenario
backend: codex
test: tests/test_runtime_ownership.py::test_hfr_131_open_head_wakes_survives_reclaim_and_claims_exact_head
- id: HFR-132
name: a queued head wakes without an explicit Session policy release
status: covered
kind: recovery
layer: scenario
backend: codex
test: tests/test_runtime_ownership.py::test_hfr_132_queued_head_wakes_without_an_explicit_release
- id: HFR-133
name: unresolved Delivery fences and Turn ownership block reclamation
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_133_hfr_134_delivery_and_turn_contract_blocks_only_live_owners
- id: HFR-134
name: live Turn states block while terminal ownership history does not
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_133_hfr_134_delivery_and_turn_contract_blocks_only_live_owners
- id: HFR-135
name: only active Activity rows pin their exact backend runtime
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_135_hfr_147_only_active_exact_mapped_activity_pins
- id: HFR-136
name: watch runtime bookkeeping never pins but an execution Run does
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_136_watch_runtime_never_pins_but_execution_run_does
- id: HFR-137
name: exact-generation owner commits and reclamation serialize in both orderings
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_activation.py::test_hfr_137_claim_that_loses_to_cleanup_during_its_write_is_given_back
- id: HFR-138
name: ownership handoffs stay visible in one SQLite generation
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_130_hfr_138_snapshot_prevents_torn_run_to_delivery_handoff
- id: HFR-139
name: unrelated Sessions do not pin an exact runtime resource target
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_139_unrelated_session_does_not_pin_target
- id: HFR-140
name: proven missing bindings fail open while lookup failures fail closed
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_140_missing_binding_fails_open_but_provider_failure_fails_closed
- id: HFR-141
name: recovery wakes do not refresh exact Session progress clocks
status: covered
kind: safety
layer: contract
backend: codex
test: tests/test_runtime_ownership.py::test_hfr_141_repeated_wakes_do_not_refresh_progress_clocks
- id: HFR-142
name: a request waiting on a runtime gate does not create progress
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_agent_service.py::test_hfr_142_gate_wait_does_not_refresh_backend_progress_clock
- id: HFR-143
name: exact observable Session progress wins the locked reclamation recheck
status: covered
kind: concurrency
layer: contract
backend: codex
test: tests/test_codex_agent.py::CodexAgentStopTests::test_hfr_143_observable_session_progress_wins_locked_recheck
- id: HFR-144
name: stuck ownership settles only the exact active owner without replay
status: covered
kind: recovery
layer: contract
backend: codex
test: tests/test_codex_agent.py::CodexAgentStopTests::test_hfr_144_stuck_active_settles_only_exact_codex_owner
related_tests:
- tests/test_codex_runtime_generations.py::test_hfr_144_a_stuck_turn_settles_on_the_generation_that_runs_it
- tests/test_codex_runtime_generations.py::test_hfr_144_the_stuck_turn_backstop_never_forgets_a_turn_admitted_meanwhile
- id: HFR-145
name: every enabled backend invalidation path consumes exact ownership
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_145_every_backend_invalidation_path_consumes_exact_ownership
- id: HFR-146
name: shared Codex and composite Claude resources use exact durable bindings
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_146_shared_codex_target_and_claude_mapping_use_exact_bindings
- id: HFR-147
name: Session-less active Activity maps to its exact backend resource
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_135_hfr_147_only_active_exact_mapped_activity_pins
- id: HFR-148
name: fallback Run ownership follows queued pre-execution and PID-started boundaries
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_148_hfr_150_fallback_run_uses_pid_boundary_and_exact_route
- id: HFR-149
name: periodic recovery re-enters only exact unresolved ownership observations
status: covered
kind: recovery
layer: scenario
backend: shared
test: tests/test_runtime_recovery.py::test_hfr_149_session_lane_recovers_only_current_exact_observation
- id: HFR-150
name: fallback Runs survive exact route mapping and archived Session reuse
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_ownership.py::test_hfr_148_hfr_150_fallback_run_uses_pid_boundary_and_exact_route
- id: HFR-151
name: supervisor wakes coalesce with bounded per-partition single flight
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_151_supervisor_coalesces_wakes_and_keeps_partition_single_flight
- id: HFR-152
name: supervisor startup is paused and periodic reconciliation re-reads work
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_152_supervisor_starts_paused_and_periodic_reconcile_wakes_lane
- id: HFR-153
name: event callbacks cross threads without off-loop lane mutation
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_153_bus_callback_crosses_threads_without_mutating_lane_off_loop
- id: HFR-154
name: live registrations require exact generation handoff before replacement
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_154_replacing_live_registration_requires_generation_handoff
- id: HFR-155
name: runtime work hints wake only their mapped durable lanes
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_155_events_wake_only_their_durable_lanes
- id: HFR-156
name: socket hint failure cannot roll back committed durable work
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_inbox_events.py::test_hfr_156_bridge_failure_does_not_rollback_committed_run
- id: HFR-157
name: startup and slow reconciliation recover lost runtime work hints
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_152_supervisor_starts_paused_and_periodic_reconcile_wakes_lane
- id: HFR-158
name: occupied partitions cannot hide later actionable work
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_158_request_scan_fills_page_across_recovery_and_queued_work
- id: HFR-159
name: blocking store scans do not block the controller loop or other lanes
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_159_blocked_store_scan_does_not_block_another_lane
- id: HFR-160
name: live and recovered work share one exact partition owner
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_160_canceled_sync_worker_remains_owner_until_thread_exits
- id: HFR-161
name: scheduled work admits one queued successor through one request owner
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_161_scheduler_only_enqueues_one_successor_behind_active_work
- id: HFR-162
name: a final-scan wake is retained and rearmed after failure
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_162_wake_during_final_empty_scan_is_not_lost
- id: HFR-163
name: runtime work lanes enforce global and per-partition single flight
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_163_lane_capacity_bounds_distinct_partition_workers
- id: HFR-164
name: service restart joins only its own runtime work registrations
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_164_hfr_165_service_restart_joins_only_its_harness_lane_generations
- id: HFR-165
name: repeated service cycles leave one current registration generation
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_164_hfr_165_service_restart_joins_only_its_harness_lane_generations
- id: HFR-166
name: recovered Activity batches retain durable live batching grace
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_session_activities.py::test_hfr_166_recovered_unbound_grace_uses_first_durable_completion
- id: HFR-167
name: accepted Activity output retries local settlement without transport replay
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_message_dispatcher_scheduled.py::MessageDispatcherScheduledTests::test_recovered_durable_message_retries_only_local_settlement_after_restart
- id: HFR-168
name: incomplete recovered Activity batches fail closed before transport
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_session_activities.py::test_recovery_marks_an_incomplete_persisted_output_batch_for_fail_closed_emit
- id: HFR-169
name: Activity recovery remains visible without a Run projection
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_169_recovered_activity_without_run_reaches_its_session
- id: HFR-170
name: skipped runtime work rearms with bounded backoff
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_170_guarded_noop_uses_partition_backoff
- id: HFR-171
name: overdue runtime work identifies lane partition and generation
status: covered
kind: observability
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_171_overdue_report_names_lane_partition_and_generation
- id: HFR-172
name: definition hints follow commit and exclude rollback or losing CAS
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_172_task_definition_wake_follows_commit_and_not_rollback
- id: HFR-173
name: local event fanout and bounded bridge echo dedupe deliver once
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_inbox_bridge.py::test_hfr_173_local_event_echo_is_suppressed_once
- id: HFR-174
name: task and watch definition commits wake separate reconcile owners
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_watches.py::test_hfr_174_watch_definition_commit_emits_watch_hint
- id: HFR-175
name: global lease loss stops and joins every runtime work registration
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_runtime_work_supervisor.py::test_hfr_175_global_lease_loss_joins_every_registration
- id: HFR-176
name: legacy file signatures wake only their mapped runtime work lanes
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_176_legacy_file_probes_wake_only_their_mapped_lanes
- id: HFR-177
name: transport readiness directly resumes skipped request admission
status: covered
kind: recovery
layer: contract
backend: shared
test: tests/test_scheduled_tasks.py::test_hfr_177_transport_ready_wakes_requests_and_resumes_skipped_run
- id: HFR-178
name: loop-owned shutdown retains supervisor join past outer grace
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_controller_dispatch_loop.py::test_request_shutdown_keeps_loop_owned_supervisor_join_alive_after_grace
- id: HFR-179
name: managed-watch store work stays single-flight and applies on loop
status: covered
kind: concurrency
layer: contract
backend: shared
test: tests/test_watches.py::test_hfr_179_watch_store_phases_are_single_flight_and_apply_on_loop
- id: HFR-240
name: the backend-wide clear does not delete a superseded row
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_sqlite_sessions_store.py::test_backend_wide_clear_does_not_delete_a_superseded_row
- id: HFR-241
name: the superseded exclusion still deletes a row carrying no marker
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_sqlite_sessions_store.py::test_backend_wide_clear_still_deletes_a_rows_with_an_empty_anchor
- id: HFR-242
name: /new end to end keeps a superseded session and its bound definitions
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_command_handler_user_names.py::NewCommandStorageIntegrationTests::test_new_keeps_a_superseded_session_and_its_definitions_but_clears_the_live_one
- id: HFR-243
name: a rebind whose snapshot Agent is gone falls back to scope defaults
status: covered
kind: failure_recovery
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_rebind_falls_back_to_scope_defaults_when_the_snapshot_agent_is_gone
- id: HFR-244
name: a snapshot's null model survives the rebind instead of adopting the Agent's
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_scheduled_tasks.py::test_rebind_keeps_a_snapshot_null_model_instead_of_adopting_the_agents
- id: HFR-245
name: an unrelated task update keeps the rebound session's Agent authority
status: covered
kind: failure_recovery
layer: scenario
backend: shared
# The schema carries one path, so this stays the primary test. A second test
# covers the same id in the report's literal order (unrelated edit BEFORE the
# default moves), where the persisted-state assertion is the load-bearing one:
# tests/test_scheduled_tasks.py::test_unrelated_task_update_keeps_the_follow_state_before_the_default_moves
test: tests/test_scheduled_tasks.py::test_unrelated_task_update_keeps_the_rebound_sessions_agent_authority
- id: HFR-246
name: adopting an unbound row replaces the old backend's whole route
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_sqlite_sessions_store.py::test_legacy_adoption_replaces_the_whole_route_of_an_unbound_row
- id: HFR-247
name: the workbench Default action drops the explicit-override marker
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_core_services_sessions.py::test_workbench_default_action_drops_the_explicit_override_marker
- id: HFR-248
name: forking an explicit-null session copies its pins, not just its nulls
status: covered
kind: safety
layer: scenario
backend: shared
test: tests/test_session_fork.py::test_forking_an_inherited_null_session_keeps_its_explicit_pins
- id: HFR-249
name: turn-start materialization never fills an explicitly pinned setting
status: covered
kind: safety
layer: contract
backend: shared
test: tests/test_sqlite_sessions_store.py::test_materialize_agent_session_route_never_fills_an_explicitly_pinned_field
- id: HFR-250
name: a native bind by id replaces the whole route of an unbound row
status: covered
kind: safety
layer: scenario
backend: shared
# HFR-246 covers the (scope, anchor) adoption door (``_claim_anchor_row``); this
# is the second one, ``bind_agent_session_by_id``, which binds an explicitly
# targeted reserved row. Two companion tests hold the edges: an already-bound
# row keeps its backend identity (write-once), and an ordinary same-backend bind
# keeps the row's model / reasoning_effort and their marker.
# tests/test_sqlite_sessions_store.py::test_native_bind_by_id_keeps_the_backend_of_an_already_bound_row
# tests/test_sqlite_sessions_store.py::test_native_bind_by_id_keeps_the_pins_of_a_same_backend_bind
test: tests/test_sqlite_sessions_store.py::test_native_bind_by_id_replaces_the_whole_route_of_an_unbound_row
- id: HFR-251
name: a native bind by id that loses the race leaves the winner's row intact
status: covered
kind: safety
layer: contract
backend: shared
# kind=safety, not idempotency: two DIFFERENT callers with different natives and
# different Agent identities are not repeats of one another, so there is no
# "same call twice" to be idempotent about. What must hold is that losing the
# race destroys NOTHING the winner owns -- not merely "the write-once native id
# survives". The winner's native, backend, Agent id / name / variant,
# model / reasoning_effort, explicit-override marker, status and
# updated_at / last_active_at all stand. HFR-250 fixed WHAT the adoption branch
# writes; this covers WHEN it is allowed to, since its snapshot reads reserve
# nothing and SQLite only locks at the UPDATE.
# Three halves, one window. The two same-backend first-bind halves cover the
# branch where _set_native_once's SELECT was the only thing enforcing
# write-once, and specifically the two routes through the fall-through that
# dropped the identity columns only when requested_backend != winner_backend --
# the loser naming the winner's own backend (comparison equal), and the loser
# naming no backend at all (comparison cannot fire). Both were red asserting
# the winner's Agent identity and timestamps while its native id stood:
# tests/test_sqlite_sessions_store.py::test_native_bind_by_id_loses_a_concurrent_first_bind_without_a_requested_backend
# tests/test_sqlite_sessions_store.py::test_native_bind_by_id_loses_a_concurrent_same_backend_first_bind
test: tests/test_sqlite_sessions_store.py::test_native_bind_by_id_loses_a_concurrent_cross_backend_adoption
- id: HFR-252
name: a session archived mid-bind stays archived, whichever branch the bind takes
status: covered
kind: safety
layer: contract
backend: shared
# The third read in bind_agent_session_by_id -- the status SELECT that refuses
# archived rows -- has the same read-then-write shape HFR-251 closed twice, but
# it decides no write: all three UPDATEs re-assert status != 'archived'
# themselves, so a late archive makes the write a no-op and the call returns
# None. So this entry is a PROOF, green before it was written, not a red-green
# regression. It exists because nothing failed if a future edit dropped one of
# those predicates and left the SELECT to "guard" the write; each case was
# confirmed to fail with its own predicate removed, one statement each.
# The other two statements: the cross-backend adopt, and the idempotent re-bind
# that is the only shape reaching the final UPDATE (write-once declines, so it
# is a bare id match carrying status='active'):
# tests/test_sqlite_sessions_store.py::test_native_bind_by_id_cannot_adopt_a_session_archived_inside_its_window
# tests/test_sqlite_sessions_store.py::test_native_bind_by_id_idempotent_rebind_cannot_resurrect_an_archived_session
test: tests/test_sqlite_sessions_store.py::test_native_bind_by_id_cannot_resurrect_a_session_archived_inside_its_window
- id: HFR-253
name: >-
an anchor relabel that loses the race leaves the winner's row intact and
returns no id for an archived winner
status: covered
kind: safety
layer: contract
backend: shared
# The THIRD writer with the HFR-251 shape, and the one that re-asserted nothing
# at all: _claim_anchor_row's unbound branch decided "relabel this row to the
# incoming backend and replace its whole route" and then issued
# UPDATE ... WHERE id = ?, with no write-once, no backend and no archive
# predicate -- while its sibling bind_agent_session_by_id, added by the same PR,
# got all three. Production path: the channel Agent switches to Claude while the
# previous Codex turn is still finishing, so the Codex native id commits inside
# the window and the row comes out agent_backend='claude' holding a Codex native.
# The scope key is part of the mechanism: a 3-part key (slack::channel::C1)
# upserts the scope first, so the transaction already holds the write lock and the
# window does not exist; only the 2-part form build_context_session_key emits for
# ordinary channel/thread turns is exposed.
# The paired half covers the same window with a terminal archive as the competing
# write:
# tests/test_sqlite_sessions_store.py::test_ensure_agent_session_id_cannot_relabel_a_row_archived_inside_its_window
# THE INVARIANT IS WIDER THAN THE ROW: what the function RETURNS is part of it.
# Guarding the UPDATE stopped the relabel, but the lost-race path still handed
# back the winner's id even when the winner ARCHIVED the row -- and an archive is
# terminal, vacates the anchor, and is filtered out by every read path here. There
# is no later re-resolve to correct it: BaseAgent.ensure_agent_session_id pins any
# non-empty answer into context.platform_specific['agent_session_id'] and the turn
# runs against that row. So a lost relabel whose winner archived yields NO usable
# session: None, propagated through get_or_create_agent_session_row ->
# SQLiteSessionsService.ensure_agent_session_id, which is what the two sibling
# bind paths already answer for the same interleaving -- and NOT a fresh row,
# which would be a second write decided from the snapshot the relabel was just
# refused for. A LIVE bound winner is a real session, so the primary test pins the
# other answer just as explicitly: its id is still returned. Asserted at the
# storage boundary by both halves and end to end (the id is never pinned into the
# turn context) by:
# tests/test_sqlite_sessions_store.py::test_ensure_agent_session_id_archive_race_never_pins_an_agent_session_id
test: tests/test_sqlite_sessions_store.py::test_ensure_agent_session_id_cannot_relabel_a_row_bound_inside_its_window
- id: HFR-254
name: the legacy-scope native bind destroys nothing a concurrent winner owns
status: covered
kind: safety
layer: contract
backend: shared
# bind_agent_session is the legacy-scope twin of bind_agent_session_by_id and was
# missed by HFR-251/252: _set_native_once is a preceding SELECT, and the UPDATE
# acting on its answer carried neither coalesce(native_session_id,'') = '' nor
# status != 'archived' while unconditionally setting status='active'. One
# competing commit inside that window therefore lost its write-once native AND
# had its terminal archive undone, with the losing caller reporting success.
# The invariant is the same as HFR-251's and is NOT just write-once + archive:
# losing the race must destroy NOTHING the winner owns -- its native id, its
# Agent id / name / variant, model / reasoning_effort and the explicit-override
# marker, its status, and its updated_at / last_active_at all stand.
# Two halves, one window. The archive half asserts the write-once native, the
# surviving archive and the None return. The identity half is the one the first
# fix reintroduced and had to close a second time: with a LIVE winner the
# rowcount-0 first bind FELL THROUGH to the final UPDATE, whose shared values
# dict carries status='active', both timestamps and the caller's agent_id /
# agent_name, so the loser stamped its own Agent identity and clock over the
# winner while the native id stood. An archived winner hides it -- that write is
# refused wholesale by status != 'archived'. Same correction as the twin's:
# tests/test_sqlite_sessions_store.py::test_bind_agent_session_loses_a_concurrent_same_backend_first_bind
# The 2-part scope key (slack::C4) is part of the mechanism: a 3-part key upserts
# the scope, taking the write lock before the window opens.
test: tests/test_sqlite_sessions_store.py::test_bind_agent_session_keeps_the_native_of_a_row_bound_inside_its_window
- id: HFR-255
name: vibe task update rejects --agent together with --clear-agent
status: covered
kind: safety
layer: scenario
backend: shared
# The follow-the-session marker (HFR-245) was defeatable in ONE command. The pair
# honoured neither flag: --clear-agent won for agent_name (-> None) while the mere
# presence of --agent set explicit_agent_requested, which POPS the marker, so the
# definition looked like "unpinned and not following its Session" and the resolve
# wrote today's scope/default Agent back as a hard pin. Fixed by rejecting the
# contradictory pair, the convention --name / --clear-name already uses; the test
# asserts both pairs so they cannot drift apart.
# The sibling hole in vibe watch update is closed by HFR-256.
test: tests/test_cli_task_command.py::test_task_update_rejects_agent_together_with_clear_agent
- id: HFR-256
name: vibe watch update keeps the bound Session's Agent authority
status: covered
kind: safety
layer: scenario
backend: shared
# cmd_watch_update is the sibling definition command over the same run_definitions
# rows and had NO follow-the-session logic at all: --clear-agent / --agent were a
# silent if/elif with no contradictory-pair rejection, and the command then ran the
# same "agent_name is None and session_policy != 'existing'" re-resolution as the
# task side, writing today's scope/default Agent back as a HARD PIN. So
# --clear-agent was silently undone, and any unrelated edit (--name) re-pinned a
# watch whose Agent authority belonged to its Session. Parity fix: reuse
# BINDING_FOLLOWS_SESSION_METADATA_KEY, keep all three durable states
# (clear/follow, preserve on unrelated edits, exit on explicit --agent), and reject
# --agent together with --clear-agent (HFR-255's shape).
# The proof is NOT the CLI payload: after the unrelated edit the scope default is
# moved and the watch is FIRED through its production path -- the real
# ManagedWatchService._run_watch reads the STORED definition, _enqueue_hook queues a
# "watch" request carrying agent_name, and the real ScheduledTaskService
# claim/execute path hands it to the real MessageHandler. The assertions are on the
# AgentRequest that handler built (Agent identity, backend, system prompt). Only the
# waiter subprocess is stubbed.
# NOTE: _recover_pinned_session_binding (the reset-rebind writer of the marker) is
# reached only from _execute_task and takes a ScheduledTask, so it never runs for a
# watch definition; a watch enters the state through --clear-agent. Extending reset
# rebinding to watches is a separate change.
# The contradictory-pair half:
# tests/test_cli_watch_command.py::test_watch_update_rejects_agent_together_with_clear_agent
test: tests/test_scheduled_tasks.py::test_unrelated_watch_update_keeps_the_follow_session_agent_authority
# HFR-257..260 are the rest of the SET. HFR-251..254 each closed one instance of the
# same defect -- decide from a SELECT, then write with a predicate that re-asserts
# nothing -- one per review round, in the BIND writers. These four come from
# enumerating every UPDATE / INSERT / DELETE in storage/session_reclaim.py,
# storage/agent_session_rows.py and on their teardown call path and asking the same
# question of each, so the class is closed rather than sampled again.
- id: HFR-257
name: a reclaim that loses to a repoint changes nothing and is reported to nobody
status: covered
kind: safety
layer: contract
backend: shared
# reclaim_bound_definitions read every live definition bound to the dying session
# and then wrote WHERE run_definitions.id = ? alone. The hard-delete path
# (_delete_agent_session_rows) reaches it after nothing but reads -- a resolved
# 2-part scope key never upserts -- so a user repointing that task/watch to another
# Session (upsert_scheduled_task, a full-row UPDATE) inside the window had the
# definition paused on its NEW live binding, with its session_settings_snapshot
# overwritten by the DEAD session's settings; that snapshot is what a later
# create_once rebind reads, so the task would return on the wrong model / agent.
# Guarded by re-asserting both halves of what the read decided: session_id = <the
# binding this reclaim is for> AND deleted_at IS NULL.
# THE ACCOUNTING IS THE OTHER HALF, and it is a user-visible invariant, not
# bookkeeping: the returned summary is what the archive confirm dialog reports and
# the ledger is what /new counts in its reply, so both are credited only on
# rowcount. Measured at b366384b: summary {'paused': 1, 'snapshotted': 1} and a
# ledger entry for a definition that was never the teardown's to touch.
# The /new half drives the production path (delete_agent_sessions ->
# _delete_agent_session_rows -> reclaim, inside the command handler's
# session_teardown_context) with two definitions, so the ledger has to name exactly
# the one that did NOT move:
# tests/test_sqlite_sessions_store.py::test_new_teardown_path_reports_only_the_definitions_it_reclaimed
test: tests/test_sqlite_sessions_store.py::test_reclaim_leaves_a_definition_repointed_inside_its_window_alone
- id: HFR-258
name: a lost anchor supersede returns the winning session instead of raising
status: covered
kind: safety
layer: contract
backend: shared
# The SECOND branch of _claim_anchor_row, and the one HFR-253 left behind: it
# guarded the relabel and not the supersede. Two turns on one thread claim a bound
# row for a new backend; the winner moves the anchor aside and inserts its
# replacement, then the loser's UPDATE ... WHERE id = ? "succeeds" (it re-supersedes
# an already-moved anchor), reports the slot freed, and falls into
# create_agent_session_row -- whose INSERT collides with the winner's replacement on
# the UNIQUE (scope_id, session_anchor) index. Red at b366384b with
# IntegrityError: UNIQUE constraint failed: agent_sessions.scope_id,
# agent_sessions.session_anchor escaping ensure_agent_session_id.
# Guarded by re-asserting status != 'archived', the anchor the row was resolved by,
# and the backend the branch decided against; on rowcount 0 the current anchor
# HOLDER is re-read and returned (None when it archived or is gone, which is what
# every caller of get_or_create_agent_session_row already handles). What the
# function RETURNS is part of the invariant, exactly as in HFR-253.
test: tests/test_sqlite_sessions_store.py::test_anchor_supersede_returns_the_winner_of_a_concurrent_supersede
- id: HFR-259
name: the placeholder relabel never hands back a row it lost the race for
status: covered
kind: safety
layer: contract
backend: shared
# _find_agent_session_row_id runs BEFORE get_or_create_agent_session_row on both
# bind entry points, and its legacy branch is itself a read-then-write: select a row
# whose agent_backend / agent_variant are still the blank / "default" placeholder,
# then relabel it with UPDATE ... WHERE id = ? and RETURN that id. Two ways to lose,
# both asserted. An archive committed inside the window was relabelled and then
# handed back -- and ensure_agent_session_id returns its answer unchanged while
# BaseAgent.ensure_agent_session_id pins any non-empty id into
# context.platform_specific['agent_session_id'] without re-resolving, so the turn ran
# against a terminal row (HFR-253's invariant, in a different function). A concurrent
# concrete-backend claim was overwritten, leaving the row labelled with this caller's
# backend while holding the winner's write-once native id.
# The answer on loss is None -- what this finder already returns when it sees nothing
# usable -- so the caller re-resolves through the guarded (scope, anchor) path and
# converges with the serial order instead of deciding twice from one snapshot.
# The identity half:
# tests/test_sqlite_sessions_store.py::test_placeholder_relabel_cannot_overwrite_a_backend_claimed_inside_its_window
test: tests/test_sqlite_sessions_store.py::test_ensure_agent_session_id_never_returns_a_placeholder_archived_inside_its_window
- id: HFR-260
name: a /new clear keeps a session superseded inside its window
status: covered
kind: safety
layer: contract
backend: shared
# _delete_agent_session_rows evaluated the WHOLE teardown query -- scope, agent-name
# match and the include_superseded=False guard -- in the id READ, before any write
# lock existed, then hard-deleted by id list. Superseding PROMISES the row is kept
# (write-once native id, unrecoverable transcript), so a supersede committed inside
# that window made /new hard-delete exactly the row the guard protects, and count it.
# Fixed by re-running id_query inside the DELETE, which re-evaluates every predicate
# under the lock whichever caller built them, and returning only rows actually
# removed.
# DELIBERATELY NOT ROLLED BACK: the reclaim runs first (it needs both rows visible
# for the settings snapshot), and wrapping the pair in a SAVEPOINT makes it worse --
# under WAL the SAVEPOINT opens the transaction before the reclaim's own SELECT, so
# the read pins a snapshot and the reclaim UPDATE fails with SQLITE_BUSY_SNAPSHOT on
# this very interleaving (measured). The pause therefore stands and the ledger says
# so; pause is the recoverable mode and the kept row is one the thread has moved off.
test: tests/test_sqlite_sessions_store.py::test_new_teardown_keeps_a_session_superseded_inside_its_window
# HFR-261..262 continue the same class from the OTHER side. HFR-249..260 guarded the
# writers that decide from a read one statement earlier; these two are the writer whose
# read is a whole LAYER earlier (a CLI command's payload) and the one race a guarded
# statement cannot answer at all -- there the loser is refused the write lock outright,
# so the remedy is to hold the lock from before the read rather than re-assert it.
- id: HFR-261
name: a full-row definition write cannot undo the reclaim it lost to
status: covered
kind: safety
layer: contract
backend: shared
# upsert_scheduled_task and upsert_watch write EVERY column of run_definitions from a
# payload the caller built out of a read one layer up (vibe task/watch update reads
# the definition, then resolves Agents, Sessions and delivery targets before writing).
# A reclaim committed in that window -- /new or the archive dialog, whose own CAS was
# closed by HFR-257 -- was then silently REVERTED: the stale payload restored
# session_id, enabled, deleted_at (no in-memory definition even carries the column, so
# it was always written back as NULL, resurrecting a soft-deleted task) and the
# pre-teardown metadata_json, including the session_settings_snapshot a later
# create_once rebind reads for the dead session's workdir/agent/model (D3). The
# reclaim's counters and the /new ledger had already told the user "1 task paused".
# PREDICATE SET = the state teardown owns: session_id, enabled, deleted_at, and the
# snapshot's captured_at. The fourth is not redundant: for an ALREADY-paused
# definition the reclaim changes none of the first three, it only refreshes the
# snapshot. Deliberately NOT updated_at / the whole row -- a version guard would
# refuse a rename racing a run-result stamp and turn a working edit into an error.
# Both writers share one guarded statement (_upsert_definition) and the
# unchanged_text idiom of storage/agent_session_rows.py, so the pair cannot drift.
# CALLERS: vibe task update / vibe watch update and pause/resume raise
# DefinitionWriteConflict -> exit 1 with code definition_write_conflict (a lost write
# must not be reported as an applied edit); the runtime stamps (mark_task_result,
# mark_cycle_start/result, record_binding_recovery) return False and reload the
# mirror; the reset-rebind persist logs and keeps the rebind for that fire only.
# The watch half, same window, same command shape:
# tests/test_cli_watch_command.py::test_watch_update_refuses_to_undo_a_reclaim_committed_after_its_read
# The deleted_at half (archive + an in-flight run's result stamp):
# tests/test_scheduled_tasks.py::test_task_result_stamp_cannot_resurrect_a_definition_the_archive_deleted
# The snapshot-marker half (the reclaim shape the lifecycle guards cannot see):
# tests/test_scheduled_tasks.py::test_cycle_result_cannot_restore_the_metadata_a_snapshot_refresh_replaced
test: tests/test_cli_task_command.py::test_task_update_refuses_to_undo_a_reclaim_committed_after_its_read
- id: HFR-262
name: a first-turn insert holds the write lock across the reads it decides from
status: covered
kind: reliability
layer: contract
backend: shared
# get_or_create_agent_session_row's create branch READ and then wrote with no lock
# between: SAVEPOINT opened the transaction and new_session_id's scan pinned a WAL read
# snapshot inside it, so a competing first turn committing between that scan and the
# INSERT left the loser unable to become a writer at all. SQLite answers
# SQLITE_BUSY_SNAPSHOT (extended code 517) -- a PLAIN OperationalError whose primary
# code and "database is locked" message are the ones every unrelated busy error
# carries -- and busy_timeout never retries it, because waiting cannot make a snapshot
# newer. Measured at ed4ddd93: 517 escaping ensure_agent_session_id on an ordinary
# first turn, from the shared get-or-create every platform reaches.
# MECHANISM: reserve_write_lock, called BEFORE the reads the INSERT decides from, so
# the failure cannot occur instead of being recovered from afterwards. The create path
# becomes the writer, re-reads the anchor under the lock, and only then inserts -- with
# one writer allowed, nothing it decided from can change, so neither SQLITE_BUSY_SNAPSHOT
# nor the UNIQUE-index IntegrityError is reachable there. Exactly the guarantee
# _claim_anchor_row's supersede branch already relied on (its anchor-move UPDATE takes
# the lock, which is why its own INSERT needs no re-read), now available to the paths
# with no write to lead with.
# WHY NOT DETECTION. Identifying 517 needs sqlite3.Error.sqlite_errorcode, which is
# Python 3.11+, while requires-python is >= 3.10. Verified on 3.10.12: the attribute is
# absent, the round-14 detect-and-retry fix let OperationalError("database is locked")
# escape a first turn, and the same test passed on 3.13 -- a fix that only works on
# some supported interpreters. Not producing the error needs nothing from the
# interpreter, so the 517 catch, its bounded retry, the SAVEPOINT and the
# "gave up, no usable session" answer are all DELETED rather than left unreachable.
# TWO SPELLINGS, ONE GUARANTEE, because SQLite has no LOCK TABLE: BEGIN IMMEDIATE when
# the connection is in autocommit (which is every entry point that resolves its scope
# with a pure SELECT, since pysqlite opens no transaction for a bare SELECT), and a
# never-matching UPDATE when a transaction is already open and BEGIN IMMEDIATE would be
# illegal (a 3-part scope key upserts the scope first). SQLite takes the write lock at
# the START of an UPDATE program, before its WHERE loop, which is pinned by a test
# rather than trusted.
# SCOPE: the create branch only. The read-mostly fast path where a session row already
# exists stays unlocked and keeps re-asserting its read inside the statement
# (unchanged_text, HFR-249..260), so no inbound message serialises on this. The window
# that remains -- a winner committing between the unlocked first read and the
# reservation -- is why the create re-decides under the lock, and is covered.
# COST: concurrent FIRST turns on one database queue behind each other for the length
# of the caller's transaction, bounded by busy_timeout (5s); the previous behaviour on
# that interleaving was an exception, not a faster answer.
# PROVEN AS A FACT, NOT AN ARGUMENT: a competing writer given busy_timeout = 0 must be
# REFUSED at the last read before the INSERT, checked for every production entry point
# and paired with a statement-sequence assertion that a reservation precedes that read.
# Both observations are version-independent, and the whole set passes on 3.10.12 and
# 3.13.5 and fails against both the pre-round-14 and the round-14 module.
# Every production path into the contested INSERT:
# tests/test_sqlite_sessions_store.py::test_every_first_turn_entry_point_reserves_the_write_lock
# tests/test_agent_run_target.py::test_resolve_agent_run_target_reserves_the_write_lock_for_its_first_turn_insert
# The window kept open on purpose, and the reserved re-read that closes it:
# tests/test_sqlite_sessions_store.py::test_first_turn_insert_joins_a_winner_that_committed_before_the_reservation
# The never-matching UPDATE actually takes the lock and changes nothing:
# tests/test_sqlite_sessions_store.py::test_write_lock_reservation_takes_the_lock_without_touching_a_row
test: tests/test_sqlite_sessions_store.py::test_first_turn_insert_reserves_the_write_lock_before_the_reads_it_decides_from
# WHAT THE WHOLE-ROW-WRITER HUNT FOUND, and what the id HFR-263 actually holds now.
# The hunt for a THIRD whole-row writer that could clobber a guarded transition came
# back empty, and that negative still stands: the only one found is
# SQLiteSessionsService.save_state (config/v2_sessions.py::SessionsStore.save →
# on_conflict_do_update over agent_sessions, which overwrites status /
# native_session_id / agent_backend / metadata_json from a legacy in-memory map), and
# it is the one DEFERRED instance, tracked as issue #1076 and not fixed here.
# HFR-263 was briefly recorded as "hunted, does not exist" on the strength of that
# negative. That was the wrong conclusion to draw from it: the hunt asked who ELSE
# writes whole rows, and the open question was the opposite one -- who CONSUMES a
# guarded write's refusal. HFR-263..266 are that question's answers, and the id
# HFR-263 now belongs to the watch consuming end below.
# HFR-263..266 are the CONSUMING end of the guards HFR-249..262 added. A guarded write
# that correctly refuses is only half an invariant: the caller still has to stop, and
# four of them did not. Two discarded the refusal outright (the watch supervisor's
# wrapper, the scheduled-fire result stamp), one discarded it and notified anyway, and
# one inferred a settled catalog fact from a broad catch and so read an infrastructure
# fault as one. Same shape as the guards themselves, one layer out: nothing that did
# not happen may be reported as though it had.
- id: HFR-263
name: a refused cycle-start stamp stops the watch before it runs anything
status: covered
kind: safety
layer: contract
backend: shared
# /new pauses a bound watch (reclaim, HFR-257) and replies "1 watch paused". The
# supervisor loop is already past its own maybe_reload, so it holds the pre-teardown
# mirror; mark_cycle_start is the guarded full-row write (HFR-261) that refuses that
# stale payload and returns False.
# THE HOLE WAS THE WRAPPER. _watch_store_call was `callback(); return True` -- it
# discarded the callback's own return value and reported the refusal to the loop as a
# landed write. The cycle then spawned its waiter subprocess and enqueued a hook into
# the session the teardown had just deleted, after /new told the user the watch was
# paused. Both the command execution and the delivery happen AFTER the stamp, so both
# are reachable from one discarded bool.
# FIX: guarded=True makes the callback's False a refusal the wrapper propagates, for
# mark_cycle_start and every mark_cycle_result site. Opt-in, not the default, because
# a False return is not universally a refusal -- maybe_reload returns False for
# "nothing changed", which is the common case and must not stop the watch. A refusal
# does NOT fuse the store: the database is healthy, this write simply lost.
# Driven through the REAL _run_watch with the reclaim committed from a second
# connection inside the write window; _run_cycle is the only double and returns a
# SUCCESS result on purpose, because on the unfixed wrapper that is what produces the
# hook the test forbids.
test: tests/test_watches.py::test_run_watch_stops_when_its_start_stamp_loses_to_a_reclaim
- id: HFR-264
name: a refused result stamp cannot complete the run ok
status: covered
kind: safety
layer: contract
backend: shared
# The task twin of HFR-263, and the one that reaches the run ledger. A one-shot task
# fires, the user archives the bound Session mid-run, reclaim(mode='delete')
# soft-deletes the definition, and mark_task_result refuses the stale terminal stamp
# (HFR-261) -- last_run_at, last_error and the one-shot disable are not stored.
# _execute_task discarded that False and returned a TaskExecutionResult with
# error=None, so _execute_claimed_request completed the run ok=True: the database
# refused the stamp and BOTH the caller and agent_runs reported success. The user sees
# a green run for a task whose stored state never moved, and an `at` task that was
# never disabled can fire again.
# CARRIED ON THE EXISTING ERROR CHANNEL, deliberately: a non-empty `error` is already
# what makes complete(ok=not error) record a failure and what the CLI and the Harness
# detail pane show. No new settlement machinery, no notification/replay work. A real
# failure keeps its own message; only a would-be success gains one.
test: tests/test_scheduled_tasks.py::test_a_refused_result_stamp_cannot_complete_the_run_ok
- id: HFR-265
name: the deleted-Agent fallback has a type, so a fault cannot spend the route
status: covered
kind: safety
layer: contract
backend: shared
# _rebind_create_once_session tries the reclaim snapshot's settings first and falls
# back to a reset attempt that degrades to scope defaults. The fallback exists for
# exactly two facts -- the snapshot's Agent was deleted, or disabled (HFR-243) -- and
# it decided that from a BROAD `except Exception`, which cannot tell a settled catalog
# fact from SQLite contention, a migration failure or a filesystem error. On any of
# those the reset attempt then SUCCEEDED: _persist_task_session_id wrote the reset
# route, agent_name was dropped, binding_follows_session was stamped, and the task
# PERMANENTLY lost the Agent and model the snapshot was holding for it -- under a
# notice claiming the settings "could not be recovered". A transient fault became
# data loss. Same shape as the forbidden broad OperationalError retry: a catch wide
# enough to convert an infrastructure fault into silence.
# FIX: a typed contract. VibeAgentStore.require / require_enabled raise
# AgentUnavailableError(reason='missing'|'disabled'), and _reserve_runtime_session
# raises it with reason='no_default' for the absent default Agent; the fallback
# catches THAT and nothing else. Operational failures propagate, with the
# definition's route, lifecycle and durable metadata untouched and NO fallback
# reservation -- the run fails through _execute_claimed_request's existing handler and
# the next fire re-resolves from the stored row. AgentUnavailableError subclasses
# ValueError and keeps the old messages, so every existing `except ValueError` caller
# (CLI, UI server, controller route resolution) is unchanged, and HFR-243's
# missing-Agent fallback half stays green.
# The typed contract itself:
# tests/test_scheduled_tasks.py::test_agent_resolution_types_the_deleted_or_disabled_condition
test: tests/test_scheduled_tasks.py::test_rebind_propagates_an_operational_fault_instead_of_resetting_the_route
- id: HFR-266
name: a refused recovery record must not notify a transition it cannot dedup
status: covered
kind: reliability
layer: contract
backend: shared
# Found by the sweep HFR-263/264 prompted: the same question asked of every guarded
# write this PR added. _emit_binding_change promises "once per binding transition,
# never once per fire", and the ONLY thing that makes it once is the durable
# metadata.binding_recovery marker it writes first. That write is guarded (HFR-261)
# and refuses when the definition was reclaimed, repointed or removed in the window --
# and its False was ignored, so the notice went out with nothing behind it: a daily
# cron re-notifies every day, about a recovery the stored definition no longer
# reflects. The notification is now conditional on the marker landing.
# THE SWEEP'S OTHER ANSWERS, checked and NOT defects:
# * archive_session's `reclaimed` tally is taken BEFORE its reclaim, so it looks like
# the same shape -- but archive_session runs entirely inside one engine.begin() and
# takes the write lock at its first UPDATE, before both the count and the reclaim's
# read. Its reclaim cannot refuse, so the tally cannot diverge. Left alone.
# * /new's ledger already counts only landed writes (HFR-257), which is what
# "N tasks paused" reports.
# * vibe task/watch update and pause/resume raise DefinitionWriteConflict -> exit 1
# (HFR-261); _pause_task swallows it deliberately and documentedly (the teardown
# already applied the state it was going to write).
# CORRECTED BY HFR-268: this round also credited _persist_task_session_id's swallow
# as deliberate, on the strength of its own comment ("the rebind stands for one
# fire"). That was checking the return-value handling, not the ORDERING -- the fire
# goes on to dispatch a real turn on the unpersisted rebind. See HFR-268.
# * modules/agents/base.py's `bound or reserved_id` substitution after a refused
# by-id bind is pre-existing and deliberate: the reserved row is the publish target
# for the open Chat, not a claim that the native id was recorded. Not this PR's.
test: tests/test_scheduled_tasks.py::test_a_refused_recovery_record_does_not_notify_a_transition_it_cannot_dedup
- id: HFR-267
name: a watch cycle hook must be enqueued after its guarded stamp, never before
status: covered
kind: safety
layer: contract
backend: shared
# THE QUESTION THIS ROUND CHANGED. HFR-263..266 asked "does the caller respect the
# guard's answer?" and closed every site where it did not. That is not sufficient.
# Here the caller DID respect it -- and the side effect had already escaped.
# All four hook-enqueueing branches of _run_watch (success, per-cycle timeout,
# terminal failure, lifetime expiry) ran:
# self._enqueue_hook(...) # durable, unrecallable
# if not self._watch_store_call(..., guarded=True):
# return # refusal, too late
# enqueue_hook_send writes a request row a SEPARATE drain loop claims and executes,
# so `return` after the refusal unqueues nothing. When /new, an archive or a
# concurrent edit reclaims the watch mid-cycle, the guard correctly refuses the
# result stamp and the prompt is still delivered into the session the teardown
# deleted, for a definition the database has torn down -- after /new told the user
# "1 watch paused". A guard only means something when it runs BEFORE the effect it
# authorises. _stop_watch_for_missing_cwd already had that order; the four branches
# now match it, and _enqueue_hook carries the invariant in its docstring.
# Driven through the real _run_watch, with the real reclaim committed from a second
# connection inside the RESULT stamp's write window (occurrence-selected, so the
# start stamp is accepted first and the cycle genuinely ran). Each branch also has a
# control case proving it DOES deliver its own hook when the stamp lands, so the
# refusal cases cannot pass by never reaching the branch.
test: tests/test_watches.py::test_run_watch_enqueues_no_hook_when_the_result_stamp_is_refused
- id: HFR-268
name: a refused rebind must not dispatch the turn it was reserved for
status: covered
kind: safety
layer: contract
backend: shared
# The ordering sweep HFR-267 prompted, applied to the task twin. Same class, one
# step subtler: the guard IS called first here and its answer is dropped rather than
# never requested. _persist_task_session_id swallowed DefinitionWriteConflict and
# returned None, so _recover_pinned_session_binding still reported action="rebound"
# with a new_session_id, and _execute_task dispatched a REAL agent turn -- prompt run,
# reply posted to the user's channel -- against a session whose binding the store had
# just refused to record. HFR-266's own notice went out too, saying "rebound to a new
# agent session X ... preserved" for a rebind that was never stored, because
# record_binding_recovery recomputes its expectation from the post-teardown mirror and
# so lands. The refusal also covers the soft-delete shape (expect.deleted_at is None),
# which is why "the rebind stands for THIS fire only" was not a safe reading of it.
# The persist now reports, and a refusal returns action="reclaimed" with no
# new_session_id -- the field _execute_task reads to decide whether to fire -- so the
# turn cannot run and both the durable error and the notice say what happened.
# RESIDUE, stated rather than hidden: the replacement session row is reserved before
# the guarded write, because the write needs the id it produces. A refusal therefore
# leaves one unreferenced background session row, the same residue create_per_run
# leaves by design. No user-visible effect escapes; the row does.
test: tests/test_scheduled_tasks.py::test_execute_task_does_not_dispatch_when_the_rebind_persist_is_refused
- id: HFR-269
name: >-
a guarded stamp and the outbox row it authorises must be one transaction: no
teardown commits between them, and a failed outbox write retires nothing
status: covered
kind: safety
layer: contract
backend: shared
# THE QUESTION THIS ROUND CHANGED AGAIN. HFR-263..266 asked "does the caller respect
# the guard's answer?"; HFR-267 asked "does the guard run before the effect?". Both
# are true here and the guard still fails, because TWO COMMITS ARE NOT ONE DECISION:
# self.store.mark_cycle_result(...) # transaction 1, COMMITS
# self.request_store.enqueue_hook_send(...) # transaction 2, COMMITS
# A /new reclaim or an archive from another connection commits in the GAP between
# those commits. The stamp is accepted -- it won its compare-and-set fairly, against
# the state that existed when it ran -- and the hook is queued afterwards anyway:
# a durable request row the drain loop delivers into a session the teardown deleted,
# under a definition it paused or soft-deleted, after the user was told so. Nothing
# is refused, because by then there is nothing left to refuse. HFR-267 moved the race
# window; it could not close it.
# THE INVERSE HFR-267 INTRODUCED: a fault between the two commits (full disk, locked
# database) left a once/terminal watch durably DISABLED with its completion hook
# LOST -- the definition says "finished", the user was never told, nothing runs it
# again. One failure traded for another.
# STEP 1, THE FACT THAT DECIDED THE FIX: run_definitions (the definition) and
# agent_runs (the outbox) are two tables in ONE SQLite database. Both stores default
# to paths.get_sqlite_state_path() -- ManagedWatchStore._sqlite and
# TaskExecutionStore._sqlite are separate SQLiteBackgroundTaskStore instances over
# the same file -- so one transaction is available and is the honest fix, not
# claim-time validation. Both stores also have FILE backends (a JSON file of watches,
# a directory of run JSON files), used only by tests and legacy state; those cannot
# share a transaction, and they also have no compare-and-set at all
# (ManagedWatchStore._write_watch returns True unconditionally without SQLite), so
# there is no guard there for a teardown to outrun. _shared_run_ledger_backend states
# that choice per configuration instead of assuming it.
# FIX: upsert_watch_with_queued_run commits the guarded run_definitions UPDATE and
# the agent_runs INSERT on one connection, guard first, and _commit_cycle_result is
# the single idiom all five result-stamp sites in _run_watch use (success, per-cycle
# timeout, terminal failure, lifetime expiry, missing cwd). A refusal or an exception
# rolls back BOTH, which removes the inverse instead of reversing it.
# THE SEPARATE-TRANSACTIONS SWEEP, and why the rest are not this defect:
# * mark_cycle_start -> spawning the waiter subprocess, and _persist_task_session_id /
# record_binding_recovery -> dispatching a turn or sending a notice: the authorised
# effect is a process or a network send, so no transaction can contain it. Ordering
# (HFR-267/268) plus a guarded terminal stamp is the whole available guarantee.
# * mark_task_result -> the run-ledger settlement is REPORTING of an effect that
# already happened, not an effect the stamp authorises; HFR-264 made it report the
# refusal.
# * _run_task's enqueue and enqueue_session_callback are authorised by a READ, not by
# a guarded write, and both dedup on re-entry (pending-run scan, find_callback_run).
# * delete_agent_sessions/archive_session run the reclaim inside the caller's
# transaction already; reserve_forked_session is one begin() for reads and insert;
# settle_run_terminal/claim_pending_run publish their events after the commit.
# * _drain_callbacks writes the callback run and THEN marks it sent -- effect before
# marker -- but the marker is not a guard and the enqueue is idempotent through
# find_callback_run.
# Driven through the real _run_watch over the real agent_runs ledger, with the real
# archive reclaim attempted from a second connection at the instant the outbox INSERT
# is about to run and PRAGMA busy_timeout = 0, so "could a teardown commit in the
# gap?" is answered by the database rather than by a sleep.
# ONE ID, TWO FAILURE HALVES. The schema carries one path, so the teardown-in-the-gap
# half stays the primary test. The INVERSE half is the same defect and the same id,
# tested separately because it fails for the opposite reason -- no teardown, no race,
# just a fault on the second commit, which left the watch disabled and retired with
# the hook that reports it gone (a once watch is unrecoverable there). Sharing the
# transaction rolls both back together, so the watch stays enabled and its completion
# is still owed; the fault is injected at the INSERT itself, on whichever connection
# the code under test writes the row through:
# tests/test_watches.py::test_a_failed_outbox_write_does_not_retire_the_watch_with_its_hook_lost
# SUCCESSFUL CONTROL PER TERMINAL BRANCH, so the contract cannot pass by refusing
# everything: with no teardown and no injected fault, the transaction must COMMIT and
# carry both halves -- the branch's own result transition read back from the
# definition, and exactly one outbox row with that branch's own prompt text. All five
# hook-producing branches, and every parametrized test here shares the same
# _HOOK_BRANCHES table so a new branch cannot be added without its control:
# tests/test_watches.py::test_the_atomic_stamp_and_its_hook_both_land_when_nothing_races_them
test: tests/test_watches.py::test_no_teardown_can_commit_between_the_result_stamp_and_its_hook
- id: HFR-270
name: a refused rebind must reclaim the session and workspace it reserved
status: covered
kind: safety
layer: contract
backend: shared
# ONE STEP PAST HFR-268, and the reason a refusal is not finished when it stops the
# effect. _rebind_create_once_session COMMITS the replacement session before
# _persist_task_session_id is called at all -- a different store, a different
# transaction, and for a standalone placement a mkdir of a Show Page workspace too.
# HFR-268 correctly stopped the dispatch and left that row behind: nothing points at
# it (the definition still names the session the teardown cleared and the notice says
# "not rebound"), so it is a live, unreferenced background session that nothing will
# ever run, list or delete, plus its workspace, and one more of each for every fire
# that loses the same race.
# ATOMIC vs EXPLICIT RECLAIM, and why reclaim: the reservation and the write that
# adopts it go through two different services with two different engines, and the
# reservation's mkdir is a side effect no SQL transaction can roll back. One atomic
# operation would mean threading a single connection through both stores and STILL
# leaving the directory. Naming the one row this call created and giving it back is
# smaller, is exact about which row it may touch, and does not depend on the two
# stores continuing to live in one database.
# NARROW BY CONSTRUCTION: release_reserved_agent_session names the row by the id the
# reservation returned, requires native_session_id still empty and no run_definitions
# row pointing at it, and re-asserts both IN the delete (_delete_agent_session_rows
# re-runs the id query with the write lock held). The workspace is removed only when
# it IS show/<session_id> -- the directory that reservation created and nothing else
# can own -- so a scoped reservation's inherited Scope workdir is never touched.
# Both placements are driven through the real _execute_task with a concurrent winner
# reserved through the SAME branch, so "delete the unreferenced background sessions"
# would fail the test:
test: tests/test_scheduled_tasks.py::test_a_refused_rebind_reclaims_the_session_and_workspace_it_reserved
- id: HFR-271
name: a write that raises must roll the in-process mirror back with the transaction
status: covered
kind: safety
layer: contract
backend: shared
# THE RULE THE REST OF THIS ROUND CAME FROM: a rollback is not proven by re-reading
# the durable row. It is proven when the durable row AND the live in-process state
# agree. HFR-269's inverse test read the rolled-back watch through a freshly built
# ManagedWatchStore -- ordinarily good hygiene, and here exactly what hid the defect,
# because the half that stayed wrong was the service still running.
# ManagedWatchStore is a write-through cache: mark_cycle_result mutates the cached
# ManagedWatch (enabled=False, retired_at, last_finished_at, last_exit_code) and THEN
# calls _write_watch. _write_watch reloaded only when the compare-and-set RETURNED
# False, never when the write RAISED, and _watch_store_call swallows the exception
# into the store fuse, so nothing downstream corrected it. Reproduced on the real
# _run_watch: durable row enabled=True/retired=None, service.store enabled=False/
# retired_at=<ts>/exit_code=0.
# WHO READS THE STALE MIRROR: reconcile_watches picks which watches keep running out
# of that dict, vibe watch list renders it, and _read_state derives the NEXT
# compare-and-set's expectation from it, so one stale entry also mis-guards the next
# write. FIX: every way the write can fail to land reloads, at the one choke point,
# and if the reload itself fails the entry is dropped rather than kept (absent reads
# as "gone" and stops the watch; stale keeps it running on state that never existed).
# No broad retry. Parametrized over every guarded writer that goes through the choke
# point, with the fault injected at the run_definitions statement itself rather than
# at one caller's second write:
# tests/test_watches.py::test_a_definition_write_that_raises_leaves_no_live_mirror_ahead_of_the_database
# The HFR-269 inverse test now asserts both halves as well, which is what makes it
# able to see this class at all:
test: tests/test_watches.py::test_a_failed_outbox_write_does_not_retire_the_watch_with_its_hook_lost
- id: HFR-272
name: the task store's mirror must roll back with a raised write too
status: covered
kind: safety
layer: contract
backend: shared
# HFR-271 applied to the sibling store rather than waiting for a second report.
# ScheduledTaskStore is the same write-through cache with the same choke point:
# set_enabled / update_task / record_binding_recovery / mark_task_result each mutate
# the cached ScheduledTask and hand the whole row to _write_task, and _write_task
# reloaded only on the False return. reconcile_jobs schedules from that dict and
# _read_state derives the next guard's expectation from it, so a raised write left
# the scheduler acting on an edit the database rolled back. Same fix, same shape,
# same drop-on-failed-reload fallback:
test: tests/test_scheduled_tasks.py::test_a_definition_write_that_raises_leaves_no_live_task_mirror_ahead_of_the_database
- id: HFR-273
name: a teardown that rolls back must not report definitions as reclaimed
status: covered
kind: safety
layer: contract
backend: shared
# The same rule applied to the one piece of teardown state that is NOT in the
# database. reclaim_bound_definitions appends to the teardown ledger as it pauses
# each definition, and the ledger is what /new counts for "N tasks paused". It was
# append-only: a transaction that reclaimed and then ABORTED -- a locked database on
# a later statement or on the COMMIT, the class of fault this whole PR is about --
# rolled the pause back and left the entry. handle_new wraps clear_session_base in
# except Exception: logger.debug(...) and reports the ledger anyway, so the user is
# told a task was paused while it is still enabled, still bound to the session they
# cleared, and still firing into it.
# FIX: reclaim_ledger_transaction wraps each transaction that can reclaim, OUTSIDE
# begin() so the truncation runs after the rollback, and discards only entries this
# transaction added. Deliberately NOT the same case as a reclaim whose own DELETE was
# refused -- that reclaim really did commit, and _delete_agent_session_rows documents
# why keeping it is the recoverable half:
test: tests/test_session_archive.py::test_a_teardown_that_rolls_back_reports_nothing_as_reclaimed
- id: HFR-274
name: the live session map must keep what the teardown SQL deliberately kept
status: covered
kind: safety
layer: contract
backend: shared
# The consuming half of HFR-240/241, found the same way. clear_session_base
# hand-pruned state.session_mappings by the prefix rule the SQL used to use --
# key == base or key.startswith(base + ":") -- which stopped being the same rule when
# delete_agent_sessions grew its include_superseded=False guard. A superseded row is
# anchored <base>:superseded:<id>, so the database KEEPS it (its native id is
# write-once and its transcript is not recoverable) while the prefix scan deleted the
# only pointer this process had to it, and save_state made that permanent: the guard
# preserved a row nothing can reach.
# FIX: re-read the map from the service, exactly as clear_agent_sessions and
# remove_agent_session already do, so the local half cannot disagree with a delete
# whose rules it no longer reimplements. Asserted on the live SessionsStore inside
# the same /new run that reads the durable rows:
test: tests/test_command_handler_user_names.py::NewCommandStorageIntegrationTests::test_new_keeps_a_superseded_session_and_its_definitions_but_clears_the_live_one
- id: HFR-275
name: the create and delete entry points must roll their mirror back too
status: covered
kind: safety
layer: contract
backend: shared
# The last two writers HFR-271/272 did not reach, found by sweeping BOTH definition
# stores for the mirror shape rather than for the guarded-write shape: an in-memory
# entry mutated BEFORE the persistence call, with no restore when it fails.
# upsert_watch / upsert_task are the create-and-adopt entry points and take no
# ``expect`` (their payload is not a re-read), so they never went through the guarded
# choke point. They are also the only writers that can add an id the database has
# NEVER seen, which is the worse direction: the caller is told the definition could
# not be created, while reconcile_watches / reconcile_jobs pick it out of exactly
# that dict and start running it -- spawning the waiter command, or firing the prompt
# into a channel -- with no durable row to stop it and nothing that will reload it
# away.
# remove_watch / remove_task are the same shape in the conservative direction: the
# entry is dropped before the soft delete, so a failure stops a definition the
# database still has. Silently, and NOT self-healing -- the row is unchanged, so
# maybe_reload sees no external write and it stays stopped until a restart.
# Both now reload through the same _reload_after_lost_write helper, which is correct
# for a create (the id is simply absent from the database) and for an adopt or a
# delete (the previous row comes back).
test: tests/test_watches.py::test_a_failed_create_leaves_no_phantom_watch_in_the_live_store
- id: HFR-276
name: a reclaim that fails must record the orphan, not report a completed reclaim
status: covered
kind: safety
layer: contract
backend: shared
# One layer INSIDE the HFR-270 fix, and the same class as HFR-263..266: the caller
# ignored the guard's answer. _release_reserved_session is deliberately never fatal
# (it runs on a path already reporting a failure to the user), so it catches every
# exception and returns False; _recover_pinned_session_binding dropped that boolean
# and emitted SessionBindingChange(action="reclaimed") regardless. A locked database
# or an I/O fault during the release therefore left exactly the orphan HFR-270
# promises cannot remain -- a live, unreferenced background session and its workspace
# -- told the user it had been given back, and lost the only handle on it: the
# reserved id is random and is never written to the definition, so the next fire that
# loses the same race reserved and leaked another one, untracked.
# FIX, both clauses. The boolean is consumed and the losing branch emits a distinct
# action="orphaned" whose detail names the session that is still live; and the id is
# recorded durably on the definition that reserved it
# (metadata.orphaned_reservations in run_definitions.metadata_json, the same row the
# binding-recovery record already uses), so a reservation may accumulate only in a
# TRACKED, retryable form. That record is itself written through the guarded full-row
# writer, so its own False is consumed too: the notice then says the id could not be
# recorded either. The next fire of the same definition retries the release from the
# record (_retry_orphaned_reservations) and drops the entries it resolves, keeping the
# ones whose release failed again. release_reserved_agent_session keeps its exact-id /
# empty-native / unreferenced predicates unchanged, so no retry can take a concurrent
# winner. Asserted on the live store mirror AND the durable row:
# tests/test_scheduled_tasks.py::test_a_release_that_fails_records_the_orphan_instead_of_reporting_a_reclaim
# THE SHARED-FAULT HALF, which the first regression could not see because it raised
# from a monkeypatched release while leaving SQLite healthy: the record is written
# through the SAME database whose fault just refused the release, so the stated
# production cases (locked database, I/O fault) refuse both writes for one reason --
# and _write_task RAISES on a faulted write (HFR-272), which the first fix's
# boolean-only handling let unwind past the notice branch entirely. FIX, two parts.
# The raise and the refusal are consumed as one "not recorded" branch in
# _track_orphaned_reservation and _retry_orphaned_reservations; and the durable
# handle no longer depends on the record at all: the recovery rebind stamps the
# reserving definition's id into the reservation row's own metadata
# (reserved_by_harness_definition), inside the reservation's INSERT transaction, so
# if the row committed the handle committed with it. The next fire sweeps rows
# stamped with this definition's id that are still empty-native and unreferenced
# (the HFR-279 classification facts, one consistent read) and releases them, so
# recovery survives a restart with nothing in memory. The stamp is written ONLY by
# the create_once recovery rebind, whose fires serialize on the pinned session's
# lock -- a create_per_run reservation is legitimately unbound and unreferenced
# between reserve and dispatch, and its fires can overlap, so it must never be
# inside the sweep's definition of an orphan. The regression takes a REAL
# BEGIN IMMEDIATE on the database file across the release and the record, asserts
# the record did NOT land, then recovers through freshly constructed stores (the
# restart shape) and finally proves a stamped-AND-adopted rebound session is never
# swept:
# tests/test_scheduled_tasks.py::test_a_locked_database_that_refuses_release_and_record_still_recovers_the_orphan
test: tests/test_scheduled_tasks.py::test_a_release_that_fails_records_the_orphan_instead_of_reporting_a_reclaim
- id: HFR-277
name: a mirror dropped by a failed write reloads without an unrelated commit
status: covered
kind: safety
layer: contract
backend: shared
# The consuming end of HFR-271/272's OWN recovery path, and the same class as
# HFR-263..266 one layer further in: the fix trusted a mechanism that cannot see what
# it needs to see. _reload_after_lost_write drops the entry when the guarded write
# fails AND the immediate recovery load fails too -- correct, an absent definition is
# safer to act on than a mutated one the database never accepted -- and documented
# that maybe_reload restores it "once the database is reachable again". It did not.
# maybe_reload consulted only SqliteInvalidationProbe, i.e. PRAGMA data_version,
# which moves when another connection COMMITS; the failed write ROLLED BACK, so
# data_version was unchanged and every later tick answered "nothing changed". The
# definition stayed durably enabled in SQLite and invisible in-process until a
# restart or an unrelated commit happened to bump the counter -- and reconcile_jobs /
# reconcile_watches choose what to schedule and what keeps running out of exactly
# those dicts, so a cron task stopped firing and a watch stopped being reconciled
# while their rows still said enabled.
# FIX, both definition stores: an in-process _reload_required flag set where the
# entry is dropped, which makes the NEXT maybe_reload load unconditionally, and is
# cleared only by the load that repairs the mirror (so a reload that fails again is
# retried on the tick after). In-process rather than a database column on purpose: it
# describes THIS mirror, not the data; a restart reloads from SQLite anyway; and
# persisting it would mean writing to the database that was just proven unwritable.
# Both tests end the fault the way a transient fault ends -- by going away, writing
# nothing -- and a witness probe on its own connection asserts data_version is
# UNCHANGED at that instant, so recovering because some other writer committed cannot
# be mistaken for recovering because the store remembered. Asserted on the live
# mirror (get / list) AND the durable row:
# tests/test_watches.py::test_a_dropped_watch_mirror_recovers_with_no_unrelated_commit_to_wake_it
test: tests/test_scheduled_tasks.py::test_a_dropped_task_mirror_recovers_with_no_unrelated_commit_to_wake_it
- id: HFR-278
name: releasing a reservation cannot damage a definition that adopted it
status: covered
kind: safety
layer: contract
backend: shared
# One layer inside our own HFR-270 fix, and the same window HFR-257..260 closed
# statement by statement -- reached this time through the reservation cleanup HFR-270
# added. release_reserved_agent_session -> _delete_agent_session_rows runs its
# id_query first and reclaim_bound_definitions second, and the id read reserves
# nothing (pysqlite opens no transaction for a bare SELECT). An adoption committing
# between the two left the reclaim reading the WINNER's definition: it paused it,
# stamped its last_error with the release's reason, and overwrote its
# session_settings_snapshot -- which a later create_once rebind reads. The final
# DELETE then re-evaluated NOT EXISTS and correctly PRESERVED the session, which is
# why nothing surfaced: the release returned False, logged "not releasing", and the
# winner was disabled anyway. The reclaim is deliberately never rolled back
# (_delete_agent_session_rows documents why under WAL), so nothing corrected it.
# FIX: reserve_write_lock(conn) -- the HFR-262 precedent -- at the top of the
# release's transaction, BEFORE the read the decision rests on. Nothing has been read
# on that connection yet, so it is the cheap BEGIN IMMEDIATE spelling, which takes
# the write lock and the read snapshot in one statement. The adoption can then only
# land before the release looks (the exact-id / native-empty / unreferenced
# predicates see it and the release backs off, all three kept unchanged) or after the
# release has committed. Re-asserting the predicates in the DELETE protects the ROW;
# the damage was to a definition, which is why order and not detection is the fix.
# Asserted on the FULL row the winner owns (the HFR-251 lesson): its Session row, its
# Show workspace on disk, its route/anchor, its pins and explicit override markers,
# its definition's enabled state, pause reason, settings snapshot, every timestamp,
# and the teardown ledger that must credit nothing. The mechanism itself is pinned
# separately, the two ways the HFR-262 tests do it (reservation ahead of the read in
# the statement sequence, and a zero-patience competing writer REFUSED at it):
# tests/test_sqlite_sessions_store.py::test_releasing_a_reservation_holds_the_write_lock_at_its_decision_read
test: tests/test_sqlite_sessions_store.py::test_releasing_a_reservation_cannot_damage_a_definition_that_adopted_it
- id: HFR-279
name: an adopted reservation is dropped from the retry record without being touched
status: covered
kind: safety
layer: contract
backend: shared
# One layer inside HFR-276's own fix, found by the exact-head Codex review of that
# fix. release_reserved_agent_session answers False for three different facts --
# the row is gone, the row was adopted, the release faulted -- and the retry's
# absence-only probe (_reserved_session_is_gone) resolved only the first. A tracked
# reservation that was since adopted (a native session dispatched into it, or a
# run_definitions row pointing at it) is not absent and can never be released, so
# its entry stayed on metadata.orphaned_reservations forever and every later fire
# of the original definition re-took SQLite's write lock (the release's
# BEGIN IMMEDIATE) to retry a cleanup that cannot succeed -- the loser's
# bookkeeping taxing the winner's row on every fire, indefinitely.
# FIX: an explicit classification (classify_reserved_agent_session) that runs
# BEFORE any release attempt and reads both adoption facts -- native binding and
# definition reference -- in ONE SQL statement, so the verdict is a state the row
# actually was in. Four verdicts, four actions: absent -> resolved and dropped;
# adopted -> resolved and dropped WITHOUT being read under the write lock, let
# alone mutated; still empty-native and unreferenced -> a genuine orphan, released
# through the unchanged guarded release (whose predicates re-assert both facts
# under the write lock, so a classification that raced an adoption destroys
# nothing -- the entry stays and the next fire classifies it as adopted); a
# classification that cannot read -> the entry is KEPT, never guessed away. The
# regression adopts one tracked reservation each way, asserts the winners' FULL
# rows (route/anchor, workdir, pins and metadata markers, every timestamp) and the
# adopting definition's full row are byte-identical across the retry, that no
# release was attempted against either winner or the absent id, and that the
# record dropped the resolved entries durably and in the live mirror. The fault
# verdict is pinned separately:
# tests/test_scheduled_tasks.py::test_a_retry_classification_that_cannot_read_keeps_the_entry
test: tests/test_scheduled_tasks.py::test_an_adopted_reservation_is_dropped_from_the_retry_record_without_being_touched
- id: HFR-280
name: >-
a Workbench PATCH and a concurrent archive of the same session serialize: the archive
waits for the PATCH, so a rename or re-route never lands on an already-archived row
status: covered
kind: safety
layer: contract
backend: shared
# The FOURTH session writer with the HFR-251/253/254 shape, and the last public one:
# workbench_sessions_service.update_session, the service behind PATCH /api/sessions/
# <id>. RED, unlike HFR-252's proofs -- its archive guard was ONLY a read-then-write
# pre-check at the top of the function, and its single UPDATE matched on id alone
# (plus the backend-lock predicate, on the backend-changing path). That read reserves
# nothing, so a stale tab's rename or re-route landed on an already-archived row.
# The production window is not hypothetical: archive_session cannot cancel an
# in-flight chat turn inside its transaction, so the DELETE route commits the archive
# FIRST and cancels best-effort afterwards -- and the route's own is_session_archived
# pre-flight runs on a separate connection, widening the same window further.
# FIX: status != 'archived' on the UPDATE (unconditional, so every write this
# function makes carries it), the pre-check demoted in comment to what it always was
# -- a fast path -- and the rowcount-0 branch re-reading the row to say WHICH
# predicate refused.
# PRECEDENCE IS PART OF THE INVARIANT, not a detail: two predicates on one statement
# make rowcount 0 ambiguous, and the branch previously belonged to the backend lock.
# Reporting the RETRYABLE backend_locked for a TERMINAL archived row is the exact
# defect this PR's round 5d fixed one layer out in the route, so archive wins here
# whenever both apply. Second test, with one commit carrying both the finishing
# turn's native bind (which locks the backend) and the archive:
# tests/test_sqlite_sessions_store.py::test_update_session_archive_race_outranks_the_backend_lock
# Both fail against the pre-fix service: the rename lands silently (DID NOT RAISE),
# the re-route answers SessionBackendLockedError. Same _commit_competing_bind_after
# harness and the same real _archive_write payload as HFR-252.
# Later the writer reservation removed the read/archive/write window itself: the
# PATCH and the archive now serialize, so there is no race left to refuse. Both
# halves are proved by test_update_session_serializes_rename_before_archive and
# test_update_session_serializes_route_change_before_archive.
test:
- tests/test_sqlite_sessions_store.py::test_update_session_serializes_rename_before_archive
- tests/test_sqlite_sessions_store.py::test_update_session_serializes_route_change_before_archive
- id: HFR-281
name: >-
a completion hook queued inside a stamp names an Agent the catalog still has
status: covered
kind: recovery
layer: scenario
backend: shared
# The watch half of SCT-030 (tests/scenarios/harness_command_task). HFR-269 made the
# stamp and the hook it authorises ONE transaction; what it did not change is WHEN the
# hook row is composed. ``_hook_request`` builds it from ``watch.agent_name`` as the
# cycle ends, and an Agent rename committed before the mirror absorbs the stamp
# rewrites the definition and every ACTIVE run -- but a row still being composed is
# neither, so the hook was inserted naming an Agent nobody can resolve and the only
# report a ``once`` watch ever produces could never be claimed.
# FIX (shared with the scheduled lane, since both writers had it): resolve the Agent
# from the definition values written in the SAME transaction and pin the row to the
# catalog's durable agent id, under the write lock the rename itself takes.
# A rename the mirror has NOT absorbed needs nothing: it bumps the agent binding
# revision and the compare-and-set refuses both halves.
test: tests/test_watches.py::test_a_hook_queued_after_a_rename_names_an_agent_that_still_exists
- id: HFR-282
name: scheduled task mirror mutations serialize with reloads through commit
status: covered
kind: safety
layer: contract
backend: shared
# A scheduler result stamp reads, mutates, and persists one full definition row.
# Reloading the mirror inside that window could replace the object being stamped,
# leaving the live mirror enabled after the durable one-shot task was disabled.
# Every mirror mutation now holds the same re-entrant lock as reload and snapshot.
test: tests/test_scheduled_tasks.py::test_hfr_282_task_reload_waits_for_result_stamp_mirror_commit
- id: HFR-283
name: session archive wakes cancellation processing after its Run commit
status: covered
kind: recovery
layer: contract
backend: shared
# Archive flags active Runs with raw SQL. The post-commit UI path must publish the
# ordinary runs.updated hint so STALE_RUNS promptly propagates command cancellation;
# a lost hint remains recoverable by periodic reconciliation.
test: tests/test_ui_server_fastapi.py::test_hfr_283_archive_run_cancellations_wake_runtime_consumers
- id: HFR-284
name: controller delivery recovery joins before final Turn owner release
status: covered
kind: safety
layer: contract
backend: shared
# Quiesce rejects new scans but does not join a worker already admitted. Controller-
# generation lanes are invalidated and joined while the executor remains available,
# before ScheduledTaskService takes its final durable owner snapshot.
test: tests/test_controller_dispatch_loop.py::test_hfr_284_runtime_work_stack_joins_controller_lanes_before_service_teardown
- id: HFR-285
name: deferred Activity recovery scans bounded raw pages with indexed eligibility
status: covered
kind: liveness
layer: contract
backend: shared
# A page limit bounds inspected runtime rows, not only due outputs. Deferred grace
# entries advance the keyset cursor while a per-backend index supplies the earliest
# future deadline without walking every recovered runtime under the Registry lock.
test: tests/test_session_activities.py::test_hfr_285_deferred_runtime_scan_bounds_raw_rows_and_indexes_deadline
- id: HFR-286
name: Run cancellation hints bypass stale sweep eligibility
status: covered
kind: recovery
layer: contract
backend: shared
# runs.updated always admits the cancellation observer as its own item. The periodic
# stale sweep keeps its configured cadence and cannot delay an in-flight command Stop.
test: tests/test_scheduled_tasks.py::test_hfr_286_cancellation_wake_is_not_gated_by_stale_sweep_cadence
- id: HFR-287
name: new-session teardown publishes committed Run cancellations
status: covered
kind: recovery
layer: contract
backend: shared
# Every SessionMappingStore teardown uses the Run event transaction. Raw SQL changes
# remain invisible before commit and wake cancellation/callback consumers afterward.
test: tests/test_session_archive.py::test_hfr_287_new_session_teardown_publishes_run_updates_after_commit
- id: HFR-288
name: expired partition backoff preserves forward scan before retry rewind
status: covered
kind: liveness
layer: contract
backend: shared
# An expired bounded retry frees admission capacity without rewinding over the same
# unavailable prefix. The lane reaches later partitions, then coalesces expired retry
# work into one tail-boundary rewind while the durable store retains the inventory.
test: tests/test_runtime_work_supervisor.py::test_hfr_288_expired_backoff_preserves_forward_scan_before_retry
- id: HFR-430
name: an Agent Run send-now steers its own content without promoting the FIFO head
status: covered
kind: recovery
layer: contract
backend: shared
# The content-bearing legacy send-now alias normalizes to durable P1 steering.
# It steers that exact content into an active native Turn without Stop and does
# not promote an older P3 queue head. Refused or stale steering falls back to P3.
test: tests/test_internal_server.py::test_agent_run_send_now_steers_its_content_without_promoting_fifo
- id: HFR-431
name: a terminal Turn racing a successful Stop receipt remains a successful cancel
status: covered
kind: recovery
layer: contract
backend: shared
# A backend may emit its terminal result synchronously while handling Stop.
# The exact durable Turn can therefore settle before the interrupt owner
# records its accepted receipt. That terminal snapshot is stronger evidence
# than the late receipt and must clear stale UI working state, not surface a
# false transport failure banner. A genuinely unresolved Stop remains 409.
test: tests/test_internal_server.py::test_cancel_accepts_terminal_settlement_that_races_the_stop_receipt
- id: HFR-432
name: a timed-out OpenCode Turn releases its Session FIFO and the shared provider lane
status: covered
kind: recovery
layer: scenario
backend: opencode
# OpenCode may accept a prompt while its provider runtime retries forever. The
# accepted Turn has a bounded wall-clock owner: expiry aborts the exact native
# session, emits one failed terminal result, admits the same-Session successor,
# and lets a different OpenCode Agent waiting on that shared provider continue.
# The timeout never enters the empty successful-result fallback. Since the
# upstream runtime bounds its own retries and surfaces the exhausted error, the
# cap is an explicit opt-in (nonzero config); this scenario exercises the
# opted-in lifecycle only, and the default-disabled deadline has its own unit
# coverage beside the poll loop.
test: tests/test_agent_service.py::test_hfr_432_opencode_timeout_releases_fifo_and_shared_runtime
- id: HFR-434
name: an OpenCode steer at the native terminal boundary stays reconcilable
status: covered
kind: recovery
layer: contract
backend: opencode
# prompt_async returns 204 after persisting the user message, while its worker
# may still be registering the continuation as busy. A transient idle sample
# keeps the exact attempt in reconciliation so it cannot be replayed; later
# native evidence either accepts the attempt or closes it terminally.
test: tests/test_agent_steering.py::test_opencode_keeps_reconciliation_armed_after_post_write_idle
- id: HFR-435
name: Claude input echoes establish steering result ownership
status: covered
kind: recovery
layer: contract
backend: claude
# A transport write only queues input, while Claude may merge several inputs
# into one response. Avibe enables the CLI's replay-user-messages protocol so
# consumed input produces a native top-level UserMessage echo in FIFO order;
# inputs dequeued together share one echo (HFR-487). A Result before the echo
# stays nonterminal; a Result after every echo can settle the shared Turn.
test: tests/test_claude_agent_sessions.py::test_user_echo_allows_one_result_to_own_primary_and_steer
- id: HFR-436
name: Watch waiter health is independent from downstream event processing
status: covered
kind: observability
layer: contract
backend: shared
# A zero-exit waiter remains healthy even when the Agent Run created from its
# event fails. The downstream verdict is exposed as processing_health; retry
# codes are healthy only while an enabled forever waiter can actually retry;
# terminal outcomes stay failing even when their code appears in the retry set.
test: tests/test_harness_health_projection.py::test_watch_health_separates_waiter_from_event_processing
- id: HFR-437
name: one visible Turn failure suppresses every linked Run fallback
status: covered
kind: safety
layer: contract
backend: shared
# The backend failure notification is the Turn's primary user-visible error.
# All Runs accepted by that Turn retain failed audit state without repeating it.
# Local persistence under suppress_delivery is not an acknowledgement, so the
# durable fallback remains eligible to reach a user-visible target.
test: tests/test_harness_failure_visibility.py::test_hfr_437_visible_turn_failure_suppresses_all_linked_run_notices
- id: HFR-438
name: one linked Run reports a missing Turn failure notification
status: covered
kind: recovery
layer: contract
backend: shared
# If primary delivery is not acknowledged, Turn identity elects one fallback
# across definitions and every other linked Run records the shared outcome.
# Canceled or still-deferred participants cannot own notices already owed by a
# settled sibling, and late participants reuse the durable Turn-wide election
# instead of electing again from their subset. When every participant is deferred,
# the first failed settlement propagates its stable ownership to the rest under
# the same reserved SQLite writer transaction.
test: tests/test_harness_failure_visibility.py::test_hfr_438_missing_turn_notification_delivers_one_fallback
- id: HFR-439
name: Turn failure notification evidence reaches every linked Run settlement
status: covered
kind: safety
layer: contract
backend: shared
# Terminal settlement copies the Turn notification identity and delivery proof
# into each owed notice atomically with the failed Run transition. The immutable
# Turn snapshot supplies the initial fallback owner; the locked participant
# settlement validates it against current cancellation and deferral state before
# any Run is written. If an Activity still owns the Run, the same evidence is first
# committed with its deferred terminal intent and survives into the eventual
# transition. Explicit delivery evidence remains authoritative for legacy Harness
# contexts that have no Turn token.
test: tests/test_scheduled_tasks.py::test_hfr_439_turn_failure_metadata_reaches_every_linked_run
- id: HFR-440
name: one sibling callback receipt suppresses the complete Turn fallback
status: covered
kind: safety
layer: contract
backend: shared
# A callback carries the shared terminal Turn result. Callback delivery facts
# are aggregated from one SQLite snapshot across every linked failed Run, so a
# successful sibling callback prevents the elected owner from sending again.
test: tests/test_harness_failure_visibility.py::test_hfr_440_one_sibling_callback_suppresses_the_whole_turn_fallback
- id: HFR-441
name: suppressed local history cannot shadow an outward receipt
status: covered
kind: safety
layer: contract
backend: shared
# suppress_delivery rows carry an explicit marker and are rejected as receipts.
# A later visible fallback sends first, then promotes the stable row under a
# guarded update. Local row ids never enter Run transport receipts, and a
# suppressed callback row is never delivery evidence.
test: tests/test_harness_failure_visibility.py::test_suppressed_history_cannot_shadow_a_later_visible_receipt
- id: HFR-442
name: bare Turn provenance does not enter notification ownership
status: covered
kind: safety
layer: contract
backend: shared
# Direct error results retain their Turn id as execution provenance, but only
# an explicit turn_failure_notification contract admits the Turn fallback lane.
# Definition-level suppression therefore remains active for generic failures.
test: tests/test_harness_failure_visibility.py::test_hfr_442_bare_turn_provenance_does_not_enter_the_fallback_lane
- id: HFR-443
name: deferred callback participant blocks the Turn fallback
status: covered
kind: safety
layer: contract
backend: shared
# Turn membership is read from either an active owed notice or a deferred
# terminal intent. A pending callback on the deferred participant therefore
# blocks an immediately settled sibling from sending the same result.
test: tests/test_harness_failure_visibility.py::test_hfr_443_deferred_sibling_callback_blocks_the_turn_fallback
- id: HFR-444
name: first in-flight waiter health remains unknown
status: covered
kind: observability
layer: contract
backend: shared
# A cycle start is not a waiter outcome. Until a finish, exit code, or error is
# recorded, the first cycle cannot project a healthy verdict.
test: tests/test_harness_failure_visibility.py::test_hfr_444_first_in_flight_waiter_health_remains_unknown
- id: HFR-445
name: suppressed history promotion adopts the visible target Session
status: covered
kind: safety
layer: contract
backend: shared
# The guarded post-send promotion preserves the stable native identity while
# rebinding the Message row from its hidden source Session to the visible target.
test: tests/test_harness_failure_visibility.py::test_visible_send_promotes_the_stable_suppressed_history_row
- id: HFR-446
name: promoted history uses visible delivery order
status: covered
kind: safety
layer: contract
backend: shared
# Promotion stamps delivered_at at the post-send commit point. Transcript
# ordering therefore places the stable row after content that was already
# visible when the hidden copy was originally created.
test: tests/test_harness_failure_visibility.py::test_hfr_446_promoted_receipt_uses_visible_delivery_order
- id: HFR-447
name: Turn fallback owners can persist their notice
status: covered
kind: recovery
layer: contract
backend: shared
# Immediate and deferred owner election use the exact metadata-writability
# predicate used by notice persistence. Malformed legacy rows still settle,
# but a writable participant becomes the stable fallback owner.
test: tests/test_harness_failure_visibility.py::test_hfr_447_fallback_owner_requires_writable_notice_metadata
- id: HFR-448
name: canceled deferred callbacks do not block a Turn fallback
status: covered
kind: recovery
layer: contract
backend: shared
# Turn-wide callback membership includes deferred participants only while
# they remain live. A canceled or cancel-requested parent cannot later deliver
# its callback, so an immediate sibling's fallback is released.
test: tests/test_harness_failure_visibility.py::test_hfr_448_cancel_requested_callback_does_not_block_turn_fallback
- id: HFR-449
name: canceled parents preserve armed callback evidence
status: covered
kind: safety
layer: contract
backend: shared
# Cancellation removes an unarmed parent from Turn callback membership, but
# cannot revoke a child that was already accepted. Pending and delivered child
# outcomes continue to defer or suppress the shared fallback.
test: tests/test_harness_failure_visibility.py::test_hfr_449_canceled_parent_keeps_armed_callback_evidence
- id: HFR-450
name: terminal replay promotes newer Turn delivery evidence
status: covered
kind: recovery
layer: contract
backend: shared
# A duplicate terminal event cannot re-settle the Run, but a later successful
# primary notification is monotonic evidence. It upgrades the existing notice
# without resetting attempts or fallback ownership.
test: tests/test_harness_failure_visibility.py::test_hfr_450_terminal_replay_promotes_new_turn_delivery_evidence
- id: HFR-451
name: Turn callback membership lookup stays bounded
status: covered
kind: performance
layer: contract
backend: shared
# The callback snapshot is bounded by explicit participant ids and the indexed
# Delivery-to-Turn ownership relation. It never searches Run metadata JSON by
# Turn id as history grows.
test: tests/test_harness_failure_visibility.py::test_hfr_451_turn_callback_lookup_uses_bounded_ownership
- id: HFR-452
name: callback children cannot own the Turn fallback
status: covered
kind: safety
layer: contract
backend: shared
# Owner election uses the same suppression predicate as notice persistence, so
# a callback child whose parent already owns a notice cannot silence siblings.
test: tests/test_harness_failure_visibility.py::test_hfr_452_callback_children_cannot_own_a_turn_fallback
- id: HFR-453
name: callback enqueue and parent arming are atomic
status: covered
kind: safety
layer: contract
backend: shared
# SQLite exposes the callback child and its parent marker in one commit. A
# cancellation cannot open an enqueue-to-stamp window for duplicate fallback.
test: tests/test_harness_failure_visibility.py::test_hfr_453_callback_enqueue_arms_the_parent_in_one_transaction
- id: HFR-454
name: delivery evidence follows the routed target platform
status: covered
kind: routing
layer: contract
backend: shared
# A transport-only id acknowledges a real IM target but never a synthetic Avibe
# target, regardless of the source Session platform before delivery_override.
test: tests/test_backend_failure.py::BackendFailureTests::test_hfr_454_delivery_only_ack_uses_the_routed_target_platform
- id: HFR-455
name: Turn fallback excludes same-batch parent suppression
status: covered
kind: safety
layer: contract
backend: shared
# A parent processed before its callback child owns the Turn fallback before
# that new parent notice suppresses the child, independent of lexical Run ids.
test: tests/test_harness_failure_visibility.py::test_hfr_455_turn_owner_excludes_same_batch_parent_suppression
- id: HFR-456
name: late-canceled failed parents reject only new callbacks
status: covered
kind: cancellation
layer: contract
backend: shared
# The SQLite writer refuses a new failure callback after late cancellation but
# still arms an already-durable child as authoritative callback evidence.
test: tests/test_harness_failure_visibility.py::test_hfr_456_late_canceled_failed_parent_rejects_only_new_callbacks
- id: HFR-457
name: stale Turn participant ids cannot roll back valid settlement
status: covered
kind: recovery
layer: contract
backend: shared
# Ownership projection and terminal writes use only Runs loaded under the
# settlement writer lock; stale attribution is excluded from durable provenance.
test: tests/test_harness_failure_visibility.py::test_hfr_457_missing_turn_participant_does_not_rollback_valid_runs
- id: HFR-458
name: steered callbacks inherit shared Turn output receipts
status: covered
kind: delivery
layer: contract
backend: shared
# A callback accepted into an active Turn shares the persisted result through
# exact Turn and output provenance even when another Run is the primary owner.
test: tests/test_harness_failure_visibility.py::test_hfr_458_steered_callback_uses_its_shared_turn_output_receipt
- id: HFR-459
name: deferred Turn owner election is writer-serialized
status: covered
kind: concurrency
layer: contract
backend: shared
# Activity completions reserve SQLite's writer slot before reading deferred
# participants or their owner, so one Turn cannot elect competing fallbacks.
test: tests/test_harness_failure_visibility.py::test_hfr_459_deferred_owner_election_reserves_writer_before_reads
- id: HFR-460
name: delayed Claude steering remains user-owned across the primary Result
status: covered
kind: recovery
layer: contract
backend: claude
# Claude can finish the active query before it dequeues an accepted steer.
# The primary Result remains visible as nonterminal output, the same logical
# Turn stays open, and the later steered Result settles it without creating
# an agent-initiated Harness Message.
test: tests/test_claude_agent_sessions.py::test_presteer_result_stays_visible_without_agent_initiated_turn
- id: HFR-461
name: genuine backend-initiated continuation keeps a hidden lifecycle input
status: covered
kind: safety
layer: contract
backend: shared
# The durable input keeps Turn ownership, Stop, and audit history intact but
# is not a human instruction and therefore never renders in the transcript.
test: tests/test_session_delivery_fsm.py::test_agent_initiated_continuation_materializes_as_hidden_turn_input
- id: HFR-462
name: inherited Workbench routes materialize through the runtime session facade
status: covered
kind: routing
layer: contract
backend: shared
# The handler-to-facade contract forwards the resolved route at Turn start;
# the refreshed chat header remains a residual manual UI check.
test: tests/test_message_handler_typing.py::MessageHandlerTypingTests::test_workbench_inherited_route_materializes_at_turn_start
- id: HFR-463
name: once Watch retries until its first reportable event
status: covered
kind: lifecycle
layer: scenario
backend: shared
# An explicitly allowed retry result keeps a once Watch armed. The first exit
# zero queues exactly one follow-up and retires the definition.
test: tests/test_watches.py::test_managed_watch_service_once_retries_until_first_success
- id: HFR-464
name: forever Watch follow-ups serialize waiter re-arm
status: covered
kind: concurrency
layer: scenario
backend: shared
# A queued/running event Run holds the next waiter closed. Terminal settlement
# starts the fixed safety delay, and only then may the next cycle begin.
test: tests/test_watches.py::test_forever_watch_waits_for_previous_follow_up_before_rearming
- id: HFR-465
name: rapid successful waiter circuit pauses once and preserves evidence
status: covered
kind: failure_recovery
layer: scenario
backend: shared
# Five successes are delivered. The sixth pauses without an ordinary event
# Run, atomically records bounded evidence and queues one repair Run; restart
# cannot create a second repair request.
test: tests/test_watches.py::test_forever_watch_sixth_rapid_success_pauses_and_queues_one_repair_run
- id: HFR-466
name: Watch outbox rejects concurrent unfinished follow-ups
status: covered
kind: safety
layer: contract
backend: shared
# The SQLite writer checks queued/running Watch Runs under the same writer lock
# as the definition stamp and outbox insert, closing a second-admission race.
test: tests/test_watches.py::test_atomic_watch_outbox_rejects_a_second_unsettled_follow_up
- id: HFR-467
name: circuit resume clears burst state but retains the repair fence
status: covered
kind: recovery
layer: contract
backend: shared
# Resume starts a fresh rate window but keeps the repair Run id, so the waiter
# cannot re-arm while the Agent that resumed it is still finishing.
test: tests/test_watches.py::test_resuming_circuit_paused_watch_clears_window_but_keeps_repair_fence
- id: HFR-468
name: storage and CLI circuit resume rules stay identical
status: covered
kind: safety
layer: contract
backend: shared
# The Web UI storage doorway clears the active burst window and marks the
# incident resumed without deleting the repair Run fence.
test: tests/test_watches.py::test_storage_resume_applies_the_same_circuit_reset_as_cli
- id: HFR-469
name: edge-triggered forever Watch re-arms without duplicate delivery
status: covered
kind: lifecycle
layer: scenario
backend: shared
# After the event Run settles, the next cycle sees the durable delivery stamp;
# quiet cycles keep the Watch armed without moving that acknowledgement.
test: tests/test_watches.py::test_a_cycle_is_told_when_this_watch_last_had_a_report_delivered
- id: HFR-470
name: Watch lifetime is one durable armed episode
status: covered
kind: timeout
layer: contract
backend: shared
# Creation or explicit resume starts the deadline. Supervisor restarts retain it,
# including legacy rows derived from created_at; retry sleeps cannot extend it.
test: tests/test_watches.py::test_watch_lifetime_origin_survives_supervisor_restart
- id: HFR-471
name: once Watch timeout retries only by explicit policy
status: covered
kind: timeout
layer: contract
backend: shared
# Exit 124 keeps a once Watch waiting only when listed, then the first event
# queues one Run and retires normally.
test: tests/test_watches.py::test_once_watch_retries_timeout_only_when_124_is_allowed
- id: HFR-472
name: empty failed Turn owns one fallback across all accepted Runs
status: covered
kind: failure_recovery
layer: contract
backend: shared
# The shared dispatcher stamps one Turn failure identity before participants
# arrive; backend, handler, and auth-recovery delivery paths preserve an already
# shown primary at its resolved delivery target, and atomic settlement elects
# one owner only when Runs exist.
test: tests/test_message_dispatcher_result_fallback.py::MessageDispatcherResultFallbackTests::test_hfr_472_empty_failed_turn_creates_one_shared_fallback_contract
- id: HFR-473
name: dead Codex transport releases its stale Turn fence for the next request
status: covered
kind: failure_recovery
layer: scenario
backend: codex
# A definitive process death makes the old local Turn fence non-authoritative;
# only unknown ownership or an active Activity can still veto replacement.
test: tests/test_codex_agent.py::CodexGenerationAcquisitionTests::test_hfr_473_dead_transport_restarts_past_stale_turn_ownership
- id: HFR-474
name: upgrade recovery collapses legacy restart notices by durable Turn ownership
status: covered
kind: failure_recovery
layer: scenario
backend: shared
# Before the notice lane starts, accepted Delivery ownership repairs legacy
# per-Run restart notices into one Turn fallback. A notice already sent remains
# authoritative and suppresses every pending sibling.
test: tests/test_session_delivery_fsm.py::test_hfr_474_startup_collapses_legacy_restart_notices_by_durable_turn
- id: HFR-475
name: restart notices stay concise and hide opaque internal identities
status: covered
kind: failure_recovery
layer: contract
backend: shared
# A service restart renders one calm recovery action. Readable definition names
# remain visible, while deleted definitions never leak their opaque id or append
# internal error, origin, lifecycle, and inspection lines.
test: tests/test_harness_failure_visibility.py::test_hfr_475_restart_notice_is_one_calm_action_without_internal_details
- id: HFR-476
name: Run cancellation stops a shared Session Turn
status: covered
kind: cancellation
layer: scenario
backend: shared
# One live Turn is one backend process turn, so no Run can be withdrawn from
# it. Canceling any Run whose input may have reached the Turn (initial,
# batched, or steered) stops the whole Turn exactly like Session Stop. Only a
# Run still outside the Turn (queued or unwritten steer) settles alone.
test: tests/test_internal_server.py::test_hfr_476_run_cancel_stops_a_shared_turn
- id: HFR-477
name: one-shot Task schedule consumption is explicit and atomic
status: covered
kind: lifecycle
layer: contract
backend: shared
# A manual early run leaves the future schedule armed. The scheduler writes
# retired_at and schedule_consumed in the same transaction as its Run; the
# definition points at that exact consuming Run for terminal status, time, and
# compact-list success. The consuming Run retains the registered run_at,
# timezone, definition revision, physical job id, and retirement time. That
# exact identity rejects stale enqueue, execution, successor suppression, and
# result writes after replacement. A manual rerun of a retired one-shot adds
# only CLI Run history, while a callback failure before enqueue atomically
# records a failed owner Run and retires the exact schedule generation.
test: tests/test_scheduled_tasks.py::test_hfr_477_scheduler_consumes_one_shot_atomically_but_manual_run_does_not
- id: HFR-478
name: missed one-shot recovery records the exact observed schedule
status: covered
kind: recovery
layer: contract
backend: shared
# APScheduler's physical job generation retains its registered run_at,
# timezone, and definition revision. The misfire records schedule_missed only
# while all still match an enabled at schedule; an event from a replacement
# that resolves to the same instant still cannot retire it.
test: tests/test_scheduled_tasks.py::test_hfr_478_misfire_retires_only_the_schedule_apscheduler_observed
- id: HFR-479
name: Watch retirement outcome has one cycle owner
status: covered
kind: concurrency
layer: contract
backend: shared
# A late cycle preserves the already-committed retired_at, finished time,
# exit code, and error while retaining its own individual Run history.
test: tests/test_watches.py::test_hfr_479_late_cycle_cannot_replace_committed_watch_terminal_outcome
- id: HFR-480
name: persisted Run activity exposes missing live ownership
status: covered
kind: failure_recovery
layer: scenario
backend: shared
# Real non-terminal output advances a monotonic durable activity fact. The
# unified view compares a running row with the controller's exact owner set,
# and reports owner loss without guessing from elapsed time.
test: tests/test_harness_live_status.py::test_hfr_480_persisted_activity_exposes_owner_loss
- id: HFR-481
name: unified live view marks same-workdir and Watch anomalies
status: covered
kind: observability
layer: scenario
backend: shared
# Active runtime rows sharing one canonical workdir are marked rather than
# blocked, while dead Watch supervision and upcoming Task inventory remain in
# the same bounded operator response.
test: tests/test_harness_live_status.py::test_hfr_481_unified_view_marks_workdir_conflict_and_watch_failure
- id: HFR-482
name: create-per-run Delivery binding adopts its freshly reserved Session
status: covered
kind: lifecycle
layer: scenario
backend: shared
# A create-per-run row starts without a Session. Its first durable Delivery
# atomically records the runtime reservation while mismatched bound Runs stay
# protected by the existing hard refusal.
test: tests/test_internal_server.py::test_hfr_482_create_per_run_delivery_adopts_reserved_session
- id: HFR-483
name: a registered cron fire enqueues from its own scheduler arguments
status: covered
kind: regression
layer: contract
backend: shared
# Every registered job carries its APScheduler job id for the stale-generation
# guard, but only an at job carries a run_at. Firing the arguments the
# scheduler actually registered proves a cron fire never presents the job id
# as half of the one-shot schedule identity the enqueue requires whole.
test: tests/test_scheduled_tasks.py::test_hfr_483_registered_job_fires_through_its_own_scheduler_arguments
- id: HFR-484
name: an in-flight cron fire cannot spend a replacement one-shot
status: covered
kind: concurrency
layer: contract
backend: shared
# A cron registration carries no schedule identity, so a fire that races an
# edit to at could spend a run_at the definition has not reached and leave it
# armed. The callback rejects on a fresh mirror; the storage CAS is the
# authority when the mirror lags. Either way the replacement schedule is
# handed back to the scheduler, because the cron job that keeps firing is
# itself the stale generation and nothing else would register the one-shot.
# That reconcile is gated on the schedule having actually changed, so a fire
# refused for a merely backlogged predecessor leaves its registration alone.
# An edit that keeps the definition recurring still runs, at its refreshed value.
test: tests/test_scheduled_tasks.py::test_hfr_484_in_flight_cron_fire_cannot_spend_a_replacement_one_shot
- id: HFR-485
name: Watch scheduling survives another reader consuming the store reload
status: covered
kind: concurrency
layer: scenario
backend: shared
# File and SQLite stores, both scheduler paths, and changes before or after
# snapshot capture must converge without a resume or another definition write.
# Unchanged snapshots retain worker identity; consumed disables still stop it.
test: tests/test_watches.py::test_hfr_485_watch_reconciles_after_another_reader_consumes_reload
- id: HFR-486
name: Watch commands and Vault callbacks use the current binding without inherited service identity
status: covered
kind: routing
layer: scenario
backend: shared
test: tests/test_background_command_caller_context.py::test_hfr_486_watch_child_vault_callback_uses_only_current_binding
# Real argv/shell children with clean/contaminated parents, bound/unbound
# targets, isolated Vault expiry, retargeting, and remote snapshot transport.
- id: HFR-487
name: one coalesced Claude input echo acknowledges every queued steer
status: covered
kind: recovery
layer: contract
backend: claude
# Claude dequeues every input queued behind a running response together and
# replays them as one newline-joined UserMessage. That echo acknowledges the
# whole FIFO run. Injected turns such as task notifications never consume
# receipts, even when their text matches; an unmatched human echo is logged.
test: tests/test_claude_agent_sessions.py::test_coalesced_echo_acknowledges_its_whole_queued_run
- id: HFR-488
name: an injected Claude turn's reply is never replayed as the next turn's narration
status: covered
kind: recovery
layer: contract
backend: claude
# A peer or wakeup turn without an Activity streams its Assistant text on the
# human path (inline or buffered replay), then its Result proves a detached
# owner. The detached record takes that phase's text, even when the Result body
# is empty, so it never replays later; text another phase set is untouched.
test: tests/test_claude_result_provenance.py::test_injected_turn_result_retires_its_unbuffered_assistant_text
- id: HFR-489
name: an idle Claude runtime that dies posts nothing to its conversation
status: covered
kind: failure
layer: contract
backend: claude
# Its last Turn already settled and no agent-initiated Turn holds the FIFO, so
# nobody waits on it: the runtime retires quietly, as an idle EOF does, with no
# notice, re-login prompt, Turn settlement or Model Hub failure record.
test: tests/test_claude_agent_sessions.py::ClaudeRuntimeFailureAuthClassificationTests::test_idle_runtime_death_posts_nothing_to_its_conversation
manual_evidence:
- local Incus backend process death after prompt acceptance
- local Incus controller restart with persisted queued successor
plan: docs/plans/harness-session-failure-recovery.md
plans:
- docs/plans/harness-session-failure-recovery.md
- docs/plans/agent-run-zombie-settlement.md
- docs/plans/harness-watch-run-failure-boundary.md
- docs/plans/watch-follow-up-circuit-breaker.md
- docs/plans/harness-live-anomalies.md