Check `ctx.emit` and `ctx.enqueue` survive recovery and replay under DBOS and Temporal
- 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.
| Scenario | DBOS | Temporal |
|---|---|---|
emit_from_tool | supported | refused |
enqueue_from_tool | supported | refused |
emit_in_unit | broken (#7971): lost on recovery | refused |
enqueue_in_unit | refused | refused |
emit_enqueue_from_hook | supported | supported |
The other six engines stay untested (#12291), with the expected level in each cell's reason.
Changes:
tests/capability_cases.py:ScenarioRun(build, observed)andSCENARIO_RUNS, the scenarios the D1 suites run.- The test-only
ScenarioNote(aCustomEvent) andScenarioCapabilityNote(aCapabilityEvent), 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 whoseon_eventruns 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_breaksrequires 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:
supportedbreaks nothing,refusedmatchesraises,brokenmatches its signature, so a fix flips it.
tests/harness/test_engine_support.py:- a scenario's owner may be
RunContextas well as a public capability; - every
RunContextscenario must be inSCENARIO_RUNS.
- a scenario's owner may be
agent_docs/capability-conformance.md: how the D1 suites run scenarios.
Decisions:
- Cases don't get the recorder. A capability that overrides
on_eventmakes the run stream, which renames the model-request unit that every case's pinned journal lists. Scenario agents are new and pin no journal. Planningunder DBOS stayssupported. A local run with the recorder observed the samePlanningevents 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 isemit_in_unithere.- 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
supportedunder 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 theReplayerhangs when a workflow listsException. - The D1 suites only check
supportedcells, 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.pynow allowsRunContextas a scenario owner and requires everyRunContextscenario to be inSCENARIO_RUNS.