From 3ca111dff2a52c68750a42cdf70b38947630f0ab Mon Sep 17 00:00:00 2001 From: RobinLee Date: Thu, 26 Nov 2026 00:24:53 +0800 Subject: [PATCH] feat(dashboard): present historical Stage 2 VRRP evidence --- templates/dashboard_home.html | 9 + templates/dashboard_reports.html | 95 ++++++++++ ...stage2_historical_evidence_presentation.py | 175 ++++++++++++++++++ 3 files changed, 279 insertions(+) create mode 100644 tests/test_stage2_historical_evidence_presentation.py diff --git a/templates/dashboard_home.html b/templates/dashboard_home.html index a6e3183..d811701 100644 --- a/templates/dashboard_home.html +++ b/templates/dashboard_home.html @@ -81,6 +81,8 @@ .section-grid > section, .section-grid + section { margin-top: 24px; } .link { margin-top: 12px; } .project-context { font-size: 14px; } + .historical-entry { margin-top: 22px; padding: 18px; border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: 12px; background: var(--panel); } + .historical-entry a { display: inline-block; margin-top: 10px; font-weight: 750; } @media (max-width: 760px) { .hero { align-items: flex-start; } .hero-marker { display: none; } @@ -282,6 +284,13 @@

證據尚不可用,無法顯示結果

+
+
STAGE 2 · 歷史證據
+

真實設備驗證,保留當時的證據與限制

+

查看各自獨立的 Lab1/Lab2 唯讀驗證,以及 2026-10-20 人工切換觀察。與上方 Stage-0 Fake Adapter 模擬流程分開;不表示目前設備狀態。

+ 查看 Stage 2 VRRP 歷史成果與來源 → +
+
平台定位與展示範圍 · 工程師補充說明
diff --git a/templates/dashboard_reports.html b/templates/dashboard_reports.html index a61e693..559f919 100644 --- a/templates/dashboard_reports.html +++ b/templates/dashboard_reports.html @@ -144,6 +144,44 @@ tr:last-child td { border-bottom: 0; } th { color: var(--muted); font-weight: 800; white-space: nowrap; } .empty { color: #7a4d00; font-weight: 700; } + .historical-vrrp { border-top: 4px solid var(--blue); overflow-wrap: anywhere; } + .historical-vrrp h3 { margin-top: 0; } + .historical-vrrp .history-label { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .04em; margin-bottom: 6px; } + .history-card-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; } + .history-boundary { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 16px; color: var(--unknown); font-size: 13px; } + .history-boundary span { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; background: var(--unknown-bg); } + .history-labs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 18px 0; } + .history-lab { border: 1px solid #bed0eb; border-radius: 12px; background: #f7faff; padding: 18px; } + .history-lab h3 { margin: 0; font-size: 20px; } + .history-card-heading svg { width: 34px; height: 34px; fill: none; stroke: var(--blue); stroke-width: 1.5; } + .historical-vrrp .history-kind { color: #344054; font-size: 12px; font-weight: 750; margin: 12px 0 6px; } + .history-role { color: #183b69; font-size: 30px; font-weight: 850; letter-spacing: -.02em; } + .history-role small { display: block; color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: 0; } + .history-facts { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 12px 0; } + .history-facts dt { color: var(--muted); font-size: 13px; } + .history-facts dd { margin: 0; font-size: 22px; font-weight: 800; } + .history-lab .history-baseline { margin: 14px 0 8px; font-size: 12px; } + .history-baseline code { display: block; color: var(--text); } + .history-source-link { display: inline-block; padding: 4px 0; font-size: 14px; } + .history-manual { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 20px; } + .history-manual h3 { margin-bottom: 4px; font-size: 20px; } + .history-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0; } + .history-metrics > div { padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #f9fbfd; } + .history-metrics dt { color: var(--muted); font-size: 13px; } + .history-metrics dd { margin: 6px 0 0; color: var(--text); font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; } + .history-metrics .history-loss { background: #fff9ec; border-color: #e7cf93; } + .history-metrics .history-loss dd { color: #805400; } + .history-timing { display: flex; flex-wrap: wrap; gap: 12px 28px; margin: 14px 0; } + .history-timing dt { font-size: 13px; color: var(--muted); } + .history-timing dd { margin: 3px 0 0; color: #805400; font-weight: 750; } + .history-limit { padding: 12px 14px; border-left: 3px solid #bb8b26; background: #fff9ec; color: #614500; font-size: 14px; } + .history-provenance { padding-top: 18px; border-top: 1px solid var(--border); margin-top: 18px; font-size: 13px; } + .history-provenance p:last-child { margin-bottom: 0; } + @media (max-width: 620px) { + .history-labs { grid-template-columns: 1fr; } + .history-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } + .history-metrics dd { font-size: 24px; } + } @media (max-width: 820px) { .count-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } } @@ -159,6 +197,63 @@

Reports

Local evidence browser for generated JSON and HTML reports. Result quality is separate from artifact availability, and this GET-only page never starts collection or execution.

+
+

STAGE 2 · HISTORICAL EVIDENCE

+

VRRP 歷史真實設備驗證

+

兩次不同時間、不同授權的唯讀驗證。以下是固定版本的公開文件摘要,不是目前設備狀態,也不能代表雙機同步健康。

+
+ STAGE2_FORMAL_STATUS = CLOSEDLIVE_AUTHORIZED = NO離線展示 · 不重新採集 +
+
+
+

MikroTik Lab1

+

HISTORICAL_LIVE_PROOF

+
MASTER該次驗證的歷史角色
+
VRID
88
Priority
150
+

指定目標、一次授權;成功驗證的固定命令執行 1 次,重試 0 次。Lab1 先前兩次嘗試曾 fail-closed,第三次才通過。

+

原驗證基準39da163d80e5d8b2dde215eb6c0979448d0739fd

+ Lab1 公開紀錄 ↗ +
+
+

MikroTik Lab2

+

HISTORICAL_LIVE_PROOF

+
BACKUP該次驗證的歷史角色
+
VRID
88
Priority
100
+

另一次獨立授權;固定命令執行 1 次,重試 0 次。這次證明沒有重新驗證 Lab1,授權已消耗,不能再次使用。

+

原驗證基準ea73196281e38a01af7bf959cc5e1bc60b0b2499

+ Lab2 公開紀錄 ↗ +
+
+

兩次成功證明均限定 mikrotik.vrrp_status 與 /interface vrrp print detail;此處僅列出歷史範圍,不提供執行入口。

+ +
+

MANUAL_FAILOVER_OBSERVATION

+

人工 Failover/Recovery 觀察

+

· Owner 提供的人工角色觀察與 Ping 統計,與上方兩次 Live Proof 分開。

+
+
Ping Replies
205
+
Timeouts
2
+
Total
207
+
Packet Loss
0.9662%
+
+
+
Failover Time
NOT_MEASURED
+
Recovery Time
NOT_MEASURED
+
+

有封包遺失,不能宣稱零中斷。缺少逐封包及事件時間戳,不能把兩次逾時分別歸因為切換與恢復,也不能推算收斂時間。Lab2 的 625 ms 僅是單次命令耗時,不是 VRRP Failover Time。

+

人工紀錄描述 Lab1 LAN 隔離後 Lab2 接手,恢復後回到 Lab1 MASTER/Lab2 BACKUP;這不是雙機同步量測,也不是 NAL 自動 Failover 或 DL-06-02 官方 Live Proof。

+ 閱讀人工觀察摘要與限制 ↗ +
+ +
+

固定來源與正式邊界

+

來源連結固定於公開 Commit 4b3f139af072d88cb6fc564b5cb37319faefe3f0,是文件版本,不是新的設備測試基準。本頁不讀取外部 ZIP、原始設備輸出或私有證據,也不自動檢查外部連結。

+

人工摘要保留原文件狀態 LOCAL_DOCS_DRAFT_READY_FOR_OWNER_REVIEW;展示不提升其驗收狀態。原始觀察來自 Owner,離線整理不等於獨立重驗設備。

+

Stage 2 結案範圍為 DOCUMENTATION_ONLY_FIXED_HEAD,原結案 SHA:0f774c47b2529a5f93c0b0abd7c245b85e2d61d2。閱讀 Formal Closure ↗。CLOSED 不代表部署驗收;任何新 Live 操作仍需另行授權。

+

上方歷史摘要與 Stage-0 Fake Adapter 模擬證據不同,也不納入下方本機報告計數。Missing/Malformed 報告保持原狀,不以歷史紀錄補成 PASS。

+
+
+

Evidence Review Summary

diff --git a/tests/test_stage2_historical_evidence_presentation.py b/tests/test_stage2_historical_evidence_presentation.py new file mode 100644 index 0000000..4d163c5 --- /dev/null +++ b/tests/test_stage2_historical_evidence_presentation.py @@ -0,0 +1,175 @@ +import html +import re +import socket +import subprocess +from pathlib import Path +from unittest.mock import Mock +from urllib.parse import urlsplit + +import pytest + +import dashboard_app as dashboard +import dashboard_command_runner as runner +import network_lab + + +ROOT = Path(__file__).resolve().parents[1] +SOURCE_COMMIT = "4b3f139af072d88cb6fc564b5cb37319faefe3f0" +SOURCE_PREFIX = f"/Robinlee0929/Network_Automation_Lab/blob/{SOURCE_COMMIT}/" +PLAN = "docs/automation_readiness/actual_automation_integration_plan.md" +MANUAL = "docs/portfolio/manual_vrrp_failover_20261020.md" +CLOSURE = "docs/automation_readiness/stage2_formal_closure.md" + + +def _page(client, path): + response = client.get(path) + assert response.status_code == 200 + return response.get_data(as_text=True) + + +def _history(source): + match = re.search(r'
', source, re.S) + assert match is not None + return match.group(0) + + +def _facts(source): + return dict(re.findall(r"
([^<]+)
([^<]+)
", source)) + + +@pytest.fixture +def reviewer(tmp_path): + app = dashboard.create_reviewer_app(tmp_path / "reports", tmp_path / "logs") + app.testing = True + return app, app.test_client() + + +@pytest.mark.parametrize( + ("lab", "role", "priority", "baseline"), + [ + ("lab1", "MASTER", "150", "39da163d80e5d8b2dde215eb6c0979448d0739fd"), + ("lab2", "BACKUP", "100", "ea73196281e38a01af7bf959cc5e1bc60b0b2499"), + ], +) +def test_each_lab_is_an_independent_historical_record(reviewer, lab, role, priority, baseline): + _, client = reviewer + history = _history(_page(client, "/reports")) + card = re.search(fr'
.*?
', history, re.S).group(0) + assert "HISTORICAL_LIVE_PROOF" in card + assert f'data-history-role="{role}"' in card + assert _facts(card) == {"VRID": "88", "Priority": priority} + assert baseline in card + assert "1 次" in card and "重試 0 次" in card + assert "不同時間、不同授權" in history + assert "不是目前設備狀態" in history and "不能代表雙機同步健康" in history + assert "CURRENT_STATUS" not in history and "CURRENT_PAIR_HEALTH" not in history + assert "STAGE2_FORMAL_STATUS = CLOSED" in history and "LIVE_AUTHORIZED = NO" in history + assert baseline in (ROOT / PLAN).read_text(encoding="utf-8") + + +def test_manual_observation_preserves_loss_and_unmeasured_timing(reviewer): + _, client = reviewer + history = _history(_page(client, "/reports")) + manual = re.search(r'
', history, re.S).group(0) + assert 'data-evidence-kind="MANUAL_FAILOVER_OBSERVATION"' in manual + assert '