Skip to content

feat(dsh): implement nativeSessionFile via sessionPersistence.stat - #1107

Merged
stamp-build[bot] merged 3 commits into
mainfrom
agent/lookout/dsh-native-session-file
Nov 21, 2026
Merged

stamp-build[bot] merged 3 commits into
mainfrom
agent/lookout/dsh-native-session-file

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Lookout from open-agent-runtime opened this pull request through Stamp
View in Stamp →


Summary

Implement Session.nativeSessionFile() and declare nativeSessionFile: true on dshRuntime.sessionCapabilities using DSH's native sessionPersistence.stat(sessionId) service (snapshot.location.path), without constructing or guessing $DSH_HOME/sessions/<cwd key>/<id> paths.

Requested by Cindy in #core:#396 following the real Raft DSH transcript lookup gap (#oar-raft:4b887fbe).

Release notes

New

  • DSH Session.nativeSessionFile() and capability declaration. dshRuntime.sessionCapabilities() now declares nativeSessionFile: true, and opened DSH sessions expose nativeSessionFile() backed by DSH's native sessionPersistence.stat(id) (location.path). Each live call queries sessionPersistence.stat(id) so selected-generation changes are picked up rather than cached. It returns null before the durable log file materializes on disk, returns the absolute path once a regular file exists (verified via the shared sessionFileLocator), reports existing files immediately on resume before a new turn, and continues to work after session.dispose() even if nativeSessionFile() was not called before disposal.

Native verification (DSH 0.2.1-rc.5 and 0.2.2-rc.5)

Probed real DSH 0.2.2-rc.5 in an isolated DSH_HOME with aimock and verified the matching implementation in DSH 0.2.1-rc.5 (DSH_MINIMUM_VERSION):

  • ctx.get("sessionPersistence") implements the abstract SessionPersistence.stat(id) method (@deepseek-ai/dsh-session-persistence-jsonl).
  • Immediately after agents.create() (before the first turn materializes on disk), persistence.stat(sessionId) returns { header, revision } with no location field (nativeSessionFile() answers null).
  • After a turn commits (and on resume immediately after agents.resume()), persistence.stat(sessionId) returns location: { kind: "jsonl", path: "<abs path>/session.v4.jsonl.zstd" }, and statSync(path).isFile() is true.
  • After handle.dispose() and persistence.flush(), persistence.stat(sessionId) still returns the same location.path.

Call-site audit

Audited all nativeSessionFile declarations, implementations, wrappers, and tests across OAR:

  • Changed:
    • packages/oar/src/runtimes/dsh/bridge.ts: added sessionFileOf(sessionId) reading persistence.stat(sessionId)?.location?.path, exposed sessionFileStat / sessionFile in opened, added sessionFile control command, returned sessionFiles from dispose() after persistence.flush() (omitted when no handles were open so bare dispose still returns {}), and added "stat" to ready.services.sessionPersistence.
    • packages/oar/src/runtimes/dsh/session.ts: wired nativeSessionFile through the shared sessionFileLocator(sessionFilePath, credentials.redact) when opened.sessionFileStat === true (absent if sessionPersistence.stat is missing), re-querying sessionFile on every live call so generation changes are reflected, and keeping the last observed path (refreshed at turn_ended and dispose()) for post-disposal calls.
    • packages/oar/src/runtimes/dsh/index.ts: declared nativeSessionFile: true in dshRuntime.sessionCapabilities.
    • docs/spec/runtime-matrix.md and docs/runtimes/dsh.md: documented DSH's nativeSessionFile declaration and sessionPersistence.stat(id) mapping.
    • sea-trial/vendor/native-session-file.vendor.test.ts: enabled the shared fresh/resume/post-dispose vendor check for dsh-aimock.
    • tests/fixtures/fake-dsh.mjs and tests/dsh/native-session-file.test.ts: added unit tests for declaration, pre/post-turn and post-dispose lookup (including dispose without prior call), generation-change re-querying across turns, nonexistent reported path, missing stat method, and resumed sessions.
  • Unchanged (and why):
    • packages/oar/src/shared/native-session-file.ts (sessionFileLocator), packages/oar/src/shared/session-credentials.ts (nativeSessionFile credential guard), sea-trial/cases/session-capabilities.ts (session.capabilities-match-declaration): already handle any runtime exposing nativeSessionFile and declaring nativeSessionFile: true.
    • codex, pi (SDK & RPC): already implement and declare nativeSessionFile.
    • All other runtimes: unchanged; out of scope for #core:#396.

Verification

  • Pre-fix failures confirmed:
    • pnpm vitest run tests/dsh/native-session-file.test.ts: 4/4 failed before the implementation.
    • OAR_TEST=dsh-aimock OAR_DSH_BIN=/tmp/probe-dsh-file/prefix/bin/dsh pnpm vitest run sea-trial/vendor/native-session-file.vendor.test.ts: failed before the implementation (TypeError: missing native session file).
  • Post-fix passes:
    • OAR_TEST=dsh-aimock OAR_DSH_BIN=/tmp/probe-dsh-file/prefix/bin/dsh pnpm vitest run sea-trial/vendor/native-session-file.vendor.test.ts on real DSH 0.2.2-rc.5: passed (fresh, resume, filesystem identity match, post-dispose).
    • OAR_TEST=dsh-aimock OAR_DSH_BIN=/tmp/probe-dsh-file/prefix/bin/dsh pnpm exec tsx sea-trial/main.ts session.capabilities-match-declaration on real DSH 0.2.2-rc.5: passed.
    • CI=1 OAR_COMMUNITY_TESTS=1 pnpm run check && pnpm run build: passed (typecheck, oxlint 0 warnings / 0 errors, all unit + community tests, mock sea-trial, build).

@stamp-build
stamp-build Bot force-pushed the agent/lookout/dsh-native-session-file branch from 2083a93 to d1adcb3 Compare November 21, 2026 10:06
@stamp-build
stamp-build Bot merged commit 68814f7 into main Nov 21, 2026
25 checks passed
@stamp-build
stamp-build Bot deleted the agent/lookout/dsh-native-session-file branch November 21, 2026 10:25
@stamp-build stamp-build Bot mentioned this pull request Nov 21, 2026
stamp-build Bot added a commit that referenced this pull request Nov 21, 2026
<!-- stamp:review:v1 -->
<sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> (open-agent-runtime) opened via Stamp · <a href="https://stamp.build/review?receipt=prc_2ce5096582e05d834584b22aa9756a40"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View →</a></sup>

---
<!-- /stamp:review:v1 -->

## OAR 0.128.1

### Fixes

- **Pi moves to 1.6.0 as one family, with undici 8.12.4** (#1110, #1112, issue #1109). OAR 0.128.0 declared `@earendil-works/pi-ai` and `@earendil-works/pi-coding-agent` at `^1.5.2` while `pi-durable` and `chord` were `~1.5.2` and `undici` was pinned to Pi 1.5.2's exact `8.12.3`. Pi 1.6.0 (published 2026-11-20) therefore installed into fresh 0.128.0 hosts untested: a second `undici` copy, a failing resume reset of restored pending tools, and missing Qwen Token Plan credentials.
  - All four Pi packages are now `~1.6.0` in `@botiverse/oar` and `@botiverse/oar-cli`, and `undici` is `8.12.4`, the version Pi 1.6.0 pins, which carries the upstream security fixes. A fresh install has a single `undici` copy.
  - A manifest check fails if the Pi ranges differ, if one is not a tilde or exact version, or if OAR's `undici` differs from the exact `undici` Pi pins.
  - Resume no longer depends on a private side effect of Pi's `setActiveToolsByName`. OAR opens a resumed session with Pi's public `noTools: "builtin"`, which skips restoring the transcript's tool selection, then applies the current default tools. A resume whose registry has no activatable tools now opens with an empty loadout instead of failing with `UnsupportedOptionError("resume")`.
  - Pi credentials gain `QWEN_TOKEN_PLAN_TEAM_API_KEY`, `QWEN_TOKEN_PLAN_TEAM_CN_API_KEY`, `QWEN_TOKEN_PLAN_INDIVIDUAL_API_KEY` and `QWEN_TOKEN_PLAN_INDIVIDUAL_CN_API_KEY`.
  - Hosts that also depend on `@earendil-works/pi-durable` or `chord` need 1.6.x of those peers.

### New

- **DSH reports its session log file** (#1107). From DSH 0.2.2-alpha.2, `Session.nativeSessionFile()` returns the absolute path DSH reports from `sessionPersistence.stat(id).location.path` (typically `session.v4.jsonl.zstd`), `null` before the log is on disk, and the last known path after disposal. An explicit call drains DSH's 200 ms write batch with DSH's own `sessions.flush` before reading, so a just-finished turn is on disk. `sessionCapabilities` declares `nativeSessionFile: true` from 0.2.2-alpha.2, `false` below it (0.2.1-rc.5's `stat` has no location), and leaves it absent when the version is unreadable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Cindy <[email protected]>
Ancienttwo added a commit to Ancienttwo/oar that referenced this pull request Nov 21, 2026
Files: packages/oar/src/runtimes/dsh/bridge.ts

`runtimes/dsh/bridge.ts`. Invariant: the SDK exposes no native session file (botiverse#1107 nativeSessionFile is omitted), so the bridge reads none. `opened()` makes no `persistence.stat` call and reports no `sessionFile` or `sessionFileStat`, so the `dsh/opened` record names no host path and a rejecting stat cannot fail the open. `dispose()` flushes and reports no `sessionFiles`. `bridge-controls.ts` keeps upstream bytes; its `sessionFile` command stays unused.

Upstream: none (SDK omits native session files).
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.

0 participants