fix(harness): route task records around the per-call sandbox proxy - #2803
Open
birdie7761 wants to merge 2 commits into
Open
fix(harness): route task records around the per-call sandbox proxy#2803birdie7761 wants to merge 2 commits into
birdie7761 wants to merge 2 commits into
Conversation
WorkspaceTaskRepository's heartbeat and orphan sweeper maintain task records from scheduler threads that run outside any agent call, where SandboxBackedFilesystem holds no live sandbox and every filesystem operation throws SandboxConfigurationException. As a result orphaned tasks were never marked FAILED and lastUpdatedAt was never refreshed under a sandbox-backed workspace; async tasks whose originating call had already ended could not even start. Task records are cross-call orchestration metadata, so WorkspaceManager now routes task-record IO (readTaskMap, persistTaskMap, and the glob in listAllTaskRecords) to the host workspace whenever the filesystem layer serving those paths is the per-call sandbox proxy - the same location used when no filesystem layer is configured. Explicit prefix routes (e.g. a persistent store mounted for agents/) are still respected via the new RoutedSandboxFilesystem.backendFor lookup. Fixes agentscope-ai#2743
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2743
Description
Under a sandbox-backed workspace,
WorkspaceTaskRepository's maintenance threads (ws-task-maint-*) cannot persist or read task records: the sandbox instance is injected intoSandboxBackedFilesystemonly during an agent call (SandboxLifecycleMiddleware.acquireForCall→releaseForCall), while the heartbeat and orphan sweeper run on a standalone scheduler withsandbox == null. Three failure modes, all reproduced by the new tests before the fix:SandboxException.SandboxConfigurationExceptionon every cycle (unguardedfilesystem.globinlistAllTaskRecords), so orphaned tasks are never marked FAILED;debuglevel (the throwing filesystem layer bypassesreadWithOverride's local-disk fallback), solastUpdatedAtis never refreshed;Task records are cross-call orchestration metadata and must not depend on a per-call sandbox instance.
WorkspaceManagernow routes task-record IO (readTaskMap,persistTaskMap, and the glob inlistAllTaskRecords) to the host workspace whenever the filesystem layer serving those paths is the per-call sandbox proxy — the same location used when no filesystem layer is configured:Two deliberate type boundaries:
SandboxBackedFilesystemspecifically, notAbstractSandboxFilesystem— the latter is also implemented by persistent filesystems (LocalFilesystemWithShell,OverlayFilesystem, …) that only exposeexecute();RoutedSandboxFilesystem.backendFor(new, delegating to the newCompositeFilesystem.filesystemFor) resolves the backend actually serving the path, so a persistent store mounted foragents/keeps serving task records unchanged — locked by a dedicated test.RemoteFilesystemSpecdeployments are unaffected (task records still route to shared storage; guarded by the existingWorkspaceTaskRepositoryTestcoverage).Test evidence (TDD red → green)
New
WorkspaceTaskRepositorySandboxMaintenanceTest(3 cases). The first two assemble the real classes — aSandboxBackedFilesystemthat never had a sandbox injected models the outside-a-call state:expected: <FAILED> but was: <RUNNING>lastUpdatedAttask supplier never startedagents/persistent route still serves task records (contract lock: no silent host-disk fallback, read-back and sweeper listing go through the routed backend)Regression: targeted task-repository family +
CompositeFilesystemTestgreen, full harness suite 836 tests / 0 failures (3 skipped pre-existing),spotless:checkclean.Checklist
mvn spotless:applymvn test)