H-385: address CDP spike review blockers

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-08-20 22:53:26 +08:00
co-authored by multica-agent
parent 8095392f7f
commit 1330585ccc
5 changed files with 150 additions and 98 deletions
+7 -3
View File
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
import { randomUUID } from "node:crypto";
import test from "node:test";
import { boundedBody, redactHeaders, safeUrl } from "../scripts/m0-spike.mjs";
import { boundedBody, redactHeaders, safeUrl, shouldRetryStartup } from "../scripts/m0-spike.mjs";
test("export policy redacts credentials and bounds bodies", () => {
const sensitive = randomUUID();
@@ -14,6 +14,10 @@ test("export policy redacts credentials and bounds bodies", () => {
"set-cookie": "[REDACTED]",
});
assert.equal(safeUrl("https://example.test/path?token=secret"), "https://example.test/path?<redacted>");
assert.deepEqual(boundedBody("hello", false, 5), { state: "stored", bytes: 5, encoding: "utf8", text: "hello" });
assert.deepEqual(boundedBody("hello!", false, 5), { state: "omitted", reason: "size_limit", bytes: 6 });
assert.deepEqual(boundedBody(sensitive, false, 100), { state: "fetched", storage: "omitted", reason: "default_body_policy", bytes: Buffer.byteLength(sensitive) });
assert(!JSON.stringify(boundedBody(sensitive, false, 100)).includes(sensitive));
assert.deepEqual(boundedBody("hello!", false, 5), { state: "size_limit", storage: "omitted", bytes: 6 });
assert(shouldRetryStartup("Render process gone."));
assert(!shouldRetryStartup("Target closed."));
assert(!shouldRetryStartup(undefined));
});