Repository navigation
feat(ai-persistence, ai-harness): the session log is the session, with ownership, an input lane, workers, schedules, and snapshots - #1814
Conversation
…overrides, and agent results live in the log
# Conflicts: # packages/ai-harness/tests/observe.test.ts
… with abort on loss
… log input lane, host.submit, and no inbox, work claims, or leases
… wake when a busy session closes
…on logRecords, and the harness.gap event
…keeps ephemeral messages with the turn
… workers, snapshots, and the changesets for the log as the session
|
| Name | Type |
|---|---|
| @tanstack/ai-harness | Minor |
| @tanstack/ai | Minor |
| @tanstack/ai-mcp | Minor |
| @tanstack/ai-persistence | Minor |
| @tanstack/ai-acp | Patch |
| @tanstack/ai-code-mode | Patch |
| @tanstack/ai-harness-cli | Patch |
| @tanstack/ai-sandbox | Patch |
| @tanstack/ai-skills | Patch |
| @tanstack/ai-angular | Patch |
| @tanstack/ai-anthropic | Patch |
| @tanstack/ai-bedrock | Patch |
| @tanstack/ai-byteplus | Patch |
| @tanstack/ai-claude-code | Patch |
| @tanstack/ai-client | Patch |
| @tanstack/ai-cloudflare | Patch |
| @tanstack/ai-code-mode-snippets | Patch |
| @tanstack/ai-codex | Patch |
| @tanstack/ai-cohere | Patch |
| @tanstack/ai-compaction | Patch |
| @tanstack/ai-devtools-core | Patch |
| @tanstack/ai-durable-stream | Patch |
| @tanstack/ai-elevenlabs | Patch |
| @tanstack/ai-fal | Patch |
| @tanstack/ai-gemini | Patch |
| @tanstack/ai-grok-build | Patch |
| @tanstack/ai-grok | Patch |
| @tanstack/ai-groq | Patch |
| @tanstack/ai-llmgateway | Patch |
| @tanstack/ai-lovable | Patch |
| @tanstack/ai-memory | Patch |
| @tanstack/ai-mistral | Patch |
| @tanstack/ai-octane | Patch |
| @tanstack/ai-ollama | Patch |
| @tanstack/ai-ollaya | Patch |
| @tanstack/ai-openai | Patch |
| @tanstack/ai-opencode | Patch |
| @tanstack/ai-openrouter | Patch |
| @tanstack/ai-perplexity | Patch |
| @tanstack/ai-preact | Patch |
| @tanstack/ai-react | Patch |
| @tanstack/ai-reactor | Patch |
| @tanstack/ai-remix | Patch |
| @tanstack/ai-sandbox-cloudflare | Patch |
| @tanstack/ai-solid | Patch |
| @tanstack/ai-svelte | Patch |
| @tanstack/ai-typesafe | Patch |
| @tanstack/ai-vercel-gateway | Patch |
| @tanstack/ai-vertex | Patch |
| @tanstack/ai-vue | Patch |
| @tanstack/ai-worldlabs | Patch |
| @tanstack/openai-base | Patch |
| ag-ui | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
View your CI Pipeline Execution ↗ for commit d73bc86
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-cloudflare
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-compaction
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-harness
@tanstack/ai-harness-cli
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-e2b
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-llmgateway
@tanstack/ai-lovable
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-octane
@tanstack/ai-ollama
@tanstack/ai-ollaya
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-reactor
@tanstack/ai-remix
@tanstack/ai-sandbox
@tanstack/ai-sandbox-blaxel
@tanstack/ai-sandbox-boxd
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-e2b
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-railway
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-upstash-box
@tanstack/ai-sandbox-vercel
@tanstack/ai-skills
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-typesafe
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vertex
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/ai-worldlabs
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
@tanstack/svelte-ai-devtools
commit: |
…gainst their run, a schedule against its maker, and keep a same-host takeover and a lost log's inputs working
…eat/harness-log-session
…id line per event
Coverage✅ Coverage held across 31 compared package(s). Each package is measured twice in this job — on this PR and on its merge-base with
|
# Conflicts: # packages/ai-harness/src/http.ts # packages/ai-harness/tests/http-media.test.ts
The session log is now the session. Every host has a log, and every part of a thread's state is a record in it. So any server can open a thread, run its waiting inputs, and pick up the work of a server that stopped. This is PR 5 of the harness redesign stack for #1755. It targets #1813 (
feat/harness-lifecycle).🎯 Changes
memoryPersistence()has alog, and the harness needsstores.log. Message mode,recoverCrashedTurn,recoverInbox,findCrashedRuns, the session inbox, andtenantStoresare gone.InboxStore,WorkClaimStore, andLeaseStoreleave@tanstack/ai-persistence.harness:*andplugin:*metadata is gone.metadatais only for data wider than one thread, and it checks compare-and-set at the start.ctx.context.runhasepochandidempotencyKey(step, scope?).LogOwnedElsewhereErroris exported.host.submitadds an input with no open session.resumePendingand the newcreateHarnessWorker({ host, harnesses, concurrency, signal, pollMs })take logs that nobody runs: expired, offered, or due to wake.session.schedule({ at, input }),session.cancelSchedule({ scheduleId }), andstep.sleep({ name, ms })in durable tools.recoverable: truewhile it has work leaves a wake, so a worker takes the log at once.logIdoption is gone.session.logState()replaceshost.logState.log.snapshot.afterBytes(1 MB) orafterMs(5 minutes). A new host opens from the snapshot.lifecycle.retention.logRecords: 'since-snapshot'drops the records before it. A reader with an older cursor gets oneharness.gapevent, and the view reloads.Docs: a new
docs/harness/workers.md.durable-sessions.mdandshared-logs.mdare rewritten, and about 20 other harness and persistence pages are updated. Changesets are edited in place.Decisions made while building:
step.sleepwaits in the process. The host keeps the log while it waits. A host that stops leaves a wake, and a worker runs the step again at that time.stores.sessions, whichmemoryPersistence()has.harness.gapis aCUSTOMevent, not a new frame.useChat, the client, andbuild.tspass it through with no parser change.resumeAtis the cursor just before the first stored record, so a reconnect still gets that record.threadIdin the URL, becauseChatClient.joinRunsends only the run id.connect.mdsays so.host.submitandsession.scheduleare checked when they are sent. The sending host reads the run from the log and passes it toauthorizewith the full principal. An input for a run that the log does not have getsunknown_run. A user can cancel only a schedule that the user made, when the policy checksrun.principalId.POST runstream has anid:line per event, because every host has a log. A client that splits SSE blocks must read thedata:line of each block.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
Testing
Commands run:
ai-persistenceandai-harness.test:typesofai-persistence,ai-harness,ai-mcp,ai-acp,ai-harness-cli,ai-code-mode,ai-skills, andai-sandbox. All pass.--maxWorkers=2. Examples:fold-records,ownership,log-stores,input-lane,harness-worker,shared-log,agent-resume,snapshots,log, and the persistencememoryand conformance tests. All pass.test:oxlintofai-harness,test:sherif,pnpm test:docs,kiira checkon the changed docs pages, andoxfmt --checkon the changed files.Not run locally: the full suites, knip, E2E (including the new
harness-worker.spec.ts), and coverage. CI runs them.Manual test:
pnpm --dir packages/ai-harness exec vitest run tests/harness-worker.test.ts tests/input-lane.test.ts tests/snapshots.test.ts.tests/harness-worker.test.ts: host A closes withrecoverable: trueduring a turn, and a worker on host B finishes it.tests/shared-log.test.ts: a subagent and an agent chain write only to the root log.How this PR makes testing easy: the new test files pin each part:
fold-records,ownership,log-stores,input-lane,harness-worker, andsnapshots.testing/e2e/tests/harness-worker.spec.tsruns a submitted input and a schedule on a second host.Risk / rollback
High. This changes how the harness stores and recovers every thread, and it removes three stores from
@tanstack/ai-persistence. Neither the harness nor those stores are released yet, and all callers in this repo are moved. To undo, revert this PR.Public API change
Before
After