Skip to content

ref(chat): Write thread/channel scratch with Junior TTL - #1320

Merged
dcramer merged 8 commits into
mainfrom
ref/thread-channel-scratch-ttl
Aug 8, 2026
Merged

dcramer merged 8 commits into
mainfrom
ref/thread-channel-scratch-ttl

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

Route thread and channel scratch writes through Junior's state adapter so they use the 7-day retention policy instead of Chat SDK's hardcoded 30-day TTL.

Single write path

persistThreadRuntimeState, persistThreadStateById, and channel configuration saves merge through one TTL-owning helper. Reads remain on the injected Thread and Channel capabilities, preserving the chat runtime boundary; id-only continuation paths still use the explicit persisted-state readers.

Harness alignment

Slack fixtures use the same adapter keys as production, including across module reloads, so tests observe the state that runtime writes actually produce.

Refs #1267

Route thread and channel scratch through the Junior state adapter so
chat-sdk no longer hardcodes a 30-day hangover on those keys.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Aug 8, 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 8, 2026 4:07pm

Request Review

Route turn prep and factory readers through getPersistedThreadState, point
the Slack test harness at Junior's adapter TTL path, and pin the memory
adapter across vi.resetModules so fixture and production scratch agree.

Co-Authored-By: David Cramer <[email protected]>
Factory skip handlers resolve a concrete conversation id before loading
persisted thread scratch so prepare builds typecheck cleanly.
Coerce adapter null reads in the Slack harness, drop the process-global
memory pin, seed cross-runtime vision state before module reloads, and
point assistant-thread contract bots at Junior's shared adapter.

Co-Authored-By: David Cramer <[email protected]>
createTestThread now seeds Junior adapter scratch asynchronously. Make
createEvalThread/getThreadRecord async and drop the redundant setState
mirror that still assumed a sync TestThread.
@dcramer
dcramer marked this pull request as ready for review August 8, 2026 15:53
@github-actions github-actions Bot added the risk: high PR risk score: high label Aug 8, 2026
createTestThread now applies constructor state to the shared Junior adapter
instead of keeping leftover keys, so suites that reuse thread ids start clean.

@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 2481933. Configure here.

Empty createTestThread channel refs no longer wipe adapter channel config.
Channel ids are shared, so only explicit constructor channel state is applied.
@dcramer
dcramer merged commit b548647 into main Aug 8, 2026
42 checks passed
@dcramer
dcramer deleted the ref/thread-channel-scratch-ttl branch August 8, 2026 16:19
dcramer added a commit that referenced this pull request Aug 8, 2026
)

Stop mirroring rebuildable conversation stats into thread-state Redis
after the TTL unification in #1320.

**Thinner conversation scratch**

`buildConversationStatePatch` now writes only `schemaVersion`,
`processing`, and `vision`. Token/count stats and the Slack backfill
marker are no longer dual-written into Redis.

**SQL hydrate rebuilds authority**

`hydrateConversationMessages` rebuilds working-set stats from the
projected message/compaction history and marks backfill complete when
SQL already has transcript. Empty conversations stay unmarked so
first-turn Slack backfill can still run.

**Still later for scratch**

- vision cache durable home (or shorter-lived authority)
- pendingAuth / sandbox / artifacts thinning
- channel configuration ownership
- further TTL tightening once the bag is thinner

Refs #1267

<!-- junior-request-attribution:start -->
Requested by **U039RR91S**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1786205981.988819 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1786205981.988819)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1786205981.988819/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

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 — 133fc535 Deployed Aug 8, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant