Repository navigation
Conversation
MarketplaceStager.materializeIfChanged() created the staged directory before checking whether there was anything to write, and stageAll() then reported StageResult.Cached unconditionally. A skill from a lazy FileSystemSkillRepository publishes no in-memory resources, so it was advertised with a <files-root> pointing at a directory that stays permanently empty; inside a sandbox its support files were unreachable, with only a later tool error as the symptom. materializeIfChanged() now returns whether anything was staged and leaves no directory behind when there is nothing to write, and stageAll() reports StageResult.NONE in that case -- the same graceful-omission path the class already uses when no host workspace is available. Closes agentscope-ai#3373
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
materializeIfChanged() now returns whether anything was staged so stageAll() can report StageResult.NONE instead of Cached for a lazy FileSystemSkillRepository, which previously advertised a permanently empty <files-root>. Verified against the PR head: the new test passes at head and fails at HEAD~1 with Cached, and spotless is clean. Correct, narrow, and safe — no must-fix items.
Two things keep this from a straight approve:
createDirectoriesstill runs before the entry filter, so an all-rejected resource map creates the directory it just declared it would not stage (inline).- This PR competes with #3376, which fixes the same issue #3373 by staging support files from the repository's
originDirin the very same method. The two are different contracts — "hide the unusablefiles-root" versus "make the files actually reachable" — and they touch overlapping lines. Please don't land them blindly in either order; if #3376 merges, theNONEpath this PR adds stops being reachable for lazy repositories that have anoriginDir.
Verified
materializeIfChangedis private, so thevoid->booleanchange is invisible to callers;StageResultand bothstage()overloads are unchanged, andNONEwas already a legal return (:158, :255). ConsumersHarnessSkillMiddleware.java:300-301andShellPathPolicy.java:101need no update.- No cross-call cache is broken: the "if changed" behaviour is the per-file SHA in
writeIfChanged(:317-322) and unchanged files still enterexpected(:307), so repeat calls returnCached, notNONE. Resources appearing later stage immediately (FileSystemSkillRepository.java:194-205). - Thread safety: no new fields;
roots/retained/expectedare per-call locals andStageResult.NONEis an immutable shared record.concurrentCallsWithDifferentVisibleSetsDoNotThrowstill passes.
Review scope
Diff-reviewed plus a local test/build run in this checkout only; no CI was triggered from this review. MarketplaceStagerOrphanGcTest.unreadableEntryDoesNotFailStage fails in this container at both revisions because the process runs as root and ignores the stripped permissions — pre-existing and unrelated to this PR.
Automated review by github-manager-bot
| // staged skill apart from one whose content is unavailable. | ||
| return false; | ||
| } | ||
| Files.createDirectories(stagedDir); |
There was a problem hiding this comment.
[Warning] createDirectories runs here, before the entries are filtered (:293-304). When a non-empty resource map has every entry rejected (blank name / unsafe path / out-of-tree), the staged directory is still created, then stageAll reports StageResult.NONE (:244) without touching or retaining it — so an empty directory survives until orphan GC reclaims it, and the "no directory when nothing was staged" intent at :283 does not hold. Either move createDirectories after the filter (create lazily on the first accepted entry) or soften the comment. Not blocking: the reported result is now correct, only the on-disk side effect is over-eager.
| .get(SKILL_NAME); | ||
|
|
||
| assertInstanceOf(StageResult.None.class, result); | ||
| assertEquals(0, countRegularFiles(stagedDir(workspace))); |
There was a problem hiding this comment.
[Info] This helper counts regular files only (:110-117), so the test asserts the cache is file-free but never asserts the staged directory is absent. Reverting the createDirectories placement at :287 keeps this suite green. Two assertions would close the gap: (a) the directory does not exist in the all-empty case, and (b) an all-resources-filtered case (non-empty map, every entry rejected) also yields NONE.
| } | ||
| // Mark as live before GC runs: this is what stops a concurrent call — or | ||
| // another replica sharing the volume — from treating it as an orphan. | ||
| touch(stagedDir); |
There was a problem hiding this comment.
[Info] Skipping the touch/retain on the NONE path makes a directory staged by an earlier call orphan-GC eligible as soon as the resource map goes empty. That is probably what you want, but worth one sentence in the javadoc (:60-62) so nobody reads NONE as "my cached files are still there".
| // render a <files-root> for a directory that stays permanently empty, | ||
| // so report NONE and let shell-mode rendering omit the skill. | ||
| log.debug("Skill '{}' (source-ns={}) staged no resources", name, ns); | ||
| roots.put(name, StageResult.NONE); |
There was a problem hiding this comment.
[Info] Competing fix for the same issue: #3376 changes the same method in stageAll to stage support files from the repository's originDir instead of only reporting NONE. The two are not obviously incompatible, but they touch the same lines and should not land blindly in either order — #3374 makes an unusable files-root invisible, #3376 makes the files actually present. Maintainers should pick the intended contract; if both land, #3374's NONE path stops being reachable for lazy repositories that have an originDir. No action needed from the author.
materializeIfChanged() no longer creates the staged directory up front. The directory is created by writeIfChanged when the first entry survives the path-safety filter, so a non-empty map whose entries are all rejected also returns NONE without leaving a directory behind -- the contract the empty-map branch already documented. Also documents that NONE does not retain the skill, so a directory written by an earlier call becomes orphan-GC eligible, and covers both cases in the test: the empty-map case now asserts the staged directory is absent rather than merely file-free, and a new case drives an all-rejected map through stage(). Addresses review feedback on agentscope-ai#3374.
|
Thanks for the review — both points are addressed in
|
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Delta re-review of b3f93540..598eff20 (one new commit: stage no directory when every resource is filtered out). It fixes exactly the item the previous review held open, correctly and with a test that pins it. Approving on the code; the overlap with #3376 below is a maintainer call, not a defect here.
Verified at 598eff20
- Dropping the eager
Files.createDirectories(stagedDir)is safe:writeIfChangedcreates the parent directory on the first surviving entry, so a partially-rejected resource map still stages normally and a fully-rejected one leaves nothing behind. removeUnexpected(stagedDir, expected)can now be reached with a non-existentstagedDir. That is handled: the walk surfacesNoSuchFileException, which the existingcatch (IOException | UncheckedIOException)already covers, so the cleanup is a silent no-op rather than a stage failure —materializeIfChangedstill returnsfalseandstageAllreportsNONE.- Two
NONEsub-cases now differ, and both are fine: an empty resource map returns before the cleanup call, so a lazy repository never wipes what an earlier call staged; an all-rejected map runs the cleanup with an empty white-list, so stale files from a previous revision are dropped. The newNonejavadoc states the consequence (NONEdoes not mean "the files cached earlier are still there"), which is the right way to close it rather than adding another walk. - New test is sound against the real APIs: the 5-arg
AgentSkillconstructor exists, andStubRepoimplements every abstract member ofAgentSkillRepository(close()is adefault, so it is not required).stagedDir(workspace)mirrorsscopeRoot/<ns>/<name>withscopeSegment("session-1") == "session-1", andcountRegularFilesalready returns 0 for a missing directory, so both new assertions test what they claim. nonLazyRepositoryReportsCachedkeeps the partially-valid path pinned, so the fix cannot over-correct into dropping real staging.
Not blocking, still worth a maintainer decision
- Competes with #3376 (same issue #3373, same method, still open). This PR hides the unusable
<files-root>; #3376 makes the files reachable fromoriginDir. Both are defensible, but they touch overlapping lines and only one contract should win. If this one lands first, #3376 needs a rebase on thebooleansignature; if #3376 lands first, theNONEpath added here stops being reachable for lazy repositories that have anoriginDir. - CI was still pending on this HEAD at review time (
build ubuntu-latest/windows-latest),mergeStateStatus=blocked;license/claandCheck Module Syncare green. No build or test run was executed locally for this delta — the verification above is static, readingMarketplaceStager.javaand the test at598eff20.
Automated review by github-manager-bot
…rces (#3779) ## AgentScope-Java Version `2.1.0-SNAPSHOT`, based on upstream `main` at `16cb024ae62a10db2aedc2371f4d729194ffda82`. ## Description Closes #3777. An empty knowledge workspace currently receives instructions to browse a supposedly populated `knowledge/` tree. A catalog mixing documentation-only and scripted skills also receives an instruction claiming that every entry has `<files-root>`. These instructions can cause reads of paths that were never declared as available. Collect the knowledge body and file catalog once, then use that snapshot for both reference material and guidance. Omit Domain Knowledge guidance when both are empty; keep inline-only knowledge without promising a directory; include file navigation only when paths were collected, retaining the existing context-budget fallback. Limit skill file listing and execution guidance to entries that actually provide `<files-root>`; documentation-only skills remain discoverable and loadable. Add regressions for empty knowledge, inline-only references, remote catalogs, host fallback, failed reads, mixed skill catalogs and rootless body loading. Adapt the assertions to the current separation between SYSTEM instructions and REFERENCE material, while preserving memory behavior. Update the matching English and Chinese workspace/skill documentation. No POM, public API or staging implementation changes; #3374 already fixed the zero-resource staging result. Validation on Java 17/macOS: - `mvn -B -T1C -pl agentscope-harness -am -DskipTests install`: dependency/module installation passed locally. - `mvn -B -T1C -pl agentscope-harness -Dtest=WorkspaceContextMiddlewareSandboxPromptTest,WorkspaceContextMiddlewareMemoryPromptTest,SkillRuntimeTest test`: 44 tests, no failures/errors/skips. - `mvn -B -T1C -pl agentscope-harness test spotless:check`: 1,407 tests, no failures/errors, 32 skipped; formatting passed. - Docs: `npm test` (13 passed), `npm run validate` (432 pages, 584 redirects and build validation passed), `npm run broken-links` (no broken links). Revalidated after the final workspace prose update; no links changed. - `git diff --check`: passed. Follow-up (2026-10-27): Windows CI exposed two platform-specific assertions in the new catalog tests. Their expected paths used `/`, while the existing renderer uses native `Path` formatting. Build the expected catalog entries with `Path.of`, retaining checks for both reference content and exclusion from SYSTEM instructions. Re-ran the 44 focused tests and Spotless successfully on macOS. Full-repository `clean verify` now passes on both Ubuntu and Windows in [Java CI run 40464242577](https://github.com/agentscope-ai/agentscope-java/actions/runs/40464242577); documentation validation, License and Module Sync checks also pass. The full repository Maven build and tests passed in Ubuntu and Windows CI. Real sandbox/LLM execution was not run. Skipped tests are not counted as executed passes. ## Checklist - [x] Code has been formatted with `mvn spotless:apply` (Harness module). - [x] All repository tests are passing — full-repository `clean verify` passed in Ubuntu and Windows CI; local Harness results and skips are listed above. - [x] Javadoc comments remain applicable; no public API was added. - [x] Related documentation has been updated in English and Chinese. - [x] Code is ready for review.
…3374) Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs. (cherry picked from commit 44ec9e7) Backport-review-patch: 1e4bcfdc37479f930e10b349001e688070ef2f4b Constraint: No AgentScope Service or SDK migration Confidence: high Not-tested: Whole-repository verification pending after lane integration
AgentScope-Java Version
2.0.4-SNAPSHOT (main @ 01da9e6)
Description
Closes #3373.
MarketplaceStager.materializeIfChanged()created the staged directory and then returned earlywhen the resource map was empty, and
stageAll()reportedStageResult.Cachedunconditionally. Askill from a lazy
FileSystemSkillRepositorypublishes no in-memory resources by design, so it wasadvertised with a
<files-root>pointing at a directory that stays permanently empty: inside asandbox the skill's support files were unreachable, and the only symptom was a later tool error.
materializeIfChanged()now returns whether anything was staged, and leaves no directory behindwhen there is nothing to write.
stageAll()reportsStageResult.NONEin that case, whichShellPathPolicy.resolve()already maps to "no files-root" — the same graceful-omission path theclass uses when no host workspace is available.
Scope is deliberately minimal: this makes the failure non-silent. Falling back to a recursive copy
from
AgentSkill.getOriginDir(), the issue's other suggestion, would restore the missing files, butthat is a larger change and is left out.
How to test:
lazyRepositoryReportsNonefails onmainwithexpected: <StageResult.None> but was: <StageResult.Cached>and passes with the change;nonLazyRepositoryReportsCachedpins the non-lazy path so the fix cannot over-correct.Test evidence
mvn -T1 -pl agentscope-harness -am -Dtest=io.agentscope.harness.**.*Test teston this machine(OpenJDK 21) reports the same pre-existing baseline with and without the change:
main(unchanged)The +2 tests are the new ones and they pass; no new failure or error is introduced. The 214 errors
and the 1 failure are pre-existing on
mainin this environment and are unrelated to this change:they are
IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMakerfrom Mockito self-attaching its inline mock maker on JDK 21 (
Mockito is currently self-attaching to enable the inline-mock-maker. This will no longer work in future releases of the JDK). CI on JDK 17is the authoritative signal; flagging it here rather than ticking the box below unchecked.
Checklist
mvn spotless:applymvn test) — see the caveat above: +2 passing tests, no new failures;the module's pre-existing Mockito/JDK 21 errors remain