Skip to content

feat(harness): expose explicit Assistant lifecycle actions [SAP-3292] - #1018

Closed
ynadge wants to merge 1 commit into
assistant-continuation-orchestrationfrom
assistant-lifecycle-actions
Closed

ynadge wants to merge 1 commit into
assistant-continuation-orchestrationfrom
assistant-lifecycle-actions

Conversation

@ynadge

@ynadge ynadge commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Primary change type

  • Feature

Problem and motivation

The browser needs authenticated, revision-checked actions for saved Assistant inspection, same-ID Resume and new-child Continue.

Summary and scope

Add strict boot-authorized POST contracts and safe typed failures. Project only public session/lifecycle/provenance fields, stripping saved systems and private receipt context. Provide an opaque authorized retry scope that survives process restart and changes on project, account or native rebinding. Production composition follows.

Related work

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

Depends on #1017. Native stack target: main.

Validation

Lifecycle routes, history and shared errors: 21 tests passed. Full Harness server TypeScript, scoped ESLint, formatting and diff checks passed.

Tests and documentation

Cover boot validation before work, strict request fields, safe private-data projection, stale lifecycle results, native/context failures, stable retry scope and project changes during IO. Updated assistant-history.md. Increment:674 changed lines including tests/docs/changeset; SDK pr:size is absent.

Compatibility and release impact

  • Additive routes and optional public history field. Record reading still starts no native runtime.
  • Changeset: @sapiom/harness patch.
  • Fix-forward: preserve authentication, revision fencing and public-only projections while correcting action behavior.

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 change with the validation described above.

Checklist

  • CONTRIBUTING.md read; maintainer-authorized issue work.
  • One focused increment, checks, documentation and release impact addressed.
  • 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: 8c19ceac-b410-4874-bd31-c852d3466f93

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

createBootTokenMiddleware(options.bootToken),
express.json({ limit: "8kb" }),
);
router.post("/sessions/:id/assistant/:action", (req, res) => {

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.

🔴 Assistant actions are never mounted

createAssistantLifecycleRouter has no production caller, so every new Assistant action falls through to the API 404 handler.

Learn more

The production server creates Assistant history and lifecycle services, then mounts the records router before the final API fallback. It never imports or calls createAssistantLifecycleRouter, and it never composes the continuation service required by the Continue callback. The isolated router tests therefore pass without proving that startServer exposes any action route.

Example: POST /api/sessions/studio-a/assistant/inspect with a valid boot token reaches the final API fallback and returns 404 {"error":"API route not found"}. The documented route must invoke native inspection and return its entry.

Recommended fix: Compose AssistantNativeHistory, AssistantContinuationStore, AssistantContinuationNative, and AssistantContinuation in the production server. Mount createAssistantLifecycleRouter under /api before the fallback, passing the existing boot token, history, lifecycle, session manager, and delivery dependencies. Add a startServer integration test that calls all three routes.

Devin Review

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

Comment on lines +146 to +150
if (
!current ||
current.lifecycle.revision !== parsed.data.expectedRevision ||
current.cwd !== entry.cwd
)

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.

🟡 Project rebinding escapes action fencing

When a session changes project without changing cwd, inspection accepts native results produced under the prior identity. continuationScope distinguishes these identities, but the Resume postcheck also ignores it.

Learn more

Each action reads an authorized history entry before asynchronous native work and reads another afterward. The history entry's continuation scope changes when the project, user, harness, or saved binding changes. Comparing only cwd allows a same-directory project rebind between the two reads to pass inspection's fence. Resume has the same gap after its coordinator returns, so it can publish an attachment prepared before the rebind.

Example: A session starts in project project-a at /workspace. While inspection reads native history, the session is rebound to project-b at /workspace; the second entry has a different continuationScope, but the route returns the old inspection result as current.

Recommended fix: Require the post-action entry's continuationScope to equal the initial entry's scope for inspection and Resume. Also add race tests that mutate agentMapIdentity.projectId between the first and second history reads while preserving cwd.

Devin Review

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

@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