Treat a paused run as an explicit state, not a sleeping function. Persist the state token before waiting, accept only known events, and reject duplicate or illegal transitions with a typed error.Asynchronous state machine
Make waiting and resumption explicit.
asynchronous_wait_and_resumeRECORD STATUSCandidate · v0.1.0UML class view
The proposed contract drawn as participant roles, received calls, and numbered dependencies.
Object interactions
The same roles and calls as a class collaboration and a numbered message sequence.
Pointcut
Where the mechanism applies. All four dimensions belong to the proposed match, not just its vocabulary.
- Context
- A harness run may pause for external work or user input.
- Trigger
- An event requests suspension or arrives to resume a paused run.
- Structure
- Enumerated states, legal transitions, event identity, and resumption state.
- Effect
- A resumed run follows only the legal transition and preserves durable state.
Protected contract
The obligation that clients, operators, and auditors should be able to rely on.
- Requires
- State can be serialized or retained and incoming events can be identified.
- Ensures
- Accepted events move the machine to a defined state and duplicate events are handled.
- Invariant
- No transition crosses from a disallowed state or executes twice after replay.
- Violation
- Invalid, duplicate, or interrupted events leave a recoverable state or raise explicitly.
Negative control
An enum without transition enforcement is not sufficient.
Variation & lifecycle
The hot spot is admitted only where the protected semantics survive.
Permitted variation
Transition dispatch, persistence backend, and recovery policy.
Test obligation
Test illegal transitions, duplicate events, interruption, and resume.
Evolution question
Did implicit control flow become an observable durable state machine?
Prompt + code design
An illustrative prompt and a small design sketch for the proposed contract. Names and APIs are invented; this is not a repository excerpt.
TRANSITIONS = {
"ready": {"start": "running"},
"running": {"wait": "waiting", "finish": "done"},
"waiting": {"resume": "running", "cancel": "cancelled"},
}
def apply(state, event, store):
target = TRANSITIONS.get(state.status, {}).get(event.kind)
if target is None:
raise IllegalTransition(state.status, event.kind)
next_state = state.with_status(target, event_id=event.id)
store.save(next_state)
return next_stateIllustrative design sketch. The durable record, not an in-memory coroutine, is the resumable unit. This example is a teaching aid, not implementation evidence or a conformance claim.
Detection & matching
The frozen rule that retrieves this record, the canonical source exemplar, and the control that should stay unmatched.
- Join point
asynchronous_wait_and_resume- Source locator
- Barbaste et al., §6.2, p. 14 (Codex, “Tokio Async State Machine”); generalized label
- Lexical cue
(?i)\bstate[_-]?machine\b|\b(?:transition|transitions|legal_states)\bFrozen expression, v0.1.0. A match is a retrieval cue, not a confirmed implementation.- Aliases
- None
- Canonical exemplar
- langchain-ai/langgraph
libs/langgraph/langgraph/graph/state.py:131Support: libs/langgraph/tests/test_subgraph_persistence_async.py:63 - Negative control
- An enum without transition enforcement is not sufficient.
Scope-anchored review. pohe-agent analyze <repo> --pattern P03 anchors the cue to its enclosing declaration and checks a separate operational signature for all four pointcut dimensions. Missing roles and negative-control risks remain visible; a structural match is not E2/E3. Calibration report ↗
Repository files
Up to five public files retrieved by the frozen cue and pinned to the audited commit. A match is a place to inspect, not a confirmed implementation.
libs/langgraph/langgraph/graph/state.py:131CANONICAL SOURCE02aaif-goose/goosecrates/goose/src/acp/server.rs:14RETRIEVAL CUE03affaan-m/ECCskills/operator-approval-loop/references/approval_claims.py:17RETRIEVAL CUE04agno-agi/agnolibs/agno/agno/company/manager.py:238RETRIEVAL CUE05Aider-AI/aideraider/website/_includes/leaderboard_table.js:286RETRIEVAL CUEEvidence & provenance
Each layer answers a different question. Do not substitute retrieval for review.
Source-located exemplar
A concrete source anchor is available for this proposed record. It is one exemplar, not evidence that all repositories—or every contract field—conform.
Review boundary: this candidate and its specification come from an AI-assisted study. Independent human validation remains open.
94.4% of repository families in the frozen panel have at least one current cue, historical cue, or canonical source layer. This is not confirmed prevalence.
Current lexical-cue repositories: 37 / 415847733bcb18libs/langgraph/langgraph/graph/state.py:131libs/langgraph/tests/test_subgraph_persistence_async.py:63State graph with typed transitions and async execution.
Exploratory retrieval cue Regex / v0.1.0
(?i)\bstate[_-]?machine\b|\b(?:transition|transitions|legal_states)\bThis expression is a discovery instrument only. A match is a retrieval cue—not a confirmed implementation, pointcut match, or contract proof.