fix(remote): drop a remote artifact whose name cannot be a file name

ZE
1h ago
+129-23

Summary

A remote daemon response that names a non-script artifact with a NUL byte in its destination crashed the client: resolveMaterializedArtifactPath built a path from artifact.fileName and the download's first fs call threw.

The client now checks the chosen destination before any filesystem work. A destination containing a NUL byte (from fileName or an echoed localPath), or a fileName that is not a string, drops that artifact. The response gains a typed droppedArtifacts: [{ field, reason: 'artifact_name_invalid' }] entry and a paired warnings line, mirroring scriptDeliveryFailure. droppedArtifacts is a client-owned field, so a daemon artifact cannot target it. The rest of the response, including the action's outcome, is kept. Script artifacts do not take this path, so they are unaffected.

Empty, . and .. names keep their existing fallback name. Wider peer-named-entry validation is left to #4669.

Files: 2 (packages/remote/src/daemon-artifacts.ts, one test).

Fixes #4661

Validation

Tested SHA: e99e7fecc7626a01d2a16ae5785dfe6f11d87f7e (base 6e18ea3).

  • pnpm exec vitest run --project unit-core packages/remote/src/__tests__/: the new test passes at head and fails at base (the NUL name crashes the client). This VM also shows 13 failures in the script-ancestry, script-download and script-hostile-daemon suites. They happen at base as well, so they come from the environment (tmp-directory ancestry) and not from this change.
  • capture/directory/test-command suites: 21/21 pass.
  • tsc over packages/remote/src (root tsconfig, noEmit): clean.
  • oxfmt --check on the changed files: clean.
  • oxlint and check:affected could not run here: oxlint crashes in its allocator on this small VM. CI is the authority for lint and the full gate.

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