@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.
- package/README.ja.md +12 -8
- package/README.md +13 -10
- package/dist/analysis/contracts.d.ts +217 -0
- package/dist/analysis/contracts.d.ts.map +1 -0
- package/dist/analysis/contracts.js +27 -0
- package/dist/analysis/contracts.js.map +1 -0
- package/dist/analysis/index.d.ts +5 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +17 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/json.d.ts +21 -0
- package/dist/analysis/json.d.ts.map +1 -0
- package/dist/analysis/json.js +111 -0
- package/dist/analysis/json.js.map +1 -0
- package/dist/cli.js +106 -35
- package/dist/cli.js.map +1 -1
- package/dist/core/derive.d.ts +13 -8
- package/dist/core/derive.d.ts.map +1 -1
- package/dist/core/derive.js +19 -13
- package/dist/core/derive.js.map +1 -1
- package/dist/core/diagnose.d.ts +4 -3
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +46 -11
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/diff.d.ts +3 -2
- package/dist/core/diff.d.ts.map +1 -1
- package/dist/core/diff.js +8 -5
- package/dist/core/diff.js.map +1 -1
- package/dist/core/fabric.d.ts +1 -3
- package/dist/core/fabric.d.ts.map +1 -1
- package/dist/core/fabric.js +8 -8
- package/dist/core/fabric.js.map +1 -1
- package/dist/core/graph.d.ts +2 -2
- package/dist/core/graph.d.ts.map +1 -1
- package/dist/core/graph.js +12 -5
- package/dist/core/graph.js.map +1 -1
- package/dist/core/light.d.ts.map +1 -1
- package/dist/core/light.js +2 -2
- package/dist/core/light.js.map +1 -1
- package/dist/core/model.d.ts +59 -10
- package/dist/core/model.d.ts.map +1 -1
- package/dist/core/model.js +128 -26
- package/dist/core/model.js.map +1 -1
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/parse.js +83 -82
- package/dist/core/parse.js.map +1 -1
- package/dist/core/poly.d.ts +0 -4
- package/dist/core/poly.d.ts.map +1 -1
- package/dist/core/poly.js +1 -5
- package/dist/core/poly.js.map +1 -1
- package/dist/core/site.d.ts +9 -0
- package/dist/core/site.d.ts.map +1 -1
- package/dist/core/site.js +8 -2
- package/dist/core/site.js.map +1 -1
- package/dist/core/tolerance.d.ts +1 -1
- package/dist/core/tolerance.js +2 -2
- package/dist/core/tolerance.js.map +1 -1
- package/dist/core/vertical.d.ts +9 -2
- package/dist/core/vertical.d.ts.map +1 -1
- package/dist/core/vertical.js +8 -1
- package/dist/core/vertical.js.map +1 -1
- package/dist/core/vocabulary.d.ts.map +1 -1
- package/dist/core/vocabulary.js +17 -5
- package/dist/core/vocabulary.js.map +1 -1
- package/dist/diagnostics.d.ts +2 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +3 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/diff.d.ts +2 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +3 -0
- package/dist/diff.js.map +1 -0
- package/dist/draw/index.js +1 -1
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/plan.js +5 -5
- package/dist/draw/plan.js.map +1 -1
- package/dist/form.d.ts +5 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +4 -0
- package/dist/form.js.map +1 -0
- package/dist/graph.d.ts +2 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +3 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +2 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -45
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +81 -30
- package/dist/mcp.js.map +1 -1
- package/dist/model.d.ts +3 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +3 -0
- package/dist/model.js.map +1 -0
- package/dist/parse-file.d.ts.map +1 -1
- package/dist/parse-file.js +18 -3
- package/dist/parse-file.js.map +1 -1
- package/dist/validate/assessment.d.ts +8 -0
- package/dist/validate/assessment.d.ts.map +1 -0
- package/dist/validate/assessment.js +1738 -0
- package/dist/validate/assessment.js.map +1 -0
- package/dist/validate/builtin/access.d.ts +55 -0
- package/dist/validate/builtin/access.d.ts.map +1 -0
- package/dist/validate/builtin/access.js +494 -0
- package/dist/validate/builtin/access.js.map +1 -0
- package/dist/validate/builtin/daylight.d.ts +44 -0
- package/dist/validate/builtin/daylight.d.ts.map +1 -0
- package/dist/validate/builtin/daylight.js +233 -0
- package/dist/validate/builtin/daylight.js.map +1 -0
- package/dist/validate/builtin/door-column-collisions.d.ts +47 -0
- package/dist/validate/builtin/door-column-collisions.d.ts.map +1 -0
- package/dist/validate/builtin/door-column-collisions.js +189 -0
- package/dist/validate/builtin/door-column-collisions.js.map +1 -0
- package/dist/validate/builtin/envelope.d.ts +30 -0
- package/dist/validate/builtin/envelope.d.ts.map +1 -0
- package/dist/validate/builtin/envelope.js +169 -0
- package/dist/validate/builtin/envelope.js.map +1 -0
- package/dist/validate/builtin/freeze.d.ts +3 -0
- package/dist/validate/builtin/freeze.d.ts.map +1 -0
- package/dist/validate/builtin/freeze.js +21 -0
- package/dist/validate/builtin/freeze.js.map +1 -0
- package/dist/validate/builtin/index.d.ts +38 -0
- package/dist/validate/builtin/index.d.ts.map +1 -0
- package/dist/validate/builtin/index.js +106 -0
- package/dist/validate/builtin/index.js.map +1 -0
- package/dist/validate/builtin/site.d.ts +62 -0
- package/dist/validate/builtin/site.d.ts.map +1 -0
- package/dist/validate/builtin/site.js +333 -0
- package/dist/validate/builtin/site.js.map +1 -0
- package/dist/validate/builtin/vertical-runs.d.ts +53 -0
- package/dist/validate/builtin/vertical-runs.d.ts.map +1 -0
- package/dist/validate/builtin/vertical-runs.js +290 -0
- package/dist/validate/builtin/vertical-runs.js.map +1 -0
- package/dist/validate/contracts.d.ts +188 -0
- package/dist/validate/contracts.d.ts.map +1 -0
- package/dist/validate/contracts.js +28 -0
- package/dist/validate/contracts.js.map +1 -0
- package/dist/validate/index.d.ts +2 -59
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +22 -70
- package/dist/validate/index.js.map +1 -1
- package/dist/vocabulary.d.ts +2 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +3 -0
- package/dist/vocabulary.js.map +1 -0
- package/editors/vscode/syntaxes/koyu.tmLanguage.json +2 -2
- package/examples/basement/main.muro +3 -3
- package/examples/complex/main.muro +1 -1
- package/examples/complex/podium.muro +1 -1
- package/examples/complex/site.muro +6 -6
- package/examples/house/L2.muro +1 -1
- package/examples/house/main.muro +1 -1
- package/examples/house/site.muro +4 -4
- package/examples/house.muro +6 -6
- package/examples/mansion.muro +2 -2
- package/examples/office.muro +3 -3
- package/examples/steps/04-exterior.muro +1 -1
- package/examples/steps/05-two-storeys.muro +1 -1
- package/examples/steps/06-finished.muro +2 -2
- package/examples/tower/L2.muro +1 -1
- package/examples/tower/main.muro +1 -1
- package/examples/tower/site.muro +4 -4
- package/examples/twin/main.muro +1 -1
- package/examples/twin/podium.muro +4 -4
- package/examples/twin/site.muro +8 -8
- package/examples/two-rooms.canonical.json +4 -4
- package/examples/two-rooms.muro +2 -2
- package/package.json +41 -9
- package/src/analysis/contracts.ts +234 -0
- package/src/analysis/index.ts +61 -0
- package/src/analysis/json.ts +117 -0
- package/src/cli.ts +116 -36
- package/src/core/derive.ts +32 -15
- package/src/core/diagnose.ts +63 -16
- package/src/core/diff.ts +10 -6
- package/src/core/fabric.ts +18 -9
- package/src/core/graph.ts +19 -5
- package/src/core/light.ts +2 -2
- package/src/core/model.ts +141 -31
- package/src/core/parse.ts +100 -85
- package/src/core/poly.ts +1 -8
- package/src/core/site.ts +19 -2
- package/src/core/tolerance.ts +2 -2
- package/src/core/vertical.ts +10 -3
- package/src/core/vocabulary.ts +18 -5
- package/src/diagnostics.ts +8 -0
- package/src/diff.ts +14 -0
- package/src/draw/index.ts +1 -1
- package/src/draw/plan.ts +5 -5
- package/src/form.ts +37 -0
- package/src/graph.ts +12 -0
- package/src/index.ts +40 -175
- package/src/mcp.ts +85 -35
- package/src/model.ts +43 -0
- package/src/parse-file.ts +17 -3
- package/src/validate/assessment.ts +1934 -0
- package/src/validate/builtin/access.ts +642 -0
- package/src/validate/builtin/daylight.ts +321 -0
- package/src/validate/builtin/door-column-collisions.ts +266 -0
- package/src/validate/builtin/envelope.ts +227 -0
- package/src/validate/builtin/freeze.ts +19 -0
- package/src/validate/builtin/index.ts +156 -0
- package/src/validate/builtin/site.ts +445 -0
- package/src/validate/builtin/vertical-runs.ts +390 -0
- package/src/validate/contracts.ts +240 -0
- package/src/validate/index.ts +45 -99
- package/src/vocabulary.ts +9 -0
- package/dist/validate/access.d.ts +0 -6
- package/dist/validate/access.d.ts.map +0 -1
- package/dist/validate/access.js +0 -238
- package/dist/validate/access.js.map +0 -1
- package/dist/validate/envelope.d.ts +0 -4
- package/dist/validate/envelope.d.ts.map +0 -1
- package/dist/validate/envelope.js +0 -55
- package/dist/validate/envelope.js.map +0 -1
- package/dist/validate/light.d.ts +0 -6
- package/dist/validate/light.d.ts.map +0 -1
- package/dist/validate/light.js +0 -28
- package/dist/validate/light.js.map +0 -1
- package/dist/validate/runs.d.ts +0 -16
- package/dist/validate/runs.d.ts.map +0 -1
- package/dist/validate/runs.js +0 -60
- package/dist/validate/runs.js.map +0 -1
- package/dist/validate/site.d.ts +0 -6
- package/dist/validate/site.d.ts.map +0 -1
- package/dist/validate/site.js +0 -63
- package/dist/validate/site.js.map +0 -1
- package/spec/README.md +0 -28
- package/spec/canonical-json.md +0 -98
- package/spec/composition.md +0 -121
- package/spec/derivation.md +0 -393
- package/spec/en/README.md +0 -30
- package/spec/en/canonical-json.md +0 -101
- package/spec/en/composition.md +0 -121
- package/spec/en/derivation.md +0 -393
- package/spec/en/language.md +0 -164
- package/spec/en/notation-v0.md +0 -145
- package/spec/en/scope.md +0 -229
- package/spec/en/semantics.md +0 -132
- package/spec/en/tools.md +0 -108
- package/spec/en/validation.md +0 -79
- package/spec/en/vocabulary.md +0 -103
- package/spec/language.md +0 -163
- package/spec/notation-v0.md +0 -184
- package/spec/scope.md +0 -229
- package/spec/semantics.md +0 -130
- package/spec/tools.md +0 -106
- package/spec/validation.md +0 -79
- package/spec/vocabulary.md +0 -114
- package/src/validate/access.ts +0 -279
- package/src/validate/envelope.ts +0 -59
- package/src/validate/light.ts +0 -43
- package/src/validate/runs.ts +0 -87
- package/src/validate/site.ts +0 -84
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import type { Diagnostic } from "../core/diagnose.js";
|
|
2
|
+
import type { Model } from "../core/model.js";
|
|
3
|
+
import type { JsonObject, JsonValue } from "./json.js";
|
|
4
|
+
|
|
5
|
+
export const COMPONENT_ID_PATTERN = /^[a-z][a-z0-9-]*(?:\.[a-z0-9-]+)+$/;
|
|
6
|
+
|
|
7
|
+
export interface ComponentIdentity {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly revision: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isComponentIdentity(value: unknown): value is ComponentIdentity {
|
|
13
|
+
if (typeof value !== "object" || value === null) return false;
|
|
14
|
+
try {
|
|
15
|
+
const id = Object.getOwnPropertyDescriptor(value, "id");
|
|
16
|
+
const revision = Object.getOwnPropertyDescriptor(value, "revision");
|
|
17
|
+
return !!id
|
|
18
|
+
&& "value" in id
|
|
19
|
+
&& id.enumerable === true
|
|
20
|
+
&& typeof id.value === "string"
|
|
21
|
+
&& COMPONENT_ID_PATTERN.test(id.value)
|
|
22
|
+
&& !!revision
|
|
23
|
+
&& "value" in revision
|
|
24
|
+
&& revision.enumerable === true
|
|
25
|
+
&& typeof revision.value === "string"
|
|
26
|
+
&& revision.value.trim() !== "";
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function sameIdentity(a: ComponentIdentity, b: ComponentIdentity): boolean {
|
|
33
|
+
return a.id === b.id && a.revision === b.revision;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface JurisdictionRef {
|
|
37
|
+
readonly country: string;
|
|
38
|
+
readonly region?: string;
|
|
39
|
+
readonly locality?: string;
|
|
40
|
+
readonly authority?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface EffectiveRange {
|
|
44
|
+
readonly from: string;
|
|
45
|
+
readonly to?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type SubjectRef =
|
|
49
|
+
| { readonly kind: "model"; readonly ref: "/" }
|
|
50
|
+
| { readonly kind: "level" | "space" | "zone" | "boundary" | "opening" | "run" | "site"; readonly ref: string }
|
|
51
|
+
| { readonly kind: `${string}.${string}`; readonly ref: string };
|
|
52
|
+
|
|
53
|
+
export interface SourceLocation {
|
|
54
|
+
readonly file?: string;
|
|
55
|
+
readonly line?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ContextSource {
|
|
59
|
+
readonly kind: "authority" | "survey" | "brief" | "user" | "import" | "other";
|
|
60
|
+
readonly ref: string;
|
|
61
|
+
readonly observedAt?: string;
|
|
62
|
+
readonly retrievedAt?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface AuthorityCitation {
|
|
66
|
+
readonly jurisdiction: JurisdictionRef;
|
|
67
|
+
readonly instrument: string;
|
|
68
|
+
readonly provision?: string;
|
|
69
|
+
readonly uri?: string;
|
|
70
|
+
readonly effective?: EffectiveRange;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type SourceRef =
|
|
74
|
+
| { readonly kind: "model"; readonly subject: SubjectRef; readonly location?: SourceLocation }
|
|
75
|
+
| { readonly kind: "context"; readonly key: string; readonly source: ContextSource }
|
|
76
|
+
| { readonly kind: "authority"; readonly citation: AuthorityCitation }
|
|
77
|
+
| { readonly kind: `${string}.${string}`; readonly data: JsonObject };
|
|
78
|
+
|
|
79
|
+
export interface Quantity {
|
|
80
|
+
readonly value: number;
|
|
81
|
+
readonly unit: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface EvidenceBase {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly subjects: readonly [SubjectRef, ...SubjectRef[]];
|
|
87
|
+
readonly sources: readonly [SourceRef, ...SourceRef[]];
|
|
88
|
+
readonly producedBy: ComponentIdentity;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type Evidence =
|
|
92
|
+
| (EvidenceBase & { readonly kind: "fact"; readonly name: string; readonly value: JsonValue | Quantity })
|
|
93
|
+
| (EvidenceBase & {
|
|
94
|
+
readonly kind: "comparison";
|
|
95
|
+
readonly observed: Quantity;
|
|
96
|
+
readonly operator: "<" | "<=" | "=" | ">=" | ">" | "inside" | "outside";
|
|
97
|
+
readonly required: Quantity | { readonly minimum?: Quantity; readonly maximum?: Quantity };
|
|
98
|
+
})
|
|
99
|
+
| (EvidenceBase & {
|
|
100
|
+
readonly kind: "route";
|
|
101
|
+
readonly reachable: boolean;
|
|
102
|
+
readonly profile: string;
|
|
103
|
+
readonly path: readonly string[];
|
|
104
|
+
readonly cost?: Quantity;
|
|
105
|
+
})
|
|
106
|
+
| (EvidenceBase & { readonly kind: "geometry"; readonly geometry: JsonObject })
|
|
107
|
+
| (EvidenceBase & {
|
|
108
|
+
readonly kind: "missing";
|
|
109
|
+
readonly missing: readonly [MissingInput, ...MissingInput[]];
|
|
110
|
+
})
|
|
111
|
+
| (EvidenceBase & { readonly kind: `${string}.${string}`; readonly data: JsonObject });
|
|
112
|
+
|
|
113
|
+
export interface ContextEntry {
|
|
114
|
+
readonly value: JsonValue;
|
|
115
|
+
readonly source: ContextSource;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface ContextSnapshot {
|
|
119
|
+
readonly schema: "koyu-context/1";
|
|
120
|
+
readonly asOf: string;
|
|
121
|
+
readonly jurisdiction?: JurisdictionRef;
|
|
122
|
+
readonly values: Readonly<Record<string, ContextEntry>>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type ContextDecode<T extends JsonValue> =
|
|
126
|
+
| { readonly ok: true; readonly value: T }
|
|
127
|
+
| { readonly ok: false; readonly message: string };
|
|
128
|
+
|
|
129
|
+
export interface ContextKey<T extends JsonValue> extends ComponentIdentity {
|
|
130
|
+
readonly description: string;
|
|
131
|
+
readonly decode: (value: JsonValue) => ContextDecode<T>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface ContextRequirement<T extends JsonValue = JsonValue> {
|
|
135
|
+
readonly key: ContextKey<T>;
|
|
136
|
+
readonly presence: "required" | "optional";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type ContextRead<T extends JsonValue> =
|
|
140
|
+
| { readonly state: "present"; readonly value: T; readonly entry: ContextEntry }
|
|
141
|
+
| { readonly state: "missing" }
|
|
142
|
+
| { readonly state: "invalid"; readonly entry: ContextEntry; readonly message: string };
|
|
143
|
+
|
|
144
|
+
export interface ContextReader {
|
|
145
|
+
get<T extends JsonValue>(key: ContextKey<T>): ContextRead<T>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export type MissingInput =
|
|
149
|
+
| { readonly kind: "context"; readonly key: string; readonly reason: "missing" | "invalid"; readonly message?: string }
|
|
150
|
+
| { readonly kind: "model"; readonly subjects: readonly SubjectRef[]; readonly reason: string }
|
|
151
|
+
| { readonly kind: "analysis"; readonly analysis: ComponentIdentity; readonly reason: "partial" | "unavailable" }
|
|
152
|
+
| { readonly kind: `${string}.${string}`; readonly data: JsonObject };
|
|
153
|
+
|
|
154
|
+
export interface ExecutionIssue {
|
|
155
|
+
readonly kind:
|
|
156
|
+
| "model-inconsistent"
|
|
157
|
+
| "dependency-unavailable"
|
|
158
|
+
| "missing-context"
|
|
159
|
+
| "invalid-context"
|
|
160
|
+
| "execution-error"
|
|
161
|
+
| `${string}.${string}`;
|
|
162
|
+
readonly message: string;
|
|
163
|
+
readonly subjects?: readonly SubjectRef[];
|
|
164
|
+
readonly missing?: readonly MissingInput[];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type AnalysisArtifact<T extends JsonValue> =
|
|
168
|
+
| {
|
|
169
|
+
readonly state: "complete";
|
|
170
|
+
readonly value: T;
|
|
171
|
+
readonly evidence: readonly Evidence[];
|
|
172
|
+
}
|
|
173
|
+
| {
|
|
174
|
+
readonly state: "partial";
|
|
175
|
+
readonly value: T;
|
|
176
|
+
readonly missing: readonly [MissingInput, ...MissingInput[]];
|
|
177
|
+
readonly evidence: readonly Evidence[];
|
|
178
|
+
}
|
|
179
|
+
| {
|
|
180
|
+
readonly state: "unavailable";
|
|
181
|
+
readonly missing: readonly [MissingInput, ...MissingInput[]];
|
|
182
|
+
readonly issues: readonly [ExecutionIssue, ...ExecutionIssue[]];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export interface AnalysisRef<T extends JsonValue = JsonValue> extends ComponentIdentity {
|
|
186
|
+
readonly __output?: T;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface AnalysisRequirement<T extends JsonValue = JsonValue> {
|
|
190
|
+
readonly analysis: AnalysisRef<T>;
|
|
191
|
+
readonly accept: "complete" | "partial";
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type DeepReadonly<T> =
|
|
195
|
+
T extends (...args: never[]) => unknown ? T
|
|
196
|
+
: T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>
|
|
197
|
+
: T extends ReadonlySet<infer U> ? ReadonlySet<DeepReadonly<U>>
|
|
198
|
+
: T extends readonly (infer U)[] ? readonly DeepReadonly<U>[]
|
|
199
|
+
: T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]> }
|
|
200
|
+
: T;
|
|
201
|
+
|
|
202
|
+
export interface AnalysisRunContext {
|
|
203
|
+
readonly model: DeepReadonly<Model>;
|
|
204
|
+
readonly context: ContextReader;
|
|
205
|
+
get<T extends JsonValue>(analysis: AnalysisRef<T>): AnalysisArtifact<T>;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface AnalysisDefinition<T extends JsonValue = JsonValue> extends AnalysisRef<T> {
|
|
209
|
+
readonly title: string;
|
|
210
|
+
readonly model: "consistent" | "any";
|
|
211
|
+
readonly dependencies: readonly AnalysisRequirement[];
|
|
212
|
+
readonly context: readonly ContextRequirement[];
|
|
213
|
+
readonly run: (context: AnalysisRunContext) => AnalysisArtifact<T>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface AnalysisResult<T extends JsonValue = JsonValue> {
|
|
217
|
+
readonly analysis: ComponentIdentity;
|
|
218
|
+
readonly artifact: AnalysisArtifact<T>;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export const ANALYSIS_FORMAT = "koyu-analysis/1" as const;
|
|
222
|
+
|
|
223
|
+
export interface AnalysisReport<T extends JsonValue = JsonValue> {
|
|
224
|
+
readonly schema: typeof ANALYSIS_FORMAT;
|
|
225
|
+
readonly profile: ComponentIdentity;
|
|
226
|
+
readonly model: {
|
|
227
|
+
readonly languageVersion: string;
|
|
228
|
+
readonly name?: string;
|
|
229
|
+
readonly state: "consistent" | "inconsistent";
|
|
230
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
231
|
+
};
|
|
232
|
+
readonly context: ContextSnapshot;
|
|
233
|
+
readonly result: AnalysisResult<T>;
|
|
234
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// koyu — the analysis surface (`@kensnzk/koyu/analysis`)
|
|
2
|
+
//
|
|
3
|
+
// **Analysis makes the material for a judgement; it never holds the authority to judge.**
|
|
4
|
+
// An artifact carries measurements, evidence you can walk back to the model, the identity of
|
|
5
|
+
// the profile and inputs it came from, and whatever input was missing. It carries no `pass`,
|
|
6
|
+
// no `fail`, no level and no verdict — drawing the line is what `@kensnzk/koyu/validate` does.
|
|
7
|
+
//
|
|
8
|
+
// Every run names its context and its versioned profile explicitly. There is no implicit
|
|
9
|
+
// jurisdiction, no process-wide default profile, and no overload that lets a required input
|
|
10
|
+
// be omitted. Two runs that differ do so because the arguments differed, and the difference
|
|
11
|
+
// is visible in the result's provenance rather than hidden in process state.
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
COMPONENT_ID_PATTERN,
|
|
15
|
+
isComponentIdentity,
|
|
16
|
+
sameIdentity,
|
|
17
|
+
ANALYSIS_FORMAT,
|
|
18
|
+
type AnalysisArtifact,
|
|
19
|
+
type AnalysisDefinition,
|
|
20
|
+
type AnalysisRef,
|
|
21
|
+
type AnalysisReport,
|
|
22
|
+
type AnalysisRequirement,
|
|
23
|
+
type AnalysisResult,
|
|
24
|
+
type AnalysisRunContext,
|
|
25
|
+
type AuthorityCitation,
|
|
26
|
+
type ComponentIdentity,
|
|
27
|
+
type ContextDecode,
|
|
28
|
+
type ContextEntry,
|
|
29
|
+
type ContextKey,
|
|
30
|
+
type ContextRead,
|
|
31
|
+
type ContextReader,
|
|
32
|
+
type ContextRequirement,
|
|
33
|
+
type ContextSnapshot,
|
|
34
|
+
type ContextSource,
|
|
35
|
+
type DeepReadonly,
|
|
36
|
+
type EffectiveRange,
|
|
37
|
+
type Evidence,
|
|
38
|
+
type ExecutionIssue,
|
|
39
|
+
type JurisdictionRef,
|
|
40
|
+
type MissingInput,
|
|
41
|
+
type Quantity,
|
|
42
|
+
type SourceLocation,
|
|
43
|
+
type SourceRef,
|
|
44
|
+
type SubjectRef,
|
|
45
|
+
} from "./contracts.js";
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
assertJsonValue,
|
|
49
|
+
canonicalJsonValue,
|
|
50
|
+
codePointCompare,
|
|
51
|
+
isJsonValue,
|
|
52
|
+
JsonBoundaryError,
|
|
53
|
+
type JsonObject,
|
|
54
|
+
type JsonPrimitive,
|
|
55
|
+
type JsonValue,
|
|
56
|
+
} from "./json.js";
|
|
57
|
+
|
|
58
|
+
// Running one analysis, without running any rule. The registry and profile are the caller's
|
|
59
|
+
// values; see `@kensnzk/koyu/validate` for how they are built.
|
|
60
|
+
export { runAnalysis } from "../validate/assessment.js";
|
|
61
|
+
export type { RunAnalysisOptions } from "../validate/contracts.js";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
2
|
+
|
|
3
|
+
export type JsonValue =
|
|
4
|
+
| JsonPrimitive
|
|
5
|
+
| readonly JsonValue[]
|
|
6
|
+
| { readonly [key: string]: JsonValue };
|
|
7
|
+
|
|
8
|
+
export type JsonObject = { readonly [key: string]: JsonValue };
|
|
9
|
+
|
|
10
|
+
export class JsonBoundaryError extends TypeError {
|
|
11
|
+
readonly path: string;
|
|
12
|
+
|
|
13
|
+
constructor(path: string, message: string) {
|
|
14
|
+
super(`${path}: ${message}`);
|
|
15
|
+
this.name = "JsonBoundaryError";
|
|
16
|
+
this.path = path;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** True only for finite JSON primitives, arrays, and plain string-keyed objects without cycles. */
|
|
21
|
+
export function isJsonValue(value: unknown): value is JsonValue {
|
|
22
|
+
try {
|
|
23
|
+
assertJsonValue(value);
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function assertJsonValue(value: unknown, path = "$", ancestors = new Set<object>()): asserts value is JsonValue {
|
|
31
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return;
|
|
32
|
+
if (typeof value === "number") {
|
|
33
|
+
if (!Number.isFinite(value)) throw new JsonBoundaryError(path, "number must be finite");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value !== "object") {
|
|
37
|
+
throw new JsonBoundaryError(path, `${typeof value} is not a JSON value`);
|
|
38
|
+
}
|
|
39
|
+
if (ancestors.has(value)) throw new JsonBoundaryError(path, "cyclic value is not JSON");
|
|
40
|
+
|
|
41
|
+
const prototype = Object.getPrototypeOf(value) as object | null;
|
|
42
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) {
|
|
43
|
+
throw new JsonBoundaryError(path, "object must have Object.prototype or a null prototype");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ancestors.add(value);
|
|
47
|
+
try {
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
50
|
+
if (key === "length") continue;
|
|
51
|
+
if (typeof key !== "string" || !/^(0|[1-9]\d*)$/.test(key) || Number(key) >= value.length) {
|
|
52
|
+
throw new JsonBoundaryError(path, "array has a non-index own property");
|
|
53
|
+
}
|
|
54
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key)!;
|
|
55
|
+
if (!("value" in descriptor) || !descriptor.enumerable) {
|
|
56
|
+
throw new JsonBoundaryError(`${path}[${key}]`, "array entries must be enumerable data properties");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (let index = 0; index < value.length; index++) {
|
|
60
|
+
if (!Object.hasOwn(value, index)) throw new JsonBoundaryError(`${path}[${index}]`, "sparse arrays are not JSON values");
|
|
61
|
+
assertJsonValue(value[index], `${path}[${index}]`, ancestors);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
66
|
+
if (typeof key !== "string") throw new JsonBoundaryError(path, "symbol keys are not JSON object keys");
|
|
67
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key)!;
|
|
68
|
+
if (!("value" in descriptor) || !descriptor.enumerable) {
|
|
69
|
+
throw new JsonBoundaryError(`${path}.${key}`, "object members must be enumerable data properties");
|
|
70
|
+
}
|
|
71
|
+
assertJsonValue(descriptor.value, `${path}.${key}`, ancestors);
|
|
72
|
+
}
|
|
73
|
+
} finally {
|
|
74
|
+
ancestors.delete(value);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Clones a JSON boundary value deterministically. Non-index keys use Unicode code-point order;
|
|
80
|
+
* ECMAScript integer-index keys retain the language's mandatory numeric enumeration order.
|
|
81
|
+
*/
|
|
82
|
+
export function canonicalJsonValue(value: unknown): JsonValue {
|
|
83
|
+
assertJsonValue(value);
|
|
84
|
+
return canonical(value);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function canonical(value: JsonValue): JsonValue {
|
|
88
|
+
if (value === null || typeof value !== "object") {
|
|
89
|
+
return typeof value === "number" && Object.is(value, -0) ? 0 : value;
|
|
90
|
+
}
|
|
91
|
+
if (Array.isArray(value)) return value.map(canonical);
|
|
92
|
+
|
|
93
|
+
const record = value as { readonly [key: string]: JsonValue };
|
|
94
|
+
const out: Record<string, JsonValue> = {};
|
|
95
|
+
for (const key of Object.keys(record).sort(codePointCompare)) {
|
|
96
|
+
Object.defineProperty(out, key, {
|
|
97
|
+
value: canonical(record[key]!),
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function codePointCompare(a: string, b: string): number {
|
|
107
|
+
const left = a[Symbol.iterator]();
|
|
108
|
+
const right = b[Symbol.iterator]();
|
|
109
|
+
while (true) {
|
|
110
|
+
const x = left.next();
|
|
111
|
+
const y = right.next();
|
|
112
|
+
if (x.done || y.done) return x.done === y.done ? 0 : x.done ? -1 : 1;
|
|
113
|
+
const xPoint = x.value.codePointAt(0)!;
|
|
114
|
+
const yPoint = y.value.codePointAt(0)!;
|
|
115
|
+
if (xPoint !== yPoint) return xPoint < yPoint ? -1 : 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -18,7 +18,9 @@ import { check, checkDiagnostics, type Diagnostic } from "./core/diagnose.js";
|
|
|
18
18
|
import { renderDiff, semanticDiff } from "./core/diff.js";
|
|
19
19
|
import { doorsBetween, neighbors } from "./core/graph.js";
|
|
20
20
|
import { daylightInputs } from "./core/light.js";
|
|
21
|
-
import {
|
|
21
|
+
import { assess } from "./validate/assessment.js";
|
|
22
|
+
import { AssessmentConfigError, type AssessmentReport } from "./validate/contracts.js";
|
|
23
|
+
import { createSchematicRegistry, SCHEMATIC_PROFILE_ID } from "./validate/builtin/index.js";
|
|
22
24
|
import { siteReport } from "./core/site.js";
|
|
23
25
|
import {
|
|
24
26
|
areaM2,
|
|
@@ -32,6 +34,8 @@ import {
|
|
|
32
34
|
zoneAreaM2,
|
|
33
35
|
type Model,
|
|
34
36
|
srcRef,
|
|
37
|
+
isOutside,
|
|
38
|
+
isVoid
|
|
35
39
|
} from "./core/model.js";
|
|
36
40
|
import { parseFile } from "./parse-file.js";
|
|
37
41
|
import { svgPlan } from "./draw/plan.js";
|
|
@@ -117,13 +121,80 @@ function enumOpt<T extends string>(
|
|
|
117
121
|
return raw as T;
|
|
118
122
|
}
|
|
119
123
|
|
|
124
|
+
/** The one profile koyu ships. Any other name is the caller's, and this build cannot resolve it. */
|
|
125
|
+
const BUILTIN_PROFILE = SCHEMATIC_PROFILE_ID.id;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Run a rule set over the model.
|
|
129
|
+
*
|
|
130
|
+
* The profile and the effective date are **required**. Neither is guessed from the filename,
|
|
131
|
+
* the locale, the environment or the clock: a judgement whose grounds were inferred cannot be
|
|
132
|
+
* reproduced, and one that quietly picked a default is worse than one that refused to start.
|
|
133
|
+
*/
|
|
134
|
+
function runAssessment(model: Model, rest: string[]): AssessmentReport {
|
|
135
|
+
const profile = opt(rest, "-p", "--profile");
|
|
136
|
+
if (!profile) {
|
|
137
|
+
die(
|
|
138
|
+
"validate needs an explicit profile: --profile <id>\n" +
|
|
139
|
+
` koyu ships one: ${BUILTIN_PROFILE}`,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
if (profile !== BUILTIN_PROFILE) {
|
|
143
|
+
die(`Unknown profile: ${profile}\n koyu ships one: ${BUILTIN_PROFILE}`);
|
|
144
|
+
}
|
|
145
|
+
const asOf = opt(rest, "--as-of");
|
|
146
|
+
if (!asOf) {
|
|
147
|
+
die(
|
|
148
|
+
"validate needs an explicit effective date: --as-of YYYY-MM-DD\n" +
|
|
149
|
+
" the date is not read from the clock, so that the same file judges the same way twice",
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
return assess(model, {
|
|
155
|
+
registry: createSchematicRegistry(),
|
|
156
|
+
profile: SCHEMATIC_PROFILE_ID,
|
|
157
|
+
context: { schema: "koyu-context/1", asOf, values: {} },
|
|
158
|
+
});
|
|
159
|
+
} catch (e) {
|
|
160
|
+
// Configuration is the caller's problem, so it exits like a usage error rather than a verdict.
|
|
161
|
+
if (e instanceof AssessmentConfigError) die(`✖ ${e.message}`);
|
|
162
|
+
throw e;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 0 only when the whole set ran and nothing was violated.
|
|
168
|
+
*
|
|
169
|
+
* A caution that failed still exits 0 — it is a doubt, not a breach. But an indeterminate rule,
|
|
170
|
+
* a rule that errored, or an inconsistent model exits 1: **not being able to judge is not the
|
|
171
|
+
* same as passing**, and silence there is exactly what this exit code exists to prevent.
|
|
172
|
+
*/
|
|
173
|
+
function assessmentExit(report: AssessmentReport): number {
|
|
174
|
+
if (report.summary.state !== "complete") return 1;
|
|
175
|
+
if (report.model.state !== "consistent") return 1;
|
|
176
|
+
return report.findings.some((f) => f.level === "violation") ? 1 : 0;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** The first model-anchored line among a finding's evidence, formatted like every other locator. */
|
|
180
|
+
function firstModelLine(evidence: AssessmentReport["findings"][number]["outcome"]["evidence"]): string {
|
|
181
|
+
for (const item of evidence) {
|
|
182
|
+
for (const source of item.sources) {
|
|
183
|
+
if (source.kind === "model" && source.location?.line !== undefined) {
|
|
184
|
+
return `${srcRef(source.location.line, source.location.file)}: `;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return "";
|
|
189
|
+
}
|
|
190
|
+
|
|
120
191
|
function main(argv: string[]): number {
|
|
121
192
|
const [cmd, file, ...rest] = argv;
|
|
122
193
|
if (!cmd || !file) {
|
|
123
194
|
console.log(
|
|
124
195
|
"Usage: koyu <check|validate|layers|diff|plan|axo|doors|graph|stats|levels|runs|light|site|json> <file.muro> [args...]\n" +
|
|
125
196
|
" check: --json (emit Diagnostic[] as JSON) / --strict (exit 1 if there are warnings) — structural consistency only\n" +
|
|
126
|
-
" validate: --
|
|
197
|
+
" validate: --profile <id> --as-of <YYYY-MM-DD> [--json] — architectural judgement (not what check guarantees)\n" +
|
|
127
198
|
" layers: the layers that took part in composition, weakest first. --attrs for the provenance of each attribute\n" +
|
|
128
199
|
" diff: koyu diff <a.muro> <b.muro> [--json] — the difference in the language of composition (0=no difference / 1=differences / 2=the input is broken)",
|
|
129
200
|
);
|
|
@@ -201,36 +272,47 @@ function main(argv: string[]): number {
|
|
|
201
272
|
(warnings.length ? ` (${qty(warnings.length, "warning", "warnings")})` : ""),
|
|
202
273
|
);
|
|
203
274
|
// **緑の意味を、緑を出す場所で言う。**構造整合が成り立っただけであって、
|
|
204
|
-
// 建築として妥当かはここでは何も言っていない (
|
|
275
|
+
// 建築として妥当かはここでは何も言っていない (docs/reference/scope.md)
|
|
205
276
|
console.log(" Structural consistency only — architectural validity is what koyu validate says, separately");
|
|
206
277
|
return strict && warnings.length > 0 ? 1 : 0;
|
|
207
278
|
}
|
|
208
279
|
return 1;
|
|
209
280
|
}
|
|
210
281
|
case "validate": {
|
|
211
|
-
// 建築的な判定 (
|
|
212
|
-
//
|
|
213
|
-
|
|
282
|
+
// 建築的な判定 (docs/reference/scope.md)。**check の保証ではない** — 型も綴りも別である。
|
|
283
|
+
//
|
|
284
|
+
// profile と基準日は呼び出し側が明示する。管轄も基準日も推測せず、内蔵 profile を
|
|
285
|
+
// 黙って選ばない — 無根拠に成功して見える判定より、入力不足で止まる方を採る。
|
|
286
|
+
const report = runAssessment(model, rest);
|
|
214
287
|
if (rest.includes("--json")) {
|
|
215
|
-
console.log(JSON.stringify(
|
|
216
|
-
return
|
|
288
|
+
console.log(JSON.stringify(report, null, 1));
|
|
289
|
+
return assessmentExit(report);
|
|
217
290
|
}
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
291
|
+
for (const f of report.findings) {
|
|
292
|
+
const where = firstModelLine(f.outcome.evidence);
|
|
293
|
+
console.log(
|
|
294
|
+
`${f.level === "violation" ? "✖" : "⚠"} [${f.rule.id}] ${where}${f.outcome.message}`,
|
|
295
|
+
);
|
|
222
296
|
}
|
|
223
|
-
const violations = findings.filter((f) => f.level === "violation").length;
|
|
224
|
-
const cautions = findings.length - violations;
|
|
297
|
+
const violations = report.findings.filter((f) => f.level === "violation").length;
|
|
298
|
+
const cautions = report.findings.length - violations;
|
|
225
299
|
console.log(
|
|
226
|
-
findings.length === 0
|
|
300
|
+
report.findings.length === 0
|
|
227
301
|
? "✔ Nothing caught by validation (this is a judgement, not a guarantee about the composition)"
|
|
228
302
|
: `Validation — ${qty(violations, "violation", "violations")} / ${qty(cautions, "caution", "cautions")}`,
|
|
229
303
|
);
|
|
230
|
-
|
|
304
|
+
console.log(
|
|
305
|
+
` ${report.profile.id}@${report.profile.revision} — ` +
|
|
306
|
+
`${report.summary.rules.evaluated} evaluated / ${report.summary.rules.notApplicable} not applicable / ` +
|
|
307
|
+
`${report.summary.rules.indeterminate} indeterminate / ${report.summary.rules.error} error`,
|
|
308
|
+
);
|
|
309
|
+
if (report.summary.state === "incomplete") {
|
|
310
|
+
console.log(" Incomplete — something could not be judged, which is not the same as passing");
|
|
311
|
+
}
|
|
312
|
+
return assessmentExit(report);
|
|
231
313
|
}
|
|
232
314
|
case "layers": {
|
|
233
|
-
// 合成の規則1と6 (
|
|
315
|
+
// 合成の規則1と6 (docs/reference/muro/import.md) — 強度順序を見せ、最終値の出所を言う。
|
|
234
316
|
// **暗黙の解決はどこにも無い**ことを、目で確かめられるようにするための面である
|
|
235
317
|
if (model.layers.length === 0) {
|
|
236
318
|
console.log("No layers (parsing a single file involves no composition)");
|
|
@@ -323,29 +405,32 @@ function main(argv: string[]): number {
|
|
|
323
405
|
console.log(`${l.name}`);
|
|
324
406
|
let sub = 0;
|
|
325
407
|
for (const s of onLevel) {
|
|
326
|
-
if (s
|
|
408
|
+
if (isVoid(s)) {
|
|
327
409
|
console.log(` ${s.path}\t${displayName(s)}\tvoid (not counted as floor area)`);
|
|
328
410
|
continue;
|
|
329
411
|
}
|
|
330
412
|
const a = areaM2(s)!;
|
|
331
|
-
if (s
|
|
413
|
+
if (isOutside(s)) {
|
|
332
414
|
outdoorTotal += a;
|
|
333
|
-
console.log(` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)} m2 (outdoor, not counted)`);
|
|
415
|
+
console.log(` ${s.path}\t${displayName(s)}\t${s.type ?? "(untyped)"}\t${a.toFixed(2)} m2 (outdoor, not counted)`);
|
|
334
416
|
continue;
|
|
335
417
|
}
|
|
336
418
|
if (isSemiOutdoor(model, s)) {
|
|
337
419
|
semiTotal += a;
|
|
338
420
|
console.log(
|
|
339
|
-
` ${s.path}\t${displayName(s)}\t${s.type}\t${a.toFixed(2)} m2 (semi-outdoor, reported separately)`,
|
|
421
|
+
` ${s.path}\t${displayName(s)}\t${s.type ?? "(untyped)"}\t${a.toFixed(2)} m2 (semi-outdoor, reported separately)`,
|
|
340
422
|
);
|
|
341
423
|
continue;
|
|
342
424
|
}
|
|
343
425
|
sub += a;
|
|
344
426
|
total += a;
|
|
345
|
-
|
|
427
|
+
// 型は任意なので、書かれなかった行にも小計の座が要る。**既定の語は捏造しない** —
|
|
428
|
+
// "(untyped)" は集計の見出しであって、その空間の型ではない (mcp の "(unspecified)" と同じ構え)
|
|
429
|
+
const label = s.type ?? "(untyped)";
|
|
430
|
+
byType.set(label, (byType.get(label) ?? 0) + a);
|
|
346
431
|
const use = effectiveUse(model, s);
|
|
347
432
|
if (use) byUse.set(use, (byUse.get(use) ?? 0) + a);
|
|
348
|
-
console.log(` ${s.path}\t${displayName(s)}\t${
|
|
433
|
+
console.log(` ${s.path}\t${displayName(s)}\t${label}\t${a.toFixed(2)} m2`);
|
|
349
434
|
}
|
|
350
435
|
console.log(` Subtotal ${sub.toFixed(2)} m2`);
|
|
351
436
|
}
|
|
@@ -376,30 +461,25 @@ function main(argv: string[]): number {
|
|
|
376
461
|
return 0;
|
|
377
462
|
}
|
|
378
463
|
case "light": {
|
|
379
|
-
//
|
|
380
|
-
//
|
|
464
|
+
// **数だけを返す。**床面積と有効窓面積は模型から出る事実であり、そこへ線を引くのは
|
|
465
|
+
// 規則の側の仕事である。閾値をここに書けば validate と二重になり、片方だけが古くなる
|
|
466
|
+
// (docs/reference/scope.md)。合否は koyu validate が言う
|
|
381
467
|
const inputs = daylightInputs(model);
|
|
382
468
|
if (inputs.length === 0) {
|
|
383
469
|
console.log("Nothing is in daylight scope (write daylight:1 on the rooms to be judged)");
|
|
384
470
|
return 0;
|
|
385
471
|
}
|
|
386
|
-
const failing = new Set(
|
|
387
|
-
validate(model).filter((f) => f.rule === "daylight.ratio").flatMap((f) => f.path ?? []),
|
|
388
|
-
);
|
|
389
472
|
for (const d of inputs) {
|
|
390
|
-
const ok = !failing.has(d.space.path);
|
|
391
473
|
const ratio = d.window > 0 ? `1/${(d.floor / d.window).toFixed(1)}` : "no window";
|
|
392
474
|
console.log(
|
|
393
|
-
|
|
475
|
+
` ${d.space.path}\t${displayName(d.space)}\twindow ${d.window.toFixed(2)} m2 / floor ${d.floor.toFixed(2)} m2 = ${ratio}` +
|
|
394
476
|
(d.missingH ? " ⚠ windows without h: are not counted" : ""),
|
|
395
477
|
);
|
|
396
478
|
}
|
|
397
479
|
console.log(
|
|
398
|
-
|
|
399
|
-
? `✔ Every room meets 1/7 — ${qty(inputs.length, "room", "rooms")} in scope (a rough judgement with no correction factor — this is validation, not what check guarantees)`
|
|
400
|
-
: `✖ Short of 1/7: ${failing.size} of ${qty(inputs.length, "room", "rooms")} (this is a validation judgement)`,
|
|
480
|
+
`${qty(inputs.length, "room", "rooms")} in daylight scope — these are numbers, not a verdict (koyu validate applies the rule)`,
|
|
401
481
|
);
|
|
402
|
-
return
|
|
482
|
+
return 0;
|
|
403
483
|
}
|
|
404
484
|
case "site": {
|
|
405
485
|
// 敷地の問い: 敷地面積・接道・建蔽率・容積率 (基本計画のボリューム検討の数字)
|
|
@@ -429,8 +509,8 @@ function main(argv: string[]): number {
|
|
|
429
509
|
` Road: ${road.road.path}${typeof nm === "string" ? ` (${nm})` : ""} width ${road.width}mm / frontage ${road.frontage}mm`,
|
|
430
510
|
);
|
|
431
511
|
}
|
|
432
|
-
console.log(` Building footprint (horizontal projection, rough): ${r.footprint.toFixed(2)} m2 → building coverage ratio ${
|
|
433
|
-
console.log(` Total floor area: ${r.totalFloor.toFixed(2)} m2 → floor area ratio ${
|
|
512
|
+
console.log(` Building footprint (horizontal projection, rough): ${r.footprint.toFixed(2)} m2 → building coverage ratio ${r.coveragePercent ?? "—"}%`);
|
|
513
|
+
console.log(` Total floor area: ${r.totalFloor.toFixed(2)} m2 → floor area ratio ${r.floorAreaRatioPercent ?? "—"}%`);
|
|
434
514
|
return 0;
|
|
435
515
|
}
|
|
436
516
|
case "axo": {
|