A dialog can disappear while the original operation is still unfinished. I wrote an independent synthetic model to make that distinction inspectable. It has no function that answers a real dialog or connects to a browser. It records externally supplied observations and shows which evidence is still missing before the original operation can be called complete.

Bind the original operation before recording continuation evidence

Binding contains synthetic aliases for the project, profile, tab, document generation, operation and expected condition. Later observations must carry that same binding. A result from another tab or account must not become evidence for the original operation while a dialog is being handled. No real names, addresses, drafts or accounts are included; even the expectation is represented by an alias such as expected-a.

Matching these strings does not authenticate a real account or establish ownership of a tab. The model assumes a trusted host connects observations with its actual operation record. A caller able to construct arbitrary state objects must not treat a dataclass as a security boundary. Producing trustworthy observations and checking consistency among supplied observations remain separate responsibilities.

Recording a response result does not establish that the dialog closed

observe_dialog binds an observed dialog identifier. record_response_result then records the result of an external response attempt and accepts only an explicit boolean acknowledgement. It has no parameter for choosing accept or cancel, sends no response and does not classify a warning as safe to handle. It records evidence about an attempt made elsewhere.

Even an acknowledged response does not automatically set dialog_closed or native_settled. A second record of the same response attempt is rejected, and a different dialog identifier cannot replace the original continuation. This is not a retransmission implementation. Its narrow responsibility is to keep evidence about one response attempt from silently becoming a claim that the business operation finished.

Record dialog lifetime and command lifetime separately

record_closed describes closure of the bound dialog. record_native_settled describes settlement of the original native command. Either observation can arrive first, but neither substitutes for the other. record_original_outcome is unavailable until both barriers have been recorded. This exposes the mistake of allowing another input immediately after a visible dialog disappears.

Finally, an external checker supplies whether the originally bound expectation matches. False keeps the operation incomplete and permits another read-only check; true sets verified. The package does not implement a new text, route or state matcher. The existing original-outcome comparison module can inform that judgment, but an automatic integration between the two packages is not included.

Explore the implementation

Complete independent synthetic implementation

"""Synthetic in-memory observations. No browser, response or replay operation."""
from dataclasses import dataclass, replace


@dataclass(frozen=True)
class Binding:
    project: str
    profile: str
    tab: str
    document_epoch: int
    operation: str
    expectation: str

    def __post_init__(self):
        for value in (self.project, self.profile, self.tab, self.operation, self.expectation):
            if not isinstance(value, str) or not value.strip() or len(value) > 80:
                raise ValueError('Bounded nonempty synthetic aliases required')
        if type(self.document_epoch) is not int or self.document_epoch < 0:
            raise ValueError('Invalid document epoch')


@dataclass(frozen=True)
class Continuation:
    binding: Binding
    dialog_id: str = ''
    response_recorded: bool = False
    response_acknowledged: bool = False
    dialog_closed: bool = False
    native_settled: bool = False
    verified: bool = False
    stopped: bool = False


def _bound(state, binding):
    if not isinstance(state, Continuation) or not isinstance(binding, Binding) or state.binding != binding:
        raise ValueError('Changed operation context')


def _dialog(state, binding, dialog_id):
    _bound(state, binding)
    if not state.dialog_id or dialog_id != state.dialog_id:
        raise ValueError('Stale or unobserved dialog')


def observe_dialog(state, binding, dialog_id):
    _bound(state, binding)
    if not isinstance(dialog_id, str) or not dialog_id.strip() or len(dialog_id) > 80:
        raise ValueError('Invalid synthetic dialog identifier')
    if state.verified or (state.dialog_id and state.dialog_id != dialog_id):
        raise ValueError('Another continuation already recorded')
    return replace(state, dialog_id=dialog_id)


def record_response_result(state, binding, dialog_id, *, acknowledged):
    """Record evidence from one external attempt; never choose or send a reply."""
    _dialog(state, binding, dialog_id)
    if state.stopped or state.verified or state.response_recorded:
        raise ValueError('Cannot record another response attempt')
    if type(acknowledged) is not bool:
        raise ValueError('Explicit boolean evidence required')
    return replace(state, response_recorded=True, response_acknowledged=acknowledged)


def record_closed(state, binding, dialog_id):
    _dialog(state, binding, dialog_id)
    return replace(state, dialog_closed=True)


def record_native_settled(state, binding):
    _bound(state, binding)
    return replace(state, native_settled=True)


def record_original_outcome(state, binding, *, matched):
    _bound(state, binding)
    if type(matched) is not bool:
        raise ValueError('Explicit original-condition evidence required')
    if state.stopped or not (state.response_recorded and state.dialog_closed and state.native_settled):
        raise ValueError('Original continuation is not ready for verification')
    if state.verified:
        raise ValueError('Completed evidence cannot be rewritten')
    return replace(state, verified=matched)


def stop(state):
    return replace(state, stopped=True)


def summary(state):
    if state.stopped: next_step = 'stopped_keep_record'
    elif state.verified: next_step = 'complete'
    elif not state.dialog_id: next_step = 'observe_dialog'
    elif not state.response_recorded: next_step = 'await_explicit_external_response_result'
    elif not state.dialog_closed: next_step = 'observe_dialog_closure_without_replay'
    elif not state.native_settled: next_step = 'wait_for_original_native_settlement'
    else: next_step = 'verify_original_expectation'
    return {'next_step': next_step, 'complete': state.verified,
            'response_acknowledged': state.response_acknowledged,
            'dialog_closed': state.dialog_closed, 'native_settled': state.native_settled,
            'operation': state.binding.operation, 'expectation': state.binding.expectation,
            'automatic_replay': False, 'response_authorized_by_module': False}

Preserve the meaning of late observations and stop

Missing acknowledgement alone never completes an operation. If dialog closure, settlement of the original command and the original expected outcome are later actually observed, the model can reconcile that evidence without another response. response_acknowledged remains false. This example distinguishes the evidence used for reconciliation instead of rewriting an unacknowledged reply as an acknowledged one.

stop records a stop flag. It neither claims to cancel a remote command nor grants permission to resume. Late closure and settlement observations remain recordable, but a stopped incomplete operation cannot be newly verified. Stopping also does not rewrite a previously completed result as a historical failure. These are explicit lifecycle choices in this small model, not a port of the product's entire cancellation implementation.

Read five records of different incomplete states

The selector below displays five records: acknowledgement only; a closed dialog with the command still pending; a settled command with an unmatched outcome; a verified original outcome; and late settlement after stop. They are synthetic records produced by actual local Python execution. The fields make it possible to compare completion claims without operating a real window.

Initial display and all five selections are checked against saved records by executing the actual inline scripts for both languages with DOM stubs. That checks the wiring of the selector, not an operating-system dialog or a rendered browser interface. The page accesses no visitor account, file or browser page and sends no dialog response. The interaction keeps that scope visible beside the records.

A read-only viewer of synthetic local records

Keep the host responsibilities explicit

Sixteen test methods cover acknowledgement, closure and settlement as separate barriers; changes to each binding field; stale dialog identifiers; unmatched and late results; stop; repeated response records; and input preservation. The same tests are repeated after ZIP extraction into a separate directory. The package includes implementation, tests, a record generator, saved results, usage notes and an MIT license.

A real integration still needs trustworthy dialog provenance and permission checks, human handoff for sensitive warnings, an exact original-condition checker, durable records and time limits. This package calculates in-memory synthetic state only. Historical evidence from the original browser or a customer's program is not borrowed as the package's test result, and no new browser compatibility is claimed.

Download code, tests and records
Python standard library, synthetic data, modification and reuse permitted