@kensnzk/koyu 0.16.0 → 0.18.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 (254) hide show
  1. package/README.ja.md +12 -8
  2. package/README.md +13 -10
  3. package/dist/analysis/contracts.d.ts +217 -0
  4. package/dist/analysis/contracts.d.ts.map +1 -0
  5. package/dist/analysis/contracts.js +27 -0
  6. package/dist/analysis/contracts.js.map +1 -0
  7. package/dist/analysis/index.d.ts +5 -0
  8. package/dist/analysis/index.d.ts.map +1 -0
  9. package/dist/analysis/index.js +17 -0
  10. package/dist/analysis/index.js.map +1 -0
  11. package/dist/analysis/json.d.ts +21 -0
  12. package/dist/analysis/json.d.ts.map +1 -0
  13. package/dist/analysis/json.js +111 -0
  14. package/dist/analysis/json.js.map +1 -0
  15. package/dist/cli.js +106 -35
  16. package/dist/cli.js.map +1 -1
  17. package/dist/core/derive.d.ts +13 -8
  18. package/dist/core/derive.d.ts.map +1 -1
  19. package/dist/core/derive.js +19 -13
  20. package/dist/core/derive.js.map +1 -1
  21. package/dist/core/diagnose.d.ts +4 -3
  22. package/dist/core/diagnose.d.ts.map +1 -1
  23. package/dist/core/diagnose.js +46 -11
  24. package/dist/core/diagnose.js.map +1 -1
  25. package/dist/core/diff.d.ts +3 -2
  26. package/dist/core/diff.d.ts.map +1 -1
  27. package/dist/core/diff.js +8 -5
  28. package/dist/core/diff.js.map +1 -1
  29. package/dist/core/fabric.d.ts +1 -3
  30. package/dist/core/fabric.d.ts.map +1 -1
  31. package/dist/core/fabric.js +8 -8
  32. package/dist/core/fabric.js.map +1 -1
  33. package/dist/core/graph.d.ts +2 -2
  34. package/dist/core/graph.d.ts.map +1 -1
  35. package/dist/core/graph.js +12 -5
  36. package/dist/core/graph.js.map +1 -1
  37. package/dist/core/light.d.ts.map +1 -1
  38. package/dist/core/light.js +2 -2
  39. package/dist/core/light.js.map +1 -1
  40. package/dist/core/model.d.ts +59 -10
  41. package/dist/core/model.d.ts.map +1 -1
  42. package/dist/core/model.js +128 -26
  43. package/dist/core/model.js.map +1 -1
  44. package/dist/core/parse.d.ts.map +1 -1
  45. package/dist/core/parse.js +83 -82
  46. package/dist/core/parse.js.map +1 -1
  47. package/dist/core/poly.d.ts +0 -4
  48. package/dist/core/poly.d.ts.map +1 -1
  49. package/dist/core/poly.js +1 -5
  50. package/dist/core/poly.js.map +1 -1
  51. package/dist/core/site.d.ts +9 -0
  52. package/dist/core/site.d.ts.map +1 -1
  53. package/dist/core/site.js +8 -2
  54. package/dist/core/site.js.map +1 -1
  55. package/dist/core/tolerance.d.ts +1 -1
  56. package/dist/core/tolerance.js +2 -2
  57. package/dist/core/tolerance.js.map +1 -1
  58. package/dist/core/vertical.d.ts +9 -2
  59. package/dist/core/vertical.d.ts.map +1 -1
  60. package/dist/core/vertical.js +8 -1
  61. package/dist/core/vertical.js.map +1 -1
  62. package/dist/core/vocabulary.d.ts.map +1 -1
  63. package/dist/core/vocabulary.js +17 -5
  64. package/dist/core/vocabulary.js.map +1 -1
  65. package/dist/diagnostics.d.ts +2 -0
  66. package/dist/diagnostics.d.ts.map +1 -0
  67. package/dist/diagnostics.js +3 -0
  68. package/dist/diagnostics.js.map +1 -0
  69. package/dist/diff.d.ts +2 -0
  70. package/dist/diff.d.ts.map +1 -0
  71. package/dist/diff.js +3 -0
  72. package/dist/diff.js.map +1 -0
  73. package/dist/draw/index.js +1 -1
  74. package/dist/draw/index.js.map +1 -1
  75. package/dist/draw/plan.js +5 -5
  76. package/dist/draw/plan.js.map +1 -1
  77. package/dist/form.d.ts +5 -0
  78. package/dist/form.d.ts.map +1 -0
  79. package/dist/form.js +4 -0
  80. package/dist/form.js.map +1 -0
  81. package/dist/graph.d.ts +2 -0
  82. package/dist/graph.d.ts.map +1 -0
  83. package/dist/graph.js +3 -0
  84. package/dist/graph.js.map +1 -0
  85. package/dist/index.d.ts +2 -14
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +36 -45
  88. package/dist/index.js.map +1 -1
  89. package/dist/mcp.js +81 -30
  90. package/dist/mcp.js.map +1 -1
  91. package/dist/model.d.ts +3 -0
  92. package/dist/model.d.ts.map +1 -0
  93. package/dist/model.js +3 -0
  94. package/dist/model.js.map +1 -0
  95. package/dist/parse-file.d.ts.map +1 -1
  96. package/dist/parse-file.js +18 -3
  97. package/dist/parse-file.js.map +1 -1
  98. package/dist/validate/assessment.d.ts +8 -0
  99. package/dist/validate/assessment.d.ts.map +1 -0
  100. package/dist/validate/assessment.js +1738 -0
  101. package/dist/validate/assessment.js.map +1 -0
  102. package/dist/validate/builtin/access.d.ts +55 -0
  103. package/dist/validate/builtin/access.d.ts.map +1 -0
  104. package/dist/validate/builtin/access.js +494 -0
  105. package/dist/validate/builtin/access.js.map +1 -0
  106. package/dist/validate/builtin/daylight.d.ts +44 -0
  107. package/dist/validate/builtin/daylight.d.ts.map +1 -0
  108. package/dist/validate/builtin/daylight.js +233 -0
  109. package/dist/validate/builtin/daylight.js.map +1 -0
  110. package/dist/validate/builtin/door-column-collisions.d.ts +47 -0
  111. package/dist/validate/builtin/door-column-collisions.d.ts.map +1 -0
  112. package/dist/validate/builtin/door-column-collisions.js +189 -0
  113. package/dist/validate/builtin/door-column-collisions.js.map +1 -0
  114. package/dist/validate/builtin/envelope.d.ts +30 -0
  115. package/dist/validate/builtin/envelope.d.ts.map +1 -0
  116. package/dist/validate/builtin/envelope.js +169 -0
  117. package/dist/validate/builtin/envelope.js.map +1 -0
  118. package/dist/validate/builtin/freeze.d.ts +3 -0
  119. package/dist/validate/builtin/freeze.d.ts.map +1 -0
  120. package/dist/validate/builtin/freeze.js +21 -0
  121. package/dist/validate/builtin/freeze.js.map +1 -0
  122. package/dist/validate/builtin/index.d.ts +38 -0
  123. package/dist/validate/builtin/index.d.ts.map +1 -0
  124. package/dist/validate/builtin/index.js +106 -0
  125. package/dist/validate/builtin/index.js.map +1 -0
  126. package/dist/validate/builtin/site.d.ts +62 -0
  127. package/dist/validate/builtin/site.d.ts.map +1 -0
  128. package/dist/validate/builtin/site.js +333 -0
  129. package/dist/validate/builtin/site.js.map +1 -0
  130. package/dist/validate/builtin/vertical-runs.d.ts +53 -0
  131. package/dist/validate/builtin/vertical-runs.d.ts.map +1 -0
  132. package/dist/validate/builtin/vertical-runs.js +290 -0
  133. package/dist/validate/builtin/vertical-runs.js.map +1 -0
  134. package/dist/validate/contracts.d.ts +188 -0
  135. package/dist/validate/contracts.d.ts.map +1 -0
  136. package/dist/validate/contracts.js +28 -0
  137. package/dist/validate/contracts.js.map +1 -0
  138. package/dist/validate/index.d.ts +2 -59
  139. package/dist/validate/index.d.ts.map +1 -1
  140. package/dist/validate/index.js +22 -70
  141. package/dist/validate/index.js.map +1 -1
  142. package/dist/vocabulary.d.ts +2 -0
  143. package/dist/vocabulary.d.ts.map +1 -0
  144. package/dist/vocabulary.js +3 -0
  145. package/dist/vocabulary.js.map +1 -0
  146. package/editors/vscode/syntaxes/koyu.tmLanguage.json +2 -2
  147. package/examples/basement/main.muro +3 -3
  148. package/examples/complex/main.muro +1 -1
  149. package/examples/complex/podium.muro +1 -1
  150. package/examples/complex/site.muro +6 -6
  151. package/examples/house/L2.muro +1 -1
  152. package/examples/house/main.muro +1 -1
  153. package/examples/house/site.muro +4 -4
  154. package/examples/house.muro +6 -6
  155. package/examples/mansion.muro +2 -2
  156. package/examples/office.muro +3 -3
  157. package/examples/steps/04-exterior.muro +1 -1
  158. package/examples/steps/05-two-storeys.muro +1 -1
  159. package/examples/steps/06-finished.muro +2 -2
  160. package/examples/tower/L2.muro +1 -1
  161. package/examples/tower/main.muro +1 -1
  162. package/examples/tower/site.muro +4 -4
  163. package/examples/twin/main.muro +1 -1
  164. package/examples/twin/podium.muro +4 -4
  165. package/examples/twin/site.muro +8 -8
  166. package/examples/two-rooms.canonical.json +4 -4
  167. package/examples/two-rooms.muro +2 -2
  168. package/package.json +41 -9
  169. package/src/analysis/contracts.ts +234 -0
  170. package/src/analysis/index.ts +61 -0
  171. package/src/analysis/json.ts +117 -0
  172. package/src/cli.ts +116 -36
  173. package/src/core/derive.ts +32 -15
  174. package/src/core/diagnose.ts +63 -16
  175. package/src/core/diff.ts +10 -6
  176. package/src/core/fabric.ts +18 -9
  177. package/src/core/graph.ts +19 -5
  178. package/src/core/light.ts +2 -2
  179. package/src/core/model.ts +141 -31
  180. package/src/core/parse.ts +100 -85
  181. package/src/core/poly.ts +1 -8
  182. package/src/core/site.ts +19 -2
  183. package/src/core/tolerance.ts +2 -2
  184. package/src/core/vertical.ts +10 -3
  185. package/src/core/vocabulary.ts +18 -5
  186. package/src/diagnostics.ts +8 -0
  187. package/src/diff.ts +14 -0
  188. package/src/draw/index.ts +1 -1
  189. package/src/draw/plan.ts +5 -5
  190. package/src/form.ts +37 -0
  191. package/src/graph.ts +12 -0
  192. package/src/index.ts +40 -175
  193. package/src/mcp.ts +85 -35
  194. package/src/model.ts +43 -0
  195. package/src/parse-file.ts +17 -3
  196. package/src/validate/assessment.ts +1934 -0
  197. package/src/validate/builtin/access.ts +642 -0
  198. package/src/validate/builtin/daylight.ts +321 -0
  199. package/src/validate/builtin/door-column-collisions.ts +266 -0
  200. package/src/validate/builtin/envelope.ts +227 -0
  201. package/src/validate/builtin/freeze.ts +19 -0
  202. package/src/validate/builtin/index.ts +156 -0
  203. package/src/validate/builtin/site.ts +445 -0
  204. package/src/validate/builtin/vertical-runs.ts +390 -0
  205. package/src/validate/contracts.ts +240 -0
  206. package/src/validate/index.ts +45 -99
  207. package/src/vocabulary.ts +9 -0
  208. package/dist/validate/access.d.ts +0 -6
  209. package/dist/validate/access.d.ts.map +0 -1
  210. package/dist/validate/access.js +0 -238
  211. package/dist/validate/access.js.map +0 -1
  212. package/dist/validate/envelope.d.ts +0 -4
  213. package/dist/validate/envelope.d.ts.map +0 -1
  214. package/dist/validate/envelope.js +0 -55
  215. package/dist/validate/envelope.js.map +0 -1
  216. package/dist/validate/light.d.ts +0 -6
  217. package/dist/validate/light.d.ts.map +0 -1
  218. package/dist/validate/light.js +0 -28
  219. package/dist/validate/light.js.map +0 -1
  220. package/dist/validate/runs.d.ts +0 -16
  221. package/dist/validate/runs.d.ts.map +0 -1
  222. package/dist/validate/runs.js +0 -60
  223. package/dist/validate/runs.js.map +0 -1
  224. package/dist/validate/site.d.ts +0 -6
  225. package/dist/validate/site.d.ts.map +0 -1
  226. package/dist/validate/site.js +0 -63
  227. package/dist/validate/site.js.map +0 -1
  228. package/spec/README.md +0 -28
  229. package/spec/canonical-json.md +0 -98
  230. package/spec/composition.md +0 -121
  231. package/spec/derivation.md +0 -393
  232. package/spec/en/README.md +0 -30
  233. package/spec/en/canonical-json.md +0 -101
  234. package/spec/en/composition.md +0 -121
  235. package/spec/en/derivation.md +0 -393
  236. package/spec/en/language.md +0 -164
  237. package/spec/en/notation-v0.md +0 -145
  238. package/spec/en/scope.md +0 -229
  239. package/spec/en/semantics.md +0 -132
  240. package/spec/en/tools.md +0 -108
  241. package/spec/en/validation.md +0 -79
  242. package/spec/en/vocabulary.md +0 -103
  243. package/spec/language.md +0 -163
  244. package/spec/notation-v0.md +0 -184
  245. package/spec/scope.md +0 -229
  246. package/spec/semantics.md +0 -130
  247. package/spec/tools.md +0 -106
  248. package/spec/validation.md +0 -79
  249. package/spec/vocabulary.md +0 -114
  250. package/src/validate/access.ts +0 -279
  251. package/src/validate/envelope.ts +0 -59
  252. package/src/validate/light.ts +0 -43
  253. package/src/validate/runs.ts +0 -87
  254. package/src/validate/site.ts +0 -84
@@ -1,279 +0,0 @@
1
- // 検証 — 到達可能性と、位置を書かない要素どうしの衝突
2
- //
3
- // **この章は、旗艦例が実際に踏んだ失敗の集まりである。**掟2 (「check が緑でも建物が
4
- // 使えるとは限らない」) は文として書かれていたが、旗艦例は check 緑のまま
5
- // 「床の無い吹抜けにしか扉が開かない区画が20」「他人の店舗を貫通する避難路」
6
- // 「車の出入口の無い2層の駐車場」「バックヤードの奥で孤立したエスカレーター」を
7
- // 抱えていた。予言された失敗を、予言した当人が踏んだのである。
8
- //
9
- // 直したことと再発しないことは別なので、その四つと「外部へ到達できない室」
10
- // 「柱が塞ぐ扉」を判定として置く。**判定は MCP から呼べなければ、機械にとって
11
- // 存在しないに等しい** (spec/validation.md) — スクリプトの中に閉じている限り、
12
- // 同じ誤りは別の建物で何度でも起きる。
13
- //
14
- // core が持つのは経路そのもの (`doorsBetween` / `passable` / `placeOpening`) で、
15
- // **どの到達不能が問題かを言うのはここである** (spec/scope.md §4)。
16
-
17
- import { passable, placeOpening } from "../core/graph.js";
18
- import {
19
- columnsFor,
20
- effectiveUse,
21
- levelsSorted,
22
- type Boundary,
23
- type Model,
24
- type Space,
25
- } from "../core/model.js";
26
- import { finding, type Finding } from "./index.js";
27
-
28
- /** 車が通れる開口の最小幅 mm。人の扉 (900) では車は出られない */
29
- export const CAR_WIDTH_MIN = 2400;
30
-
31
- /** 空間としては連続するが人も車も通り抜けられない型 — どの到達性の問いでも常に避ける */
32
- const IMPASSABLE = new Set(["shaft", "void"]);
33
-
34
- /** 境界を通れるかの判定。人 (passable) と車 (carPassable) で通れる境界が違うので差し替える */
35
- type CanPass = (b: Boundary) => boolean;
36
-
37
- /**
38
- * from (複数可) から toSet のどれかへ、avoid が真になる空間を**通らずに**辿り着けるか。
39
- * 到達先そのものは avoid を問わない (外部は exterior だが、着いた時点で目的は果たされている)。
40
- */
41
- function reachableAvoiding(
42
- model: Model,
43
- from: string[],
44
- toSet: Set<string>,
45
- avoid: (s: Space) => boolean = () => false,
46
- canPass: CanPass = passable,
47
- ): boolean {
48
- const seen = new Set<string>();
49
- const queue: string[] = [];
50
- for (const f of from) {
51
- if (toSet.has(f)) return true;
52
- if (model.spaces.has(f) && !seen.has(f)) {
53
- seen.add(f);
54
- queue.push(f);
55
- }
56
- }
57
- while (queue.length) {
58
- const u = queue.shift()!;
59
- for (const b of model.boundaries) {
60
- if (!canPass(b)) continue;
61
- const v = b.a === u ? b.b : b.b === u ? b.a : undefined;
62
- if (!v || seen.has(v)) continue;
63
- if (toSet.has(v)) return true;
64
- const s = model.spaces.get(v);
65
- if (!s || IMPASSABLE.has(s.type) || avoid(s)) continue;
66
- seen.add(v);
67
- queue.push(v);
68
- }
69
- }
70
- return false;
71
- }
72
-
73
- /** 外部の空間パスの集合。空なら到達性は問えない (外部が書かれていない模型に穴は無い) */
74
- function exteriorSet(model: Model): Set<string> {
75
- return new Set([...model.spaces.values()].filter((s) => s.type === "exterior").map((s) => s.path));
76
- }
77
-
78
- /**
79
- * 通れる境界だけを辿って外部から届く空間の集合。
80
- *
81
- * ここは `doorsBetween` と同じグラフを一度だけ広げたものである — 通行は向きを持たないので
82
- * 「どれかの外部から s へ行けるか」は「s とどれかの外部が同じ連結成分にあるか」に等しい。
83
- * 空間ごとに最短経路を引き直すと室数×外部数の探索になり、延床14万㎡の例で分単位になる。
84
- */
85
- function reachableFromExterior(model: Model): Set<string> {
86
- const seen = new Set<string>(exteriorSet(model));
87
- const queue = [...seen];
88
- while (queue.length) {
89
- const u = queue.shift()!;
90
- for (const b of model.boundaries) {
91
- if (!passable(b)) continue;
92
- const v = b.a === u ? b.b : b.b === u ? b.a : undefined;
93
- if (!v || seen.has(v)) continue;
94
- seen.add(v);
95
- queue.push(v);
96
- }
97
- }
98
- return seen;
99
- }
100
-
101
- /** 車が通れる境界 — open・幅 2400mm 以上の扉・斜路の縦連結だけ */
102
- function carPassable(model: Model): CanPass {
103
- return (b) => {
104
- if (b.kind === "open") return true;
105
- if (b.kind === "shaft" || b.kind === "void") return false;
106
- if (b.kind === "stair") {
107
- // 階段の縦連結は、斜路の宣言が無ければ車にとってただの段差である
108
- const ra = model.spaces.get(b.a)?.attrs["ramp"];
109
- const rb = model.spaces.get(b.b)?.attrs["ramp"];
110
- return ra != null || rb != null;
111
- }
112
- return b.openings.some((o) => o.kind === "door" && o.w >= CAR_WIDTH_MIN);
113
- };
114
- }
115
-
116
- const at = (s: Space) => ({ line: s.line, file: s.file, path: [s.path] });
117
-
118
- export function accessFindings(model: Model): Finding[] {
119
- const out: Finding[] = [];
120
- const outs = exteriorSet(model);
121
-
122
- // ---- 外部へ到達できない室 ----
123
- // **扉の有無ではなく到達性を問う。**扉を持っていても、その先が行き止まりなら出られない。
124
- // violation — 「出られない室」を建築として読める解釈は無い。シャフト (人が通れない) と
125
- // 吹抜け (床が無い) と外部そのものだけが対象外である。
126
- if (outs.size > 0) {
127
- const reached = reachableFromExterior(model);
128
- for (const s of model.spaces.values()) {
129
- if (s.rects.length === 0 || s.type === "exterior" || IMPASSABLE.has(s.type)) continue;
130
- if (reached.has(s.path)) continue;
131
- out.push(
132
- finding(
133
- "access.unreachable",
134
- `Cannot reach the exterior: ${s.path} (no passable boundary leads out — write a door)`,
135
- at(s),
136
- ),
137
- );
138
- }
139
- }
140
-
141
- // ---- 吹抜けにしか扉が開かない区画 ----
142
- // 通れる境界を持つのに行き先が全部 type:void なら、扉は床の無い穴に向かって開いている。
143
- // violation — 出入りしたつもりでどこへも行けない。旗艦例はこれを20区画抱えたまま緑だった。
144
- for (const s of model.spaces.values()) {
145
- if (s.rects.length === 0 || s.type === "exterior" || IMPASSABLE.has(s.type)) continue;
146
- let doors = 0;
147
- let allVoid = true;
148
- for (const b of model.boundaries) {
149
- if (!passable(b)) continue;
150
- const other = b.a === s.path ? b.b : b.b === s.path ? b.a : undefined;
151
- if (!other) continue;
152
- doors++;
153
- if (model.spaces.get(other)?.type !== "void") allVoid = false;
154
- }
155
- if (doors > 0 && allVoid) {
156
- out.push(
157
- finding(
158
- "access.voidonly",
159
- `Doors open only onto a void: ${s.path} (they open where there is no floor, so nobody can pass)`,
160
- at(s),
161
- ),
162
- );
163
- }
164
- }
165
-
166
- // ---- 賃貸区画を貫く避難路 ----
167
- // 階段室ごとに「use:rentable を避けても外部へ出られるか」を問う。賃貸経由でしか出られない
168
- // 階段は、テナントが施錠した瞬間に死ぬ。
169
- // caution — 通ってよいかは契約と管轄の側の事実であって、原本には書かれていない
170
- // (専用通路として通す設計も現にある)。疑う値打ちはあるが、断じる根拠はここに無い。
171
- if (outs.size > 0) {
172
- for (const s of model.spaces.values()) {
173
- if (s.type !== "stair" || s.rects.length === 0) continue;
174
- if (reachableAvoiding(model, [s.path], outs, (t) => effectiveUse(model, t) === "rentable")) continue;
175
- out.push(
176
- finding(
177
- "access.throughtenant",
178
- `Escape from ${s.path} passes through rentable space (if the tenant locks up, there is no way out)`,
179
- at(s),
180
- ),
181
- );
182
- }
183
- }
184
-
185
- // ---- 車が出られない駐車場 ----
186
- // 人は900mmの扉と階段で出られてしまうので access.unreachable では見えない。
187
- // violation — 車が出られない駐車場は駐車場ではない。
188
- if (outs.size > 0) {
189
- const canPass = carPassable(model);
190
- for (const s of model.spaces.values()) {
191
- if (s.rects.length === 0 || s.type === "exterior" || IMPASSABLE.has(s.type)) continue;
192
- if (effectiveUse(model, s) !== "parking") continue;
193
- if (reachableAvoiding(model, [s.path], outs, () => false, canPass)) continue;
194
- out.push(
195
- finding(
196
- "access.parking",
197
- `No vehicle route to the exterior: ${s.path} (needs an opening at least ${CAR_WIDTH_MIN}mm wide, a type:open boundary, or a ramp)`,
198
- at(s),
199
- ),
200
- );
201
- }
202
- }
203
-
204
- // ---- 客が乗れない縦動線 ----
205
- // 縦動線の宣言 (stair:/escalator: — ADR-0021) を持つ共用の空間は客動線の一部なので、
206
- // 共用廊下からバックヤードを通らずに届かなければ孤立している。共用廊下が一つも無い建物には
207
- // 客動線の区別が無いので問わない (住宅の階段を孤立と誤検出しないため)。
208
- //
209
- // 当の空間へは**水平に**入れなければならない。自分の縦連結を経由すると「上の階から当の
210
- // エスカレーターで降りてくれば乗り場に着く」という循環が成り立ってしまう。
211
- //
212
- // caution — 「共用の縦動線はすべて客用」は粗い推定である。従業員用の共用階段を客用と
213
- // 読み違えることがあるので、断じずに疑う。
214
- const corridors = [...model.spaces.values()]
215
- .filter((s) => s.type === "corridor" && s.rects.length > 0 && effectiveUse(model, s) === "common")
216
- .map((s) => s.path);
217
- if (corridors.length > 0) {
218
- for (const s of model.spaces.values()) {
219
- if (s.rects.length === 0 || s.type === "shaft") continue;
220
- if (s.attrs["stair"] == null && s.attrs["escalator"] == null) continue;
221
- if (effectiveUse(model, s) !== "common") continue;
222
- const horizontalEntry: CanPass = (b) =>
223
- passable(b) && !(b.kind === "stair" && (b.a === s.path || b.b === s.path));
224
- if (reachableAvoiding(model, corridors, new Set([s.path]), (t) => t.type === "backyard", horizontalEntry)) {
225
- continue;
226
- }
227
- out.push(
228
- finding(
229
- "access.backofhouse",
230
- `${s.path} cannot be reached from a common corridor without passing through back-of-house (visitors cannot use this vertical circulation)`,
231
- at(s),
232
- ),
233
- );
234
- }
235
- }
236
-
237
- // ---- 柱が塞ぐ扉 ----
238
- // **位置を書かない要素が二つあると、衝突は導出でしか分からない。**柱は通り芯の交点から
239
- // (ADR-0023)、扉は境界線分の上から (at: の比率か通り参照から) 導かれるので、どちらも
240
- // 原本には座標が無い。だから目で見るまで気づかない。通り芯の交点は境界線分の端でもあるので、
241
- // 扉を隅に寄せると必ずぶつかる。
242
- // violation — 物と物が同じ場所を占めている。読み方によって許される衝突ではない。
243
- const byLevel = new Map<string, ReturnType<typeof columnsFor>>();
244
- for (const l of levelsSorted(model)) byLevel.set(l.name, columnsFor(model, l.name));
245
- for (const b of model.boundaries) {
246
- const lv = model.spaces.get(b.a)?.level ?? model.spaces.get(b.b)?.level;
247
- if (!lv) continue;
248
- for (const o of b.openings) {
249
- if (o.kind !== "door") continue;
250
- const p = placeOpening(model, b, o);
251
- if ("error" in p) continue; // 置けない開口は core が既に言っている
252
- const seg = p.segment;
253
- const half = o.w / 2;
254
- for (const c of byLevel.get(lv) ?? []) {
255
- const cx1 = c.x - c.w / 2;
256
- const cx2 = c.x + c.w / 2;
257
- const cy1 = c.y - c.d / 2;
258
- const cy2 = c.y + c.d / 2;
259
- // 扉は線分に沿って幅を持ち、線分に直交する向きには厚みを持たない
260
- const along = seg.horizontal
261
- ? Math.max(p.cx - half, cx1) < Math.min(p.cx + half, cx2)
262
- : Math.max(p.cy - half, cy1) < Math.min(p.cy + half, cy2);
263
- const across = seg.horizontal ? cy1 < seg.y1 && seg.y1 < cy2 : cx1 < seg.x1 && seg.x1 < cx2;
264
- if (along && across) {
265
- out.push(
266
- finding(
267
- "column.blocksdoor",
268
- `A column blocks a door: the door (${o.w}mm wide) on ${b.a} | ${b.b} overlaps the column at ${c.grid}`,
269
- { line: b.line, file: b.file, path: [b.a, b.b] },
270
- ),
271
- );
272
- break;
273
- }
274
- }
275
- }
276
- }
277
-
278
- return out;
279
- }
@@ -1,59 +0,0 @@
1
- // 検証 — 外皮の連続 (ADR-0025)
2
- //
3
- // 方針が「保証しないもの」に**外皮の連続**を名指しで挙げている (spec/scope.md §3)。
4
- // core に残るのは `envelopeGaps` — 何にも面していない外周の**線分を返す導出**であって、
5
- // それが穴かどうかの判断はしない。判断はここが引き受ける。
6
- //
7
- // 判定は粗い。**外部への境界を一本でも書いたレベルだけ**を見る — 外皮をまだ模型に
8
- // していない階を「穴が開いている」とは言わない。「書き始めたなら閉じきる」という
9
- // 整合の要求であって、完全性の要求ではない。粗さが許されるのは、ここが凍らないからである。
10
-
11
- import { envelopeGaps, segmentLength } from "../core/graph.js";
12
- import { isSemiOutdoor, type Model } from "../core/model.js";
13
- import { finding, type Finding } from "./index.js";
14
-
15
- const VERTICAL = new Set(["stair", "shaft", "void"]);
16
-
17
- export function envelopeFindings(model: Model): Finding[] {
18
- const out: Finding[] = [];
19
- const siteZones = [...model.zones.values()].filter((z) => z.attrs["site"] === 1).map((z) => z.path);
20
-
21
- // 外皮を書き始めているレベル = 領域を持たない空間 (外部) との境界が宣言されているレベル
22
- const envelopedLevels = new Set<string>();
23
- for (const b of model.boundaries) {
24
- if (b.derived || VERTICAL.has(b.kind)) continue;
25
- const sa = model.spaces.get(b.a);
26
- const sb = model.spaces.get(b.b);
27
- if (!sa || !sb) continue;
28
- const outer = sa.rects.length === 0 ? sb : sb.rects.length === 0 ? sa : undefined;
29
- if (outer?.level) envelopedLevels.add(outer.level);
30
- }
31
-
32
- for (const s of model.spaces.values()) {
33
- if (s.rects.length === 0) continue;
34
- if (!s.level || !envelopedLevels.has(s.level)) continue;
35
- // 外部・半屋外・外構のタイルは囲われていないのが正常
36
- if (s.type === "exterior" || isSemiOutdoor(model, s)) continue;
37
- if (siteZones.some((z) => s.path.startsWith(z + "/"))) continue;
38
-
39
- const gaps = envelopeGaps(model, s);
40
- if (gaps.length === 0) continue;
41
-
42
- // **どの辺かを言う。**合計長だけでは、edge を書き分けている図面で直す辺が特定できない
43
- const byDir = new Map<string, number>();
44
- for (const g of gaps) {
45
- const d = g.edgeOfA ?? (g.horizontal ? "N/S" : "E/W");
46
- byDir.set(d, (byDir.get(d) ?? 0) + segmentLength(g));
47
- }
48
- const total = gaps.reduce((a, g) => a + segmentLength(g), 0);
49
- const where = [...byDir].map(([d, mm]) => `${d} ${Math.round(mm)}mm`).join(" / ");
50
- out.push(
51
- finding(
52
- "envelope.gap",
53
- `Perimeter not faced by any envelope: ${s.path} — ${where} (${Math.round(total)}mm over ${gaps.length} run(s)). Write a boundary to the exterior`,
54
- { line: s.line, file: s.file, path: [s.path] },
55
- ),
56
- );
57
- }
58
- return out;
59
- }
@@ -1,43 +0,0 @@
1
- // 検証 — 採光 (法28条1項の粗い写し)
2
- //
3
- // **合否はここが言う。**core が返すのは `daylightInputs` — 床面積と、係数を掛けた
4
- // 有効窓面積という**数**だけである (spec/scope.md §4「問いは合否を言わない」)。
5
- // 1/7 という閾値は建築の側の規則であって、原本の構成が満たすべき不変量ではない。
6
- //
7
- // 判定は甘い。採光補正係数を掛けない粗い判定であり、基本計画の解像度に合わせた
8
- // 早期警報である。用途別割合 (令19条3項) も適用建築物 (法28条1項) も見ない —
9
- // 1/7 を掛ける先は `daylight:1` を書く位置として書き手が決める (ADR-0020)。
10
-
11
- import type { Model } from "../core/model.js";
12
- import { daylightInputs } from "../core/light.js";
13
- import { finding, type Finding } from "./index.js";
14
-
15
- /** 必要面積の分母。**建築の側の数であって、core の不変量ではない** */
16
- export const DAYLIGHT_DIVISOR = 7;
17
-
18
- export function daylightFindings(model: Model): Finding[] {
19
- const out: Finding[] = [];
20
- for (const d of daylightInputs(model)) {
21
- const at = { line: d.space.line, file: d.space.file, path: [d.space.path] };
22
- const need = d.floor / DAYLIGHT_DIVISOR;
23
- if (d.window + 1e-9 < need) {
24
- out.push(
25
- finding(
26
- "daylight.ratio",
27
- `Insufficient daylight: ${d.space.path} — effective window ${d.window.toFixed(2)} m2 < required ${need.toFixed(2)} m2 (1/${DAYLIGHT_DIVISOR} of the ${d.floor.toFixed(2)} m2 floor)`,
28
- at,
29
- ),
30
- );
31
- }
32
- if (d.missingH) {
33
- out.push(
34
- finding(
35
- "daylight.unknown",
36
- `Window area is not fully counted: ${d.space.path} has a window without h: (write h: on it)`,
37
- at,
38
- ),
39
- );
40
- }
41
- }
42
- return out;
43
- }
@@ -1,87 +0,0 @@
1
- // 検証 — 縦動線の建築的な妥当性 (ADR-0021)
2
- //
3
- // core が保証するのは「宣言から**形が一意に決まる**」までである (RUN01〜RUN05)。
4
- // 決まった形が**登りやすいか**は建築の側の判断で、ここが引き受ける。
5
- //
6
- // 段数も踏面も勾配も原本には書かれない — 領域と階高から導出される。
7
- // だから検査の対象は「書かれた値」ではなく「導出された値」である。
8
- // 閾値 (踏面240mm・2R+T の 550〜700・エスカレーターの常用域) は日本の慣行の粗い写しで、
9
- // 管轄が二つ目を持ったときに章の下へ足す。凍らないので、その時に足せばよい。
10
-
11
- import type { Model } from "../core/model.js";
12
- import { slopeText, verticalRuns } from "../core/vertical.js";
13
- import { finding, type Finding } from "./index.js";
14
-
15
- /** 踏面の下限 mm — 令23条の一般的な下限に倣う粗い値 */
16
- export const TREAD_MIN = 240;
17
- /** 2×蹴上 + 踏面 の目安 mm (歩幅則) */
18
- export const STEP_RULE = { lo: 550, hi: 700 };
19
- /** エスカレーターの常用勾配 (約1/1.7 = 30度) の許容幅 */
20
- export const ESCALATOR_SLOPE = { lo: 1 / 2.3, hi: 1 / 1.4 };
21
-
22
- export function runFindings(model: Model): Finding[] {
23
- const out: Finding[] = [];
24
-
25
- // 上下を繋ぐ垂直境界を持つ空間 — 形があってもここに無ければグラフでは通れない
26
- const stairLinked = new Set<string>();
27
- for (const b of model.boundaries) {
28
- if (b.kind === "stair" || b.kind === "shaft") {
29
- stairLinked.add(b.a);
30
- stairLinked.add(b.b);
31
- }
32
- }
33
-
34
- for (const run of verticalRuns(model)) {
35
- const s = model.spaces.get(run.path);
36
- if (!s) continue;
37
- const at = { line: s.line, file: s.file, path: [s.path] };
38
- if (run.device === "lift") continue;
39
-
40
- if (!stairLinked.has(run.path)) {
41
- out.push(
42
- finding(
43
- "run.disconnected",
44
- `${run.path} has a vertical-circulation form but no vertical boundary connecting the levels (write stack or boundary type:stair — the form exists, but the graph cannot pass)`,
45
- at,
46
- ),
47
- );
48
- }
49
-
50
- if (run.device === "stair") {
51
- const t = Math.round(run.tread);
52
- const r = Math.round(run.riser);
53
- const rule = 2 * r + t;
54
- if (t < TREAD_MIN || rule < STEP_RULE.lo || rule > STEP_RULE.hi) {
55
- out.push(
56
- finding(
57
- "stair.proportion",
58
- `Derived step dimensions are cramped: ${run.risers} risers of ${r}mm, tread ${t}mm (2*riser+tread = ${Math.round(rule)}mm; expected ${STEP_RULE.lo}-${STEP_RULE.hi}mm)`,
59
- at,
60
- ),
61
- );
62
- }
63
- } else if (run.device === "ramp") {
64
- const declared = s.attrs["slope"];
65
- if (typeof declared === "number" && declared > 0 && run.slope > 1 / declared + 1e-9) {
66
- out.push(
67
- finding(
68
- "run.slope",
69
- `Derived slope ${slopeText(run.slope)} is steeper than the declared 1/${declared} (lengthen the run or lower the storey height)`,
70
- at,
71
- ),
72
- );
73
- }
74
- } else if (run.device === "escalator") {
75
- if (run.slope < ESCALATOR_SLOPE.lo || run.slope > ESCALATOR_SLOPE.hi) {
76
- out.push(
77
- finding(
78
- "run.slope",
79
- `Derived slope ${slopeText(run.slope)} is outside the usual escalator range (about 1/1.7 = 30 degrees)`,
80
- at,
81
- ),
82
- );
83
- }
84
- }
85
- }
86
- return out;
87
- }
@@ -1,84 +0,0 @@
1
- // 検証 — 敷地に対する建物の判断 (ADR-0009 / ADR-0011)
2
- //
3
- // 敷地形状そのものの健全性 (重複頂点・自己交差・対応ゾーンの不在) は **core に残る** —
4
- // 与件が壊れていれば形が作れないので、あれは読解の一部である。
5
- //
6
- // ここが持つのは建物と敷地の**関係についての判断**の二つだけ:
7
- // - 建物が敷地からはみ出していないか (形は一意に出る。出た形が法に触れるかは別の話)
8
- // - 測量値として書かれた面積と、多角形から導出される面積が食い違わないか
9
- //
10
- // 建蔽率・容積率は**数**なので core の siteReport が返す。上限と較べるのは、
11
- // 用途地域という原本の外の事実を要するので、ここでも持たない — 持てるようになったら足す。
12
-
13
- import { polygonAreaM2, regionOf, shapeEscapesPolygon, type Model } from "../core/model.js";
14
- import { siteReport } from "../core/site.js";
15
- import { finding, type Finding } from "./index.js";
16
-
17
- /** 敷地の許容 mm — 境界上は内側扱い */
18
- const EPS_SITE = 1;
19
- /** 面積照合の許容 ㎡ */
20
- const AREA_TOLERANCE = 0.05;
21
- /** 接道長の下限 mm — 法43条 (接道義務) の粗い写し */
22
- export const FRONTAGE_MIN = 2000;
23
-
24
- export function siteFindings(model: Model): Finding[] {
25
- const out: Finding[] = [];
26
- const withRect = [...model.spaces.values()].filter((s) => s.rects.length > 0);
27
-
28
- // 接道 — core が返すのは接道長という数だけで、2m という下限は建築の側の規則である。
29
- //
30
- // **敷地が宣言されていなければ問わない。**接道長は「敷地と道路が共有する境界の長さ」なので、
31
- // site:1 のゾーンが無い模型では 0 が導かれるが、それは「接道が無い」ではなく
32
- // 「導けていない」である。地下の断面だけを書いた例のように、道路は書くが敷地は書かない
33
- // 模型は現にある — 導けていない数に線を引くと、書いていないことが違反になる。
34
- const report = siteReport(model);
35
- for (const road of report.siteZone ? report.roads : []) {
36
- if (road.frontage >= FRONTAGE_MIN) continue;
37
- out.push(
38
- finding(
39
- "site.frontage",
40
- `Road frontage is too short: ${road.road.path} — ${road.frontage}mm (needs at least ${FRONTAGE_MIN}mm)`,
41
- { line: road.road.line, file: road.road.file, path: [road.road.path] },
42
- ),
43
- );
44
- }
45
-
46
- for (const poly of model.polygons.values()) {
47
- const zone = model.zones.get(poly.path);
48
- // 形の健全性と対応ゾーンの不在は core が既に言っている — ここでは黙って飛ばす
49
- if (!zone || zone.attrs["site"] !== 1) continue;
50
-
51
- const declared = zone.attrs["area"];
52
- if (typeof declared === "number") {
53
- const derived = polygonAreaM2(poly.points);
54
- if (Math.abs(declared - derived) >= AREA_TOLERANCE) {
55
- out.push(
56
- finding(
57
- "site.area",
58
- `Declared and derived site areas disagree: declared ${declared} m2 / derived ${derived.toFixed(2)} m2`,
59
- { line: zone.line, file: zone.file, path: [zone.path] },
60
- ),
61
- );
62
- }
63
- }
64
-
65
- for (const s of withRect) {
66
- if (s.type === "exterior" || s.path.startsWith(poly.path + "/")) continue;
67
- // 照合するのは割付ではなく**導出された領域** — 敷地なりに切った外形はここで通る
68
- for (const r of regionOf(s)) {
69
- const esc = shapeEscapesPolygon(r, poly.points, EPS_SITE);
70
- if (esc) {
71
- out.push(
72
- finding(
73
- "site.escape",
74
- `${s.path} escapes the site shape (near ${Math.round(esc.x)},${Math.round(esc.y)})`,
75
- { line: s.line, file: s.file, path: [s.path] },
76
- ),
77
- );
78
- break;
79
- }
80
- }
81
- }
82
- }
83
- return out;
84
- }