























@@ -1,3 +1,5 @@
1+// Subagent spawn attachment tests cover strict base64 decoding, attachment name
2+// validation, materialization paths, and cleanup after spawn failures.
13import fs from "node:fs";
24import os from "node:os";
35import path from "node:path";
@@ -26,8 +28,6 @@ beforeAll(async () => {
2628});
2729});
283029-// --- decodeStrictBase64 ---
30-3131describe("decodeStrictBase64", () => {
3232const maxBytes = 1024;
3333@@ -61,7 +61,8 @@ describe("decodeStrictBase64", () => {
61616262it("pre-decode oversize guard: encoded string > maxEncodedBytes * 2 returns null", () => {
6363const { decodeStrictBase64 } = subagentSpawnModule;
64-// maxEncodedBytes = ceil(1024/3)*4 = 1368; *2 = 2736
64+// Pre-decode guard rejects obviously oversized payloads before allocating
65+// the decoded buffer.
6566const oversized = "A".repeat(2737);
6667expect(decodeStrictBase64(oversized, maxBytes)).toBeNull();
6768});
@@ -82,8 +83,6 @@ describe("decodeStrictBase64", () => {
8283});
8384});
848585-// --- filename validation via spawnSubagentDirect ---
86-8786describe("spawnSubagentDirect filename validation", () => {
8887beforeEach(async () => {
8988workspaceDirOverride = fs.mkdtempSync(
@@ -241,6 +240,8 @@ describe("spawnSubagentDirect filename validation", () => {
241240});
242241243242it("removes materialized attachments when lineage patching fails", async () => {
243+// Attachments are created before the child session lineage patch; failures
244+// must delete both the child session and materialized files.
244245const calls: Array<{ method?: string; params?: Record<string, unknown> }> = [];
245246const store: Record<string, Record<string, unknown>> = {};
246247updateSessionStoreMock.mockImplementation(async (_storePath: unknown, mutator: unknown) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。