@capagents/forgeqe 3.1.8 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/HOW_TO_USE.md +51 -4
  2. package/THIRD_PARTY_NOTICES.md +2 -1
  3. package/dist/docs-site/docs/area-operations/index.html +25 -2
  4. package/dist/docs-site/docs/area-quality/index.html +17 -3
  5. package/dist/docs-site/docs/area-setup/index.html +1 -1
  6. package/dist/docs-site/docs/get-started/index.html +18 -2
  7. package/dist/docs-site/docs/overview/index.html +1 -1
  8. package/dist/docs-site/docs/search.js +1 -1
  9. package/dist/forgeqe.js +1972 -1930
  10. package/dist/template.html +12 -12
  11. package/dist/vendor/ibm-ace.js +2 -0
  12. package/dist/web/THIRD_PARTY_NOTICES.md +29 -0
  13. package/dist/web/assets/{3d-force-graph-OeCdKJJ-.js → 3d-force-graph-Bhmgjf_7.js} +1 -1
  14. package/dist/web/assets/Agent-Dx4aOB_h.js +8 -0
  15. package/dist/web/assets/AgentWork-D0MS10up.js +2 -0
  16. package/dist/web/assets/ApiTests-DUoEh0nX.js +10 -0
  17. package/dist/web/assets/Browse-BGgyLuL3.js +1 -0
  18. package/dist/web/assets/Chat-CEHUI2ty.js +3 -0
  19. package/dist/web/assets/{CommandPalette-zRrrp6F_.js → CommandPalette-rY8rp79k.js} +1 -1
  20. package/dist/web/assets/Compare-B_NCvogR.js +1 -0
  21. package/dist/web/assets/Cost-sm-6tWRQ.js +1 -0
  22. package/dist/web/assets/Data-CFyxbwPS.js +6 -0
  23. package/dist/web/assets/Desktop-A_D4LTis.js +1 -0
  24. package/dist/web/assets/DesktopReview-CM7xmpHS.js +2 -0
  25. package/dist/web/assets/Evidence-BlTkmzfE.js +1 -0
  26. package/dist/web/assets/Explore-DyGqAEff.js +2 -0
  27. package/dist/web/assets/Features-BjPR9gCe.js +1 -0
  28. package/dist/web/assets/Flags-C_DneXS9.js +2 -0
  29. package/dist/web/assets/Flaky-l5ugC_ER.js +1 -0
  30. package/dist/web/assets/Impact-7TXQHcsW.js +3 -0
  31. package/dist/web/assets/Jobs-xRLNI-8l.js +5 -0
  32. package/dist/web/assets/KindPage-BZu1Zo4S.js +6 -0
  33. package/dist/web/assets/Migration-DKsyDwDO.js +8 -0
  34. package/dist/web/assets/Observability-CVwKJ-fI.js +1 -0
  35. package/dist/web/assets/PageAgent-C1X5ot6v.js +1 -0
  36. package/dist/web/assets/Product-iHqLyIhD.js +12 -0
  37. package/dist/web/assets/Production-C8eGcwCi.js +1 -0
  38. package/dist/web/assets/Quality-BVsN6u0E.js +1 -0
  39. package/dist/web/assets/Readiness-BWlbiTeu.js +1 -0
  40. package/dist/web/assets/Record-C7qgNFqs.js +1 -0
  41. package/dist/web/assets/Regression-ChleHlqe.js +5 -0
  42. package/dist/web/assets/RelationGraph-CzR_Hs8A.js +1 -0
  43. package/dist/web/assets/Reports-CIcKyoHH.js +2 -0
  44. package/dist/web/assets/Response-D2ZeO8uW.js +9 -0
  45. package/dist/web/assets/Responsive-DCfw-Oz3.js +3 -0
  46. package/dist/web/assets/RunDiff-COaxhvKm.js +1 -0
  47. package/dist/web/assets/Runs-3qx2qf56.js +2 -0
  48. package/dist/web/assets/Settings-DG2k3Lno.js +21 -0
  49. package/dist/web/assets/Steps-CN4n8U1I.js +3 -0
  50. package/dist/web/assets/TestCases-BEfJFp5h.js +1 -0
  51. package/dist/web/assets/TestData-SO2qqaAF.js +2 -0
  52. package/dist/web/assets/TestDebt-DIYhbhjh.js +1 -0
  53. package/dist/web/assets/TestManagement-D7q6G3YN.js +4 -0
  54. package/dist/web/assets/WhatsNew-DqBLhhgk.js +1 -0
  55. package/dist/web/assets/{agents-C0Jg2pN8.js → agents-BUWN-VJv.js} +1 -1
  56. package/dist/web/assets/{coverage-BB9BLjGz.js → coverage-DCtiu73T.js} +4 -4
  57. package/dist/web/assets/dataParts-BdmBLsU9.js +3 -0
  58. package/dist/web/assets/{diff-cbn6NGtL.js → diff-DEgLgw6R.js} +1 -1
  59. package/dist/web/assets/families-CrnKBjis.js +1 -0
  60. package/dist/web/assets/{highlight--Ayfy7Gy.js → highlight-DSLpJ_Dq.js} +1 -1
  61. package/dist/web/assets/index-DAteDsgB.css +2 -0
  62. package/dist/web/assets/index-RJ1kEHuo.js +64 -0
  63. package/dist/web/assets/input-Be3YOEK2.js +1 -0
  64. package/dist/web/assets/logLevel-Dq8s6DZz.js +3 -0
  65. package/dist/web/assets/palette-Dcoz5crU.js +1 -0
  66. package/dist/web/assets/{paletteCommands-ar4wAGok.js → paletteCommands-fwv5XVOS.js} +1 -1
  67. package/dist/web/assets/parts-CkI14hIv.js +1 -0
  68. package/dist/web/assets/productParts-BOUMBM_H.js +1 -0
  69. package/dist/web/assets/qualityParts-8KI3JCY8.js +1 -0
  70. package/dist/web/assets/recordTest-kf2ykEQF.js +1 -0
  71. package/dist/web/assets/route-D8G-pTdk.js +1 -0
  72. package/dist/web/assets/stepper-CQSK6KS0.js +1 -0
  73. package/dist/web/index.html +7 -7
  74. package/docs/OBSERVABILITY.md +233 -0
  75. package/docs/user-guide.html +59 -6
  76. package/forgeqe.example.yaml +5 -1
  77. package/llms.example.json +1 -1
  78. package/package.json +2 -1
  79. package/prompts/browser-persona.md +1 -1
  80. package/py/forgeqe_desktop/handhooks.py +106 -4
  81. package/py/forgeqe_desktop/handrecord.py +77 -2
  82. package/py/forgeqe_desktop/service.py +22 -5
  83. package/py/forgeqe_desktop/workflow.py +47 -2
  84. package/py/forgeqe_engine/copilot_gateway.py +139 -5
  85. package/py/forgeqe_engine/copilot_models.py +186 -0
  86. package/py/forgeqe_engine/diagnostics.py +119 -2
  87. package/py/forgeqe_engine/llm.py +85 -1
  88. package/py/forgeqe_engine/persona.py +3 -2
  89. package/py/forgeqe_engine/service.py +36 -10
  90. package/py/forgeqe_mobile/record.py +95 -5
  91. package/dist/web/assets/Agent-DrdDwck4.js +0 -8
  92. package/dist/web/assets/AgentWork-wNaA-i2T.js +0 -2
  93. package/dist/web/assets/ApiTests-B3X6NIn8.js +0 -10
  94. package/dist/web/assets/Browse-Cd1DEgYR.js +0 -1
  95. package/dist/web/assets/Chat-4GknHS5Z.js +0 -3
  96. package/dist/web/assets/Compare-DJVhkzqO.js +0 -1
  97. package/dist/web/assets/Cost-CbKnuQuB.js +0 -1
  98. package/dist/web/assets/Data-Bt5yqqvq.js +0 -6
  99. package/dist/web/assets/Desktop-CPDo3Ir-.js +0 -1
  100. package/dist/web/assets/DesktopReview-CCaqTSu5.js +0 -1
  101. package/dist/web/assets/Evidence-BAuIgj1h.js +0 -1
  102. package/dist/web/assets/Explore-BqzEPdP7.js +0 -2
  103. package/dist/web/assets/Features-DFuPCW9x.js +0 -1
  104. package/dist/web/assets/Flags-UBakvqIq.js +0 -2
  105. package/dist/web/assets/Flaky-DUzdfQW4.js +0 -1
  106. package/dist/web/assets/Impact-jLZqUzz9.js +0 -3
  107. package/dist/web/assets/Jobs-De3NyY5s.js +0 -5
  108. package/dist/web/assets/KindPage-DWznWcLB.js +0 -6
  109. package/dist/web/assets/Migration-BdOq6RO6.js +0 -2
  110. package/dist/web/assets/PageAgent-dVvZtNoB.js +0 -1
  111. package/dist/web/assets/Product-ByZ8Qr3i.js +0 -12
  112. package/dist/web/assets/Production-D8L2TchK.js +0 -1
  113. package/dist/web/assets/Quality-CSZEuhZo.js +0 -1
  114. package/dist/web/assets/Readiness-bBu_84mx.js +0 -1
  115. package/dist/web/assets/Record-DWJEDj2C.js +0 -1
  116. package/dist/web/assets/Regression-D2VkPIhZ.js +0 -5
  117. package/dist/web/assets/RelationGraph-q5H4bYjq.js +0 -1
  118. package/dist/web/assets/Reports-dF-O5HTI.js +0 -2
  119. package/dist/web/assets/Response-D4JW3pwi.js +0 -9
  120. package/dist/web/assets/Responsive-CLX9S27s.js +0 -3
  121. package/dist/web/assets/RunDiff-BuL_-GwF.js +0 -1
  122. package/dist/web/assets/Runs-DyyaAiyA.js +0 -2
  123. package/dist/web/assets/Settings-DnG6_QQj.js +0 -21
  124. package/dist/web/assets/Steps-C-0zwG7T.js +0 -2
  125. package/dist/web/assets/TestCases-DXk9qsEL.js +0 -1
  126. package/dist/web/assets/TestData-D4al7-3Z.js +0 -2
  127. package/dist/web/assets/TestDebt-BzOVDuS8.js +0 -1
  128. package/dist/web/assets/TestManagement-T-NIlhc9.js +0 -1
  129. package/dist/web/assets/Tosca-D7tqMGK0.js +0 -3
  130. package/dist/web/assets/WhatsNew-DBViE2Qt.js +0 -1
  131. package/dist/web/assets/dataParts-D56_9p6T.js +0 -3
  132. package/dist/web/assets/families-gkpkloLT.js +0 -1
  133. package/dist/web/assets/filters-Culzq1j1.js +0 -1
  134. package/dist/web/assets/fold-UP5ihvz-.js +0 -1
  135. package/dist/web/assets/head-BpR3dGRT.js +0 -1
  136. package/dist/web/assets/index-CljX5dI4.js +0 -64
  137. package/dist/web/assets/index-CwAqcn-z.css +0 -2
  138. package/dist/web/assets/input-D7iHeNXz.js +0 -1
  139. package/dist/web/assets/logos-B4e5nBuL.js +0 -1
  140. package/dist/web/assets/palette-lUno7fso.js +0 -1
  141. package/dist/web/assets/parts-DbdUgAZS.js +0 -1
  142. package/dist/web/assets/productParts-DSrnTFn8.js +0 -1
  143. package/dist/web/assets/qualityParts-D_U5zhKC.js +0 -1
  144. package/dist/web/assets/recordTest-D9zuJ-aG.js +0 -1
  145. package/dist/web/assets/route-Dg53WdFu.js +0 -1
@@ -0,0 +1,186 @@
1
+ """
2
+ Which Copilot model answers a request, worked out by the gateway (copilot_gateway.py) so nobody has to pick again when
3
+ a model stops working on their seat.
4
+
5
+ Seen on 2026-11-23: a seat's models answered for weeks, then one stopped answering the browser engine's requests (a 502
6
+ after minutes, every step), with nothing changed on the computer. So the gateway keeps each model's health, sends a
7
+ failing model's requests to a healthy one of the seat for a while, and remembers that across ForgeQE's processes.
8
+
9
+ - `auto` is Copilot's own routing: a request without pictures goes to it as it is; a request with a screenshot goes to
10
+ the seat's best healthy model that takes pictures, as Copilot's routing does not promise one.
11
+ - A model fails when Copilot does not answer within the gateway's time, or answers with an error that is about the
12
+ model (not the sign-in, a rate limit, the caller's tools or the request's size). It is then avoided for
13
+ `COOLDOWN_S`, and its requests go to a stand-in: one that takes pictures when the request has one, enabled by the
14
+ seat's policy, never costlier than the failing one allows (`affordable`), cheapest first.
15
+ - What is kept on disk (`health_file`) is read back as untrusted: model ids of their shape, times within the cooldown.
16
+ """
17
+ from __future__ import annotations
18
+
19
+ import json
20
+ import os
21
+ import re
22
+ import tempfile
23
+ import time
24
+ from typing import Any, Dict, List, Optional, Tuple
25
+
26
+ AUTO = "auto"
27
+ # How long a model that failed is avoided before it is tried again.
28
+ COOLDOWN_S = 60 * 60
29
+ # A Copilot model id as the SDK lists it.
30
+ MODEL_ID = re.compile(r"^[A-Za-z0-9][\w.:-]{0,127}$")
31
+ MAX_KEPT = 64
32
+
33
+ # Errors about the sign-in, a limit, the caller's tools or the request itself: another model would fail the same way.
34
+ _NOT_THE_MODEL = re.compile(
35
+ r"authori[sz]ation|credentials|unauthori[sz]ed|not authenticated|oauth token|\b401\b|\b403\b"
36
+ r"|rate.?limit|too many requests|quota|premium request|allowance|exceeded your|usage limit|\b429\b"
37
+ r"|conflicts with a built-in tool|tool names?|context|too long|token limit|max_prompt_tokens|request (?:body )?too large"
38
+ r"|\b400\b|\b413\b|bad request|invalid request",
39
+ re.I,
40
+ )
41
+
42
+
43
+ # GitHub no longer taking this version of its SDK or runtime: another model would be refused the same way, and only a
44
+ # newer ForgeQE (with newer pins) helps.
45
+ _OUTDATED = re.compile(
46
+ r"upgrade required|\b426\b|(?:client|cli|sdk|runtime|version)[^.\n]{0,40}(?:too old|outdated|no longer supported|not supported any ?more|deprecated)"
47
+ r"|unsupported (?:client|cli|sdk|runtime|protocol)(?: version)?|(?:please|you must|need to) (?:update|upgrade) (?:your |the )?(?:copilot|client|cli|sdk)"
48
+ r"|minimum (?:supported )?(?:client |cli |sdk |protocol )?version|protocol version mismatch",
49
+ re.I,
50
+ )
51
+
52
+
53
+ def client_outdated(message: str) -> bool:
54
+ """Whether Copilot's error says this version of its SDK or runtime is too old for GitHub's service."""
55
+ return bool(_OUTDATED.search(message or ""))
56
+
57
+
58
+ def model_failed(status: Optional[int], message: str) -> bool:
59
+ """Whether a failed request says the model itself is not working: a time-out, or a model error of Copilot's."""
60
+ if status == 504:
61
+ return True
62
+ if status != 502:
63
+ return False
64
+ return not _NOT_THE_MODEL.search(message or "") and not client_outdated(message)
65
+
66
+
67
+ def health_file() -> str:
68
+ home = os.environ.get("FORGEQE_HOME") or os.path.join(os.path.expanduser("~"), ".forgeqe")
69
+ return os.path.join(home, "copilot", "model-health.json")
70
+
71
+
72
+ def read_health(path: str, now: Optional[float] = None) -> Dict[str, float]:
73
+ """{model: until}, only entries of a model id's shape still within the cooldown; {} for anything unreadable."""
74
+ now = time.time() if now is None else now
75
+ try:
76
+ if os.path.islink(path):
77
+ return {}
78
+ with open(path, "r", encoding="utf-8") as f:
79
+ raw = json.load(f)
80
+ except (OSError, ValueError):
81
+ return {}
82
+ failing = raw.get("failing") if isinstance(raw, dict) else None
83
+ if not isinstance(failing, dict):
84
+ return {}
85
+ out: Dict[str, float] = {}
86
+ for model, until in list(failing.items())[:MAX_KEPT]:
87
+ if isinstance(model, str) and MODEL_ID.match(model) and isinstance(until, (int, float)) and now < until <= now + COOLDOWN_S:
88
+ out[model] = float(until)
89
+ return out
90
+
91
+
92
+ def write_health(path: str, failing: Dict[str, float]) -> None:
93
+ """Written through a new file at 0600, never through a link; a failure to write is not the request's problem."""
94
+ try:
95
+ folder = os.path.dirname(path)
96
+ os.makedirs(folder, exist_ok=True)
97
+ if os.path.islink(path):
98
+ return
99
+ fd, tmp = tempfile.mkstemp(prefix=".model-health-", dir=folder)
100
+ try:
101
+ with os.fdopen(fd, "w", encoding="utf-8") as f:
102
+ json.dump({"failing": dict(list(failing.items())[:MAX_KEPT])}, f)
103
+ os.chmod(tmp, 0o600)
104
+ os.replace(tmp, path)
105
+ except Exception:
106
+ try:
107
+ os.unlink(tmp)
108
+ except OSError:
109
+ pass
110
+ except OSError:
111
+ pass
112
+
113
+
114
+ def _cost(m: Dict[str, Any]) -> float:
115
+ v = m.get("multiplier")
116
+ return float(v) if isinstance(v, (int, float)) and v >= 0 else 1.0
117
+
118
+
119
+ def affordable(candidate: Dict[str, Any], failing: Optional[Dict[str, Any]]) -> bool:
120
+ """A stand-in never costs more premium requests per call than the failing model, or than 1 when that was cheaper."""
121
+ limit = max(1.0, _cost(failing)) if failing else 1.0
122
+ return _cost(candidate) <= limit
123
+
124
+
125
+ class ModelHealth:
126
+ """The seat's failing models, shared by every request of this gateway and kept on disk for the next ForgeQE."""
127
+
128
+ def __init__(self, path: Optional[str] = None, now: Any = time.time) -> None:
129
+ self.path = path or health_file()
130
+ self.now = now
131
+ self.failing = read_health(self.path, now())
132
+
133
+ def healthy(self, model: str) -> bool:
134
+ until = self.failing.get(model)
135
+ if until is None:
136
+ return True
137
+ if until <= self.now():
138
+ self.failing.pop(model, None)
139
+ return True
140
+ return False
141
+
142
+ def fail(self, model: str) -> None:
143
+ if not MODEL_ID.match(model or ""):
144
+ return
145
+ self.failing[model] = self.now() + COOLDOWN_S
146
+ write_health(self.path, self.failing)
147
+
148
+ def recovered(self, model: str) -> None:
149
+ if self.failing.pop(model, None) is not None:
150
+ write_health(self.path, self.failing)
151
+
152
+
153
+ def usable(seat: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
154
+ """The seat's models the policy allows, real ones only (not `auto`), in the seat's order."""
155
+ return [m for m in seat if isinstance(m.get("id"), str) and MODEL_ID.match(m["id"]) and m["id"] != AUTO and (m.get("policy") or "enabled") == "enabled"]
156
+
157
+
158
+ def stand_in(seat: List[Dict[str, Any]], health: ModelHealth, failing: str, needs_vision: bool, auto_ok: bool) -> Optional[str]:
159
+ """
160
+ The model to answer instead of `failing`: Copilot's `auto` for a request without pictures (when the seat takes it
161
+ and it is healthy), else the cheapest healthy model that takes pictures when needed and is `affordable`.
162
+ """
163
+ if not needs_vision and auto_ok and failing != AUTO and health.healthy(AUTO):
164
+ return AUTO
165
+ listed = usable(seat)
166
+ was = next((m for m in listed if m["id"] == failing), None)
167
+ order = [(i, m) for i, m in enumerate(listed) if m["id"] != failing and health.healthy(m["id"]) and (m.get("vision") or not needs_vision)]
168
+ order = [(i, m) for i, m in order if affordable(m, was)]
169
+ order.sort(key=lambda im: (_cost(im[1]), im[0]))
170
+ return order[0][1]["id"] if order else None
171
+
172
+
173
+ def route(requested: str, seat: List[Dict[str, Any]], health: ModelHealth, needs_vision: bool, auto_ok: bool) -> Tuple[str, Optional[str]]:
174
+ """
175
+ The model a request goes to, and why when it is not the one asked for. `auto` with a picture goes to the seat's
176
+ best healthy model that takes pictures; a failing model's request goes to its stand-in, if there is one.
177
+ """
178
+ if requested == AUTO and needs_vision:
179
+ pick = stand_in(seat, health, AUTO, True, False)
180
+ return (pick, None) if pick else (AUTO, None)
181
+ if health.healthy(requested):
182
+ return requested, None
183
+ pick = stand_in(seat, health, requested, needs_vision, auto_ok)
184
+ if not pick:
185
+ return requested, None
186
+ return pick, f"{requested} failed recently on this seat, so {pick} answers for it"
@@ -203,6 +203,74 @@ AXE_RUN = r"""axe.run(document, {runOnly: {type: 'tag', values: %s}, resultTypes
203
203
  examples: v.nodes.slice(0, 5).map((n) => ({html: (n.html || '').slice(0, 160), target: (n.target || []).join(' '), text: (n.failureSummary || '').slice(0, 300)}))}))
204
204
  }))"""
205
205
 
206
+ # IBM Equal Access (accessibility-checker-engine's ace.js): the engine's source is evaluated inside a function, so its
207
+ # top-level `var ace` stays local: nothing is put on the page's window (a page's own `window.ace`, such as the Ace code
208
+ # editor, is left alone) and the page cannot hand ForgeQE a checker of its own. The rules kept are the ruleset's at the
209
+ # levels asked for (recommendations only when asked); results are made plain here, each rule with up to five elements.
210
+ IBM_RUN = r"""(async ({ruleset, levels, recommendations}) => {
211
+ const ace = (function () {
212
+ /*IBM_ENGINE_SOURCE*/
213
+ ;return ace })();
214
+ const checker = new ace.Checker();
215
+ const guide = checker.getGuidelines().find((g) => g.id === ruleset);
216
+ if (!guide) return {error: 'no ruleset ' + ruleset};
217
+ const rules = {};
218
+ for (const cp of guide.checkpoints || []) {
219
+ const sc = /^\d+\.\d+\.\d+$/.test(cp.num || '');
220
+ if (sc ? !levels.includes(cp.wcagLevel) : !recommendations) continue;
221
+ for (const r of cp.rules || []) {
222
+ if (r.level !== 'VIOLATION' && !(recommendations && r.level === 'RECOMMENDATION')) continue;
223
+ const x = rules[r.id] || (rules[r.id] = {criteria: [], level: '', policy: r.level, toolkit: String(r.toolkitLevel || '')});
224
+ if (r.level === 'VIOLATION') x.policy = 'VIOLATION';
225
+ if (sc && !x.criteria.includes(cp.num)) x.criteria.push(cp.num);
226
+ if (sc && (!x.level || cp.wcagLevel.length < x.level.length)) x.level = cp.wcagLevel;
227
+ }
228
+ }
229
+ const report = await checker.check(document, [ruleset]);
230
+ const by = {};
231
+ for (const r of report.results || []) {
232
+ if (!rules[r.ruleId] || !Array.isArray(r.value) || r.value[0] === 'INFORMATION') continue;
233
+ const e = by[r.ruleId] || (by[r.ruleId] = {fail: [], open: 0, pass: 0});
234
+ if (r.value[1] === 'PASS') e.pass++;
235
+ else if (r.value[1] === 'FAIL') e.fail.push(r);
236
+ else if (r.value[1] === 'POTENTIAL' || r.value[1] === 'MANUAL') e.open++;
237
+ }
238
+ const ids = Object.keys(by);
239
+ return {
240
+ passed: ids.filter((id) => by[id].pass && !by[id].fail.length),
241
+ incomplete: ids.filter((id) => by[id].open && !by[id].fail.length),
242
+ violations: ids.filter((id) => by[id].fail.length).map((id) => ({id, policy: rules[id].policy, toolkit: rules[id].toolkit,
243
+ criteria: rules[id].criteria, level: rules[id].level, count: by[id].fail.length, help: String(by[id].fail[0].message || '').slice(0, 300),
244
+ examples: by[id].fail.slice(0, 5).map((n) => ({html: String(n.snippet || '').slice(0, 160), target: String((n.path || {}).dom || ''), text: String(n.message || '').slice(0, 300)}))}))
245
+ };
246
+ })(%s)"""
247
+
248
+ IBM_RULESETS = ("WCAG_2_0", "WCAG_2_1", "WCAG_2_2", "IBM_Accessibility")
249
+ IBM_HELP = "https://able.ibm.com/rules/archives/latest/doc/en-US/{}.html"
250
+ IBM_RULE = re.compile(r"^[A-Za-z0-9_]{1,80}$")
251
+ IBM_SC = re.compile(r"^\d\.\d{1,2}\.\d{1,2}$")
252
+ # A violation's impact from IBM's toolkit level (1: the most essential); a recommendation is minor.
253
+ IBM_IMPACT = {"1": "critical", "2": "serious", "3": "moderate", "4": "minor"}
254
+
255
+
256
+ def ibm_issue(v: Dict[str, Any]) -> Optional[Dict[str, Any]]:
257
+ """One IBM rule's failures in accessibility.json's shape (as axe's), read as data; None for one not of its shape."""
258
+ rule = str(v.get("id") or "")
259
+ if not IBM_RULE.fullmatch(rule):
260
+ return None
261
+ criteria = [c for c in (v.get("criteria") or []) if isinstance(c, str) and IBM_SC.fullmatch(c)][:6]
262
+ level = str(v.get("level") or "")
263
+ impact = "minor" if v.get("policy") != "VIOLATION" else IBM_IMPACT.get(str(v.get("toolkit") or ""), "moderate")
264
+ examples = [
265
+ {"html": str(e.get("html") or "")[:160], "target": str(e.get("target") or "")[:300], "text": str(e.get("text") or "")[:300]}
266
+ for e in (v.get("examples") or [])[:5]
267
+ if isinstance(e, dict)
268
+ ]
269
+ return {"rule": rule, "wcag": ", ".join(criteria), "level": level if level in ("A", "AA", "AAA") else "", "impact": impact,
270
+ "help": " ".join(str(v.get("help") or "").split())[:300], "helpUrl": IBM_HELP.format(rule),
271
+ "count": max(0, int(v.get("count") or 0)), "examples": examples}
272
+
273
+
206
274
  WCAG_SC = re.compile(r"^wcag(\d)(\d)(\d{1,2})$")
207
275
  WCAG_LEVEL = re.compile(r"^wcag2\d?(a{1,3})$")
208
276
 
@@ -277,7 +345,7 @@ def box_for(browser_state: Any, index: Any) -> Optional[Dict[str, float]]:
277
345
 
278
346
 
279
347
  class Diagnostics:
280
- def __init__(self, *, accessibility: bool = True, network: bool = True, axe: Optional[Dict[str, Any]] = None, vitals: bool = True, visual: Optional[Dict[str, Any]] = None, keep_headers: Optional[List[str]] = None) -> None:
348
+ def __init__(self, *, accessibility: bool = True, network: bool = True, axe: Optional[Dict[str, Any]] = None, vitals: bool = True, visual: Optional[Dict[str, Any]] = None, keep_headers: Optional[List[str]] = None, ibm: Optional[Dict[str, Any]] = None) -> None:
281
349
  self.accessibility = accessibility
282
350
  # axe-core: {"script": path to axe.min.js, "tags": ["wcag2a", "wcag2aa"]}; without it, the built-in checks.
283
351
  self.axe_tags: List[str] = [str(t) for t in ((axe or {}).get("tags") or ["wcag2a", "wcag2aa"])]
@@ -287,12 +355,27 @@ class Diagnostics:
287
355
  self._axe_source = Path(str(axe["script"])).read_text(encoding="utf-8")
288
356
  except OSError:
289
357
  logger.warning("axe-core not found at %s: using the built-in accessibility checks", axe.get("script"))
358
+ # IBM Equal Access: {"script": path to ace.js, "ruleset": "WCAG_2_1", "levels": ["A", "AA"], "recommendations":
359
+ # bool, "version": "4.0.34"}; it takes the place of axe-core when given and found.
360
+ self._ibm_source: Optional[str] = None
361
+ self.ibm: Dict[str, Any] = {}
362
+ if ibm and ibm.get("script"):
363
+ try:
364
+ self._ibm_source = Path(str(ibm["script"])).read_text(encoding="utf-8")
365
+ self.ibm = {
366
+ "ruleset": str(ibm.get("ruleset") or "WCAG_2_1") if str(ibm.get("ruleset") or "") in IBM_RULESETS else "WCAG_2_1",
367
+ "levels": [x for x in (ibm.get("levels") or ["A", "AA"]) if x in ("A", "AA")] or ["A", "AA"],
368
+ "recommendations": ibm.get("recommendations") is True,
369
+ "version": re.sub(r"[^0-9.]", "", str(ibm.get("version") or ""))[:20],
370
+ }
371
+ except OSError:
372
+ logger.warning("IBM Equal Access not found at %s: using %s", ibm.get("script"), "axe-core" if self._axe_source else "the built-in accessibility checks")
290
373
  self.vitals = vitals
291
374
  self.perf: Dict[str, Dict[str, Any]] = {}
292
375
  # {"mask": [selectors], "pages": {"/path": [selectors]}, "full_page": bool}; None: no visual captures.
293
376
  self.visual: Optional[Dict[str, Any]] = visual
294
377
  self.shots: Dict[str, Dict[str, Any]] = {}
295
- self.timeout = CHECK_TIMEOUT * (3 if self._axe_source else 1)
378
+ self.timeout = CHECK_TIMEOUT * (3 if self._axe_source or self._ibm_source else 1)
296
379
  self.network: Optional[NetworkCapture] = NetworkCapture(keep_headers) if network else None
297
380
  self._net_handlers: Dict[str, Any] = {}
298
381
  self.events: List[Dict[str, Any]] = []
@@ -589,6 +672,21 @@ class Diagnostics:
589
672
  logger.debug("axe-core did not run", exc_info=True)
590
673
  return None
591
674
 
675
+ async def _ibm(self, session: Any) -> Optional[Dict[str, Any]]:
676
+ """IBM Equal Access's results for the page, or None when it could not run (axe-core or the built-in checks run instead)."""
677
+ if not self._ibm_source:
678
+ return None
679
+ try:
680
+ # The arguments first, then the engine's source in its place: the source has % signs of its own.
681
+ args = {"ruleset": self.ibm["ruleset"], "levels": self.ibm["levels"], "recommendations": self.ibm["recommendations"]}
682
+ expr = (IBM_RUN % json.dumps(args)).replace("/*IBM_ENGINE_SOURCE*/", self._ibm_source, 1)
683
+ r = await session.cdp_client.send.Runtime.evaluate(params={"expression": expr, "returnByValue": True, "awaitPromise": True}, session_id=session.session_id)
684
+ value = ((r or {}).get("result") or {}).get("value")
685
+ return value if isinstance(value, dict) and isinstance(value.get("violations"), list) else None
686
+ except Exception:
687
+ logger.debug("IBM Equal Access did not run", exc_info=True)
688
+ return None
689
+
592
690
  async def _check_page(self, browser: Any, session: Any) -> None:
593
691
  try:
594
692
  url = str(await browser.get_current_page_url() or "")
@@ -599,6 +697,25 @@ class Diagnostics:
599
697
  return
600
698
  send = session.cdp_client.send
601
699
  order = {"critical": 0, "serious": 1, "moderate": 2, "minor": 3}
700
+ ibm = await self._ibm(session)
701
+ if ibm is not None:
702
+ title = ""
703
+ try:
704
+ title = str(await self._eval(session, "document.title") or "")
705
+ except Exception:
706
+ pass
707
+ found = [i for i in (ibm_issue(v) for v in ibm["violations"] if isinstance(v, dict)) if i]
708
+ plain = lambda xs: [x for x in (xs or []) if isinstance(x, str) and IBM_RULE.fullmatch(x)] # noqa: E731
709
+ self.pages[key] = {
710
+ "url": url,
711
+ "title": title,
712
+ "engine": f"IBM Equal Access {self.ibm['version']}".strip(),
713
+ "tags": [self.ibm["ruleset"], *self.ibm["levels"], *(["recommendations"] if self.ibm["recommendations"] else [])],
714
+ "passed": plain(ibm.get("passed")),
715
+ "incomplete": plain(ibm.get("incomplete")),
716
+ "issues": sorted(found, key=lambda i: (order.get(i["impact"], 9), -i["count"])),
717
+ }
718
+ return
602
719
  axe = await self._axe(session)
603
720
  if axe is not None:
604
721
  issues_list = []
@@ -97,6 +97,15 @@ def _bearer_client(token: Any):
97
97
  return httpx.AsyncClient(auth=_Bearer(), limits=httpx.Limits(max_connections=20, max_keepalive_connections=6))
98
98
 
99
99
 
100
+ # The key ForgeQE's Copilot gateway hands the engine (GATEWAY_KEY_ENV, src/copilot.ts): a profile naming it is the gateway.
101
+ COPILOT_GATEWAY_KEY_ENV = "FORGEQE_COPILOT_GATEWAY_KEY"
102
+
103
+
104
+ def copilot_gateway(cfg: Dict[str, Any]) -> bool:
105
+ """Whether this profile is ForgeQE's GitHub Copilot gateway (engineRoute in src/copilot.ts sets it so)."""
106
+ return str(cfg.get("api_key_env") or cfg.get("apiKeyEnv") or "").strip() == COPILOT_GATEWAY_KEY_ENV
107
+
108
+
100
109
  def _build_llm(llm_config: Optional[Dict[str, Any]]):
101
110
  """Construct a browser_use chat model from a ForgeQE llms.json profile."""
102
111
  cfg: Dict[str, Any] = dict(llm_config) if llm_config else {}
@@ -148,6 +157,10 @@ def _build_llm(llm_config: Optional[Dict[str, Any]]):
148
157
  kw["http_client"] = _bearer_client(entra_token_provider(cfg))
149
158
  return _adaptive(cfg, ChatOpenAI(**kw))
150
159
  kw["api_key"] = api_key or "local"
160
+ if copilot_gateway(cfg):
161
+ # The gateway has already retried (Copilot retries five times itself). A retry here sends the same
162
+ # minutes-long call again, and the step then ends on the call's time limit, hiding Copilot's reason.
163
+ kw["max_retries"] = 0
151
164
  else:
152
165
  if not api_key:
153
166
  raise ValueError("OpenAI needs an API key: set OPENAI_API_KEY or the profile's api_key_env.")
@@ -226,7 +239,72 @@ def call_usage(result: Any) -> Dict[str, int]:
226
239
  return out
227
240
 
228
241
 
229
- def _time_llm_calls(llm: Any, calls: List[Tuple[float, float]], on_call: Optional[Callable[[Dict[str, Any]], None]] = None) -> None:
242
+ class ModelFailures:
243
+ """
244
+ Model calls that failed in a row at the model's end: the provider refused or broke (an HTTP status of 401, 403,
245
+ 429 or 5xx) or did not answer within the time limit. A page action that fails is not one of them. At `limit` in a
246
+ row the run stops with the last reason, instead of the agent failing step after step for its whole failure budget
247
+ (seen on 2026-11-23: six steps of four minutes each, every one a 502 from Copilot). A call that answers resets it.
248
+ """
249
+
250
+ def __init__(self, limit: int = 2, copilot: bool = False, timeout_s: Optional[float] = None) -> None:
251
+ self.limit = max(1, limit)
252
+ self.copilot = copilot
253
+ # The library's time limit for one call: it cancels the call when it runs out, so a cancelled call that ran
254
+ # this long went unanswered. A shorter cancelled call is a stop, and not counted.
255
+ self.timeout_s = timeout_s
256
+ self.count = 0
257
+ self.reason = ""
258
+
259
+ def answered(self) -> None:
260
+ self.count = 0
261
+ self.reason = ""
262
+
263
+ def failed(self, error: BaseException, elapsed_s: float = 0.0) -> None:
264
+ import asyncio
265
+
266
+ if isinstance(error, asyncio.CancelledError):
267
+ reason = "no answer within the time limit" if self.timeout_s and elapsed_s >= self.timeout_s * 0.95 else None
268
+ else:
269
+ reason = model_failure(error)
270
+ if reason is None:
271
+ return
272
+ self.count += 1
273
+ self.reason = reason
274
+
275
+ @property
276
+ def stuck(self) -> bool:
277
+ return self.count >= self.limit
278
+
279
+ def message(self) -> str:
280
+ where = (
281
+ " GitHub Copilot did not give an answer: check GitHub's status page, your network or proxy, or try another"
282
+ " model; ~/.forgeqe/logs/copilot-gateway.log says what Copilot answered."
283
+ if self.copilot
284
+ else " Check the model's provider, your network or proxy, or try another model."
285
+ )
286
+ return f"The model failed {self.count} calls in a row, so the run stopped: {self.reason}.{where}"
287
+
288
+
289
+ def model_failure(error: BaseException) -> Optional[str]:
290
+ """Why a model call failed at the model's end, one line and clipped; None when it was not the model (or a stop)."""
291
+ import asyncio
292
+
293
+ if isinstance(error, (asyncio.TimeoutError, TimeoutError)):
294
+ return "no answer within the time limit"
295
+ status = getattr(error, "status_code", None)
296
+ if not isinstance(status, int) or not (status in (401, 403, 429) or 500 <= status <= 599):
297
+ return None
298
+ text = " ".join(str(getattr(error, "message", "") or error).split())
299
+ return f"HTTP {status}: {text[:300]}" if text else f"HTTP {status}"
300
+
301
+
302
+ def _time_llm_calls(
303
+ llm: Any,
304
+ calls: List[Tuple[float, float]],
305
+ on_call: Optional[Callable[[Dict[str, Any]], None]] = None,
306
+ failures: Optional[ModelFailures] = None,
307
+ ) -> None:
230
308
  """
231
309
  Record when each model call started and ended, so the report can split step time into model and browser;
232
310
  on_call also gets each call's time and tokens (counts only, never the prompt), for ForgeQE's usage ledger.
@@ -242,7 +320,13 @@ def _time_llm_calls(llm: Any, calls: List[Tuple[float, float]], on_call: Optiona
242
320
  try:
243
321
  result = await inner(*args, **kwargs)
244
322
  ok = True
323
+ if failures is not None:
324
+ failures.answered()
245
325
  return result
326
+ except BaseException as e:
327
+ if failures is not None:
328
+ failures.failed(e, time.time() - started)
329
+ raise
246
330
  finally:
247
331
  ended = time.time()
248
332
  calls.append((started, ended))
@@ -88,7 +88,7 @@ This run is accessibility testing, not functional testing. You act as the person
88
88
  - You MUST set `wcag` to the WCAG success criterion the barrier fails, such as 1.1.1 or 2.4.7, when one applies.
89
89
  - You MUST set `severity`: critical when it stops the person from reaching the goal, serious when they get past it only with a lot of effort or help, moderate when it slows or confuses them, minor for an annoyance.
90
90
  - When a barrier stops you, you MUST NOT go around it in a way this person could not, such as a mouse click for a keyboard user. Record it, then try another way this person has, such as another link or the browser's back.
91
- - You MUST finish with done. Start the text with "Goal reached: yes", "Goal reached: partly", or "Goal reached: no", then say in a few sentences how it went for this person. Use success=true when you reached the goal and success=false when a barrier stopped you.
91
+ - You MUST finish with done. Start the text with "Goal reached: yes", "Goal reached: partly", or "Goal reached: no", then say in a few sentences how it went for this person. Use success=true when you reached the goal and success=false when a barrier stopped you. You MUST call done in a step of its own, with no other action: a done that follows another action in the same step, such as record_accessibility_issue, is not carried out. Record the last barrier, then call done in the next step.
92
92
  """.strip()
93
93
 
94
94
  SCREEN_READER_MESSAGE = """
@@ -381,7 +381,8 @@ def register_persona_tools(tools: Any, persona: Dict[str, Any], findings: List[D
381
381
  pass
382
382
  item = {"title": title, "what_happened": what, "expected": clip(expected, 400), "severity": sev, "wcag": criterion, "element": clip(element, 200), "url": url}
383
383
  if any(f["title"].lower() == title.lower() and f["url"] == url for f in findings):
384
- return ActionResult(extracted_content=f"Already recorded on this page: {title}")
384
+ # The same barrier again is often a done that the library dropped for sharing a step with this record.
385
+ return ActionResult(extracted_content=f"Already recorded on this page: {title}. Record another barrier, go on, or, when you are finished, call done alone in a step of its own.")
385
386
  findings.append(item)
386
387
  save_findings(out_dir, persona, findings)
387
388
  return ActionResult(extracted_content=f"Recorded barrier ({sev}{f', WCAG {criterion}' if criterion else ''}): {title}")
@@ -47,6 +47,8 @@ from .urls import (
47
47
  from .llm import (
48
48
  _build_llm,
49
49
  _time_llm_calls,
50
+ ModelFailures,
51
+ copilot_gateway,
50
52
  _usage_from_history,
51
53
  _agent_usage,
52
54
  )
@@ -148,6 +150,8 @@ class RunRequest:
148
150
  keep_headers: List[str] = field(default_factory=list)
149
151
  # axe-core for the accessibility checks: {"script": path to axe.min.js, "tags": [...]}; empty: the built-in checks.
150
152
  axe: Dict[str, Any] = field(default_factory=dict)
153
+ # IBM Equal Access instead of axe-core: {"script": path to ace.js, "ruleset", "levels", "recommendations", "version"}.
154
+ ibm: Dict[str, Any] = field(default_factory=dict)
151
155
  # Core Web Vitals and load timings of each page (performance.json).
152
156
  vitals: bool = True
153
157
  # Screenshots of each page for visual comparison: {"mask": [...], "pages": {...}, "full_page": bool}; None: off.
@@ -187,6 +191,7 @@ class RunRequest:
187
191
  keep_headers=[str(h) for h in (d.get("keep_headers") or [])[:20] if isinstance(h, str)] if isinstance(d.get("keep_headers"), list) else [],
188
192
  prompts={str(k): str(v) for k, v in (d.get("prompts") or {}).items()} if isinstance(d.get("prompts"), dict) else {},
189
193
  axe=dict(d["axe"]) if isinstance(d.get("axe"), dict) else {},
194
+ ibm=dict(d["ibm"]) if isinstance(d.get("ibm"), dict) else {},
190
195
  vitals=d.get("vitals") is not False,
191
196
  visual=dict(d["visual"]) if isinstance(d.get("visual"), dict) else None,
192
197
  goal=str(d.get("goal") or ""),
@@ -1106,9 +1111,13 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1106
1111
  _llm_cfg = req.llm if isinstance(req.llm, dict) else {}
1107
1112
  model_label = str(_llm_cfg.get("deployment") or _llm_cfg.get("model") or "the model")
1108
1113
  llm_calls: List[Tuple[float, float]] = []
1109
- _time_llm_calls(llm, llm_calls, lambda c: emit({"type": "call", **c}))
1114
+ # Calls that fail at the model's end, in a row: at two the run stops with the reason (see _should_stop_callback).
1115
+ model_failures = ModelFailures(
1116
+ limit=2, copilot=copilot_gateway(_llm_cfg), timeout_s=_browser_use_agent_tuning_kwargs().get("llm_timeout")
1117
+ )
1118
+ _time_llm_calls(llm, llm_calls, lambda c: emit({"type": "call", **c}), failures=model_failures)
1110
1119
  use_prompts(req.prompts)
1111
- diag = Diagnostics(accessibility=req.accessibility, network=req.network, axe=req.axe or None, vitals=req.vitals, visual=req.visual, keep_headers=req.keep_headers)
1120
+ diag = Diagnostics(accessibility=req.accessibility, network=req.network, axe=req.axe or None, ibm=req.ibm or None, vitals=req.vitals, visual=req.visual, keep_headers=req.keep_headers)
1112
1121
 
1113
1122
  browser_cfg = req.browser if isinstance(req.browser, dict) else {}
1114
1123
  browser_provider = str(browser_cfg.get("provider") or "local")
@@ -1513,6 +1522,11 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1513
1522
  async def _should_stop_callback() -> bool:
1514
1523
  if cancel_event.is_set():
1515
1524
  return True
1525
+ if model_failures.stuck:
1526
+ loop_break_state.setdefault("model", model_failures.message())
1527
+ emit({"type": "log", "level": "error", "text": loop_break_state["model"]})
1528
+ cancel_event.set()
1529
+ return True
1516
1530
  return _evaluate_control_loop()
1517
1531
 
1518
1532
  agent_kw["register_should_stop_callback"] = _should_stop_callback
@@ -1792,17 +1806,20 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1792
1806
  with contextlib.suppress(asyncio.CancelledError, Exception):
1793
1807
  await run_task
1794
1808
  triggered = bool(loop_break_state.get("triggered"))
1795
- err = loop_break_state.get("message") if triggered else "Browser task stopped by user"
1809
+ model_down = str(loop_break_state.get("model") or "")
1810
+ err = model_down or (loop_break_state.get("message") if triggered else "Browser task stopped by user")
1796
1811
  out = {
1797
1812
  "success": False,
1798
1813
  "error": err,
1799
1814
  "summary": err,
1800
1815
  "step_events": collected_steps,
1801
- "cancelled": not triggered,
1816
+ "cancelled": not (triggered or model_down),
1802
1817
  "loop_breaker": triggered,
1803
1818
  "usage": await _agent_usage(agent),
1804
1819
  }
1805
- if triggered:
1820
+ if model_down:
1821
+ out["model_unavailable"] = True
1822
+ if triggered or model_down:
1806
1823
  _plan_resume(str(err))
1807
1824
  _save(out, "cancelled")
1808
1825
  return out
@@ -1815,15 +1832,17 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1815
1832
  history = run_task.result()
1816
1833
  except Exception as e:
1817
1834
  triggered = bool(loop_break_state.get("triggered"))
1835
+ model_down = str(loop_break_state.get("model") or "")
1818
1836
  if cancel_event.is_set():
1819
- err = loop_break_state.get("message") if triggered else "Browser task stopped by user"
1837
+ err = model_down or (loop_break_state.get("message") if triggered else "Browser task stopped by user")
1820
1838
  out = {
1821
1839
  "success": False,
1822
1840
  "error": err,
1823
1841
  "summary": err,
1824
1842
  "step_events": collected_steps,
1825
- "cancelled": not triggered,
1843
+ "cancelled": not (triggered or model_down),
1826
1844
  "loop_breaker": triggered,
1845
+ **({"model_unavailable": True} if model_down else {}),
1827
1846
  }
1828
1847
  else:
1829
1848
  logger.exception("engine library Agent.run failed")
@@ -1841,7 +1860,7 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1841
1860
  if success_flag is None:
1842
1861
  success_flag = not history.has_errors() and bool(primary)
1843
1862
  ok = bool(success_flag)
1844
- if loop_break_state.get("triggered"):
1863
+ if loop_break_state.get("triggered") or loop_break_state.get("model"):
1845
1864
  ok = False
1846
1865
  # Stopped at a limit (no progress, or a person chose not to carry on): the goal was not reached.
1847
1866
  if budget_state.get("message"):
@@ -1857,7 +1876,9 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1857
1876
  ok = False
1858
1877
  errs_list = [e for e in history.errors() if e]
1859
1878
  if not ok:
1860
- if loop_break_state.get("triggered"):
1879
+ if loop_break_state.get("model"):
1880
+ summary = str(loop_break_state["model"])
1881
+ elif loop_break_state.get("triggered"):
1861
1882
  summary = str(loop_break_state.get("message") or "Stopped after repeated search/select attempts.")
1862
1883
  elif budget_state.get("message"):
1863
1884
  summary = str(budget_state["message"]) + (f"\n\n{primary}" if primary else "")
@@ -1912,7 +1933,12 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
1912
1933
  failed_checks = [c for c in recorded_checks if c.get("holds") is False]
1913
1934
  # The steps were done and an expected result did not hold: the test failed, the run did not.
1914
1935
  assertion_failed = contradicted or (
1915
- not ok and bool(failed_checks) and not loop_break_state.get("triggered") and not budget_state.get("message") and not judge_rejected
1936
+ not ok
1937
+ and bool(failed_checks)
1938
+ and not loop_break_state.get("triggered")
1939
+ and not loop_break_state.get("model")
1940
+ and not budget_state.get("message")
1941
+ and not judge_rejected
1916
1942
  )
1917
1943
  out["outcome"] = "passed" if ok else "assertion_failed" if assertion_failed else "error"
1918
1944
  if recorded_checks and (ok or assertion_failed):