Procházet zdrojové kódy

Release 0.8.1.29: preserve active-run state across link bounce, IPMI seq_id guard, early freeze status & web dirty debounce

XJKJ STL před 1 týdnem
rodič
revize
c48b44d084

+ 1 - 1
Dockerfile

@@ -14,7 +14,7 @@ COPY config/ ./config/
 COPY build/native/stl_native_server /usr/local/bin/stl_native_server
 
 ARG STL_BUILD_COMMIT=vd012-native
-ARG STL_VERSION=0.8.1.28
+ARG STL_VERSION=0.8.1.29
 ENV STL_BUILD_COMMIT=${STL_BUILD_COMMIT} \
     STL_VERSION=${STL_VERSION}
 

+ 1 - 1
VERSION

@@ -1 +1 @@
-0.8.1.28
+0.8.1.29

+ 2 - 2
docker-compose.yml

@@ -3,9 +3,9 @@ services:
     build:
       context: .
       args:
-        STL_VERSION: ${STL_VERSION:-0.8.1.28}
+        STL_VERSION: ${STL_VERSION:-0.8.1.29}
         STL_BUILD_COMMIT: ${STL_BUILD_COMMIT:-vd012-native}
-    image: xjkj-stl:0.8.1.28
+    image: xjkj-stl:0.8.1.29
     container_name: xjkj-stl-backend
     restart: unless-stopped
     stop_grace_period: 30s

+ 21 - 0
native/stl_accel/parser_re2c.re

@@ -710,6 +710,27 @@ scan_anywhere:
                 /* Check if Rank Margin Tool or MemTest or FAILED (excluding benign SNC/Pipe Sync SBSP Status reset notice) */
                 for (const uint8_t *p = YYCURSOR; p + 6 <= lim; p++) {
                     if (p + 16 <= lim && memcmp(p, "Rank Margin Tool", 16) == 0) {
+                        for (const uint8_t *q = p + 16; q + 6 <= lim; q++) {
+                            if (memcmp(q, "FAILED", 6) == 0) {
+                                ev->subkind = 2;
+                                return STL_LK_TRAINING_ERROR;
+                            }
+                            if (q + 7 <= lim && memcmp(q, "Started", 7) == 0) {
+                                return STL_LK_RMT_START;
+                            }
+                            if (q + 7 <= lim && (memcmp(q, "Skipped", 7) == 0 || memcmp(q, "SKIPPED", 7) == 0)) {
+                                ev->subkind = 3;
+                                return STL_LK_RMT_STOP;
+                            }
+                            if (q + 8 <= lim && (memcmp(q, "Disabled", 8) == 0 || memcmp(q, "DISABLED", 8) == 0)) {
+                                ev->subkind = 3;
+                                return STL_LK_RMT_STOP;
+                            }
+                            if (q + 9 <= lim && memcmp(q, "SUCCEEDED", 9) == 0) {
+                                ev->subkind = 1;
+                                return STL_LK_RMT_STOP;
+                            }
+                        }
                         return STL_LK_RMT_STOP;
                     }
                     if (!is_pipe_sync_sbsp && memcmp(p, "FAILED", 6) == 0) {

+ 185 - 61
native/stl_accel/src/actors.rs

@@ -157,6 +157,7 @@ pub enum StationMsg {
     },
     PowerSequenceDone {
         boot_id: String,
+        seq_id: u64,
         ok: bool,
         resolved_host: Option<String>,
         err_msg: Option<String>,
@@ -189,6 +190,7 @@ pub enum IpmiJob {
         pass: String,
         hint_off: bool,
         boot_id: String,
+        seq_id: u64,
         station_id: String,
         debug_log_path: Option<PathBuf>,
     },
@@ -1067,6 +1069,8 @@ fn dispatch_pending_bmc_power(
                 st.power_seq_started_ms = 0;
                 return;
             }
+            st.power_seq_id = st.power_seq_id.wrapping_add(1).max(1);
+            let seq_id = st.power_seq_id;
             st.power_seq_in_progress = true;
             st.power_seq_started_ms = now_ms();
             let _ = ipmi_tx.send(IpmiJob::SmartRestart {
@@ -1075,6 +1079,7 @@ fn dispatch_pending_bmc_power(
                 pass: st.bmc_password.clone(),
                 hint_off: st.server_power == "off",
                 boot_id: st.boot_id.clone(),
+                seq_id,
                 station_id: st.station_id.clone(),
                 debug_log_path: st.debug_log_path.clone(),
             });
@@ -1082,6 +1087,76 @@ fn dispatch_pending_bmc_power(
     }
 }
 
+pub fn apply_runtime_disconnect_policy(
+    st: &mut StationState,
+    offline_since_ms: &mut Option<i64>,
+    active_disconnect_logged: &mut bool,
+    now: i64,
+) -> bool {
+    if st.power_seq_in_progress {
+        *offline_since_ms = None;
+        return false;
+    }
+    let bmc_disconnected = !st.bmc_enabled
+        || st.bmc_host.is_empty()
+        || st.bmc_state == "offline"
+        || st.bmc_state == "disabled";
+    let serial_disconnected = !st.console_online && st.pty_master_fd < 0;
+    if !(bmc_disconnected && serial_disconnected) {
+        let mut dirty = false;
+        if *active_disconnect_logged {
+            st.log_debug(
+                "CONN",
+                &format!(
+                    "RECONNECTED_ACTIVE_RUN boot_id={} bmc_state={} console_online={} started={}",
+                    st.boot_id, st.bmc_state, st.console_online, st.run_started_unix_ms
+                ),
+            );
+            *active_disconnect_logged = false;
+            if st.observed_detail == "link_offline_waiting" {
+                st.observed_detail = "link_recovered".to_string();
+                dirty = true;
+            }
+        }
+        *offline_since_ms = None;
+        return dirty;
+    }
+    if st.is_run_active() {
+        let since = *offline_since_ms.get_or_insert(now);
+        if now.saturating_sub(since) >= 5_000 {
+            let mut dirty = false;
+            if st.observed_detail != "link_offline_waiting" {
+                st.observed_detail = "link_offline_waiting".to_string();
+                dirty = true;
+            }
+            if !*active_disconnect_logged {
+                *active_disconnect_logged = true;
+                st.log_debug(
+                    "CONN",
+                    &format!(
+                        "DISCONNECT_PRESERVE_ACTIVE_RUN boot_id={} started={} task_status={}",
+                        st.boot_id, st.run_started_unix_ms, st.task_status
+                    ),
+                );
+            }
+            return dirty;
+        }
+        return false;
+    }
+    *active_disconnect_logged = false;
+    if st.has_stale_station_state() {
+        let since = *offline_since_ms.get_or_insert(now);
+        if now.saturating_sub(since) >= 5_000 {
+            st.reset_on_disconnect();
+            *offline_since_ms = None;
+            return true;
+        }
+    } else {
+        *offline_since_ms = None;
+    }
+    false
+}
+
 #[allow(clippy::too_many_arguments)]
 pub fn spawn_station_actor(
     actor_idx: usize,
@@ -1132,12 +1207,14 @@ pub fn spawn_station_actor(
                         pass,
                         hint_off: _,
                         boot_id,
+                        seq_id,
                         station_id,
                         debug_log_path,
                     } => {
                         if host.is_empty() {
                             let _ = actor_tx_for_ipmi.send(StationMsg::PowerSequenceDone {
                                 boot_id,
+                                seq_id,
                                 ok: false,
                                 resolved_host: None,
                                 err_msg: Some("BMC host 为空,无法执行先关机再开机".to_string()),
@@ -1162,31 +1239,43 @@ pub fn spawn_station_actor(
                             }
                         };
 
+                        let seq_begin = Instant::now();
                         let mut resolved: Option<String> = None;
-                        log_pwr(&format!("SEQ_BEGIN host={} boot_id={}", host, boot_id));
+                        log_pwr(&format!(
+                            "SEQ_BEGIN host={} boot_id={} seq_id={}",
+                            host, boot_id, seq_id
+                        ));
 
-                        // Step 1: Ensure verified POWER OFF (up to 4 retries, 35s timeout)
+                        // Step 1: Ensure verified POWER OFF (up to 5 retries, 38s timeout)
                         let mut off_verified = false;
-                        if let Ok((rh, s)) = run_ipmi_with_session(
+                        let mut last_off_status;
+                        match run_ipmi_with_session(
                             Some(&mut session),
                             &host,
                             &user,
                             &pass,
                             &["chassis", "power", "status"],
                         ) {
-                            resolved = Some(rh);
-                            if s.to_ascii_lowercase().contains(" is off") {
-                                off_verified = true;
-                                log_pwr("STEP1_OFF_ALREADY_VERIFIED");
+                            Ok((rh, s)) => {
+                                resolved = Some(rh);
+                                last_off_status = s.trim().to_string();
+                                if last_off_status.to_ascii_lowercase().contains(" is off") {
+                                    off_verified = true;
+                                    log_pwr(&format!("STEP1_OFF_ALREADY_VERIFIED seq_id={}", seq_id));
+                                }
+                            }
+                            Err(e) => {
+                                last_off_status = format!("err:{}", e);
+                                log_pwr(&format!("STEP1_OFF_STATUS err={}", e));
                             }
                         }
 
                         if !off_verified {
-                            let off_deadline = Instant::now() + Duration::from_secs(35);
+                            let off_deadline = Instant::now() + Duration::from_secs(38);
                             let mut off_attempts: u32 = 0;
                             let mut last_off_send = Instant::now() - Duration::from_secs(10);
                             while Instant::now() < off_deadline {
-                                if off_attempts < 4
+                                if off_attempts < 5
                                     && last_off_send.elapsed() >= Duration::from_millis(2500)
                                 {
                                     off_attempts += 1;
@@ -1212,19 +1301,31 @@ pub fn spawn_station_actor(
                                     thread::sleep(Duration::from_millis(1200));
                                 }
                                 let target_h = resolved.as_deref().unwrap_or(&host);
-                                if let Ok((rh, s)) = run_ipmi_with_session(
+                                match run_ipmi_with_session(
                                     Some(&mut session),
                                     target_h,
                                     &user,
                                     &pass,
                                     &["chassis", "power", "status"],
                                 ) {
-                                    resolved = Some(rh);
-                                    let low = s.to_ascii_lowercase();
-                                    if low.contains(" is off") {
-                                        off_verified = true;
-                                        log_pwr(&format!("STEP1_OFF_VERIFIED attempts={}", off_attempts));
-                                        break;
+                                    Ok((rh, s)) => {
+                                        resolved = Some(rh);
+                                        last_off_status = s.trim().to_string();
+                                        let low = last_off_status.to_ascii_lowercase();
+                                        if low.contains(" is off") {
+                                            off_verified = true;
+                                            log_pwr(&format!(
+                                                "STEP1_OFF_VERIFIED attempts={} seq_id={} elapsed_ms={}",
+                                                off_attempts,
+                                                seq_id,
+                                                seq_begin.elapsed().as_millis()
+                                            ));
+                                            break;
+                                        }
+                                    }
+                                    Err(e) => {
+                                        last_off_status = format!("err:{}", e);
+                                        log_pwr(&format!("STEP1_OFF_STATUS attempt={} err={}", off_attempts, e));
                                     }
                                 }
                             }
@@ -1232,12 +1333,19 @@ pub fn spawn_station_actor(
 
                         if !off_verified {
                             let err = format!(
-                                "BMC ({}) 关机确认超时或重试 4 次后仍未处于 Power Off",
+                                "BMC ({}) 关机确认超时或重试 5 次后仍未处于 Power Off",
                                 resolved.as_deref().unwrap_or(&host)
                             );
-                            log_pwr(&format!("STEP1_OFF_FAILED {}", err));
+                            log_pwr(&format!(
+                                "STEP1_OFF_FAILED seq_id={} elapsed_ms={} last_status='{}' err={}",
+                                seq_id,
+                                seq_begin.elapsed().as_millis(),
+                                last_off_status,
+                                err
+                            ));
                             let _ = actor_tx_for_ipmi.send(StationMsg::PowerSequenceDone {
                                 boot_id,
+                                seq_id,
                                 ok: false,
                                 resolved_host: resolved,
                                 err_msg: Some(err),
@@ -1259,13 +1367,14 @@ pub fn spawn_station_actor(
                         log_pwr("STEP2_DISCHARGE_WAIT_MS=2000");
                         thread::sleep(Duration::from_millis(2000));
 
-                        // Step 3: Ensure verified POWER ON (up to 4 retries, 35s timeout)
+                        // Step 3: Ensure verified POWER ON (up to 5 retries, 38s timeout)
                         let mut on_verified = false;
-                        let on_deadline = Instant::now() + Duration::from_secs(35);
+                        let mut last_on_status = String::new();
+                        let on_deadline = Instant::now() + Duration::from_secs(38);
                         let mut on_attempts: u32 = 0;
                         let mut last_on_send = Instant::now() - Duration::from_secs(10);
                         while Instant::now() < on_deadline {
-                            if on_attempts < 4
+                            if on_attempts < 5
                                 && last_on_send.elapsed() >= Duration::from_millis(2500)
                             {
                                 on_attempts += 1;
@@ -1291,18 +1400,30 @@ pub fn spawn_station_actor(
                                 thread::sleep(Duration::from_millis(1200));
                             }
                             let target_h = resolved.as_deref().unwrap_or(&host);
-                            if let Ok((rh, s)) = run_ipmi_with_session(
+                            match run_ipmi_with_session(
                                 Some(&mut session),
                                 target_h,
                                 &user,
                                 &pass,
                                 &["chassis", "power", "status"],
                             ) {
-                                resolved = Some(rh);
-                                if s.to_ascii_lowercase().contains(" is on") {
-                                    on_verified = true;
-                                    log_pwr(&format!("STEP3_ON_VERIFIED attempts={}", on_attempts));
-                                    break;
+                                Ok((rh, s)) => {
+                                    resolved = Some(rh);
+                                    last_on_status = s.trim().to_string();
+                                    if last_on_status.to_ascii_lowercase().contains(" is on") {
+                                        on_verified = true;
+                                        log_pwr(&format!(
+                                            "STEP3_ON_VERIFIED attempts={} seq_id={} elapsed_ms={}",
+                                            on_attempts,
+                                            seq_id,
+                                            seq_begin.elapsed().as_millis()
+                                        ));
+                                        break;
+                                    }
+                                }
+                                Err(e) => {
+                                    last_on_status = format!("err:{}", e);
+                                    log_pwr(&format!("STEP3_ON_STATUS attempt={} err={}", on_attempts, e));
                                 }
                             }
                         }
@@ -1311,14 +1432,21 @@ pub fn spawn_station_actor(
                             None
                         } else {
                             let e = format!(
-                                "BMC ({}) 开机确认超时或重试 4 次后仍未处于 Power On",
+                                "BMC ({}) 开机确认超时或重试 5 次后仍未处于 Power On",
                                 resolved.as_deref().unwrap_or(&host)
                             );
-                            log_pwr(&format!("STEP3_ON_FAILED {}", e));
+                            log_pwr(&format!(
+                                "STEP3_ON_FAILED seq_id={} elapsed_ms={} last_status='{}' err={}",
+                                seq_id,
+                                seq_begin.elapsed().as_millis(),
+                                last_on_status,
+                                e
+                            ));
                             Some(e)
                         };
                         let _ = actor_tx_for_ipmi.send(StationMsg::PowerSequenceDone {
                             boot_id,
+                            seq_id,
                             ok: on_verified,
                             resolved_host: resolved,
                             err_msg,
@@ -1612,6 +1740,7 @@ pub fn spawn_station_actor(
             let mut pending_sdr_refresh = false;
             let mut last_seen_boot_id = st.boot_id.clone();
             let mut offline_since_ms: Option<i64> = None;
+            let mut active_disconnect_logged = false;
             let mut ev_tokens = [0u64; 8];
             let mut ev_masks = [0u32; 8];
 
@@ -1965,20 +2094,28 @@ pub fn spawn_station_actor(
                         }
                         StationMsg::PowerSequenceDone {
                             boot_id,
+                            seq_id,
                             ok,
                             resolved_host,
                             err_msg,
                         } => {
-                            if !boot_id.is_empty() && boot_id != st.boot_id {
+                            if (!boot_id.is_empty() && boot_id != st.boot_id)
+                                || (seq_id != 0 && seq_id != st.power_seq_id)
+                            {
                                 st.log_debug(
                                     "POWER",
                                     &format!(
-                                        "STALE_SEQUENCE_IGNORED seq_boot_id={} current_boot_id={} ok={}",
-                                        boot_id, st.boot_id, ok
+                                        "STALE_SEQUENCE_IGNORED seq_id={} current_seq_id={} seq_boot_id={} current_boot_id={} ok={}",
+                                        seq_id, st.power_seq_id, boot_id, st.boot_id, ok
                                     ),
                                 );
                                 continue;
                             }
+                            let seq_elapsed_ms = if st.power_seq_started_ms > 0 {
+                                now_ms().saturating_sub(st.power_seq_started_ms)
+                            } else {
+                                0
+                            };
                             st.power_seq_in_progress = false;
                             st.power_seq_started_ms = 0;
                             if ok {
@@ -2000,8 +2137,8 @@ pub fn spawn_station_actor(
                                 st.log_debug(
                                     "POWER",
                                     &format!(
-                                        "SEQUENCE_DONE ok=true boot_id={} run_started={} boot_seq={}",
-                                        st.boot_id, st.run_started_unix_ms, st.boot_seq
+                                        "SEQUENCE_DONE ok=true boot_id={} seq_id={} elapsed_ms={} run_started={} boot_seq={}",
+                                        st.boot_id, seq_id, seq_elapsed_ms, st.run_started_unix_ms, st.boot_seq
                                     ),
                                 );
                                 if matches!(
@@ -2026,7 +2163,10 @@ pub fn spawn_station_actor(
                                     .unwrap_or_else(|| "BMC 先关机再开机电源序列失败".to_string());
                                 st.log_debug(
                                     "POWER",
-                                    &format!("SEQUENCE_DONE ok=false boot_id={} err={}", st.boot_id, msg),
+                                    &format!(
+                                        "SEQUENCE_DONE ok=false boot_id={} seq_id={} elapsed_ms={} err={}",
+                                        st.boot_id, seq_id, seq_elapsed_ms, msg
+                                    ),
                                 );
                                 if st.is_run_active() {
                                     st.task_status = "failed".to_string();
@@ -2328,32 +2468,16 @@ pub fn spawn_station_actor(
 
                 // 6b. Real-time disconnect/idle reset: once BOTH console and BMC are offline
                 // (or station is unconfigured idle), clear stale channel PASS/FAIL, presence,
-                // temperatures, and run state so frontends never display phantom legacy states.
-                if enable_hw_bg_probes {
-                    if st.power_seq_in_progress {
-                        offline_since_ms = None;
-                    } else {
-                        let bmc_disconnected = !st.bmc_enabled
-                            || st.bmc_host.is_empty()
-                            || st.bmc_state == "offline"
-                            || st.bmc_state == "disabled";
-                        let serial_disconnected = !st.console_online && st.pty_master_fd < 0;
-                        if bmc_disconnected && serial_disconnected {
-                            if st.has_stale_station_state() {
-                                let since = *offline_since_ms.get_or_insert(now);
-                                let grace_ms = if st.is_run_active() { 90_000 } else { 5_000 };
-                                if now.saturating_sub(since) >= grace_ms {
-                                    st.reset_on_disconnect();
-                                    offline_since_ms = None;
-                                    state_dirty = true;
-                                }
-                            } else {
-                                offline_since_ms = None;
-                            }
-                        } else {
-                            offline_since_ms = None;
-                        }
-                    }
+                // temperatures, and run state ONLY when no active test run is in progress.
+                if enable_hw_bg_probes
+                    && apply_runtime_disconnect_policy(
+                        &mut st,
+                        &mut offline_since_ms,
+                        &mut active_disconnect_logged,
+                        now,
+                    )
+                {
+                    state_dirty = true;
                 }
 
                 // 7. Publish updated ring offsets & station snapshot + emit active `task_complete` push

+ 21 - 6
native/stl_accel/src/api.rs

@@ -276,6 +276,8 @@ impl AppHub {
                 .name("stl-state-pub".to_string())
                 .spawn(move || {
                     let mut last_pub = Instant::now() - Duration::from_secs(2);
+                    let mut last_web_dirty = Instant::now() - Duration::from_secs(2);
+                    let mut pending_web_dirty = 0u64;
                     loop {
                         let dirty = {
                             let mut guard = bg_hub
@@ -304,13 +306,20 @@ impl AppHub {
                                 }
                                 let elapsed_hb = last_pub.elapsed();
                                 let hb_wait = Duration::from_millis(1000).saturating_sub(elapsed_hb);
-                                if hb_wait.is_zero() {
+                                let web_wait = if pending_web_dirty != 0 {
+                                    Duration::from_millis(500)
+                                        .saturating_sub(last_web_dirty.elapsed())
+                                } else {
+                                    hb_wait
+                                };
+                                let wait_dur = hb_wait.min(web_wait);
+                                if wait_dur.is_zero() {
                                     break 0;
                                 }
                                 let (g, res) = bg_hub
                                     .dirty_cond
                                     .1
-                                    .wait_timeout(guard, hb_wait)
+                                    .wait_timeout(guard, wait_dur)
                                     .unwrap_or_else(|e| e.into_inner());
                                 guard = g;
                                 if res.timed_out() {
@@ -321,9 +330,14 @@ impl AppHub {
                         last_pub = Instant::now();
                         bg_hub.refresh_and_broadcast_qt_state();
                         let active_mask = bg_hub.active_station_mask();
-                        let notify_mask = dirty | active_mask;
-                        if notify_mask != 0 {
-                            bg_hub.push_hub.broadcast_web_dirty(notify_mask);
+                        pending_web_dirty |= dirty | active_mask;
+                        if pending_web_dirty != 0
+                            && last_web_dirty.elapsed() >= Duration::from_millis(500)
+                        {
+                            let emit_mask = pending_web_dirty;
+                            pending_web_dirty = 0;
+                            last_web_dirty = Instant::now();
+                            bg_hub.push_hub.broadcast_web_dirty(emit_mask);
                         }
                     }
                 })
@@ -892,7 +906,8 @@ impl AppHub {
         let res = self.dispatch_rpc_inner(method, params, is_qt_clean);
         let is_polling = matches!(
             method,
-            "GetState"
+            "GetSystemInfo"
+                | "GetState"
                 | "ListStations"
                 | "GetStation"
                 | "GetStationControl"

+ 17 - 1
native/stl_accel/src/commands.rs

@@ -1043,6 +1043,8 @@ pub fn handle_station_command_nonblocking(
             }
             st.boot_execution
                 .set("state", JsonVal::Str("completed".to_string()));
+            st.boot_execution
+                .set("current_stage", JsonVal::Str("uefi".to_string()));
             st.boot_execution.set(
                 "waiting_reason",
                 JsonVal::Str("已跳过 MT 测试并完成本轮流程".to_string()),
@@ -1117,6 +1119,20 @@ pub fn handle_station_command_nonblocking(
             }
             st.boot_execution
                 .set("state", JsonVal::Str("running".to_string()));
+            st.boot_execution.set(
+                "current_stage",
+                JsonVal::Str(if mark_mt_started { "mt" } else { "uefi" }.to_string()),
+            );
+            st.boot_execution.set(
+                "waiting_reason",
+                JsonVal::Str(if mark_mt_started {
+                    "正在启动 MemTest86 (118.efi) 内存测试".to_string()
+                } else {
+                    "已到达 UEFI Shell,正在探测 118.efi 所在卷并准备启动 MT".to_string()
+                }),
+            );
+            st.boot_execution
+                .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
             let extra_steps = if mark_mt_started { 0 } else { 24 };
             let timeout_ms = ((steps.len() + extra_steps) as u64) * 4000 + 2000;
             let (tx, rx) = mpsc::channel();
@@ -1748,11 +1764,11 @@ pub fn handle_station_command_nonblocking(
             }
             if act == "host_off" && st.is_run_active() {
                 let now = now_ms();
-                st.freeze_run_timing(now);
                 st.single_run_active = false;
                 st.plan_paused = false;
                 st.async_script.clear();
                 st.task_status = "interrupted".to_string();
+                st.freeze_run_timing(now);
                 st.boot_execution.set("state", JsonVal::Str("stopped".to_string()));
                 st.boot_execution.set(
                     "waiting_reason",

+ 326 - 0
native/stl_accel/src/main.rs

@@ -3966,6 +3966,7 @@ Please press ENTER to start UIP\r\n\
         // Stale PowerSequenceDone from wrong boot_id is ignored; matching PowerSequenceDone completes cleanly
         s1.send(StationMsg::PowerSequenceDone {
             boot_id: "WRONG-BOOT".to_string(),
+            seq_id: 0,
             ok: false,
             resolved_host: None,
             err_msg: Some("stale".to_string()),
@@ -3976,6 +3977,7 @@ Please press ENTER to start UIP\r\n\
         let cur_boot_id = hub.read_station_view("S1").unwrap().boot_id;
         s1.send(StationMsg::PowerSequenceDone {
             boot_id: cur_boot_id,
+            seq_id: 0,
             ok: true,
             resolved_host: Some("192.168.2.166".to_string()),
             err_msg: None,
@@ -4203,4 +4205,328 @@ FS0:\\EFI\\> \r\n",
 
         let _ = std::fs::remove_dir_all(&tmp_dir);
     }
+
+    #[test]
+    fn test_v29_rmt_succeeded_disconnect_policy_and_mt_dedup() {
+        use crate::actors::{apply_runtime_disconnect_policy, StationMsg};
+        use crate::results::{now_ms, StationState};
+        use crate::workflow::control_boot_plan;
+
+        lib::init_hardware();
+        let tmp_dir = env::temp_dir().join(format!(
+            "stl-v29-fixes-{}-{}",
+            std::process::id(),
+            now_ms()
+        ));
+        let _ = std::fs::remove_dir_all(&tmp_dir);
+        std::fs::create_dir_all(tmp_dir.join("station-controls")).unwrap();
+        std::fs::create_dir_all(tmp_dir.join("debug")).unwrap();
+
+        // 1. Disconnect policy: preserve active running task/timer across transient BMC+SOL offline; reset idle run
+        let mut st_disc = StationState::new("S3", "Station 3", "192.168.2.167", "");
+        st_disc.debug_log_path = Some(tmp_dir.join("debug").join("S3.log"));
+        let _ = control_boot_plan(&mut st_disc, "restart", &tmp_dir).unwrap();
+        st_disc.power_seq_in_progress = false;
+        let run_t0_disc = st_disc.run_started_unix_ms;
+        assert!(run_t0_disc > 0);
+        assert!(st_disc.is_run_active());
+        st_disc.bmc_state = "offline".to_string();
+        st_disc.console_online = false;
+        st_disc.pty_master_fd = -1;
+
+        let mut offline_since = None;
+        let mut active_logged = false;
+        let base_t = now_ms();
+        assert!(!apply_runtime_disconnect_policy(
+            &mut st_disc,
+            &mut offline_since,
+            &mut active_logged,
+            base_t,
+        ));
+        assert!(apply_runtime_disconnect_policy(
+            &mut st_disc,
+            &mut offline_since,
+            &mut active_logged,
+            base_t + 6_000,
+        ));
+        assert_eq!(st_disc.task_status, "running");
+        assert_eq!(st_disc.run_started_unix_ms, run_t0_disc);
+        assert_eq!(st_disc.observed_detail, "link_offline_waiting");
+        assert!(active_logged);
+
+        // Recovery clears waiting detail and logs RECONNECTED_ACTIVE_RUN
+        st_disc.console_online = true;
+        assert!(apply_runtime_disconnect_policy(
+            &mut st_disc,
+            &mut offline_since,
+            &mut active_logged,
+            base_t + 7_000,
+        ));
+        assert!(!active_logged);
+        assert_eq!(st_disc.observed_detail, "link_recovered");
+
+        // Now mark completed + offline -> idle disconnect DOES reset stale run state
+        st_disc.single_run_active = false;
+        st_disc.task_status = "completed".to_string();
+        st_disc.freeze_run_timing(base_t + 8_000);
+        st_disc.boot_execution.set("state", JsonVal::Str("completed".to_string()));
+        st_disc.console_online = false;
+        assert!(!apply_runtime_disconnect_policy(
+            &mut st_disc,
+            &mut offline_since,
+            &mut active_logged,
+            base_t + 9_000,
+        ));
+        assert!(apply_runtime_disconnect_policy(
+            &mut st_disc,
+            &mut offline_since,
+            &mut active_logged,
+            base_t + 15_000,
+        ));
+        assert_eq!(st_disc.task_status, "not_started");
+        assert_eq!(st_disc.run_started_unix_ms, 0);
+
+        let s3_log = std::fs::read_to_string(tmp_dir.join("debug").join("S3.log")).unwrap();
+        assert!(s3_log.contains("DISCONNECT_PRESERVE_ACTIVE_RUN"));
+        assert!(s3_log.contains("RECONNECTED_ACTIVE_RUN"));
+
+        // 2. Full AppHub test: GetSystemInfo excluded from RPC logs, stale seq_id ignored,
+        //    108_VD012 RMT SUCCEEDED sets rmt_complete=true + DIMM stage_rmt=pass (while Skipped stays false),
+        //    MT 26/26 preserves 26/26 across # Tests Completed : 1/1 and emits single MT_PASS_COMPLETE
+        let args = ServerArgs {
+            config_path: Path::new("config/backend.example.json").to_path_buf(),
+            data_dir: tmp_dir.clone(),
+            web_listen: "127.0.0.1:0".to_string(),
+            tftp_listen: "disabled".to_string(),
+            web_dir: Path::new("web").to_path_buf(),
+            contracts_path: Path::new("contracts/firmware-vd012.json").to_path_buf(),
+            web_password: None,
+            version: "0.8.1.29".to_string(),
+            commit: "unit-test".to_string(),
+        };
+        let hub = AppHub::init_for_test(&args);
+        let s1 = hub.stations.get("S1").unwrap();
+
+        let sys_info = hub.dispatch_rpc("GetSystemInfo", &JsonVal::obj(), false).unwrap();
+        assert_eq!(sys_info.get_str_or("version", ""), "0.8.1.29");
+
+        // Run A: Skipped RMT must stay rmt_complete=false
+        let req_skip = parse_json(
+            r#"{
+                "command_id": "v29-skip",
+                "station_id": "S1",
+                "run_rmt": false,
+                "run_amt": false,
+                "run_mt": false
+            }"#,
+        )
+        .unwrap();
+        hub.dispatch_rpc("StartTest", &req_skip, true).unwrap();
+        let cur_boot_skip = hub.read_station_view("S1").unwrap().boot_id;
+        s1.send(StationMsg::PowerSequenceDone {
+            boot_id: cur_boot_skip.clone(),
+            seq_id: 999,
+            ok: false,
+            resolved_host: None,
+            err_msg: Some("stale seq".to_string()),
+        });
+        s1.send(StationMsg::PowerSequenceDone {
+            boot_id: cur_boot_skip,
+            seq_id: 0,
+            ok: true,
+            resolved_host: Some("192.168.2.165".to_string()),
+            err_msg: None,
+        });
+        hub.force_tick("S1");
+        hub.test_inject_serial(
+            "S1",
+            b"[HS_BIOS]Version:GNRSRF_AP(SDP)_RDIMM_108_VD012_20260612\r\n\
+[HS_DRAM]Socket:0,Channel:0,Dimm:0,Rank:2,Size:64GB,Width:x4,Vendor:Hynix,Type:DDR5 RDIMM,Speed:5600,HS_DIMM_SN:SN0A,DimmLocation:CPU0_CHA\r\n\
+[HS_DRAM]Socket:1,Channel:0,Dimm:0,Rank:2,Size:64GB,Width:x4,Vendor:Hynix,Type:DDR5 RDIMM,Speed:5600,HS_DIMM_SN:SN1A,DimmLocation:CPU1_CHA\r\n\
+[HS_BIOS][Training][ScktId: 1][125]Rank Margin Tool -- Skipped,Time=0 ms\r\n\
+[HS_BIOS][Training][ScktId: 0][131]Rank Margin Tool -- Disabled,Time=0 ms\r\n",
+            Some("running"),
+            false,
+        );
+        assert_eq!(
+            hub.read_station_view("S1")
+                .unwrap()
+                .stage_completions
+                .get_bool("rmt_complete"),
+            Some(false)
+        );
+
+        // Stop explicitly -> TIMER FREEZE must record task_status=interrupted
+        let _ = hub
+            .dispatch_rpc(
+                "EnqueueCommand",
+                &parse_json(r#"{"station_id":"S1","method":"ControlBootPlan","arguments":{"action":"stop"}}"#).unwrap(),
+                false,
+            )
+            .unwrap();
+
+        // Run B: Full 26-test MT + real 108_VD012 RMT SUCCEEDED on both sockets
+        let req_full = parse_json(
+            r#"{
+                "command_id": "v29-full",
+                "station_id": "S1",
+                "run_rmt": true,
+                "run_amt": false,
+                "run_mt": true,
+                "mt": {
+                    "enabled": true,
+                    "memory_range": "all",
+                    "numpass": 1,
+                    "exit_mode": 2
+                }
+            }"#,
+        )
+        .unwrap();
+        hub.dispatch_rpc("StartTest", &req_full, true).unwrap();
+        let cur_boot_full = hub.read_station_view("S1").unwrap().boot_id;
+        s1.send(StationMsg::PowerSequenceDone {
+            boot_id: cur_boot_full,
+            seq_id: 0,
+            ok: true,
+            resolved_host: Some("192.168.2.165".to_string()),
+            err_msg: None,
+        });
+        hub.force_tick("S1");
+        let after_power_on = hub.dispatch_rpc(
+            "GetStationControl",
+            &parse_json(r#"{"station_id":"S1"}"#).unwrap(),
+            false,
+        ).unwrap();
+        let be_boot = after_power_on.get("boot_execution").unwrap();
+        assert_eq!(be_boot.get_str_or("current_stage", ""), "boot");
+
+        // UIP Stage 1 prompt arrives -> current_stage advances from "boot" -> "uip1"
+        hub.test_inject_serial(
+            "S1",
+            b"[HS_BIOS]Version:GNRSRF_AP(SDP)_RDIMM_108_VD012_20260612\r\n\
+[HS_DRAM]Socket:0,Channel:0,Dimm:0,Rank:2,Size:64GB,Width:x4,Vendor:Hynix,Type:DDR5 RDIMM,Speed:5600,HS_DIMM_SN:SN0A,DimmLocation:CPU0_CHA\r\n\
+[HS_DRAM]Socket:1,Channel:0,Dimm:0,Rank:2,Size:64GB,Width:x4,Vendor:Hynix,Type:DDR5 RDIMM,Speed:5600,HS_DIMM_SN:SN1A,DimmLocation:CPU1_CHA\r\n\
+[0] Please input your command:",
+            Some("running"),
+            false,
+        );
+        let after_uip1 = hub.dispatch_rpc(
+            "GetStationControl",
+            &parse_json(r#"{"station_id":"S1"}"#).unwrap(),
+            false,
+        ).unwrap();
+        assert_eq!(
+            after_uip1.get("boot_execution").and_then(|b| b.get_str("current_stage")),
+            Some("uip1")
+        );
+
+        // RMT stage starts & finishes -> current_stage advances to "rmt" (not stuck at stale boot/amt!)
+        hub.test_inject_serial(
+            "S1",
+            b"\r\n[ScktId: 1] Rank Margin Tool -- Started\r\n\
+[ScktId: 0] Rank Margin Tool -- Started\r\n\
+[HS_BIOS][Training][ScktId: 1][125]Rank Margin Tool -- SUCCEEDED,Time=18 ms\r\n\
+[HS_BIOS][Training][ScktId: 0][131]Rank Margin Tool -- SUCCEEDED,Time=25 ms\r\n",
+            Some("running"),
+            false,
+        );
+        let after_rmt = hub.dispatch_rpc(
+            "GetStationControl",
+            &parse_json(r#"{"station_id":"S1"}"#).unwrap(),
+            false,
+        ).unwrap();
+        assert_eq!(
+            after_rmt.get("boot_execution").and_then(|b| b.get_str("current_stage")),
+            Some("rmt")
+        );
+
+        // UEFI Shell arrives -> transitions to "uefi", then MT starts -> "mt" WHILE still running
+        hub.test_inject_serial(
+            "S1",
+            b"UEFI Interactive Shell v2.2\r\nFS0:\\EFI\\> ",
+            Some("running"),
+            false,
+        );
+        let after_uefi = hub.dispatch_rpc(
+            "GetStationControl",
+            &parse_json(r#"{"station_id":"S1"}"#).unwrap(),
+            false,
+        ).unwrap();
+        assert_eq!(
+            after_uefi.get("boot_execution").and_then(|b| b.get_str("current_stage")),
+            Some("uefi")
+        );
+
+        hub.test_inject_serial(
+            "S1",
+            b"\r\n118.efi\r\n\
+Hovsee V0.1 Pro Build: 1000No UI (64-bit)\r\n\
+2026-11-18 19:00:01 - Running test #0 (Test 0: Address test)\r\n",
+            Some("running"),
+            false,
+        );
+        let during_mt = hub.dispatch_rpc(
+            "GetStationControl",
+            &parse_json(r#"{"station_id":"S1"}"#).unwrap(),
+            false,
+        ).unwrap();
+        let be_mt = during_mt.get("boot_execution").unwrap();
+        assert_eq!(be_mt.get_str_or("state", ""), "running");
+        assert_eq!(be_mt.get_str_or("current_stage", ""), "mt");
+        assert!(be_mt.get_str_or("waiting_reason", "").contains("MemTest86"));
+
+        hub.test_inject_serial(
+            "S1",
+            b"2026-11-18 19:00:02 - MtSupportRunAllTests - Test execution time: 1.0s (Test 0)\r\n\
+2026-11-18 19:50:00 - Running test #25 (Test 25: Row Hammer test)\r\n\
+2026-11-18 19:50:05 - MtSupportRunAllTests - Test execution time: 5.0s (Test 25)\r\n\
+2026-11-18 19:50:06 - Finished pass #1 (of 1) (Cumulative error count: 0, buffer full count: 0)\r\n\
+Test result: PASS\r\n\
+# Tests Completed : 1/1\r\n\
+#Tests Passed     : 1/1\r\n\
+FS0:\\EFI\\> \r\n",
+            Some("running"),
+            false,
+        );
+        hub.force_tick("S1");
+        let after_mt_done = hub.dispatch_rpc(
+            "GetStationControl",
+            &parse_json(r#"{"station_id":"S1"}"#).unwrap(),
+            false,
+        ).unwrap();
+        let be_done = after_mt_done.get("boot_execution").unwrap();
+        assert_eq!(be_done.get_str_or("state", ""), "completed");
+        assert_eq!(be_done.get_str_or("current_stage", ""), "mt");
+        assert!(be_done.get_str_or("waiting_reason", "").contains("PASS"));
+        let after_full = hub.read_station_view("S1").unwrap();
+        assert_eq!(after_full.stage_completions.get_bool("rmt_complete"), Some(true));
+        let dimms = after_full.control_base.get_arr("dimms").unwrap();
+        let mut present_rmt_pass = 0usize;
+        for d in dimms {
+            if d.get_str_or("presence", "") == "present" {
+                assert_eq!(
+                    d.get("stages").and_then(|s| s.get_str("rmt")),
+                    Some("pass"),
+                    "DIMM RMT stage must be pass when 108_VD012 RMT SUCCEEDED"
+                );
+                present_rmt_pass += 1;
+            }
+        }
+        assert_eq!(present_rmt_pass, 2);
+
+        let mt_res = after_full.qt_clean_station.get("mt_result").unwrap();
+        assert_eq!(mt_res.get_str_or("status", ""), "pass");
+        assert_eq!(mt_res.get_i64("tests_total"), Some(26));
+        assert_eq!(mt_res.get_i64("tests_completed"), Some(26));
+        assert_eq!(mt_res.get_i64("progress_pct"), Some(100));
+
+        let sys_log = std::fs::read_to_string(tmp_dir.join("debug").join("system.log")).unwrap();
+        assert!(!sys_log.contains("method=GetSystemInfo"));
+        let s1_log = std::fs::read_to_string(tmp_dir.join("debug").join("S1.log")).unwrap();
+        assert!(s1_log.contains("STALE_SEQUENCE_IGNORED seq_id=999"));
+        assert!(s1_log.contains("task_status=interrupted"));
+        assert_eq!(s1_log.matches("MT_PASS_COMPLETE").count(), 1);
+
+        let _ = std::fs::remove_dir_all(&tmp_dir);
+    }
 }

+ 181 - 79
native/stl_accel/src/results.rs

@@ -515,6 +515,7 @@ pub struct StationState {
     pub amt_fallback_attempted: bool,
     pub power_seq_in_progress: bool,
     pub power_seq_started_ms: i64,
+    pub power_seq_id: u64,
     pub debug_log_path: Option<PathBuf>,
     pub persistent_baseline: Option<StationBaselineSnapshot>,
     pub dimm_seen_in_boot: [bool; 24],
@@ -714,6 +715,7 @@ impl StationState {
             amt_fallback_attempted: false,
             power_seq_in_progress: false,
             power_seq_started_ms: 0,
+            power_seq_id: 0,
             debug_log_path: None,
             persistent_baseline: None,
             dimm_seen_in_boot: [false; 24],
@@ -1266,6 +1268,51 @@ impl StationState {
             self.observed_phase = new_phase.to_string();
             self.observed_detail = detail.to_string();
         }
+        let bp_state_now = self.boot_execution.get_str_or("state", "idle");
+        if matches!(bp_state_now.as_str(), "running" | "waiting_boot") {
+            let cur_bp_stage = match self.observed_phase.as_str() {
+                "uip" => {
+                    if self.observed_uip_stage.unwrap_or(1) > 1 {
+                        "uip2"
+                    } else {
+                        "uip1"
+                    }
+                }
+                "training" => "training",
+                "rmt" => "rmt",
+                "amt" => "amt",
+                "post" => "post",
+                "uefi" => "uefi",
+                "mt" => "mt",
+                "boot" => "boot",
+                _ => "",
+            };
+            if !cur_bp_stage.is_empty() {
+                let prev_bp_stage = self.boot_execution.get_str_or("current_stage", "");
+                if prev_bp_stage != cur_bp_stage || prev_phase != self.observed_phase {
+                    let default_reason = match cur_bp_stage {
+                        "uip1" => "已进入 ICT Stage 1 阶段,等待/下发 ICT 参数",
+                        "uip2" => "已进入 ICT Stage 2 阶段,等待/下发 Stage 2 参数",
+                        "training" => "正在执行 DDR Training 内存训练",
+                        "rmt" => "正在执行 RMT 眼图裕量扫描",
+                        "amt" => "已进入 AMT 阶段,等待处理或执行测试",
+                        "post" => "正在执行 POST / DXE 启动,等待进入 UEFI Shell",
+                        "uefi" => "已进入 UEFI Shell",
+                        "mt" => "正在执行 MemTest86 (118.efi) 内存测试",
+                        "boot" => "正在启动 BIOS,等待 ICT Stage 1 提示符",
+                        _ => "",
+                    };
+                    self.boot_execution
+                        .set("current_stage", JsonVal::Str(cur_bp_stage.to_string()));
+                    if !default_reason.is_empty() {
+                        self.boot_execution
+                            .set("waiting_reason", JsonVal::Str(default_reason.to_string()));
+                    }
+                    self.boot_execution
+                        .set("updated_unix_ms", JsonVal::Num(now as f64));
+                }
+            }
+        }
         if prev_phase != self.observed_phase || detail == "rmt_completed" || detail == "mt_complete" {
             self.log_debug(
                 "STAGE",
@@ -1576,7 +1623,10 @@ impl StationState {
             self.dimms[idx].stage_training = "pass".to_string();
         }
         if self.hot.rmt_complete
-            && self.rmt_results.values().any(|r| r.measurement_rows > 0)
+            && self
+                .rmt_results
+                .values()
+                .any(|r| r.measurement_rows > 0 || r.state == "completed")
             && self.dimms[idx].stage_rmt == "idle"
         {
             self.dimms[idx].stage_rmt = "pass".to_string();
@@ -2606,7 +2656,10 @@ impl StationState {
                     self.hot.ict_stage1_complete = true;
                     self.hot.training_complete = true;
                     if self.observed_stages.contains("rmt")
-                        && self.rmt_results.values().any(|r| r.measurement_rows > 0)
+                        && self
+                            .rmt_results
+                            .values()
+                            .any(|r| r.measurement_rows > 0 || r.state == "completed")
                     {
                         for r in self.rmt_results.values_mut() {
                             if r.state != "completed" && r.measurement_rows > 0 {
@@ -2647,7 +2700,10 @@ impl StationState {
                 self.hot.training_complete = true;
                 self.mark_present_channels_training_pass();
                 if self.observed_stages.contains("rmt")
-                    && self.rmt_results.values().any(|r| r.measurement_rows > 0)
+                    && self
+                        .rmt_results
+                        .values()
+                        .any(|r| r.measurement_rows > 0 || r.state == "completed")
                 {
                     for r in self.rmt_results.values_mut() {
                         if r.state != "completed" && r.measurement_rows > 0 {
@@ -2801,7 +2857,10 @@ impl StationState {
                         verdict_supported: false,
                     });
                     entry.execution_supported = true;
-                    if entry.measurement_rows > 0 {
+                    if ev.subkind == 3 {
+                        entry.state = "skipped".to_string();
+                        entry.verdict_supported = false;
+                    } else if entry.measurement_rows > 0 || ev.subkind == 1 {
                         entry.state = "completed".to_string();
                         entry.verdict_supported = true;
                     } else {
@@ -2832,17 +2891,31 @@ impl StationState {
                 self.prompt_ready = false;
                 self.hot.prompt_ready = false;
                 let has_rmt_rows = self.rmt_results.values().any(|r| r.measurement_rows > 0);
-                if all_done && has_rmt_rows {
+                let has_rmt_completed = self
+                    .rmt_results
+                    .values()
+                    .any(|r| r.measurement_rows > 0 || r.state == "completed");
+                if all_done && has_rmt_completed {
                     self.hot.rmt_complete = true;
                     self.advance_phase("rmt", "rmt_completed", now);
-                } else if has_rmt_rows || self.observed_stages.contains("rmt") {
+                    for idx in 0..24 {
+                        if self.dimms[idx].presence == "present"
+                            && self.dimms[idx].enabled != "disabled"
+                            && self.dimms[idx].failed_stage.is_empty()
+                            && self.dimms[idx].stage_rmt == "idle"
+                        {
+                            self.dimms[idx].stage_rmt = "pass".to_string();
+                            self.sync_dimm_to_soa(idx);
+                        }
+                    }
+                } else if has_rmt_completed || self.observed_stages.contains("rmt") {
                     self.advance_phase("rmt", "rmt_running", now);
                 }
                 self.log_debug(
                     "STAGE",
                     &format!(
-                        "RMT_STOP has_rmt_rows={} all_done={} rmt_complete={} line={}",
-                        has_rmt_rows, all_done, self.hot.rmt_complete, trimmed
+                        "RMT_STOP subkind={} has_rmt_rows={} has_rmt_completed={} all_done={} rmt_complete={} line={}",
+                        ev.subkind, has_rmt_rows, has_rmt_completed, all_done, self.hot.rmt_complete, trimmed
                     ),
                 );
                 *self.stage_step_counts.entry("rmt".to_string()).or_insert(0) += 1;
@@ -2852,7 +2925,10 @@ impl StationState {
                 self.hot.training_complete = true;
                 self.mark_present_channels_training_pass();
                 if self.observed_stages.contains("rmt")
-                    && self.rmt_results.values().any(|r| r.measurement_rows > 0)
+                    && self
+                        .rmt_results
+                        .values()
+                        .any(|r| r.measurement_rows > 0 || r.state == "completed")
                 {
                     for r in self.rmt_results.values_mut() {
                         if r.state != "completed" && r.measurement_rows > 0 {
@@ -3083,43 +3159,44 @@ impl StationState {
                     self.mt_result.set("tests_completed", JsonVal::Num(0.0));
                     self.mt_result.set("progress_pct", JsonVal::Num(0.0));
                 }
-                if ev.kind == lib::STL_LK_MT_PROGRESS {
-                    // `Running test #N` emits val0=tid, val1=25 from re2c; translate to configured test count
-                    if trimmed.contains("Running test #") && ev.val1 == 25 {
-                        let done = (self.mt_completed_test_ids.len() as i64).min(cfg_tot);
-                        let tot = cfg_tot.max(done).max(1);
-                        let cur_tid = (ev.val0 as i64).max(0);
-                        let pct = if done > 0 {
-                            ((done * 100) / tot).clamp(0, 100)
-                        } else if tot > 1 {
-                            ((cur_tid * 100) / tot).clamp(0, 99)
+                if !self.hot.mt_pass_complete && !self.hot.mt_fail_complete {
+                    if ev.kind == lib::STL_LK_MT_PROGRESS {
+                        // `Running test #N` emits val0=tid, val1=25 from re2c; translate to configured test count
+                        if trimmed.contains("Running test #") && ev.val1 == 25 {
+                            let done = (self.mt_completed_test_ids.len() as i64).min(cfg_tot);
+                            let tot = cfg_tot.max(done).max(1);
+                            let cur_tid = (ev.val0 as i64).max(0);
+                            let pct = if done > 0 {
+                                ((done * 100) / tot).clamp(0, 100)
+                            } else if tot > 1 {
+                                ((cur_tid * 100) / tot).clamp(0, 99)
+                            } else {
+                                0
+                            };
+                            self.mt_result
+                                .set("current_test_id", JsonVal::Num(cur_tid as f64));
+                            self.mt_result
+                                .set("tests_completed", JsonVal::Num(done as f64));
+                            self.mt_result
+                                .set("tests_total", JsonVal::Num(tot as f64));
+                            self.mt_result
+                                .set("progress_pct", JsonVal::Num(pct as f64));
                         } else {
-                            0
-                        };
-                        self.mt_result
-                            .set("current_test_id", JsonVal::Num(cur_tid as f64));
-                        self.mt_result
-                            .set("tests_completed", JsonVal::Num(done as f64));
-                        self.mt_result
-                            .set("tests_total", JsonVal::Num(tot as f64));
-                        self.mt_result
-                            .set("progress_pct", JsonVal::Num(pct as f64));
-                    } else {
-                        if ev.val1 > 0 {
-                            if ev.val0 >= 0 {
+                            // Do not let summary `# Tests Completed : 1/1` overwrite multi-test `cfg_tot > 1`
+                            if ev.val1 > 0 && !(ev.val1 == 1 && cfg_tot > 1) {
+                                if ev.val0 >= 0 {
+                                    self.mt_result
+                                        .set("tests_completed", JsonVal::Num(ev.val0 as f64));
+                                }
                                 self.mt_result
-                                    .set("tests_completed", JsonVal::Num(ev.val0 as f64));
+                                    .set("tests_total", JsonVal::Num(ev.val1 as f64));
+                            }
+                            if ev.val2 >= 0 && !(ev.val1 == 1 && cfg_tot > 1) {
+                                self.mt_result
+                                    .set("progress_pct", JsonVal::Num(ev.val2 as f64));
                             }
-                            self.mt_result
-                                .set("tests_total", JsonVal::Num(ev.val1 as f64));
-                        }
-                        if ev.val2 >= 0 {
-                            self.mt_result
-                                .set("progress_pct", JsonVal::Num(ev.val2 as f64));
                         }
                     }
-                }
-                if !self.hot.mt_pass_complete && !self.hot.mt_fail_complete {
                     if self.mt_result.get_str_or("status", "") != "fail" {
                         self.mt_result.set("status", JsonVal::Str("running".to_string()));
                     }
@@ -3183,12 +3260,12 @@ impl StationState {
                 self.hot.mt_banner_seen = true;
                 let has_mt_err = self.stage_errors.get("mt").map(|v| !v.is_empty()).unwrap_or(false)
                     || self.mt_result.get_i64("errors").unwrap_or(0) > 0;
-                self.advance_phase("mt", "mt_complete", now);
-                let boot_active = matches!(
-                    self.boot_execution.get_str_or("state", "idle").as_str(),
-                    "running" | "waiting_user" | "waiting_boot"
-                );
                 if has_mt_err {
+                    self.advance_phase("mt", "mt_complete", now);
+                    let boot_active = matches!(
+                        self.boot_execution.get_str_or("state", "idle").as_str(),
+                        "running" | "waiting_user" | "waiting_boot"
+                    );
                     self.hot.mt_fail_complete = true;
                     self.mt_result.set("status", JsonVal::Str("fail".to_string()));
                     self.mt_result.set("complete", JsonVal::Bool(true));
@@ -3197,38 +3274,45 @@ impl StationState {
                         let _ = self.check_and_latch_stage_failure("mt");
                     }
                 } else {
-                    self.hot.mt_pass_complete = true;
-                    self.mark_present_channels_training_pass();
-                    self.mt_result.set("status", JsonVal::Str("pass".to_string()));
-                    self.mt_result.set("complete", JsonVal::Bool(true));
-                    let tot = self
-                        .mt_result
-                        .get_i64("tests_total")
-                        .filter(|&t| t > 0 && t != 25)
-                        .unwrap_or_else(|| {
-                            crate::pxe::configured_mt_test_count(&self.mt_selection) as i64
-                        });
-                    let done = (self.mt_completed_test_ids.len() as i64).max(tot);
-                    let final_tot = tot.max(done).max(1);
-                    self.mt_result
-                        .set("tests_total", JsonVal::Num(final_tot as f64));
-                    self.mt_result
-                        .set("tests_completed", JsonVal::Num(final_tot as f64));
-                    self.mt_result.set("progress_pct", JsonVal::Num(100.0));
-                    self.log_debug(
-                        "MT",
-                        &format!(
-                            "MT_PASS_COMPLETE tests={}/{} progress=100 run_started={} run_ended={} boot_id={}",
-                            final_tot, final_tot, self.run_started_unix_ms, self.run_ended_unix_ms, self.boot_id
-                        ),
-                    );
-                    for idx in 0..24 {
-                        if self.dimms[idx].presence == "present"
-                            && self.dimms[idx].enabled != "disabled"
-                            && self.dimms[idx].failed_stage.is_empty()
-                        {
-                            self.dimms[idx].stage_mt = "pass".to_string();
-                            self.sync_dimm_to_soa(idx);
+                    let was_pass_complete = self.hot.mt_pass_complete
+                        && !self.hot.mt_fail_complete
+                        && self.mt_result.get_bool("complete") == Some(true)
+                        && self.mt_result.get_str_or("status", "") == "pass";
+                    if !was_pass_complete {
+                        self.advance_phase("mt", "mt_complete", now);
+                        self.hot.mt_pass_complete = true;
+                        self.mark_present_channels_training_pass();
+                        self.mt_result.set("status", JsonVal::Str("pass".to_string()));
+                        self.mt_result.set("complete", JsonVal::Bool(true));
+                        let cfg_tot =
+                            crate::pxe::configured_mt_test_count(&self.mt_selection) as i64;
+                        let tot = self
+                            .mt_result
+                            .get_i64("tests_total")
+                            .filter(|&t| t > 0 && t != 25 && !(t == 1 && cfg_tot > 1))
+                            .unwrap_or(cfg_tot);
+                        let done = (self.mt_completed_test_ids.len() as i64).max(tot);
+                        let final_tot = tot.max(done).max(1);
+                        self.mt_result
+                            .set("tests_total", JsonVal::Num(final_tot as f64));
+                        self.mt_result
+                            .set("tests_completed", JsonVal::Num(final_tot as f64));
+                        self.mt_result.set("progress_pct", JsonVal::Num(100.0));
+                        self.log_debug(
+                            "MT",
+                            &format!(
+                                "MT_PASS_COMPLETE tests={}/{} progress=100 run_started={} run_ended={} boot_id={}",
+                                final_tot, final_tot, self.run_started_unix_ms, self.run_ended_unix_ms, self.boot_id
+                            ),
+                        );
+                        for idx in 0..24 {
+                            if self.dimms[idx].presence == "present"
+                                && self.dimms[idx].enabled != "disabled"
+                                && self.dimms[idx].failed_stage.is_empty()
+                            {
+                                self.dimms[idx].stage_mt = "pass".to_string();
+                                self.sync_dimm_to_soa(idx);
+                            }
                         }
                     }
                 }
@@ -3361,7 +3445,10 @@ impl StationState {
                 self.hot.ict_stage1_complete = true;
                 self.mark_present_channels_training_pass();
                 if self.observed_stages.contains("rmt")
-                    && self.rmt_results.values().any(|r| r.measurement_rows > 0)
+                    && self
+                        .rmt_results
+                        .values()
+                        .any(|r| r.measurement_rows > 0 || r.state == "completed")
                 {
                     for r in self.rmt_results.values_mut() {
                         if r.state != "completed" && r.measurement_rows > 0 {
@@ -3483,6 +3570,21 @@ impl StationState {
                 self.prompt_evidence = text;
                 self.observed_unix_ms = now;
                 self.hot.observed_unix_ms = now;
+                let bp_state_now = self.boot_execution.get_str_or("state", "idle");
+                if matches!(bp_state_now.as_str(), "running" | "waiting_boot")
+                    && !self.hot.mt_pass_complete
+                    && !self.hot.mt_fail_complete
+                {
+                    let prev_bp_stage = self.boot_execution.get_str_or("current_stage", "");
+                    if prev_bp_stage != "uefi" {
+                        self.boot_execution
+                            .set("current_stage", JsonVal::Str("uefi".to_string()));
+                        self.boot_execution
+                            .set("waiting_reason", JsonVal::Str("已进入 UEFI Shell".to_string()));
+                        self.boot_execution
+                            .set("updated_unix_ms", JsonVal::Num(now as f64));
+                    }
+                }
                 self.log_debug(
                     "PROMPT",
                     &format!(

+ 133 - 14
native/stl_accel/src/workflow.rs

@@ -446,6 +446,19 @@ fn finish_async_script(st: &mut StationState, now: i64) {
             }
             let steps = build_uefi_mt_steps(st, &sel);
             st.plan_mt_started = true;
+            if matches!(
+                st.boot_execution.get_str_or("state", "idle").as_str(),
+                "running" | "waiting_boot"
+            ) {
+                st.boot_execution
+                    .set("current_stage", JsonVal::Str("mt".to_string()));
+                st.boot_execution.set(
+                    "waiting_reason",
+                    JsonVal::Str("已探测到启动路径,正在写入 mt86.cfg 并启动 MemTest86 (118.efi)".to_string()),
+                );
+                st.boot_execution
+                    .set("updated_unix_ms", JsonVal::Num(now as f64));
+            }
             start_async_script(
                 st,
                 "interactive_start_mt",
@@ -829,6 +842,9 @@ pub fn control_boot_plan_impl(
             st.power_seq_started_ms = 0;
             st.plan_paused = false;
             st.single_run_active = false;
+            if matches!(st.task_status.as_str(), "running" | "queued") {
+                st.task_status = "interrupted".to_string();
+            }
             st.freeze_run_timing(now);
             st.restore_persistent_baseline("control_boot_plan_stop");
             st.log_debug(
@@ -838,9 +854,6 @@ pub fn control_boot_plan_impl(
                     st.boot_id, st.run_started_unix_ms, st.run_ended_unix_ms
                 ),
             );
-            if matches!(st.task_status.as_str(), "running" | "queued") {
-                st.task_status = "interrupted".to_string();
-            }
             st.async_script.clear();
             st.boot_execution.set("state", JsonVal::Str("stopped".to_string()));
             st.boot_execution.set(
@@ -1386,6 +1399,22 @@ pub fn step_boot_plan(st: &mut StationState, contract: &FirmwareContract) {
                     });
                     st.plan_configured.insert(key.clone());
                     st.plan_done.insert(key);
+                    st.boot_execution
+                        .set("current_stage", JsonVal::Str(stage.to_string()));
+                    st.boot_execution.set(
+                        "waiting_reason",
+                        JsonVal::Str(if stage == "uip2" {
+                            format!("CPU{} 已到达 Stage 2 提示符,正在下发 Stage 2 参数", cpu)
+                        } else {
+                            format!(
+                                "CPU{} 已到达 ICT Stage 1 提示符,正在下发 {} 条参数并继续启动",
+                                cpu,
+                                cmds.len()
+                            )
+                        }),
+                    );
+                    st.boot_execution
+                        .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
                     sync_handled_inputs(st);
                     start_async_script(
                         st,
@@ -1425,6 +1454,14 @@ pub fn step_boot_plan(st: &mut StationState, contract: &FirmwareContract) {
                 }
                 let _ = write_station_paced(st, b"exit\r");
                 st.plan_done.insert(key);
+                st.boot_execution
+                    .set("current_stage", JsonVal::Str("amt".to_string()));
+                st.boot_execution.set(
+                    "waiting_reason",
+                    JsonVal::Str(format!("CPU{} AMT 已配置为跳过,已提交 exit 继续启动", cpu)),
+                );
+                st.boot_execution
+                    .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
                 sync_handled_inputs(st);
                 return;
             }
@@ -1514,7 +1551,18 @@ pub fn step_boot_plan(st: &mut StationState, contract: &FirmwareContract) {
                 if needs_uefi_efi_probe(st, &st.mt_selection) {
                     let (probe_steps, base_efi) = build_uefi_efi_probe_steps_for(st, &st.mt_selection);
                     let mut pmeta = JsonVal::obj();
-                    pmeta.set("probe_efi_basename", JsonVal::Str(base_efi));
+                    pmeta.set("probe_efi_basename", JsonVal::Str(base_efi.clone()));
+                    st.boot_execution
+                        .set("current_stage", JsonVal::Str("uefi".to_string()));
+                    st.boot_execution.set(
+                        "waiting_reason",
+                        JsonVal::Str(format!(
+                            "已到达 UEFI Shell,正在探测 {} 所在卷并准备启动 MT",
+                            base_efi
+                        )),
+                    );
+                    st.boot_execution
+                        .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
                     start_async_script(
                         st,
                         "probe_mt_efi",
@@ -1530,6 +1578,14 @@ pub fn step_boot_plan(st: &mut StationState, contract: &FirmwareContract) {
                 st.plan_mt_started = true;
                 st.mt_started_unix_ms = now_ms();
                 st.plan_done.insert(key);
+                st.boot_execution
+                    .set("current_stage", JsonVal::Str("mt".to_string()));
+                st.boot_execution.set(
+                    "waiting_reason",
+                    JsonVal::Str("正在下发 mt86.cfg 并启动 MemTest86 (118.efi) 内存测试".to_string()),
+                );
+                st.boot_execution
+                    .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
                 sync_handled_inputs(st);
                 start_async_script(st, "plan_mt", steps, true, Vec::new(), JsonVal::Null, None);
             }
@@ -1596,7 +1652,23 @@ fn consume_pending_stage_intent(st: &mut StationState, contract: &FirmwareContra
                 if needs_uefi_efi_probe(st, &preview_sel) {
                     let (probe_steps, base_efi) = build_uefi_efi_probe_steps_for(st, &preview_sel);
                     let mut pmeta = JsonVal::obj();
-                    pmeta.set("probe_efi_basename", JsonVal::Str(base_efi));
+                    pmeta.set("probe_efi_basename", JsonVal::Str(base_efi.clone()));
+                    if matches!(
+                        st.boot_execution.get_str_or("state", "idle").as_str(),
+                        "running" | "waiting_user" | "waiting_boot"
+                    ) {
+                        st.boot_execution
+                            .set("current_stage", JsonVal::Str("uefi".to_string()));
+                        st.boot_execution.set(
+                            "waiting_reason",
+                            JsonVal::Str(format!(
+                                "已到达 UEFI Shell,正在探测 {} 所在卷并准备启动 MT",
+                                base_efi
+                            )),
+                        );
+                        st.boot_execution
+                            .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
+                    }
                     start_async_script(
                         st,
                         "probe_mt_efi",
@@ -1694,7 +1766,18 @@ fn consume_pending_stage_intent(st: &mut StationState, contract: &FirmwareContra
                     promote_stage_to_auto(st, stage_key);
                     st.boot_execution
                         .set("state", JsonVal::Str("running".to_string()));
+                    st.boot_execution
+                        .set("current_stage", JsonVal::Str(stage_key.to_string()));
                     let cpu = st.prompt_cpu.unwrap_or(0);
+                    st.boot_execution.set(
+                        "waiting_reason",
+                        JsonVal::Str(format!(
+                            "CPU{} 已按预设意图下发 {} 条 {} 参数并继续启动",
+                            cpu,
+                            cmds.len(),
+                            stage_key
+                        )),
+                    );
                     let key = format!("{}:{}:cpu{}", st.boot_id, stage_key, cpu);
                     st.plan_configured.insert(key.clone());
                     st.plan_done.insert(key);
@@ -1708,7 +1791,16 @@ fn consume_pending_stage_intent(st: &mut StationState, contract: &FirmwareContra
                 promote_stage_to_auto(st, stage_key);
                 st.boot_execution
                     .set("state", JsonVal::Str("running".to_string()));
+                st.boot_execution
+                    .set("current_stage", JsonVal::Str(stage_key.to_string()));
                 let cpu = st.prompt_cpu.unwrap_or(0);
+                st.boot_execution.set(
+                    "waiting_reason",
+                    JsonVal::Str(format!(
+                        "CPU{} 已按预设意图跳过 {},已提交 exit 继续启动",
+                        cpu, stage_key
+                    )),
+                );
                 let key = format!("{}:{}:cpu{}", st.boot_id, stage_key, cpu);
                 st.plan_done.insert(key);
                 sync_handled_inputs(st);
@@ -1722,6 +1814,14 @@ fn consume_pending_stage_intent(st: &mut StationState, contract: &FirmwareContra
                 promote_stage_to_auto(st, "amt");
                 st.boot_execution
                     .set("state", JsonVal::Str("running".to_string()));
+                st.boot_execution
+                    .set("current_stage", JsonVal::Str("amt".to_string()));
+                st.boot_execution.set(
+                    "waiting_reason",
+                    JsonVal::Str("已按预设意图跳过 AMT,正在退出 AMT 菜单".to_string()),
+                );
+                st.boot_execution
+                    .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
                 st.boot_plan.set("run_amt", JsonVal::Bool(false));
             } else {
                 let _ = write_station_paced(st, b"exit\r");
@@ -1782,6 +1882,14 @@ fn consume_pending_stage_intent(st: &mut StationState, contract: &FirmwareContra
                 promote_stage_to_auto(st, "amt");
                 st.boot_execution
                     .set("state", JsonVal::Str("running".to_string()));
+                st.boot_execution
+                    .set("current_stage", JsonVal::Str("amt".to_string()));
+                st.boot_execution.set(
+                    "waiting_reason",
+                    JsonVal::Str("已切换 AMT 为自动执行,正在下发参数并启动算法测试".to_string()),
+                );
+                st.boot_execution
+                    .set("updated_unix_ms", JsonVal::Num(now_ms() as f64));
                 st.boot_plan.set("run_amt", JsonVal::Bool(true));
             } else {
                 let cmds = contract
@@ -1861,6 +1969,12 @@ fn consume_pending_stage_intent(st: &mut StationState, contract: &FirmwareContra
                 st.plan_mt_started = true;
                 st.mt_started_unix_ms = now_ms();
                 if plan_active {
+                    st.boot_execution
+                        .set("current_stage", JsonVal::Str("mt".to_string()));
+                    st.boot_execution.set(
+                        "waiting_reason",
+                        JsonVal::Str("正在按预设意图启动 MemTest86 (118.efi) 内存测试".to_string()),
+                    );
                     let cpu = st.prompt_cpu.unwrap_or(0);
                     st.plan_done
                         .insert(format!("{}:uefi:cpu{}", st.boot_id, cpu));
@@ -2276,6 +2390,20 @@ pub fn step_task_batch(
     let b_state = st.task_batch.get_str_or("state", "idle");
     if b_state != "running" {
         let now = now_ms();
+        let has_any_err = st.awaiting_dimm_replacement
+            || st.stage_errors.values().any(|v| !v.is_empty());
+        let verdict = if bp_state == "completed" && !has_any_err {
+            "pass"
+        } else {
+            "fail"
+        };
+        if st.single_run_active || matches!(st.task_status.as_str(), "running" | "queued") {
+            st.task_status = if verdict == "pass" {
+                "completed".to_string()
+            } else {
+                "failed".to_string()
+            };
+        }
         st.freeze_run_timing(now);
         // Universal archiving + active complete push for standalone / frontend-queue runs!
         if st.single_run_active {
@@ -2291,15 +2419,6 @@ pub fn step_task_batch(
                 .or_else(|| st.single_run_profile.get_str("task_name"))
                 .unwrap_or("Single-Run")
                 .to_string();
-            let has_any_err = st.awaiting_dimm_replacement
-                || st.stage_errors.values().any(|v| !v.is_empty());
-            let verdict = if bp_state == "completed" && !has_any_err {
-                st.task_status = "completed".to_string();
-                "pass"
-            } else {
-                st.task_status = "failed".to_string();
-                "fail"
-            };
             let started_ms = if st.run_started_unix_ms > 0 {
                 st.run_started_unix_ms
             } else if st.single_run_started_ms > 0 {

+ 24 - 3
web/app.js

@@ -9,6 +9,7 @@
   }
 
   let stationId = 'S1', stationUserChosen = false, stations = [], polling = false, repollPending = false, selectionRevision = 0, connected = false;
+  let sysInfoCache = null, sysInfoFetchedAt = 0, dirtyPollTimer = null;
   const logs = new Map(), pending = new Map(), diagnostics = new Map();
   let queueItems = [], queuePolling = false, eventPolling = false, auditItems = [], auditPolling = false;
   const eventViews = new Map(), bmcPending = new Map();
@@ -601,7 +602,15 @@
     }
     polling = true;
     try {
-      const [info, list] = await Promise.all([callApi('GetSystemInfo'), callApi('ListStations')]);
+      const needSysInfo = !sysInfoCache || (Date.now() - sysInfoFetchedAt >= 30000);
+      const [info, list] = await Promise.all([
+        needSysInfo ? callApi('GetSystemInfo') : Promise.resolve(sysInfoCache),
+        callApi('ListStations'),
+      ]);
+      if (needSysInfo && info) {
+        sysInfoCache = info;
+        sysInfoFetchedAt = Date.now();
+      }
       if (!connected) status('已连接后端;选择工位操作。');
       connected = true;
       $('refresh-indicator').classList.remove('offline');
@@ -625,6 +634,7 @@
       renderDetail();
     } catch (error) {
       connected = false;
+      sysInfoFetchedAt = 0;
       $('refresh-indicator').textContent = '连接失败 · 显示上次数据';
       $('refresh-indicator').classList.add('offline');
       status(`后端连接失败:${error.message}`, true);
@@ -801,7 +811,10 @@
     $('transport-state').classList.toggle('connected', ready);
     $('transport-state').classList.toggle('error', ['disconnected','closed'].includes(transport.state));
     if (ready) {
-      if (transport.generation > 1) poll();
+      if (transport.generation > 1) {
+        sysInfoFetchedAt = 0;
+        poll();
+      }
     } else {
       connected = false;
       $('refresh-indicator').textContent = '连接未就绪 · 显示上次数据';
@@ -811,8 +824,16 @@
   });
   window.addEventListener('stl:server-event', event => {
     const ev = event.detail?.event;
-    if (ev === 'station_dirty' || ev === 'task_complete') {
+    if (ev === 'task_complete') {
+      if (dirtyPollTimer) { clearTimeout(dirtyPollTimer); dirtyPollTimer = null; }
       void poll();
+    } else if (ev === 'station_dirty') {
+      if (!dirtyPollTimer) {
+        dirtyPollTimer = setTimeout(() => {
+          dirtyPollTimer = null;
+          void poll();
+        }, 500);
+      }
     }
   });
   window.addEventListener('load', async () => {