@buaa_smat/hometrans 26.0.4 → 26.0.5

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 (102) hide show
  1. package/agents/code-reviewer.md +2 -0
  2. package/agents/model-render-worker.md +1 -1
  3. package/i18n/agents/code-reviewer.md +2 -0
  4. package/i18n/agents/model-render-worker.md +1 -1
  5. package/i18n/skills/a2h-app-migrate/SKILL.md +51 -3
  6. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +140 -32
  7. package/i18n/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
  8. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
  9. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
  10. package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +3 -3
  11. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
  12. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
  13. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
  14. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
  15. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
  16. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
  17. package/i18n/skills/a2h-batch-ui-align/SKILL.md +1 -1
  18. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
  19. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
  20. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
  21. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
  22. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
  23. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
  24. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
  25. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
  26. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
  27. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
  28. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
  29. package/i18n/skills/a2h-page-specgen/references/spec-example.md +35 -5
  30. package/i18n/skills/a2h-page-specgen/references/spec-template.md +4 -4
  31. package/i18n/skills/a2h-spec-generate/SKILL.md +3 -1
  32. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
  33. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  34. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
  35. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
  36. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +5 -1
  37. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
  38. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +25 -2
  39. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +121 -6
  40. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +2 -1
  41. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
  42. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
  43. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +11 -2
  44. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +35 -0
  45. package/package.json +1 -1
  46. package/skills/a2h-app-migrate/SKILL.md +53 -5
  47. package/skills/a2h-app-migrate/references/workflow.yaml +140 -32
  48. package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +226 -0
  49. package/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
  50. package/skills/a2h-app-migrate/scripts/dag_process_executor.mjs +199 -0
  51. package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +897 -0
  52. package/skills/a2h-app-migrate/scripts/dag_runner.mjs +1767 -0
  53. package/skills/a2h-app-migrate/scripts/ledger.mjs +15 -2
  54. package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +8 -2
  55. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -8
  56. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
  57. package/skills/a2h-app-migrate/test/test_dag_complete.mjs +222 -0
  58. package/skills/a2h-app-migrate/test/test_dag_production.mjs +670 -0
  59. package/skills/a2h-app-migrate/test/test_dag_runner.mjs +423 -0
  60. package/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
  61. package/skills/a2h-app-migrate/test/test_image_probe.mjs +1 -1
  62. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +16 -1
  63. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
  64. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
  65. package/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
  66. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
  67. package/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
  68. package/skills/a2h-batch-ui-align/SKILL.md +1 -1
  69. package/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
  70. package/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
  71. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
  72. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
  73. package/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
  74. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +49 -3
  75. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +36 -0
  76. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
  77. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +8 -0
  78. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
  79. package/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
  80. package/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
  81. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
  82. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_ds1123.test.mjs +433 -0
  83. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_in_linear.test.mjs +288 -0
  84. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +46 -0
  85. package/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
  86. package/skills/a2h-page-specgen/references/spec-example.md +35 -5
  87. package/skills/a2h-page-specgen/references/spec-template.md +4 -4
  88. package/skills/a2h-spec-generate/SKILL.md +3 -1
  89. package/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
  90. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  91. package/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
  92. package/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
  93. package/skills/a2h-spec-generate/references/spec-samples.md +5 -1
  94. package/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
  95. package/skills/a2h-spec-generate/references/worker-rules.md +25 -2
  96. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +3 -1
  97. package/skills/a2h-spec-generate/scripts/check_spec.ts +262 -6
  98. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +12 -2
  99. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
  100. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
  101. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +54 -3
  102. package/skills/a2h-spec-generate/test/check-spec.test.ts +247 -0
@@ -0,0 +1,297 @@
1
+ const TERMINAL_STATUSES = new Set(["done", "reused", "skipped", "failed"]);
2
+
3
+ /** Nodes cut by the profile: lane not in include_lanes, or named by force_skip (node id or lane id). */
4
+ export function profileSkipped(doc, profile) {
5
+ const conf = doc.profiles?.[profile] || {};
6
+ const lanes = conf.include_lanes === "all" || !conf.include_lanes ? null : new Set(conf.include_lanes);
7
+ const force = new Set(conf.force_skip || []);
8
+ return new Set((doc.nodes || []).filter((n) => (lanes && !lanes.has(n.lane)) || force.has(n.id) || force.has(n.lane)).map((n) => n.id));
9
+ }
10
+
11
+ function graphParts(doc) {
12
+ const nodes = doc.nodes || [];
13
+ const byId = new Map(nodes.map((node) => [node.id, node]));
14
+ const byGroup = {};
15
+ for (const node of nodes) {
16
+ if (node.parallel_group) (byGroup[node.parallel_group] ||= []).push(node.id);
17
+ }
18
+ const parents = {};
19
+ const children = {};
20
+ for (const node of nodes) {
21
+ const ids = new Set(node.needs || []);
22
+ for (const conditional of node.conditional_needs || []) {
23
+ for (const id of conditional.add || []) ids.add(id);
24
+ }
25
+ if (node.also_needs_group) {
26
+ for (const id of byGroup[node.also_needs_group] || []) {
27
+ if (id !== node.id) ids.add(id);
28
+ }
29
+ }
30
+ parents[node.id] = ids;
31
+ children[node.id] ||= new Set();
32
+ }
33
+ for (const [child, ids] of Object.entries(parents)) {
34
+ for (const parent of ids) (children[parent] ||= new Set()).add(child);
35
+ }
36
+ return { nodes, byId, byGroup, parents, children };
37
+ }
38
+
39
+ export function validateGraph(doc) {
40
+ const { nodes, byId, byGroup, parents } = graphParts(doc);
41
+ const ids = nodes.map((node) => node.id);
42
+ const errors = [];
43
+ const duplicates = new Set(ids.filter((id, index) => ids.indexOf(id) !== index));
44
+ if (duplicates.size) errors.push(`duplicate node ids: ${[...duplicates].sort()}`);
45
+
46
+ for (const node of nodes) {
47
+ for (const parent of node.needs || []) {
48
+ if (!byId.has(parent)) errors.push(`${node.id}: needs points to a missing node \`${parent}\``);
49
+ }
50
+ for (const conditional of node.conditional_needs || []) {
51
+ for (const parent of conditional.add || []) {
52
+ if (!byId.has(parent)) errors.push(`${node.id}: conditional_needs.add points to a missing node \`${parent}\``);
53
+ }
54
+ }
55
+ if (node.also_needs_group && !byGroup[node.also_needs_group]) {
56
+ errors.push(`${node.id}: also_needs_group points to a missing group \`${node.also_needs_group}\``);
57
+ }
58
+ }
59
+
60
+ const seen = new Set();
61
+ let todo = [...new Set(ids)];
62
+ while (todo.length) {
63
+ const ready = todo.filter((id) => [...(parents[id] || [])].every((parent) => !byId.has(parent) || seen.has(parent)));
64
+ if (!ready.length) {
65
+ errors.push(`the DAG has a cycle involving: ${todo.join(",")}`);
66
+ break;
67
+ }
68
+ for (const id of ready) seen.add(id);
69
+ todo = todo.filter((id) => !seen.has(id));
70
+ }
71
+ return errors;
72
+ }
73
+
74
+ export function buildGraph(doc, options = {}) {
75
+ const profile = typeof options === "string" ? options : options.profile || "";
76
+ const errors = validateGraph(doc);
77
+ if (errors.length) {
78
+ const error = new Error(errors.join("\n"));
79
+ error.code = "DAG_GRAPH_INVALID";
80
+ error.errors = errors;
81
+ throw error;
82
+ }
83
+ const { nodes, byId, parents, children } = graphParts(doc);
84
+ const skippedByProfile = profileSkipped(doc, profile);
85
+ const serialRank = new Map((doc.serial_order || []).map((id, index) => [id, index]));
86
+ return {
87
+ nodes,
88
+ byId,
89
+ parents,
90
+ children,
91
+ serialRank,
92
+ activeIds: new Set(nodes.filter((node) => !skippedByProfile.has(node.id)).map((node) => node.id)),
93
+ skippedByProfile,
94
+ };
95
+ }
96
+
97
+ /**
98
+ * Nodes a gate rewind to `targetId` must reset: the target plus everything that consumes its output,
99
+ * transitively. Only data edges count (needs, also_needs_group). conditional_needs are ordering-only
100
+ * (e.g. boot.workspace waits for discover.arch to create the shell under SERIALIZE_DISCOVER) and do not
101
+ * read the target's artifacts, so redoing the target must not re-run nodes hanging off such an edge.
102
+ */
103
+ export function rewindAffected(graph, targetId) {
104
+ const dataChildren = {};
105
+ for (const node of graph.nodes) {
106
+ for (const parent of resolveParents(graph, node, {}, { conditional: false })) {
107
+ (dataChildren[parent] ||= new Set()).add(node.id);
108
+ }
109
+ }
110
+ const affected = new Set([targetId]);
111
+ const queue = [targetId];
112
+ while (queue.length) {
113
+ for (const child of dataChildren[queue.shift()] || []) {
114
+ if (!affected.has(child)) {
115
+ affected.add(child);
116
+ queue.push(child);
117
+ }
118
+ }
119
+ }
120
+ return affected;
121
+ }
122
+
123
+ export function resolveParents(graph, node, vars = {}, { conditional = true } = {}) {
124
+ const parents = new Set(node.needs || []);
125
+ for (const entry of conditional ? node.conditional_needs || [] : []) {
126
+ if (evaluateExpression(entry.when, vars)) {
127
+ for (const id of entry.add || []) parents.add(id);
128
+ }
129
+ }
130
+ if (node.also_needs_group) {
131
+ for (const candidate of graph.nodes) {
132
+ if (candidate.id !== node.id && candidate.parallel_group === node.also_needs_group) parents.add(candidate.id);
133
+ }
134
+ }
135
+ return parents;
136
+ }
137
+
138
+ export function readyNodes(graph, statuses, vars = {}) {
139
+ const readStatus = (id) => statuses instanceof Map ? statuses.get(id) : statuses?.[id];
140
+ const isTerminal = (id) => {
141
+ const record = readStatus(id);
142
+ const status = record && typeof record === "object" && !Array.isArray(record) ? record.status : record;
143
+ return TERMINAL_STATUSES.has(status);
144
+ };
145
+ const declarationOrder = new Map(graph.nodes.map((node, index) => [node.id, index]));
146
+ return graph.nodes.filter((node) => {
147
+ if (!graph.activeIds.has(node.id) || isTerminal(node.id)) return false;
148
+ return [...resolveParents(graph, node, vars)].every((parent) => !graph.activeIds.has(parent) || isTerminal(parent));
149
+ }).sort((left, right) => {
150
+ const leftRank = graph.serialRank?.has(left.id) ? graph.serialRank.get(left.id) : Number.MAX_SAFE_INTEGER;
151
+ const rightRank = graph.serialRank?.has(right.id) ? graph.serialRank.get(right.id) : Number.MAX_SAFE_INTEGER;
152
+ return leftRank - rightRank || declarationOrder.get(left.id) - declarationOrder.get(right.id);
153
+ });
154
+ }
155
+
156
+ function unsupported(message) {
157
+ const error = new Error(message);
158
+ error.code = "UNSUPPORTED_EXPRESSION";
159
+ throw error;
160
+ }
161
+
162
+ function evaluateExpression(input, vars = {}) {
163
+ const source = String(input ?? "");
164
+ const readVar = (name) => {
165
+ if (name === "true") return true;
166
+ if (name === "false") return false;
167
+ if (name === "null") return null;
168
+ if (vars instanceof Map) return vars.get(name);
169
+ return vars != null && Object.prototype.hasOwnProperty.call(vars, name) ? vars[name] : undefined;
170
+ };
171
+ let at = 0;
172
+
173
+ function skipSpace() {
174
+ while (/\s/.test(source[at] || "")) at++;
175
+ }
176
+
177
+ function take(token) {
178
+ skipSpace();
179
+ if (!source.startsWith(token, at)) return false;
180
+ at += token.length;
181
+ return true;
182
+ }
183
+
184
+ function primary() {
185
+ skipSpace();
186
+ if (at >= source.length) unsupported(`missing expression at position ${at}`);
187
+ if (take("(")) {
188
+ const value = expression();
189
+ if (!take(")")) unsupported(`expected ) at position ${at}`);
190
+ return value;
191
+ }
192
+ if (source[at] === "'" || source[at] === '"') return string();
193
+ const number = source.slice(at).match(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/);
194
+ if (number) {
195
+ at += number[0].length;
196
+ return Number(number[0]);
197
+ }
198
+ let name;
199
+ if (take("${")) {
200
+ name = source.slice(at).match(/^[A-Za-z_$][\w$]*/)?.[0];
201
+ if (!name) unsupported(`invalid variable at position ${at}`);
202
+ at += name.length;
203
+ if (!take("}")) unsupported(`invalid variable at position ${at}`);
204
+ return readVar(name);
205
+ }
206
+ name = source.slice(at).match(/^[A-Za-z_$][\w$]*/)?.[0];
207
+ if (!name) unsupported(`unsupported expression at position ${at}`);
208
+ at += name.length;
209
+ const value = readVar(name);
210
+ return value === undefined ? name : value;
211
+ }
212
+
213
+ function keyword(token) {
214
+ skipSpace();
215
+ if (!source.startsWith(token, at)) return false;
216
+ const before = source[at - 1] || "";
217
+ const after = source[at + token.length] || "";
218
+ if (/[A-Za-z0-9_$]/.test(before) || /[A-Za-z0-9_$]/.test(after)) return false;
219
+ at += token.length;
220
+ return true;
221
+ }
222
+
223
+ function unary() {
224
+ skipSpace();
225
+ if (take("!") || keyword("not")) return !unary();
226
+ return primary();
227
+ }
228
+
229
+ function string() {
230
+ const quote = source[at++];
231
+ let value = "";
232
+ while (at < source.length && source[at] !== quote) {
233
+ if (source[at] === "\\") unsupported(`string escapes are not supported at position ${at}`);
234
+ value += source[at++];
235
+ }
236
+ if (source[at] !== quote) unsupported(`unterminated string at position ${at}`);
237
+ at++;
238
+ return value;
239
+ }
240
+
241
+ function relational() {
242
+ let left = unary();
243
+ for (;;) {
244
+ const operator = [">=", "<=", ">", "<"].find((candidate) => take(candidate));
245
+ if (!operator) return left;
246
+ const right = unary();
247
+ if (operator === ">=") left = left >= right;
248
+ else if (operator === "<=") left = left <= right;
249
+ else if (operator === ">") left = left > right;
250
+ else left = left < right;
251
+ }
252
+ }
253
+
254
+ function equality() {
255
+ let left = relational();
256
+ for (;;) {
257
+ const operator = ["===", "!==", "==", "!="].find((candidate) => take(candidate));
258
+ if (!operator) return left;
259
+ const right = relational();
260
+ if (operator === "===") left = left === right;
261
+ else if (operator === "!==") left = left !== right;
262
+ else if (operator === "==") left = left == right;
263
+ else left = left != right;
264
+ }
265
+ }
266
+
267
+ function andExpression() {
268
+ let left = equality();
269
+ for (;;) {
270
+ skipSpace();
271
+ if (source.startsWith("&&", at)) at += 2;
272
+ else if (keyword("and")) { /* consumed */ }
273
+ else return left;
274
+ const right = equality();
275
+ left = left && right;
276
+ }
277
+ }
278
+
279
+ function expression() {
280
+ let left = andExpression();
281
+ for (;;) {
282
+ skipSpace();
283
+ if (source.startsWith("||", at)) at += 2;
284
+ else if (keyword("or")) { /* consumed */ }
285
+ else return left;
286
+ const right = andExpression();
287
+ left = left || right;
288
+ }
289
+ }
290
+
291
+ const value = expression();
292
+ skipSpace();
293
+ if (at !== source.length) unsupported(`unsupported expression at position ${at}`);
294
+ return value;
295
+ }
296
+
297
+ export { evaluateExpression };
@@ -12,6 +12,7 @@ import path from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
 
14
14
  import yaml from "./lib-yaml-lite.mjs";
15
+ import { validateGraph } from "./dag_graph.mjs";
15
16
  import { parseArgs } from "./paths_preflight.mjs";
16
17
 
17
18
  const HERE = path.dirname(fileURLToPath(import.meta.url));
@@ -63,6 +64,75 @@ function hasPhrase(text, [zh, en], { ci = false } = {}) {
63
64
 
64
65
  const SEED = { ANDROID: "/A", HMOS: "/H", SKILLS_ROOT: "/S", APK_PATH: "/apk" };
65
66
 
67
+ const PRODUCTION_SERIAL_ORDER = [
68
+ "bootstrap",
69
+ "discover.android_index",
70
+ "boot.workspace",
71
+ "discover.arch",
72
+ "discover.utg_static",
73
+ "review.arch",
74
+ "discover.utg_snapshot",
75
+ "discover.feature_scope",
76
+ "ui.batch",
77
+ "review.ui_batch",
78
+ "enrich.spec_gen",
79
+ "review.spec_gen",
80
+ "enrich.module_docs",
81
+ "barrier.l2_enrich",
82
+ "adopt.signing",
83
+ "adopt.specs_json",
84
+ "logic.spec_pipeline",
85
+ "logic.finalize",
86
+ ];
87
+
88
+ // A node's own reuse lives only in runner.reuse_if. The one exception is a node whose sole consumer is reused
89
+ // this round: that is "nobody needs this output", a skip, not a reuse of this node's artifacts.
90
+ const CROSS_NODE_REUSE_IN_SKIP_IF = {
91
+ "discover.utg_static": ["REUSE_SPEC_GENERATE"],
92
+ };
93
+
94
+ const PRODUCTION_RUNNER_KINDS = {
95
+ bootstrap: "bootstrap",
96
+ "discover.android_index": "script",
97
+ "discover.arch": "skill",
98
+ "boot.workspace": "workspace",
99
+ "discover.utg_static": "skill",
100
+ "review.arch": "gate",
101
+ "discover.utg_snapshot": "snapshot",
102
+ "discover.feature_scope": "host_action",
103
+ "ui.batch": "skill",
104
+ "review.ui_batch": "gate",
105
+ "enrich.spec_gen": "skill",
106
+ "review.spec_gen": "gate",
107
+ "enrich.module_docs": "skill",
108
+ "barrier.l2_enrich": "barrier",
109
+ "adopt.signing": "host_action",
110
+ "adopt.specs_json": "adopt_specs",
111
+ "logic.spec_pipeline": "skill",
112
+ "logic.finalize": "host_action",
113
+ };
114
+
115
+ const PRODUCTION_GATES = {
116
+ "review.arch": {
117
+ gate: "arch",
118
+ checkpoint: "${CHECKPOINT_DIR}/arch-reviewed.ok",
119
+ rewind_to: "discover.arch",
120
+ rewind_clear_vars: ["REUSE_DISCOVER_ARCH"],
121
+ },
122
+ "review.spec_gen": {
123
+ gate: "spec_gen",
124
+ checkpoint: "${CHECKPOINT_DIR}/spec-gen-reviewed.ok",
125
+ rewind_to: "enrich.spec_gen",
126
+ rewind_clear_vars: ["REUSE_SPEC_GENERATE"],
127
+ },
128
+ "review.ui_batch": {
129
+ gate: "ui_batch",
130
+ checkpoint: "${CHECKPOINT_DIR}/ui-batch-reviewed.ok",
131
+ rewind_to: "ui.batch",
132
+ rewind_clear_vars: ["REUSE_UI_BATCH"],
133
+ },
134
+ };
135
+
66
136
  function expand(value, env, depth = 12) {
67
137
  let out = String(value);
68
138
  for (let i = 0; i < depth; i++) {
@@ -164,38 +234,78 @@ function main() {
164
234
  const ids = nodes.map((n) => n.id);
165
235
  const N = Object.fromEntries(nodes.map((n) => [n.id, n]));
166
236
  const env = buildEnv(doc);
167
- const errors = [];
237
+ const errors = validateGraph(doc);
168
238
 
169
- const dups = new Set(ids.filter((i) => ids.filter((x) => x === i).length > 1));
170
- if (dups.size) errors.push(`duplicate node ids: ${[...dups].sort()}`);
239
+ if (doc.id === "a2h-app-migrate") {
240
+ if (JSON.stringify(doc.serial_order || []) !== JSON.stringify(PRODUCTION_SERIAL_ORDER)) {
241
+ errors.push(`serial_order must exactly cover the production nodes in the approved fixed order: ${PRODUCTION_SERIAL_ORDER.join(", ")}`);
242
+ }
243
+ for (const n of nodes) {
244
+ const expectedKind = PRODUCTION_RUNNER_KINDS[n.id];
245
+ if (!expectedKind) {
246
+ errors.push(`${n.id}: unexpected node in the production workflow`);
247
+ continue;
248
+ }
249
+ if (n.runner?.action !== "production" || n.runner?.kind !== expectedKind) {
250
+ errors.push(`${n.id}: runner must be action=production kind=${expectedKind}`);
251
+ }
252
+ const allowedReuse = CROSS_NODE_REUSE_IN_SKIP_IF[n.id] || [];
253
+ const ownReuse = new Set(String(n.runner?.reuse_if || "").match(/\bREUSE_[A-Z0-9_]+\b/g) || []);
254
+ for (const v of new Set(String(n.skip_if || "").match(/\bREUSE_[A-Z0-9_]+\b/g) || [])) {
255
+ if (!allowedReuse.includes(v) || ownReuse.has(v)) {
256
+ errors.push(`${n.id}: skip_if must not contain ${v}; reuse belongs only in runner.reuse_if`);
257
+ }
258
+ }
259
+ }
260
+ for (const id of PRODUCTION_SERIAL_ORDER) {
261
+ if (!N[id]) errors.push(`production workflow is missing node ${id}`);
262
+ }
171
263
 
172
- for (const n of nodes) {
173
- for (const p of n.needs || []) {
174
- if (!(p in N)) errors.push(`${n.id}: needs points to a missing node \`${p}\``);
264
+ const summaryNodes = nodes.filter((n) => n.runner?.after_terminal != null);
265
+ const expectedSummaryNodes = ["ui.batch", "enrich.spec_gen", "logic.spec_pipeline"];
266
+ if (JSON.stringify(summaryNodes.map((n) => n.id).sort()) !== JSON.stringify([...expectedSummaryNodes].sort())) {
267
+ errors.push(`runner.after_terminal=resume_summary must be configured only on ${expectedSummaryNodes.join(", ")}`);
268
+ }
269
+ for (const n of summaryNodes) {
270
+ if (n.runner.after_terminal !== "resume_summary") errors.push(`${n.id}: unsupported runner.after_terminal ${n.runner.after_terminal}`);
271
+ }
272
+
273
+ for (const [id, expected] of Object.entries(PRODUCTION_GATES)) {
274
+ const runner = N[id]?.runner || {};
275
+ for (const [key, value] of Object.entries(expected)) {
276
+ if (JSON.stringify(runner[key]) !== JSON.stringify(value)) {
277
+ errors.push(`${id}: runner.${key} must be ${JSON.stringify(value)}`);
278
+ }
279
+ }
280
+ if (N[id]?.human_gate !== true) errors.push(`${id}: production review gate must keep human_gate: true`);
281
+ }
282
+
283
+ const finalize = N["logic.finalize"];
284
+ const finalizeSuccess = finalize?.success || [];
285
+ if (
286
+ finalizeSuccess.length !== 1
287
+ || finalizeSuccess[0]?.file_exists !== "${LOGIC_REPORT}"
288
+ ) {
289
+ errors.push("logic.finalize: success must only verify file_exists=${LOGIC_REPORT}; the Runner owns DAG certification");
175
290
  }
291
+ const finalizeBlob = JSON.stringify(finalize || {});
292
+ if (finalizeBlob.includes("--write-run-end") || /--node\s+logic\.finalize\s+--status/.test(finalizeBlob)) {
293
+ errors.push("logic.finalize: workflow must not append its own terminal record or run_end");
294
+ }
295
+ if (JSON.stringify(doc).includes("--write-run-end")) {
296
+ errors.push("workflow must not contain --write-run-end; only the Runner may certify a run");
297
+ }
298
+ }
299
+
300
+ for (const n of nodes) {
176
301
  for (const c of n.conditional_needs || []) {
177
302
  if (!String(c.when || "").trim()) errors.push(`${n.id}: conditional_needs entry is missing when`);
178
303
  if (!String(c.why || "").trim()) {
179
304
  errors.push(`${n.id}: conditional_needs entry is missing why (a conditional edge must state its reason)`);
180
305
  }
181
- for (const t of c.add || []) {
182
- if (!(t in N)) errors.push(`${n.id}: conditional_needs.add points to a missing node \`${t}\``);
183
- }
184
306
  }
185
307
  }
186
308
 
187
- const seen = new Set();
188
- let todo = [...nodes];
189
- while (todo.length) {
190
- const ready = todo.filter((n) => (n.needs || []).every((p) => seen.has(p)));
191
- if (!ready.length) {
192
- errors.push(`the DAG has a cycle involving: ${todo.map((n) => n.id)}`);
193
- break;
194
- }
195
- for (const n of ready) seen.add(n.id);
196
- todo = todo.filter((n) => !seen.has(n.id));
197
- }
198
-
199
309
  const fm = new Set(Object.keys(doc.fail_matrix || {}));
200
310
  for (const i of ids) {
201
311
  if (!fm.has(i)) errors.push(`fail_matrix is missing node \`${i}\` (no failure handling defined)`);
@@ -505,6 +615,9 @@ function main() {
505
615
  process.stdout.write("✅ ids unique / needs closed / no cycles\n");
506
616
  process.stdout.write("✅ fail_matrix and schedule_hint cover every node\n");
507
617
  process.stdout.write("✅ force_skip targets valid\n");
618
+ if (doc.id === "a2h-app-migrate") {
619
+ process.stdout.write("✅ all production nodes use the fixed Runner kinds/order; reuse, gates, summaries and finalize ownership are valid\n");
620
+ }
508
621
  process.stdout.write(
509
622
  `✅ no unregistered concurrent read/write races (${exempt.length} registered exemption(s), all still valid)\n`,
510
623
  );
@@ -90,15 +90,32 @@ test("the page-specgen leaf keeps its gaps out of the app-migrate report", () =>
90
90
  assert.doesNotMatch(finalize, /gaps must go into the final report/);
91
91
  });
92
92
 
93
+ test("logic.finalize leaves terminal recording and DAG certification to the Runner", () => {
94
+ const finalize = byId["logic.finalize"];
95
+ assert.deepEqual(finalize.success, [{ file_exists: "${LOGIC_REPORT}" }]);
96
+ assert.equal(finalize.runner.action, "production");
97
+ assert.equal(finalize.runner.kind, "host_action");
98
+
99
+ const inv = finalize.invoke;
100
+ assert.match(inv, /do not append your own logic\.finalize terminal record or run_end/);
101
+ assert.match(inv, /Runner verifies the report and commits the only logic\.finalize done/);
102
+ assert.match(inv, /single run_end/);
103
+ assert.doesNotMatch(inv, /--node logic\.finalize --status done/);
104
+ assert.doesNotMatch(inv, /--write-run-end/);
105
+ });
106
+
93
107
  test("review.spec_gen: rerun says plainly that it does not refreeze the UTG snapshot (N12)", () => {
94
108
  const inv = byId["review.spec_gen"].invoke;
95
109
  assert.doesNotMatch(inv, /fix the Android side or the UTG and regenerate/);
96
110
  assert.match(inv, /fixing the UTG does not take effect this way[\s\S]*reuse_discover_utg=false/);
97
111
  });
98
112
 
99
- test("gates: rerun first turns off the producer's REUSE_* so its skip_if no longer fires (L5)", () => {
113
+ test("gates: rewind clears the producer's runner.reuse_if instead of conflating reuse with skip_if (L5)", () => {
100
114
  for (const [gate, producer, v] of [["review.arch", "discover.arch", "REUSE_DISCOVER_ARCH"], ["review.spec_gen", "enrich.spec_gen", "REUSE_SPEC_GENERATE"], ["review.ui_batch", "ui.batch", "REUSE_UI_BATCH"]]) {
101
- assert.match(byId[producer].skip_if, new RegExp(v));
115
+ assert.match(byId[producer].runner.reuse_if, new RegExp(v));
116
+ assert.doesNotMatch(String(byId[producer].skip_if || ""), new RegExp(v));
117
+ assert.equal(byId[gate].runner.rewind_to, producer);
118
+ assert.deepEqual(byId[gate].runner.rewind_clear_vars, [v]);
102
119
  const reruns = byId[gate].invoke.split("\n").filter((l) => l.includes("`rerun` ->"));
103
120
  assert.ok(reruns.length > 0, gate);
104
121
  for (const l of reruns) assert.match(l, new RegExp(`first set ${v}=false`), `${gate}: ${l}`);
@@ -111,7 +128,7 @@ test("ui-only keeps logic.finalize so soft_continue failures still get a report
111
128
  assert.ok(!ui.force_skip.includes("finalize") && !ui.force_skip.includes("logic.finalize"));
112
129
  assert.ok(ui.force_skip.includes("logic"), "the logic pipeline itself stays out");
113
130
  const inv = byId["logic.finalize"].invoke;
114
- assert.match(inv, /0\. logic\.spec_pipeline was skipped this round[^\n]*\$\{PROFILE\} == ui-only/);
115
- assert.match(inv, /skipped \([^\n]*\$\{PROFILE\} == ui-only\) -> \*\*do not read\*\*/);
131
+ assert.match(inv, /0\. logic\.spec_pipeline was skipped this round[^\n]*\$\{PROFILE\} == 'ui-only'/);
132
+ assert.match(inv, /skipped \([^\n]*\$\{PROFILE\} == 'ui-only'\) -> \*\*do not read\*\*/);
116
133
  assert.match(inv, /ledger/i);
117
134
  });
@@ -13,8 +13,8 @@ import {
13
13
  renderDigitsPng,
14
14
  renderMetrics,
15
15
  verify,
16
- } from "../../../../skills/a2h-batch-ui-align/scripts/image_probe.mjs";
17
- import yaml from "../../../../skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs";
16
+ } from "../../a2h-batch-ui-align/scripts/image_probe.mjs";
17
+ import yaml from "../scripts/lib-yaml-lite.mjs";
18
18
 
19
19
  const HERE = path.dirname(fileURLToPath(import.meta.url));
20
20
  const WORKFLOW = path.join(HERE, "..", "references", "workflow.yaml");
@@ -82,7 +82,7 @@ test("bootstrap env-probes image-read; ui.batch re-probes; skip env probe when U
82
82
  assert.equal(tip.skip_when, "${IMAGE_READ} != false or ${REUSE_UI_BATCH} == true");
83
83
  const probe = boot.actions.map((a) => a.probe_image_read).find(Boolean);
84
84
  assert.ok(probe, "bootstrap.probe_image_read is missing");
85
- assert.equal(probe.skip_when, "${IMAGE_READ} != probe or ${REUSE_UI_BATCH} == true");
85
+ assert.equal(probe.skip_when, "${IMAGE_READ} != 'probe' or ${REUSE_UI_BATCH} == true");
86
86
  assert.match(doc.policy.image_read, /REUSE_UI_BATCH == true|will not run ui\.batch/);
87
87
  assert.match(doc.policy.image_read, /probe again|do not reuse each other's verdict/i);
88
88
  assert.match(doc.policy.image_read, /never.*pass.*image_read=/i);
@@ -143,7 +143,7 @@ test("bootstrap runs plan_resume first so the run dirs are resolved from the led
143
143
  // args / when unchanged: still only consumes SKILLS_ROOT / LEDGER / FROM_NODE / RESUME_BASE_PROFILE
144
144
  const plan = boot.actions.map((a) => a.plan_resume).find(Boolean);
145
145
  assert.match(plan.args, /--ledger \$\{LEDGER\} --from-node \$\{FROM_NODE\}/);
146
- assert.match(plan.when, /\$\{PROFILE\} == resume/);
146
+ assert.match(plan.when, /\$\{PROFILE\} == 'resume'/);
147
147
  assert.doesNotMatch(plan.exit_0, /last_engine/, "exit_0 no longer backfills the engine");
148
148
  // The engine carry-over actions are gone: bootstrap has no resolve_last_engine / resolve_case_id
149
149
  assert.equal(at("resolve_last_engine"), -1, names.join(","));
@@ -102,7 +102,7 @@ test("ui.batch reuses discover's workspace only by copying, and only when discov
102
102
  const utg = doc.nodes.find((n) => n.id === "discover.utg_static").invoke;
103
103
  assert.match(ui, /reuse_static_utg\.mjs --from \$\{UTG_DIR\} --to \$\{UI_UTG_DIR\}/);
104
104
  assert.match(ui, /REUSE_DISCOVER_UTG/);
105
- assert.match(ui, /PROFILE\} == ui-only/);
105
+ assert.match(ui, /PROFILE\} == 'ui-only'/);
106
106
  assert.match(ui, /never back to \$\{UTG_DIR\}/);
107
107
  assert.match(utg, /--lang <locale>/);
108
108
  assert.match(utg, /persist\.sys\.locale/);
@@ -85,8 +85,14 @@ test("workflow: utg_static success, probe and invoke all use the check", () => {
85
85
  test("workflow: utg_static is skipped whenever no spec generation will consume it; snapshot never hard-stops on that", () => {
86
86
  const doc = yaml.load(fs.readFileSync(WORKFLOW, "utf8"));
87
87
  const byId = Object.fromEntries(doc.nodes.map((n) => [n.id, n]));
88
- const noSpec = ["${SKIP_LOGIC}", "${SKIP_SPEC_GENERATE}", "${REUSE_SPEC_GENERATE} == true", "${PROFILE} == ui-only"];
89
- for (const c of noSpec) assert.ok(byId["discover.utg_static"].skip_if.includes(c), `utg_static skip_if lacks ${c}`);
88
+ const skipNoSpec = ["${SKIP_LOGIC}", "${SKIP_SPEC_GENERATE}", "${REUSE_SPEC_GENERATE} == true", "${PROFILE} == 'ui-only'"];
89
+ for (const c of skipNoSpec) assert.ok(byId["discover.utg_static"].skip_if.includes(c), `utg_static skip_if lacks ${c}`);
90
+ // The consumer's reuse (REUSE_SPEC_GENERATE) skips it; its own reuse is owned by runner.reuse_if, not skip_if.
91
+ assert.doesNotMatch(byId["discover.utg_static"].skip_if.replace("${REUSE_SPEC_GENERATE}", ""), /REUSE_/);
92
+ // Same condition as the snapshot it feeds: otherwise utg_static runs (hard_stop on failure) while the snapshot ignores it.
93
+ const ensure = byId["discover.utg_snapshot"].actions.find((a) => a.ensure_utg_snapshot).ensure_utg_snapshot;
94
+ assert.equal(ensure.when, `not (${byId["discover.utg_static"].skip_if})`);
95
+ assert.match(byId["discover.utg_static"].runner.reuse_if, /REUSE_DISCOVER_UTG/);
90
96
  const snap = byId["discover.utg_snapshot"];
91
97
  assert.equal(snap.skip_if, undefined, "snapshot keeps running: its precondition is ui.batch's arch gate");
92
98
  assert.match(JSON.stringify(snap.actions), /"when":"not \(/);
@@ -157,9 +163,10 @@ test("workflow: arch reuse does not hinge on utg_static (which skips legitimatel
157
163
  assert.deepEqual(map.REUSE_DISCOVER_UTG, [1]);
158
164
  assert.ok(!("REUSE_DISCOVER" in map) && !("REUSE_DISCOVER" in doc.vars));
159
165
  const byId = Object.fromEntries(doc.nodes.map((n) => [n.id, n]));
160
- assert.match(byId["discover.arch"].skip_if, /REUSE_DISCOVER_ARCH/);
161
- assert.doesNotMatch(byId["discover.arch"].skip_if, /REUSE_DISCOVER_UTG/);
162
- assert.match(byId["discover.utg_static"].skip_if, /REUSE_DISCOVER_UTG/);
166
+ assert.match(byId["discover.arch"].runner.reuse_if, /REUSE_DISCOVER_ARCH/);
167
+ assert.doesNotMatch(byId["discover.arch"].skip_if, /REUSE_DISCOVER_(ARCH|UTG)/);
168
+ assert.match(byId["discover.utg_static"].runner.reuse_if, /REUSE_DISCOVER_UTG/);
169
+ assert.doesNotMatch(byId["discover.utg_static"].skip_if, /REUSE_DISCOVER_UTG/);
163
170
  for (const v of ["REUSE_DISCOVER_ARCH", "REUSE_DISCOVER_UTG"]) assert.ok(doc.vars[v].from.includes("reuse_discover"), v);
164
171
  });
165
172
 
@@ -146,14 +146,13 @@ extraction to the commit.
146
146
  (unresolved key, lock budget, moved document) takes the same fallback with the key and error
147
147
  recorded. Never guess silently and never block the chunk on the docs.
148
148
 
149
- **Platform API doc gate (soft).** When the chunk calls a platform API whose call shape the
150
- worktree does not already show, run the gate in `references/code-generation.md` Step 2 — it owns
151
- the trigger, the `state_doc.mjs search` / `read-id --section` commands, the
152
- worktree > `.d.ts` > docs precedence, the per-chunk budget and the API-level check. Record the
153
- rows plus `api-docs: available` / `unavailable` / `not-applicable` in the same
154
- `state_docs_used.md`. With `api-docs-mode: unavailable`, skip the wrapper and record
155
- `api-docs: unavailable`; this gate never blocks the chunk and never changes the `state-docs`
156
- verdict.
149
+ **Platform API doc gate (shape: soft; semantics: mandatory).** `references/code-generation.md`
150
+ Step 2 owns the trigger, commands, precedence and record. A working call site may satisfy a shape
151
+ query; a call whose correctness depends on meaning — targets, ordering, capability level, units,
152
+ addressed keys — must read the official page, and its record needs one verbatim sentence from it
153
+ (a `SDK .d.ts` row does not count). Never record `available` without that sentence. A failed read
154
+ is recorded `unavailable` and the chunk continues — the gate never blocks; only the shape half is
155
+ skippable.
157
156
 
158
157
  Do the code generation, its scenario self-check (up to 3 iterations), and its
159
158
  MVVM + px/vp unit hook checks. Do not re-plan or override that workflow.
@@ -7,4 +7,4 @@ Common implementation pitfalls:
7
7
  * Text measurement results are px, not vp: `MeasureText.measureText` / `measureTextSize` (`@ohos.measure`) and the methods of the same name on `getUIContext().getMeasureUtils()` take `fontSize` in fp, but the returned width and height are both **px** (`.d.ts` `@returns`: "both in px"). Before comparing the result with a vp budget or passing it to `.width()`, convert it with `this.getUIContext().px2vp(...)`. Observed (where-to-study bottom navigation): comparing `measureTextSize().width` (px) directly with a vp cell width always concluded "does not fit" at 3.5x density, so the tab labels never showed on any device, and reviewers trusted a code comment claiming "vp output". Canvas `context.measureText()` returns vp by default; it is different, so do not carry experience over between them. For other APIs the `.d.ts` is authoritative; see the unit table in code-generation.md Implementation Principle 6. `scripts/check_units.ts` blocks this pattern.
8
8
  * Do not use `ForEach` for large lists (lists/grids of songs, messages, feeds, etc. that may have hundreds of entries): it creates all child nodes on first load, so with many entries the first frame stutters noticeably or even times out with a blank screen. Prefer `LazyForEach` + `IDataSource` to create on-screen nodes on demand; note that data-source changes must be notified through interfaces such as `notifyDataReload` / `notifyDataAdd` / `notifyDataChange` — replacing the whole array without notifying does not refresh the UI (a pitfall already seen when combined with `@Observed`/`@ObjectLink`). A small fixed set of options (menus, tabs) can still use `ForEach`.
9
9
  * Every value that crosses an "untyped boundary" into strongly typed code must be normalized as nullable; never assume it has a value: deserialization results, database rows, local caches and cross-page parameters all count. An ArkTS type is a compile-time annotation only — nothing is validated at runtime, `as T` fills in no default, and `null` enters the entity as-is; a mapping that tests only `=== undefined` misses it. On the read side that throws `TypeError` (a crash) at `.length`, iteration or a method call, and in numeric comparisons `null` is silently taken as 0; on the write side it is rejected by the non-null constraint and never reaches the database, or it is written to JSON and read back with missing values (a `null` inside an object stays `null`, while the key of an `undefined` property disappears entirely). Rule: always normalize inside the function that maps external data to the entity — add one first if it does not exist; declare the field `?: T | null` and use `??` to supply the type's default when it is missing (string `''`, number `0`, array `[]`, object `{}`); catch the whole object first, then normalize item by item, field by field; when reading a database, read per the column's nullable declaration instead of substituting an empty string or 0 for missing; use only `??` for fallbacks, never `||` or `if (!v)`, which treat a legitimate `0` or `''` as empty. Writing `=== null` on a non-null field is not a fallback: it misses `undefined` and is also reported as a comparison with no type overlap; the fix is to first change the declaration to `?: T | null`.
10
- * Never write a platform API from memory, and never pick a page from a single search-result list: parameter order, sync/async, the lifecycle (`create` → use → `destroy`/`off`) and the returned unit come from the local `.d.ts`; the call order and usage come from one section of the page via `scripts/state_doc.mjs search "<module or method>"` + `read-id "<documentId>" --section "<heading>" --max-lines 80` (an API page runs to a few thousand lines; reading all of it crowds out the code context; an overload list repeats the same heading, so `--section` returns every occurrence marked `<!-- section "request" 2/3 -->` — add `--occurrence <n>` to pick one). When this worktree already has a working call site for the same API, copy it and skip the lookup; when the doc and the `.d.ts` disagree, the `.d.ts` wins; when the `phone 12+`-style tag beside the heading is above the project's `compatibleSdkVersion`, use the older overload or `canIUse` instead. When nothing resolves, record `api-docs: unavailable`, fall back to the `.d.ts` and this file, and never guess silently.
10
+ * Never write a platform API from memory, and never pick a page from a single search-result list: parameter order, sync/async, the lifecycle (`create` → use → `destroy`/`off`) and the returned unit come from the local `.d.ts`; the call order and usage come from one section of the page via `scripts/state_doc.mjs search "<module or method>"` + `read-id "<documentId>" --section "<heading>" --max-lines 80` (an API page runs to a few thousand lines; reading all of it crowds out the code context; an overload list repeats the same heading, so `--section` returns every occurrence marked `<!-- section "request" 2/3 -->` — add `--occurrence <n>` to pick one). When this worktree already has a working call site for the same API: **shape** questions (parameter order, sync/async, lifecycle, returned unit) may copy it, and the `.d.ts` outranks the page; **meaning** questions (targets, ordering, grant level, boundaries, which key is addressed) still require the official page even when a call site exists, the page outranks the `.d.ts` there, and the record needs one sentence quoted from it; when the `phone 12+`-style tag beside the heading is above the project's `compatibleSdkVersion`, use the older overload or `canIUse` instead. When nothing resolves, record `api-docs: unavailable`, fall back to the `.d.ts` and this file, and never guess silently.