Check `ctx.emit` and `ctx.enqueue` survive recovery and replay under DBOS and Temporal

DO
20h ago
+433-24
  • Part of #12291 (the durable x capability matrix) and #7971 (a durable unit's events and enqueued messages); closes neither.

Stacked on #14462 (base durable-scenario-support). It retargets when #14462 does. The scenario shape, and running the scenarios from the D1 suites, were agreed with the D1 owner.

The change adds five RunContext scenarios to SCENARIO_SUPPORT, split by where the call runs, because that's what decides the outcome. DBOS runs a function tool in workflow code. Temporal runs it in an activity. A @durable_operation is a unit on both.

ScenarioDBOSTemporal
emit_from_toolsupportedrefused
enqueue_from_toolsupportedrefused
emit_in_unitbroken (#7971): lost on recoveryrefused
enqueue_in_unitrefusedrefused
emit_enqueue_from_hooksupportedsupported

The other six engines stay untested (#12291), with the expected level in each cell's reason.

Changes:

  • tests/capability_cases.py:
    • ScenarioRun(build, observed) and SCENARIO_RUNS, the scenarios the D1 suites run.
    • The test-only ScenarioNote (a CustomEvent) and ScenarioCapabilityNote (a CapabilityEvent), and the capabilities that emit and enqueue from a unit or a hook.
    • The cells, and BROKEN_SIGNATURES[7971].
  • tests/harness/_durable_cases.py:
    • ScenarioRecorder: a capability whose on_event runs in workflow code. It records custom and capability events and enqueued messages, keyed by agent name, since engines may copy capabilities.
    • observe_run, scenario_breaks, assert_scenario_cell.
    • scenario_breaks requires each expected item exactly once, and reports what recovery or replay lost or added.
  • Both D1 suites:
    • DBOS forks the workflow from its last step.
    • Temporal replays the history with a Replayer, which re-runs the workflow code and so the recorder.
    • Each cell is asserted: supported breaks nothing, refused matches raises, broken matches its signature, so a fix flips it.
  • tests/harness/test_engine_support.py:
    • a scenario's owner may be RunContext as well as a public capability;
    • every RunContext scenario must be in SCENARIO_RUNS.
  • agent_docs/capability-conformance.md: how the D1 suites run scenarios.

Decisions:

  • Cases don't get the recorder. A capability that overrides on_event makes the run stream, which renames the model-request unit that every case's pinned journal lists. Scenario agents are new and pin no journal.
  • Planning under DBOS stays supported. A local run with the recorder observed the same Planning events after recovery: its tools emit from workflow code, which DBOS re-executes. The loss #7971 describes shows only for an emit inside a unit, which is emit_in_unit here.
  • The hook scenario uses before_model_request. A tool-execution hook can run inside Temporal's activity, which would make it in-unit; a model-request hook doesn't.

Locally I ran -k scenario in both modules: all 10 scenario tests pass with these cells. In the full modules, one DBOS case failed on SmartSearch's journal (fewer workspace calls than pinned), and one Temporal case failed that I didn't identify. Neither touches scenario code, and I believe both come from local tooling. CI is the check.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

🤖 Generated with Claude Code


Summary by cubic

Checks that ctx.emit and ctx.enqueue observe the same custom and capability events and enqueued messages, each exactly once, under DBOS recovery and Temporal replay. Part of #12291 (the durable × capability matrix) and #7971 (a durable unit's events and enqueued messages); closes neither.

Adds five RunContext scenarios to SCENARIO_RUNS, split by where the call runs: a function tool, a @durable_operation, and a hook. The D1 suites run them with a ScenarioRecorder in workflow code and compare the first run's observations with a DBOS workflow fork from its last step or a Temporal Replayer replay.

  • #15404 fixed event and message loss on unit recovery, so all five scenarios are supported under DBOS and Temporal.
  • Temporal runs a function tool in an activity but carries the call's effect in the unit's recorded result, which a replay re-runs.
  • The Temporal replay uses a twin workflow without failure_exception_types, since the Replayer hangs when a workflow lists Exception.
  • The D1 suites only check supported cells, so a scenario DBOS or Temporal refuses or limits fails until its check is designed.
  • The other six engines stay untested (#12291), with the expected level in each cell's reason.
  • test_engine_support.py now allows RunContext as a scenario owner and requires every RunContext scenario to be in SCENARIO_RUNS.