Skip to content

fix(harness): archive daily memory after sandbox release - #4261

Merged
jujn merged 2 commits into
agentscope-ai:mainfrom
liu-657667:fix/harness-memory-archive-4257
Nov 28, 2026
Merged

jujn merged 2 commits into
agentscope-ai:mainfrom
liu-657667:fix/harness-memory-archive-4257

Conversation

@liu-657667

@liu-657667 liu-657667 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT, based on main at c1d4829003c374b202b99806099a60ec92fc0b28.

Description

Fixes #4257.

Daily-memory expiration still accesses the sandbox filesystem directly after the sandbox has been released. Follow the memory I/O approach introduced in #3113: route listing and archival moves through WorkspaceManager, using the authoritative host memory namespace for sandbox-backed paths and retaining native move behavior for persistent filesystem routes.

  • Preserve the calling user's runtime-data namespace, existing path normalization, replacement semantics and backend failure results.
  • Process only direct date-named ledgers, not archived or nested entries returned by recursive glob implementations.
  • Keep per-file best-effort maintenance and report an archive only after a successful move. Handle null/failed/empty listings without preventing consolidation.
  • Do not change sandbox release timing or lifecycle policy. Cross-backend host/persistent moves return a failure instead of copying/deleting between stores.

Validation

Tested locally with Java 21.0.10, Maven 3.9.6 and Docker 29.9.2; Java release target remains 17. All fixtures use synthetic records and temporary directories.

  • Red/green: the same real Docker release/maintenance test fails on original main (the expired source remains) and passes with this patch. It starts the upstream Alpine fixture, verifies synthetic upload/download, shuts down and clears the sandbox, then checks that maintenance archives Alice's expired ledger while Bob's remains unchanged. No host mounts or credentials are used. The test container was cleaned up.
  • 414 nonduplicated candidate test passes: 348 selected core/Harness ordinary tests, 65 selected cross-module ordinary tests, and 1 real Docker lifecycle test. The optional Docker test is skipped in the ordinary run and exercised separately.
  • New regression coverage includes retention boundary/zero-day retention, unavailable sandbox, user namespaces on both backends, repeated maintenance, existing targets, failure continuation, missing source, persistent routes, recursive listings and null/failed/empty lists.
  • 114/114 reactor modules built successfully with serial verify; tests, integration tests and frontend installation/build were explicitly skipped for that build. Javadoc/source packaging was also skipped. Earlier parallel attempts failed on dependency TLS/cache-lock errors; the serial retry passed without deleting Maven cache/locks.
  • Spotless checks and git diff --check passed.

Focused reproduction:

mvn -B -T1C -pl agentscope-harness -am test -Ddocker.it=false -Dtest=MemoryMaintenanceArchiveTest
mvn -B -T1C -pl agentscope-harness -am test -Ddocker.it=true '-Dtest=MemoryMaintenanceArchiveTest#archivesHostLedgerAfterRealDockerSandboxRelease'

Not a full test-matrix pass: external database/provider tests, credential-dependent integrations, the full security test matrix, frontend builds and production model/service flows were not run. Upstream Maven CI passed on the submitted head (Ubuntu and Windows); the CLA check also passed. Full raw logs are retained locally; they are not included because they contain local environment paths.

Checklist

  • Code has been formatted with mvn spotless:apply (Spotless checks passed).
  • All tests are passing (mvn test) — selected suites passed; full matrix not run.
  • Javadoc comments are complete and follow project conventions.
  • Related documentation has been updated (method Javadoc documents routing; no new user configuration).
  • Code is ready for review.

@CLAassistant

CLAassistant commented Nov 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@liu-657667
liu-657667 marked this pull request as ready for review November 20, 2026 02:46

@ningmao-hlyz ningmao-hlyz 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.

[P2] expireDailyFiles now accepts a ledger only when the listed path equals fromPath or its namespaced form, and the catch swallows everything without a log. A backend that spells paths differently (absolute, short 8.3 names, another namespace) silently stops archiving with no trace. A debug line on the drop path would make that visible.

[P2] moveMemoryFile fails when the source is gone. With several replicas archiving concurrently, the loser of the race logs a warning per file; treating "already archived" as skipped rather than failed reads cleaner in the log.

Log unexpected daily ledger paths at debug without relaxing namespace checks. Treat a failed move as already handled only when the source is gone and the authoritative archive exists; preserve warnings for other failures.

Verified on macOS with Java 21: 75 focused regressions and one real Docker sandbox release test passed. Captured DEBUG for an already archived ledger and WARN for a genuinely missing ledger.
@liu-657667

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I addressed both points in 3901b59. Unexpected ledger paths now produce a debug log without relaxing namespace checks. After a failed move, we skip it as already archived only if the source is gone and the archive file exists in the same namespace. Other failures still warn. On macOS with Java 21, 75 focused tests and the real Docker sandbox release test passed.

@ningmao-hlyz

Copy link
Copy Markdown
Contributor

LGTM

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

Labels

None yet

Projects

None yet

4 participants