@kensnzk/koyu 0.28.0 → 0.29.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 (73) hide show
  1. package/README.ja.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/analysis/contracts.d.ts +1 -0
  4. package/dist/analysis/contracts.d.ts.map +1 -1
  5. package/dist/cli.js +14 -2
  6. package/dist/cli.js.map +1 -1
  7. package/dist/core/derive.d.ts +4 -1
  8. package/dist/core/derive.d.ts.map +1 -1
  9. package/dist/core/derive.js +3 -2
  10. package/dist/core/derive.js.map +1 -1
  11. package/dist/core/diagnose.d.ts +1 -0
  12. package/dist/core/diagnose.d.ts.map +1 -1
  13. package/dist/core/diagnose.js +4 -1
  14. package/dist/core/diagnose.js.map +1 -1
  15. package/dist/core/diff.d.ts +4 -0
  16. package/dist/core/diff.d.ts.map +1 -1
  17. package/dist/core/diff.js +4 -0
  18. package/dist/core/diff.js.map +1 -1
  19. package/dist/core/fabric.js +1 -1
  20. package/dist/core/fabric.js.map +1 -1
  21. package/dist/core/graph.d.ts +8 -0
  22. package/dist/core/graph.d.ts.map +1 -1
  23. package/dist/core/graph.js +31 -1
  24. package/dist/core/graph.js.map +1 -1
  25. package/dist/core/light.d.ts.map +1 -1
  26. package/dist/core/light.js +2 -0
  27. package/dist/core/light.js.map +1 -1
  28. package/dist/core/model.d.ts +16 -10
  29. package/dist/core/model.d.ts.map +1 -1
  30. package/dist/core/model.js +10 -8
  31. package/dist/core/model.js.map +1 -1
  32. package/dist/core/parse.d.ts.map +1 -1
  33. package/dist/core/parse.js +18 -0
  34. package/dist/core/parse.js.map +1 -1
  35. package/dist/draw/plan.d.ts.map +1 -1
  36. package/dist/draw/plan.js +10 -1
  37. package/dist/draw/plan.js.map +1 -1
  38. package/dist/mcp.js +1 -0
  39. package/dist/mcp.js.map +1 -1
  40. package/dist/validate/assessment.js +13 -2
  41. package/dist/validate/assessment.js.map +1 -1
  42. package/dist/validate/contracts.d.ts +1 -0
  43. package/dist/validate/contracts.d.ts.map +1 -1
  44. package/dist/validate/contracts.js.map +1 -1
  45. package/editors/vscode/syntaxes/koyu.tmLanguage.json +1 -1
  46. package/examples/basement/main.muro +1 -1
  47. package/examples/complex/main.muro +1 -1
  48. package/examples/house/main.muro +1 -1
  49. package/examples/house.muro +1 -1
  50. package/examples/mansion.muro +1 -1
  51. package/examples/office.muro +1 -1
  52. package/examples/spatial/layout.muro +8 -0
  53. package/examples/spatial/main.muro +4 -0
  54. package/examples/steps/06-finished.muro +1 -1
  55. package/examples/tower/main.muro +1 -1
  56. package/examples/twin/main.muro +1 -1
  57. package/examples/two-rooms.canonical.json +1 -1
  58. package/examples/two-rooms.muro +1 -1
  59. package/package.json +5 -4
  60. package/src/analysis/contracts.ts +1 -0
  61. package/src/cli.ts +13 -2
  62. package/src/core/derive.ts +6 -2
  63. package/src/core/diagnose.ts +3 -1
  64. package/src/core/diff.ts +3 -0
  65. package/src/core/fabric.ts +1 -1
  66. package/src/core/graph.ts +32 -0
  67. package/src/core/light.ts +1 -0
  68. package/src/core/model.ts +14 -9
  69. package/src/core/parse.ts +16 -0
  70. package/src/draw/plan.ts +9 -1
  71. package/src/mcp.ts +1 -0
  72. package/src/validate/assessment.ts +17 -3
  73. package/src/validate/contracts.ts +1 -0
@@ -4,7 +4,7 @@
4
4
  # 合成時にコンフリクト (パス・アセット・グリッドの重複) が検査され、一棟としてビルドされる。
5
5
  # koyu check examples/house/main.muro がそのビルドの門番になる。
6
6
 
7
- muro 1.5
7
+ muro 1.6
8
8
  name 小さな戸建住宅
9
9
  unit mm
10
10
 
@@ -7,7 +7,7 @@
7
7
  # 敷地 = zone site:1 (宣言面積と導出面積を site コマンドが突き合わせる)。
8
8
  # L1の平面図はそのまま配置図兼用になる。
9
9
 
10
- muro 1.5
10
+ muro 1.6
11
11
  name 小さな戸建住宅
12
12
  unit mm
13
13
 
@@ -4,7 +4,7 @@
4
4
  # 外部に対し open または air:1 (手すり等、遮蔽しない物) の境界を持つ空間として導出される)。
5
5
  # 基準階は一度だけ書く — /L2..L9/ のスパンが8フロアに展開される。
6
6
 
7
- muro 1.5
7
+ muro 1.6
8
8
  name 内廊下型集合住宅
9
9
  unit mm
10
10
 
@@ -2,7 +2,7 @@
2
2
  # 基本計画の解像度で書く。垂れ壁や建具詳細は表現しない — 省略ではなく抽象度の選択。
3
3
  # 高さの一貫性は level の宣言 (z / h / slab) と check の不変量が担保する。
4
4
 
5
- muro 1.5
5
+ muro 1.6
6
6
  name 小さなオフィス
7
7
  unit mm
8
8
 
@@ -0,0 +1,8 @@
1
+ grid X 0 4000 6000 10000
2
+ grid Y 0 2000 6000
3
+ level L1 0
4
+ level L2 3200
5
+ space /L1/a room X1..X2 Y2..Y3 uid:space-a name:"Room A"
6
+ space /L1/b room X2..X4 Y2..Y3 uid:space-b name:"Room B"
7
+ space /L1/c circulation X1..X4 Y1..Y2 uid:space-c name:"Shared space"
8
+ space /L2/d room X1..X2 Y1..Y3 uid:space-d name:"Upper space"
@@ -0,0 +1,4 @@
1
+ muro 1.6
2
+ mode spatial
3
+ name Spatial study
4
+ import layout.muro
@@ -1,4 +1,4 @@
1
- muro 1.5
1
+ muro 1.6
2
2
  name 小さな家
3
3
 
4
4
  grid X 0 3600 5400
@@ -5,7 +5,7 @@
5
5
  # L1-L2 商業 / L3-L10 住宅基準階 (L3は低層部屋根のテラス付き例外階) / L11 ペントハウス
6
6
  # koyu check examples/tower/main.muro が一棟のビルドの門番。
7
7
 
8
- muro 1.5
8
+ muro 1.6
9
9
  name 街角の複合ビル — 低層商業+高層住宅
10
10
  unit mm
11
11
 
@@ -28,7 +28,7 @@
28
28
  # koyu plan examples/twin/main.muro -l L8 A棟基準階とB棟ホテル階
29
29
  # koyu axo examples/twin/main.muro -l L1,L2,L3,L4,L5
30
30
 
31
- muro 1.5
31
+ muro 1.6
32
32
  name 双塔複合建築 — 商業・事務所・ホテル・レジデンス
33
33
  unit mm
34
34
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": "koyu-canonical/2.0",
3
- "muro": "1.5",
3
+ "muro": "1.6",
4
4
  "name": "二室",
5
5
  "unit": "mm",
6
6
  "grid": {
@@ -4,7 +4,7 @@
4
4
  # 書いてあるのは、扉を吊るために宣言した境界と、外皮の境界だけ。
5
5
  # 両室に daylight:1 を書いたので、窓が要る — `koyu light` が 1/7 を確かめる (ADR-0020)。
6
6
 
7
- muro 1.5
7
+ muro 1.6
8
8
  name 二室
9
9
  unit mm
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kensnzk/koyu",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "muro": {
5
5
  "reads": [
6
6
  "0.1",
@@ -13,9 +13,10 @@
13
13
  "1.2",
14
14
  "1.3",
15
15
  "1.4",
16
- "1.5"
16
+ "1.5",
17
+ "1.6"
17
18
  ],
18
- "newest": "1.5",
19
+ "newest": "1.6",
19
20
  "undeclared": "1.1"
20
21
  },
21
22
  "description": "A text-native architectural notation with space as the primary element",
@@ -97,7 +98,7 @@
97
98
  "prepare": "npm run build",
98
99
  "test": "node --import tsx --test test/*.test.ts",
99
100
  "typecheck": "tsc --noEmit",
100
- "check:examples": "for f in examples/two-rooms.muro examples/office.muro examples/mansion.muro examples/house.muro examples/house/main.muro examples/tower/main.muro examples/basement/main.muro examples/complex/main.muro examples/twin/main.muro examples/steps/*.muro skills/koyu-author/examples/flat-1ldk.muro skills/koyu-author/examples/office/main.muro; do tsx src/cli.ts check $f || exit 1; done",
101
+ "check:examples": "for f in examples/spatial/main.muro examples/two-rooms.muro examples/office.muro examples/mansion.muro examples/house.muro examples/house/main.muro examples/tower/main.muro examples/basement/main.muro examples/complex/main.muro examples/twin/main.muro examples/steps/*.muro skills/koyu-author/examples/flat-1ldk.muro skills/koyu-author/examples/office/main.muro; do tsx src/cli.ts check $f || exit 1; done",
101
102
  "gate:examples": "node --import tsx scripts/gate.mjs",
102
103
  "plan:examples": "tsx src/cli.ts plan examples/two-rooms.muro -o out/two-rooms.svg",
103
104
  "conformance": "node --import tsx --test test/conformance.test.ts",
@@ -235,6 +235,7 @@ export interface AnalysisReport<T extends JsonValue = JsonValue> {
235
235
  readonly profile: ComponentIdentity;
236
236
  readonly model: {
237
237
  readonly languageVersion: string;
238
+ readonly mode?: "spatial";
238
239
  readonly name?: string;
239
240
  readonly state: "consistent" | "inconsistent";
240
241
  readonly diagnostics: readonly Diagnostic[];
package/src/cli.ts CHANGED
@@ -310,7 +310,9 @@ function main(argv: string[]): number {
310
310
  );
311
311
  // **緑の意味を、緑を出す場所で言う。**構造整合が成り立っただけであって、
312
312
  // 建築として妥当かはここでは何も言っていない (docs/reference/scope.md)
313
- console.log(" Structural consistency only — architectural validity is what koyu validate says, separately");
313
+ console.log(model.mode === "spatial"
314
+ ? " Spatial model — unwritten boundaries are unresolved; architectural assessment is not evaluated"
315
+ : " Structural consistency only — architectural validity is what koyu validate says, separately");
314
316
  return strict && warnings.length > 0 ? 1 : 0;
315
317
  }
316
318
  return 1;
@@ -334,7 +336,7 @@ function main(argv: string[]): number {
334
336
  const violations = report.findings.filter((f) => f.level === "violation").length;
335
337
  const cautions = report.findings.length - violations;
336
338
  console.log(
337
- report.findings.length === 0
339
+ model.mode === "spatial" ? "Spatial model — architectural assessment is not evaluated" : report.findings.length === 0
338
340
  ? "✔ Nothing caught by validation (this is a judgement, not a guarantee about the composition)"
339
341
  : `Validation — ${qty(violations, "violation", "violations")} / ${qty(cautions, "caution", "cautions")}`,
340
342
  );
@@ -388,6 +390,10 @@ function main(argv: string[]): number {
388
390
  return 0;
389
391
  }
390
392
  case "doors": {
393
+ if (model.mode === "spatial") {
394
+ console.error("Circulation is not evaluated in spatial mode");
395
+ return 2;
396
+ }
391
397
  const [from, to] = rest;
392
398
  if (!from || !to) {
393
399
  console.log("Usage: koyu doors <file> /pathA /pathB");
@@ -402,6 +408,7 @@ function main(argv: string[]): number {
402
408
  return 0;
403
409
  }
404
410
  case "graph": {
411
+ if (model.mode === "spatial") console.log("Spatial model — declared relations only; missing boundaries are unresolved");
405
412
  for (const s of model.spaces.values()) {
406
413
  const ns = neighbors(model, s.path);
407
414
  console.log(`${s.path} (${displayName(s)})`);
@@ -506,6 +513,10 @@ function main(argv: string[]): number {
506
513
  return 0;
507
514
  }
508
515
  case "light": {
516
+ if (model.mode === "spatial") {
517
+ console.error("Daylight is not evaluated in spatial mode");
518
+ return 2;
519
+ }
509
520
  // **数だけを返す。**床面積と有効窓面積は模型から出る事実であり、そこへ線を引くのは
510
521
  // 規則の側の仕事である。閾値をここに書けば validate と二重になり、片方だけが古くなる
511
522
  // (docs/reference/scope.md)。合否は koyu validate が言う
@@ -19,7 +19,7 @@
19
19
  // 切断高さは Form の**入力**であって中身ではない。
20
20
 
21
21
  import { CEILING_T, ROOF_T, slabs, type Slab } from "./fabric.js";
22
- import { placeBand, placeOpening, segmentLength, segmentsFor, type Segment } from "./graph.js";
22
+ import { placeBand, placeOpening, segmentLength, segmentsFor, unresolvedBoundaries, type UnresolvedBoundary, type Segment } from "./graph.js";
23
23
  import {
24
24
  areaM2,
25
25
  columnsFor,
@@ -341,6 +341,9 @@ export interface FormPlan {
341
341
  * 座標・厚み・z 範囲・向き・対象の同一性だけを持ち、描き方は消費者が決める
342
342
  */
343
343
  export interface Form {
344
+ /** Present only in spatial mode. These faces have no physical or passage meaning. */
345
+ mode?: "spatial";
346
+ unresolved?: UnresolvedBoundary[];
344
347
  input: FormInput;
345
348
  levels: FormLevel[];
346
349
  spaces: FormSpace[];
@@ -380,7 +383,7 @@ export function levelPitch(model: Model, level: string): number | undefined {
380
383
  const h = heff(model, s);
381
384
  if (h !== undefined && (top === undefined || h > top)) top = h;
382
385
  }
383
- return top === undefined ? undefined : top + ROOF_T;
386
+ return top === undefined ? undefined : top + (model.mode === "spatial" ? 0 : ROOF_T);
384
387
  }
385
388
 
386
389
  /** 境界が立つレベル — 領域を持つ側の空間が決める (a を先に見る) */
@@ -1048,6 +1051,7 @@ export function derive(model: Model, opts: DeriveOptions = {}): Form {
1048
1051
  );
1049
1052
 
1050
1053
  return {
1054
+ ...(model.mode === "spatial" ? { mode: model.mode, unresolved: unresolvedBoundaries(model) } : {}),
1051
1055
  input: { cut },
1052
1056
  levels: formLevels,
1053
1057
  spaces,
@@ -147,6 +147,7 @@ export const DIAGNOSTIC_CODES = {
147
147
  VER07: "error", // the file declares a version in which a key it writes is retired (ADR-0061)
148
148
  VER08: "error", // the file uses opening presentation introduced in muro 1.5 (ADR-0068/0074)
149
149
  VER09: "error", // the file uses component assets or area placement introduced in muro 1.5
150
+ VER10: "error", // spatial mode requires muro 1.6
150
151
  SYN01: "error", // 構文・合成エラー (SourceError の写し — check --json のみ)
151
152
  } as const satisfies Record<string, "error" | "warning">;
152
153
 
@@ -1373,7 +1374,7 @@ function checkSpaceSufficiency(ctx: Ctx): void {
1373
1374
  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);
1374
1375
  continue; // z が決まらない空間には、天井高を問う意味が無い
1375
1376
  }
1376
- if (isVoid(s) || isOutside(s) || isSemiOutdoor(model, s)) continue;
1377
+ if (model.mode === "spatial" || isVoid(s) || isOutside(s) || isSemiOutdoor(model, s)) continue;
1377
1378
  if (heff(model, s) === undefined) {
1378
1379
  emit(
1379
1380
  "SUF01",
@@ -1392,6 +1393,7 @@ function checkSpaceSufficiency(ctx: Ctx): void {
1392
1393
  * 決定的な規則であり、複数の形が出るわけではない。ただし床の無い建物になることは知らされるべきである
1393
1394
  */
1394
1395
  function checkLevelSufficiency(ctx: Ctx): void {
1396
+ if (ctx.model.mode === "spatial") return;
1395
1397
  const { emit, withRect, levels } = ctx;
1396
1398
  for (const l of levels) {
1397
1399
  if (l.slab !== undefined) continue;
package/src/core/diff.ts CHANGED
@@ -87,6 +87,7 @@ export interface BoundaryChange {
87
87
 
88
88
  export interface ModelDiff {
89
89
  version?: { from: string; to: string };
90
+ mode?: { from: "building" | "spatial"; to: "building" | "spatial" };
90
91
  name?: { from?: string; to?: string };
91
92
  grid: GridChange[];
92
93
  levels: { added: string[]; removed: string[]; changed: ChangedItem[] };
@@ -464,6 +465,7 @@ export function semanticDiff(a: Model, b: Model): ModelDiff {
464
465
  boundaries: { added: [], removed: [], changed: [] },
465
466
  columns: { added: [], removed: [], changed: [] },
466
467
  };
468
+ if (a.mode !== b.mode) d.mode = { from: a.mode ?? "building", to: b.mode ?? "building" };
467
469
  if (a.version !== b.version) d.version = { from: a.version, to: b.version };
468
470
  if (a.name !== b.name) {
469
471
  d.name = { ...(a.name !== undefined ? { from: a.name } : {}), ...(b.name !== undefined ? { to: b.name } : {}) };
@@ -689,6 +691,7 @@ export function renderDiff(d: ModelDiff): string[] {
689
691
  // **The label names the language, not the implementation.** It also may not be the written
690
692
  // declaration: from 1.2 the word is `muro`, so printing `koyu 1.2` would show a line the
691
693
  // parser refuses. This is a label for a change, not a copy of either file's first line.
694
+ if (d.mode) out.push(`± mode ${d.mode.from} → ${d.mode.to}`);
692
695
  if (d.version) out.push(`± muro ${d.version.from} → ${d.version.to}`);
693
696
  if (d.name) out.push(`± name ${d.name.from ?? "—"} → ${d.name.to ?? "—"}`);
694
697
  for (const n of d.levels.added) out.push(`+ level ${n}`);
@@ -109,7 +109,7 @@ export function slabs(model: Model): Slab[] {
109
109
  // 吹抜けは、天窓で塞がれた竪穴か、空に開いた中庭かのどちらかであり、
110
110
  // 後者は半屋外として導出される (ADR-0007)。だから除くのは外部と半屋外だけである。
111
111
  // 逆に**覆っている側には吹抜けも数える** — 竪穴の途中の階に屋根は架からない。
112
- if (isExterior || semi) continue;
112
+ if (model.mode === "spatial" || isExterior || semi) continue;
113
113
  // **覆っているものも導出された形で取る。**割付で取ると、上階を斜めに切った
114
114
  // 範囲まで「覆われている」と数えてしまい、その真下に屋根が架からなかった
115
115
  const covers: Pt[][] = [];
package/src/core/graph.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  import type { Boundary, Edge, Model, Opening, Pt, Rect, Space } from "./model.js";
7
7
  import {
8
8
  canonicalBoundaryOrder,
9
+ canonicalSpaceOrder,
9
10
  canonicalizeDrawn,
10
11
  compareCanonical,
11
12
  EXTERIOR,
@@ -152,6 +153,35 @@ export function mergeCollinear(segs: Segment[]): Segment[] {
152
153
  return out;
153
154
  }
154
155
 
156
+ /** An allocated face with no boundary declaration; it asserts no wall or passage. */
157
+ export interface UnresolvedBoundary {
158
+ a: string;
159
+ b: string;
160
+ level: string;
161
+ segment: Segment;
162
+ }
163
+
164
+ export function unresolvedBoundaries(model: Model): UnresolvedBoundary[] {
165
+ if (model.mode !== "spatial") return [];
166
+ const spaces = canonicalSpaceOrder(model).filter(s => s.rects.length > 0 && s.level !== undefined);
167
+ const result: UnresolvedBoundary[] = [];
168
+ for (let i = 0; i < spaces.length; i++) {
169
+ const a = spaces[i]!;
170
+ for (let j = i + 1; j < spaces.length; j++) {
171
+ const b = spaces[j]!;
172
+ if (a.level !== b.level) continue;
173
+ let segments = sharedFromPieces(piecesOf(a), piecesOf(b));
174
+ for (const boundary of model.boundaries) {
175
+ if (!((boundary.a === a.path && boundary.b === b.path) || (boundary.a === b.path && boundary.b === a.path))) continue;
176
+ for (const covered of segmentsFor(model, boundary)) segments = segments.flatMap(s => subtractOverlap(s, covered));
177
+ }
178
+ for (const segment of segments) result.push({ a: a.path, b: b.path, level: a.level!, segment });
179
+ }
180
+ for (const segment of envelopeGaps(model, a)) result.push({ a: a.path, b: EXTERIOR, level: a.level!, segment });
181
+ }
182
+ return result;
183
+ }
184
+
155
185
  /**
156
186
  * 既定境界の導出 (ADR-0014) — 垂直の「既定は床」と対称の、水平の「既定は壁」。
157
187
  * 同一レベル (未特定同士を含む) で平面が接する領域つき空間の組に、宣言境界がその組に
@@ -160,6 +190,7 @@ export function mergeCollinear(segs: Segment[]): Segment[] {
160
190
  * 合成・スパン展開の完了後に呼ぶ (parse / parseWith の出口)。冪等。
161
191
  */
162
192
  export function deriveDefaultBoundaries(model: Model): void {
193
+ if (model.mode === "spatial") return;
163
194
  const declared = new Set<string>();
164
195
  for (const b of model.boundaries) declared.add([b.a, b.b].sort().join("|"));
165
196
  const withRect = [...model.spaces.values()].filter((s) => s.rects.length > 0);
@@ -770,6 +801,7 @@ export interface Route {
770
801
 
771
802
  /** aからbまで扉をいくつ通るか (最小)。到達不能なら undefined */
772
803
  export function doorsBetween(model: Model, from: string, to: string): Route | undefined {
804
+ if (model.mode === "spatial") throw new Error("Circulation is not evaluated in spatial mode");
773
805
  if (!model.spaces.has(from) || !model.spaces.has(to)) return undefined;
774
806
  const dist = new Map<string, number>();
775
807
  const prev = new Map<string, string>();
package/src/core/light.ts CHANGED
@@ -33,6 +33,7 @@ export interface DaylightInput {
33
33
  * 上が開いた半屋外越しなら1.0。この係数は形の導出であって判定ではない。
34
34
  */
35
35
  export function daylightInputs(model: Model): DaylightInput[] {
36
+ if (model.mode === "spatial") throw new Error("Daylight is not evaluated in spatial mode");
36
37
  const out: DaylightInput[] = [];
37
38
  for (const s of model.spaces.values()) {
38
39
  if (s.rects.length === 0) continue;
package/src/core/model.ts CHANGED
@@ -56,6 +56,7 @@ export const MURO_SUPPORT: readonly { muro: string; since: string; until: string
56
56
  // place fixed furniture or equipment footprints while keeping SVG artwork out of Form
57
57
  // (ADR-0068, ADR-0075).
58
58
  { muro: "1.5", since: "0.28.0", until: null },
59
+ { muro: "1.6", since: "0.29.0", until: null },
59
60
  ];
60
61
 
61
62
  /** The word a version line is written with from 1.2 on. */
@@ -82,7 +83,7 @@ export const LAST_KOYU_SPELLED_VERSION = "1.1";
82
83
  * `since` column is written in this vocabulary, and every surface that answers "which muro
83
84
  * does this build speak" needs both halves at once.
84
85
  */
85
- export const KOYU_VERSION = "0.28.0";
86
+ export const KOYU_VERSION = "0.29.0";
86
87
 
87
88
  /**
88
89
  * Whether `a` names a later language version than `b`.
@@ -203,18 +204,18 @@ export const NEWEST_LANGUAGE_VERSION = SUPPORTED_LANGUAGE_VERSIONS[SUPPORTED_LAN
203
204
  export const DEFAULT_LANGUAGE_VERSION = "1.1";
204
205
 
205
206
  /**
206
- * 機械形式 (正準JSON) が自分を名乗る版 (ADR-0036)。**言語版でもツール版でもない** —
207
- * 数えるのは綴りだけである。minorはキーが増えたとき、majorは既存のキーの名前・並び・照合順・
208
- * 正規化・数の綴りが変わったとき。**minorでも全ての文書のバイトは動く** — この文字列自体が
209
- * 第一キーだからで、増えたキーを持たない文書も先頭行だけは変わる (ADR-0051 が実測している)。
210
- * 意味論の版は muro が持つので、`muro` キー (書かれた版宣言の素通し) とは別の面である。
207
+ * The canonical spelling version is independent of the language and package versions.
208
+ * A format bump changes every document's bytes, including unchanged older sources.
209
+ * The optional `mode` key is gated by an explicit Muro 1.6 declaration and spatial opt-in;
210
+ * it keeps format 2.0 so building documents retain their existing canonical bytes.
211
+ * Consumers must understand the declared language and mode before interpreting a document.
211
212
  *
212
213
  * The format keeps the name `koyu` because it is the implementation's output spelling — the
213
214
  * shape koyu writes. The key inside it names the language, and is spelled `muro` for the same
214
215
  * reason the version line is.
215
216
  *
216
- * **That rename is why this is 2.0 and not 1.3.** An existing key changed its name, which the
217
- * rule above puts squarely in major. Shipping it as a minor would have told every reader that
217
+ * **That rename introduced 2.0 rather than 1.3.** An existing key changed its name, which the
218
+ * format policy puts squarely in major. Shipping it as a minor would have told every reader that
218
219
  * `1.x` stays compatible — so a reader expecting `koyu` would have accepted the document and
219
220
  * found no language version in it, which is the silent misread the format version exists to
220
221
  * prevent.
@@ -477,6 +478,9 @@ export function srcRef(line: number, file?: string): string {
477
478
 
478
479
  export interface Model {
479
480
  version: string;
481
+ /** Absent means the building reading. Spatial mode leaves unwritten boundaries unresolved. */
482
+ mode?: "spatial";
483
+ modeSource?: { line: number; file?: string };
480
484
  name?: string;
481
485
  unit: "mm";
482
486
  /**
@@ -701,7 +705,7 @@ export class SourceError extends Error {
701
705
  * module, so the union cannot be imported here — and widening it to `string` would let
702
706
  * a typo reach `check --json` as a code no page documents.
703
707
  */
704
- public code?: "VER06",
708
+ public code?: "VER06" | "VER10",
705
709
  ) {
706
710
  super(`${file ? `${file}:` : ""}line ${line}: ${raw}`);
707
711
  this.name = "SourceError";
@@ -1214,6 +1218,7 @@ export function toCanonical(model: Model): string {
1214
1218
  // A document written `koyu 1.1` still says `"muro": "1.1"` here: the key is the name of
1215
1219
  // the thing being versioned, not a copy of how the author spelled the declaration.
1216
1220
  ...(model.versionDeclared ? { muro: model.version } : {}),
1221
+ ...(model.mode ? { mode: model.mode } : {}),
1217
1222
  ...(model.name ? { name: model.name } : {}),
1218
1223
  unit: model.unit,
1219
1224
  // 測地の枠 (ADR-0057) — **単位を言った直後、グリッドを言う前。**この二つは grid が張る
package/src/core/parse.ts CHANGED
@@ -66,6 +66,12 @@ interface BandMember {
66
66
  line: number;
67
67
  }
68
68
 
69
+ function checkModeVersion(model: Model): void {
70
+ if (model.mode && !isNewerVersion(model.version, "1.5")) {
71
+ throw new SourceError(model.modeSource?.line ?? 0, "mode spatial requires muro 1.6", model.modeSource?.file, "VER10");
72
+ }
73
+ }
74
+
69
75
  function emptyModel(): Model {
70
76
  return {
71
77
  version: DEFAULT_LANGUAGE_VERSION,
@@ -100,6 +106,7 @@ export function parse(source: string): Model {
100
106
  // 描かれた線で領域を切り分けてから、既定の壁を導く (ADR-0022 / docs/reference/form/index.md)。
101
107
  // 逆順だと、線で接触が消えた組にも既定境界が生まれ、線分ゼロの境界に
102
108
  // 出所の無い BND04 が出る — 書いていない関係を責めることになる
109
+ checkModeVersion(model);
103
110
  derivePieces(model);
104
111
  deriveDefaultBoundaries(model);
105
112
  return model;
@@ -121,6 +128,7 @@ export function parseWith(loader: LayerLoader, entry: string): Model {
121
128
  // 描かれた線で領域を切り分けてから、既定の壁を導く (ADR-0022 / docs/reference/form/index.md)。
122
129
  // 逆順だと、線で接触が消えた組にも既定境界が生まれ、線分ゼロの境界に
123
130
  // 出所の無い BND04 が出る — 書いていない関係を責めることになる
131
+ checkModeVersion(model);
124
132
  derivePieces(model);
125
133
  deriveDefaultBoundaries(model);
126
134
  return model;
@@ -328,6 +336,14 @@ function ingest(
328
336
  model.versionDeclared = true;
329
337
  break;
330
338
  }
339
+ case "mode": {
340
+ if (rest.length !== 1 || rest[0] !== "spatial") throw new SourceError(ln, "mode takes exactly one value: spatial");
341
+ if (file !== undefined && model.layers[0] !== file) throw new SourceError(ln, "The mode is declared only in the base layer (the entry)");
342
+ if (model.mode) throw new SourceError(ln, "The mode is declared once");
343
+ model.mode = "spatial";
344
+ model.modeSource = { line: ln, ...(file ? { file } : {}) };
345
+ break;
346
+ }
331
347
  case "import": {
332
348
  const rel = rest[0];
333
349
  if (!rel) throw new SourceError(ln, "import takes a relative path: import ./assets.muro");
package/src/draw/plan.ts CHANGED
@@ -97,6 +97,13 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
97
97
  }
98
98
  }
99
99
 
100
+ if (form.mode === "spatial") {
101
+ parts.push(`<desc>Spatial model: dashed faces are unresolved; circulation, daylight and egress are not evaluated.</desc>`);
102
+ for (const face of form.unresolved ?? []) {
103
+ if (face.level === level) parts.push(`<g data-unresolved="true">${line(face.segment, FAINT, 1, "6 4")}</g>`);
104
+ }
105
+ }
106
+
100
107
  // Uncounted area subdivisions, such as a floor-finish change, reproduce the written input.
101
108
  for (const s of modelRooms) {
102
109
  for (const a of s.areas) {
@@ -424,7 +431,8 @@ export function svgPlan(model: Model, opts: PlanOptions = {}): string {
424
431
  }
425
432
 
426
433
  // Sheet title.
427
- const title = `${model.name ?? "Untitled"} — ${level} plan`;
434
+ const title = `${model.name ?? "Untitled"} — ${level} ${model.mode === "spatial" ? "spatial plan" : "plan"}`;
435
+ if (model.mode === "spatial") parts.push(`<text x="${M - 62}" y="${H - 38}" font-size="9" fill="${FAINT}">Dashed: unresolved boundary</text>`);
428
436
  parts.push(`<text x="${M - 62}" y="${H - 18}" font-size="12" fill="${INK}">${esc(title)}</text>`);
429
437
 
430
438
  parts.push("</svg>");
package/src/mcp.ts CHANGED
@@ -113,6 +113,7 @@ function summarize(model: Model, file: string, by: readonly string[] = []): unkn
113
113
  const components = placedComponents(model).components;
114
114
  return {
115
115
  name: model.name,
116
+ ...(model.mode ? { mode: model.mode } : {}),
116
117
  unit: model.unit,
117
118
  layers: layerFiles(model),
118
119
  levels: levelsSorted(model).map((l) => ({
@@ -215,7 +215,7 @@ export function assess(model: Model, options: AssessmentOptions): AssessmentRepo
215
215
  }
216
216
  }
217
217
 
218
- const summary = summarize(prepared.modelState, runs);
218
+ const summary = { ...summarize(prepared.modelState, runs), ...(prepared.spatial ? { state: "incomplete" as const } : {}) };
219
219
  const report: AssessmentReport = {
220
220
  schema: ASSESSMENT_FORMAT,
221
221
  profile: identityOf(prepared.profile),
@@ -237,9 +237,10 @@ interface PreparedRun {
237
237
  readonly usedContext: Set<string>;
238
238
  readonly diagnostics: readonly Diagnostic[];
239
239
  readonly modelState: "consistent" | "inconsistent";
240
+ readonly spatial: boolean;
240
241
  }
241
242
 
242
- type PreparedConfiguration = Omit<PreparedRun, "diagnostics" | "modelState">;
243
+ type PreparedConfiguration = Omit<PreparedRun, "diagnostics" | "modelState" | "spatial">;
243
244
 
244
245
  function prepareConfiguration(options: AssessmentOptions): PreparedConfiguration {
245
246
  try {
@@ -290,7 +291,7 @@ function diagnoseModel(model: Model, configured: PreparedConfiguration): Prepare
290
291
  const modelState = diagnostics.some((diagnostic) => diagnostic.severity === "error")
291
292
  ? "inconsistent"
292
293
  : "consistent";
293
- return { ...configured, diagnostics, modelState };
294
+ return { ...configured, diagnostics, modelState, spatial: model.mode === "spatial" };
294
295
  }
295
296
 
296
297
  function preflightRegistry(input: AssessmentRegistryInput): void {
@@ -1024,6 +1025,12 @@ class AnalysisSession {
1024
1025
  )) as AnalysisArtifact<T>;
1025
1026
  }
1026
1027
  const definition = requireResolved(reference, this.definitions, reference, "analysis");
1028
+ if (this.model.mode === "spatial") {
1029
+ return this.store(reference, unavailable(
1030
+ [{ kind: "model", subjects: [{ kind: "model", ref: "/" }], reason: "spatial mode leaves physical boundaries unresolved" }],
1031
+ [{ kind: "koyu.spatial-model", message: "Analysis is not evaluated in spatial mode" }],
1032
+ )) as AnalysisArtifact<T>;
1033
+ }
1027
1034
 
1028
1035
  const dependencyArtifacts = new Map<string, AnalysisArtifact<JsonValue>>();
1029
1036
  const dependencyMissing: MissingInput[] = [];
@@ -1106,6 +1113,12 @@ function executeRule(
1106
1113
  prepared: PreparedRun,
1107
1114
  ): RuleRun {
1108
1115
  const identity = { rule: identityOf(rule), ruleSet: identityOf(ruleSet) };
1116
+ if (prepared.spatial) return {
1117
+ ...identity, state: "indeterminate",
1118
+ evaluation: { applicability: "indeterminate", reason: "Architectural assessment is not evaluated in spatial mode",
1119
+ missing: [{ kind: "model", subjects: [{ kind: "model", ref: "/" }], reason: "spatial mode leaves physical boundaries unresolved" }], evidence: [] },
1120
+ issues: [{ kind: "koyu.spatial-model", message: "Switch to the building reading before architectural assessment" }],
1121
+ };
1109
1122
  const artifacts = new Map<string, AnalysisArtifact<JsonValue>>();
1110
1123
  const missing: MissingInput[] = [];
1111
1124
  const issues: ExecutionIssue[] = [];
@@ -1773,6 +1786,7 @@ function modelReport(
1773
1786
  ): AnalysisReport["model"] {
1774
1787
  return {
1775
1788
  languageVersion: model.version,
1789
+ ...(model.mode ? { mode: model.mode } : {}),
1776
1790
  ...(model.name !== undefined ? { name: model.name } : {}),
1777
1791
  state,
1778
1792
  diagnostics: diagnostics.map((diagnostic) => ({
@@ -157,6 +157,7 @@ export interface AssessmentReport {
157
157
  readonly ruleSets: readonly ComponentIdentity[];
158
158
  readonly model: {
159
159
  readonly languageVersion: string;
160
+ readonly mode?: "spatial";
160
161
  readonly name?: string;
161
162
  readonly state: "consistent" | "inconsistent";
162
163
  readonly diagnostics: readonly Diagnostic[];