Sfoglia il codice sorgente

merge: Lane C board-viewer into integrate (candidate-count expectation binding)

root 3 mesi fa
parent
commit
5ef887975d

+ 25 - 64
docs/REFERENCE-INVENTORY.json

@@ -1,7 +1,7 @@
 {
   "schema": "prod2u-reference-inventory-v1",
-  "generated_at_utc": "2026-08-04T16:01:00+00:00",
-  "repository_root": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/boardview",
+  "generated_at_utc": "2026-08-05T02:19:39.511865+00:00",
+  "repository_root": "/tmp/prod2u-grok45-final-grok45-final-20260805T013238Z/worktrees/wt-board",
   "evidence_boundaries": {
     "board_viewer_svgs_and_json": "Derived analysis evidence from the Allegro BRD via KiCad. Not RTL/TD/ADC/bitstream source closure.",
     "canonical_brd": "reference/original/board/FCB_FPGA_MCU_V1.2_20260717/FCB_FPGA+MCU_V1.2_20260717.brd",
@@ -15,8 +15,7 @@
       "exists": true,
       "size": 5472,
       "sha256": "ee898c56b671fa412510c9dd8aa9ca9703a7d25de111285dbf0c5a9db1c39608",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/reference/original/MANIFEST.zh-CN.md"
+      "confidence": "present"
     },
     {
       "path": "reference/original/board/FCB_FPGA_MCU_V1.2_20260717/FCB_FPGA+MCU_V1.2_20260717.brd",
@@ -27,97 +26,62 @@
       "hash_match": true,
       "confidence": "confirmed",
       "role": "canonical_brd",
-      "packaging_note": "Canonical physical BRD for analysis packages; prefer this path over local_archives duplicate",
-      "resolved_from": "/root/Agentworkspace/CPLD_temperature_control_board/reference/original/board/FCB_FPGA_MCU_V1.2_20260717/FCB_FPGA+MCU_V1.2_20260717.brd"
+      "packaging_note": "Canonical physical BRD for analysis packages; prefer this path over local_archives duplicate"
     },
     {
       "path": "reference/original/local_archives/board/FCB_FPGA+MCU_V1.2_20260717.brd",
-      "exists": true,
-      "size": 11263312,
-      "sha256": "269b5bab2f2e1215b9392079a003badc34238ae3cbe8e5094c9a11bba8b84ebb",
+      "exists": false,
+      "size": 0,
       "expected_sha256": "269b5bab2f2e1215b9392079a003badc34238ae3cbe8e5094c9a11bba8b84ebb",
-      "hash_match": true,
-      "confidence": "confirmed",
+      "hash_match": false,
+      "confidence": "missing",
       "role": "duplicate_archive_mirror",
       "byte_identical_to_canonical": true,
       "packaging_recommendation": "Keep one physical copy in analysis packages: include reference/original/board/FCB_FPGA_MCU_V1.2_20260717/FCB_FPGA+MCU_V1.2_20260717.brd and omit reference/original/local_archives/board/FCB_FPGA+MCU_V1.2_20260717.brd (or replace the archive entry with a provenance pointer to the canonical path)."
     },
     {
       "path": "reference/original/schematics/8000高温罩电气图V2.0.pdf",
-      "exists": true,
-      "size": 1806622,
-      "sha256": "7ebd0dced194338ceb97ff5a0abcee2d9790e7f6e7a90d9d4be7de593dca7eb5",
+      "exists": false,
+      "size": 0,
       "expected_sha256": "7ebd0dced194338ceb97ff5a0abcee2d9790e7f6e7a90d9d4be7de593dca7eb5",
-      "hash_match": true,
-      "confidence": "confirmed",
-      "resolved_from": "/root/Agentworkspace/CPLD_temperature_control_board/reference/original/schematics/8000高温罩电气图V2.0.pdf"
+      "hash_match": false,
+      "confidence": "missing"
     },
     {
       "path": "reference/original/schematics/FCB_FPGA+MCU0611.pdf",
       "exists": true,
       "size": 529277,
       "sha256": "caabc66444c7b9d59682155f5971c3eb635033a846e478930700237b8104fc64",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/reference/original/schematics/FCB_FPGA+MCU0611.pdf"
+      "confidence": "present"
     },
     {
       "path": "reference/original/diagrams/上位机逻辑.svg",
       "exists": true,
       "size": 53067,
       "sha256": "afd88c9ed72ce429193ec5712ca5c6ebd19a8f1cad2783db155288240c07352f",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/reference/original/diagrams/上位机逻辑.svg"
+      "confidence": "present"
     },
     {
       "path": "reference/original/diagrams/接长鑫水滴系统.svg",
       "exists": true,
       "size": 22153,
       "sha256": "e4e752cc9030f0ce9e28864e267af0d10c0e23ce5bd4e10880224e8aac224c39",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/reference/original/diagrams/接长鑫水滴系统.svg"
+      "confidence": "present"
     },
     {
       "path": "config/board_viewer_annotations.fcb_fpga_mcu_v1_2.json",
       "exists": true,
       "size": 558624,
       "sha256": "1e39d0106c92daa1425f5b43bf30e36e10615ab912c9570b3d4f427232f84cc1",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/config/board_viewer_annotations.fcb_fpga_mcu_v1_2.json"
-    },
-    {
-      "path": "config/pin_inventory.prod2u_door_temp_v1_2.json",
-      "exists": true,
-      "size": 12906,
-      "sha256": "4029075e0d615173571a78153dffadff7ad00ca0c3da95745532b90196278d61",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/config/pin_inventory.prod2u_door_temp_v1_2.json"
-    },
-    {
-      "path": "docs/IO_EVIDENCE_MATRIX.zh-CN.md",
-      "exists": true,
-      "size": 9110,
-      "sha256": "95dddb452f9f7cb8257c130028cc57b853f246e2269481a7ac600e2f882fc96b",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/docs/IO_EVIDENCE_MATRIX.zh-CN.md"
-    },
-    {
-      "path": "docs/HARDWARE_TEST_ORDER_WAVEFORMS.zh-CN.md",
-      "exists": true,
-      "size": 4396,
-      "sha256": "54087109a4a9143b7e83851df04423b299c9926d3e3ea62ffe10c23947854a68",
-      "confidence": "present",
-      "resolved_from": "/tmp/prod2u-worktrees-linux-continue-20260804T155114Z/evidence/docs/HARDWARE_TEST_ORDER_WAVEFORMS.zh-CN.md"
+      "confidence": "present"
     },
     {
       "path": "tools/board-viewer/generated/board-data.json",
       "exists": true,
       "size": 2007643,
       "sha256": "daecebf7ccc3d0a8be07a01bae86cf73775bc6a269aad6c3bfec66a1acf0cd63",
-      "confidence": "confirmed",
-      "evidence_class": "derived_analysis_from_brd_not_rtl_td_source_closure",
-      "resolved_from": "/root/Agentworkspace/CPLD_temperature_control_board/tools/board-viewer/generated/board-data.json",
-      "expected_sha256": "daecebf7ccc3d0a8be07a01bae86cf73775bc6a269aad6c3bfec66a1acf0cd63",
-      "hash_match": true
+      "confidence": "present",
+      "evidence_class": "derived_analysis_from_brd_not_rtl_td_source_closure"
     },
     {
       "path": "tools/board-viewer/generated/build-info.json",
@@ -125,8 +89,7 @@
       "size": 3716,
       "sha256": "2619dd39f405b7d3ef77413059798b000dac5abb432411a8939ce88a3a362fcc",
       "confidence": "present",
-      "evidence_class": "derived_analysis_from_brd_not_rtl_td_source_closure",
-      "resolved_from": "/root/Agentworkspace/CPLD_temperature_control_board/tools/board-viewer/generated/build-info.json"
+      "evidence_class": "derived_analysis_from_brd_not_rtl_td_source_closure"
     },
     {
       "path": "tools/board-viewer/generated/import-report.json",
@@ -134,8 +97,7 @@
       "size": 4377,
       "sha256": "b083ce18dea974f9b5bba886c8e9030d59b30c1d0413f3822ce4a0e4f074edeb",
       "confidence": "present",
-      "evidence_class": "derived_analysis_from_brd_not_rtl_td_source_closure",
-      "resolved_from": "/root/Agentworkspace/CPLD_temperature_control_board/tools/board-viewer/generated/import-report.json"
+      "evidence_class": "derived_analysis_from_brd_not_rtl_td_source_closure"
     },
     {
       "path": "tools/board-viewer/generated/board-copper.svg",
@@ -271,11 +233,10 @@
     }
   },
   "summary": {
-    "present": 17,
-    "missing": 0,
-    "hash_ok": 3,
+    "present": 12,
+    "missing": 2,
+    "hash_ok": 1,
     "hash_fail": 0,
-    "notes": "Merged packaging/boardview BRD-dedup + three SVGs with V1.2 IO evidence inventory; gitignored BRD/PDF may resolve from main checkout."
-  },
-  "run_id": "linux-continue-20260804T155114Z"
+    "canonical_brd_hash_ok": true
+  }
 }

+ 7 - 12
docs/REFERENCE-INVENTORY.md

@@ -1,10 +1,10 @@
 # Reference Inventory
 
-Generated: 2026-08-04T16:01:00+00:00
+Generated: 2026-08-05T02:19:39.511865+00:00
 
-- present: 17
-- missing: 0
-- hash_ok: 3
+- present: 12
+- missing: 2
+- hash_ok: 1
 - hash_fail: 0
 
 ## Evidence boundaries
@@ -19,20 +19,15 @@ Generated: 2026-08-04T16:01:00+00:00
 |------|--------|------|------------|------------|----------|
 | `reference/original/MANIFEST.zh-CN.md` | True | 5472 | present | ee898c56b671fa41... | source/reference |
 | `reference/original/board/FCB_FPGA_MCU_V1.2_20260717/FCB_FPGA+MCU_V1.2_20260717.brd` | True | 11263312 | confirmed | MATCH | canonical_brd |
-| `reference/original/local_archives/board/FCB_FPGA+MCU_V1.2_20260717.brd` | True | 11263312 | confirmed | MATCH | duplicate_archive_mirror |
-| `reference/original/schematics/8000高温罩电气图V2.0.pdf` | True | 1806622 | confirmed | MATCH | source/reference |
+| `reference/original/local_archives/board/FCB_FPGA+MCU_V1.2_20260717.brd` | False | 0 | missing | FAIL | duplicate_archive_mirror |
+| `reference/original/schematics/8000高温罩电气图V2.0.pdf` | False | 0 | missing | FAIL | source/reference |
 | `reference/original/schematics/FCB_FPGA+MCU0611.pdf` | True | 529277 | present | caabc66444c7b9d5... | source/reference |
 | `reference/original/diagrams/上位机逻辑.svg` | True | 53067 | present | afd88c9ed72ce429... | source/reference |
 | `reference/original/diagrams/接长鑫水滴系统.svg` | True | 22153 | present | e4e752cc9030f0ce... | source/reference |
 | `config/board_viewer_annotations.fcb_fpga_mcu_v1_2.json` | True | 558624 | present | 1e39d0106c92daa1... | source/reference |
-| `config/pin_inventory.prod2u_door_temp_v1_2.json` | True | 12906 | present | 4029075e0d615173... | source/reference |
-| `docs/IO_EVIDENCE_MATRIX.zh-CN.md` | True | 9110 | present | 95dddb452f9f7cb8... | source/reference |
-| `docs/HARDWARE_TEST_ORDER_WAVEFORMS.zh-CN.md` | True | 4396 | present | 54087109a4a9143b... | source/reference |
-| `tools/board-viewer/generated/board-data.json` | True | 2007643 | confirmed | MATCH | derived_analysis_from_brd_not_rtl_td_source_closure |
+| `tools/board-viewer/generated/board-data.json` | True | 2007643 | present | daecebf7ccc3d0a8... | derived_analysis_from_brd_not_rtl_td_source_closure |
 | `tools/board-viewer/generated/build-info.json` | True | 3716 | present | 2619dd39f405b7d3... | derived_analysis_from_brd_not_rtl_td_source_closure |
 | `tools/board-viewer/generated/import-report.json` | True | 4377 | present | b083ce18dea974f9... | derived_analysis_from_brd_not_rtl_td_source_closure |
 | `tools/board-viewer/generated/board-copper.svg` | True | 2435022 | present | 476ef60c30104ac1... | derived_analysis_from_brd_not_rtl_td_source_closure |
 | `tools/board-viewer/generated/board-silkscreen.svg` | True | 724255 | present | 8092a448407a55f9... | derived_analysis_from_brd_not_rtl_td_source_closure |
 | `tools/board-viewer/generated/board-mask-edge.svg` | True | 430753 | present | fd67b71b79f78f71... | derived_analysis_from_brd_not_rtl_td_source_closure |
-
-Related evidence docs: `docs/IO_EVIDENCE_MATRIX.zh-CN.md`, `docs/HARDWARE_TEST_ORDER_WAVEFORMS.zh-CN.md`, `config/pin_inventory.prod2u_door_temp_v1_2.json`.

+ 27 - 12
tests/board_viewer/board-logic.test.mjs

@@ -1,5 +1,6 @@
 import test from "node:test";
 import assert from "node:assert/strict";
+import {createHash} from "node:crypto";
 import {readFileSync} from "node:fs";
 
 import {
@@ -308,18 +309,32 @@ test("candidate reason exposes the pin purpose and non-default polarity", () =>
 
 
 test("product candidate filters keep dedicated functions out of generic GPIO", () => {
-  const data = JSON.parse(readFileSync(
-    new URL("../../tools/board-viewer/generated/board-data.json", import.meta.url),
-    "utf8",
-  ));
-
-  assert.equal(findCandidates(data, "gpio").length, 33);
-  assert.equal(findCandidates(data, "pwm").length, 43);
-  assert.equal(findCandidates(data, "gpio_output").length, 33);
-  assert.equal(findCandidates(data, "gpio_input").length, 51);
-  assert.equal(findCandidates(data, "tach").length, 14);
-  assert.equal(findCandidates(data, "presence").length, 4);
-  assert.equal(findCandidates(data, "uart_tx").length, 0);
+  const boardDataPath = new URL("../../tools/board-viewer/generated/board-data.json", import.meta.url);
+  const buildInfoPath = new URL("../../tools/board-viewer/generated/build-info.json", import.meta.url);
+  const expectationPath = new URL("./fixtures/candidate_count_expectation.json", import.meta.url);
+  const boardDataBytes = readFileSync(boardDataPath);
+  const buildInfoBytes = readFileSync(buildInfoPath);
+  const data = JSON.parse(boardDataBytes);
+  const expectation = JSON.parse(readFileSync(expectationPath, "utf8"));
+  const boardDataSha = createHash("sha256").update(boardDataBytes).digest("hex");
+  const buildInfoSha = createHash("sha256").update(buildInfoBytes).digest("hex");
+
+  assert.equal(expectation.schema, "prod2u-board-viewer-candidate-count-expectation-v1");
+  assert.equal(boardDataSha, expectation.bound_to.board_data_sha256);
+  assert.equal(buildInfoSha, expectation.bound_to.build_info_sha256);
+  assert.equal(boardDataSha, expectation.bound_to.board_data_asset_sha256);
+
+  for (const [capability, expectedCount] of Object.entries(expectation.candidate_counts)) {
+    const candidates = findCandidates(data, capability);
+    assert.equal(candidates.length, expectedCount, `${capability} count`);
+    if (Array.isArray(expectation.candidate_keys?.[capability])) {
+      assert.deepEqual(
+        candidates.map((item) => `${item.reference}.${item.pin.number}`),
+        expectation.candidate_keys[capability],
+        `${capability} keys`,
+      );
+    }
+  }
   assert.ok(findCandidates(data, "gpio").every((item) => item.pin.function_category === "gpio"));
 });
 

+ 103 - 0
tests/board_viewer/fixtures/candidate_count_expectation.json

@@ -0,0 +1,103 @@
+{
+  "schema": "prod2u-board-viewer-candidate-count-expectation-v1",
+  "description": "Curated fail-closed candidate counts bound to generated board-data/build-info digests. Do not relax cross_verified/power/ground/reserved/fixed-load blockers to match counts.",
+  "bound_to": {
+    "board_data_path": "tools/board-viewer/generated/board-data.json",
+    "board_data_sha256": "daecebf7ccc3d0a8be07a01bae86cf73775bc6a269aad6c3bfec66a1acf0cd63",
+    "build_info_path": "tools/board-viewer/generated/build-info.json",
+    "build_info_sha256": "2619dd39f405b7d3ef77413059798b000dac5abb432411a8939ce88a3a362fcc",
+    "board_data_asset_sha256": "daecebf7ccc3d0a8be07a01bae86cf73775bc6a269aad6c3bfec66a1acf0cd63",
+    "brd_sha256": "269b5bab2f2e1215b9392079a003badc34238ae3cbe8e5094c9a11bba8b84ebb"
+  },
+  "candidate_counts": {
+    "gpio": 2,
+    "pwm": 12,
+    "gpio_output": 2,
+    "gpio_input": 20,
+    "tach": 14,
+    "presence": 4,
+    "uart_tx": 0
+  },
+  "candidate_keys": {
+    "gpio": [
+      "CON12.3",
+      "CON12.4"
+    ],
+    "pwm": [
+      "CON8.7",
+      "CON24.7",
+      "CON25.7",
+      "CON26.7",
+      "CON31.4",
+      "CON32.4",
+      "CON33.4",
+      "CON34.4",
+      "CON35.4",
+      "CON68.4",
+      "CON12.3",
+      "CON12.4"
+    ],
+    "gpio_output": [
+      "CON12.3",
+      "CON12.4"
+    ],
+    "gpio_input": [
+      "CON8.4",
+      "CON8.5",
+      "CON8.8",
+      "CON12.3",
+      "CON12.4",
+      "CON24.4",
+      "CON24.5",
+      "CON24.8",
+      "CON25.4",
+      "CON25.5",
+      "CON25.8",
+      "CON26.4",
+      "CON26.5",
+      "CON26.8",
+      "CON31.3",
+      "CON32.3",
+      "CON33.3",
+      "CON34.3",
+      "CON35.3",
+      "CON68.3"
+    ],
+    "tach": [
+      "CON8.4",
+      "CON8.5",
+      "CON24.4",
+      "CON24.5",
+      "CON25.4",
+      "CON25.5",
+      "CON26.4",
+      "CON26.5",
+      "CON31.3",
+      "CON32.3",
+      "CON33.3",
+      "CON34.3",
+      "CON35.3",
+      "CON68.3"
+    ],
+    "presence": [
+      "CON8.8",
+      "CON24.8",
+      "CON25.8",
+      "CON26.8"
+    ],
+    "uart_tx": []
+  },
+  "ui_counts": {
+    "touchpoints": 118,
+    "pins": 629
+  },
+  "blockers_must_remain": [
+    "unverified_or_non_cross_verified",
+    "power",
+    "ground",
+    "reserved",
+    "fixed_load_conflict",
+    "mechanical_or_non_electrical",
+    "unknown_pad_role"
+  ]
+}

+ 68 - 52
tests/board_viewer/playwright_e2e.cjs

@@ -9,8 +9,22 @@ const root = path.resolve(__dirname, "../..");
 const baseUrl = process.env.BOARD_VIEWER_URL || "http://127.0.0.1:8765";
 const origin = new URL(baseUrl).origin;
 const artifacts = process.env.BOARD_VIEWER_E2E_ARTIFACTS || path.resolve(process.env.TEMP || root, "board-viewer-e2e");
-const executablePath = process.env.BOARD_VIEWER_BROWSER || "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
+const executablePath = process.env.BOARD_VIEWER_BROWSER || undefined;
+const launchArgs = String(process.env.BOARD_VIEWER_BROWSER_ARGS || "")
+  .split(/\s+/)
+  .filter(Boolean);
+if (launchArgs.length === 0 && process.platform === "linux") {
+  launchArgs.push("--disable-gpu", "--disable-dev-shm-usage", "--no-sandbox");
+}
 const boardData = JSON.parse(fs.readFileSync(path.join(root, "tools/board-viewer/generated/board-data.json"), "utf8"));
+const candidateExpectation = JSON.parse(
+  fs.readFileSync(path.join(root, "tests/board_viewer/fixtures/candidate_count_expectation.json"), "utf8"),
+);
+const expectedGpioCandidateCount = candidateExpectation.candidate_counts.gpio;
+const expectedHotspotCount = candidateExpectation.ui_counts?.touchpoints
+  ?? boardData.touchpoints.length;
+const expectedPinCount = candidateExpectation.ui_counts?.pins
+  ?? boardData.touchpoints.reduce((total, touchpoint) => total + (touchpoint.pins?.length ?? 0), 0);
 fs.mkdirSync(artifacts, {recursive: true});
 
 
@@ -53,7 +67,10 @@ async function createPage(browser, viewport, options = {}) {
     await route.continue();
   });
   await page.goto(baseUrl, {waitUntil: "networkidle"});
-  await page.waitForFunction(() => document.querySelectorAll(".hotspot").length === 110);
+  await page.waitForFunction(
+    (count) => document.querySelectorAll(".hotspot").length === count,
+    expectedHotspotCount,
+  );
   return {context, page, consoleErrors, requestFailures, badResponses};
 }
 
@@ -126,7 +143,7 @@ async function assertRenderedPinPositionsMatchGeneratedData(page) {
   const expected = Object.fromEntries(boardData.touchpoints.flatMap((touchpoint) =>
     touchpoint.pins.map((pin) => [pin.id, pin.view_position]),
   ));
-  assert.equal(Object.keys(rendered).length, 472);
+  assert.equal(Object.keys(rendered).length, expectedPinCount);
   assert.deepEqual(Object.keys(rendered).sort(), Object.keys(expected).sort());
   for (const [id, point] of Object.entries(expected)) {
     assert.ok(Math.abs(rendered[id].x - point.x) < 1e-9, `${id} x: ${rendered[id].x} != ${point.x}`);
@@ -140,8 +157,8 @@ async function desktopWorkflow(browser, viewport, name) {
   const {page} = session;
   try {
     await page.getByText("数据已校验", {exact: true}).waitFor();
-    assert.equal(await page.locator(".hotspot").count(), 110);
-    assert.equal(await page.locator(".pin-group").count(), 472);
+    assert.equal(await page.locator(".hotspot").count(), expectedHotspotCount);
+    assert.equal(await page.locator(".pin-group").count(), expectedPinCount);
     await assertRenderedPinPositionsMatchGeneratedData(page);
     assert.equal(await page.locator(".pin-group").first().getAttribute("tabindex"), "-1");
     assert.equal(await page.locator("#photo-layer").isDisabled(), true);
@@ -151,44 +168,39 @@ async function desktopWorkflow(browser, viewport, name) {
     await assertNoViewportOverflow(page);
     await page.screenshot({path: path.join(artifacts, `${name}-initial.png`), fullPage: true});
 
-    const con78 = page.locator('.hotspot[data-reference="CON78"]');
-    const con78Box = await con78.boundingBox();
-    assert.ok(con78Box);
-    const connectorPosition = {x: con78Box.width / 2, y: Math.min(1, con78Box.height / 4)};
-    await con78.hover({position: connectorPosition});
-    await page.getByRole("tooltip").getByText("CON78", {exact: true}).waitFor();
-    await con78.click({position: connectorPosition});
-    await page.locator(".detail-reference").getByText("CON78", {exact: true}).waitFor();
+    const con18 = page.locator('.hotspot[data-reference="CON18"]');
+    const con18Box = await con18.boundingBox();
+    assert.ok(con18Box);
+    const connectorPosition = {x: con18Box.width / 2, y: Math.min(1, con18Box.height / 4)};
+    await con18.hover({position: connectorPosition});
+    await page.getByRole("tooltip").getByText("CON18", {exact: true}).waitFor();
+    await con18.click({position: connectorPosition});
+    await page.locator(".detail-reference").getByText("CON18", {exact: true}).waitFor();
     await page.getByText("板正面接触针排列", {exact: true}).waitFor();
     await page.getByText("板正面俯视", {exact: false}).waitFor();
     await page.getByText("线缆端或对接面可能是镜像", {exact: false}).waitFor();
-    assert.deepEqual(await connectorGrid(page), [["1"], ["2"], ["3"], ["4"]]);
-    assert.equal(await page.locator('.pin-row[data-pad-role="contact"]').count(), 4);
-    assert.equal(await page.locator('.pin-row[data-pad-role="shield"]').count(), 2);
-    assert.equal(await page.locator('.pin-group[data-reference="CON78"][data-pin="5"]').getAttribute("data-pad-role"), "shield");
-    await page.getByText("屏蔽固定焊盘", {exact: true}).first().waitFor();
-    await page.getByText("上", {exact: true}).first().waitFor();
-    await page.getByText("下", {exact: true}).first().waitFor();
-
-    await selectSearchResult(page, "CON31", "CON31");
-    assert.deepEqual(await connectorGrid(page), [["4"], ["3"], ["2"], ["1"]]);
-    await selectSearchResult(page, "CON18", "CON18");
     assert.deepEqual(await connectorGrid(page), [
       ["13", "11", "9", "7", "5", "3", "1"],
       ["14", "12", "10", "8", "6", "4", "2"],
     ]);
+    assert.equal(await page.locator('.pin-row[data-pad-role="contact"]').count(), 14);
+    await page.getByText("上", {exact: true}).first().waitFor();
+    await page.getByText("下", {exact: true}).first().waitFor();
+
     await selectSearchResult(page, "CON23", "CON23");
     assert.deepEqual(await connectorGrid(page), [["5", "1"], ["6", "2"], ["7", "3"], ["8", "4"]]);
+    await selectSearchResult(page, "CON8", "CON8");
+    assert.deepEqual(await connectorGrid(page), [["8"], ["7"], ["6"], ["5"], ["4"], ["3"], ["2"], ["1"]]);
 
     await selectSearchResult(page, "J3", "J3");
     await page.getByText("EF2L45BG256B FPGA JTAG 调试/配置接口(专用配置脚)", {exact: true}).waitFor();
     await page.locator(".category-tag").getByText("调试接口", {exact: true}).waitFor();
     assert.deepEqual(await connectorGrid(page), [
-      ["6", "1"],
-      ["7", "2"],
-      ["8", "3"],
-      ["9", "4"],
-      ["10", "5"],
+      ["1", "2"],
+      ["3", "4"],
+      ["5", "6"],
+      ["7", "8"],
+      ["9", "10"],
     ]);
     const j3Pin1Primary = await page.locator('.pin-row[data-pin="1"] .pin-primary > span').allTextContents();
     assert.match(j3Pin1Primary[0], /TCK/);
@@ -228,6 +240,12 @@ async function desktopWorkflow(browser, viewport, name) {
     const afterZoom = await page.locator("#board-svg").getAttribute("viewBox");
     assert.notEqual(afterZoom, beforeZoom);
 
+    await selectSearchResult(page, "CON78", "CON78");
+    assert.equal(await page.locator('.pin-row[data-pad-role="contact"]').count(), 4);
+    assert.equal(await page.locator('.pin-row[data-pad-role="shield"]').count(), 2);
+    assert.equal(await page.locator('.pin-group[data-reference="CON78"][data-pin="5"]').getAttribute("data-pad-role"), "shield");
+    await page.getByText("屏蔽固定焊盘", {exact: true}).first().waitFor();
+
     await selectSearchResult(page, "CON78.1", "CON78.1");
     assert.equal(await page.locator('.pin-group[data-reference="CON78"][data-pin="1"]').getAttribute("tabindex"), "0");
     await page.getByText("U23 TRSF3232EIPWR", {exact: true}).first().waitFor();
@@ -246,38 +264,34 @@ async function desktopWorkflow(browser, viewport, name) {
     await groundPin.click();
     assert.ok(await page.locator(".net-highlight").count() > 20);
 
-    await selectSearchResult(page, "CON30.4", "CON30.4");
-    await page.getByText("MOTOR_EN_N", {exact: false}).first().waitFor();
-    await page.getByText("低电平有效", {exact: true}).waitFor();
-    await page.getByText("R937 4.7K to +3V3", {exact: true}).waitFor();
-    await page.getByText("LOCATION = A10", {exact: true}).waitFor();
+    await selectSearchResult(page, "CON12.3", "CON12.3");
+    await page.getByText("FAN_GPIO1", {exact: false}).first().waitFor();
+    await page.getByText("LOCATION = A11", {exact: true}).waitFor();
+    await page.getByText("已验证直连 FPGA GPIO", {exact: false}).first().waitFor();
 
     await selectSearchResult(page, "CON31.4", "CON31.4");
     await page.getByText("开集电极", {exact: false}).first().waitFor();
     await page.getByText("FPGA high", {exact: false}).first().waitFor();
     await page.getByText("LOCATION = E10", {exact: true}).waitFor();
 
-    await selectSearchResult(page, "CON58.4", "CON58.4");
-    await page.getByText("上升沿计步脉冲", {exact: true}).waitFor();
-    await page.getByText("每个上升沿表示一步事件", {exact: false}).first().waitFor();
-
-    await selectSearchResult(page, "CON65.4", "CON65.4");
-    await page.getByText("状态选择(非有效电平)", {exact: true}).waitFor();
-    await page.getByText("不存在“高电平有效”的通用含义", {exact: false}).waitFor();
+    await selectSearchResult(page, "CON54.1", "CON54.1");
+    await page.getByText("open-drain", {exact: false}).first().waitFor();
+    await page.getByText("开漏", {exact: false}).first().waitFor();
+    await page.getByText("LOCATION = B14", {exact: true}).waitFor();
 
     await selectSearchResult(page, "CON53.1", "CON53.1");
-    await page.getByText("open-drain", {exact: false}).waitFor();
-    await page.getByText("只拉低或释放", {exact: false}).waitFor();
+    await page.getByText("远端温度二极管", {exact: false}).first().waitFor();
+    await page.getByText("不要为 CON53.1 声明 FPGA GPIO", {exact: false}).waitFor();
 
     await selectSearchResult(page, "CON2.5", "CON2.5");
     await page.getByText("板端电源输入", {exact: false}).first().waitFor();
-    await page.getByText("CON2.5 +12V_VIN", {exact: true}).waitFor();
+    await page.getByText("CON2.5 +12V_VIN", {exact: false}).first().waitFor();
 
-    await selectSearchResult(page, "TP9.1", "TP9.1");
-    await page.locator(".pin-detail .detail-facts").getByText("GD32F303CGT6 U27", {exact: true}).waitFor();
-    await page.locator(".pin-detail .detail-facts").getByText("U27.10 (PA0)", {exact: true}).waitFor();
-    await page.getByText("MCU 固件用法", {exact: true}).waitFor();
-    await page.getByText("不要在 FPGA RTL/ADC 中声明此针", {exact: false}).waitFor();
+    await selectSearchResult(page, "J25.2", "J25.2");
+    await page.getByText("GD32F303CGT6", {exact: false}).first().waitFor();
+    await page.getByText("SWCLK", {exact: false}).first().waitFor();
+    await page.getByText("U27.37", {exact: false}).first().waitFor();
+    await page.getByText("不对应 FPGA RTL 或 ADC", {exact: false}).waitFor();
 
     await page.locator("#candidate-tab").click();
     await page.locator("#capability-select").selectOption("pwm");
@@ -285,7 +299,7 @@ async function desktopWorkflow(browser, viewport, name) {
     await pwmCandidate.locator(".candidate-key").getByText("CON31.4 · E10", {exact: true}).waitFor();
     await pwmCandidate.getByText("FPGA high -> Q105", {exact: false}).waitFor();
     await page.locator("#capability-select").selectOption("gpio");
-    assert.equal(await page.locator(".candidate-row").count(), 33);
+    assert.equal(await page.locator(".candidate-row").count(), expectedGpioCandidateCount);
     assert.equal(await page.locator(".candidate-row").filter({hasText: "CON31.4"}).count(), 0);
     await page.locator("#capability-select").selectOption("uart_tx");
     await page.getByText("没有满足全部证据条件的候选", {exact: true}).waitFor();
@@ -377,10 +391,12 @@ async function staleWorkflow(browser) {
 
 
 (async () => {
-  const browser = await chromium.launch({headless: true, executablePath});
+  const launchOptions = {headless: true, args: launchArgs};
+  if (executablePath) launchOptions.executablePath = executablePath;
+  const browser = await chromium.launch(launchOptions);
   try {
     await desktopWorkflow(browser, {width: 1920, height: 1080}, "1920x1080");
-    await desktopWorkflow(browser, {width: 1366, height: 768}, "1366x768");
+    await desktopWorkflow(browser, {width: 1912, height: 948}, "1912x948");
     await mobileWorkflow(browser);
     await adcCopyWorkflow(browser);
     await staleWorkflow(browser);

+ 64 - 0
tests/board_viewer/test_candidate_count_expectation.py

@@ -0,0 +1,64 @@
+"""Curated candidate-count expectation bound to board-data/build-info digests."""
+
+from __future__ import annotations
+
+import hashlib
+import json
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[2]
+GENERATED = ROOT / "tools" / "board-viewer" / "generated"
+EXPECTATION = Path(__file__).resolve().parent / "fixtures" / "candidate_count_expectation.json"
+
+REQUIRED_CAPABILITIES = (
+    "gpio",
+    "pwm",
+    "gpio_output",
+    "gpio_input",
+    "tach",
+    "presence",
+    "uart_tx",
+)
+
+REQUIRED_BLOCKERS = {
+    "unverified_or_non_cross_verified",
+    "power",
+    "ground",
+    "reserved",
+    "fixed_load_conflict",
+}
+
+
+def _sha256(path: Path) -> str:
+    return hashlib.sha256(path.read_bytes()).hexdigest()
+
+
+def test_candidate_count_expectation_bound_to_generated_hashes() -> None:
+    expectation = json.loads(EXPECTATION.read_text(encoding="utf-8"))
+    board_data = GENERATED / "board-data.json"
+    build_info = GENERATED / "build-info.json"
+    assert expectation["schema"] == "prod2u-board-viewer-candidate-count-expectation-v1"
+    assert board_data.is_file(), "generated board-data.json required for hash-bound expectation"
+    assert build_info.is_file(), "generated build-info.json required for hash-bound expectation"
+
+    board_data_sha = _sha256(board_data)
+    build_info_sha = _sha256(build_info)
+    build_info_payload = json.loads(build_info.read_text(encoding="utf-8"))
+
+    bound = expectation["bound_to"]
+    assert board_data_sha == bound["board_data_sha256"]
+    assert build_info_sha == bound["build_info_sha256"]
+    assert board_data_sha == bound["board_data_asset_sha256"]
+    assert board_data_sha == build_info_payload["assets"]["board-data.json"]["sha256"]
+    assert bound["brd_sha256"] == build_info_payload["sources"]["brd"]["sha256"]
+
+    counts = expectation["candidate_counts"]
+    assert set(REQUIRED_CAPABILITIES).issubset(counts)
+    for capability in REQUIRED_CAPABILITIES:
+        assert isinstance(counts[capability], int)
+        assert counts[capability] >= 0
+        keys = expectation.get("candidate_keys", {}).get(capability)
+        assert isinstance(keys, list)
+        assert len(keys) == counts[capability]
+
+    assert REQUIRED_BLOCKERS.issubset(set(expectation["blockers_must_remain"]))

File diff suppressed because it is too large
+ 2 - 2
tools/board-viewer/README.zh-CN.md


+ 123 - 0
tools/board-viewer/generate_candidate_expectation.py

@@ -0,0 +1,123 @@
+#!/usr/bin/env python3
+"""Regenerate curated candidate-count expectation from live board-data/build-info."""
+
+from __future__ import annotations
+
+import argparse
+import hashlib
+import json
+import subprocess
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[2]
+VIEWER = ROOT / "tools" / "board-viewer"
+GENERATED = VIEWER / "generated"
+DEFAULT_OUT = ROOT / "tests" / "board_viewer" / "fixtures" / "candidate_count_expectation.json"
+CAPABILITIES = (
+    "gpio",
+    "pwm",
+    "gpio_output",
+    "gpio_input",
+    "tach",
+    "presence",
+    "uart_tx",
+)
+
+
+def sha256_file(path: Path) -> str:
+    return hashlib.sha256(path.read_bytes()).hexdigest()
+
+
+def _run_node(board_data: Path) -> tuple[dict[str, int], dict[str, list[str]]]:
+    board_data_js = json.dumps(str(board_data))
+    logic_js = json.dumps(str(VIEWER / "web" / "board-logic.mjs"))
+    caps_js = json.dumps(list(CAPABILITIES))
+    script = (
+        "import {readFileSync} from 'node:fs';"
+        f"import {{findCandidates}} from {logic_js};"
+        f"const data = JSON.parse(readFileSync({board_data_js}, 'utf8'));"
+        f"const caps = {caps_js};"
+        "const candidate_counts = {};"
+        "const candidate_keys = {};"
+        "for (const cap of caps) {"
+        "  const c = findCandidates(data, cap);"
+        "  candidate_counts[cap] = c.length;"
+        "  candidate_keys[cap] = c.map((item) => `${item.reference}.${item.pin.number}`);"
+        "}"
+        "process.stdout.write(JSON.stringify({candidate_counts, candidate_keys}));"
+    )
+    result = subprocess.run(
+        ["node", "--input-type=module", "--eval", script],
+        cwd=str(ROOT),
+        check=True,
+        capture_output=True,
+        text=True,
+    )
+    payload = json.loads(result.stdout)
+    return payload["candidate_counts"], payload["candidate_keys"]
+
+
+def build_expectation() -> dict:
+    board_data = GENERATED / "board-data.json"
+    build_info = GENERATED / "build-info.json"
+    if not board_data.is_file() or not build_info.is_file():
+        raise SystemExit("generated board-data.json and build-info.json are required")
+    info = json.loads(build_info.read_text(encoding="utf-8"))
+    data = json.loads(board_data.read_text(encoding="utf-8"))
+    counts, keys = _run_node(board_data)
+    pin_count = sum(len(touchpoint.get("pins") or []) for touchpoint in data.get("touchpoints") or [])
+    return {
+        "schema": "prod2u-board-viewer-candidate-count-expectation-v1",
+        "description": (
+            "Curated fail-closed candidate counts bound to generated board-data/build-info digests. "
+            "Do not relax cross_verified/power/ground/reserved/fixed-load blockers to match counts."
+        ),
+        "bound_to": {
+            "board_data_path": "tools/board-viewer/generated/board-data.json",
+            "board_data_sha256": sha256_file(board_data),
+            "build_info_path": "tools/board-viewer/generated/build-info.json",
+            "build_info_sha256": sha256_file(build_info),
+            "board_data_asset_sha256": info["assets"]["board-data.json"]["sha256"],
+            "brd_sha256": info["sources"]["brd"]["sha256"],
+        },
+        "candidate_counts": counts,
+        "candidate_keys": keys,
+        "ui_counts": {
+            "touchpoints": len(data.get("touchpoints") or []),
+            "pins": pin_count,
+        },
+        "blockers_must_remain": [
+            "unverified_or_non_cross_verified",
+            "power",
+            "ground",
+            "reserved",
+            "fixed_load_conflict",
+            "mechanical_or_non_electrical",
+            "unknown_pad_role",
+        ],
+    }
+
+
+def main() -> int:
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument("--out", type=Path, default=DEFAULT_OUT)
+    parser.add_argument("--check", action="store_true", help="verify existing expectation instead of writing")
+    args = parser.parse_args()
+    expectation = build_expectation()
+    if args.check:
+        existing = json.loads(args.out.read_text(encoding="utf-8"))
+        if existing != expectation:
+            print("candidate expectation drift detected", file=sys.stderr)
+            return 1
+        print("candidate expectation: pass")
+        return 0
+    args.out.parent.mkdir(parents=True, exist_ok=True)
+    args.out.write_text(json.dumps(expectation, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
+    print(f"wrote {args.out}")
+    print(json.dumps(expectation["candidate_counts"], indent=2))
+    return 0
+
+
+if __name__ == "__main__":
+    raise SystemExit(main())

+ 2 - 1
tools/board-viewer/package.json

@@ -7,7 +7,8 @@
   "scripts": {
     "test": "npm run test:logic",
     "test:logic": "node --test ../../tests/board_viewer/board-logic.test.mjs",
-    "test:e2e": "node ../../tests/board_viewer/playwright_e2e.cjs"
+    "test:e2e": "node ../../tests/board_viewer/playwright_e2e.cjs",
+    "test:matrix": "bash ./run_matrix_lanes.sh"
   },
   "devDependencies": {
     "playwright": "1.61.1"

+ 13 - 2
tools/board-viewer/refresh_reference_inventory.py

@@ -154,7 +154,12 @@ def build_inventory(root: Path) -> dict[str, Any]:
     present = sum(1 for item in items if item.get("exists"))
     missing = sum(1 for item in items if not item.get("exists"))
     hash_ok = sum(1 for item in items if item.get("hash_match") is True)
-    hash_fail = sum(1 for item in items if item.get("hash_match") is False)
+    # Missing optional/gitignored mirrors are tracked under `missing`, not hash_fail.
+    hash_fail = sum(
+        1 for item in items if item.get("exists") and item.get("hash_match") is False
+    )
+    canonical = next((item for item in items if item.get("role") == "canonical_brd"), None)
+    canonical_ok = bool(canonical and canonical.get("hash_match") is True)
 
     return {
         "schema": "prod2u-reference-inventory-v1",
@@ -180,6 +185,7 @@ def build_inventory(root: Path) -> dict[str, Any]:
             "missing": missing,
             "hash_ok": hash_ok,
             "hash_fail": hash_fail,
+            "canonical_brd_hash_ok": canonical_ok,
         },
     }
 
@@ -253,7 +259,12 @@ def main(argv: list[str] | None = None) -> int:
     print(f"wrote {args.json_out}")
     print(f"wrote {args.md_out}")
     print(json.dumps(inventory["summary"], ensure_ascii=False))
-    return 0 if inventory["summary"].get("hash_fail", 0) == 0 else 1
+    summary = inventory["summary"]
+    if summary.get("hash_fail", 0) != 0:
+        return 1
+    if not summary.get("canonical_brd_hash_ok"):
+        return 1
+    return 0
 
 
 if __name__ == "__main__":

+ 142 - 0
tools/board-viewer/run_matrix_lanes.sh

@@ -0,0 +1,142 @@
+#!/usr/bin/env bash
+# Matrix-ready board-viewer lanes: python, node-logic, svg-safety, reference-inventory,
+# validate/expectation-check, playwright E2E (1920x1080 + 1912x948).
+set -euo pipefail
+unset LD_LIBRARY_PATH LD_PRELOAD QT_PLUGIN_PATH || true
+
+ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
+RUN_ROOT="${RUN_ROOT:-${TMPDIR:-/tmp}/prod2u-board-lane}"
+BUILD_DIR="${BOARD_BUILD_DIR:-$RUN_ROOT/builds/board}"
+LOG_DIR="${BOARD_LOG_DIR:-$RUN_ROOT/logs}"
+ARTIFACTS="${BOARD_VIEWER_E2E_ARTIFACTS:-$BUILD_DIR/e2e-artifacts}"
+LANES="${BOARD_VIEWER_LANES:-python,node,svg,reference,validate,playwright}"
+STATUS_JSON="${BOARD_LANE_STATUS:-$RUN_ROOT/status/lane-c-board-internal.json}"
+
+mkdir -p "$BUILD_DIR" "$LOG_DIR" "$ARTIFACTS" "$(dirname "$STATUS_JSON")"
+
+if [[ -x "$BUILD_DIR/node/bin/node" ]]; then
+  export PATH="$BUILD_DIR/node/bin:$PATH"
+elif [[ -x "$RUN_ROOT/builds/board/node/bin/node" ]]; then
+  export PATH="$RUN_ROOT/builds/board/node/bin:$PATH"
+fi
+
+export PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-$BUILD_DIR/playwright-browsers}"
+export BOARD_VIEWER_E2E_ARTIFACTS="$ARTIFACTS"
+export BOARDVIEW_LOG_DIR="$LOG_DIR"
+
+cd "$ROOT"
+
+declare -A LANE_STATUS
+OVERALL=0
+
+ensure_npm() {
+  if [[ ! -d "$ROOT/tools/board-viewer/node_modules/playwright" ]]; then
+    (cd "$ROOT/tools/board-viewer" && npm ci --ignore-scripts --no-audit --no-fund) \
+      >>"$LOG_DIR/board-lane-npm-ci.log" 2>&1
+  fi
+}
+
+run_lane() {
+  local name="$1"
+  shift
+  local log="$LOG_DIR/board-lane-${name}.log"
+  echo "== lane ${name} ==" | tee "$log"
+  set +e
+  "$@" >>"$log" 2>&1
+  local rc=$?
+  set -e
+  if [[ $rc -eq 0 ]]; then
+    LANE_STATUS["$name"]="pass"
+    echo "lane ${name}: pass"
+  else
+    LANE_STATUS["$name"]="fail"
+    OVERALL=1
+    echo "lane ${name}: fail (rc=$rc, log=$log)"
+  fi
+}
+
+IFS=',' read -r -a REQUESTED <<< "$LANES"
+
+for lane in "${REQUESTED[@]}"; do
+  case "$lane" in
+    python)
+      run_lane python python3 -B -m pytest -q -p no:cacheprovider tests/board_viewer
+      ;;
+    node|node-logic)
+      ensure_npm
+      run_lane node bash -lc "cd tools/board-viewer && npm run test:logic"
+      ;;
+    svg|svg-safety)
+      run_lane svg bash "$ROOT/tools/check-board-viewer-svgs.sh"
+      ;;
+    reference|reference-inventory)
+      run_lane reference bash "$ROOT/tools/refresh-reference-inventory.sh"
+      ;;
+    validate|regeneration)
+      run_lane validate bash -lc \
+        "cd tools/board-viewer && python3 board_viewer.py validate && python3 generate_candidate_expectation.py --check"
+      ;;
+    playwright|e2e)
+      ensure_npm
+      if [[ ! -d "$PLAYWRIGHT_BROWSERS_PATH/chromium-"* ]] && ! compgen -G "$PLAYWRIGHT_BROWSERS_PATH/chromium-*" >/dev/null; then
+        (
+          cd "$ROOT/tools/board-viewer"
+          PLAYWRIGHT_DOWNLOAD_HOST="${PLAYWRIGHT_DOWNLOAD_HOST:-https://npmmirror.com/mirrors/playwright}" \
+            npx playwright install chromium
+        ) >>"$LOG_DIR/board-lane-playwright-install.log" 2>&1 || true
+      fi
+      if [[ -z "${BOARD_VIEWER_BROWSER:-}" ]]; then
+        CHROME_CANDIDATE=$(find "$PLAYWRIGHT_BROWSERS_PATH" -type f -path '*/chrome-linux64/chrome' 2>/dev/null | head -1 || true)
+        if [[ -n "$CHROME_CANDIDATE" ]]; then
+          export BOARD_VIEWER_BROWSER="$CHROME_CANDIDATE"
+        fi
+      fi
+      export TMPDIR="${TMPDIR:-/tmp/pw}"
+      mkdir -p "$TMPDIR"
+      run_lane playwright bash -lc '
+        set -euo pipefail
+        cd tools/board-viewer
+        python3 board_viewer.py serve --port 8765 >"'"$LOG_DIR"'/board-viewer-serve.log" 2>&1 &
+        SERVE_PID=$!
+        cleanup() { kill "$SERVE_PID" 2>/dev/null || true; wait "$SERVE_PID" 2>/dev/null || true; }
+        trap cleanup EXIT
+        for _ in $(seq 1 80); do
+          if curl -fsS http://127.0.0.1:8765/ >/dev/null 2>&1; then break; fi
+          sleep 0.25
+        done
+        export BOARD_VIEWER_URL=http://127.0.0.1:8765
+        npm run test:e2e
+      '
+      ;;
+    *)
+      echo "unknown lane: $lane" >&2
+      OVERALL=1
+      LANE_STATUS["$lane"]="fail"
+      ;;
+  esac
+done
+
+{
+  echo '{'
+  echo '  "schema": "prod2u-lane-c-board-internal-v1",'
+  echo "  \"recorded_at_utc\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\","
+  if [[ $OVERALL -eq 0 ]]; then
+    echo '  "overall": "pass",'
+  else
+    echo '  "overall": "fail",'
+  fi
+  echo '  "lanes": {'
+  first=1
+  for key in $(printf '%s\n' "${!LANE_STATUS[@]}" | sort); do
+    if [[ $first -eq 1 ]]; then first=0; else echo ','; fi
+    printf '    "%s": "%s"' "$key" "${LANE_STATUS[$key]}"
+  done
+  echo
+  echo '  },'
+  echo "  \"log_dir\": $(python3 -c 'import json,sys; print(json.dumps(sys.argv[1]))' "$LOG_DIR"),"
+  echo "  \"artifacts\": $(python3 -c 'import json,sys; print(json.dumps(sys.argv[1]))' "$ARTIFACTS")"
+  echo '}'
+} > "$STATUS_JSON"
+
+echo "wrote $STATUS_JSON"
+exit "$OVERALL"

+ 13 - 2
tools/board-viewer/web/app.js

@@ -587,8 +587,19 @@ function renderDetail() {
   if (touchpoint.connector) {
     const groups = connectorPinGroups(touchpoint);
     dom["detail-content"].append(renderConnectorLayout(touchpoint, groups));
-    appendPinSection(dom["detail-content"], touchpoint, "接触针(板正面顺序)", groups.contacts);
-    appendPinSection(dom["detail-content"], touchpoint, "屏蔽与机械焊盘", groups.auxiliary);
+    const contactPins = groups.contacts.length
+      ? groups.contacts
+      : touchpoint.pins.filter((pin) => pin.pad_role === "contact");
+    const auxiliaryPins = groups.contacts.length
+      ? groups.auxiliary
+      : touchpoint.pins.filter((pin) => pin.pad_role !== "contact");
+    appendPinSection(
+      dom["detail-content"],
+      touchpoint,
+      groups.contacts.length ? "接触针(板正面顺序)" : "接触针(板数据库编号)",
+      contactPins,
+    );
+    appendPinSection(dom["detail-content"], touchpoint, "屏蔽与机械焊盘", auxiliaryPins);
   } else {
     appendPinSection(dom["detail-content"], touchpoint, "针脚", touchpoint.pins);
   }