# Execution Continuity — Lane A Progress

Status: implementation and final repository gate complete; commit/push pending  
Branch: `impl/continuity-a-domain`  
Baseline: `9b1c43b3ce64f9e7486325bf8ee027d9df2a2e54` (`origin/main`)  
Worktree: `/home/user/Projects/chatgpt-orchestrator-worktrees/continuity-a-domain`

## Scope

Lane A owns the execution-continuity domain, protocol, persistence, and corresponding tests. No browser DOM, ChatGPT Web adapter, extension UI, operator dashboard, or main-branch integration is implemented here.

Compatibility choice: retain the existing `WorkerState` lifecycle and add a separate durable `WorkerDisposition`. This avoids a protocol-major break while representing `running`, `awaiting_execution`, `awaiting_human`, `awaiting_dependency`, `paused`, and `terminal` explicitly.

## Implemented

### Protocol

- Durable `ContinuationPolicy` with conservative migrated/default mode `manual`, idle grace, progress-heartbeat flag, and progress-aware stall thresholds.
- Cross-field policy validation rejects warning thresholds greater than pause thresholds and invalid grace values.
- `WorkerDisposition`, `WorkerContinuityState`, structured human/dependency waits, and pause reasons.
- Durable `ExecutionAttempt` identity, reason, lifecycle state, outcome, sequence, timestamps, progress cursors, command identity, and error metadata.
- Execution-continuity event vocabulary and stable error codes required by later lanes.
- Canonical output-only `<continuation-state>` representation and strict fail-safe parser. The parser accepts exactly one four-field block and does not encode executor/browser continuation mechanics.

### Persistence

- Added durable collections for run continuation defaults, per-worker continuity state, execution attempts, per-worker sequences, and execution-attempt idempotency.
- Backward-compatible normalization/migration for older serialized state. Existing workers load without destructive reset and inherit manual continuation unless explicitly enabled.
- Effective-policy precedence: worker override > run default > conservative protocol default.
- Restart reconstruction preserves attempt sequence and continuity state exactly.
- Retention removes continuity state, execution attempts/sequences, policy state, and execution idempotency together with the terminal run.
- Existing atomic mutation/event persistence semantics remain intact.

### Core domain

- Root run creation now records the root worker's initial execution attempt and marks it generating; child spawn records a scheduled initial attempt.
- Follow-up assignment creates a distinct `followup` attempt rather than conflating follow-up with resume.
- Durable attempt operations cover schedule, submit, generate, idle, completion/block/failure/cancellation, listing, and restart recovery.
- Per-worker sequence is monotonic and scheduling is idempotent by stable key; conflicting key reuse fails closed.
- One active scheduled/submitted/generating logical attempt per worker is enforced.
- Existing executor-command enqueue links compatible create/send commands to the pending attempt; a successful command result records submission.
- Conversation lifecycle reconciliation coalesces duplicate browser state without losing a required lifecycle transition when an intermediate `generating` observation was missed but worker attachment proves the new attempt is active.
- `worker.progress` updates last-progress cursor/time and resets no-progress accounting atomically.
- Explicit `awaitHuman` and `awaitDependency` durable blockers suppress continuation and terminate the current attempt as blocked.
- Non-terminal pause supports immediate pause or pause-after-current-turn. `resumeWorker` clears blocking/pause/stall state explicitly.
- `continueNow` distinguishes terminal, blocked, generating, pending, paused, and idle states; it queues one post-turn intent while generating or creates exactly one manual-resume attempt while idle.
- Run default and worker override policy mutation/read APIs append durable `continuation.policy_changed` events.
- `evaluateContinuation` implements the normative stop/wait/schedule ordering for run/worker terminality, human/dependency waits, pause/stall, in-flight attempt, managed-conversation availability, idle grace, manual policy, queued manual intent, and automatic resume.
- `listContinuationCandidates` exposes restart-safe due work without making the browser authoritative.
- Stall protection warns/pauses based on durable no-progress attempts/time and never converts explicit human/dependency/user-pause state into a stall pause.
- Completion/failure/cancellation terminalize worker continuity and invalidate pending continuation state; root completion still requires terminal children, and root failure/cancel propagates terminal state to unfinished children.
- Delivery timeout can end the prior attempt with `message_delivery_timeout` while keeping the logical worker unfinished and, under auto policy, create one durable recovery attempt. The browser rule to send a fresh `continue` and never click Retry remains intentionally outside Lane A.

## Verification

Focused verification completed before the final gate:

- `pnpm --filter @platform-modules/chatgpt-orchestrator-protocol typecheck` — PASS.
- `pnpm --filter @platform-modules/chatgpt-orchestrator-persistence typecheck` — PASS.
- `pnpm --filter @platform-modules/chatgpt-orchestrator-core typecheck` — PASS.
- Protocol tests — 8 passed, 0 failed.
- Persistence tests — 5 passed, 0 failed.
- Core tests — 26 passed, 0 failed.
- `pnpm typecheck` — PASS across all 6 workspace projects with typecheck scripts.
- `pnpm test` — PASS. The command rebuilt the workspace and passed all current suites: protocol 8/8, ChatGPT Web adapter 7/7, extension 5/5, persistence 5/5, core 26/26, MCP server 4/4.
- `git diff --check` — PASS.
- `pnpm gate` — PASS. This reran workspace typecheck, the complete build+test matrix, and a final workspace build successfully.

The first direct persistence test invocation before building its workspace dependency failed at module resolution because `packages/protocol/dist` did not yet exist. After building protocol, the persistence suite passed 5/5. The repository's root `pnpm test` performs the required build first and passes completely.

## Lane A test coverage highlights

- manual vs auto idle evaluation;
- duplicate idle/evaluation deduplication;
- root-worker initial attempt and root auto-resume eligibility;
- completion during idle grace suppresses resume;
- completion/failure/cancellation terminal suppression;
- explicit human/dependency waits;
- pause-after-current-turn and Continue Now distinction;
- blocked Continue Now requires explicit override;
- progress reset semantics;
- stall warning and automatic stall pause thresholds;
- blocked state cannot be reclassified as stall;
- run-policy inheritance and worker override;
- execution-attempt idempotency/conflict rejection;
- submitted/generating/idle-grace restart convergence without duplicate attempts;
- scheduled continuation restart recovery;
- stall-pause restart/recovery;
- delivery-timeout auto/manual domain behavior;
- follow-up attempt identity distinct from resume;
- retention compatibility.

## Cross-lane integration contract sent to `/root`

The root worker has been notified of these required integration seams:

1. MCP/integration should expose core domain operations equivalent to `worker.await_human`, `worker.await_dependency`, `worker.pause`, `worker.resume`, `worker.continue_now`, worker continuation get/set, and optionally run-default get/set.
2. The backend scheduler should use durable conversation observations plus `listContinuationCandidates` / `evaluateContinuation`, then dispatch the returned scheduled attempt exactly once using its execution identity.
3. Existing `enqueueExecutorCommand` links compatible create/send commands to scheduled attempts; later dispatch code should preserve that path rather than introduce a parallel attempt store.
4. Delivery-timeout adapter/executor behavior remains outside Lane A. It should call `recordDeliveryTimeout`; when a recovery attempt is returned, the executor lane must implement the specification's fresh user message `continue` and must not click ChatGPT Retry.
5. Resume prompt generation, asynchronous browser observation, DOM behavior, popup/dashboard UI, and extension command-journal recovery remain owned by the later lanes.
6. `parseContinuationState` is a signal parser only. Durable worker lifecycle and acceptance state remain authoritative.

## Remaining before Lane A terminal report

- Commit all Lane A files and this progress record.
- Push `impl/continuity-a-domain` without force.
- Send commit SHA, exact final gate result, known risks, and cross-lane notes to `/root`.
