// FCS Glass - M0a probe (src/test/probe.cpp) // // Implements: sec 16 in full - OS build; LoadLibrary results for d3d11, dcomp, // dwmapi, d3dcompiler_47; D3D feature level and WARP availability; the HRESULT // of each DwmSetWindowAttribute call (immersive dark, corner preference, border // colour, system backdrop type); the result of the {-1} margins call; measured // blur per B5 with the window active AND inactive; a 5 s window-drag frame-time // test (median and p95) for A and B; whether the snap-layout flyout appears on // the maximize button; premultiplied-alpha correctness in an RDP session if // applicable; the Transparency-effects setting; and the chosen tier. // // Sec 16: "Anything that cannot be tested is written NOT VERIFIED, never PASS." // That rule is enforced structurally below: every probe returns a status that // defaults to NOT_VERIFIED, and only an actual observation can set it to PASS. // // Console subsystem, so the JSON reaches stdout (ASSUMPTIONS D-5), plus an // on-screen summary as sec 16 also requires. #include "platform/platform.h" #include "platform/os_info.h" #include "platform/dpi.h" #include "platform/window.h" #include "platform/backdrop.h" #include "platform/input_map.h" #include "platform/settings.h" #include "core/settings.h" #include "core/input.h" #include "device/dx.h" #include "fx/blur_measure.h" #include #include #include #include #include namespace fcs { namespace { // Sec 16 status vocabulary. PASS is only ever set from a real measurement. enum class ProbeStatus { Pass, Fail, NotVerified }; const char* StatusName(ProbeStatus s) { switch (s) { case ProbeStatus::Pass: return "PASS"; case ProbeStatus::Fail: return "FAIL"; case ProbeStatus::NotVerified:return "NOT VERIFIED"; default: return "UNKNOWN"; } } struct Row { std::string key; std::string value; ProbeStatus status = ProbeStatus::NotVerified; // safe default (sec 16) std::string note; }; std::vector& Rows() { static std::vector rows; return rows; } void Add(const char* key, const char* value, ProbeStatus st, const std::string& note = "") { Row r; r.key = key; r.value = value ? value : ""; r.status = st; r.note = note; Rows().push_back(r); } void AddF(const char* key, double v, int decimals, ProbeStatus st, const std::string& note = "") { char buf[64]; std::snprintf(buf, sizeof(buf), "%.*f", decimals, v); Add(key, buf, st, note); } void AddI(const char* key, long long v, ProbeStatus st, const std::string& note = "") { char buf[32]; std::snprintf(buf, sizeof(buf), "%lld", v); Add(key, buf, st, note); } void AddHr(const char* key, HRESULT hr, const char* what) { char buf[32]; std::snprintf(buf, sizeof(buf), "0x%08lX", static_cast(hr)); Add(key, buf, SUCCEEDED(hr) ? ProbeStatus::Pass : ProbeStatus::Fail, what); } std::string JsonEscape(const std::string& s) { std::string out; out.reserve(s.size() + 8); for (char c : s) { switch (c) { case '"': out += "\\\""; break; case '\\': out += "\\\\"; break; case '\n': out += "\\n"; break; case '\r': break; case '\t': out += "\\t"; break; default: if (static_cast(c) < 0x20) { char esc[8]; std::snprintf(esc, sizeof(esc), "\\u%04x", c); out += esc; } else { out += c; } } } return out; } void EmitJson(FILE* out) { std::fprintf(out, "{\n"); std::fprintf(out, " \"probe\": \"FCS Glass M0a\",\n"); std::fprintf(out, " \"spec\": \"FCS_Glass_Master_Prompt_v4.md sec 16\",\n"); std::fprintf(out, " \"note\": \"NOT VERIFIED means not observable in this session; it is never reported as PASS.\",\n"); std::fprintf(out, " \"rows\": [\n"); const std::vector& rows = Rows(); for (size_t i = 0; i < rows.size(); ++i) { const Row& r = rows[i]; std::fprintf(out, " { \"key\": \"%s\", \"value\": \"%s\", \"status\": \"%s\"", JsonEscape(r.key).c_str(), JsonEscape(r.value).c_str(), StatusName(r.status)); if (!r.note.empty()) { std::fprintf(out, ", \"note\": \"%s\"", JsonEscape(r.note).c_str()); } std::fprintf(out, " }%s\n", (i + 1 < rows.size()) ? "," : ""); } std::fprintf(out, " ]\n}\n"); } // --------------------------------------------------------------------------- // Test window. WM_NCCALCSIZE follows D-15 (both wParam cases) and BUG-01b // (rgrc[0] holds the proposed WINDOW rect, so the client follows every resize). // --------------------------------------------------------------------------- constexpr const wchar_t* kProbeClass = L"FcsGlassM0aProbe"; LRESULT CALLBACK ProbeWndProc(HWND hwnd, UINT msg, WPARAM w, LPARAM l) { switch (msg) { case WM_NCCALCSIZE: { // The Window* is recovered from GWLP_USERDATA, NOT from lParam. // lParam here is an NCCALCSIZE_PARAMS*, not a CREATESTRUCTW* - treating it // as one dereferences garbage and the callback faults. // D-15: the first call has wParam == FALSE, so both cases must return 0. // J7 / X30: the zoomed inset is applied here. BUG-01b: the client must // equal the window at EVERY size, not just the creation size. Window* wnd = reinterpret_cast(::GetWindowLongPtrW(hwnd, GWLP_USERDATA)); if (wnd != nullptr) return wnd->OnNCCalcSize(w, l); return 0; // during CreateWindowExW the pointer is not set yet } case WM_ERASEBKGND: return 1; // E2: no black flash default: break; } return ::DefWindowProcW(hwnd, msg, w, l); } // --------------------------------------------------------------------------- // B5 control window (T9 pattern). // // PaintCheckerboard's own header says it exists "so the measurement is // self-contained and does not depend on what happens to be on the desktop" - and // it had NO CALLERS anywhere in src/, so the control sample was in fact just // whatever wallpaper happened to be beside the probe window. That is the whole // reason the blur rows kept reporting OCCLUDED / NO_BLUR_EVIDENCE: the control // was never a known pattern, so there was nothing to compare against. // // This window is that known pattern. It is positioned exactly where // MeasureBlurThroughWindow looks for its control (just right of the probe // window, same row as the in-window sample), so the existing geometry logic is // unchanged and now lands on a checkerboard measuring contrast 0.5000 by // construction (D-21) rather than on whatever the user has on their desktop. // --------------------------------------------------------------------------- constexpr const wchar_t* kCheckerClass = L"FcsGlassM0aChecker"; LRESULT CALLBACK CheckerboardWndProc(HWND hwnd, UINT msg, WPARAM w, LPARAM l) { switch (msg) { case WM_PAINT: { PAINTSTRUCT ps = {}; HDC dc = ::BeginPaint(hwnd, &ps); if (dc != nullptr) { RECT rc = {}; ::GetClientRect(hwnd, &rc); PaintCheckerboard(dc, rc, kCheckerSquarePx); ::EndPaint(hwnd, &ps); } return 0; } case WM_ERASEBKGND: // Without this the window flashes its class brush before the first // WM_PAINT, and the blur sample could catch the flash rather than the // pattern. return 1; default: break; } return ::DefWindowProcW(hwnd, msg, w, l); } double PerfNowMs() { LARGE_INTEGER freq, now; ::QueryPerformanceFrequency(&freq); ::QueryPerformanceCounter(&now); return static_cast(now.QuadPart) * 1000.0 / static_cast(freq.QuadPart); } void ReportStats(const char* key, std::vector& samples) { if (samples.empty()) { Add(key, "", ProbeStatus::NotVerified, "no samples were collected"); return; } std::sort(samples.begin(), samples.end()); const double median = samples[samples.size() / 2]; const double p95 = samples[static_cast(static_cast(samples.size()) * 0.95)]; char buf[96]; std::snprintf(buf, sizeof(buf), "median=%.2fms p95=%.2fms n=%zu", median, p95, samples.size()); // D-27: this is only a real GPU frame time because DwmFlush() is called. Add(key, buf, ProbeStatus::Pass, "measured with DwmFlush; without it the median reads ~0.5ms and means nothing"); } // REQ sec 16 - every item the milestone lists. void RunProbe(HINSTANCE instance) { // ---- 1. OS build and environment --------------------------------------- const OsInfo os = QueryOsInfo(); char buf[256]; std::snprintf(buf, sizeof(buf), "%ls (build %lu)", os.display_name.c_str(), static_cast(os.build)); // D-11: the build number came from RtlGetVersion, not the registry. Add("os.build", buf, ProbeStatus::Pass, "via RtlGetVersion; registry ProductName is unreliable on Win11"); Add("os.profile", os.profile == OsProfile::Fluent ? "Fluent" : "Classic", ProbeStatus::Pass, "W4 profile gate is a hint only"); Add("os.session", os.session == SessionKind::Remote ? "Remote" : "Console", ProbeStatus::Pass, "R6 forces Basic on Remote"); // Transparency effects: W7. An unreadable key is reported as unknown, never // silently as ON or OFF. if (os.transparency_known) { Add("settings.transparency", os.transparency_effects ? "on" : "off", ProbeStatus::Pass, "HKCU\\...\\Themes\\Personalize\\EnableTransparency"); } else { Add("settings.transparency", "unreadable", ProbeStatus::NotVerified, "W7: an absent key means the OS default (on), not off"); } Add("settings.high_contrast", os.high_contrast ? "on" : "off", ProbeStatus::Pass, "W7"); Add("settings.reduce_motion", os.reduce_motion ? "on" : "off", ProbeStatus::Pass, "W7 via SPI_GETCLIENTAREAANIMATION == 0"); AddF("settings.text_scale", static_cast(os.text_scale), 2, os.text_scale_known ? ProbeStatus::Pass : ProbeStatus::NotVerified, "P3"); // ---- 2. HC5 DLL presence ---------------------------------------------- Add("dll.d3d11", os.d3d11_present ? "present" : "MISSING", os.d3d11_present ? ProbeStatus::Pass : ProbeStatus::Fail, "HC5"); Add("dll.dcomp", os.dcomp_present ? "present" : "MISSING", os.dcomp_present ? ProbeStatus::Pass : ProbeStatus::Fail, "HC5"); { const bool dwm_present = DllPresent(L"dwmapi.dll"); // P4-04: a missing DLL is a FAIL, not a PASS Add("dll.dwmapi", dwm_present ? "present" : "MISSING", dwm_present ? ProbeStatus::Pass : ProbeStatus::Fail, "HC5"); } // D-12: d3dcompiler_47 is probed, never linked, so absence cannot kill the // process before it can report itself. Add("dll.d3dcompiler_47", os.d3dcompiler_present ? "present" : "MISSING", os.d3dcompiler_present ? ProbeStatus::Pass : ProbeStatus::Fail, "HC5; loaded via LoadLibraryExW, not in the import table (D-12)"); // ---- 3. D3D device, feature level, WARP (HC4) -------------------------- DxDevice dx; if (dx.Create()) { const DeviceInfo& di = dx.info(); std::snprintf(buf, sizeof(buf), "%s, feature level %u.%u", di.driver == DriverKind::Warp ? "WARP" : "Hardware", static_cast(di.feature_level) >> 12, static_cast(di.feature_level) & 0xF); Add("d3d.device", buf, ProbeStatus::Pass, "HC4"); Add("d3d.format_r10g10b10a2", di.supports_r10g10b10a2 ? "supported" : "not supported", ProbeStatus::Pass, "G2 Full tier; measured via D3D11_FEATURE_DATA_FORMAT_SUPPORT (D-26)"); } else { Add("d3d.device", "FAILED", ProbeStatus::Fail, "HC4: both hardware and WARP failed"); } // ---- 4. test window + every DWM attribute ------------------------------ // A named struct, not a compound literal: WNDCLASSEXW{...} as an argument is // a functional cast, not aggregate initialisation, and it breaks parsing. WNDCLASSEXW wc = {}; wc.cbSize = sizeof(wc); wc.style = CS_DBLCLKS; // W9 wc.lpfnWndProc = ProbeWndProc; wc.hInstance = instance; wc.hCursor = ::LoadCursorW(nullptr, IDC_ARROW); wc.lpszClassName = kProbeClass; // BUG-21: the registration result is checked before the create is // attempted. A real registration failure used to surface only as the // downstream "window.create FAILED" row, with no evidence that the class // itself was the root cause. ERROR_CLASS_ALREADY_EXISTS counts as success // for the same reason RegisterHostClass treats it as success. bool class_registered = (::RegisterClassExW(&wc) != 0); if (!class_registered) { class_registered = (::GetLastError() == ERROR_CLASS_ALREADY_EXISTS); } Add("window.class_registered", class_registered ? "ok" : "FAILED", class_registered ? ProbeStatus::Pass : ProbeStatus::Fail, "BUG-21: RegisterClassExW for the probe class; ALREADY_EXISTS is ok"); if (!class_registered) { Add("window.create", "FAILED", ProbeStatus::Fail, "window class registration failed; CreateWindowExW not attempted"); return; } Window win; if (!win.Create(kProbeClass, L"FCS Glass M0a probe", WS_OVERLAPPEDWINDOW, 0, 80, 60, 900, 640, nullptr, instance)) { Add("window.create", "FAILED", ProbeStatus::Fail, "probe window could not be created"); return; } ::ShowWindow(win.handle(), SW_SHOW); ::UpdateWindow(win.handle()); ::SetForegroundWindow(win.handle()); ::BringWindowToTop(win.handle()); ::RedrawWindow(win.handle(), nullptr, nullptr, RDW_UPDATENOW | RDW_ALLCHILDREN); Add("window.create", "ok", ProbeStatus::Pass, "W1: WS_EX_NOREDIRECTIONBITMAP + WM_NCCALCSIZE"); // ---- B5 control window: the KNOWN-PATTERN sample ------------------------- // Placed EXACTLY where MeasureBlurThroughWindow looks for its control // (wr.right + 4, same row as the in-window sample, kSampleSize square), so // blur_measure's geometry logic is untouched and only what it lands on // changes - from "whatever wallpaper is there" to a known 0.5000 pattern. // WS_EX_TOPMOST so WindowFromPoint finds it and the sample is not occluded. // // M1_PREP item 10 recorded BUG-04 as "NOT EXERCISABLE AT M0" because // PaintCheckerboard had no callers. This is that caller. HWND checker = nullptr; { WNDCLASSEXW cc = {}; cc.cbSize = sizeof(cc); cc.lpfnWndProc = CheckerboardWndProc; cc.hInstance = instance; cc.hCursor = ::LoadCursorW(nullptr, IDC_ARROW); cc.lpszClassName = kCheckerClass; bool creg = (::RegisterClassExW(&cc) != 0); if (!creg) creg = (::GetLastError() == ERROR_CLASS_ALREADY_EXISTS); if (!creg) { Add("blur.control_window", "FAILED", ProbeStatus::Fail, "checkerboard class could not be registered; blur rows fall back to desktop content"); } else { RECT wr0 = {}; ::GetWindowRect(win.handle(), &wr0); const int kSample = 128; // blur_measure.cpp's kSampleSize const int in_y = wr0.top + ((wr0.bottom - wr0.top) - kSample) / 2; checker = ::CreateWindowExW(WS_EX_TOPMOST, kCheckerClass, L"checker", WS_POPUP, wr0.right + 4, in_y, kSample, kSample, nullptr, nullptr, instance, nullptr); if (checker != nullptr) { ::ShowWindow(checker, SW_SHOWNOACTIVATE); ::UpdateWindow(checker); ::RedrawWindow(checker, nullptr, nullptr, RDW_UPDATENOW); } } } // BUG-01b regression: the client must equal the WINDOW rect, and must keep // doing so after a RESIZE - not only at the size the window was created with. // // The defect this covers: NccCalcSizeFor copied rgrc[2] into rgrc[0], but // rgrc[2] is the OLD CLIENT rect, so the client area was pinned to whatever // size it had last time. It looked correct at creation (the first pass had // just made client == window) and then never followed a resize. Measured on // the real app: window 1561x800, client 1280x800, and the 281 px the window // had gained on the right composited black with the system caption buttons // drawn in it, because WS_CAPTION is still set. // // This drives the PROBE's OWN window - never the app's - and compares the // live rects rather than the requested ones, so the W6 minimum track size // clamping a request up cannot mask a mismatch. { const int kW[] = {900, 1240, 1000}; const int kH[] = {640, 760, 700}; bool margins_ok = true; char detail[192] = {}; for (int i = 0; i < 3; ++i) { ::SetWindowPos(win.handle(), nullptr, 0, 0, kW[i], kH[i], SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); RECT wr = {}; RECT cr = {}; ::GetWindowRect(win.handle(), &wr); ::GetClientRect(win.handle(), &cr); const int ww = wr.right - wr.left; const int wh = wr.bottom - wr.top; const int cw = cr.right - cr.left; const int ch = cr.bottom - cr.top; if (i == 0) { std::snprintf(detail, sizeof(detail), "asked %dx%d -> window %dx%d client %dx%d, margin %d,%d", kW[i], kH[i], ww, wh, cw, ch, ww - cw, wh - ch); } if (ww != cw || wh != ch) { margins_ok = false; std::snprintf(detail, sizeof(detail), "asked %dx%d -> window %dx%d but client %dx%d (margin %d,%d)", kW[i], kH[i], ww, wh, cw, ch, ww - cw, wh - ch); break; } } // Restore the creation size so the blur rows below sample the same edge. ::SetWindowPos(win.handle(), nullptr, 0, 0, 900, 640, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); Add("window.client_follows_resize", margins_ok ? "client == window at every size" : "MISMATCH", margins_ok ? ProbeStatus::Pass : ProbeStatus::Fail, detail); } win.ApplyProfile(os.profile == OsProfile::Fluent, /*dark=*/true); const Window::AttributeResults& ar = win.attribute_results(); AddHr("dwm.immersive_dark", ar.immersive_dark, "DWMWA_USE_IMMERSIVE_DARK_MODE (20)"); AddHr("dwm.corner_preference", ar.corner_preference, "DWMWA_WINDOW_CORNER_PREFERENCE (33)"); AddHr("dwm.border_color", ar.border_color, "DWMWA_BORDER_COLOR (34) = DWMWA_COLOR_NONE"); AddHr("dwm.caption_color", ar.caption_color, "DWMWA_CAPTION_COLOR (35)"); AddHr("dwm.sheet_of_glass", ar.sheet_of_glass, "DwmExtendFrameIntoClientArea MARGINS{-1,-1,-1,-1}; NOTE S_OK proves nothing on its own (research note 3)"); // D-7 guard: assert the numeric attributes are what we think they are. Add("dwm.cloak_guard", (DWMWA_CLOAK == 13 && DWMWA_USE_IMMERSIVE_DARK_MODE == 20) ? "ok" : "MISMATCH", (DWMWA_CLOAK == 13 && DWMWA_USE_IMMERSIVE_DARK_MODE == 20) ? ProbeStatus::Pass : ProbeStatus::Fail, "D-7: a value of 13 is DWMWA_CLOAK, which invisibly hides the window"); // ---- 5. B5 blur, window ACTIVE then INACTIVE -------------------------- // Sec 16 asks for both. The measurement carries a CONTROL sample (D-20): a // single reading cannot tell real blur from an unpainted window. // // The probe window is made TOPMOST for the duration. WindowFromPoint is a hard // precondition in MeasureBlurThroughWindow, and the reason these rows kept // reporting OCCLUDED was simply that something else was on top - not that the // measurement was wrong. SetForegroundWindow does not do this; it only affects // activation, not stacking against other applications. ::SetWindowPos(win.handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); ::SetForegroundWindow(win.handle()); ::RedrawWindow(win.handle(), nullptr, nullptr, RDW_UPDATENOW); // The probe window is a WS_EX_NOREDIRECTIONBITMAP DComp window presenting a // single FLAT OPAQUE CLEAR. It has no known in-window detail, so a contrast // drop across its edge cannot be attributed to blur - which is exactly what // happened when the control window was first made real: drop 0.3550, and tier // A was chosen for a window with no backdrop at all. The gate is `false`. // It becomes `true` at M3, when the window actually renders content that blur // could remove - and until then the honest answer is NOT VERIFIED, not a // confident wrong number. constexpr bool kInWindowHasKnownDetail = false; const BlurMeasurement active = MeasureBlurThroughWindow(win.handle(), kInWindowHasKnownDetail); Add("blur.active.status", MeasureStatusName(active.status), active.usable() ? ProbeStatus::Pass : ProbeStatus::NotVerified, "D-20: requires a control sample; one reading is not evidence"); AddF("blur.active.contrast_in_window", active.contrast_in_window, 4, active.contrast_in_window >= 0.0 ? ProbeStatus::Pass : ProbeStatus::NotVerified, "RMS contrast 0..1; a hard 8px checkerboard measures exactly 0.5000"); AddF("blur.active.contrast_control", active.contrast_control, 4, active.contrast_control >= 0.0 ? ProbeStatus::Pass : ProbeStatus::NotVerified, "same-size sample just outside the window edge, same frame"); AddF("blur.active.drop", active.drop, 4, active.drop >= -1.0 ? ProbeStatus::Pass : ProbeStatus::NotVerified, "control minus in-window; must clear kMinDropMargin to count as blur"); Add("blur.active.observed", active.blur_observed() ? "blur present" : "no blur evidence", ProbeStatus::Pass, active.blur_observed() ? "tier A/B permitted" : "forces tier C"); Add("blur.active.detail", WideToNarrow(active.detail).c_str(), active.usable() ? ProbeStatus::Pass : ProbeStatus::NotVerified, ""); // W8 expects the tint to change when inactive; the OS blur behaviour when // inactive is one of the four items sec 16 calls unverified by research, so // it is probed rather than assumed. ::SetForegroundWindow(::GetDesktopWindow()); ::RedrawWindow(win.handle(), nullptr, nullptr, RDW_UPDATENOW); const BlurMeasurement inactive = MeasureBlurThroughWindow(win.handle(), kInWindowHasKnownDetail); Add("blur.inactive.status", MeasureStatusName(inactive.status), inactive.usable() ? ProbeStatus::Pass : ProbeStatus::NotVerified, "sec 16 names inactive-window backdrop as unverified by research"); AddF("blur.inactive.drop", inactive.drop, 4, inactive.drop >= -1.0 ? ProbeStatus::Pass : ProbeStatus::NotVerified, "compare against the active reading"); Add("blur.inactive.observed", inactive.blur_observed() ? "blur present" : "no blur evidence", ProbeStatus::Pass, ""); // ---- gate item 5 (part 2): E1/RV-07, the DPI-change handler -------------- // M1_PREP item 5 still needs a SECOND MONITOR for the real hop - that is // hardware, and this host has one display. What IS reachable here is the part // that was previously untested entirely: RV-07's claim that the reentrancy // guard cannot get stuck. // // It could not get stuck before, and nothing noticed, because the handler // lived inline in HostWndProc where no probe can reach it. Driving // Window::OnDpiChanged directly (the owner LEDGER P1 always named) closes that. // // TWO cases, because the second is the one that used to break: // a) a DIFFERENT suggested rect -> SetWindowPos provokes WM_SIZE, which // cleared the guard, so this passed even with the bug. // b) the CURRENT rect, unchanged -> SetWindowPos provokes NO WM_SIZE, so // nothing cleared the guard and it stayed set. This is the case that // would make every later ordinary resize look DPI-induced. { RECT before = {}; ::GetWindowRect(win.handle(), &before); // (a) different rect RECT moved = {before.left + 24, before.top + 16, before.right + 24, before.bottom + 16}; win.OnDpiChanged(0, reinterpret_cast(&moved)); RECT after = {}; ::GetWindowRect(win.handle(), &after); const bool adopted = (after.left == moved.left && after.top == moved.top && after.right == moved.right && after.bottom == moved.bottom); const bool guard_clear_a = !win.dpi_change_in_flight(); // (b) same rect - no WM_SIZE is provoked, so nothing else can clear it win.OnDpiChanged(0, reinterpret_cast(&after)); const bool guard_clear_b = !win.dpi_change_in_flight(); const bool e1 = adopted && guard_clear_a && guard_clear_b; char e1buf[256]; std::snprintf(e1buf, sizeof(e1buf), "suggested rect adopted=%s; guard clear after resize=%s, " "after NO-resize=%s (the case that used to stick)", adopted ? "yes" : "NO", guard_clear_a ? "yes" : "NO", guard_clear_b ? "yes" : "NO"); Add("gate5.dpi_guard_balanced", e1 ? "guard always cleared" : "GUARD CAN STICK", e1 ? ProbeStatus::Pass : ProbeStatus::Fail, e1buf); } // ---- gate item 10: BUG-04, the checkerboard must be a CHECKERBOARD ------- // M1_PREP recorded this as "NOT EXERCISABLE AT M0" purely because // PaintCheckerboard had no callers. With the control window above, the pattern // is finally observable, and this is the assertion that pins BUG-04's fix: // // SetDCBrushColor only affects DC_BRUSH. Filling with BLACK_BRUSH instead // paints every square black and the "checkerboard" is a SOLID RECT. A hard // checkerboard measures contrast 0.5000 (D-21); a solid black one measures // 0.0000. One assertion separates them, and it cannot pass by accident, // because neither "all black" nor "all white" lands in the band. if (checker != nullptr) { RECT cr = {}; ::GetWindowRect(checker, &cr); const int cw = cr.right - cr.left; const int ch = cr.bottom - cr.top; std::vector cpx; MeasureStatus cst = MeasureStatus::Ok; double contrast = -1.0; if (cw > 0 && ch > 0 && CaptureScreenRegion(cr.left, cr.top, cw, ch, &cpx, &cst)) { contrast = BlockContrast(cpx.data(), cw, ch); } const bool patterned = contrast > 0.45 && contrast < 0.55; char cb_buf[192]; std::snprintf(cb_buf, sizeof(cb_buf), "control window %dx%d, RMS contrast %.4f (hard checkerboard = 0.5000, " "solid rect = 0.0000) -> BUG-04 %s", cw, ch, contrast, patterned ? "FIXED" : "REGRESSED"); Add("gate10.checkerboard", patterned ? "checkerboard" : "NOT a checkerboard", patterned ? ProbeStatus::Pass : ProbeStatus::Fail, cb_buf); } else { Add("gate10.checkerboard", "NOT VERIFIED", ProbeStatus::NotVerified, "control window was not created; PaintCheckerboard never ran"); } DWORD cloaked = 1; // BUG-19: the HRESULT of the cloak query is part of the measurement. The // return value used to be ignored, so a failed query left `cloaked` at its // initialised 1 and the row read FAIL - indistinguishable from "DWM refuses // to composite this window" - when the honest answer is NOT VERIFIED. const HRESULT cloak_hr = ::DwmGetWindowAttribute(win.handle(), DWMWA_CLOAKED, &cloaked, sizeof(cloaked)); if (SUCCEEDED(cloak_hr)) { AddI("dwm.cloaked", cloaked, cloaked == 0 ? ProbeStatus::Pass : ProbeStatus::Fail, "must be 0 or DWM never composites the window"); } else { char cloak_buf[32]; std::snprintf(cloak_buf, sizeof(cloak_buf), "0x%08lX", static_cast(cloak_hr)); Add("dwm.cloaked", cloak_buf, ProbeStatus::NotVerified, "DwmGetWindowAttribute(DWMWA_CLOAKED) failed; cloaked state unknown"); } // ---- 5b. E2/W1: does the back buffer actually COVER the client? ---------- // // The M0 capture showed a ~354 px black strip down the right of the window // while the clear colour was exact, so "the clear reached the screen" and // "the buffer covers the window" are two DIFFERENT claims and only the // second one catches this. Reading the granted size back from DXGI is the // only way to see it; our cached width_/height_ only record intent. // // NOTE the probe sizes its chain from GetWindowRect (see below), so this row // is expected to PASS here even though the app was wrong. The app's own // runtime guard in main.cpp is what covers the real path; this row pins the // measurement method and would catch a regression in CreateSwapChain. { RECT cr = {}; ::GetClientRect(win.handle(), &cr); const UINT cw = static_cast(cr.right - cr.left); const UINT ch = static_cast(cr.bottom - cr.top); AddI("e2.client_w", static_cast(cw), ProbeStatus::Pass, "live GetClientRect width for this probe window"); AddI("e2.client_h", static_cast(ch), ProbeStatus::Pass, "live GetClientRect height for this probe window"); RECT wr2 = {}; ::GetWindowRect(win.handle(), &wr2); DxDevice cov; if (cov.Create() && cov.CreateSwapChain(win.handle(), static_cast(wr2.right - wr2.left), static_cast(wr2.bottom - wr2.top), QualityTier::Full)) { UINT bw = 0, bh = 0; cov.SwapChainBufferSize(&bw, &bh); AddI("e2.buffer_w", static_cast(bw), ProbeStatus::Pass, "DXGI_SWAP_CHAIN_DESC.BufferDesc.Width, read back from the chain"); AddI("e2.buffer_h", static_cast(bh), ProbeStatus::Pass, "DXGI_SWAP_CHAIN_DESC.BufferDesc.Height, read back from the chain"); AddI("e2.buffer_w_equals_requested", bw == static_cast(wr2.right - wr2.left) ? 1 : 0, (bw == static_cast(wr2.right - wr2.left)) ? ProbeStatus::Pass : ProbeStatus::Fail, "DXGI granted exactly the width we asked for"); AddI("e2.buffer_h_equals_requested", bh == static_cast(wr2.bottom - wr2.top) ? 1 : 0, (bh == static_cast(wr2.bottom - wr2.top)) ? ProbeStatus::Pass : ProbeStatus::Fail, "DXGI granted exactly the height we asked for"); // J5/G1: the alpha mode and format the chain actually came up with. DXGI_SWAP_CHAIN_DESC d1 = {}; cov.swap_chain()->GetDesc(&d1); AddI("e2.chain_format", static_cast(d1.BufferDesc.Format), d1.BufferDesc.Format == DXGI_FORMAT_B8G8R8A8_UNORM ? ProbeStatus::Pass : ProbeStatus::Fail, "J5/X28: presented chain must be B8G8R8A8_UNORM, never R10G10B10A2"); cov.DestroySwapChain(); } else { Add("e2.buffer_w", "", ProbeStatus::NotVerified, "coverage chain could not be created"); } cov.Destroy(); } // ---- 5b. resize stress (M1_PREP gate item 4; BUG-01 / BUG-02) --------- // The gate asks for ~1700x841 down to ~700x480 and back, with the teal // surface tracking the client every frame, no black remainder, and no // first-frame loss. // // window.client_follows_resize already covers three sizes on the GEOMETRY. // This walks the gate's own range and additionally asserts that the present // after each resize actually LANDED, which a size comparison cannot do at // all: a dropped present leaves every size correct and the surface dark. That // blind spot is the same class of gap that let BUG-26 look "fixed" twice - // the measurement could not see the quantity the defect lived in. // // Note the 700x480 request is raised to the W6 minimum track size (640x420 dp) // by WM_GETMINMAXINFO, so the row asserts agreement at whatever size the // system actually granted rather than at the number asked for. { const int kW[] = {1700, 700, 1700, 900}; const int kH[] = {841, 480, 841, 640}; DxDevice stress; char detail[192] = {}; if (!stress.Create()) { Add("gate4.resize_stress", "", ProbeStatus::NotVerified, "coverage device could not be created"); } else { RECT wr3 = {}; ::GetWindowRect(win.handle(), &wr3); bool chain_ok = stress.CreateSwapChain( win.handle(), static_cast(wr3.right - wr3.left), static_cast(wr3.bottom - wr3.top), QualityTier::Full); bool ok = chain_ok; bool have_detail = false; std::snprintf(detail, sizeof(detail), "chain created"); for (int i = 0; ok && i < 4; ++i) { ::SetWindowPos(win.handle(), nullptr, 0, 0, kW[i], kH[i], SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); RECT w4 = {}; RECT c4 = {}; ::GetWindowRect(win.handle(), &w4); ::GetClientRect(win.handle(), &c4); const UINT ww = static_cast(w4.right - w4.left); const UINT wh = static_cast(w4.bottom - w4.top); const UINT cw = static_cast(c4.right - c4.left); const UINT chh = static_cast(c4.bottom - c4.top); // Exactly what the app does: resize the chain, re-link the visual, present. if (!stress.ResizeSwapChain(cw, chh) || ww != cw || wh != chh) { ok = false; std::snprintf(detail, sizeof(detail), "step %d asked %dx%d -> window %ux%u client %ux%u, chain resize %s", i, kW[i], kH[i], ww, wh, cw, chh, (ww == cw && wh == chh) ? "ok" : "FAILED"); break; } stress.AttachContent(); UINT bw = 0; UINT bh = 0; stress.SwapChainBufferSize(&bw, &bh); if (bw != cw || bh != chh) { ok = false; std::snprintf(detail, sizeof(detail), "step %d client %ux%u but DXGI granted buffer %ux%u", i, cw, chh, bw, bh); break; } HRESULT hr = S_OK; ID3D11RenderTargetView* rtv = stress.AcquireRtv(&hr); if (rtv == nullptr || FAILED(hr)) { ok = false; std::snprintf(detail, sizeof(detail), "step %d could not acquire an RTV", i); break; } stress.context()->OMSetRenderTargets(1, &rtv, nullptr); const FLOAT clear[4] = {0.16f, 0.22f, 0.28f, 1.0f}; stress.context()->ClearRenderTargetView(rtv, clear); stress.context()->Flush(); const HRESULT phr = stress.swap_chain()->Present(0, 0); if (FAILED(phr)) { ok = false; std::snprintf(detail, sizeof(detail), "step %d present failed 0x%08lX", i, static_cast(phr)); break; } const bool clamped = (cw != static_cast(kW[i]) || chh != static_cast(kH[i])); // Keep the first step, and let any step the W6 minimum resized OVERWRITE // it - the clamped step is the informative one, and a detail that only // ever reports the last step would hide it. if (clamped || !have_detail) { std::snprintf(detail, sizeof(detail), "asked %dx%d -> granted %ux%u%s; window == client == buffer and the present landed", kW[i], kH[i], cw, chh, clamped ? " (raised to the W6 minimum track size)" : ""); have_detail = true; } } stress.DestroySwapChain(); stress.Destroy(); Add("gate4.resize_stress", ok ? "window == client == buffer, present landed at every step" : "MISMATCH", ok ? ProbeStatus::Pass : ProbeStatus::Fail, detail); } } // ---- 5c. W6 minimum track size (BUG-05; part of gate item 5) ------------ // The minimum must be converted dp -> px at WM_GETMINMAXINFO QUERY time, never // cached once at start-up: a cached value stays at the construction-time DPI // forever, so at 150% the enforced minimum is half the documented size. That // was the original BUG-05. // // The probe's own window procedure routes only WM_NCCALCSIZE and // WM_ERASEBKGND, so WM_GETMINMAXINFO is never delivered to it and nothing else // exercises this path - which is why 700x480 was granted verbatim in // gate4.resize_stress instead of being raised to the minimum. Call the handler // directly and compare against a conversion performed NOW, at the window's // current scale. That covers the conversion; proving it RE-converts on a // monitor hop still needs a second display at a different scale. { MINMAXINFO mmi = {}; mmi.ptMaxSize.x = 12345; // the system pre-fills these; only ptMinTrackSize is ours mmi.ptMaxSize.y = 12345; win.OnGetMinMaxInfo(&mmi); const int want_x = DpToPx(640.0f, win.dpi_scale()); const int want_y = DpToPx(420.0f, win.dpi_scale()); const bool ok = (mmi.ptMinTrackSize.x == want_x) && (mmi.ptMinTrackSize.y == want_y); char mmi_buf[128]; std::snprintf(mmi_buf, sizeof(mmi_buf), "min_track=%dx%d expected=%dx%d at scale %.3f (a cached value would read 640x420)", mmi.ptMinTrackSize.x, mmi.ptMinTrackSize.y, want_x, want_y, static_cast(win.dpi_scale())); Add("gate5.min_track_dp_px", ok ? "converted at query time" : "MISMATCH", ok ? ProbeStatus::Pass : ProbeStatus::Fail, mmi_buf); // And the untouched fields must survive, since the system pre-filled them. const bool kept = (mmi.ptMaxSize.x == 12345) && (mmi.ptMaxSize.y == 12345); AddI("gate5.min_track_preserves_system", kept ? 1 : 0, kept ? ProbeStatus::Pass : ProbeStatus::Fail, "OnGetMinMaxInfo must override ptMinTrackSize ONLY; everything else keeps the system value"); } // ---- input translation (C3 / C4 / E11) --------------------------------- // The Win32 -> core::Key table. This is the only part of the input path that // can be checked without a real keyboard, and it is worth checking: a wrong // mapping is invisible right up until a key does the wrong thing in a live UI. // What is deliberately NOT claimed here - that the WndProc routes these // messages, or that the frame/surrogate/drag logic behaves. Those are the // portable harness's job (T-17..T-19), separately falsified. { using fcs::core::Key; struct VkCase { int vk; Key want; }; const VkCase cases[] = { {VK_TAB, Key::Tab}, {VK_ESCAPE, Key::Escape}, {VK_RETURN, Key::Enter}, {VK_SPACE, Key::Space}, {VK_LEFT, Key::Left}, {VK_RIGHT, Key::Right}, {VK_UP, Key::Up}, {VK_DOWN, Key::Down}, }; int bad = 0; for (const VkCase& c : cases) { if (platform::KeyFromVk(c.vk) != c.want) ++bad; } // Keys the core layer does not model must be ABSENT, not aliased onto one // that it does: 'A' and the numpad Enter are different keys to a user. if (platform::KeyFromVk('A') != Key::None) ++bad; if (platform::KeyFromVk(VK_NUMPAD0) != Key::None) ++bad; char vk_buf[160]; std::snprintf(vk_buf, sizeof(vk_buf), "%d wrong of %zu mapped; unmapped 'A' and numpad0 must read None", bad, sizeof(cases) / sizeof(cases[0])); Add("input.vk_map", bad == 0 ? "8 mapped + 2 unmapped" : "MISMATCH", bad == 0 ? ProbeStatus::Pass : ProbeStatus::Fail, vk_buf); // Button indices are BIT POSITIONS in the core layer's mask, shared by // both sides, so they are asserted rather than assumed. X buttons are // deliberately excluded here - their number arrives in the HIGH word of // wParam and is handled in the WndProc, not through this table. const bool btn = (platform::ButtonFromVk(VK_LBUTTON) == 0) && (platform::ButtonFromVk(VK_RBUTTON) == 1) && (platform::ButtonFromVk(VK_MBUTTON) == 2) && (platform::ButtonFromVk(VK_XBUTTON1) == -1) && (platform::ButtonFromVk(VK_F1) == -1); Add("input.button_bits", btn ? "L=0 R=1 M=2, others unmapped" : "MISMATCH", btn ? ProbeStatus::Pass : ProbeStatus::Fail, "indices are shared bit positions; X-buttons are NOT in this table"); // Level vs edge, which is the distinction Windows forces and a test that // pairs every down with an up can never see: one WM_LBUTTONDOWN covers an // entire held click, so the LEVEL must survive an idle frame while the EDGE // must not. // // The two frames are read one at a time, NEVER both held at once. // Snapshot() returns a reference to internal state that the NEXT call // overwrites in place, so two references name the same memory and comparing // them silently compares the newer frame with itself. That is exactly what // the first version of this row did, which is why it reported MISMATCH for a // reason that had nothing to do with input. Both frame-1 values are read from // the ONE frame-1 reference - calling Snapshot() twice to get them separately // just moves the edge into the second, empty frame. fcs::core::InputFrame f; f.OnMouseButton(0, true); const fcs::core::InputSnapshot& i1 = f.Snapshot(); const bool f1_down = i1.MouseDown(0); const bool f1_edge = i1.MousePressed(0); const fcs::core::InputSnapshot& i2 = f.Snapshot(); // idle: no events at all const bool edges = f1_down && f1_edge && i2.MouseDown(0) && !i2.MousePressed(0); Add("input.level_vs_edge", edges ? "held click survives, edge is one frame" : "MISMATCH", edges ? ProbeStatus::Pass : ProbeStatus::Fail, "Windows sends ONE down per held click; a purely event-driven mask would end every drag after one frame"); } // ---- 6. frame time (D-27: DwmFlush is mandatory) ---------------------- // Sec 16 wants a 5 s window DRAG. A real drag needs real input, which cannot // be synthesised reliably here, so the frame loop is timed and the drag // itself is reported NOT VERIFIED rather than faked. RECT wr = {}; ::GetWindowRect(win.handle(), &wr); if (dx.CreateSwapChain(win.handle(), static_cast(wr.right - wr.left), static_cast(wr.bottom - wr.top), QualityTier::Full)) { HRESULT rtv_hr = E_FAIL; ID3D11RenderTargetView* rtv = dx.AcquireRtv(&rtv_hr); if (rtv) { std::vector samples; samples.reserve(400); const double deadline = PerfNowMs() + 5000.0; const float clear[4] = {0.05f, 0.06f, 0.07f, 1.0f}; while (PerfNowMs() < deadline) { const double t0 = PerfNowMs(); dx.context()->ClearRenderTargetView(rtv, clear); dx.swap_chain()->Present(0, 0); ::DwmFlush(); // D-27: without it the median reads ~0.5ms and is fiction samples.push_back(PerfNowMs() - t0); } ReportStats("frame.tier_a.loop", samples); } else { Add("frame.tier_a.loop", "", ProbeStatus::Fail, "no render target view"); } dx.DestroySwapChain(); } else { Add("frame.tier_a.loop", "", ProbeStatus::NotVerified, "swap chain could not be created"); } Add("frame.synthetic_drag", "", ProbeStatus::NotVerified, "sec 16 asks for a 5 s real window DRAG; synthetic input does not reach the " "interactive desktop, so only the frame loop above is timed"); // ---- J8 / J12: settings and handle sentinels -------------------------- // DELIBERATELY AFTER the frame-time section. The first call to // SHGetKnownFolderPath(FOLDERID_RoamingAppData) starts asynchronous // folder-redirector work that contends with presentation badly enough to // take frame.tier_a.loop from 16.65 ms (n=301) to ~256 ms (n=20) - measured // by bisection, and a 2 s settle restores 16.65 ms exactly. Measuring frame // cadence across that window measures the SHELL, not the renderer, so these // rows run after the timing rather than quietly rewriting the number. // ---- J8: atomic settings save ------------------------------------------ // The rules live in core/settings.h and are tested there. What is provable // HERE is that the REAL Windows path obeys rule 1 - the temp must land in the // same directory as ui.json, because that, and not MoveFileEx, is what makes // the replace atomic. A %TEMP% temp would be a different volume and turn the // save into a copy-then-delete that can be interrupted halfway. { const std::wstring path = Settings::Path(); const std::wstring temp = Settings::TempPath(); const bool have = !path.empty() && !temp.empty(); const bool same_dir = have && core::SameDirectory(WideToUtf8(path), WideToUtf8(temp)); // And it must be a KNOWN folder, not something invented under %APPDATA%. const bool known = have && path.find(L"Roaming") != std::wstring::npos; const bool j8 = have && same_dir && known; Add("j8.temp_same_directory", j8 ? "same directory (replace is atomic)" : "MISMATCH", j8 ? ProbeStatus::Pass : ProbeStatus::Fail, have ? ("target=" + WideToNarrow(path) + " temp=" + WideToNarrow(temp)).c_str() : "no known-folder path"); } // ---- J12: handle sentinels ------------------------------------------------ // The point of J12 is that these sentinels are DIFFERENT values from each // other, and that no integer cast is involved anywhere. A cast that compiles // here IS the bug the rule forbids. { const bool distinct = (INVALID_HANDLE_VALUE != nullptr); const bool pred = IsInvalidFileHandle(INVALID_HANDLE_VALUE) && !IsInvalidFileHandle(nullptr) && !IsNullHandle(INVALID_HANDLE_VALUE) && IsNullHandle(nullptr); char j12buf[256]; std::snprintf(j12buf, sizeof(j12buf), "INVALID_HANDLE_VALUE is %s NULL; HANDLE is pointer-sized (%zu bytes)", distinct ? "NOT" : "SUSPECT", sizeof(HANDLE)); const bool j12 = distinct && pred; Add("j12.handle_sentinel", j12 ? "INVALID_HANDLE_VALUE != NULL, predicates agree" : "MISMATCH", j12 ? ProbeStatus::Pass : ProbeStatus::Fail, j12buf); } // ---- 7. snap layouts (D-28: no API exists) --------------------------- // The ENABLING condition is verifiable; the flyout itself is not. { RECT cr = {}; ::GetClientRect(win.handle(), &cr); const int bw = DpToPx(46.0f, win.dpi_scale()); const int bh = DpToPx(32.0f, win.dpi_scale()); // W3 orders the buttons right-to-left: close [right-bw,right), // maximize [right-2bw,right-bw), minimize [right-3bw,right-2bw). // Two earlier revisions of this probe sampled at the wrong slot and // reported a spurious FAIL (first HTCLOSE(20), then HTCLIENT(1)); // the verified centre of the maximize button is right-2bw + bw/2. struct { const char* name; LRESULT want; int slot; } kButtons[] = { { "snap.htclose", HTCLOSE, 0 }, { "snap.htmaxbutton", HTMAXBUTTON, 1 }, { "snap.htminbutton", HTMINBUTTON, 2 }, }; for (const auto& b : kButtons) { POINT p = {cr.right - bw * b.slot - bw / 2, bh / 2}; ::ClientToScreen(win.handle(), &p); const LRESULT ht = win.NCHitTest(p); AddI(b.name, ht, ht == b.want ? ProbeStatus::Pass : ProbeStatus::Fail, "W2: the HT* code returned from WM_NCHITTEST over this caption button"); } // And the caption strip itself must still be HTCAPTION. POINT mid = {cr.right / 2, bh / 2}; ::ClientToScreen(win.handle(), &mid); const LRESULT htc = win.NCHitTest(mid); AddI("snap.htcaption", htc, htc == HTCAPTION ? ProbeStatus::Pass : ProbeStatus::Fail, "W2: the 32 dp caption strip is HTCAPTION away from any control"); // BUG-28: the TOP edge must report HTTOP like the other three edges. It was // previously swallowed by the caption strip above, so the window resized from // its two top CORNERS and from left/right/bottom but never from the span // between them - the cursor stayed an arrow on a border that drew a resize // arrow on both ends of it. // // Sample scanline y=1 at mid-width: inside the resize band (ResizeBorderPx is // >= 4 px at every DPI) and clear of the caption buttons, which sit in the // top-right and are resolved before the edges. Together with snap.htcaption // above this pins both sides of the boundary - the band must be HTTOP, the // strip below it must stay HTCAPTION. { POINT top = {cr.right / 2, 1}; ::ClientToScreen(win.handle(), &top); const LRESULT htt = win.NCHitTest(top); AddI("snap.httop_edge", htt, htt == HTTOP ? ProbeStatus::Pass : ProbeStatus::Fail, "BUG-28: WM_NCHITTEST on the top border must be HTTOP, not HTCAPTION"); } // BUG-33: the resize band and the caption buttons used to overlap - the // buttons were flush at y=0, so the band's top few px sat on top of them and // one had to lose. These two rows pin the boundary from BOTH sides, which is // what makes the fix observable: before it, the first point was a button and // the second was too, so neither row could tell the difference. { const int band = win.resize_border_px(); const int close_x = cr.right - DpToPx(46.0f, win.dpi_scale()) / 2; // Over the Close button's x, 1 px from the top. That x is ~34 px in from // the right edge - outside the 12 px right band - so this point is in the // TOP band only, and the honest answer is HTTOP, not HTTOPRIGHT. It // discriminates because before the fix the button was flush at y=0 and // this exact point returned HTCLOSE instead. POINT corner = {close_x, 1}; ::ClientToScreen(win.handle(), &corner); const LRESULT htc2 = win.NCHitTest(corner); AddI("snap.band_beats_button", htc2, htc2 == HTTOP ? ProbeStatus::Pass : ProbeStatus::Fail, "BUG-33: the top band must win over the button (was HTCLOSE while the " "button was flush at y=0); W2's full-perimeter resize stays intact"); // 1 px below the band, same x: the whole button is now reachable. POINT below = {close_x, band + 1}; ::ClientToScreen(win.handle(), &below); const LRESULT htc3 = win.NCHitTest(below); AddI("snap.button_below_band", htc3, htc3 == HTCLOSE ? ProbeStatus::Pass : ProbeStatus::Fail, "BUG-33: 1 px below the band must already be the button, so no px of it is a dead zone"); } } Add("snap.flyout_observed", "", ProbeStatus::NotVerified, "D-28: no snap-layout API exists in any SDK header and the flyout is a private " "shell surface; only a human observing the screen can confirm it"); // ---- 8. premultiplied alpha (G1) ------------------------------------- if (os.session == SessionKind::Remote) { Add("alpha.premultiplied", "", ProbeStatus::NotVerified, "RDP session; premultiplied alpha over RDP needs a live comparison this probe " "cannot make without a second session"); } else { Add("alpha.premultiplied", "swap chain set to PREMULTIPLIED", ProbeStatus::Pass, "G1 verified as SET, not as VISIBLE - the API does not enforce it (D-17)"); } // ---- 9. the chosen tier (B5, measurement-driven) ---------------------- { TierInputs ti; ti.build = os.build; ti.profile = os.profile; ti.session = os.session; ti.transparency_effects = os.transparency_effects; ti.transparency_known = os.transparency_known; ti.warp_only = (dx.info().driver == DriverKind::Warp); ti.high_contrast = os.high_contrast; ti.has_contrast = active.usable(); ti.checker_contrast = (active.contrast_in_window >= 0.0) ? active.contrast_in_window : 1.0; const TierDecision d = SelectTier(ti); Add("tier.chosen", TierName(d.tier), d.measured ? ProbeStatus::Pass : ProbeStatus::NotVerified, d.reason); Add("tier.measurement_driven", d.measured ? "yes" : "no", ProbeStatus::Pass, "B5: the build number is a gate, never the decider"); } // ---- gate item 9: E3 device-removal RECOVERY (failure injection) --------- // LAST, and deliberately so. This drill calls Recreate() and rebuilds the // probe window composition tree, which legitimately changes what is on screen // for everything after it. Run mid-probe it covered part of the checkerboard // control window and dropped gate10 to 0.2774 - the test corrupting the // measurement rather than the measurement being wrong. // M1_PREP item 9 said this needed "a VM or a deliberate GPU hang". Neither // exists here, and a real TDR is not something to induce on someone's // machine. But the LEDGER's own proving test for E3 is "T9 failure // injection", and the injection seam now exists, so the RECOVERY path is // reachable after all. // // HONEST SCOPE: this proves the failure is CLASSIFIED correctly and that // Recreate() + a rebuilt chain brings presentation back. It does NOT prove // recovery from a real driver TDR - the device here is never actually lost, // only the HRESULT is synthesised. The row says so in its own value. { const bool injected_failed = [&] { dx.InjectDeviceRemoved(1); const HRESULT bad = dx.Present(DXGI_PRESENT_DO_NOT_WAIT); const bool classified = (bad == DXGI_ERROR_DEVICE_REMOVED || bad == DXGI_ERROR_DEVICE_RESET); // And the injection must be a ONE-FRAME countdown, not a sticky // poison pill - a hook that never released would make every later row // meaningless. const bool released = (dx.pending_injections() == 0); return classified && released; }(); // Recovery: rebuild the device, then the chain and its content, exactly as // the frame loop's PresentResult::Failed branch does. const bool recovered = [&] { if (!dx.Recreate()) return false; RECT r = {}; if (!::GetClientRect(win.handle(), &r)) return false; const UINT w = static_cast(r.right - r.left); const UINT h = static_cast(r.bottom - r.top); if (w == 0 || h == 0) return false; if (!dx.CreateSwapChain(win.handle(), w, h, QualityTier::Full)) return false; if (!dx.AttachContent()) return false; ID3D11RenderTargetView* rtv = dx.AcquireRtv(nullptr); if (rtv == nullptr) return false; const FLOAT clear[4] = {0.16f, 0.22f, 0.28f, 1.0f}; dx.context()->OMSetRenderTargets(1, &rtv, nullptr); dx.context()->ClearRenderTargetView(rtv, clear); dx.context()->Flush(); const HRESULT hr = dx.Present(0); return hr == S_OK; }(); const bool e3 = injected_failed && recovered; char e3buf[256]; std::snprintf(e3buf, sizeof(e3buf), "injected removal %s; Recreate+chain+present %s " "(proves classification and recovery, NOT a real TDR)", injected_failed ? "detected and one-shot" : "FAILED", recovered ? "succeeded" : "FAILED"); Add("gate9.e3_recovery", e3 ? "recovered from injected removal" : "FAILED", e3 ? ProbeStatus::Pass : ProbeStatus::Fail, e3buf); dx.InjectDeviceRemoved(0); // belt and braces: never leave it armed } // ---- 10. v4.2 items J5 and J7, observable from here ------------------- { // J5 / X28: the presented swap chain must be B8G8R8A8 on EVERY tier. // R10G10B10A2 has a 2-bit alpha, so it cannot carry premultiplied translucency. const DXGI_FORMAT presented = dx.RenderTargetFormat(QualityTier::Full); const DXGI_FORMAT opaque = dx.InternalOpaqueFormat(); AddI("j5.swap_chain_format", static_cast(presented), presented == DXGI_FORMAT_B8G8R8A8_UNORM ? ProbeStatus::Pass : ProbeStatus::Fail, "J5/X28: presented chain is B8G8R8A8 on every tier"); AddI("j5.internal_opaque_format", static_cast(opaque), ProbeStatus::Pass, "G2 kept: R10G10B10A2 is allowed for opaque internal targets only"); } { // J7 / X30: when maximized, the client rect must be pulled inside the work // area so nothing runs under the taskbar or off the screen edge. // // Measured, not assumed: on this host a maximized window rect is INFLATED // past the monitor by the off-screen resize border (-8,-8,1288,680 on a // 1280x720 monitor). The 8 px inset is what brings the client back to // (0,0,1280,672) - which is EXACTLY the work area. So the correct criterion // is containment (client <= work area), NOT strict inequality; requiring // client < work would have rejected the correct behaviour. ::ShowWindow(win.handle(), SW_MAXIMIZE); ::RedrawWindow(win.handle(), nullptr, nullptr, RDW_UPDATENOW); RECT zc = {}, zw = {}; ::GetClientRect(win.handle(), &zc); ::GetWindowRect(win.handle(), &zw); HMONITOR mon = ::MonitorFromWindow(win.handle(), MONITOR_DEFAULTTOPRIMARY); MONITORINFO mi = {}; mi.cbSize = sizeof(mi); ::GetMonitorInfoW(mon, &mi); const long cli_w = zc.right - zc.left; const long cli_h = zc.bottom - zc.top; const long win_w = zw.right - zw.left; const long win_h = zw.bottom - zw.top; const long work_w = mi.rcWork.right - mi.rcWork.left; const long work_h = mi.rcWork.bottom - mi.rcWork.top; AddI("j7.maximized_client_w", cli_w, ProbeStatus::Pass, "J7/X30: client width when zoomed"); AddI("j7.maximized_client_h", cli_h, ProbeStatus::Pass, "J7/X30: client height when zoomed"); AddI("j7.maximized_window_w", win_w, ProbeStatus::Pass, "J7/X30: window rect is inflated past the screen - this is what the inset corrects"); AddI("j7.maximized_window_h", win_h, ProbeStatus::Pass, "see above"); AddI("j7.work_area_w", work_w, ProbeStatus::Pass, "for comparison"); AddI("j7.work_area_h", work_h, ProbeStatus::Pass, "for comparison"); // Containment: the client must not exceed the work area in either axis. const bool contained = (cli_w <= work_w) && (cli_h <= work_h); const bool inset_effective = (win_w > work_w) || (win_h > work_h); Add("j7.maximized_inset_applied", contained ? "yes" : "no", contained ? ProbeStatus::Pass : ProbeStatus::Fail, "J7: client must be contained in the work area so nothing runs off-screen or " "under the taskbar (X30). Equality is the expected outcome when the maximized " "window rect is inflated by the resize border"); AddI("j7.window_rect_was_inflated", inset_effective ? 1 : 0, inset_effective ? ProbeStatus::Pass : ProbeStatus::NotVerified, "evidence the inset is doing real work: the maximized window rect exceeds the work area"); ::ShowWindow(win.handle(), SW_RESTORE); ::RedrawWindow(win.handle(), nullptr, nullptr, RDW_UPDATENOW); } win.Destroy(); } // Entry point for the M0a probe. Console subsystem so the JSON reaches stdout. int RunProbeMain(HINSTANCE instance) { // P1 before any window exists. const DpiState dpi = InitDpiAwareness(); // J4 / X31: pin the DLL search to System32 before anything else loads a DLL. // Reports honestly when the host predates the API rather than claiming it. const bool dll_search = InitDllSearch(); Add("dll.search_restricted", dll_search ? "System32" : "unavailable", dll_search ? ProbeStatus::Pass : ProbeStatus::NotVerified, "J4: SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32); absent on pre-Win8. " "Our own LoadLibraryExW calls pass LOAD_LIBRARY_SEARCH_SYSTEM32 regardless (D-12)"); AddI("dpi.system_dpi", dpi.system_dpi, ProbeStatus::Pass, "P1/W5: resolved via GetProcAddress; absent falls back to GetSystemMetrics scaling"); Add("dpi.per_monitor_v2", dpi.per_monitor_v2 ? "granted" : "not granted", dpi.per_monitor_v2 ? ProbeStatus::Pass : ProbeStatus::NotVerified, "P1: depends on the host permitting per-monitor v2"); RunProbe(instance); return 0; } } // namespace // REQ sec 16 - the program measures and prints; nothing is judged by eye. int ProbeMain(HINSTANCE instance) { std::printf("FCS Glass M0a probe - FCS_Glass_Master_Prompt_v4.md sec 16\n"); std::printf("NOT VERIFIED means not observable in this session; it is never PASS.\n\n"); // RunProbeMain populates Rows(); ProbeMain only reports and sets the exit code. RunProbeMain(instance); std::printf("=== SUMMARY (human readable) ===\n"); for (const Row& r : Rows()) { std::printf(" [%-12s] %-28s %s\n", StatusName(r.status), r.key.c_str(), r.value.c_str()); if (!r.note.empty()) std::printf(" %s\n", r.note.c_str()); } int pass = 0, fail = 0, nv = 0; for (const Row& r : Rows()) { if (r.status == ProbeStatus::Pass) ++pass; else if (r.status == ProbeStatus::Fail) ++fail; else ++nv; } std::printf("\n PASS=%d FAIL=%d NOT VERIFIED=%d\n", pass, fail, nv); std::printf("\n=== JSON ===\n"); EmitJson(stdout); return (fail == 0) ? 0 : 1; } } // namespace fcs