Skip to content

ref(chat): Project turn sessions through explicit schemas - #1286

Merged
dcramer merged 7 commits into
mainfrom
ref/turn-session-stop-nested-routing-writes
Aug 7, 2026
Merged

dcramer merged 7 commits into
mainfrom
ref/turn-session-stop-nested-routing-writes

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Stop writing nested destination/source into turn-session state. Writers project through one explicit Zod schema (.strip()), so unknown/deprecated keys never land in durable records or summary indexes. SQL remains the authority for routing via conversation metadata dual-writes.

Projection schemas

agentTurnSessionSummarySchema is the shared field set. The stored record schema extends that same projection with resume-only fields (committedSeq, runtimeContext, …). Summary indexes intentionally omit the heavier fields; they are not a second domain model.

Write-path cleanup

Optional-field ternary walls in the turn-session service collapse behind definedProps + a shared sessionWriteContext helper so each persist path only fills state-specific bits.

Naming

Turn-session APIs keep source for the structured inbound Source. That maps to conversation-store sessionSource only at the SQL boundary, because the store already has a separate coarse source enum.

Deploy after #1268 is in prod. Leaves actor dual-written for a later slice.

Refs #1267

@vercel

vercel Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Aug 7, 2026 6:01pm

Request Review

@sentry-junior sentry-junior Bot changed the title ref(chat): Stop writing nested routing into turn-session Redis ref(chat): Project turn sessions through Redis schemas Aug 7, 2026
@sentry-junior sentry-junior Bot changed the title ref(chat): Project turn sessions through Redis schemas ref(chat): Project turn sessions through explicit schemas Aug 7, 2026
@dcramer dcramer added the trigger-evals Run evals on a PR label Aug 7, 2026
@dcramer
dcramer marked this pull request as ready for review August 7, 2026 16:45
@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 7, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d776665. Configure here.

sentry-junior Bot and others added 7 commits August 7, 2026 17:59
SQL already owns destination and session source on resume. Drop those nested
contracts from new Redis turn-session records and summary indexes while still
dual-writing them into conversation metadata for SQL readers.

Refs #1267

Co-Authored-By: David Cramer <[email protected]>
Auth-pause records no longer keep source/destination in redis; assert the
materialized record omits those fields instead.

Refs #1267

Co-Authored-By: David Cramer <[email protected]>
Address review feedback: document projection strip behavior, drop storage-
prefixed schema names, keep source naming through the turn-session API, and
collapse optional-field ternary walls behind definedProps helpers.

Refs #1267

Co-Authored-By: David Cramer <[email protected]>
Abandon/fail no longer carry nested routing, so activity dual-writes must
not invent ConversationSource from surface alone. That path was overwriting
durable local source with internal via SQL coalesce.

Refs #1267

Co-Authored-By: David Cramer <[email protected]>
Agent invocation children are destinationless; recovery must not read
destination/source from the turn-session projection after those fields left
the record schema.

Refs #1267

Co-Authored-By: David Cramer <[email protected]>
ConversationStore gained createChild with agent invocations; the nested
routing dual-write mock still omitted it and broke workspace typecheck.

Refs #1267

Co-Authored-By: David Cramer <[email protected]>
@dcramer
dcramer merged commit 6f6661d into main Aug 7, 2026
37 checks passed
@dcramer
dcramer deleted the ref/turn-session-stop-nested-routing-writes branch August 7, 2026 18:16
dcramer added a commit that referenced this pull request Aug 7, 2026
Finish the nested-contract cutover for turn sessions after #1268/#1286.
Singular execution `actor` leaves the Redis turn-session projection and
summary indexes; resume rebuilds it from durable sources.

**Identity model (simplified)**
- Set `actor` first (who runs)
- Derive `credentialContext` with `credentialContextForActor(actor,
subject?)`
- They name the same principal except system runs with delegated
`subject` (scheduled/event-task creator tokens)
- resource-event identity owned by `resource-events/actor.ts`

**Resume**
1. caller routingContext (dispatch / OAuth already bound)
2. resource-event markers → system actor
3. Slack author + destination team

**Also**
- live resource-event turns set `routing.actor` to the system principal
- plugin `run.actor` = instruction provenance, else dispatch
- reply / dispatch / local runner use the same actor→credential
projection

**Checks**
- `tsc --noEmit` ✅
- continue-runner, agent-continue-slack, plugin-tasks ✅
- subscribed-message-behavior, agent-dispatch-work/recovery,
slack-runtime ✅

Refs #1267

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 7ea8ad4f Deployed Aug 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high trigger-evals Run evals on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant