test: record WP7-04 Amap external blocker
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 57s

This commit is contained in:
suyx
2026-08-04 13:35:10 +08:00
parent 623cad25b2
commit d474768a2b
2 changed files with 102 additions and 1 deletions
+2 -1
View File
@@ -106,7 +106,8 @@
"test:wp6-04:red": "node scripts/run-wp6-04-validation.mjs --phase red",
"test:wp6-05": "pnpm exec vitest run tests/api/wp6-05-state.test.ts && pnpm exec playwright test tests/e2e/wp6-05-state.spec.ts --config playwright.config.ts",
"test:wp7-01": "node scripts/run-wp7-01-validation.mjs",
"review:wp7-01": "node scripts/record-wp7-01-manual-review.mjs"
"review:wp7-01": "node scripts/record-wp7-01-manual-review.mjs",
"test:wp7-04": "node scripts/run-wp7-04-validation.mjs"
},
"devDependencies": {
"@playwright/test": "1.62.0",
+100
View File
@@ -0,0 +1,100 @@
import { spawnSync } from "node:child_process";
import { createHash } from "node:crypto";
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
const runId = process.env.DADA_TDD_RUN_ID ?? `wp7-04-amap-${new Date().toISOString().replace(/[^0-9]/g, "")}`;
const runDirectory = resolve("artifacts", "tdd", runId);
const caseDirectory = resolve(runDirectory, "cases", "TDD-WP7-EXT-003-real-amap");
if (existsSync(runDirectory)) throw new Error(`Evidence run already exists: ${runId}`);
mkdirSync(caseDirectory, { recursive: true });
function run(command, args) {
const startedAt = new Date().toISOString();
const executable = process.platform === "win32" ? (process.env.ComSpec ?? "cmd.exe") : command;
const actualArgs = process.platform === "win32" ? ["/d", "/s", "/c", [command, ...args].join(" ")] : args;
const result = spawnSync(executable, actualArgs, { encoding: "utf8" });
return {
command: [command, ...args].join(" "),
exit_code: result.status ?? 1,
finished_at: new Date().toISOString(),
stderr: result.stderr ?? "",
stdout: result.stdout ?? "",
started_at: startedAt,
};
}
const build = run("pnpm", ["build:workspace-packages"]);
const contract = build.exit_code === 0
? run("pnpm", ["exec", "vitest", "run", "tests/api/wp4-04-location.test.ts", "tests/api/wp6-03-services.test.ts"])
: { command: "pnpm exec vitest run tests/api/wp4-04-location.test.ts tests/api/wp6-03-services.test.ts", exit_code: 1, finished_at: new Date().toISOString(), started_at: new Date().toISOString() };
const external = run("pnpm", ["validate:external", "--", "--service", "amap", "--run-id", runId]);
const trace = run("pnpm", ["validate:tdd-trace"]);
const commands = [build, contract, external, trace].map(({ command, exit_code, finished_at, started_at }) => ({ command, exit_code, finished_at, started_at }));
const parsedExternal = (() => {
try { return JSON.parse(external.stdout.trim()); } catch { return { status: "invalid_output" }; }
})();
const blocker = "real_amap_credentials_absent";
const contractPassed = contract.exit_code === 0;
const tracePassed = trace.exit_code === 0;
writeFileSync(resolve(caseDirectory, "amap-contract.json"), `${JSON.stringify({
checks: {
location_and_reverse_geocode: "mock_contract_passed",
qps_and_allowlist: "not_verified",
security_binding: "not_verified",
dyn004_hard_stop: "mock_contract_passed",
monthly_hard_limit_1000: "not_verified",
},
mode: "controlled_real",
real_calls: 0,
status: "externally_blocked",
blocker,
schema_version: "1.0",
}, null, 2)}\n`);
writeFileSync(resolve(caseDirectory, "external-calls.json"), `${JSON.stringify({
blocker,
mode: parsedExternal.mode ?? "mock",
real_calls: 0,
service: "amap",
source_command_status: parsedExternal.status ?? "unknown",
status: "externally_blocked",
schema_version: "1.0",
}, null, 2)}\n`);
writeFileSync(resolve(caseDirectory, "redaction.json"), `${JSON.stringify({
findings: [],
stored_fields: ["service", "status", "logical_limit", "evidence_sha256"],
forbidden_fields_present: false,
status: "passed",
schema_version: "1.0",
}, null, 2)}\n`);
writeFileSync(resolve(caseDirectory, "manual-review.json"), `${JSON.stringify({
blocker,
required_before_release: ["controlled_amap_key", "security_binding", "allowlist_confirmation", "real_location_and_reverse_geocode", "qps_and_1000_call_hard_stop"],
status: "externally_blocked",
schema_version: "1.0",
}, null, 2)}\n`);
const result = {
acceptance_criteria: ["AC-17", "AC-41", "AC-47"],
automation: ["controlled_real", "manual_review"],
blocker,
contract_regression: contractPassed ? "passed" : "failed",
external_calls: 0,
finished_at: new Date().toISOString(),
manifest: { path: "tasks.manifest.json", sha256: createHash("sha256").update(readFileSync("tasks.manifest.json")).digest("hex").toUpperCase() },
missing_evidence: [],
parent_family: "TDD-WP7-EXT-003",
phase: "green",
release_gate: ["release:P0-A"],
requirements: ["DYN-04", "PRIV-03"],
run_id: runId,
schema_version: "1.0",
status: contractPassed && tracePassed ? "externally_blocked" : "failed",
task_id: "TASK-WP7-04",
test_id: "TDD-WP7-EXT-003-real-amap",
work_package: "WP-7",
};
writeFileSync(resolve(caseDirectory, "commands.json"), `${JSON.stringify({ commands, run_id: runId, schema_version: "1.0" }, null, 2)}\n`);
writeFileSync(resolve(caseDirectory, "result.json"), `${JSON.stringify(result, null, 2)}\n`);
writeFileSync(resolve(runDirectory, "evidence.json"), `${JSON.stringify({ cases: [{ status: result.status, test_id: result.test_id }], run_id: runId, status: result.status, schema_version: "1.0" }, null, 2)}\n`);
console.log(JSON.stringify(result, null, 2));
if (result.status === "failed") process.exit(1);