@buaa_smat/hometrans 26.0.6 → 26.0.8-devecocli.1

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 (181) hide show
  1. package/agents/a2h-executor.md +37 -0
  2. package/devecocli-plugin/common.ts +2370 -0
  3. package/devecocli-plugin/content-resolver.ts +363 -0
  4. package/devecocli-plugin/install.ts +72 -0
  5. package/devecocli-plugin/uninstall.ts +26 -0
  6. package/devecocli-plugin/update.ts +77 -0
  7. package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
  8. package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
  9. package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
  10. package/i18n/skills/a2h-app-migrate/SKILL.md +2 -2
  11. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +27 -4
  12. package/i18n/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
  13. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  14. package/i18n/skills/a2h-batch-ui-align/SKILL.md +7 -7
  15. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
  16. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
  17. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
  18. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
  19. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
  20. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
  21. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
  22. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
  23. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
  24. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
  25. package/i18n/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
  26. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
  27. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
  28. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
  29. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
  30. package/i18n/skills/a2h-page-specgen/SKILL.md +1 -1
  31. package/i18n/skills/a2h-page-specgen/references/gates.md +3 -1
  32. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +11 -11
  33. package/i18n/skills/a2h-page-specgen/references/spec-template.md +3 -3
  34. package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
  35. package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
  36. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +144 -0
  37. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +11 -11
  38. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +11 -11
  39. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +11 -11
  40. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +11 -11
  41. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
  42. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
  43. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +11 -11
  44. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +11 -11
  45. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +11 -11
  46. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +11 -11
  47. package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
  48. package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
  49. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +132 -3
  50. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
  51. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
  52. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
  53. package/i18n/skills/a2h-utg-static/SKILL.md +2 -0
  54. package/index.js +1741 -0
  55. package/package.json +8 -8
  56. package/platforms/atomcode/agents/a2h-executor.frontmatter.md +6 -0
  57. package/platforms/codebuddy/agents/a2h-executor.frontmatter.md +5 -0
  58. package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
  59. package/platforms/deveco/agents/a2h-executor.frontmatter.md +7 -0
  60. package/platforms/deveco/agents/build-fixer.frontmatter.md +0 -2
  61. package/platforms/deveco/agents/code-reviewer.frontmatter.md +0 -2
  62. package/platforms/deveco/agents/model-render-worker.frontmatter.md +0 -2
  63. package/platforms/deveco/agents/model-worker.frontmatter.md +0 -2
  64. package/platforms/deveco/agents/specgen-worker.frontmatter.md +0 -2
  65. package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
  66. package/platforms/opencode/agents/a2h-executor.frontmatter.md +7 -0
  67. package/platforms/opencode/agents/build-fixer.frontmatter.md +0 -2
  68. package/platforms/opencode/agents/code-reviewer.frontmatter.md +0 -2
  69. package/platforms/opencode/agents/model-render-worker.frontmatter.md +0 -2
  70. package/platforms/opencode/agents/model-worker.frontmatter.md +0 -2
  71. package/platforms/opencode/agents/specgen-worker.frontmatter.md +0 -2
  72. package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
  73. package/plugin.jsonc +12 -0
  74. package/skills/a2h-app-migrate/SKILL.md +29 -3
  75. package/skills/a2h-app-migrate/references/host-rules.md +33 -0
  76. package/skills/a2h-app-migrate/references/workflow.yaml +24 -4
  77. package/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
  78. package/skills/a2h-app-migrate/test/test_executor_header_sync.mjs +78 -0
  79. package/skills/a2h-app-migrate/test/test_opencode_depth.mjs +312 -0
  80. package/skills/a2h-app-migrate/tools/dag.mjs +267 -0
  81. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  82. package/skills/a2h-batch-ui-align/SKILL.md +7 -7
  83. package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
  84. package/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
  85. package/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
  86. package/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
  87. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
  88. package/skills/a2h-batch-ui-align/references/host-dispatch.md +5 -5
  89. package/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
  90. package/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
  91. package/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
  92. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
  93. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
  94. package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +3 -2
  95. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +139 -23
  96. package/skills/a2h-batch-ui-align/scripts/host_env.mjs +32 -8
  97. package/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
  98. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
  99. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
  100. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
  101. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +82 -0
  102. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
  103. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +184 -2
  104. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +33 -0
  105. package/skills/a2h-batch-ui-align/scripts/tests/interactions.test.mjs +258 -0
  106. package/skills/a2h-page-specgen/SKILL.md +1 -1
  107. package/skills/a2h-page-specgen/references/evidence.md +15 -0
  108. package/skills/a2h-page-specgen/references/gates.md +3 -1
  109. package/skills/a2h-page-specgen/references/scenario-authoring.md +10 -10
  110. package/skills/a2h-page-specgen/references/spec-template.md +2 -2
  111. package/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
  112. package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
  113. package/skills/a2h-page-specgen/scripts/gate.mjs +141 -0
  114. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +10 -10
  115. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +10 -10
  116. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +10 -10
  117. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +10 -10
  118. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
  119. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
  120. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +10 -10
  121. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +10 -10
  122. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +10 -10
  123. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +10 -10
  124. package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
  125. package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
  126. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +104 -3
  127. package/skills/a2h-resource-convert/references/conversion-rules.md +2 -0
  128. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
  129. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +42 -0
  130. package/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
  131. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
  132. package/skills/a2h-spec-design-pipeline/references/execution-model.md +2 -2
  133. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +5 -1
  134. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
  135. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
  136. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +2 -1
  137. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +3 -1
  138. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-cn.md +105 -0
  139. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-en.md +122 -0
  140. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +4 -4
  141. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIV2ObservationCheck.js +1862 -0
  142. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +2 -0
  143. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
  144. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +15 -2
  145. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +20 -4
  146. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_v2_observation.ts +284 -0
  147. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +32 -0
  148. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +22 -1
  149. package/skills/a2h-utg-static/SKILL.md +2 -0
  150. package/skills/a2h-utg-static/references/extractors.md +16 -0
  151. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +22 -1
  152. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +4 -0
  153. package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +15 -0
  154. package/skills/a2h-utg-static/scripts/tests/test_view_attachments.mjs +330 -0
  155. package/skills/a2h-utg-static/scripts/view_attachments.mjs +465 -0
  156. package/README.md +0 -410
  157. package/dist/cli/config-store.js +0 -128
  158. package/dist/cli/config.js +0 -48
  159. package/dist/cli/editors.json +0 -134
  160. package/dist/cli/env-vars.js +0 -127
  161. package/dist/cli/index.js +0 -76
  162. package/dist/cli/init.js +0 -2618
  163. package/dist/cli/uninstall.js +0 -406
  164. package/dist/platform/compose.js +0 -228
  165. package/dist/platform/frontmatter.js +0 -151
  166. package/dist/platform/installer.js +0 -417
  167. package/dist/platform/language.js +0 -77
  168. package/dist/platform/registry.js +0 -338
  169. package/dist/platform/transform.js +0 -363
  170. package/dist/platform/types.js +0 -9
  171. package/dist/platform/validate.js +0 -153
  172. package/dist/utils/regex.js +0 -7
  173. package/env-requirements.json +0 -536
  174. package/platforms/codebuddy/agents/build-fixer.frontmatter.md +0 -5
  175. package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +0 -5
  176. package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +0 -5
  177. package/platforms/codebuddy/agents/model-worker.frontmatter.md +0 -5
  178. package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +0 -5
  179. package/resource/choose_editor.png +0 -0
  180. package/resource/set_sdk.png +0 -0
  181. package/resource/title_dark.png +0 -0
@@ -187,18 +187,18 @@ Review every lifecycle-signal candidate and choose one of three: a user-observab
187
187
 
188
188
  Timing wording follows the source: "refreshes immediately" when it takes effect on completion, "re-read on return" or "re-read on next entry" when it waits until the page is visible again — never mix the two. An axis scenario's trigger sequence starts from the timing event, and its last step lands on an assertable observable outcome.
189
189
 
190
- ## Request Bodies and Responses
190
+ ## Request Parameters and Responses
191
191
 
192
- When a scenario performs a network request, write the request body as a **tree-shaped field table inside the request step that sends it**. Write the response key by key.
192
+ When a scenario performs a network request, write the request parameters (`query` and `body`) as a **tree-shaped field table inside the request step that sends it**; list path parameters and request headers explicitly with their `in`. Write the response key by key.
193
193
 
194
194
  The table has four fixed, labelled segments in a fixed order and is a top-level fenced code block, so every renderer keeps its line breaks:
195
195
 
196
196
  ```text
197
- <Request body name>
197
+ <Request parameter name>
198
198
  ├─ field:<path> type/encoding:<type> default:<value> send:<rule>
199
199
  ```
200
200
 
201
- - **Write every key**: list each key of the source's request-body construction, including keys that are **always the default**, **always sent**, or **never sent on this page**; dropping one is a failure, and fields may not be picked by scenario. **A field with a default is not necessarily sent** — whether it appears must be confirmed from the source's serializer or request-construction site.
201
+ - **Write every key**: list each key of the source's request construction (`query` or `body`), including keys that are **always the default**, **always sent**, or **never sent on this page**; dropping one is a failure, and fields may not be picked by scenario. **A field with a default is not necessarily sent** — whether it appears must be confirmed from the source's serializer or request-construction site.
202
202
  - `field:` a top-level field is written with its plain name; a nested leaf is `a.b`; an array element is `a[].b`; the array itself is `a[]` (type `array<T>`). A parent object appears together with its children; give it its own `object` row only when the parent itself carries a send rule.
203
203
  - `type/encoding:` only the closed vocabulary `string`, `int`, `int64`, `float`, `double`, `bool`, `object`, `array<T>`; put a time format, a byte encoding or a radix in parentheses (`string(yyyy-MM-dd HH:mm)`, `string(Base64)`, `int(>=1)`). Never write "text" or "number" as loose prose, and keep the token byte-identical to the contract's `type`.
204
204
  - `default:` `—` means the field has no default value; strings are quoted; write only the value, never whether the key is sent.
@@ -206,22 +206,22 @@ The table has four fixed, labelled segments in a fixed order and is a top-level
206
206
  - `required`: the key is always present. Stop there when a missing source value is a defect; add ", falls back to the default" when the default fills it, and name the source or failure when it matters, for example ", falls back to the default unknown when it cannot be read";
207
207
  - `optional`: the key may be absent, immediately followed by a decidable condition written as ", not sent when <condition>" or ", sent only when <condition>", for example ", not sent when it has no value", ", not sent when the array is empty", ", not sent when it equals the default 0", ", not sent when the source cannot be determined", ", not sent when the user specifies no insert position";
208
208
  - `never`: never appears; the field stays in the data model and is skipped when serializing.
209
- - Whether a key is sent follows the source's serializer or request-construction site: a nullable field, a field with a default, and a model-required field do not mean "always sent"; a field with a default may be omitted when it equals the default, and may also always be sent.
209
+ - Whether a key is sent follows the source's serializer or request-construction site: a nullable field, a field with a default, and a model-required field do not mean "always sent", and `"nullable": false` only means the value cannot be empty. **None of these is equivalent to `required`** — a field with a default may be omitted when it equals the default, and may also always be sent.
210
210
  - The condition must be writable as a single `if`: name a concrete condition such as "has no value", "the array is empty", "equals the default", "the control is off", "nothing is selected", "cannot be read", "the source cannot be determined". Never write "as needed", "depending on", "generally", "maybe"; list every condition separately instead of "except in special cases".
211
211
  - `required` and `optional` differ only in whether the key is always present; the `default:` segment says what value fills a missing value and never whether the key appears, so the two segments never substitute for each other. A boolean that uses `false` for "the user set nothing" must say "not sent when it equals the default false", not "not sent when it has no value".
212
212
  - When writing a condition, "no value" means unassigned or `null`; for strings and arrays a length of 0 also counts as no value; `0` and `false` count as values.
213
- - Start the step with an executable action, not a caption such as "the structure is as follows": "the request body is serialized field by field from the table below and then sent; the key order follows the table's row order and whether a key appears follows the send segment".
213
+ - Start the step with an executable action, not a caption such as "the structure is as follows": "the request parameters are serialized field by field from the table below and then sent; the key order follows the table's row order and whether a key appears follows the send segment".
214
214
  - Separate the segments with at least one space: the path after `field:` must not be glued to the next segment, or the path and `default:` read as a `file:line`; write `default:false`, never `default=false`; no table line starts with `#`.
215
- - Name the table root in business terms (for example "sync request body"), never with the request type name from the source.
215
+ - Name the table root in business terms (for example "sync request body" or "weather query parameters"), never with the request type name from the source.
216
216
  - When a field's value does not come from this page's input (local storage, the previous response, a fixed value, a computed value), add one line after the table naming each such field, for example: "Value sources: `userId` is the current signed-in user number in local storage, `deviceId` is the device identifier in local storage, and `payload` is the pending-queue record count." Fields fed by page input need no entry.
217
217
 
218
- **Relation to the contracts.** Each table row is also declared once in that scenario's `contracts.endpoints[].params` with `in: "body"`, byte-identical. The contracts are the audited fact base: G2 compares every parameter name, default and value source against the step text, and one missing token fails the gate. The table is what the reader and the downstream coder see. Query parameters, path parameters and headers are listed the same way with their own `in`; key names, defaults and fixed values follow the source — never guess, and never drop a key that has a default.
218
+ **Relation to the contracts.** Each table row is also declared once in that scenario's `contracts.endpoints[].params` with `in: "query"` or `in: "body"`, byte-identical. The contracts are the audited fact base: G2 compares every parameter name, default and value source against the step text, and one missing token fails the gate. The table is what the reader and the downstream coder see. Path parameters and headers are listed with their own `in` (no table required); key names, defaults and fixed values follow the source — never guess, and never drop a key that has a default.
219
219
 
220
220
  **Response.** List one field path per string in `response_fields[]` (`current_temperature`, `hourly.temperatures[]`); the envelope (code/data/message), types, nullability and the handling of a missing or default-valued field go into that endpoint's `note` and are merged into the step — never into a `response_fields` element, because G2 requires each element to appear verbatim in the step.
221
221
 
222
222
  **G2 checks verbatim.** A method, URL, parameter name, parameter default, value source or response field present in the contracts but absent from the steps fails the gate. The envelope, types, nullability and missing-value handling are outside that check and must still be written into the steps, not left in `contracts` alone.
223
223
 
224
- When the same request appears in several scenarios, each scenario repeats the complete table; never write "same as above" or "see scenario 1". The send condition lives only in the table; the steps state the server behaviour or the user-visible result once the condition holds. When the body is an object or an array, state the nesting and every child key; never write "other fields", "etc.", or a single sample value.
224
+ When the same request appears in several scenarios, each scenario repeats the complete table; never write "same as above" or "see scenario 1". The send condition lives only in the table; the steps state the server behaviour or the user-visible result once the condition holds. When the body (or a nested query object) is an object or an array, state the nesting and every child key; never write "other fields", "etc.", or a single sample value.
225
225
 
226
226
  ## Platform-Neutral Body Text
227
227
 
@@ -317,9 +317,9 @@ Before submission, confirm all of the following:
317
317
  - Numeric inputs state integer versus decimal and whether a negative value is accepted, with no “accepts digits only” standing in for the type; the decimal places, bounds, whitespace and invalid-character handling the source implements are written out, and no unimplemented constraint is written as existing behavior.
318
318
  - Every data boundary names both sides — present (source and destination) and absent (what it does not carry, write or send, and where empty, missing or default goes); entries over one data set line up item by item, absent items are written out, and absence is never written as -1, 0 or an empty string.
319
319
  - Every value answers where it comes from (including the field’s origin in the consuming code), how it is processed (including the inputs that change the result and the difference after they change), and where it is consumed; missing any of the three leaves the scenario incomplete.
320
- - Every branch states how its condition is determined and both outcomes; every step traces to a source location or an evidence entry; whether a key is sent follows the source serializer, never a nullable field, a default value, or a model-required flag.
320
+ - Every branch states how its condition is determined and both outcomes; every step traces to a source location or an evidence entry; whether a key is sent follows the source serializer, never nullability (for example `"nullable": false`), a default value, or a model-required flag.
321
321
  - Scenarios that create, read, update, or delete data, or synchronize state or data, list every affected piece of data and how it changes, with no vague “related data updates in sync.”
322
- - Network scenarios write the request body as a field table inside the sending step, each row carrying the four labelled segments `field:`, `type/encoding:`, `default:` and `send:`; declare the same fields in `contracts.endpoints[].params`, list every value source that is not page input, start every send segment with `required`/`optional`/`never` and follow it with a decidable condition (never "as needed" or "depending on"), describe the response structure as fully as possible, and keep all of these facts in that same step.
322
+ - Network scenarios write the request parameters (`query` and `body`) as a field table inside the sending step, each row carrying the four labelled segments `field:`, `type/encoding:`, `default:` and `send:`; path parameters and headers are listed with their `in` (no table required); declare the same fields in `contracts.endpoints[].params`, list every value source that is not page input, start every send segment with `required`/`optional`/`never` and follow it with a decidable condition (never "as needed" or "depending on"), describe the response structure as fully as possible, and keep all of these facts in that same step.
323
323
  - No vague phrase such as “handle all other errors uniformly” substitutes for concrete branches.
324
324
  - Every scenario is independently readable, with no abbreviated cross-scenario references and no unsupported copy, branches, thresholds, or outcomes added to fill gaps.
325
325
  - Each scenario is exactly one normal or one edge/boundary case, with no success/failure mix.
@@ -105,14 +105,14 @@ Percent encoding is **reversible** (`%` itself becomes `%25`, and the encoded re
105
105
 
106
106
  | kind | Contents | Written into the steps as |
107
107
  |---|---|---|
108
- | `endpoints` | `operation_id` / `branch` / `state_version` (audit-only) / `name` / `method` / `url` / `params[]` (`in`∈`query`\|`path`\|`header`\|`body`, `name` / `type` / `required` / `default` / `source` / `note`) / `response_fields[]` / `timeouts[]` / `note` | The request step: method, complete URL, request headers and timeouts; the body as a field table whose rows carry four labels (`field:` / `type/encoding:` / `default:` / `send:`) plus a value-source line for fields not fed by this page's input; every response field. `operation_id`, `branch`, and `state_version` are not rendered |
108
+ | `endpoints` | `operation_id` / `branch` / `state_version` (audit-only) / `name` / `method` / `url` / `params[]` (`in`∈`query`\|`path`\|`header`\|`body`, `name` / `type` / `required` / `default` / `source` / `note`) / `response_fields[]` / `timeouts[]` / `note` | The request step: method, complete URL, request headers and timeouts; the query and body parameters as a field table whose rows carry four labels (`field:` / `type/encoding:` / `default:` / `send:`) plus a value-source line for fields not fed by this page's input; every response field. `operation_id`, `branch`, and `state_version` are not rendered |
109
109
  | `stores` | `name` / `key` / `type` / `default` / `values[]` (strings or `{value, label}`) / `note` | The persistence step: key name, type, default, and every enum value — never "etc." |
110
110
  | `entities` | `name` / `fields[]` (`name` / `type` / `nullable` / `unit` / `note`) / `note` | The display or computation step: the entity's business name and every field with its type, nullability, and unit |
111
111
  | `rules` | `name` / `statement` | The step that performs the conversion or applies the boundary: an instruction that can be followed verbatim, carrying every numeric value the rule can be wrong about (a coefficient, an offset, a threshold, an enum value) |
112
112
 
113
113
  **Request and response keys are written key by key.** A parameter's default and value source belong in its `default` and `source` fields (`default: 0`, `source: local storage`) and are merged into the request step; a nested key keeps its path in `name` (`data.list[].id`); a non-required parameter also states in its `note` when it is absent from the wire (e.g. “equals its default, so the request body omits it”) or that it is always sent with its default (“always sent, uses the default value”), and the request step carries that rule too so the coder does not turn a default value into a sent key; `response_fields[]` lists one field path per string (`current_temperature`, `hourly.temperatures[]`), while the envelope (code/data/message), types, nullability and missing-value handling go into the entry's `note` and the step text. An endpoint or parameter field outside the lists above, or a non-string `response_fields[]` item, is rejected by G2 because the fact base cannot carry it.
114
114
 
115
- **The request body is a field table inside the request step.** Every row carries four labelled segments in a fixed order — `field:`, `type/encoding:`, `default:`, `send:` — and the table is a top-level fenced block whose row order is the serialization key order. The send segment starts with `required` (always present), `optional` (may be absent) or `never` (never present), followed by a decidable condition such as “, not sent when it equals the default 0”; a plain `required` means a missing source value is a defect, while “, falls back to the default” means the default fills it. A value-source line follows the table for every field not fed by this page's input. Each row must also be declared in `params[]` with `in: "body"`: the path goes after `field:` (`a.b` nested, `a[].b` for an array element), the type matches the table token verbatim, and the default/source hold the same values. A table row missing from `params[]`, or a `params[]` entry missing from the table, is reported by G2 as a fact that never reached the steps. See `scenario-authoring.md`, “Request Bodies and Responses”, for the complete rule.
115
+ **The request parameters (query and body) are a field table inside the request step.** Every row carries four labelled segments in a fixed order — `field:`, `type/encoding:`, `default:`, `send:` — and the table is a top-level fenced block whose row order is the serialization key order. The send segment starts with `required` (always present), `optional` (may be absent) or `never` (never present), followed by a decidable condition such as “, not sent when it equals the default 0”; a plain `required` means a missing source value is a defect, while “, falls back to the default” means the default fills it. A value-source line follows the table for every field not fed by this page's input. Each row must also be declared in `params[]` with the same `in` (`query` or `body`): the path goes after `field:` (`a.b` nested, `a[].b` for an array element), the type matches the table token verbatim, and the default/source hold the same values. A `params[]` entry missing from the table is reported by G2 as a missing field row. See `scenario-authoring.md`, “Request Parameters and Responses”, for the complete rule.
116
116
 
117
117
  **The body language rules apply to the merged steps.** Contract-only syntax is no longer legal anywhere: no `dp`/`sp`/`px`/`dip` (with or without a number), no `#hex`, no `key=value` (write "the code field is 1001"), no framework type names, no `file:line`. Visual values are rewritten as business descriptions ("the size is large"). Data values keep their source spelling (`maxRows`, `countryName`, `temperaturePrefs`, `kmh`) because the coder must use the same names. A value the body rules forbid verbatim (`600dp`, `#FF5733`, `timezone=auto`, a framework type) is therefore rewritten, and G2 does not require it token by token.
118
118
 
@@ -180,7 +180,7 @@ Rendering rules (`scripts/render.mjs`, deterministic):
180
180
  - The H1 is always `# <title> SPEC`—**there is one space before `SPEC`**.
181
181
  - Scenario headings are always `## Scenario <N>` (one space after `##`, a digit after `Scenario`), ensuring that `countScenarios` matches them.
182
182
  - Steps always use `- 1. ` / `- 2. ` numbering, one step per item. Implementation facts are already merged into the consuming steps; the renderer prints `steps` verbatim and never appends a contract section.
183
- - A step may carry a fenced code block (the request-body field table); the block's row order defines the serialization key order.
183
+ - A step may carry a fenced code block (the request-parameter field table); the block's row order defines the serialization key order.
184
184
  - `## Android Code Reference` is always the final section, with one `- <file:line>` per entry.
185
185
  - Do not produce a `Deviations from Requirement` section.
186
186
  - The filename is `<title>-SPEC.md` (characters in `title` that are unsuitable for filenames are replaced with `-`). Note that downstream `specTitle` comes from the H1 (after trimming, `<title> SPEC`, preserving the space in the middle), while `spec_stem` comes from the filename (`<title>-SPEC`). They differ only in the separator and do not need to be aligned.
@@ -26,7 +26,7 @@ import path from "node:path";
26
26
  import { canonicalSourcePath, stableDigest } from "./behavior-model.mjs";
27
27
  import { stripJsComments, stripSourceComments } from "./lib/source-text.mjs";
28
28
 
29
- export const CONTRACT_CALLS_SCHEMA_VERSION = 2;
29
+ export const CONTRACT_CALLS_SCHEMA_VERSION = 3; // v3: `targets` is projected per (file, symbol); each target carries `target_symbols`.
30
30
  export const DEFAULT_MAX_CONTRACT_TARGETS = 128;
31
31
  const MAX_SOURCE_BYTES = 1_000_000;
32
32
 
@@ -277,7 +277,7 @@ function emptyResult(pageId) {
277
277
  omitted: [],
278
278
  source_contracts: sourceContracts,
279
279
  counts: {
280
- calls: 0, kept: 0, deferred: 0, not_contract: 0,
280
+ calls: 0, targets: 0, kept: 0, deferred: 0, not_contract: 0,
281
281
  reviewed_scope: 0, contract_path: 0, omitted: 0,
282
282
  },
283
283
  };
@@ -373,6 +373,33 @@ function callSortKey(call) {
373
373
  ].join("\u0000");
374
374
  }
375
375
 
376
+ /**
377
+ * One evidence record per (file, symbol). A service file often exposes several transport
378
+ * functions; the file-level target kept only the first symbol, so the projection expands it back.
379
+ *
380
+ * `kinds` and `signals` stay file-level summaries (the transport classification runs on the file);
381
+ * `call_sites` are narrowed to the symbol so each record still points at its own calls. A call site
382
+ * with a null `target_symbol` cannot be attributed to one symbol, so it is copied into every
383
+ * expanded record (the payload may show that site more than once).
384
+ */
385
+ function expandTargetSymbols(targets) {
386
+ const out = [];
387
+ for (const target of targets) {
388
+ const symbols = Array.isArray(target.target_symbols) && target.target_symbols.length > 0
389
+ ? [...new Set(target.target_symbols)]
390
+ : [target.target_symbol];
391
+ for (const symbol of symbols) {
392
+ out.push({
393
+ ...target,
394
+ target_symbol: symbol,
395
+ call_sites: (target.call_sites ?? []).filter(site =>
396
+ site.target_symbol === undefined || site.target_symbol === null || site.target_symbol === symbol),
397
+ });
398
+ }
399
+ }
400
+ return out;
401
+ }
402
+
376
403
  /**
377
404
  * Collect contract-only calls for one page.
378
405
  *
@@ -573,6 +600,7 @@ export function collectContractCalls({
573
600
  targets.set(target, {
574
601
  locator: target,
575
602
  target_symbol: targetSymbol,
603
+ target_symbols: [],
576
604
  platform: classification.platform,
577
605
  kinds: [...classification.kinds],
578
606
  signals: [...classification.signals],
@@ -580,11 +608,15 @@ export function collectContractCalls({
580
608
  });
581
609
  }
582
610
  const targetRecord = targets.get(target);
611
+ if (targetSymbol !== null && !targetRecord.target_symbols.includes(targetSymbol)) {
612
+ targetRecord.target_symbols.push(targetSymbol);
613
+ }
583
614
  targetRecord.kinds = [...new Set([...targetRecord.kinds, ...classification.kinds])].sort(cmp);
584
615
  targetRecord.signals = [...new Set([...targetRecord.signals, ...classification.signals])].sort(cmp);
585
616
  targetRecord.call_sites.push({
586
617
  from,
587
618
  kind,
619
+ target_symbol: targetSymbol,
588
620
  line: Number.isInteger(row.line) ? row.line : null,
589
621
  col: Number.isInteger(row.col) ? row.col : null,
590
622
  });
@@ -616,6 +648,7 @@ export function collectContractCalls({
616
648
  for (const target of kept) {
617
649
  dispose(target.locator, "kept", "contract-signal", {
618
650
  target_symbol: target.target_symbol,
651
+ target_symbols: target.target_symbols,
619
652
  kinds: target.kinds,
620
653
  signals: target.signals,
621
654
  });
@@ -623,6 +656,7 @@ export function collectContractCalls({
623
656
  for (const target of omitted) {
624
657
  dispose(target.locator, "omitted", "contract-evidence-limit", {
625
658
  target_symbol: target.target_symbol,
659
+ target_symbols: target.target_symbols,
626
660
  kinds: target.kinds,
627
661
  signals: target.signals,
628
662
  });
@@ -691,18 +725,21 @@ export function collectContractCalls({
691
725
  const sourceContracts = extractSourceContracts(contracts);
692
726
 
693
727
  const dispositionList = [...dispositions.values()].sort((a, b) => cmp(a.locator, b.locator));
728
+ const expandedKept = expandTargetSymbols(kept);
694
729
  const payload = {
695
730
  schema_version: CONTRACT_CALLS_SCHEMA_VERSION,
696
731
  page_id: pageId,
697
732
  calls: keptCalls,
698
- targets: kept,
733
+ targets: expandedKept,
699
734
  dispositions: dispositionList,
700
735
  deferred: deferredCalls,
701
736
  omitted,
702
737
  source_contracts: sourceContracts,
703
738
  counts: {
704
739
  calls: callCount,
740
+ // kept/omitted describe the file-level budget; targets counts the expanded (file, symbol) evidence.
705
741
  kept: kept.length,
742
+ targets: expandedKept.length,
706
743
  deferred: dispositionList.filter(item => item.disposition === "deferred").length,
707
744
  not_contract: dispositionList.filter(item => item.disposition === "not-contract").length,
708
745
  reviewed_scope: dispositionList.filter(item => item.disposition === "reviewed-scope").length,
@@ -832,6 +832,63 @@ function dbImplementations(db, targetPage, targetOrigin) {
832
832
  return implementations;
833
833
  }
834
834
 
835
+ /** File part of a `path:line` locator. */
836
+ function locatorFile(locator) {
837
+ const value = normalizeLocator(locator);
838
+ if (value === null) return null;
839
+ const match = /^(.*):\d+$/.exec(value);
840
+ return match === null ? value : match[1];
841
+ }
842
+
843
+ /** The name part of a `kind:name` node id. */
844
+ function pageIdName(pageId) {
845
+ const value = firstString(pageId);
846
+ return value === null ? null : value.replace(/^[^:]*:/, "");
847
+ }
848
+
849
+ /**
850
+ * Implementation identities recoverable from `declared_at` and the page-body source unit when the
851
+ * page/origin registers no `fqn` (e.g. UTG nodes for sheets/overlays carry only `declared_at`).
852
+ * The node is looked up by file + the origin/page label, so the same exact `qualified_name` +
853
+ * `file_path` contract as `explicitImplementations` still governs the match.
854
+ */
855
+ function derivedImplementations({ targetPage, targetOrigin, db }) {
856
+ if (!db || typeof db.prepare !== "function") return [];
857
+ const pageBody = targetPage?.behavior && Array.isArray(targetPage.behavior.source_units)
858
+ ? targetPage.behavior.source_units.filter(unit => unit?.role === "page-body").map(unit => unit?.locator)
859
+ : [];
860
+ const files = uniqueStrings([
861
+ locatorFile(targetOrigin?.declared_at),
862
+ locatorFile(targetPage?.declared_at),
863
+ ...pageBody.map(locatorFile),
864
+ ]);
865
+ const names = new Set(uniqueStrings([
866
+ targetOrigin?.label, targetPage?.label,
867
+ pageIdName(targetOrigin?.page_id), pageIdName(targetPage?.page_id),
868
+ ]).map(name => String(name).trim()).filter(name => name !== ""));
869
+ if (files.length === 0 || names.size === 0) return [];
870
+ let statement;
871
+ try {
872
+ statement = db.prepare("SELECT name, qualified_name, file_path FROM nodes WHERE file_path = ?");
873
+ } catch {
874
+ return [];
875
+ }
876
+ const out = [];
877
+ for (const file of files) {
878
+ let rows = [];
879
+ try { rows = statement.all(file); } catch { continue; }
880
+ for (const row of rows) {
881
+ const name = firstString(row?.name);
882
+ const qualifiedName = firstString(row?.qualified_name);
883
+ const filePath = normalizeLocator(row?.file_path);
884
+ if (name !== null && names.has(name) && qualifiedName !== null && filePath !== null) {
885
+ out.push({ qualified_name: qualifiedName, file_path: filePath });
886
+ }
887
+ }
888
+ }
889
+ return out;
890
+ }
891
+
835
892
  function readableCurrentSource(sourceProject, locator) {
836
893
  if (typeof sourceProject !== "string" || sourceProject === "" || locator === null) return false;
837
894
  try {
@@ -843,15 +900,15 @@ function readableCurrentSource(sourceProject, locator) {
843
900
  }
844
901
 
845
902
  /** Resolve only a qualified callee independently backed by the target implementation. */
846
- function implementationMatch({ item, targetPage, targetOrigin, db, sourceProject }) {
903
+ function implementationMatch({ item, targetPage, targetOrigin, db, sourceProject, implementations = null }) {
847
904
  if (dynamicDispatch(item)) return null;
848
905
  const identity = calleeIdentity(item);
849
906
  if (identity === null || !readableCurrentSource(sourceProject, identity.file_path)) return null;
850
- const implementations = [
907
+ const pool = implementations ?? [
851
908
  ...explicitImplementations(targetPage, targetOrigin),
852
909
  ...dbImplementations(db, targetPage, targetOrigin),
853
910
  ];
854
- return implementations.some(implementation =>
911
+ return pool.some(implementation =>
855
912
  implementation.qualified_name === identity.qualified_name
856
913
  && implementation.file_path === identity.file_path)
857
914
  ? identity
@@ -896,9 +953,18 @@ function outboundFor({ pages, pageById, db, query, sourceProject }) {
896
953
  const fromDb = dbCallees(db, edge);
897
954
  const items = [...(fromQuery?.items ?? []), ...(fromDb?.items ?? [])];
898
955
  const partial = [fromQuery, fromDb].find(result => result?.status === "partial") ?? null;
956
+ const implementations = [
957
+ ...explicitImplementations(targetPage, targetOrigin),
958
+ ...dbImplementations(db, targetPage, targetOrigin),
959
+ ];
960
+ // The derived fallback exists only for origins that register no FQN. With an FQN present,
961
+ // a same-named node in the declared_at file must not weaken the exact identity check.
962
+ if (targetQualifiedNames(targetPage, targetOrigin).length === 0) {
963
+ implementations.push(...derivedImplementations({ targetPage, targetOrigin, db }));
964
+ }
899
965
  const matches = items.map(item => ({
900
966
  item,
901
- implementation: implementationMatch({ item, targetPage, targetOrigin, db, sourceProject }),
967
+ implementation: implementationMatch({ item, targetPage, targetOrigin, db, sourceProject, implementations }),
902
968
  }));
903
969
  const validated = matches.find(match => match.implementation !== null) ?? null;
904
970
  const dynamic = items.some(dynamicDispatch);
@@ -906,7 +972,9 @@ function outboundFor({ pages, pageById, db, query, sourceProject }) {
906
972
  const status = resolved ? "resolved" : "partial";
907
973
  const reason = status === "resolved" ? null
908
974
  : partial?.reason ?? (items.length === 0 ? "outbound-callees-missing"
909
- : dynamic && validated === null ? "outbound-dynamic-dispatch-unresolved" : "outbound-target-unresolved");
975
+ : dynamic && validated === null ? "outbound-dynamic-dispatch-unresolved"
976
+ : implementations.length === 0 ? "outbound-implementation-unavailable"
977
+ : "outbound-target-unresolved");
910
978
  const record = {
911
979
  source: page.page_id,
912
980
  target: edge.target,
@@ -108,6 +108,125 @@ function factPattern(token) {
108
108
  return null;
109
109
  }
110
110
 
111
+ /**
112
+ * Parameters that must appear in the four-label field table: `query` and `body`.
113
+ * A path/header-only endpoint stays prose (its values are positional or metadata, not selectable fields).
114
+ *
115
+ * @param {object|null|undefined} contracts
116
+ * @returns {object[]}
117
+ */
118
+ function endpointTableParams(contracts) {
119
+ if (contracts === null || typeof contracts !== "object" || Array.isArray(contracts)) return [];
120
+ const endpoints = Array.isArray(contracts.endpoints) ? contracts.endpoints : [];
121
+ const out = [];
122
+ for (const endpoint of endpoints) {
123
+ if (endpoint === null || typeof endpoint !== "object" || Array.isArray(endpoint)) continue;
124
+ const params = Array.isArray(endpoint.params) ? endpoint.params : [];
125
+ for (const param of params) {
126
+ if (param === null || typeof param !== "object" || Array.isArray(param)) continue;
127
+ if ((param.in === "query" || param.in === "body") && typeof param.name === "string" && param.name.trim() !== "") out.push(param);
128
+ }
129
+ }
130
+ return out;
131
+ }
132
+
133
+ /** The field name of one field-table row, or "" when the line is not a row. */
134
+ function fieldTableRowName(line) {
135
+ const match = /\bfield\s*[::]\s*([^\s ]+)/.exec(line);
136
+ return match === null ? "" : match[1];
137
+ }
138
+
139
+ const BODY_TABLE_LABELS = ["field:", "type/encoding:", "default:", "send:"];
140
+ // Word boundaries keep prose such as "response field:" from counting as a table label.
141
+ const BODY_TABLE_LABEL_RES = [
142
+ /\bfield\s*[::]/,
143
+ /\btype\/encoding\s*[::]/,
144
+ /\bdefault\s*[::]/,
145
+ /\bsend\s*[::]/,
146
+ ];
147
+ const BODY_TABLE_ROW_RE = /\bfield\s*[::]/;
148
+ const BODY_TABLE_SEND_RE = /\bsend\s*[::]/;
149
+ const BODY_SEND_VALUES = ["required", "optional", "never"];
150
+
151
+ /**
152
+ * A declared request (`query` / `body`) must be written as the four-label field table
153
+ * (`field:` / `type/encoding:` / `default:` / `send:`).
154
+ *
155
+ * Checked only for scenarios that declare at least one `in: "query"` or `in: "body"` parameter,
156
+ * so a path/header-only endpoint is never required to carry a table.
157
+ *
158
+ * @param {object|null|undefined} contracts
159
+ * @param {unknown} steps
160
+ * @returns {string[]} one entry per missing label, row, or send rule
161
+ */
162
+ function missingFieldTable(contracts, steps) {
163
+ const params = endpointTableParams(contracts);
164
+ if (params.length === 0) return [];
165
+ const text = (Array.isArray(steps) ? steps : []).map((step) => String(step ?? "")).join("\n");
166
+ const missing = [];
167
+ for (let i = 0; i < BODY_TABLE_LABELS.length; i++) {
168
+ if (!BODY_TABLE_LABEL_RES[i].test(text)) missing.push(`missing "${BODY_TABLE_LABELS[i]}"`);
169
+ }
170
+ if (missing.length > 0) return missing;
171
+ const rows = text.split(/\r?\n/).filter((line) => BODY_TABLE_ROW_RE.test(line) && BODY_TABLE_SEND_RE.test(line));
172
+ const rowNames = new Set(rows.map(fieldTableRowName).filter((name) => name !== ""));
173
+ for (const param of params) {
174
+ const name = param.name.trim();
175
+ if (!rowNames.has(name)) missing.push(`missing field row "${name}"`);
176
+ }
177
+ for (const line of rows) {
178
+ const name = fieldTableRowName(line);
179
+ const send = /\bsend\s*[::]\s*([^\s ]+)/.exec(line);
180
+ if (send === null || !BODY_SEND_VALUES.some((value) => send[1].startsWith(value))) {
181
+ missing.push(`row "${name === "" ? "?" : name}" send segment does not start with ${BODY_SEND_VALUES.join("/")}`);
182
+ }
183
+ }
184
+ return missing;
185
+ }
186
+
187
+ const BODY_REQUEST_VERB_RE = /\b(?:POST|PUT|PATCH)\b/i;
188
+ const BODY_REQUEST_URL_RE = /https?:\/\//i;
189
+ const BODY_REQUEST_LANGUAGE_RE = /(请求体|请求参数|\bbody\b|表单|request\s+parameters?|\bforms?\b)/i;
190
+ const BODY_REQUEST_NO_BODY_RE = /(不携带[^。;;,,\n]{0,12}请求体|无请求体|不带请求体|没有请求体|不携带[^。;;,,\n]{0,12}请求参数|无请求参数|不带请求参数|没有请求参数|no\s+(?:request\s+)?body|without\s+(?:a\s+)?(?:request\s+)?body|does\s+not\s+(?:carry|send|include)\s+(?:a\s+)?(?:request\s+)?body)/i;
191
+
192
+ /**
193
+ * Warnings for a body-shaped request described in steps without a declared body contract.
194
+ *
195
+ * The hard check (`missingFieldTable`) owns scenarios that declare `in: "query"`/`in: "body"`
196
+ * params. This warning targets the case where no body contract is projected at all (e.g. operations
197
+ * owned by `external`, which the ledger does not project): the steps still describe a request body
198
+ * (or carry a request-parameter field table) that no `contracts.endpoints[]` backs. Warn-only
199
+ * because prose detection is a heuristic; an explicit "不携带请求体" statement closes it.
200
+ *
201
+ * @param {object|null|undefined} contracts
202
+ * @param {unknown} steps
203
+ * @returns {string[]}
204
+ */
205
+ function bodyRequestWarnings(contracts, steps) {
206
+ if (endpointTableParams(contracts).length > 0) return [];
207
+ const endpoints = contracts !== null && typeof contracts === "object" && !Array.isArray(contracts)
208
+ && Array.isArray(contracts.endpoints) ? contracts.endpoints : [];
209
+ const hasEndpoints = endpoints.length > 0;
210
+ const out = [];
211
+ for (const raw of Array.isArray(steps) ? steps : []) {
212
+ const step = String(raw ?? "");
213
+ if (BODY_REQUEST_NO_BODY_RE.test(step)) continue;
214
+ const hasTable = step.split(/\r?\n/).some((line) => BODY_TABLE_ROW_RE.test(line) && BODY_TABLE_SEND_RE.test(line));
215
+ if (hasTable) {
216
+ out.push(hasEndpoints
217
+ ? "steps carry a request parameter field table but contracts.endpoints[].params declares no matching query/body parameter"
218
+ : "steps carry a request parameter field table but scenarios[].contracts.endpoints is not declared");
219
+ continue;
220
+ }
221
+ if (BODY_REQUEST_VERB_RE.test(step) && BODY_REQUEST_URL_RE.test(step) && BODY_REQUEST_LANGUAGE_RE.test(step)) {
222
+ out.push(hasEndpoints
223
+ ? "steps describe a request body but contracts.endpoints[].params has no matching body parameter"
224
+ : "steps describe a request body but scenarios[].contracts.endpoints is not declared");
225
+ }
226
+ }
227
+ return Array.from(new Set(out));
228
+ }
229
+
111
230
  /**
112
231
  * Fact tokens from a scenario's `contracts` that never made it into the merged steps.
113
232
  *
@@ -464,6 +583,31 @@ function runGates(opts, { partial }) {
464
583
  hint: "Write each fact naturally into the step that consumes it; keep the existing step count and order",
465
584
  });
466
585
  }
586
+
587
+ // A declared request (`query` / `body`) must be a four-label field table
588
+ // (spec-template.md). Only scenarios that declare those parameters are checked; a
589
+ // path/header-only endpoint is not required to carry a table.
590
+ const missingFieldTableIssues = missingFieldTable(scenarioDraft?.contracts, scenarioDraft?.steps);
591
+ if (missingFieldTableIssues.length > 0) {
592
+ failures.push({
593
+ gate: "G2",
594
+ spec_id,
595
+ message: `scenario ${scenarioNumber} declares query/body parameters but its steps lack the four-label field table: ${missingFieldTableIssues.join("; ")}`,
596
+ hint: "Write query and body parameters as the four-label table (field:/type/encoding:/default:/send:), one row per field, with send: starting with required/optional/never followed by the condition",
597
+ });
598
+ }
599
+
600
+ // A body-shaped request described in steps without any body contract (e.g. an `external`
601
+ // operation that the ledger does not project) is a warning, not a failure: prose detection
602
+ // is a heuristic and "不携带请求体" closes it.
603
+ for (const alert of bodyRequestWarnings(scenarioDraft?.contracts, scenarioDraft?.steps)) {
604
+ warnings.push({
605
+ gate: "G2",
606
+ spec_id,
607
+ message: `scenario ${scenarioNumber}: ${alert}`,
608
+ hint: "If the request truly has no body, state 不携带请求体 in the steps; otherwise add the endpoint/body parameters or explain why they are not projected",
609
+ });
610
+ }
467
611
  }
468
612
  for (let i = draftScenarios.length; i < zones.scenarios.length; i++) {
469
613
  failures.push({
@@ -306,18 +306,18 @@ Review every lifecycle-signal candidate and choose one of three: a user-observab
306
306
 
307
307
  Timing wording follows the source: "refreshes immediately" when it takes effect on completion, "re-read on return" or "re-read on next entry" when it waits until the page is visible again — never mix the two. An axis scenario's trigger sequence starts from the timing event, and its last step lands on an assertable observable outcome.
308
308
 
309
- ### Request Bodies and Responses
309
+ ### Request Parameters and Responses
310
310
 
311
- When a scenario performs a network request, write the request body as a **tree-shaped field table inside the request step that sends it**. Write the response key by key.
311
+ When a scenario performs a network request, write the request parameters (`query` and `body`) as a **tree-shaped field table inside the request step that sends it**; list path parameters and request headers explicitly with their `in`. Write the response key by key.
312
312
 
313
313
  The table has four fixed, labelled segments in a fixed order and is a top-level fenced code block, so every renderer keeps its line breaks:
314
314
 
315
315
  ```text
316
- <Request body name>
316
+ <Request parameter name>
317
317
  ├─ field:<path> type/encoding:<type> default:<value> send:<rule>
318
318
  ```
319
319
 
320
- - **Write every key**: list each key of the source's request-body construction, including keys that are **always the default**, **always sent**, or **never sent on this page**; dropping one is a failure, and fields may not be picked by scenario. **A field with a default is not necessarily sent** — whether it appears must be confirmed from the source's serializer or request-construction site.
320
+ - **Write every key**: list each key of the source's request construction (`query` or `body`), including keys that are **always the default**, **always sent**, or **never sent on this page**; dropping one is a failure, and fields may not be picked by scenario. **A field with a default is not necessarily sent** — whether it appears must be confirmed from the source's serializer or request-construction site.
321
321
  - `field:` a top-level field is written with its plain name; a nested leaf is `a.b`; an array element is `a[].b`; the array itself is `a[]` (type `array<T>`). A parent object appears together with its children; give it its own `object` row only when the parent itself carries a send rule.
322
322
  - `type/encoding:` only the closed vocabulary `string`, `int`, `int64`, `float`, `double`, `bool`, `object`, `array<T>`; put a time format, a byte encoding or a radix in parentheses (`string(yyyy-MM-dd HH:mm)`, `string(Base64)`, `int(>=1)`). Never write "text" or "number" as loose prose, and keep the token byte-identical to the contract's `type`.
323
323
  - `default:` `—` means the field has no default value; strings are quoted; write only the value, never whether the key is sent.
@@ -325,22 +325,22 @@ The table has four fixed, labelled segments in a fixed order and is a top-level
325
325
  - `required`: the key is always present. Stop there when a missing source value is a defect; add ", falls back to the default" when the default fills it, and name the source or failure when it matters, for example ", falls back to the default unknown when it cannot be read";
326
326
  - `optional`: the key may be absent, immediately followed by a decidable condition written as ", not sent when <condition>" or ", sent only when <condition>", for example ", not sent when it has no value", ", not sent when the array is empty", ", not sent when it equals the default 0", ", not sent when the source cannot be determined", ", not sent when the user specifies no insert position";
327
327
  - `never`: never appears; the field stays in the data model and is skipped when serializing.
328
- - Whether a key is sent follows the source's serializer or request-construction site: a nullable field, a field with a default, and a model-required field do not mean "always sent"; a field with a default may be omitted when it equals the default, and may also always be sent.
328
+ - Whether a key is sent follows the source's serializer or request-construction site: a nullable field, a field with a default, and a model-required field do not mean "always sent", and `"nullable": false` only means the value cannot be empty. **None of these is equivalent to `required`** — a field with a default may be omitted when it equals the default, and may also always be sent.
329
329
  - The condition must be writable as a single `if`: name a concrete condition such as "has no value", "the array is empty", "equals the default", "the control is off", "nothing is selected", "cannot be read", "the source cannot be determined". Never write "as needed", "depending on", "generally", "maybe"; list every condition separately instead of "except in special cases".
330
330
  - `required` and `optional` differ only in whether the key is always present; the `default:` segment says what value fills a missing value and never whether the key appears, so the two segments never substitute for each other. A boolean that uses `false` for "the user set nothing" must say "not sent when it equals the default false", not "not sent when it has no value".
331
331
  - When writing a condition, "no value" means unassigned or `null`; for strings and arrays a length of 0 also counts as no value; `0` and `false` count as values.
332
- - Start the step with an executable action, not a caption such as "the structure is as follows": "the request body is serialized field by field from the table below and then sent; the key order follows the table's row order and whether a key appears follows the send segment".
332
+ - Start the step with an executable action, not a caption such as "the structure is as follows": "the request parameters are serialized field by field from the table below and then sent; the key order follows the table's row order and whether a key appears follows the send segment".
333
333
  - Separate the segments with at least one space: the path after `field:` must not be glued to the next segment, or the path and `default:` read as a `file:line`; write `default:false`, never `default=false`; no table line starts with `#`.
334
- - Name the table root in business terms (for example "sync request body"), never with the request type name from the source.
334
+ - Name the table root in business terms (for example "sync request body" or "weather query parameters"), never with the request type name from the source.
335
335
  - When a field's value does not come from this page's input (local storage, the previous response, a fixed value, a computed value), add one line after the table naming each such field, for example: "Value sources: `userId` is the current signed-in user number in local storage, `deviceId` is the device identifier in local storage, and `payload` is the pending-queue record count." Fields fed by page input need no entry.
336
336
 
337
- **Relation to the contracts.** Each table row is also declared once in that scenario's `contracts.endpoints[].params` with `in: "body"`, byte-identical. The contracts are the audited fact base: G2 compares every parameter name, default and value source against the step text, and one missing token fails the gate. The table is what the reader and the downstream coder see. Query parameters, path parameters and headers are listed the same way with their own `in`; key names, defaults and fixed values follow the source — never guess, and never drop a key that has a default.
337
+ **Relation to the contracts.** Each table row is also declared once in that scenario's `contracts.endpoints[].params` with `in: "query"` or `in: "body"`, byte-identical. The contracts are the audited fact base: G2 compares every parameter name, default and value source against the step text, and one missing token fails the gate. The table is what the reader and the downstream coder see. Path parameters and headers are listed with their own `in` (no table required); key names, defaults and fixed values follow the source — never guess, and never drop a key that has a default.
338
338
 
339
339
  **Response.** List one field path per string in `response_fields[]` (`current_temperature`, `hourly.temperatures[]`); the envelope (code/data/message), types, nullability and the handling of a missing or default-valued field go into that endpoint's `note` and are merged into the step — never into a `response_fields` element, because G2 requires each element to appear verbatim in the step.
340
340
 
341
341
  **G2 checks verbatim.** A method, URL, parameter name, parameter default, value source or response field present in the contracts but absent from the steps fails the gate. The envelope, types, nullability and missing-value handling are outside that check and must still be written into the steps, not left in `contracts` alone.
342
342
 
343
- When the same request appears in several scenarios, each scenario repeats the complete table; never write "same as above" or "see scenario 1". The send condition lives only in the table; the steps state the server behaviour or the user-visible result once the condition holds. When the body is an object or an array, state the nesting and every child key; never write "other fields", "etc.", or a single sample value.
343
+ When the same request appears in several scenarios, each scenario repeats the complete table; never write "same as above" or "see scenario 1". The send condition lives only in the table; the steps state the server behaviour or the user-visible result once the condition holds. When the body (or a nested query object) is an object or an array, state the nesting and every child key; never write "other fields", "etc.", or a single sample value.
344
344
 
345
345
  ### Platform-Neutral Body Text
346
346
 
@@ -436,9 +436,9 @@ Before submission, confirm all of the following:
436
436
  - Numeric inputs state integer versus decimal and whether a negative value is accepted, with no “accepts digits only” standing in for the type; the decimal places, bounds, whitespace and invalid-character handling the source implements are written out, and no unimplemented constraint is written as existing behavior.
437
437
  - Every data boundary names both sides — present (source and destination) and absent (what it does not carry, write or send, and where empty, missing or default goes); entries over one data set line up item by item, absent items are written out, and absence is never written as -1, 0 or an empty string.
438
438
  - Every value answers where it comes from (including the field’s origin in the consuming code), how it is processed (including the inputs that change the result and the difference after they change), and where it is consumed; missing any of the three leaves the scenario incomplete.
439
- - Every branch states how its condition is determined and both outcomes; every step traces to a source location or an evidence entry; whether a key is sent follows the source serializer, never a nullable field, a default value, or a model-required flag.
439
+ - Every branch states how its condition is determined and both outcomes; every step traces to a source location or an evidence entry; whether a key is sent follows the source serializer, never nullability (for example `"nullable": false`), a default value, or a model-required flag.
440
440
  - Scenarios that create, read, update, or delete data, or synchronize state or data, list every affected piece of data and how it changes, with no vague “related data updates in sync.”
441
- - Network scenarios write the request body as a field table inside the sending step, each row carrying the four labelled segments `field:`, `type/encoding:`, `default:` and `send:`; declare the same fields in `contracts.endpoints[].params`, list every value source that is not page input, start every send segment with `required`/`optional`/`never` and follow it with a decidable condition (never "as needed" or "depending on"), describe the response structure as fully as possible, and keep all of these facts in that same step.
441
+ - Network scenarios write the request parameters (`query` and `body`) as a field table inside the sending step, each row carrying the four labelled segments `field:`, `type/encoding:`, `default:` and `send:`; path parameters and headers are listed with their `in` (no table required); declare the same fields in `contracts.endpoints[].params`, list every value source that is not page input, start every send segment with `required`/`optional`/`never` and follow it with a decidable condition (never "as needed" or "depending on"), describe the response structure as fully as possible, and keep all of these facts in that same step.
442
442
  - No vague phrase such as “handle all other errors uniformly” substitutes for concrete branches.
443
443
  - Every scenario is independently readable, with no abbreviated cross-scenario references and no unsupported copy, branches, thresholds, or outcomes added to fill gaps.
444
444
  - Each scenario is exactly one normal or one edge/boundary case, with no success/failure mix.