Skip to content

feat(harness): coordinate confirmed Studio session End [SAP-3292] - #1002

Closed
ynadge wants to merge 1 commit into
assistant-history-discoveryfrom
assistant-session-end
Closed

ynadge wants to merge 1 commit into
assistant-history-discoveryfrom
assistant-session-end

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

End could dismiss a Studio session while one managed engine was still running. A cleanup deadline or failed metadata write must not be reported as successful termination.

Summary and scope

Coordinate Terminal and Assistant End under one per-session operation. Fence admission and request both shutdowns before waiting for metadata. Persist ended only after confirmed cleanup, and return a bounded 409 result for unresolved process or storage outcomes. Completed retries check both engines again, including a Terminal restarted under an ended Assistant header. Map expected Terminal resume conflicts to 409. Zero-revision defaults do not claim an active Assistant in the public projection.

Related work

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

Depends on #1001. Native stack target: main. Existing confirmation/history UI follows in the dependent increment.

Validation

pnpm --filter @sapiom/harness exec vitest run src/core/assistant-end.test.ts src/core/assistant-lifecycle.test.ts src/server/rest.test.ts src/server/state-isolation.test.ts — 153 passed
pnpm --filter @sapiom/harness exec vitest run src/core/assistant-state-projection.test.ts — 7 passed
pnpm --filter @sapiom/harness typecheck — passed
pnpm exec eslint (changed production files) — passed
git diff --check — passed

Tests and documentation

Tests cover concurrent End, startup cancellation, same-ID Terminal restart, bounded and failed storage, late reads after timeout, cleanup uncertainty, and REST conflicts. Documented the result contract and prior-host uncertainty. pr:size is absent; measured increment: 661 changed lines including tests and changeset.

Compatibility and release impact

  • Breaking or externally visible changes: confirmed End returns 200; incomplete cleanup returns 409 and retains the session/history.
  • Changeset: added for @sapiom/harness.
  • Fix-forward: correct cleanup/reporting while preserving exact process ownership and durable fences. A prior-host ending header cannot be cleared merely because the new process has no in-memory handle.

Security

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

AI assistance

  • AI assistance used: Codex implemented and reviewed the coordinator and routes; root review found the completed-result cache problem, added production wiring, and reran composition tests.

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: a9f4b805-93e8-4c5f-97a6-203d794678e2

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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@ynadge ynadge closed this Sep 15, 2026
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