Skip to content

feat(harness): fence paused continuation preparation [SAP-3292] - #1011

Closed
ynadge wants to merge 1 commit into
assistant-resume-receiptsfrom
assistant-continuation-admission
Closed

ynadge wants to merge 1 commit into
assistant-resume-receiptsfrom
assistant-continuation-admission

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

Continue needs exclusive ownership while preparing a paused child, before ordinary attachment is allowed. A lost acceptance acknowledgement must also not let retried pending input repair lost committed source material.

Summary and scope

Expose trusted continuation preparation through the existing lifecycle ownership slot, retaining only the validated exact host and granting no lease. End preempts preparation. When an acceptance manifest already exists, validate its original content and retained material before any retry writes, preserving the source store as the authority.

Related work

Related issue: https://linear.app/sapiom/issue/SAP-3292

Depends on #1010. Native stack target: main. Native preparation and Continue API consumers follow.

Validation

pnpm --filter @sapiom/harness exec vitest run src/core/assistant-lifecycle.test.ts src/core/assistant-native-history.test.ts src/core/assistant-end.test.ts src/core/assistant-source-store.test.ts src/core/studio-assistant-delivery.test.ts — 122 passed
pnpm --filter @sapiom/harness exec tsc --noEmit — passed
Scoped ESLint and git diff --check — passed

Tests and documentation

Covers gated child preparation, shared-slot exclusion, paused handoff, exact failure cleanup, stale/ended revisions, End during preparation, and rejection without repair after committed material loss. Updated assistant-continuation.md. Increment:154 changed lines including tests/docs/changeset; pr:size is absent.

Compatibility and release impact

  • Breaking or externally visible changes: additive trusted preparation seam; source retries fail closed when committed material is missing.
  • Changeset: added for @sapiom/harness.
  • Fix-forward: preserve exact host ownership and accepted manifests while correcting preparation or retry validation.

Security

  • No secrets, credentials, private data, or unsanitized logs included.
  • No suspected vulnerability disclosed publicly.

AI assistance

  • AI assistance used: Codex implemented the shared preparation seam and source retry correction; root reviewed exact ownership and reran 122 tests, typecheck and lint.

Checklist

  • CONTRIBUTING.md read; maintainer-authorized issue work.
  • One focused increment, tests, relevant checks, documentation, and release impact addressed above.
  • I can explain and maintain the submitted changes.

Devin Review

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 0b1f1f07-80fc-45be-8e83-4bd5751d717f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment on lines +300 to +304
if (
state.revision !== expectedRevision ||
state.lifecycle === "ending" ||
(retain && state.lifecycle !== "open")
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Active leases survive continuation preparation

prepareContinuation accepts a session with an existing lease, so preparation can overlap live use of the same runtime. inspections blocks new attachment but neither rejects nor revokes the lease already stored in leases. Continuation seeding can race user dispatch and alter an active conversation.

Learn more

Continuation preparation uses the same admission slot as attachment and inspection, but the slot only prevents new operations from starting. An attachment completed before preparation leaves a lease in leases. Requests using that lease continue through use, which does not consult inspections. The callback can therefore mutate the native conversation while an already-admitted request uses it.

Example: A child is attached and receives a paused lease. Before or during enablement, a continuation retry calls prepareContinuation with the current revision. Preparation is admitted because the lifecycle is open, while the existing lease remains usable against the same host.

Recommended fix: Reject retained preparation when the session has a current lease. Permit an obsolete lease whose host is no longer current, since the retained path can safely allocate a replacement.

Suggested change
if (
state.revision !== expectedRevision ||
state.lifecycle === "ending" ||
(retain && state.lifecycle !== "open")
)
if (
state.revision !== expectedRevision ||
state.lifecycle === "ending" ||
(retain &&
(state.lifecycle !== "open" ||
this.leases.get(id)?.hosted.isCurrent() === true))
)
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +257 to +263
prepareContinuation<T>(
id: string,
expectedRevision: number,
prepare: (hosted: HostedOpenCode, signal: AbortSignal) => Promise<T>,
callerSignal?: AbortSignal,
): Promise<T> {
return this.prepareRuntime(id, expectedRevision, prepare, true, callerSignal);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Continuation fencing remains unwired

Production constructs the coordinator without canAttach, and only tests call prepareContinuation. Continue operations remain unchanged until the planned consumer wiring lands.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant