@kensnzk/koyu 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.ja.md +14 -10
  2. package/README.md +16 -13
  3. package/dist/cli.js +162 -84
  4. package/dist/cli.js.map +1 -1
  5. package/dist/core/derive.d.ts +264 -0
  6. package/dist/core/derive.d.ts.map +1 -0
  7. package/dist/core/derive.js +576 -0
  8. package/dist/core/derive.js.map +1 -0
  9. package/dist/{check.d.ts → core/diagnose.d.ts} +15 -15
  10. package/dist/core/diagnose.d.ts.map +1 -0
  11. package/dist/{check.js → core/diagnose.js} +269 -223
  12. package/dist/core/diagnose.js.map +1 -0
  13. package/dist/{diff.d.ts → core/diff.d.ts} +3 -2
  14. package/dist/core/diff.d.ts.map +1 -0
  15. package/dist/{diff.js → core/diff.js} +89 -43
  16. package/dist/core/diff.js.map +1 -0
  17. package/dist/{fabric.d.ts → core/fabric.d.ts} +5 -3
  18. package/dist/core/fabric.d.ts.map +1 -0
  19. package/dist/{fabric.js → core/fabric.js} +12 -11
  20. package/dist/core/fabric.js.map +1 -0
  21. package/dist/{graph.d.ts → core/graph.d.ts} +2 -4
  22. package/dist/core/graph.d.ts.map +1 -0
  23. package/dist/{graph.js → core/graph.js} +53 -54
  24. package/dist/core/graph.js.map +1 -0
  25. package/dist/core/light.d.ts +24 -0
  26. package/dist/core/light.d.ts.map +1 -0
  27. package/dist/{light.js → core/light.js} +17 -12
  28. package/dist/core/light.js.map +1 -0
  29. package/dist/{model.d.ts → core/model.d.ts} +178 -18
  30. package/dist/core/model.d.ts.map +1 -0
  31. package/dist/{model.js → core/model.js} +307 -68
  32. package/dist/core/model.js.map +1 -0
  33. package/dist/core/parse.d.ts.map +1 -0
  34. package/dist/{parse.js → core/parse.js} +546 -133
  35. package/dist/core/parse.js.map +1 -0
  36. package/dist/{poly.d.ts → core/poly.d.ts} +3 -6
  37. package/dist/core/poly.d.ts.map +1 -0
  38. package/dist/{poly.js → core/poly.js} +8 -13
  39. package/dist/core/poly.js.map +1 -0
  40. package/dist/core/site.d.ts.map +1 -0
  41. package/dist/{site.js → core/site.js} +2 -2
  42. package/dist/core/site.js.map +1 -0
  43. package/dist/core/tolerance.d.ts +26 -0
  44. package/dist/core/tolerance.d.ts.map +1 -0
  45. package/dist/core/tolerance.js +48 -0
  46. package/dist/core/tolerance.js.map +1 -0
  47. package/dist/{vertical.d.ts → core/vertical.d.ts} +48 -12
  48. package/dist/core/vertical.d.ts.map +1 -0
  49. package/dist/{vertical.js → core/vertical.js} +53 -105
  50. package/dist/core/vertical.js.map +1 -0
  51. package/dist/core/vocabulary.d.ts +40 -0
  52. package/dist/core/vocabulary.d.ts.map +1 -0
  53. package/dist/core/vocabulary.js +176 -0
  54. package/dist/core/vocabulary.js.map +1 -0
  55. package/dist/{axo.d.ts → draw/axo.d.ts} +1 -1
  56. package/dist/draw/axo.d.ts.map +1 -0
  57. package/dist/{axo.js → draw/axo.js} +53 -81
  58. package/dist/draw/axo.js.map +1 -0
  59. package/dist/draw/index.d.ts +3 -0
  60. package/dist/draw/index.d.ts.map +1 -0
  61. package/dist/draw/index.js +11 -0
  62. package/dist/draw/index.js.map +1 -0
  63. package/dist/draw/plan.d.ts +10 -0
  64. package/dist/draw/plan.d.ts.map +1 -0
  65. package/dist/draw/plan.js +284 -0
  66. package/dist/draw/plan.js.map +1 -0
  67. package/dist/index.d.ts +16 -11
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +55 -12
  70. package/dist/index.js.map +1 -1
  71. package/dist/mcp.js +112 -50
  72. package/dist/mcp.js.map +1 -1
  73. package/dist/parse-file.d.ts +1 -1
  74. package/dist/parse-file.d.ts.map +1 -1
  75. package/dist/parse-file.js +19 -4
  76. package/dist/parse-file.js.map +1 -1
  77. package/dist/validate/access.d.ts +6 -0
  78. package/dist/validate/access.d.ts.map +1 -0
  79. package/dist/validate/access.js +248 -0
  80. package/dist/validate/access.js.map +1 -0
  81. package/dist/validate/envelope.d.ts +4 -0
  82. package/dist/validate/envelope.d.ts.map +1 -0
  83. package/dist/validate/envelope.js +55 -0
  84. package/dist/validate/envelope.js.map +1 -0
  85. package/dist/validate/index.d.ts +60 -0
  86. package/dist/validate/index.d.ts.map +1 -0
  87. package/dist/validate/index.js +77 -0
  88. package/dist/validate/index.js.map +1 -0
  89. package/dist/validate/light.d.ts +6 -0
  90. package/dist/validate/light.d.ts.map +1 -0
  91. package/dist/validate/light.js +28 -0
  92. package/dist/validate/light.js.map +1 -0
  93. package/dist/validate/runs.d.ts +16 -0
  94. package/dist/validate/runs.d.ts.map +1 -0
  95. package/dist/validate/runs.js +60 -0
  96. package/dist/validate/runs.js.map +1 -0
  97. package/dist/validate/site.d.ts +6 -0
  98. package/dist/validate/site.d.ts.map +1 -0
  99. package/dist/validate/site.js +63 -0
  100. package/dist/validate/site.js.map +1 -0
  101. package/editors/vscode/.vscodeignore +2 -0
  102. package/editors/vscode/README.md +28 -0
  103. package/editors/vscode/extension.js +150 -0
  104. package/editors/vscode/language-configuration.json +19 -0
  105. package/editors/vscode/package.json +57 -0
  106. package/editors/vscode/syntaxes/koyu.tmLanguage.json +226 -0
  107. package/examples/basement/main.muro +3 -3
  108. package/examples/complex/main.muro +1 -1
  109. package/examples/complex/podium.muro +1 -1
  110. package/examples/complex/site.muro +6 -6
  111. package/examples/house/L2.muro +1 -1
  112. package/examples/house/main.muro +2 -2
  113. package/examples/house/site.muro +4 -4
  114. package/examples/house.muro +7 -7
  115. package/examples/mansion.muro +3 -3
  116. package/examples/office.muro +4 -4
  117. package/examples/steps/01-one-room.muro +1 -1
  118. package/examples/steps/02-two-rooms.muro +1 -1
  119. package/examples/steps/03-door.muro +1 -1
  120. package/examples/steps/04-exterior.muro +2 -2
  121. package/examples/steps/05-two-storeys.muro +2 -2
  122. package/examples/steps/06-finished.muro +3 -3
  123. package/examples/tower/L2.muro +1 -1
  124. package/examples/tower/main.muro +1 -1
  125. package/examples/tower/site.muro +4 -4
  126. package/examples/twin/main.muro +2 -2
  127. package/examples/twin/podium.muro +4 -4
  128. package/examples/twin/site.muro +8 -8
  129. package/examples/two-rooms.canonical.json +6 -4
  130. package/examples/two-rooms.muro +3 -3
  131. package/package.json +18 -3
  132. package/src/cli.ts +173 -83
  133. package/src/core/derive.ts +869 -0
  134. package/src/{check.ts → core/diagnose.ts} +313 -235
  135. package/src/{diff.ts → core/diff.ts} +91 -43
  136. package/src/{fabric.ts → core/fabric.ts} +22 -12
  137. package/src/{graph.ts → core/graph.ts} +64 -63
  138. package/src/core/light.ts +69 -0
  139. package/src/{model.ts → core/model.ts} +361 -74
  140. package/src/{parse.ts → core/parse.ts} +618 -135
  141. package/src/{poly.ts → core/poly.ts} +8 -16
  142. package/src/{site.ts → core/site.ts} +2 -2
  143. package/src/core/tolerance.ts +55 -0
  144. package/src/{vertical.ts → core/vertical.ts} +73 -116
  145. package/src/core/vocabulary.ts +210 -0
  146. package/src/{axo.ts → draw/axo.ts} +51 -94
  147. package/src/draw/index.ts +11 -0
  148. package/src/draw/plan.ts +344 -0
  149. package/src/index.ts +201 -34
  150. package/src/mcp.ts +119 -50
  151. package/src/parse-file.ts +19 -5
  152. package/src/validate/access.ts +291 -0
  153. package/src/validate/envelope.ts +59 -0
  154. package/src/validate/index.ts +107 -0
  155. package/src/validate/light.ts +43 -0
  156. package/src/validate/runs.ts +87 -0
  157. package/src/validate/site.ts +84 -0
  158. package/dist/axo.d.ts.map +0 -1
  159. package/dist/axo.js.map +0 -1
  160. package/dist/check.d.ts.map +0 -1
  161. package/dist/check.js.map +0 -1
  162. package/dist/diff.d.ts.map +0 -1
  163. package/dist/diff.js.map +0 -1
  164. package/dist/fabric.d.ts.map +0 -1
  165. package/dist/fabric.js.map +0 -1
  166. package/dist/graph.d.ts.map +0 -1
  167. package/dist/graph.js.map +0 -1
  168. package/dist/light.d.ts +0 -15
  169. package/dist/light.d.ts.map +0 -1
  170. package/dist/light.js.map +0 -1
  171. package/dist/model.d.ts.map +0 -1
  172. package/dist/model.js.map +0 -1
  173. package/dist/parse.d.ts.map +0 -1
  174. package/dist/parse.js.map +0 -1
  175. package/dist/plan.d.ts +0 -10
  176. package/dist/plan.d.ts.map +0 -1
  177. package/dist/plan.js +0 -354
  178. package/dist/plan.js.map +0 -1
  179. package/dist/poly.d.ts.map +0 -1
  180. package/dist/poly.js.map +0 -1
  181. package/dist/site.d.ts.map +0 -1
  182. package/dist/site.js.map +0 -1
  183. package/dist/vertical.d.ts.map +0 -1
  184. package/dist/vertical.js.map +0 -1
  185. package/src/light.ts +0 -63
  186. package/src/plan.ts +0 -472
  187. /package/dist/{parse.d.ts → core/parse.d.ts} +0 -0
  188. /package/dist/{site.d.ts → core/site.d.ts} +0 -0
@@ -5,15 +5,17 @@
5
5
  // 吹抜け (type:void) はこの不変量の宣言的な免除である。
6
6
  //
7
7
  // 診断契約 (ADR-0016): 一次形式は checkDiagnostics の Diagnostic[] — code / severity /
8
- // 日本語本文 / 出所 / 対象パス。check は互換層で、従来の文字列 (位置接頭辞つき) を組み立てる。
8
+ // 本文 / 出所 / 対象パス。check は互換層で、従来の文字列 (位置接頭辞つき) を組み立てる。
9
9
  // severity はコードの不変属性 — 重さを変えたくなったら新コードを切る。
10
- import { placeBand, placeOpening, planOverlap, segmentsFor, segmentLength, envelopeGaps, drawnCut, spacesOverlap, } from "./graph.js";
11
- import { heff, isSemiOutdoor, levelsSorted, columnSites, columnsFor, pointInPolygon, rectToPoly, regionOf, srcRef, polygonAreaM2, polygonSelfIntersection, shapeEscapesPolygon, } from "./model.js";
12
- import { cutsInWindow } from "./poly.js";
10
+ import { placeBand, placeOpening, planOverlap, segmentsFor, spacesOverlap, } from "./graph.js";
11
+ import { heff, isSemiOutdoor, levelsSorted, SUPPORTED_LANGUAGE_VERSIONS, columnSites, openingIdentity, regionOf, columnsFor, pointInPolygon, rectToPoly, srcRef, polygonSelfIntersection, isOutside, isVoid } from "./model.js";
12
+ import { ASSET_ELEM, attrSpec, isNamespaced } from "./vocabulary.js";
13
13
  import { runDecls, runIssues } from "./vertical.js";
14
14
  /**
15
- * 診断コードの台帳 — 全コードと規範severity。specの表 (semantics.md §5) とテストで一致を守る。
15
+ * 診断コードの台帳 — 全コードと規範severity。公開文書の表 (docs/reference/diagnostics/index.md) とテストで一致を守る。
16
16
  * BND07 は欠番 — 「接しているのに境界が無い」警告はADR-0014 (既定境界) で廃止された。
17
+ * HGT03・HGT04・HGT05・RUN04 も欠番 — この四つは「高さがどうか」「縦動線がどうか」ではなく
18
+ * 「形を作るのに必要な情報が書かれていない」という一つの話であり、SUF01-04 へ合流した (ADR-0034)。
17
19
  * SYN01 は構文・合成エラー (SourceError) の写し — checkは例外を診断にしない。CLIの check --json だけが写す。
18
20
  */
19
21
  export const DIAGNOSTIC_CODES = {
@@ -53,37 +55,35 @@ export const DIAGNOSTIC_CODES = {
53
55
  ZON02: "warning", // ゾーンと同パスの空間
54
56
  HGT01: "error", // 上階への食い込み (高さ不変量違反)
55
57
  HGT02: "error", // 部分吹抜けの被覆不足
56
- HGT03: "warning", // 上階slab未宣言で高さ検査ができない
57
- HGT04: "warning", // 天井高不明で高さ検査ができない
58
- HGT05: "warning", // レベルが特定できない領域つき空間
58
+ SUF01: "error", // 天井高が決まらず、天井も屋根も生成できない (ADR-0034)
59
+ SUF02: "error", // レベルが特定できず、立体が一つも生成できない
60
+ SUF03: "warning", // レベルに slab が無く、床が一枚も生成されない
61
+ SUF04: "warning", // 縦動線の宣言に対して形が一つも生成されない
59
62
  SIT01: "error", // 敷地形状の重複頂点
60
63
  SIT02: "error", // 敷地形状の自己交差
61
- SIT03: "error", // 建物の敷地形状からのはみ出し
62
64
  SIT04: "warning", // 対応するゾーンの無いpolygon
63
- SIT05: "warning", // 敷地面積の宣言と導出の食い違い
64
65
  UID01: "error", // 数字だけのuid (ADR-0015)
65
66
  UID02: "error", // 空白を含むuid
66
67
  UID03: "error", // uidの重複
68
+ UID04: "error", // 含む対象の中で name が重複 (開口・seg・area・柱の同一性 — ADR-0039)
67
69
  ATT01: "error", // 解釈される属性の値が数値でない (ADR-0028)
68
70
  ATT02: "error", // 解釈される属性の値が台帳の語彙にない (ADR-0028)
71
+ ATT03: "error", // 台帳に無い属性キー — 名前空間が無い (ADR-0033)
69
72
  DAY01: "error", // daylightの値が 0/1 以外 (ADR-0020)
70
73
  RUN01: "error", // 一つの空間に縦動線の宣言が複数 (ADR-0021)
71
74
  RUN02: "error", // 縦動線の値が上る向き (N/E/S/W) でない
72
75
  RUN03: "error", // 縦動線の領域が矩形一つでない / レベルが不明
73
- RUN04: "warning", // 上にレベルが無く縦動線の形が生成できない
74
76
  RUN05: "error", // form の値が不正、または形が決まらない
75
- RUN06: "warning", // 導出された段の寸法が窮屈 (書かないが検査する)
76
- RUN07: "warning", // 導出された勾配が宣言・常用域から外れる
77
- RUN08: "warning", // 縦動線の形はあるが上下を繋ぐ垂直境界が無い
78
77
  LIN01: "error", // 描かれた線が二つの空間を分離しない (ADR-0022)
79
78
  LIN02: "error", // 垂直境界に描かれた線
80
79
  LIN03: "warning", // 描かれた線が何も切っていない
81
- ENV01: "warning", // 外皮に穴 — 何にも面していない外周 (ADR-0025)
82
80
  COL01: "warning", // 柱の宣言に対して立つ柱が0本 (ADR-0023)
83
81
  COL02: "warning", // 同じ通りの交点に複数の柱宣言が重なる (先の宣言が勝つ)
84
82
  VER01: "error", // koyu 0.1 での既定境界の導出 (ADR-0017)
85
83
  VER02: "error", // koyu 0.3以前で採光の推定対象だった型に daylight が無い (ADR-0020)
86
84
  VER03: "error", // koyu 0.4以前のファイルに0.5の語 (縦動線・線・柱・地下)
85
+ VER04: "error", // koyu 0.5以前のファイルに1.0の語 (over・drop・集合編集 — ADR-0035/0038)
86
+ VER05: "error", // koyu 1.0以前のファイルの型の位置に exterior / void (ADR-0051)
87
87
  SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
88
88
  };
89
89
  const EPS = 0.5;
@@ -92,51 +92,59 @@ const EPS_SITE = 1;
92
92
  const VERTICAL = new Set(["stair", "shaft", "void"]);
93
93
  /** 0.3以前が採光の対象と推定していた型 (ADR-0020で廃止)。旧版の受理条件の判定にだけ使う — 意味論には効かない */
94
94
  const LEGACY_DAYLIT = new Set(["unit", "room", "ldk", "bedroom", "living"]);
95
- /** 互換層 — 従来の文字列形式。位置を持つ診断は「file:N行目: 本文」に組み立てる */
96
95
  /**
97
- * 解釈される属性の値の台帳 (ADR-0028)。**spec/vocabulary.md の★が契約であり、これはその写しである。**
98
- *
99
- * `of` があれば列挙、無ければ正の数値。ここに無い属性は自由に書けてそのまま運ばれる
100
- * (台帳の規則3)。daylight は DAY01 が、form は RUN05 が、縦動線の向きは RUN02 が
101
- * 既に守っているので重ねない。
96
+ * 1.0以前が型の位置から構造として読んでいた二語 (ADR-0051で廃止)。
97
+ * **VER05 の受理条件の判定にだけ使う — 意味論には効かない。**
98
+ * 型を読む場所がここにしか無いことは test/vocabulary.test.ts が守っている
102
99
  */
103
- const ATTR_RULES = {
104
- space: {
105
- h: {},
106
- ceiling: { of: [0, 1] },
107
- turn: { of: ["R", "L"] },
108
- riser: {},
109
- tread: {},
110
- entry: {},
111
- landing: {},
112
- lane: {},
113
- slope: {},
114
- road: {},
115
- },
116
- zone: { site: { of: [0, 1] }, area: {} },
117
- // air:1 の境界の天端高 (手すり・腰壁) — 立体が読むので台帳に載る (ADR-0028)
118
- boundary: { h: {} },
119
- opening: { style: { of: ["hinged", "sliding", "auto"] } },
100
+ const RETIRED_STRUCTURAL_TYPES = {
101
+ exterior: { decl: "outside:1", loses: "stops being outside (it becomes indoor floor area)" },
102
+ void: { decl: "void:1", loses: "stops being a void (a floor is generated in it)" },
120
103
  };
121
- /** 値を検査すべき宣言を、出所つきで数え上げる — 母集団は**書かれた宣言**である */
104
+ /**
105
+ * 版の新旧は `SUPPORTED_LANGUAGE_VERSIONS` の並びで決まる。**辞書順で比べてはならない** —
106
+ * 文字列としては "0.5" > "1.0" であり、比較を綴りに任せると新しい版が古い版と判定される
107
+ */
108
+ const olderThan = (version, ref) => SUPPORTED_LANGUAGE_VERSIONS.indexOf(version) < SUPPORTED_LANGUAGE_VERSIONS.indexOf(ref);
109
+ /**
110
+ * 属性を検査すべき宣言を、出所つきで数え上げる — 母集団は**書かれた宣言**である。
111
+ * 走査は宣言の順 (空間 → ゾーン → 境界 → その開口・seg → 空間の area → 柱)。
112
+ */
122
113
  function attrSubjects(model) {
123
114
  const out = [];
124
115
  for (const s of model.spaces.values()) {
125
- out.push([s.path, { rules: ATTR_RULES["space"], of: s.attrs }, { line: s.line, file: s.file, path: [s.path] }]);
116
+ const at = { line: s.line, file: s.file, path: [s.path] };
117
+ out.push([s.path, { elem: "space", of: s.attrs }, at]);
118
+ for (const a of s.areas) {
119
+ out.push([`area (${s.path})`, { elem: "area", of: a.attrs }, { line: a.line, file: s.file, path: [s.path] }]);
120
+ }
126
121
  }
127
122
  for (const z of model.zones.values()) {
128
- out.push([`ゾーン ${z.path}`, { rules: ATTR_RULES["zone"], of: z.attrs }, { line: z.line, file: z.file, path: [z.path] }]);
123
+ out.push([`zone ${z.path}`, { elem: "zone", of: z.attrs }, { line: z.line, file: z.file, path: [z.path] }]);
129
124
  }
130
125
  for (const b of model.boundaries) {
131
126
  const at = { line: b.line, file: b.file, path: [b.a, b.b] };
132
- out.push([`境界 ${b.a} | ${b.b}`, { rules: ATTR_RULES["boundary"], of: b.attrs }, at]);
127
+ out.push([`boundary ${b.a} | ${b.b}`, { elem: "boundary", of: b.attrs }, at]);
133
128
  for (const o of b.openings) {
134
129
  out.push([
135
130
  `${o.kind} (${b.a} | ${b.b})`,
136
- { rules: ATTR_RULES["opening"], of: o.attrs },
131
+ { elem: "opening", of: o.attrs },
137
132
  { line: o.line, file: b.file, path: [b.a, b.b] },
138
133
  ]);
139
134
  }
135
+ for (const g of b.segs) {
136
+ out.push([
137
+ `seg (${b.a} | ${b.b})`,
138
+ { elem: "seg", of: g.attrs },
139
+ { line: g.line, file: b.file, path: [b.a, b.b] },
140
+ ]);
141
+ }
142
+ }
143
+ for (const a of model.assets.values()) {
144
+ out.push([`asset ${a.name}`, { elem: ASSET_ELEM, of: a.attrs }, { line: a.line, file: a.file }]);
145
+ }
146
+ for (const c of model.columns) {
147
+ out.push([`column ${c.size}mm`, { elem: "column", of: c.attrs }, { line: c.line, file: c.file }]);
140
148
  }
141
149
  return out;
142
150
  }
@@ -191,7 +199,6 @@ export function checkDiagnostics(model) {
191
199
  checkAttrValues(ctx);
192
200
  checkRuns(ctx);
193
201
  checkDrawnLines(ctx);
194
- checkEnvelopeGaps(ctx);
195
202
  checkColumns(ctx);
196
203
  checkLanguageVersion(ctx);
197
204
  checkUids(ctx);
@@ -199,7 +206,8 @@ export function checkDiagnostics(model) {
199
206
  checkAreas(ctx);
200
207
  checkZones(ctx);
201
208
  checkHeights(ctx);
202
- checkOrphanSpaces(ctx);
209
+ checkSpaceSufficiency(ctx);
210
+ checkLevelSufficiency(ctx);
203
211
  checkSite(ctx);
204
212
  return diags;
205
213
  }
@@ -225,11 +233,11 @@ function checkBoundaryRefs(ctx) {
225
233
  for (const b of model.boundaries) {
226
234
  for (const p of [b.a, b.b]) {
227
235
  if (!model.spaces.has(p)) {
228
- emit("REF01", `未定義の空間を参照しています: ${p}`, { line: b.line, file: b.file, path: [b.a, b.b] });
236
+ emit("REF01", `References an undefined space: ${p}`, { line: b.line, file: b.file, path: [b.a, b.b] });
229
237
  }
230
238
  }
231
239
  if (b.a === b.b) {
232
- emit("BND01", `同じ空間同士の境界は書けません: ${b.a}`, { line: b.line, file: b.file, path: [b.a, b.b] });
240
+ emit("BND01", `A boundary between a space and itself cannot be written: ${b.a}`, { line: b.line, file: b.file, path: [b.a, b.b] });
233
241
  }
234
242
  }
235
243
  }
@@ -247,7 +255,7 @@ function checkBoundaryIdentity(ctx) {
247
255
  const key = `${pair}#${b.edge ?? ""}#${b.drawn ? `${b.drawn.aRef}..${b.drawn.bRef}` : ""}`;
248
256
  const prev = seenBoundary.get(key);
249
257
  if (prev) {
250
- emit("BND02", `境界が重複しています: ${pair}${b.edge ? ` edge:${b.edge}` : ""} (既出: ${srcRef(prev.line, prev.file)})`, { line: b.line, file: b.file, path: [b.a, b.b], related: [loc(prev.line, prev.file)] });
258
+ emit("BND02", `Duplicate boundary: ${pair}${b.edge ? ` edge:${b.edge}` : ""} (first seen at ${srcRef(prev.line, prev.file)})`, { line: b.line, file: b.file, path: [b.a, b.b], related: [loc(prev.line, prev.file)] });
251
259
  }
252
260
  else {
253
261
  seenBoundary.set(key, b);
@@ -265,7 +273,7 @@ function checkBoundaryIdentity(ctx) {
265
273
  // 「どこかで併存している」だけでは直す場所が無い
266
274
  const members = model.boundaries.filter((b) => !b.drawn && [b.a, b.b].sort().join(" | ") === pair);
267
275
  const first = members.find((b) => !b.edge) ?? members[0];
268
- emit("BND05", `同じ空間対に edge 限定つきと無しの境界が併存しています (線分が重なります): ${pair}`, {
276
+ emit("BND05", `The same pair of spaces carries both an edge-restricted and an unrestricted boundary (the segments overlap): ${pair}`, {
269
277
  ...(first ? { line: first.line, file: first.file } : {}),
270
278
  path: pair.split(" | "),
271
279
  related: members.filter((b) => b !== first).map((b) => loc(b.line, b.file)),
@@ -279,7 +287,7 @@ function checkLevelDepth(ctx) {
279
287
  // レベルの重複
280
288
  for (let i = 1; i < levels.length; i++) {
281
289
  if (Math.abs(levels[i].z - levels[i - 1].z) < EPS) {
282
- emit("LVL01", `レベル ${levels[i - 1].name} と ${levels[i].name} のzが同じです`, {
290
+ emit("LVL01", `Levels ${levels[i - 1].name} and ${levels[i].name} have the same z`, {
283
291
  line: levels[i].line,
284
292
  file: levels[i].file,
285
293
  related: [loc(levels[i - 1].line, levels[i - 1].file)],
@@ -296,7 +304,7 @@ function checkSelfOverlap(ctx) {
296
304
  for (let j = i + 1; j < s.rects.length; j++) {
297
305
  if (planOverlap(s.rects[i], s.rects[j])) {
298
306
  // どの組かを言わなければ、三つ重なる空間にバイト同一の診断が三件並ぶ
299
- emit("GEO01", `${s.path} の領域同士が重なっています: ${gridRefText(s, i)} と ${gridRefText(s, j)}`, {
307
+ emit("GEO01", `Regions within ${s.path} overlap: ${gridRefText(s, i)} and ${gridRefText(s, j)}`, {
300
308
  line: s.line,
301
309
  file: s.file,
302
310
  path: [s.path],
@@ -317,7 +325,7 @@ function checkSpaceOverlap(ctx) {
317
325
  if (a.level !== b.level)
318
326
  continue;
319
327
  if (spacesOverlap(a, b)) {
320
- emit("GEO02", `空間の領域が重なっています: ${a.path} と ${b.path}`, {
328
+ emit("GEO02", `Space regions overlap: ${a.path} and ${b.path}`, {
321
329
  line: a.line,
322
330
  file: a.file,
323
331
  path: [a.path, b.path],
@@ -337,7 +345,7 @@ function checkDaylightScope(ctx) {
337
345
  if (v === undefined)
338
346
  continue;
339
347
  if (v !== 0 && v !== 1) {
340
- emit("DAY01", `daylight は 1 (採光判定の対象) か 0 (対象外) です: ${s.path} に daylight:${v}`, {
348
+ emit("DAY01", `daylight is either 1 (in scope for the daylight check) or 0 (out of scope): ${s.path} carries daylight:${v}`, {
341
349
  line: s.line,
342
350
  file: s.file,
343
351
  path: [s.path],
@@ -347,31 +355,38 @@ function checkDaylightScope(ctx) {
347
355
  }
348
356
  /** 解釈される属性の値 — ATT01 / ATT02 */
349
357
  function checkAttrValues(ctx) {
350
- const { model, emit, loc, withRect, levels, levelIndex } = ctx;
351
- // 解釈される属性の値 (ADR-0028): **書いたのに解釈されなかった値は、黙って既定へ落とさない。**
358
+ const { model, emit } = ctx;
359
+ // 属性の三層 (docs/reference/scope.md)。**書いたのに解釈されなかったものを、黙って落とさない。**
360
+ //
361
+ // ADR-0028 は値を守った — `site:yes` は敷地の判定を、`h:35OO` は高さ不変量を、
362
+ // それぞれ丸ごと無音にしていた。だが**キー**は無防備のままだった。
363
+ // `heigh:2400` `sit:1` `stiar:N` は、一字違いで同じことを起こしながら緑で通る。
352
364
  //
353
- // daylight だけが DAY01 で守られていて、他の★属性は素通りだった。帰結は黙殺である —
354
- // `site:yes` は敷地の検査 (SIT03 error) を丸ごと無効にし、`h:35OO` は高さ不変量
355
- // (HGT01 error) を消し、`ceiling:none` は天井を張り、`turn:l` は階段を鏡像にする。
356
- // どれも check は緑のままだった。台帳 (spec/vocabulary.md) が契約である以上、
357
- // 台帳の型に合わない値はエラーである。
358
- for (const [where, attrs, at] of attrSubjects(model)) {
359
- for (const [key, rule] of Object.entries(attrs.rules)) {
360
- const v = attrs.of[key];
361
- if (v === undefined)
365
+ // 台帳に無いキーは、名前空間 (`acme.sensor`) を持たなければエラーである (ATT03) —
366
+ // これが「見ていない」と「見て問題がない」を区別できる唯一の形である (ADR-0033)。
367
+ for (const [where, subj, at] of attrSubjects(model)) {
368
+ for (const [key, v] of Object.entries(subj.of)) {
369
+ const spec = attrSpec(subj.elem, key);
370
+ if (!spec) {
371
+ if (isNamespaced(key))
372
+ continue; // 運搬層 — core は中身に一切の意味を与えない
373
+ emit("ATT03", `${where} carries ${key}:, which is not in the ledger (check the spelling, or add a namespace if the value is only carried — e.g. acme.${key}:${v})`, at);
362
374
  continue;
363
- if (rule.of) {
364
- if (!rule.of.includes(v)) {
365
- emit("ATT02", `${where} の ${key} は ${rule.of.join(" / ")} のどれかです: ${key}:${v}`, at);
375
+ }
376
+ if (spec.tier === "carry")
377
+ continue; // 運搬層は値を見ない
378
+ if (spec.of) {
379
+ if (!spec.of.includes(v)) {
380
+ emit("ATT02", `${key} on ${where} is one of ${spec.of.join(" / ")}: ${key}:${v}`, at);
366
381
  }
367
382
  }
368
- else if (typeof v !== "number" || !(v > 0)) {
369
- emit("ATT01", `${where} の ${key} は正の数値で書きます: ${key}:${v}`, at);
383
+ else if (spec.num && (typeof v !== "number" || !(v > 0))) {
384
+ emit("ATT01", `${key} on ${where} is written as a positive number: ${key}:${v}`, at);
370
385
  }
371
386
  }
372
387
  }
373
388
  }
374
- /** 縦動線 — RUN01〜RUN08 */
389
+ /** 縦動線 — RUN01〜RUN03 / RUN05 / SUF04 (形が一意に決まるか。登りやすさは検証の面) */
375
390
  function checkRuns(ctx) {
376
391
  const { model, emit, loc, withRect, levels, levelIndex } = ctx;
377
392
  // 縦動線 (ADR-0021): 宣言の妥当性と、**書かれていない導出値**の妥当性。
@@ -390,7 +405,7 @@ function checkDrawnLines(ctx) {
390
405
  continue;
391
406
  const bAt = { line: b.drawn.line, file: b.file, path: [b.a, b.b] };
392
407
  if (VERTICAL.has(b.kind)) {
393
- emit("LIN02", `垂直境界に線は描けません (線は平面を区切る行為です): ${b.a} | ${b.b}`, bAt);
408
+ emit("LIN02", `A line cannot be drawn on a vertical boundary (drawing a line is an act of dividing a plan): ${b.a} | ${b.b}`, bAt);
394
409
  continue;
395
410
  }
396
411
  const sa = model.spaces.get(b.a);
@@ -398,68 +413,21 @@ function checkDrawnLines(ctx) {
398
413
  if (!sa || !sb)
399
414
  continue;
400
415
  if (sa.rects.length === 0 && sb.rects.length === 0) {
401
- emit("LIN01", `領域を持たない空間同士に線は描けません: ${b.a} | ${b.b}`, bAt);
416
+ emit("LIN01", `A line cannot be drawn between spaces that have no region: ${b.a} | ${b.b}`, bAt);
402
417
  continue;
403
418
  }
404
- // 判定と操作を同じ関数に通す (ADR-0027)。窓の中で分離が決まらなければ LIN01、
405
- // 決まるが実際には何も切っていなければ LIN03。以前は判定だけが別の窓 (線分の
406
- // 外接矩形) を使っていたので、軸平行の線では窓が潰れて必ず誤報していた
407
- const cut = drawnCut(sa, sb, b.drawn.a, b.drawn.b);
408
- if (!cut) {
419
+ // **帰結は導出のその場で記録されている** (ADR-0041)。ここで計算し直すと、
420
+ // 既に切られた形を相手に窓を組み立てることになり、母集団が食い違う —
421
+ // 実際に切った線に「何も切っていない」と言う経路がそこにあった
422
+ if (b.drawn.effect === "undetermined") {
409
423
  emit("LIN01", sa.rects.length > 0 && sb.rects.length > 0
410
- ? `線 ${b.drawn.aRef}..${b.drawn.bRef} は ${b.a} と ${b.b} を分離していません (二つの割付が線の両側に来るように引きます)`
411
- : `線 ${b.drawn.aRef}..${b.drawn.bRef} が割付をちょうど二等分していて、どちらを残すか決まりません`, bAt);
424
+ ? `Line ${b.drawn.aRef}..${b.drawn.bRef} does not separate ${b.a} and ${b.b} (draw it so the two allocations fall on opposite sides)`
425
+ : `Line ${b.drawn.aRef}..${b.drawn.bRef} bisects the allocation exactly, so which side to keep is undetermined`, bAt);
412
426
  continue;
413
427
  }
414
- const target = cut.solo ? [cut.solo] : [sa, sb];
415
- if (!target.some((s) => cutsInWindow(s.rects.map(rectToPoly), cut.window, b.drawn.a, b.drawn.b))) {
416
- emit("LIN03", `線 ${b.drawn.aRef}..${b.drawn.bRef} は何も切っていません (既定の隣接線と同じか、割付の外にあります)`, bAt);
417
- }
418
- }
419
- }
420
- /** 外皮の穴 — ENV01 */
421
- function checkEnvelopeGaps(ctx) {
422
- const { model, emit, loc, withRect, levels, levelIndex } = ctx;
423
- // 外皮の穴 (ADR-0025): 既定境界は領域を持たない空間との間には導かれない (ADR-0014) ので、
424
- // 外部への境界の書き忘れは黙って壁の不在になる。導出された外周のうち、
425
- // 他の空間とも宣言された境界とも向かい合っていない区間を数える。
426
- // 外構のタイル (site:1 ゾーンの配下)・外部・半屋外は囲われていないのが正常なので数えない。
427
- // そして**外皮を書き始めているレベルだけ**を見る — 外部への境界が一本も無い階は
428
- // 外皮をまだ模型にしていないだけであって、穴が開いているのではない。
429
- // 「書き始めたなら閉じきる」という整合の検査であって、完全性の要求ではない
430
- const siteZones = [...model.zones.values()].filter((z) => z.attrs["site"] === 1).map((z) => z.path);
431
- const envelopedLevels = new Set();
432
- for (const b of model.boundaries) {
433
- if (b.derived || VERTICAL.has(b.kind))
434
- continue;
435
- const sa = model.spaces.get(b.a);
436
- const sb = model.spaces.get(b.b);
437
- if (!sa || !sb)
438
- continue;
439
- const outer = sa.rects.length === 0 ? sb : sb.rects.length === 0 ? sa : undefined;
440
- if (outer?.level)
441
- envelopedLevels.add(outer.level);
442
- }
443
- for (const s of withRect) {
444
- if (!s.level || !envelopedLevels.has(s.level))
445
- continue;
446
- if (s.type === "exterior" || isSemiOutdoor(model, s))
447
- continue;
448
- if (siteZones.some((z) => s.path.startsWith(z + "/")))
449
- continue;
450
- const gaps = envelopeGaps(model, s);
451
- if (gaps.length === 0)
452
- continue;
453
- // **どの辺かを言う。**合計長だけでは、edge を書き分けている図面で直す辺が特定できない。
454
- // envelopeGaps は座標つきの線分を返しているので、方角は既に手元にある
455
- const byDir = new Map();
456
- for (const g of gaps) {
457
- const d = g.edgeOfA ?? (g.horizontal ? "N/S" : "E/W");
458
- byDir.set(d, (byDir.get(d) ?? 0) + segmentLength(g));
428
+ if (b.drawn.effect === "nothing") {
429
+ emit("LIN03", `Line ${b.drawn.aRef}..${b.drawn.bRef} cuts nothing (it is the same as the default adjacency line, or falls outside the allocation)`, bAt);
459
430
  }
460
- const total = gaps.reduce((a, g) => a + segmentLength(g), 0);
461
- const where = [...byDir].map(([d, mm]) => `${d} ${Math.round(mm)}mm`).join(" / ");
462
- emit("ENV01", `外皮に面していない外周があります: ${s.path} — ${where} (合計 ${Math.round(total)}mm・${gaps.length}区間)。外部への境界を書きます`, { line: s.line, file: s.file, path: [s.path] });
463
431
  }
464
432
  }
465
433
  /** 柱 — COL01 / COL02 */
@@ -495,14 +463,14 @@ function checkColumns(ctx) {
495
463
  return false;
496
464
  return o.levels.some((lv) => columnsFor(model, lv).some((k) => k.decl === oi && sites.has(`${lv}|${k.grid}`)));
497
465
  });
498
- emit("COL02", `この柱の宣言 (${c.levels.join(",")} ${c.size}角) は同じ交点を先の宣言に取られていて、一本も立ちません (同じ交点では先の宣言が勝ちます)`, { ...at, related: shadow.map((o) => loc(o.line, o.file)) });
466
+ emit("COL02", `This column declaration (${c.levels.join(",")} ${c.size}mm square) stands nowhere because an earlier declaration took the same intersections (at the same intersection the earlier declaration wins)`, { ...at, related: shadow.map((o) => loc(o.line, o.file)) });
499
467
  }
500
468
  else {
501
- emit("COL01", `柱の宣言に対して立つ柱がありません (通りの交点に床がありません): ${c.levels.join(",")} ${c.size}角`, at);
469
+ emit("COL01", `Not one column stands for this declaration (the grid intersections have no floor): ${c.levels.join(",")} ${c.size}mm square`, at);
502
470
  }
503
471
  }
504
472
  }
505
- /** 言語版の受理条件 — VER01〜VER03 */
473
+ /** 言語版の受理条件 — VER01〜VER05 */
506
474
  function checkLanguageVersion(ctx) {
507
475
  const { model, emit, loc, withRect, levels, levelIndex } = ctx;
508
476
  // 言語版の受理条件 (ADR-0017): 旧版は意味保存の場合のみ受理する。
@@ -510,7 +478,7 @@ function checkLanguageVersion(ctx) {
510
478
  if (model.version === "0.1") {
511
479
  for (const b of model.boundaries) {
512
480
  if (b.derived) {
513
- emit("VER01", `koyu 0.1 のファイルに境界が宣言されていない接触ペアがあります: ${b.a} | ${b.b} — 0.2では既定の壁が導出され意味が変わります。境界を宣言するか、koyu 0.2 へ上げます`, { path: [b.a, b.b] });
481
+ emit("VER01", `A koyu 0.1 file has a touching pair with no declared boundary: ${b.a} | ${b.b} — in 0.2 a default wall is derived and the meaning changes. Declare the boundary, or raise the version to koyu 0.2`, { path: [b.a, b.b] });
514
482
  }
515
483
  }
516
484
  }
@@ -518,19 +486,44 @@ function checkLanguageVersion(ctx) {
518
486
  // 書かれていなければ、0.4では判定から黙って外れる — 意味が変わるのでエラーで二択を示す
519
487
  if (["0.1", "0.2", "0.3"].includes(model.version)) {
520
488
  for (const s of model.spaces.values()) {
521
- if (!LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined)
489
+ if (s.type === undefined || !LEGACY_DAYLIT.has(s.type) || s.attrs["daylight"] !== undefined)
490
+ continue;
491
+ emit("VER02", `A koyu ${model.version} file has a ${s.type} with no daylight: ${s.path} — 0.4 does not infer the daylight scope from the type, so it falls out of the check. Write daylight:1 (in scope) or daylight:0 (out of scope), then raise the version to koyu 0.4`, { line: s.line, file: s.file, path: [s.path] });
492
+ }
493
+ }
494
+ // 1.0 以前は型の位置に書かれた `exterior` と `void` が構造として読まれていた (ADR-0051 で廃止)。
495
+ // 1.1 の処理系はそこを一切読まないので、**書き換えないまま版を上げないと黙って別の建物になる** —
496
+ // 外部が屋内の床になり、吹抜けに床が生成される。実測で複合用途の例は延床 31,606.24㎡ が
497
+ // 33,004.00㎡ に増えながら check は緑で通った。ADR-0020 が `daylight` で下したのと同じ判断で、
498
+ // エラーにして二択を示す。
499
+ if (olderThan(model.version, "1.1")) {
500
+ for (const s of model.spaces.values()) {
501
+ const retired = RETIRED_STRUCTURAL_TYPES[s.type ?? ""];
502
+ if (!retired)
522
503
  continue;
523
- emit("VER02", `koyu ${model.version} のファイルに daylight の無い ${s.type} があります: ${s.path} — 0.4では型から採光の対象を推定しないので判定から外れます。daylight:1 (対象) か daylight:0 (対象外) を書いてから koyu 0.4 へ上げます`, { line: s.line, file: s.file, path: [s.path] });
504
+ emit("VER05", `A koyu ${model.version} file writes ${s.type} in the type position: ${s.path} — 1.1 reads no meaning from the type, so this space silently ${retired.loses}. Write ${retired.decl} instead, then raise the version to koyu 1.1`, { line: s.line, file: s.file, path: [s.path] });
505
+ }
506
+ // 逆向きも同じ境界である — 1.1 で入った語を古い版で書けば、知らない処理系は
507
+ // ATT03 で拒む。版の宣言と語彙は一致していなければならない (VER03/VER04 と同型)
508
+ for (const s of model.spaces.values()) {
509
+ if (s.type === undefined) {
510
+ emit("VER05", `A koyu ${model.version} file writes a space with no type: ${s.path} — the type became optional in 1.1, and an older processor refuses the line. Write a type, or raise the version to koyu 1.1`, { line: s.line, file: s.file, path: [s.path] });
511
+ }
512
+ for (const key of ["outside", "void"]) {
513
+ if (s.attrs[key] === undefined)
514
+ continue;
515
+ emit("VER05", `A koyu ${model.version} file carries ${key}: on ${s.path} — that word arrives in 1.1. Raise the version to koyu 1.1`, { line: s.line, file: s.file, path: [s.path] });
516
+ }
524
517
  }
525
518
  }
526
519
  // 0.5 で入った語 (縦動線の宣言・描かれた線・柱・地下) は 0.4 以前の処理系が知らない。
527
520
  // 知らない処理系では黙って形が生成されないので、版を上げずに使うのはエラー (ADR-0017 決定3)
528
- if (model.version !== "0.5") {
529
- const older = `koyu ${model.version} のファイルに 0.5 の語があります`;
521
+ if (olderThan(model.version, "0.5")) {
522
+ const older = `A koyu ${model.version} file uses a 0.5 word`;
530
523
  for (const s of model.spaces.values()) {
531
524
  const d = runDecls(s);
532
525
  if (d.length > 0) {
533
- emit("VER03", `${older}: ${s.path} の ${d[0].device}: (縦動線) — koyu 0.5 へ上げます`, {
526
+ emit("VER03", `${older}: ${s.path} carries ${d[0].device}: (a vertical circulation) — raise the version to koyu 0.5`, {
534
527
  line: s.line,
535
528
  file: s.file,
536
529
  path: [s.path],
@@ -539,7 +532,7 @@ function checkLanguageVersion(ctx) {
539
532
  }
540
533
  for (const b of model.boundaries) {
541
534
  if (b.drawn) {
542
- emit("VER03", `${older}: ${b.a} | ${b.b} の line (描かれた線) — koyu 0.5 へ上げます`, {
535
+ emit("VER03", `${older}: ${b.a} | ${b.b} carries line (a drawn line) — raise the version to koyu 0.5`, {
543
536
  line: b.drawn.line,
544
537
  file: b.file,
545
538
  path: [b.a, b.b],
@@ -547,19 +540,36 @@ function checkLanguageVersion(ctx) {
547
540
  }
548
541
  }
549
542
  for (const c of model.columns) {
550
- emit("VER03", `${older}: column (柱) — koyu 0.5 へ上げます`, { line: c.line, file: c.file });
543
+ emit("VER03", `${older}: column — raise the version to koyu 0.5`, { line: c.line, file: c.file });
551
544
  }
552
545
  for (const l of Object.values(model.levels)) {
553
546
  if (l.underground) {
554
- emit("VER03", `${older}: level ${l.name} の underground: — koyu 0.5 へ上げます`, {
547
+ emit("VER03", `${older}: level ${l.name} carries underground: — raise the version to koyu 0.5`, {
555
548
  line: l.line,
556
549
  file: l.file,
557
550
  });
558
551
  }
559
552
  }
560
553
  }
554
+ // 1.0 で入った語 (上書き `over`・削除 `drop`・`over` 直下の集合編集 `+` `-` `=`) は
555
+ // 0.5 以前の処理系が知らない。知らない処理系ではその行が語として読めず、上書きも削除も
556
+ // 起きない — **黙って別の建物になる**。VER03 と同型の理屈である (ADR-0017 決定3 / ADR-0035)
557
+ if (olderThan(model.version, "1.0")) {
558
+ const older = `A koyu ${model.version} file uses a 1.0 word`;
559
+ for (const e of model.compositionEdits) {
560
+ const what = e.word === "over" ? "a composition override"
561
+ : e.word === "drop" ? "a composition removal"
562
+ : "a set edit under over";
563
+ const paths = e.subject.split(" ").filter((t) => t.startsWith("/"));
564
+ emit("VER04", `${older}: ${[e.word, e.subject].filter(Boolean).join(" ")} (${what}) — raise the version to koyu 1.0`, {
565
+ line: e.line,
566
+ file: e.file,
567
+ ...(paths.length > 0 ? { path: paths } : {}),
568
+ });
569
+ }
570
+ }
561
571
  }
562
- /** uid — UID01〜UID03 */
572
+ /** 同一性 — UID01〜UID04 */
563
573
  function checkUids(ctx) {
564
574
  const { model, emit, loc, withRect, levels, levelIndex } = ctx;
565
575
  // uid (ADR-0015): 不透明トークン、space/zone横断でモデル全体一意。
@@ -570,7 +580,7 @@ function checkUids(ctx) {
570
580
  if (v === undefined)
571
581
  return;
572
582
  if (typeof v === "number") {
573
- emit("UID01", `uid は数字だけのトークンにできません: uid:${v} (sp-${v} のような形にします)`, {
583
+ emit("UID01", `A uid cannot be a token of digits alone: uid:${v} (write something like sp-${v})`, {
574
584
  line,
575
585
  file,
576
586
  path: [path],
@@ -578,7 +588,7 @@ function checkUids(ctx) {
578
588
  return;
579
589
  }
580
590
  if (v === "" || /\s/.test(v)) {
581
- emit("UID02", `uid に空白は使えません: "${v}"`, { line, file, path: [path] });
591
+ emit("UID02", `A uid cannot contain whitespace: "${v}"`, { line, file, path: [path] });
582
592
  return;
583
593
  }
584
594
  const arr = uidOwners.get(v) ?? [];
@@ -591,9 +601,45 @@ function checkUids(ctx) {
591
601
  collectUid("zone", z.path, z.attrs, z.line, z.file);
592
602
  for (const [uid, owners] of uidOwners) {
593
603
  if (owners.length > 1) {
594
- emit("UID03", `uid が重複しています: ${uid} (${owners.map((o) => `${o.kind} ${o.path} — ${srcRef(o.line, o.file)}`).join(", ")})`, { path: owners.map((o) => o.path), related: owners.map((o) => loc(o.line, o.file)) });
604
+ emit("UID03", `Duplicate uid: ${uid} (${owners.map((o) => `${o.kind} ${o.path} — ${srcRef(o.line, o.file)}`).join(", ")})`, { path: owners.map((o) => o.path), related: owners.map((o) => loc(o.line, o.file)) });
595
605
  }
596
606
  }
607
+ // 開口・内包物の同一性は「含む対象 + その中で一意な名」から導かれる (docs/reference/scope.md)。
608
+ // 名が重複していれば、その同一性は成り立たない — `over ... = door D1` はどちらを指すのか
609
+ // 決められず、`drop column C1` は二本まとめて消してしまう。**推測せずに拒む** (ADR-0039)。
610
+ // 名を書かない要素は同一性を主張していないので、母集団に入らない
611
+ const dupNames = (what, where, items, path) => {
612
+ const byName = new Map();
613
+ for (const it of items) {
614
+ if (it.name === undefined || it.name === "")
615
+ continue;
616
+ const arr = byName.get(it.name) ?? [];
617
+ arr.push(loc(it.line, it.file));
618
+ byName.set(it.name, arr);
619
+ }
620
+ for (const [name, at] of byName) {
621
+ if (at.length < 2)
622
+ continue;
623
+ const last = at[at.length - 1];
624
+ emit("UID04", `Duplicate ${what} name within ${where}: ${name} (${at.map((o) => srcRef(o.line, o.file)).join(", ")}) — the name is what identifies it inside its container`, { line: last.line, file: last.file, ...(path ? { path } : {}), related: at.slice(0, -1) });
625
+ }
626
+ };
627
+ const written = (attrs) => {
628
+ const n = attrs["name"];
629
+ return n === undefined || n === "" ? undefined : String(n);
630
+ };
631
+ for (const b of model.boundaries) {
632
+ const where = `boundary ${b.a} | ${b.b}`;
633
+ const at = b.file !== undefined ? { file: b.file } : {};
634
+ // 開口だけは、アセットから継いだ型の名を主張として数えない (ADR-0039)
635
+ dupNames("opening", where, b.openings.map((o) => ({ name: openingIdentity(model, o), line: o.line, ...at })), [b.a, b.b]);
636
+ dupNames("seg", where, b.segs.map((g) => ({ name: written(g.attrs), line: g.line, ...at })), [b.a, b.b]);
637
+ }
638
+ for (const s of model.spaces.values()) {
639
+ const at = s.file !== undefined ? { file: s.file } : {};
640
+ dupNames("area", `space ${s.path}`, s.areas.map((a) => ({ name: written(a.attrs), line: a.line, ...at })), [s.path]);
641
+ }
642
+ dupNames("column", "the model", model.columns.map((c) => ({ name: written(c.attrs), line: c.line, ...(c.file !== undefined ? { file: c.file } : {}) })));
597
643
  }
598
644
  /** 境界の妥当性 — VRT / BND03〜06 / OPN / SEG */
599
645
  function checkBoundaryValidity(ctx) {
@@ -614,7 +660,7 @@ function checkBoundaryValidity(ctx) {
614
660
  continue; // 垂直境界は水平の検査 (線分・開口・seg) を一切受けない
615
661
  }
616
662
  if (sa.rects.length > 0 && sb.rects.length > 0 && sa.level !== sb.level) {
617
- emit("BND03", `異なるレベルの空間に壁境界は書けません (垂直は type:stair/shaft/void): ${b.a} | ${b.b}`, bAt);
663
+ emit("BND03", `A wall boundary cannot be written to a space on a different level (vertical takes type:stair/shaft/void): ${b.a} | ${b.b}`, bAt);
618
664
  continue; // レベルを跨ぐ壁は成立していない — 線分も開口も問わない
619
665
  }
620
666
  checkBoundarySegments(ctx, b, sa, sb, bAt);
@@ -627,30 +673,30 @@ function checkVerticalBoundary(ctx, b, sa, sb, bAt) {
627
673
  const { emit, levelIndex } = ctx;
628
674
  // 垂直境界: 隣り合うレベルの、平面で重なる空間同士にしか張れない
629
675
  if (sa.rects.length === 0 || sb.rects.length === 0 || !sa.level || !sb.level) {
630
- emit("VRT01", `${b.kind} 境界は領域とレベルを持つ空間同士に書きます`, bAt);
676
+ emit("VRT01", `A ${b.kind} boundary is written between spaces that have both a region and a level`, bAt);
631
677
  return; // 前提が崩れているので、以降の判定は意味を持たない
632
678
  }
633
679
  const ia = levelIndex.get(sa.level);
634
680
  const ib = levelIndex.get(sb.level);
635
681
  if (ia === undefined || ib === undefined || Math.abs(ia - ib) !== 1) {
636
- emit("VRT02", `${b.kind} 境界は隣り合うレベルの間に書きます: ${b.a} | ${b.b}`, bAt);
682
+ emit("VRT02", `A ${b.kind} boundary is written between adjacent levels: ${b.a} | ${b.b}`, bAt);
637
683
  }
638
684
  else if (!spacesOverlap(sa, sb)) {
639
- emit("VRT03", `${b.kind} 境界の空間が平面上で重なっていません: ${b.a} | ${b.b}`, bAt);
685
+ emit("VRT03", `The spaces of a ${b.kind} boundary do not overlap in plan: ${b.a} | ${b.b}`, bAt);
640
686
  }
641
687
  if (b.kind === "void") {
642
688
  const upper = (ia ?? 0) > (ib ?? 0) ? sa : sb;
643
- if (upper.type !== "void") {
644
- emit("VRT04", `void境界の上側は type:void の空間を想定しています: ${upper.path}`, bAt);
689
+ if (!isVoid(upper)) {
690
+ emit("VRT04", `The space above a void boundary is expected to declare void:1: ${upper.path}`, bAt);
645
691
  }
646
692
  }
647
693
  // 咎めているのは字下げされた door / window / seg の行そのものなので、
648
694
  // 親の境界宣言ではなくその行を指す。宣言が複数あれば診断も複数出る
649
695
  for (const o of b.openings) {
650
- emit("VRT05", `垂直境界の${o.kind}は解釈されません`, { line: o.line, file: b.file, path: [b.a, b.b] });
696
+ emit("VRT05", `A ${o.kind} on a vertical boundary is not interpreted`, { line: o.line, file: b.file, path: [b.a, b.b] });
651
697
  }
652
698
  for (const g of b.segs) {
653
- emit("VRT06", `垂直境界の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
699
+ emit("VRT06", `A seg on a vertical boundary is not interpreted`, { line: g.line, file: b.file, path: [b.a, b.b] });
654
700
  }
655
701
  }
656
702
  /** 水平境界の線分がゼロ — BND04 / BND06 */
@@ -668,14 +714,14 @@ function checkBoundarySegments(ctx, b, sa, sb, bAt) {
668
714
  const without = b.edge ? segmentsFor(model, { ...b, edge: undefined }) : [];
669
715
  if (without.length > 0) {
670
716
  const dirs = [...new Set(without.map((g) => g.edgeOfA))].filter((d) => d !== undefined);
671
- emit("BND04", `edge:${b.edge} に共有辺がありません: ${b.a} | ${b.b} (実際に接しているのは ${dirs.join("・") || "別の辺"} です)`, bAt);
717
+ emit("BND04", `No shared edge on edge:${b.edge}: ${b.a} | ${b.b} (they actually touch on ${dirs.join(" / ") || "another edge"})`, bAt);
672
718
  }
673
719
  else {
674
- emit("BND04", `空間が接していないため境界を導けません: ${b.a} | ${b.b}`, bAt);
720
+ emit("BND04", `The spaces do not touch, so no boundary can be derived: ${b.a} | ${b.b}`, bAt);
675
721
  }
676
722
  }
677
723
  if ((sa.rects.length > 0 ? 1 : 0) + (sb.rects.length > 0 ? 1 : 0) === 1 && segs.length === 0) {
678
- emit("BND06", `${b.edge ? `edge:${b.edge} の` : ""}外周に残る辺が無く、境界線分がゼロです: ${b.a} | ${b.b}`, bAt);
724
+ emit("BND06", `No edge remains on the perimeter${b.edge ? ` for edge:${b.edge}` : ""}, so the boundary segment is of zero length: ${b.a} | ${b.b}`, bAt);
679
725
  }
680
726
  }
681
727
  /**
@@ -687,7 +733,7 @@ function checkOpenings(ctx, b) {
687
733
  const { model, emit, loc } = ctx;
688
734
  if (b.kind === "open" && b.openings.length > 0) {
689
735
  for (const o of b.openings) {
690
- emit("OPN03", `open境界の${o.kind}は通行に影響しません (常に通れます)`, {
736
+ emit("OPN03", `A ${o.kind} on an open boundary has no effect on passage (it is always passable)`, {
691
737
  line: o.line,
692
738
  file: b.file,
693
739
  path: [b.a, b.b],
@@ -714,7 +760,7 @@ function checkOpenings(ctx, b) {
714
760
  ? o.hinge === "W" || o.hinge === "E"
715
761
  : o.hinge === "N" || o.hinge === "S";
716
762
  if (!okAxis) {
717
- emit("OPN01", `hinge:${o.hinge} は${placed.segment.horizontal ? "水平線分 (W/E)" : "垂直線分 (N/S)"}で指定します`, { line: o.line, file: b.file, path: [b.a, b.b] });
763
+ emit("OPN01", `hinge:${o.hinge}: ${placed.segment.horizontal ? "a horizontal segment takes W/E" : "a vertical segment takes N/S"}`, { line: o.line, file: b.file, path: [b.a, b.b] });
718
764
  }
719
765
  }
720
766
  }
@@ -732,7 +778,7 @@ function checkOpenings(ctx, b) {
732
778
  const q = group[k + 1];
733
779
  const need = (p.o.w + q.o.w) / 2;
734
780
  if (q.c - p.c < need - EPS) {
735
- emit("OPN02", `開口同士が重なっています (${p.o.kind}と${q.o.kind} — 中心間 ${Math.round(q.c - p.c)}mm < 必要 ${Math.round(need)}mm)`, { line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] });
781
+ emit("OPN02", `Openings overlap (${p.o.kind} and ${q.o.kind} — center to center ${Math.round(q.c - p.c)}mm < the required ${Math.round(need)}mm)`, { line: q.o.line, file: b.file, path: [b.a, b.b], related: [loc(p.o.line, b.file)] });
736
782
  }
737
783
  }
738
784
  }
@@ -742,7 +788,7 @@ function checkBoundarySegs(ctx, b) {
742
788
  const { model, emit } = ctx;
743
789
  for (const g of b.segs) {
744
790
  if (b.kind === "open") {
745
- emit("SEG03", `open境界 (壁が無い) の seg は解釈されません`, { line: g.line, file: b.file, path: [b.a, b.b] });
791
+ emit("SEG03", `A seg on an open boundary (there is no wall) is not interpreted`, { line: g.line, file: b.file, path: [b.a, b.b] });
746
792
  continue;
747
793
  }
748
794
  const placed = placeBand(model, b, g, "seg");
@@ -758,7 +804,7 @@ function checkAreas(ctx) {
758
804
  for (const s of model.spaces.values()) {
759
805
  for (const a of s.areas) {
760
806
  if (s.rects.length === 0) {
761
- emit("SEG01", `領域を持たない空間 ${s.path} に area は書けません`, {
807
+ emit("SEG01", `An area cannot be written on ${s.path}, which has no region`, {
762
808
  line: a.line,
763
809
  file: s.file,
764
810
  path: [s.path],
@@ -768,7 +814,7 @@ function checkAreas(ctx) {
768
814
  // 内包も導出された形で見る — 割付で見ると、切り落とした側に置いた床材が通ってしまう
769
815
  const inside = regionOf(s).some((g) => rectToPoly(a.rect).every((pt) => pointInPolygon(pt, g, EPS)));
770
816
  if (!inside) {
771
- emit("SEG02", `area が ${s.path} の領域からはみ出しています`, { line: a.line, file: s.file, path: [s.path] });
817
+ emit("SEG02", `The area spills outside the region of ${s.path}`, { line: a.line, file: s.file, path: [s.path] });
772
818
  }
773
819
  }
774
820
  }
@@ -780,10 +826,10 @@ function checkZones(ctx) {
780
826
  for (const z of model.zones.values()) {
781
827
  const children = [...model.spaces.keys()].filter((p) => p.startsWith(z.path + "/"));
782
828
  if (children.length === 0) {
783
- emit("ZON01", `ゾーン ${z.path} の下に空間がありません`, { line: z.line, file: z.file, path: [z.path] });
829
+ emit("ZON01", `There are no spaces beneath zone ${z.path}`, { line: z.line, file: z.file, path: [z.path] });
784
830
  }
785
831
  if (model.spaces.has(z.path)) {
786
- emit("ZON02", `ゾーンと同じパスの空間があります (どちらかに寄せます): ${z.path}`, {
832
+ emit("ZON02", `A space shares its path with a zone (settle on one of them): ${z.path}`, {
787
833
  line: z.line,
788
834
  file: z.file,
789
835
  path: [z.path],
@@ -791,7 +837,12 @@ function checkZones(ctx) {
791
837
  }
792
838
  }
793
839
  }
794
- /** 高さ方向の一貫性 — HGT01〜HGT04 */
840
+ /**
841
+ * 高さ方向の一貫性 — HGT01 / HGT02。
842
+ * **ここは「書かれた値が矛盾しているか」だけを見る。**値が書かれていないこと (上階の slab が無い、
843
+ * 天井高が決まらない) は不変量の破れではなく情報の欠落なので、充足性の節が SUF01 / SUF03 で言う
844
+ * (ADR-0034)。以前はここが HGT03 / HGT04 として二重に言っていた
845
+ */
795
846
  function checkHeights(ctx) {
796
847
  const { model, emit, loc, withRect, levels, levelIndex } = ctx;
797
848
  // 高さ方向の一貫性: 下階の空間の天井高 + 上階のslab ≤ 階高
@@ -828,7 +879,6 @@ function checkHeights(ctx) {
828
879
  const below = byLevel.get(lb.name) ?? [];
829
880
  const above = byLevel.get(lu.name) ?? [];
830
881
  const pitch = lu.z - lb.z;
831
- let slabMissing = false;
832
882
  for (const s of below) {
833
883
  if (isSemiOutdoor(model, s))
834
884
  continue; // 屋外・半屋外 (庭・バルコニー等) に天井は無い
@@ -840,19 +890,11 @@ function checkHeights(ctx) {
840
890
  const covered = above.some((u) => spacesOverlap(s, u)) || above.length === 0;
841
891
  if (!covered)
842
892
  continue;
843
- if (lu.slab === undefined) {
844
- slabMissing = true;
845
- continue;
846
- }
893
+ if (lu.slab === undefined)
894
+ continue; // 立式に要る値が無い — SUF03 が言う
847
895
  const h = heff(model, s);
848
- if (h === undefined) {
849
- emit("HGT04", `${s.path} の天井高が不明で、${lu.name} との高さ検査ができません`, {
850
- line: s.line,
851
- file: s.file,
852
- path: [s.path],
853
- });
854
- continue;
855
- }
896
+ if (h === undefined)
897
+ continue; // 同上 — SUF01 が言う
856
898
  if (h + lu.slab > pitch + EPS) {
857
899
  const partners = voidPartners.get(`${s.path}|${lu.name}`) ?? [];
858
900
  const cover = partners.length ? voidCoverage(s, partners) : 0;
@@ -862,36 +904,65 @@ function checkHeights(ctx) {
862
904
  // 本文は HGT01 と同じ三項を出す — 決め手が上階の slab のとき
863
905
  // 「天井高3000は階高3000を超えます」という成り立たない不等式になっていた。
864
906
  // 被覆は免除しきい値 (99%) と衝突しないよう小数一桁で言う
865
- emit("HGT02", `${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}。吹抜けの被覆は${(cover * 100).toFixed(1)}%しかありません — 部分吹抜けでは天井高を階高内に収めます (吹抜け部分の高さは導出)`, { line: s.line, file: s.file, path: [s.path] });
907
+ emit("HGT02", `${s.path} collides into the floor above: ceiling height ${h} + ${lu.name}'s slab ${lu.slab} = ${h + lu.slab} > storey height ${pitch}. The void covers only ${(cover * 100).toFixed(1)}% — under a partial void keep the ceiling height within the storey height (the height of the void part is derived)`, { line: s.line, file: s.file, path: [s.path] });
866
908
  }
867
909
  else {
868
- emit("HGT01", `${s.path} が上階に食い込みます: 天井高${h} + ${lu.name}のslab${lu.slab} = ${h + lu.slab} > 階高${pitch}`, { line: s.line, file: s.file, path: [s.path] });
910
+ emit("HGT01", `${s.path} collides into the floor above: ceiling height ${h} + ${lu.name}'s slab ${lu.slab} = ${h + lu.slab} > storey height ${pitch}`, { line: s.line, file: s.file, path: [s.path] });
869
911
  }
870
912
  }
871
913
  }
872
- if (slabMissing) {
873
- emit("HGT03", `レベル ${lu.name} に slab が未宣言のため、${lb.name} との高さ検査ができません`, {
874
- line: lu.line,
875
- file: lu.file,
876
- });
877
- }
878
914
  }
879
915
  }
880
- /** レベルに載らない空間 — HGT05 */
881
- function checkOrphanSpaces(ctx) {
882
- const { model, emit, loc, withRect, levels, levelIndex } = ctx;
883
- // レベルに載らない領域つき空間
916
+ /**
917
+ * 充足性 — 領域を持つ空間の走査 (SUF02 / SUF01)。
918
+ *
919
+ * **妥当性の判定ではなく、完全性の検査である** (docs/reference/scope.md-2)。形を作らないことと
920
+ * 形を作れないことは違う — 天井高が決まらなければ押し出す高さが無く、レベルが決まらなければ
921
+ * z が無い。どちらも「書いてある構成から一意な形が出る」という契約 (ADR-0034) の破れである。
922
+ *
923
+ * 除くのは、その空間の形が天井高に依らないものだけ — 吹抜け (床も天井も無い)、外部 (地面)、
924
+ * 半屋外 (`fabric.ts` が天井も屋根も架けない)。**節の粒度は走査単位である** (ADR-0028) ので、
925
+ * 一つの空間が出す二つのコードはこの一本のループの中で決まる
926
+ */
927
+ function checkSpaceSufficiency(ctx) {
928
+ const { model, emit, withRect } = ctx;
884
929
  for (const s of withRect) {
930
+ const at = { line: s.line, file: s.file, path: [s.path] };
885
931
  if (!s.level) {
886
- emit("HGT05", `${s.path} は領域を持ちますが、レベルが特定できません (パス先頭か level: で指定します)`, {
887
- line: s.line,
888
- file: s.file,
889
- path: [s.path],
890
- });
932
+ emit("SUF02", `${s.path} has a region, but its level cannot be determined (give it at the head of the path or with level:)`, at);
933
+ continue; // z が決まらない空間には、天井高を問う意味が無い
934
+ }
935
+ if (isVoid(s) || isOutside(s) || isSemiOutdoor(model, s))
936
+ continue;
937
+ if (heff(model, s) === undefined) {
938
+ emit("SUF01", `The ceiling height of ${s.path} cannot be determined (neither the space's h: nor level ${s.level}'s h: is there)`, at);
891
939
  }
892
940
  }
893
941
  }
894
- /** 敷地形状 — SIT01〜SIT05 */
942
+ /**
943
+ * 充足性 — レベルの走査 (SUF03)。
944
+ *
945
+ * 床は level の `slab` (床組み厚) だけが与える (ADR-0024) ので、書かなければその階に床は
946
+ * 一枚も生成されない。**形そのものは定まる**ので警告である — 「slab が無ければ床要素を作らない」は
947
+ * 決定的な規則であり、複数の形が出るわけではない。ただし床の無い建物になることは知らされるべきである
948
+ */
949
+ function checkLevelSufficiency(ctx) {
950
+ const { emit, withRect, levels } = ctx;
951
+ for (const l of levels) {
952
+ if (l.slab !== undefined)
953
+ continue;
954
+ // 床を持ちうる空間が一つも載っていない階 (最上階の上限を与えるだけの屋上レベルなど) には
955
+ // 言うことが無い — 生成されなかった床が無いのだから
956
+ const n = withRect.filter((s) => s.level === l.name && !isVoid(s) && !isOutside(s)).length;
957
+ if (n === 0)
958
+ continue;
959
+ emit("SUF03", `Level ${l.name} has no slab:, so not one floor is generated on this storey`, {
960
+ line: l.line,
961
+ file: l.file,
962
+ });
963
+ }
964
+ }
965
+ /** 敷地形状 — SIT01 / SIT02 / SIT04 (与件の健全性。建物との関係の判断は検証の面) */
895
966
  function checkSite(ctx) {
896
967
  const { model, emit, loc, withRect, levels, levelIndex } = ctx;
897
968
  // 敷地形状 (ADR-0011): 形の妥当性、対応ゾーンの存在、宣言面積との照合、建物のはみ出し検査。
@@ -902,7 +973,7 @@ function checkSite(ctx) {
902
973
  const a = poly.points[i];
903
974
  const b = poly.points[(i + 1) % poly.points.length];
904
975
  if (Math.hypot(b.x - a.x, b.y - a.y) <= EPS_SITE) {
905
- emit("SIT01", `敷地形状に重複する頂点があります (${Math.round(a.x)},${Math.round(a.y)})`, {
976
+ emit("SIT01", `The site shape has a duplicate vertex (${Math.round(a.x)},${Math.round(a.y)})`, {
906
977
  line: poly.line,
907
978
  file: poly.file,
908
979
  path: [poly.path],
@@ -911,7 +982,7 @@ function checkSite(ctx) {
911
982
  }
912
983
  const selfX = polygonSelfIntersection(poly.points);
913
984
  if (selfX) {
914
- emit("SIT02", `敷地形状が自己交差しています (${Math.round(selfX.x)},${Math.round(selfX.y)} 付近)`, {
985
+ emit("SIT02", `The site shape is self-intersecting (near ${Math.round(selfX.x)},${Math.round(selfX.y)})`, {
915
986
  line: poly.line,
916
987
  file: poly.file,
917
988
  path: [poly.path],
@@ -920,38 +991,13 @@ function checkSite(ctx) {
920
991
  }
921
992
  const zone = model.zones.get(poly.path);
922
993
  if (!zone) {
923
- emit("SIT04", `polygon ${poly.path} に対応するゾーンがありません`, {
994
+ emit("SIT04", `No zone corresponds to polygon ${poly.path}`, {
924
995
  line: poly.line,
925
996
  file: poly.file,
926
997
  path: [poly.path],
927
998
  });
928
999
  continue;
929
1000
  }
930
- if (zone.attrs["site"] !== 1)
931
- continue;
932
- const declared = zone.attrs["area"];
933
- if (typeof declared === "number") {
934
- const derived = polygonAreaM2(poly.points);
935
- if (Math.abs(declared - derived) >= 0.05) {
936
- emit("SIT05", `敷地面積の宣言と導出が食い違います: 宣言 ${declared}㎡ / 導出 ${derived.toFixed(2)}㎡`, { line: zone.line, file: zone.file, path: [zone.path] });
937
- }
938
- }
939
- for (const s of withRect) {
940
- if (s.type === "exterior" || s.path.startsWith(poly.path + "/"))
941
- continue;
942
- // 照合するのは割付ではなく**導出された領域** — 敷地なりに切った外形はここで通る
943
- for (const r of regionOf(s)) {
944
- const out = shapeEscapesPolygon(r, poly.points, EPS_SITE);
945
- if (out) {
946
- emit("SIT03", `${s.path} が敷地形状からはみ出しています (${Math.round(out.x)},${Math.round(out.y)} 付近)`, {
947
- line: s.line,
948
- file: s.file,
949
- path: [s.path],
950
- });
951
- break;
952
- }
953
- }
954
- }
955
1001
  }
956
1002
  }
957
- //# sourceMappingURL=check.js.map
1003
+ //# sourceMappingURL=diagnose.js.map