Browse Source

chore(release): 0.8.1.2 per-stage DIMM presence/pass/fail/idle flags and raw UART log isolation

XJKJ-STL Dev Automation 1 month ago
parent
commit
4ed665e0df

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # XJKJ-STL 高温内存测试平台
 
-当前开发版:`0.8.1.1.dev0`。唯一 Git 分支:`dev`。
+当前开发版:`0.8.1.2`。唯一 Git 分支:`dev`。
 
 一台 Linux 后端管理四个工位;Qt 保留前端开发人员原有界面,界面仅展示状态、BIOS UART 原文和提交动作。实际 BMC、固件阶段、诊断采集、失败判断、命令队列均由后端完成。
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-0.8.1.1.dev0
+0.8.1.2

+ 1 - 1
docs/GRPC_API_ZH.md

@@ -1,4 +1,4 @@
-# XJKJ-STL 0.8.1.1.dev0:原生 gRPC 专用接口手册
+# XJKJ-STL 0.8.1.2:原生 gRPC 专用接口手册
 
 **只开发原生 gRPC 客户端,请只看这份;Qt 前端精简纯净版 WebSocket 对接请看 [QT_CLIENT_API_ZH.md](QT_CLIENT_API_ZH.md)。** 直接使用 `stl.v1.BenchService` 和 protobuf 消息;没有 WebSocket 风格的 JSON 请求 id,但控制动作仍需要持久 command_id。
 

File diff suppressed because it is too large
+ 27 - 14
docs/QT_CLIENT_API_ZH.md


+ 1 - 1
docs/WEBSOCKET_API_ZH.md

@@ -1,4 +1,4 @@
-# XJKJ-STL 0.8.1.1.dev0:完整 WebSocket 接口手册
+# XJKJ-STL 0.8.1.2:完整 WebSocket 接口手册
 
 **Qt 前端精简纯净版对接请看 [QT_CLIENT_API_ZH.md](QT_CLIENT_API_ZH.md)(地址:`ws://192.168.2.79:8080/ws?view=qt-clean`)。** 本文是 `/ws`(或 `/ws?view=full`)的全部业务和诊断接口。后端同时支持三个接口:完整 WebSocket(`/ws`)、完整原生 gRPC(`:50051`)、Qt 专用精简纯净 WebSocket(`/ws?view=qt-clean`)。
 

+ 1 - 1
pyproject.toml

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
 
 [project]
 name = "xjkj-stl-backend"
-version = "0.8.1.1.dev0"
+version = "0.8.1.2"
 description = "Four-station memory thermal test backend with WebSocket and gRPC"
 readme = "README.md"
 requires-python = ">=3.11"

+ 1 - 1
qt-client/QT_CLEAN_CLIENT_ZH.md

@@ -1,4 +1,4 @@
-# Qt 纯净版临时客户端 0.8.1.1.dev0
+# Qt 纯净版临时客户端 0.8.1.2
 
 本目录基于上传的 XJKJ-STL Qt 工程制作;原始工程另存,界面布局沿用原来的 `.ui`。它只连接独立接口 `/ws?view=qt-clean`。
 

+ 1 - 2
qt-client/src/detailview.cpp

@@ -217,8 +217,7 @@ QJsonObject DetailView::collectParams(bool *valid)
         const qlonglong value = edit->text().trimmed().toLongLong(&ok);
         if (!ok || !edit->hasAcceptableInput() || value < 0 || value > 99999999) {
             *valid = false;
-            m_store->appendLog(m_index, QStringLiteral("[参数] %1 必须为非负整数,未保存任何修改")
-                .arg(QLatin1String(kParamKeys[i])));
+            qWarning().noquote() << "[param] 工位" << m_index + 1 << QLatin1String(kParamKeys[i]) << "必须为非负整数,未保存任何修改";
             return QJsonObject();
         }
         params.insert(QLatin1String(kParamKeys[i]), static_cast<double>(value));

+ 1 - 1
qt-client/src/main.cpp

@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
 
     QApplication app(argc, argv);
     app.setApplicationName(QStringLiteral("HOVSE SLT Pro"));
-    app.setApplicationVersion(QStringLiteral("0.8.1.1.dev0"));
+    app.setApplicationVersion(QStringLiteral("0.8.1.2"));
     app.setOrganizationName(QStringLiteral("XJKJ"));
 
     applyAppFont(app);

+ 4 - 3
qt-client/src/mainwindow.cpp

@@ -162,9 +162,10 @@ void MainWindow::saveLocalParams(int index, const QJsonObject &params)
     LocalPlans plans;
     QString error;
     const bool saved = plans.saveMemoryParams(index, params, &error);
-    m_store->appendLog(index, saved
-        ? QStringLiteral("[参数] 已保存到本工位 Qt 本地计划;下次开始测试在 UIP 阶段应用")
-        : QStringLiteral("[参数] 保存失败:%1").arg(error));
+    if (saved)
+        qInfo().noquote() << "[param] 工位" << index + 1 << "已保存到本工位 Qt 本地计划;下次开始测试在 UIP 阶段应用";
+    else
+        qWarning().noquote() << "[param] 工位" << index + 1 << "保存失败:" << error;
 }
 
 // ---------------------------------------------------------------------------

+ 2 - 1
qt-client/tests/qt_clean_probe.cpp

@@ -105,7 +105,7 @@ public:
             {"boot_id", changedBoot ? "fixture-boot-2" : (step >= 0 ? "fixture-boot-1" : "fixture-boot-0")},
             {"verdict", failAtEnd && step >= 5 ? "fail" : "not_tested"},
             {"input", input}, {"command", command},
-            {"channels", QJsonArray{QJsonObject{{"name", "CPU0_CHA"}, {"state", "unknown"}, {"temperature_c", 48.0}}}}};
+            {"channels", QJsonArray{QJsonObject{{"name", "CPU0_CHA"}, {"present", false}, {"state", "idle"}, {"temperature_c", 48.0}}}}};
     }
     QJsonObject state() const
     {
@@ -318,6 +318,7 @@ int main(int argc, char **argv)
         window.findChild<QLineEdit *>("paramEdit_0_0")->setText("invalid");
         window.findChild<QAbstractButton *>("btnParamSubmit")->click();
         checks.insert("invalid_parameter_not_coerced_to_zero", LocalPlans().memoryParams(0).value("mem vdd").toInt() == 1070);
+        checks.insert("param_actions_do_not_pollute_bios_uart_log", window.store()->station(0).logs.isEmpty());
         window.store()->appendLog(0, QStringLiteral("fixture-unique-live-log"));
         window.findChild<QAbstractButton *>("btnBackMonitor")->click();
         window.findChild<QAbstractButton *>("cardDetail_1")->click();

+ 7 - 3
scripts/version.py

@@ -5,13 +5,16 @@ from __future__ import annotations
 import argparse
 from pathlib import Path
 import re
-import tomllib
+try:
+    import tomllib
+except ModuleNotFoundError:
+    tomllib = None
 
 ROOT = Path(__file__).resolve().parents[1]
 VERSION_FILE = ROOT / "VERSION"
 PROJECT_FILE = ROOT / "pyproject.toml"
 PACKAGE_FILE = ROOT / "src/stl_backend/__init__.py"
-PLAIN_VERSION = re.compile(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)")
+PLAIN_VERSION = re.compile(r"(?:0|[1-9][0-9]*)(?:\.(?:0|[1-9][0-9]*)){2,}(?:\.dev(?:0|[1-9][0-9]*))?")
 
 
 def read_fields() -> dict[str, str]:
@@ -19,7 +22,8 @@ def read_fields() -> dict[str, str]:
     values = re.findall(r'^__version__ = "([^"]+)"$', package, re.MULTILINE)
     if len(values) != 1:
         raise ValueError("Expected exactly one __version__ assignment")
-    project = tomllib.loads(PROJECT_FILE.read_text(encoding="utf-8"))
+    project_text = PROJECT_FILE.read_text(encoding="utf-8")
+    project = tomllib.loads(project_text) if tomllib else {"project": {"version": re.findall(r'^version = "([^"]+)"$', project_text, re.MULTILINE)[0]}}
     return {
         "VERSION": VERSION_FILE.read_text(encoding="utf-8").strip(),
         "pyproject.toml": project["project"]["version"],

+ 1 - 1
src/stl_backend/__init__.py

@@ -1,3 +1,3 @@
 """XJKJ-STL memory thermal testing backend."""
-__version__ = "0.8.1.1.dev0"
+__version__ = "0.8.1.2"
 

+ 162 - 20
src/stl_backend/application/qt_clean.py

@@ -132,13 +132,12 @@ class QtCleanService:
         return observer.snapshot(live=live, include_steps=True), live
 
     @staticmethod
-    def _training_outcomes(firmware, started):
-        """DDR Training SUCCEEDED is stage health, not an AMT/MT verdict."""
+    def _task_outcomes(firmware, started, detail_id, name):
         latest = {}
         if not started:
             return latest
         for row in firmware.get("stage_progress", {}).get("steps", []):
-            if (row.get("detail_id") != "ddr_training" or row.get("name") != "DDR Training"
+            if (row.get("detail_id") != detail_id or row.get("name") != name
                     or not isinstance(row.get("cpu"), int)
                     or (row.get("ended_unix_ms") or 0) < started):
                 continue
@@ -148,6 +147,11 @@ class QtCleanService:
                 latest[cpu] = (stamp, row.get("state", ""))
         return {cpu: state for cpu, (_, state) in latest.items()}
 
+    @classmethod
+    def _training_outcomes(cls, firmware, started):
+        """DDR Training SUCCEEDED is stage health, not an AMT/MT verdict."""
+        return cls._task_outcomes(firmware, started, "ddr_training", "DDR Training")
+
     def _input(self, rt, firmware, live):
         p = firmware.get("console_prompt", {})
         kind = p.get("kind", "")
@@ -215,6 +219,10 @@ class QtCleanService:
                         try:
                             key = (int(details["cpu"]), canonical_channel(details["channel"], self._runtime(sid).cfg["channels_per_cpu"]))
                             record.setdefault("failed_channels", set()).add(key)
+                            stage_name = {"bios_training": "training", "amemdiag": "amt"}.get(event.get("phase", ""), event.get("phase", ""))
+                            if stage_name not in ("training", "rmt", "amt", "mt"):
+                                stage_name = "training"
+                            record.setdefault("failed_channel_stages", {}).setdefault(key, stage_name)
                         except (TypeError, ValueError, BenchError):
                             pass
             cursor = page["next_after_sequence"]
@@ -222,6 +230,155 @@ class QtCleanService:
             if not page["has_more"]:
                 break
 
+    def _channels(self, rt, fw, observer, record, started, temperatures):
+        cpu_count = rt.cfg["cpu_count"]
+        ch_count = rt.cfg["channels_per_cpu"]
+        boot_matches = (fw.get("boot_id") == record["boot_id"]
+                        if record.get("boot_id") else not record and bool(fw.get("boot_id")))
+        if record.get("state") == "starting" or fw.get("boot_pending") or not boot_matches:
+            return [{"cpu": cpu, "channel": str(ch), "name": f"CPU{cpu}_CH{chr(65 + ch)}",
+                     "present": False,
+                     "stages": {"detected": False, "training": "idle", "rmt": "idle", "amt": "idle", "mt": "idle"},
+                     "failed_stage": "", "state": "idle", "temperature_c": None}
+                    for cpu in range(cpu_count) for ch in range(ch_count)]
+
+        stage_started = started or (fw.get("boot_started_unix_ms", 0) if not record else 0)
+
+        def norm_key(c, ch_val):
+            try:
+                if isinstance(c, bool) or c is None or ch_val is None:
+                    return None
+                return int(c), canonical_channel(ch_val, ch_count)
+            except (TypeError, ValueError, BenchError):
+                return None
+
+        failed_channel_stages = dict(record.get("failed_channel_stages", {}))
+        default_err_stage = record.get("failure_scope") if record.get("failure_scope") in ("training", "rmt", "amt", "mt") else "training"
+        for key in record.get("failed_channels", set()):
+            failed_channel_stages.setdefault(key, default_err_stage)
+        if not record:
+            for (c, ch_val), st in getattr(observer, "channel_errors", {}).items():
+                nk = norm_key(c, ch_val)
+                if nk:
+                    failed_channel_stages.setdefault(nk, st if st in ("training", "rmt", "amt", "mt") else "training")
+
+        dimms_by_ch = {}
+        for d in fw.get("training_dimms", []):
+            nk = norm_key(d.get("cpu"), d.get("channel"))
+            if nk:
+                dimms_by_ch.setdefault(nk, []).append(d)
+
+        chans_by_ch = {}
+        for c_row in fw.get("training_channels", []):
+            nk = norm_key(c_row.get("cpu"), c_row.get("channel"))
+            if nk:
+                chans_by_ch[nk] = c_row
+
+        rmt_measured_chs = set()
+        for m in fw.get("rmt_measurements", []):
+            if (m.get("observed_unix_ms") or 0) >= stage_started:
+                nk = norm_key(m.get("cpu"), m.get("channel"))
+                if nk:
+                    rmt_measured_chs.add(nk)
+
+        sensor_chs = set()
+        for c, ch_val in getattr(observer, "detected_sensor_channels", set()):
+            nk = norm_key(c, ch_val)
+            if nk:
+                sensor_chs.add(nk)
+
+        present_map = {}
+        disabled_map = {}
+        for cpu in range(cpu_count):
+            for ch in range(ch_count):
+                key = (cpu, str(ch))
+                d_rows = dimms_by_ch.get(key, [])
+                c_row = chans_by_ch.get(key, {})
+                has_pos_dimm = any(
+                    d.get("presence") == "present" or bool(d.get("sn")) or bool(d.get("serial"))
+                    or bool(d.get("reported_dimm_code")) or d.get("training_state") in ("enabled", "disabled")
+                    for d in d_rows
+                )
+                explicitly_absent = bool(d_rows) and all(d.get("presence") == "absent" for d in d_rows) and not has_pos_dimm
+                present_map[key] = (not explicitly_absent) and (
+                    has_pos_dimm or c_row.get("state") in ("enabled", "disabled")
+                    or key in rmt_measured_chs or key in sensor_chs or key in failed_channel_stages
+                )
+                disabled_map[key] = (
+                    any(d.get("training_state") == "disabled" for d in d_rows)
+                    or c_row.get("state") == "disabled"
+                )
+
+        training = self._task_outcomes(fw, stage_started, "ddr_training", "DDR Training")
+        rmt_tasks = self._task_outcomes(fw, stage_started, "rmt_task", "Rank Margin Tool")
+        rmt_rows = {r["cpu"]: r for r in fw.get("rmt_results", [])
+                    if isinstance(r.get("cpu"), int) and (r.get("observed_unix_ms") or 0) >= stage_started}
+        amt_rows = {a["cpu"]: a for a in fw.get("amt_results", [])
+                    if isinstance(a.get("cpu"), int) and (a.get("observed_unix_ms") or 0) >= stage_started}
+        mt = fw.get("mt_result", {}) if (fw.get("mt_result", {}).get("observed_unix_ms") or 0) >= stage_started else {}
+
+        any_present_cpu = {cpu: any(present_map[(cpu, str(c))] for c in range(ch_count)) for cpu in range(cpu_count)}
+        any_rmt_cpu = {cpu: any((cpu, str(c)) in rmt_measured_chs for c in range(ch_count)) for cpu in range(cpu_count)}
+        any_present_station = any(present_map.values())
+        any_ch_err_stage = {st: any(v == st for v in failed_channel_stages.values()) for st in ("training", "rmt", "amt", "mt")}
+        any_ch_err_cpu = {(cpu, st): any(k[0] == cpu and v == st for k, v in failed_channel_stages.items())
+                          for cpu in range(cpu_count) for st in ("training", "rmt", "amt", "mt")}
+
+        channels = []
+        for cpu in range(cpu_count):
+            for ch in range(ch_count):
+                key = (cpu, str(ch))
+                present = present_map[key]
+                disabled = disabled_map[key]
+                ch_err = failed_channel_stages.get(key, "")
+                cpu_fail_target = present or not any_present_cpu[cpu]
+                station_fail_target = present or not any_present_station
+
+                if ch_err == "training" or (training.get(cpu) == "failed" and not any_ch_err_cpu[(cpu, "training")] and cpu_fail_target):
+                    st_training = "fail"
+                elif training.get(cpu) == "completed" and present and not disabled:
+                    st_training = "pass"
+                else:
+                    st_training = "idle"
+
+                rmt_failed = rmt_tasks.get(cpu) == "failed" or rmt_rows.get(cpu, {}).get("state") == "failed"
+                rmt_passed = (rmt_tasks.get(cpu) == "completed" or rmt_rows.get(cpu, {}).get("state") == "completed") and not rmt_failed
+                if ch_err == "rmt" or (rmt_failed and not any_ch_err_cpu[(cpu, "rmt")] and cpu_fail_target):
+                    st_rmt = "fail"
+                elif rmt_passed and present and not disabled and (key in rmt_measured_chs or not any_rmt_cpu[cpu]):
+                    st_rmt = "pass"
+                else:
+                    st_rmt = "idle"
+
+                amt_row = amt_rows.get(cpu, {})
+                amt_failed = amt_row.get("status") in ("fail", "block", "blocked")
+                amt_passed = amt_row.get("status") == "pass" and bool(amt_row.get("verdict_supported")) and (amt_row.get("algorithm_count") or 0) > 0
+                if ch_err == "amt" or (amt_failed and not any_ch_err_cpu[(cpu, "amt")] and cpu_fail_target):
+                    st_amt = "fail"
+                elif amt_passed and present and not disabled:
+                    st_amt = "pass"
+                else:
+                    st_amt = "idle"
+
+                mt_failed = mt.get("status") == "fail"
+                mt_passed = mt.get("status") == "pass" and mt.get("complete") is True
+                if ch_err == "mt" or (mt_failed and not any_ch_err_stage["mt"] and station_fail_target):
+                    st_mt = "fail"
+                elif mt_passed and present and not disabled:
+                    st_mt = "pass"
+                else:
+                    st_mt = "idle"
+
+                stages = {"detected": bool(present), "training": st_training, "rmt": st_rmt, "amt": st_amt, "mt": st_mt}
+                failed_stage = next((s for s in ("training", "rmt", "amt", "mt") if stages[s] == "fail"), ch_err)
+                ch_state = ("fail" if failed_stage else
+                            "pass" if (present and not disabled and any(stages[s] == "pass" for s in ("training", "rmt", "amt", "mt"))) else
+                            "idle")
+                channels.append({"cpu": cpu, "channel": str(ch), "name": f"CPU{cpu}_CH{chr(65 + ch)}",
+                                 "present": bool(present), "stages": stages, "failed_stage": failed_stage,
+                                 "state": ch_state, "temperature_c": temperatures.get(key)})
+        return channels
+
     async def state(self):
         stations = []
         for sid, rt in self.bench.runtimes.items():
@@ -234,14 +391,6 @@ class QtCleanService:
             await self._observe_errors(sid, record)
             started = record.get("started_unix_ms", 0)
             verdict, completed_mt, verdict_scope = self._outcome(fw, started, rt.cfg["cpu_count"]) if started else ("unknown", False, "")
-            # Passive multi-station monitoring must also show proven Training
-            # health on a BIOS boot that Qt did not initiate. With an active
-            # Qt StartTest, however, never mix another boot into that run.
-            training_started = started or (fw.get("boot_started_unix_ms", 0) if not record else 0)
-            training_boot_matches = (fw.get("boot_id") == record["boot_id"]
-                                     if record.get("boot_id") else not record and bool(fw.get("boot_id")))
-            training = (self._training_outcomes(fw, training_started)
-                        if training_boot_matches else {})
             if record.get("test_failed"):
                 verdict = "fail"
                 verdict_scope = record.get("failure_scope", "")
@@ -272,15 +421,8 @@ class QtCleanService:
                         except (KeyError, TypeError, ValueError, BenchError):
                             continue
                         temperatures[key] = max(value, temperatures.get(key, value))
-            # Green means this CPU's DDR Training explicitly completed, never
-            # that the later AMT/MT memory algorithms passed. A training failure
-            # affects that CPU; a located memory error affects its channel.
-            channels = [{"cpu": cpu, "channel": str(channel),
-                         "state": "fail" if (cpu, str(channel)) in record.get("failed_channels", set())
-                         or training.get(cpu) == "failed" else
-                         "pass" if training.get(cpu) == "completed" else "unknown",
-                         "name": f"CPU{cpu}_CH{chr(65 + channel)}", "temperature_c": temperatures.get((cpu, str(channel)))}
-                        for cpu in range(rt.cfg["cpu_count"]) for channel in range(rt.cfg["channels_per_cpu"])]
+            channels = self._channels(rt, fw, rt.firmware if rt.run else rt.diagnostic.firmware,
+                                      record, started, temperatures)
             connection = rt.snapshot["sol_state"] if rt.run else rt.diagnostic.state["state"]
             if connection == "closed":
                 connection = "offline"

+ 9 - 0
src/stl_backend/domain/firmware.py

@@ -241,6 +241,8 @@ class FirmwareObservation:
         self.mt_result = {}
         self._seen_uip = False
         self._seen_ddr_training = False
+        self.detected_sensor_channels = set()
+        self.channel_errors = {}
 
     @staticmethod
     def _rank(phase):
@@ -446,6 +448,13 @@ class FirmwareObservation:
         if kind == "training_channel" and is_cpu and "channel" in details:
             self.training_channels[(cpu, str(details["channel"]))] = {**copy.deepcopy(details), **stamp}
             changed = True
+        if kind == "dimm_temperature" and is_cpu and "channel" in details:
+            self.detected_sensor_channels.add((cpu, str(details["channel"])))
+            changed = True
+        if (kind == "error" or details.get("test_failure") or details.get("execution_error")) and is_cpu and "channel" in details:
+            stage_err = phase if phase in ("training", "rmt", "amt", "mt") else "training"
+            self.channel_errors.setdefault((cpu, str(details["channel"])), stage_err)
+            changed = True
         if kind == "uefi_directory":
             self.uefi_directory = details.get("path", "")
             self.uefi_files.clear()

+ 73 - 3
tests/test_qt_clean_control.py

@@ -189,7 +189,8 @@ class QtCleanControlTests(unittest.IsolatedAsyncioTestCase):
                 await asyncio.sleep(.02)
         self.assertGreaterEqual(len(handled), 4)
         self.assertNotEqual(state["verdict"], "pass")
-        self.assertTrue(all(row["state"] != "pass" for row in state["channels"]))
+        self.assertEqual([row["name"] for row in state["channels"] if row["state"] == "pass"], ["CPU0_CHA", "CPU1_CHA"])
+        self.assertEqual(sum(row["state"] == "idle" for row in state["channels"]), 22)
         self.assertEqual(self.bench.control_settings.load("S1"), self.original_settings)
         self.assertFalse(self.bench.controls.boot_plans.active("S1"))
         self.assertNotIn(b"amemdiag 1\r", self.rt.device.sent_commands)
@@ -270,6 +271,16 @@ class QtCleanControlTests(unittest.IsolatedAsyncioTestCase):
     async def test_ddr_training_success_colors_channels_before_amt_without_mt_verdict(self):
         await self.start()
         fw = self.rt.diagnostic.firmware
+        initial = await self.current()
+        self.assertTrue(all(row["state"] == "idle" and not row["present"] for row in initial["channels"]))
+        for cpu in (0, 1):
+            for ch in range(12):
+                fw.observe({"phase": "bios_training", "kind": "dimm", "message": "Firmware physical DIMM inventory",
+                            "details": {"cpu": cpu, "channel": ch, "dimm": 0, "presence": "present",
+                                        "reported_dimm_code": "0x401"}}, now_ms())
+        detected = await self.current()
+        self.assertTrue(all(row["present"] and row["stages"]["detected"] and row["state"] == "idle"
+                            for row in detected["channels"]))
         for cpu in (0, 1):
             fw.observe({"phase": "bios_training", "kind": "training", "message": "Memory training step",
                         "raw_line": f"[BIOS][Training][ScktId: {cpu}]DDR Training -- SUCCEEDED",
@@ -278,6 +289,7 @@ class QtCleanControlTests(unittest.IsolatedAsyncioTestCase):
                                     "completion_is_not_pass": True}}, now_ms())
             state = await self.current()
             self.assertEqual(sum(row["state"] == "pass" for row in state["channels"]), 12 * (cpu + 1))
+            self.assertEqual(sum(row["state"] == "idle" for row in state["channels"]), 24 - 12 * (cpu + 1))
             self.assertEqual(state["verdict"], "unknown")
         self.assertNotEqual(state["phase"], "amt")
 
@@ -291,14 +303,67 @@ class QtCleanControlTests(unittest.IsolatedAsyncioTestCase):
             "phase": "training", "message": "Located memory failure", "observed_unix_ms": now_ms(),
             "payload": {"source": "bios_console", "details": {"test_failure": True, "cpu": 0, "channel": "A"}}})
         state = await self.current()
-        self.assertEqual(next(row for row in state["channels"] if row["name"] == "CPU0_CHA")["state"], "fail")
+        ch0 = next(row for row in state["channels"] if row["name"] == "CPU0_CHA")
+        self.assertEqual(ch0["state"], "fail")
+        self.assertEqual(ch0["failed_stage"], "training")
+        self.assertEqual(ch0["stages"]["training"], "fail")
         self.assertEqual(sum(row["state"] == "pass" for row in state["channels"]), 23)
 
+    async def test_unpopulated_and_disabled_channels_stay_idle_while_detected_progress_and_fail(self):
+        await self.start()
+        fw = self.rt.diagnostic.firmware
+        for cpu in (0, 1):
+            for ch in range(12):
+                present = (cpu == 0 and ch in (0, 1)) or (cpu == 1 and ch == 0)
+                fw.observe({"phase": "bios_training", "kind": "dimm", "message": "Firmware physical DIMM inventory",
+                            "details": {"cpu": cpu, "channel": ch, "dimm": 0,
+                                        "presence": "present" if present else "absent",
+                                        "reported_dimm_code": "0x401" if present else ""}}, now_ms())
+        fw.observe({"phase": "bios_training", "kind": "training_dimm", "message": "Firmware DIMM enable state",
+                    "details": {"cpu": 0, "channel": 1, "dimm": 0, "state": "disabled"}}, now_ms())
+        for cpu in (0, 1):
+            fw.observe({"phase": "bios_training", "kind": "training", "message": "Memory training step",
+                        "details": {"cpu": cpu, "name": "DDR Training", "status": "succeeded",
+                                    "state": "completed", "duration_ms": 1000}}, now_ms())
+        state = await self.current()
+        by_name = {row["name"]: row for row in state["channels"]}
+        self.assertEqual([row["name"] for row in state["channels"] if row["state"] == "pass"], ["CPU0_CHA", "CPU1_CHA"])
+        self.assertEqual(by_name["CPU0_CHB"]["state"], "idle")
+        self.assertEqual(by_name["CPU0_CHB"]["stages"]["training"], "idle")
+        self.assertEqual(by_name["CPU0_CHC"]["state"], "idle")
+        self.assertFalse(by_name["CPU0_CHC"]["present"])
+        self.assertEqual(sum(row["state"] == "idle" for row in state["channels"]), 22)
+
+        for cpu in (0, 1):
+            fw.observe({"phase": "rmt", "kind": "stage", "message": "RMT completed",
+                        "details": {"cpu": cpu, "name": "Rank Margin Tool", "status": "succeeded",
+                                    "state": "completed", "duration_ms": 120, "detail_id": "task_completed"}}, now_ms())
+        state = await self.current()
+        by_name = {row["name"]: row for row in state["channels"]}
+        self.assertEqual(by_name["CPU0_CHA"]["stages"]["rmt"], "pass")
+        self.assertEqual(by_name["CPU1_CHA"]["stages"]["rmt"], "pass")
+        self.assertEqual(by_name["CPU0_CHB"]["stages"]["rmt"], "idle")
+
+        await self.bench.event_queue.publish({"station_id": "S1", "kind": "error", "severity": "error",
+            "phase": "amt", "message": "AMT failure", "observed_unix_ms": now_ms(),
+            "payload": {"source": "bios_console", "details": {"test_failure": True, "cpu": 1, "channel": "A"}}})
+        state = await self.current()
+        by_name = {row["name"]: row for row in state["channels"]}
+        self.assertEqual(by_name["CPU1_CHA"]["state"], "fail")
+        self.assertEqual(by_name["CPU1_CHA"]["failed_stage"], "amt")
+        self.assertEqual(by_name["CPU1_CHA"]["stages"]["amt"], "fail")
+        self.assertEqual(by_name["CPU0_CHA"]["state"], "pass")
+        self.assertEqual(sum(row["state"] == "idle" for row in state["channels"]), 22)
+
     async def test_passive_monitor_also_shows_observed_training_without_qt_plan(self):
         fw = self.rt.diagnostic.firmware
         fw.observe({"phase": "boot", "kind": "stage", "message": "System BIOS boot",
                     "details": {"bios_version": "fixture-version", "state": "initializing"}}, now_ms())
         for cpu in (0, 1):
+            for ch in range(12):
+                fw.observe({"phase": "bios_training", "kind": "dimm", "message": "Firmware physical DIMM inventory",
+                            "details": {"cpu": cpu, "channel": ch, "dimm": 0, "presence": "present",
+                                        "reported_dimm_code": "0x401"}}, now_ms())
             fw.observe({"phase": "bios_training", "kind": "training", "message": "DDR Training",
                         "details": {"cpu": cpu, "name": "DDR Training", "status": "succeeded",
                                     "state": "completed", "duration_ms": 1000}}, now_ms())
@@ -310,13 +375,18 @@ class QtCleanControlTests(unittest.IsolatedAsyncioTestCase):
     async def test_ddr_training_failure_marks_affected_cpu_not_all_channels(self):
         await self.start()
         fw = self.rt.diagnostic.firmware
+        for cpu in (0, 1):
+            for ch in range(12):
+                fw.observe({"phase": "bios_training", "kind": "dimm", "message": "Firmware physical DIMM inventory",
+                            "details": {"cpu": cpu, "channel": ch, "dimm": 0, "presence": "present",
+                                        "reported_dimm_code": "0x401"}}, now_ms())
         for cpu, outcome in ((0, "succeeded"), (1, "failed")):
             fw.observe({"phase": "bios_training", "kind": "training", "message": "Memory training step",
                         "details": {"cpu": cpu, "name": "DDR Training", "status": outcome,
                                     "state": "completed", "completion_is_not_pass": True}}, now_ms())
         state = await self.current()
         self.assertEqual(sum(row["state"] == "pass" for row in state["channels"]), 12)
-        self.assertEqual(sum(row["state"] == "fail" for row in state["channels"]), 12)
+        self.assertEqual(sum(row["state"] == "fail" and row["failed_stage"] == "training" for row in state["channels"]), 12)
 
 
 if __name__ == "__main__":

+ 4 - 1
tests/test_qt_clean_websocket.py

@@ -73,7 +73,10 @@ class QtCleanWebSocketTests(unittest.IsolatedAsyncioTestCase):
             for key in ("connections", "firmware", "boot_plan", "boot_execution", "raw_line", "transport"):
                 self.assertNotIn(key, station)
             self.assertEqual(len(station["channels"]), 24)
-            self.assertTrue(all(channel["temperature_c"] is None for channel in station["channels"]))
+            self.assertTrue(all(channel["temperature_c"] is None and channel["state"] == "idle"
+                                and channel["present"] is False and channel["failed_stage"] == ""
+                                and channel["stages"]["detected"] is False
+                                for channel in station["channels"]))
             bad = await self.call(clean, "GetState", {"unknown": True})
             self.assertEqual(bad["error"]["code"], "INVALID_ARGUMENT")
             missing = await self.call(clean, "GetCommand", {"command_id": "missing"})

+ 1 - 1
validation/build_windows_release.ps1

@@ -1,7 +1,7 @@
 param(
     [Parameter(Mandatory=$true)][string]$QtRoot,
     [Parameter(Mandatory=$true)][string]$MingwRoot,
-    [string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.1.dev0'
+    [string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.2'
 )
 $ErrorActionPreference = 'Stop'
 $ProgressPreference = 'SilentlyContinue'

+ 1 - 1
validation/launch_windows_demo.ps1

@@ -1,4 +1,4 @@
-param([string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.1.dev0')
+param([string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.2')
 $ErrorActionPreference = 'Stop'
 $ProgressPreference = 'SilentlyContinue'
 $appRoot = Join-Path $ReleaseRoot 'app'

+ 9 - 5
validation/live_channel_probe.py

@@ -40,24 +40,28 @@ async def observe(args):
                     channels = state.get("channels", [])
                     row = {"unix_ms": int(time.time() * 1000), "boot_id": state.get("boot_id"),
                            "phase": state.get("phase"), "run_state": state.get("run_state"),
+                           "detected": sum(bool(c.get("present")) for c in channels),
                            "green": sum(c.get("state") == "pass" for c in channels),
                            "red": sum(c.get("state") == "fail" for c in channels),
-                           "unknown": sum(c.get("state") == "unknown" for c in channels),
+                           "idle": sum(c.get("state") == "idle" for c in channels),
                            "verdict": state.get("verdict", "unknown")}
                     if not history or history[-1]["boot_id"] != row["boot_id"] or any(
-                        history[-1][key] != row[key] for key in ("phase", "green", "red", "unknown", "verdict")):
+                        history[-1][key] != row[key] for key in ("phase", "detected", "green", "red", "idle", "verdict")):
                         history.append(row)
                         print(json.dumps(row, ensure_ascii=False), flush=True)
     output = {"station": args.station, "history": history, "uart_bytes": total_uart_bytes,
               "raw_training_signature": b"DDR Training -- SUCCEEDED" in sample,
-              "saw_24_green": any(row["green"] == 24 and row["red"] == 0 for row in history),
-              "saw_before_amt": any(row["green"] == 24 and row["red"] == 0
+              "saw_initial_all_idle": any(row["idle"] == 24 and row["green"] == 0 and row["red"] == 0 for row in history),
+              "saw_detected_green": any(row["detected"] > 0 and row["green"] == row["detected"]
+                                        and row["idle"] == 24 - row["detected"] and row["red"] == 0 for row in history),
+              "saw_before_amt": any(row["detected"] > 0 and row["green"] == row["detected"]
+                                    and row["idle"] == 24 - row["detected"] and row["red"] == 0
                                     and row["phase"] in ("training", "rmt", "uip") for row in history),
               "final_verdict": history[-1]["verdict"] if history else "unknown"}
     if args.output:
         Path(args.output).write_text(json.dumps(output, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
     print(json.dumps({key: value for key, value in output.items() if key != "history"}, ensure_ascii=False))
-    return 0 if output["saw_24_green"] and total_uart_bytes and output["raw_training_signature"] else 1
+    return 0 if output["saw_detected_green"] and total_uart_bytes and output["raw_training_signature"] else 1
 
 
 if __name__ == "__main__":

+ 1 - 1
validation/package_windows_dev.py

@@ -7,7 +7,7 @@ from pathlib import Path
 import struct
 import zipfile
 
-VERSION = "0.8.1.1.dev0"
+VERSION = "0.8.1.2"
 UI_HASHES = {
     "src/mainwindow.ui": "e2ed5a4aaadf0d089eab4e4b6791357423482c2adb9ef7c8c7a01f0b1caddabd",
     "src/style/app.qss": "b4774ac879b64a07fbb361c5e763e0355ed4cb0051e37c412bec38dcbcba8558",

+ 1 - 1
validation/run_windows_live.ps1

@@ -1,4 +1,4 @@
-param([string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.1.dev0')
+param([string]$ReleaseRoot = 'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.2')
 $ErrorActionPreference = 'Stop'
 $ProgressPreference = 'SilentlyContinue'
 $appRoot = Join-Path $ReleaseRoot 'app'

+ 1 - 1
validation/run_windows_validation.py

@@ -7,7 +7,7 @@ from pathlib import Path
 import subprocess
 
 parser = argparse.ArgumentParser()
-parser.add_argument('--release', type=Path, default=Path(r'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.1.dev0'))
+parser.add_argument('--release', type=Path, default=Path(r'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.2'))
 args = parser.parse_args()
 app = args.release / 'app'
 evidence = args.release / 'evidence'

+ 1 - 1
validation/schedule_windows_dev.ps1

@@ -1,6 +1,6 @@
 param(
     [ValidateSet('live','demo')][string]$Mode='live',
-    [string]$ReleaseRoot='C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.1.dev0'
+    [string]$ReleaseRoot='C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.2'
 )
 $ErrorActionPreference='Stop'
 $taskName = if ($Mode -eq 'live') {'XJKJ-Qt-Dev-Live'} else {'XJKJ-Qt-Dev-Demo'}