Skip to content

fix(harness): route native journals to remote sessions backend - #4146

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
iluv7:fix/remote-session-storage-routing
Nov 16, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
iluv7:fix/remote-session-storage-routing

Conversation

@iluv7

@iluv7 iluv7 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Fixes #4140.

Native thread journals configured through RemoteFilesystemSpec were silently written to the local workspace. CompositeFilesystem.journalStorage() looked up agents/, which cannot match the more specific agents/<agentId>/sessions/ route.

Add an optional explicit journal backend to CompositeFilesystem and have RemoteFilesystemSpec pass its sessions backend. File routing and the existing two-argument constructor retain their behavior. Journals now use the remote sessions namespace and its configured isolation scope. Existing local journals are not migrated automatically.

Rebased onto main at a4306d63d and adapted to the journal API introduced by #4154: journalStorage, AtomicJournalStorage, ThreadKey, JournalEvent, and WorkspaceThreadJournalStore. Regression tests are in the journal package and the English and Chinese guides are updated under docs/dev.

Tests cover all four isolation scopes, recovery with a different local workspace, user isolation, history discovery, constructor compatibility, and propagation of unsupported-backend errors. The existing isolation example test disables background memory consolidation to avoid racing temporary workspace cleanup.

Validation after rebase:

  • mvn -B -T1C clean verify passed, including Spotless checks.
  • Harness tests: 1835 run, 0 failures, 0 errors, 36 skipped.
  • All 27 tests in the four targeted test classes passed.
  • Docs: npm test, npm run validate, and npm run broken-links passed.

The remote storage regression tests use InMemoryStore; no live MySQL integration was run.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@mintlify

mintlify Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 579de9d.

Approve preview

@aiyili aiyili 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.

Reviewed the full diff — this is exactly the right shape, and I can say that with unusual confidence: I independently arrived at the identical design in my own (now withdrawn) attempt — optional explicit backend constructor parameter on CompositeFilesystem, RemoteFilesystemSpec passing the sessions overlay it already builds, two-arg constructor behavior preserved. Convergent independent implementations are about as strong a design cross-validation as it gets.

Your version has three things mine didn't, all good:

  1. Fallback resolved at construction (sessionBackend != null ? sessionBackend : routeForPath("agents/").backend() in the constructor) rather than per-call — one resolution instead of a route scan on every sessionStorage call, same semantics since the route table is immutable after construction.
  2. Recovery and isolation regressions (RemoteSessionRoutingTest): persistence + recovery against a different local workspace + isolation scope coverage + history discovery — wider than the single store-namespace assertion I had planned, and the recovery-across-workspaces case is the one that actually bites multi-replica deployments.
  3. Docs updated in both languages — something I skipped.

One blocking-to-merge note: #4154 (a4306d63) renamed this API under you — sessionStorage(RuntimeContext) → journalStorage(RuntimeContext), io.agentscope.core.session.AtomicSessionStorage → io.agentscope.core.journal.AtomicJournalStorage. Your head b704ba0 predates the rename and the branch is now mergeable_state: dirty; as-is it won't compile against current main. The adaptation is mechanical (rename + import in CompositeFilesystem, OverlayFilesystem already delegates under the new name), but the rebase is required before review can conclude.

My PR #4193 is withdrawn in favor of this one — branch deleted. #4140 stays fixed here.

@iluv7
iluv7 force-pushed the fix/remote-session-storage-routing branch from b704ba0 to 579de9d Compare November 15, 2026 02:57
@iluv7 iluv7 changed the title fix(harness): route native session logs to remote sessions backend fix(harness): route native journals to remote sessions backend Nov 15, 2026
@iluv7

iluv7 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@aiyili Thanks for the review! Rebased onto the latest main (a4306d63d) and adapted to the journal API from #4154. The regression tests now use ThreadKey, JournalEvent, and WorkspaceThreadJournalStore, and the docs changes are under docs/dev.

@aiyili aiyili 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.

Re-reviewed the rebase — approving.

The #4154 adaptation is exactly right: journalStorage / io.agentscope.core.journal.AtomicJournalStorage rename applied through the composite and the spec, and the regression suite was rebuilt on the new primitives rather than mechanically renamed — RemoteJournalRoutingTest drives the real journal path (WorkspaceThreadJournalStore.open/commit with ThreadKey/JournalEvent) instead of asserting on raw storage, parameterizes all four IsolationScopes against their expected store namespaces, verifies recovery into a fresh local workspace, and asserts the local .agentscope-runtime journal never materializes on either side. That last assertion is the sharpest formulation of the original bug: in the pre-fix behavior the composite wrote journals to the local default backend, so any correct test must fail on Files.exists(<workspace>/.agentscope-runtime) — this one proves the negative on both workspaces.

For the record from my withdrawn attempt (#4193): independently-derived same design, so the approach here carries a second implementation's cross-validation. Nothing blocking from my side. The ci(harness): avoid background memory race commit is a sensible de-flake for the new parameterized test.

@jujn jujn added the P1 紧急不重要 label Nov 16, 2026
@jujn

jujn commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Assign to @aiyili (Review)

@jujn
jujn merged commit 5525ac1 into agentscope-ai:main Nov 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 紧急不重要

Projects

None yet

3 participants