Skip to content

test(session-test-source-discovery-inspection): write remote test attempt artifacts from shipped script sources - #4623

Merged
thymikee merged 2 commits into
callstack:mainfrom
mvanhorn:fix/4561-test-maestro-remote-source
Nov 17, 2026
Merged

thymikee merged 2 commits into
callstack:mainfrom
mvanhorn:fix/4561-test-maestro-remote-source

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A Maestro test sent to a daemon on another machine fails with ENOENT while the attempt directory is prepared, and the run never reaches a device. The missing path is the flow file from the caller, which that daemon host does not have. Refs #4561. Each attempt called prepareReplayTestAttemptArtifacts with only entry.path, and copyReplaySourceFile always used copyFileSync on that path. Source inspection had already read the shipped script, but inspectReplayTestSource returned only the path and manifest, so discoverReplayTestEntries never placed the text on the run entry.

inspectReplayTestSource now returns the script it read as sourceText, and discoverReplayTestEntries copies that field onto a run entry when the source has it. runSingleReplayTestAttempt passes entry.sourceText into prepareReplayTestAttemptArtifacts. When the value is a string, including an empty string, copyReplaySourceFile writes it to replay.ad and to the original flow filename and leaves the caller path unopened; when sourceText is absent, it still copies the local file.

Refs #4561

Test plan

npx --no-install vitest run on the source-inspection, artifact, attempt, and discovery test files passed 4 files and 35 tests.
Ran pnpm run test-app:install in a Linux container (localhost/osc-linux-node:22) for the agent-device inspectReplayTestSource change; it passed.
The changed test packages/replay-port/src/daemon-port/session-test-source-discovery.ts did not run here: no test runner for it was available.
The changed test packages/replay-test/src/index.ts did not run here: no test runner for it was available.
The changed test packages/replay-test/src/internal/session-test-artifacts.ts did not run here: no test runner for it was available.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

…empt artifacts from shipped script sources

inspectReplayTestSource now returns the script it read as sourceText,
and discoverReplayTestEntries copies that field onto a run entry when
the source has it. runSingleReplayTestAttempt passes entry.sourceText
into prepareReplayTestAttemptArtifacts. When the value is a string,
including an empty string, copyReplaySourceFile writes it to replay.ad
and to the original flow filename and leaves the caller path unopened;
when sourceText is absent, it still copies the local file.

Refs callstack#4561
@thymikee

Copy link
Copy Markdown
Member

The code at 6dc09a5 looks correct: remote test attempts now write replay.ad from the shipped script text instead of reading the entry path on the daemon host. CI is green (14 checks reported, none failing) and there are no conflicts. No live device run is needed, because this change only prepares attempt artifacts before any device dispatch. One design question remains before merge.

Could sourceText be required instead of optional, with the same data flow? If ReplayTestSource and the run entry always carry the text, copyReplaySourceFile can write it unconditionally. Then both fs.copyFileSync branches (session-test-artifacts.ts:143 and the one at line 158), the conditional spread in discovery and the "leaves it absent" test case can go. The only producer, inspectReplayTestSource, already always sets the text. So the copy branch is a leftover fallback that no production route reaches. It is also the primitive that let a remote client make the daemon copy a daemon-host file into the downloadable artifacts directory. A required field makes that read impossible to express, and the patch gets smaller.

Not blocking, and you can take or leave these: a route-level case next to test-command-remote-artifacts.test.ts could run runReplayTestCommand with replayScriptSources for a missing entry path and assert that attempt-1/replay.ad holds the shipped text, which would replace the hand-built entry in the attempt test. The PR title could be fix(replay-test): write remote test attempt artifacts from shipped flow sources, since this fixes production behavior. The test plan could shrink to the vitest run plus CI.

The PR says Refs #4561, so the issue should stay open: the second problem there, attempt sessions that cannot use the outer session's leased device, is not addressed here. Separately, an entry whose basename is .. gives the slug .. and moves the attempt directory up to the suite root. It stays inside the client-chosen --artifacts-dir, and this PR did not introduce it.

…rces

ReplayTestSource.sourceText and the run discovery entry's sourceText are
now required, and copyReplaySourceFile always writes that text into the
attempt directory. The fs.copyFileSync fallback that read the entry path
on the daemon host is gone, so a remote client can no longer make the
daemon copy a daemon-host file into the downloadable artifacts.
inspectReplayTestSource already sets the text on every source.

Refs callstack#4561
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Made sourceText required in 129752a: ReplayTestSource and the run entry always carry the text, and copyReplaySourceFile writes it unconditionally. Both copyFileSync branches, the conditional spread in discovery and the "leaves it absent" test case are gone. Agreed that #4561 stays open for the leased-device half.

@thymikee

Copy link
Copy Markdown
Member

The code at 129752a looks ready, and the earlier concern about missing evidence from 6dc09a5 is now resolved. Not blocking: the PR body still says discovery copies sourceText "when the source has it" and falls back to copying the local file, but this head made the field required and removed that fallback. You could replace that paragraph with: inspectReplayTestSource returns the shipped script as a required sourceText, discovery copies it onto every run entry, and copyReplaySourceFile writes it to replay.ad and the original flow filename without opening entry.path. You could also trim the test plan to the vitest run plus CI.

The Coverage job failed in the "Run coverage" step, and the log shows no failing test or vitest summary. Its output stops about 2.5 minutes before the step fails, which looks like a killed or hung worker rather than a test failure. The changed tests are in-process fs tests, and all other checks are green. The changed-line coverage gate was skipped. Please re-run the job. Coverage must pass at 129752a before merge, and if it fails again, the failing test or hang needs a look.

No live device run is needed, because the change only prepares attempt artifacts before any device dispatch.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 17, 2026
@thymikee
thymikee merged commit bfb67d5 into callstack:main Nov 17, 2026
12 of 13 checks passed
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Thanks for merging this, @thymikee. Remote Maestro runs should now get their attempt artifacts written from the shipped flow text instead of failing with ENOENT on a path only the caller has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants