@floless/app 0.115.0 → 0.117.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/dist/floless-server.cjs +262 -31
- package/dist/schemas/steel.model.v2.schema.json +9 -4
- package/dist/schemas/steel.takeoff.v1.schema.json +7 -0
- package/dist/schemas/steel.takeoff.v1.staging-snapshot.json +263 -0
- package/dist/skills/floless-app-bridge/SKILL.md +1 -1
- package/dist/skills/floless-app-onboarding/SKILL.md +1 -1
- package/dist/skills/floless-app-queue/SKILL.md +1 -1
- package/dist/skills/floless-app-routines/SKILL.md +1 -1
- package/dist/skills/floless-app-steel-model/SKILL.md +9 -6
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +116 -17
- package/dist/skills/floless-app-ui/SKILL.md +1 -1
- package/dist/skills/floless-app-workflows/SKILL.md +1 -1
- package/dist/skills/reading-structural-drawings/SKILL.md +1 -1
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +1 -1
- package/dist/web/app.css +52 -5
- package/dist/web/aware.js +194 -5
- package/dist/web/index.html +1 -1
- package/dist/web/json-schema-subset.js +72 -0
- package/dist/web/steel-editor.html +473 -142
- package/dist/web/steel-model-commands.js +154 -14
- package/dist/web/steel-model-v2-client-validation.js +95 -0
- package/dist/web/steel-model-v2-commands.js +836 -0
- package/dist/web/steel-model-v2-projection.js +170 -0
- package/dist/web/steel-plan-transform.js +151 -0
- package/dist/web/workspaces.js +406 -17
- package/package.json +3 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -52427,9 +52427,6 @@ var AwareLifecycleGate = class {
|
|
|
52427
52427
|
runAs(leaseOwner, fn) {
|
|
52428
52428
|
return this.#owners.run(leaseOwner, fn);
|
|
52429
52429
|
}
|
|
52430
|
-
enterAs(leaseOwner) {
|
|
52431
|
-
this.#owners.enterWith(leaseOwner);
|
|
52432
|
-
}
|
|
52433
52430
|
acquireShared(signal) {
|
|
52434
52431
|
return this.#acquire("shared", signal);
|
|
52435
52432
|
}
|
|
@@ -54472,7 +54469,7 @@ function appVersion() {
|
|
|
54472
54469
|
return resolveVersion({
|
|
54473
54470
|
isSea: isSea2(),
|
|
54474
54471
|
sqVersionXml: readSqVersionXml(),
|
|
54475
|
-
define: true ? "0.
|
|
54472
|
+
define: true ? "0.117.0" : void 0,
|
|
54476
54473
|
pkgVersion: readPkgVersion()
|
|
54477
54474
|
});
|
|
54478
54475
|
}
|
|
@@ -54488,7 +54485,7 @@ function resolveChannel(s) {
|
|
|
54488
54485
|
function appChannel() {
|
|
54489
54486
|
return resolveChannel({
|
|
54490
54487
|
isSea: isSea2(),
|
|
54491
|
-
define: true ? "0.
|
|
54488
|
+
define: true ? "0.117.0" : void 0,
|
|
54492
54489
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
54493
54490
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
54494
54491
|
modulePath: process.argv[1]
|
|
@@ -55527,7 +55524,7 @@ function schemaErrorsFor(type, doc) {
|
|
|
55527
55524
|
if (res.valid) return null;
|
|
55528
55525
|
return res.errors.slice(0, 5).map((e) => `${e.path}: ${e.message}`).join("; ");
|
|
55529
55526
|
}
|
|
55530
|
-
function
|
|
55527
|
+
function assertTypeOwnedByApp(type, ctx) {
|
|
55531
55528
|
if (!KNOWN_TYPES.includes(type)) {
|
|
55532
55529
|
throw new ContractPolicyError(
|
|
55533
55530
|
`contract type "${type}" is not known to this build \u2014 a newer FloLess may be required`,
|
|
@@ -55541,6 +55538,10 @@ function assertAcceptableType(type, ctx) {
|
|
|
55541
55538
|
"contract-type-wrong-app"
|
|
55542
55539
|
);
|
|
55543
55540
|
}
|
|
55541
|
+
return authorityId;
|
|
55542
|
+
}
|
|
55543
|
+
function assertAcceptableType(type, ctx) {
|
|
55544
|
+
const authorityId = assertTypeOwnedByApp(type, ctx);
|
|
55544
55545
|
if (type === STEEL_V2 && !isActivatedFor(type, ctx, authorityId)) {
|
|
55545
55546
|
throw new ContractPolicyError(
|
|
55546
55547
|
`contract type "${STEEL_V2}" is not activated for this store \u2014 it must be migrated before it can be used`,
|
|
@@ -59327,36 +59328,36 @@ function similarityFromControls(c0, c1) {
|
|
|
59327
59328
|
var _finite2 = (p) => Array.isArray(p) && p.length >= 2 && Number.isFinite(p[0]) && Number.isFinite(p[1]);
|
|
59328
59329
|
function registerSheet(input) {
|
|
59329
59330
|
const reasons = [];
|
|
59330
|
-
const
|
|
59331
|
-
if (input !== void 0 && (typeof input !== "object" || input === null || Array.isArray(input))) return
|
|
59331
|
+
const refuse2 = (why) => ({ verdict: "refuse", reasons: [...reasons, why], transform: null });
|
|
59332
|
+
if (input !== void 0 && (typeof input !== "object" || input === null || Array.isArray(input))) return refuse2("bad-input");
|
|
59332
59333
|
const { controls, axes, samples, bounds } = input || {};
|
|
59333
|
-
if (controls !== void 0 && !Array.isArray(controls) || samples !== void 0 && !Array.isArray(samples)) return
|
|
59334
|
+
if (controls !== void 0 && !Array.isArray(controls) || samples !== void 0 && !Array.isArray(samples)) return refuse2("bad-input");
|
|
59334
59335
|
const wellFormed = (c) => !!c && typeof c === "object" && _finite2(c.local) && _finite2(c.world);
|
|
59335
59336
|
const cs = controls || [];
|
|
59336
|
-
if (cs.some((c) => !wellFormed(c))) return
|
|
59337
|
+
if (cs.some((c) => !wellFormed(c))) return refuse2("malformed-control");
|
|
59337
59338
|
const ss = samples || [];
|
|
59338
|
-
if (ss.some((s) => !wellFormed(s))) return
|
|
59339
|
-
if (cs.length < 2) return
|
|
59339
|
+
if (ss.some((s) => !wellFormed(s))) return refuse2("malformed-sample");
|
|
59340
|
+
if (cs.length < 2) return refuse2("needs-two-controls");
|
|
59340
59341
|
const transform4 = similarityFromControls(cs[0], cs[1]);
|
|
59341
59342
|
if (!transform4 || !Number.isFinite(transform4.scale) || !Number.isFinite(transform4.rotationRad) || !Number.isFinite(transform4.baselineMm) || !transform4.translation.every(Number.isFinite)) {
|
|
59342
|
-
return
|
|
59343
|
+
return refuse2("degenerate-controls");
|
|
59343
59344
|
}
|
|
59344
59345
|
if (!axes || !_finite2(axes.localX) || !_finite2(axes.localY) || !_finite2(axes.worldX) || !_finite2(axes.worldY)) {
|
|
59345
|
-
return
|
|
59346
|
+
return refuse2("handedness-unestablished");
|
|
59346
59347
|
}
|
|
59347
59348
|
const crossOf = (u, v) => u[0] * v[1] - u[1] * v[0];
|
|
59348
59349
|
const localHand = crossOf(axes.localX, axes.localY), worldHand = crossOf(axes.worldX, axes.worldY);
|
|
59349
|
-
if (!(Math.abs(localHand) > 1e-12) || !(Math.abs(worldHand) > 1e-12)) return
|
|
59350
|
-
if (localHand > 0 !== worldHand > 0) return
|
|
59350
|
+
if (!(Math.abs(localHand) > 1e-12) || !(Math.abs(worldHand) > 1e-12)) return refuse2("handedness-degenerate");
|
|
59351
|
+
if (localHand > 0 !== worldHand > 0) return refuse2("mirrored");
|
|
59351
59352
|
const pivot = cs[0].world;
|
|
59352
59353
|
const far = (p) => Math.hypot(p[0] - pivot[0], p[1] - pivot[1]);
|
|
59353
|
-
if (!bounds || typeof bounds !== "object" || !_finite2(bounds.min) || !_finite2(bounds.max)) return
|
|
59354
|
+
if (!bounds || typeof bounds !== "object" || !_finite2(bounds.min) || !_finite2(bounds.max)) return refuse2("bounds-missing");
|
|
59354
59355
|
let extentMm = 0;
|
|
59355
59356
|
for (const x of [bounds.min[0], bounds.max[0]]) for (const y of [bounds.min[1], bounds.max[1]]) extentMm = Math.max(extentMm, far([x, y]));
|
|
59356
59357
|
for (const c of cs) extentMm = Math.max(extentMm, far(c.world));
|
|
59357
59358
|
const extraSamples = [...cs.slice(2), ...ss];
|
|
59358
59359
|
for (const s of extraSamples) extentMm = Math.max(extentMm, far(s.world));
|
|
59359
|
-
if (!Number.isFinite(extentMm) || extentMm <= 0) return
|
|
59360
|
+
if (!Number.isFinite(extentMm) || extentMm <= 0) return refuse2("bounds-degenerate");
|
|
59360
59361
|
let residualMm = null;
|
|
59361
59362
|
for (const s of extraSamples) {
|
|
59362
59363
|
const q = applySimilarity(transform4, s.local);
|
|
@@ -59368,10 +59369,10 @@ function registerSheet(input) {
|
|
|
59368
59369
|
reasons.push(why);
|
|
59369
59370
|
if (verdict === "ok") verdict = "report";
|
|
59370
59371
|
};
|
|
59371
|
-
if (induced > MODEL_V2_TOL.RESIDUAL_REFUSE_MM) return
|
|
59372
|
-
if (Math.abs(transform4.rotationRad) * 180 / Math.PI > MODEL_V2_TOL.ROTATION_REFUSE_DEG) return
|
|
59373
|
-
if (Math.abs(transform4.scale - 1) > MODEL_V2_TOL.SCALE_REFUSE_FRAC) return
|
|
59374
|
-
if (residualMm !== null && residualMm > MODEL_V2_TOL.RESIDUAL_REFUSE_MM) return
|
|
59372
|
+
if (induced > MODEL_V2_TOL.RESIDUAL_REFUSE_MM) return refuse2("induced-displacement");
|
|
59373
|
+
if (Math.abs(transform4.rotationRad) * 180 / Math.PI > MODEL_V2_TOL.ROTATION_REFUSE_DEG) return refuse2("rotation");
|
|
59374
|
+
if (Math.abs(transform4.scale - 1) > MODEL_V2_TOL.SCALE_REFUSE_FRAC) return refuse2("scale");
|
|
59375
|
+
if (residualMm !== null && residualMm > MODEL_V2_TOL.RESIDUAL_REFUSE_MM) return refuse2("residual");
|
|
59375
59376
|
if (induced > MODEL_V2_TOL.RESIDUAL_REPORT_MM) report("induced-displacement");
|
|
59376
59377
|
if (residualMm === null) report("residual-unverified");
|
|
59377
59378
|
else if (residualMm > MODEL_V2_TOL.RESIDUAL_REPORT_MM) report("residual");
|
|
@@ -60638,7 +60639,7 @@ function previewMigration(v1, ctx) {
|
|
|
60638
60639
|
}
|
|
60639
60640
|
const plans = arr2(doc.plans).filter(isObj2).map((p) => {
|
|
60640
60641
|
const sheet = str2(p.sheet) ?? "";
|
|
60641
|
-
const out = { sheet, memberObservations: obsBySheet.get(sheet) ?? [] };
|
|
60642
|
+
const out = { sheet, viewKind: "plan", memberObservations: obsBySheet.get(sheet) ?? [] };
|
|
60642
60643
|
if (str2(p.title)) out.title = str2(p.title);
|
|
60643
60644
|
if (num(p.pt_per_ft) !== null) out.pt_per_ft = num(p.pt_per_ft);
|
|
60644
60645
|
if (num(p.elevation_in) !== null) out.elevation_in = num(p.elevation_in);
|
|
@@ -60896,6 +60897,121 @@ function previewMigration(v1, ctx) {
|
|
|
60896
60897
|
return { candidate: issues.some((i) => i.severity === "block") ? null : candidate, report, remap };
|
|
60897
60898
|
}
|
|
60898
60899
|
|
|
60900
|
+
// ../web/steel-plan-transform.js
|
|
60901
|
+
var FT_MM2 = 304.8;
|
|
60902
|
+
var finite2 = (p) => Array.isArray(p) && p.length === 2 && p.every(Number.isFinite);
|
|
60903
|
+
var PlanTransformError = class extends Error {
|
|
60904
|
+
constructor(code, message, viewKind = null) {
|
|
60905
|
+
super(message);
|
|
60906
|
+
this.name = "PlanTransformError";
|
|
60907
|
+
this.code = code;
|
|
60908
|
+
this.viewKind = viewKind;
|
|
60909
|
+
}
|
|
60910
|
+
};
|
|
60911
|
+
var refuse = (code, message, plan) => {
|
|
60912
|
+
throw new PlanTransformError(code, message, plan && plan.viewKind);
|
|
60913
|
+
};
|
|
60914
|
+
function gridIntersection(grid, ref, plan) {
|
|
60915
|
+
if (!grid || typeof grid !== "object" || !finite2(grid.origin)) {
|
|
60916
|
+
return refuse("grid-unavailable", `sheet "${plan.sheet || "?"}" has no model grid to resolve its registration controls`, plan);
|
|
60917
|
+
}
|
|
60918
|
+
if (!ref || typeof ref !== "object" || typeof ref.axis_x !== "string" || typeof ref.axis_y !== "string") {
|
|
60919
|
+
return refuse("control-ref-invalid", `sheet "${plan.sheet || "?"}" has an unreadable registration control`, plan);
|
|
60920
|
+
}
|
|
60921
|
+
const X = parseSpacings(grid.x), Y = parseSpacings(grid.y);
|
|
60922
|
+
if (X.err || Y.err) {
|
|
60923
|
+
return refuse("grid-spacing-invalid", `sheet "${plan.sheet || "?"}" cannot use an invalid model-grid spacing string`, plan);
|
|
60924
|
+
}
|
|
60925
|
+
const axes = Array.isArray(grid.axes) ? grid.axes : [];
|
|
60926
|
+
const axisLabels = (dir, fallback, n) => {
|
|
60927
|
+
const rows2 = axes.filter((a) => a && a.dir === dir);
|
|
60928
|
+
return rows2.length === n ? rows2.map((a, i) => String(a.label || fallback[i] || "")) : fallback;
|
|
60929
|
+
};
|
|
60930
|
+
const xs = axisLabels("x", labelsFor(grid.labels_x, "num", X.offsets.length), X.offsets.length);
|
|
60931
|
+
const ys = axisLabels("y", labelsFor(grid.labels_y, "alpha", Y.offsets.length), Y.offsets.length);
|
|
60932
|
+
const uniqueIndex = (labels, wanted) => {
|
|
60933
|
+
const hits = labels.map((label2, i) => label2 === wanted ? i : -1).filter((i) => i >= 0);
|
|
60934
|
+
return hits.length === 1 ? hits[0] : -1;
|
|
60935
|
+
};
|
|
60936
|
+
const xi = uniqueIndex(xs, ref.axis_x), yi = uniqueIndex(ys, ref.axis_y);
|
|
60937
|
+
if (xi < 0 || yi < 0) {
|
|
60938
|
+
return refuse(
|
|
60939
|
+
"control-ref-unresolved",
|
|
60940
|
+
`sheet "${plan.sheet || "?"}" registration control ${ref.axis_x}/${ref.axis_y} does not resolve uniquely on the model grid`,
|
|
60941
|
+
plan
|
|
60942
|
+
);
|
|
60943
|
+
}
|
|
60944
|
+
return [grid.origin[0] + X.offsets[xi], grid.origin[1] + Y.offsets[yi]];
|
|
60945
|
+
}
|
|
60946
|
+
function planTransform(plan) {
|
|
60947
|
+
const kind = plan && plan.viewKind;
|
|
60948
|
+
if (kind !== "plan") {
|
|
60949
|
+
const named = typeof kind === "string" ? kind : "unknown";
|
|
60950
|
+
return refuse(
|
|
60951
|
+
"view-kind-unsupported",
|
|
60952
|
+
`sheet "${plan && plan.sheet || "?"}" is a ${named} view; ${named} views are not supported by the plan transform`,
|
|
60953
|
+
plan
|
|
60954
|
+
);
|
|
60955
|
+
}
|
|
60956
|
+
if (!finite2(plan.datum_at) || !finite2(plan.control2_at) || !plan.control2_ref) {
|
|
60957
|
+
return refuse(
|
|
60958
|
+
"registration-incomplete",
|
|
60959
|
+
`sheet "${plan.sheet || "?"}" needs two resolved registration controls before it can be edited`,
|
|
60960
|
+
plan
|
|
60961
|
+
);
|
|
60962
|
+
}
|
|
60963
|
+
const ptPerFt = Number(plan.pt_per_ft);
|
|
60964
|
+
if (!(ptPerFt > 0) || !Number.isFinite(ptPerFt)) {
|
|
60965
|
+
return refuse("scale-invalid", `sheet "${plan.sheet || "?"}" has no positive drawing scale`, plan);
|
|
60966
|
+
}
|
|
60967
|
+
const registrationGrid = plan.modelGrid || plan.grid;
|
|
60968
|
+
const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan) : [0, 0];
|
|
60969
|
+
const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan);
|
|
60970
|
+
const mmPerPx2 = FT_MM2 / ptPerFt;
|
|
60971
|
+
const local1 = [
|
|
60972
|
+
(plan.control2_at[0] - plan.datum_at[0]) * mmPerPx2,
|
|
60973
|
+
(plan.datum_at[1] - plan.control2_at[1]) * mmPerPx2
|
|
60974
|
+
];
|
|
60975
|
+
const worldDelta = [world1[0] - world0[0], world1[1] - world0[1]];
|
|
60976
|
+
const localLen = Math.hypot(local1[0], local1[1]);
|
|
60977
|
+
const worldLen = Math.hypot(worldDelta[0], worldDelta[1]);
|
|
60978
|
+
if (!(localLen > 1e-9) || !(worldLen > 1e-9)) {
|
|
60979
|
+
return refuse("registration-degenerate", `sheet "${plan.sheet || "?"}" has coincident registration controls`, plan);
|
|
60980
|
+
}
|
|
60981
|
+
const fitScale = worldLen / localLen;
|
|
60982
|
+
const rotation = Math.atan2(worldDelta[1], worldDelta[0]) - Math.atan2(local1[1], local1[0]);
|
|
60983
|
+
const c = Math.cos(rotation) * fitScale;
|
|
60984
|
+
const s = Math.sin(rotation) * fitScale;
|
|
60985
|
+
if (![c, s, fitScale, world0[0], world0[1]].every(Number.isFinite)) {
|
|
60986
|
+
return refuse("registration-invalid", `sheet "${plan.sheet || "?"}" has a non-finite registration transform`, plan);
|
|
60987
|
+
}
|
|
60988
|
+
return { datumPx: plan.datum_at, world0, mmPerPx: mmPerPx2, fitScale, rotation, c, s };
|
|
60989
|
+
}
|
|
60990
|
+
|
|
60991
|
+
// steel-v1-staging-exit.ts
|
|
60992
|
+
var V1_SCHEMA_ADDITION_REASONS = Object.freeze({
|
|
60993
|
+
// "$.$defs.example.properties.futureField": "reader",
|
|
60994
|
+
});
|
|
60995
|
+
function migrationBlockingCodes(report, candidate) {
|
|
60996
|
+
const projectionCodes = [];
|
|
60997
|
+
for (const plan of candidate?.plans ?? []) {
|
|
60998
|
+
if (plan.viewKind !== "plan") continue;
|
|
60999
|
+
try {
|
|
61000
|
+
planTransform({ ...plan, grid: candidate?.grid });
|
|
61001
|
+
} catch (error) {
|
|
61002
|
+
projectionCodes.push(
|
|
61003
|
+
`plan-uneditable:${error instanceof PlanTransformError ? error.code : "unknown"}`
|
|
61004
|
+
);
|
|
61005
|
+
}
|
|
61006
|
+
}
|
|
61007
|
+
return [.../* @__PURE__ */ new Set(
|
|
61008
|
+
[
|
|
61009
|
+
...report.issues.filter((issue) => issue.severity === "block").map((issue) => issue.code),
|
|
61010
|
+
...projectionCodes
|
|
61011
|
+
]
|
|
61012
|
+
)].sort();
|
|
61013
|
+
}
|
|
61014
|
+
|
|
60899
61015
|
// contract-transaction.ts
|
|
60900
61016
|
var ContractTransactionError = class extends Error {
|
|
60901
61017
|
code;
|
|
@@ -60968,11 +61084,12 @@ function publish(begin, staged, before) {
|
|
|
60968
61084
|
writeActivation(projectId, staged.activation);
|
|
60969
61085
|
const existing = listVersions(projectId).find((v) => v.txn === begin.txnId);
|
|
60970
61086
|
const row = existing ?? createVersion(projectId, staged.contract, {
|
|
60971
|
-
author: "You",
|
|
61087
|
+
author: staged.versionAuthor ?? "You",
|
|
60972
61088
|
message: staged.versionMessage,
|
|
60973
61089
|
gate: null,
|
|
60974
61090
|
kind: staged.versionKind,
|
|
60975
|
-
txn: begin.txnId
|
|
61091
|
+
txn: begin.txnId,
|
|
61092
|
+
...staged.versionSource ? { source: staged.versionSource } : {}
|
|
60976
61093
|
});
|
|
60977
61094
|
clearApproval(projectId);
|
|
60978
61095
|
return row.n;
|
|
@@ -60986,7 +61103,7 @@ function rollBack(before, begin) {
|
|
|
60986
61103
|
if (before.contract !== void 0 && before.contract !== null) {
|
|
60987
61104
|
writeContract(appId, before.contract, projectId, {
|
|
60988
61105
|
operation: "rollback",
|
|
60989
|
-
permit: transitionPermit(begin.storeKey, begin.from, begin.from),
|
|
61106
|
+
permit: transitionPermit(begin.storeKey, begin.from ?? declaredTypeOf(before.contract), begin.from ?? declaredTypeOf(before.contract)),
|
|
60990
61107
|
currentType: declaredTypeOf(now),
|
|
60991
61108
|
storeKey: begin.storeKey
|
|
60992
61109
|
});
|
|
@@ -61143,6 +61260,89 @@ async function runMigration(opts) {
|
|
|
61143
61260
|
}
|
|
61144
61261
|
});
|
|
61145
61262
|
}
|
|
61263
|
+
async function runInitialReadToV2(opts) {
|
|
61264
|
+
const { appId, projectId } = opts;
|
|
61265
|
+
return withLifecycleLock("project", projectId, () => {
|
|
61266
|
+
assertNoPendingRecovery(projectId);
|
|
61267
|
+
const current = readContract(appId, projectId);
|
|
61268
|
+
if (current == null && (0, import_node_fs27.existsSync)(contractPath(appId, projectId))) {
|
|
61269
|
+
throw new ContractTransactionError("the project contract exists but is unreadable", "contract-corrupt");
|
|
61270
|
+
}
|
|
61271
|
+
const currentType = current == null ? null : declaredTypeOf(current);
|
|
61272
|
+
if (currentType !== null && currentType !== STEEL_V1) {
|
|
61273
|
+
throw new ContractTransactionError(
|
|
61274
|
+
`the initial-read transaction requires an empty store or provisional ${STEEL_V1}, not "${currentType}"`,
|
|
61275
|
+
"contract-already-exists"
|
|
61276
|
+
);
|
|
61277
|
+
}
|
|
61278
|
+
const head = ledgerHead(projectId);
|
|
61279
|
+
if (head !== 0) {
|
|
61280
|
+
throw new ContractTransactionError("the initial-read transaction requires empty project history", "history-already-exists");
|
|
61281
|
+
}
|
|
61282
|
+
if (declaredTypeOf(opts.v1) !== STEEL_V1) {
|
|
61283
|
+
throw new ContractTransactionError(`the reader staging document must be "${STEEL_V1}"`, "contract-type-unsupported");
|
|
61284
|
+
}
|
|
61285
|
+
const { candidate, report } = previewMigration(opts.v1);
|
|
61286
|
+
const codes = migrationBlockingCodes(report, candidate);
|
|
61287
|
+
if (!candidate || codes.length) {
|
|
61288
|
+
throw new ContractTransactionError(
|
|
61289
|
+
`v1 reader staging must end because this fresh read cannot become ${STEEL_V2}: ${codes.join(", ") || "candidate unavailable"}`,
|
|
61290
|
+
"v1-staging-exit"
|
|
61291
|
+
);
|
|
61292
|
+
}
|
|
61293
|
+
const uuid = getProject(projectId)?.uuid ?? null;
|
|
61294
|
+
const storeKey = uuid ?? (0, import_node_crypto15.randomUUID)();
|
|
61295
|
+
const generation = lastGeneration(projectId) + 1;
|
|
61296
|
+
const authorityAppId = contractAuthorityFor(appId);
|
|
61297
|
+
assertTypeOwnedByApp(STEEL_V2, { appId, projectId, storeKey, operation: "migrate" });
|
|
61298
|
+
const txnId = `${Date.now().toString(36)}-${process.pid.toString(36)}-${(0, import_node_crypto15.randomUUID)().slice(0, 8)}`;
|
|
61299
|
+
const dir = txnDir(projectId, txnId);
|
|
61300
|
+
(0, import_node_fs27.mkdirSync)(dir, { recursive: true });
|
|
61301
|
+
const begin = {
|
|
61302
|
+
txnId,
|
|
61303
|
+
projectId,
|
|
61304
|
+
appId,
|
|
61305
|
+
storeKey,
|
|
61306
|
+
from: currentType,
|
|
61307
|
+
to: STEEL_V2,
|
|
61308
|
+
expectContractHash: current == null ? null : contractHash(current),
|
|
61309
|
+
expectLedgerHead: 0,
|
|
61310
|
+
acknowledgedDecisions: report.issues.filter((issue) => issue.severity === "decision").map((issue) => issue.code)
|
|
61311
|
+
};
|
|
61312
|
+
writePhase(dir, "000-begin", begin);
|
|
61313
|
+
const before = {
|
|
61314
|
+
contract: current,
|
|
61315
|
+
activation: readActivation(projectId),
|
|
61316
|
+
approvedAt: getProject(projectId)?.approvedAt ?? null,
|
|
61317
|
+
uuid
|
|
61318
|
+
};
|
|
61319
|
+
writePhase(dir, "001-before", before);
|
|
61320
|
+
const staged = {
|
|
61321
|
+
contract: candidate,
|
|
61322
|
+
// The resolved LINEAGE ROOT, matching runMigration and runRollbackToV1. Stamping the raw appId
|
|
61323
|
+
// here would write a record whose meaning differs from the other two producers': grantFor tolerates
|
|
61324
|
+
// either today, which is exactly what would hide it until a derived app is renamed and the grant
|
|
61325
|
+
// stops matching, quarantining an activated store with a message that reads like correct behaviour.
|
|
61326
|
+
activation: { appId: authorityAppId, storeKey, type: STEEL_V2, generation },
|
|
61327
|
+
versionMessage: opts.message,
|
|
61328
|
+
versionKind: "revision-read",
|
|
61329
|
+
versionAuthor: "AI",
|
|
61330
|
+
...opts.source ? { versionSource: opts.source } : {}
|
|
61331
|
+
};
|
|
61332
|
+
writePhase(dir, "002-staged", staged);
|
|
61333
|
+
try {
|
|
61334
|
+
writePhase(dir, "003-commit", { at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
61335
|
+
const versionN = publish(begin, staged, before);
|
|
61336
|
+
writePhase(dir, "004-done", { committedAt: (/* @__PURE__ */ new Date()).toISOString(), generation, versionN });
|
|
61337
|
+
retire(dir);
|
|
61338
|
+
return { ok: true, generation, versionN, report };
|
|
61339
|
+
} catch (error) {
|
|
61340
|
+
throw new ContractTransactionError(
|
|
61341
|
+
`the initial read could not be completed and will be recovered on the next start: ${error.message}`
|
|
61342
|
+
);
|
|
61343
|
+
}
|
|
61344
|
+
});
|
|
61345
|
+
}
|
|
61146
61346
|
async function runRollbackToV1(opts) {
|
|
61147
61347
|
const { appId, projectId, doc } = opts;
|
|
61148
61348
|
return withLifecycleLock("project", projectId, () => {
|
|
@@ -62569,6 +62769,7 @@ var REGISTRY = /* @__PURE__ */ new Map([
|
|
|
62569
62769
|
// The MATCH KEY, exactly like `$.members[].id`: plans are paired by sheet before diffing, so this can
|
|
62570
62770
|
// never differ within a pair. Listed so the coverage test sees a decision.
|
|
62571
62771
|
["$.plans[].sheet", { disposition: "issue", note: "the sheet name, which pairs the documents \u2014 a change to it is an add plus a remove, not an edit" }],
|
|
62772
|
+
["$.plans[].viewKind", { disposition: "propose", note: "the reader's explicit sheet classification; unsupported kinds remain stored but are refused by their transform" }],
|
|
62572
62773
|
// The canonical registration a revision read may genuinely move: where the cut plane sits, which grid
|
|
62573
62774
|
// intersection anchors the sheet, what it is called, and which members it presents.
|
|
62574
62775
|
["$.plans[].title", { disposition: "propose" }],
|
|
@@ -64412,6 +64613,7 @@ function readModelOrIssues(doc) {
|
|
|
64412
64613
|
byId: new Map(members.map((m) => [m.id, m])),
|
|
64413
64614
|
sheets: (v2.plans ?? []).map((p) => ({
|
|
64414
64615
|
sheet: p.sheet,
|
|
64616
|
+
viewKind: p.viewKind,
|
|
64415
64617
|
title: p.title,
|
|
64416
64618
|
// `elevation_in` is INCHES and is the sheet's CUT elevation. Deliberately not `default_tos`, which
|
|
64417
64619
|
// v1 defines as the fallback T.O.S for blank ends — the same number on a typical framing plan and
|
|
@@ -67038,6 +67240,28 @@ function registerRevisionRoutes(app) {
|
|
|
67038
67240
|
});
|
|
67039
67241
|
}
|
|
67040
67242
|
sweepOrphanedStaged();
|
|
67243
|
+
const message = typeof req.body?.message === "string" && req.body.message.trim() ? req.body.message.trim() : head === 0 ? "Read the first steel model from the drawing set" : "Re-read a revised drawing set";
|
|
67244
|
+
const source = request.sourceRefs && request.sourceRefs.length ? { files: request.sourceRefs, requestId: request.id } : void 0;
|
|
67245
|
+
if (head === 0 && [void 0, STEEL_V1].includes(storedContractType(project.app, project.id)) && declaredTypeOf(req.body.contract) === STEEL_V1) {
|
|
67246
|
+
try {
|
|
67247
|
+
const committed = await runInitialReadToV2({
|
|
67248
|
+
appId: project.app,
|
|
67249
|
+
projectId: project.id,
|
|
67250
|
+
v1: req.body.contract,
|
|
67251
|
+
message,
|
|
67252
|
+
...source ? { source } : {}
|
|
67253
|
+
});
|
|
67254
|
+
const version2 = listVersions(project.id).find((row) => row.n === committed.versionN);
|
|
67255
|
+
broadcast(contractChangedWithReason(project.app, project.id, "revision-read"));
|
|
67256
|
+
deleteRequest(request.id);
|
|
67257
|
+
return { ok: true, version: version2, contractType: STEEL_V2 };
|
|
67258
|
+
} catch (error) {
|
|
67259
|
+
if (error instanceof ContractTransactionError) {
|
|
67260
|
+
return reply.status(400).send({ ok: false, error: error.message, code: error.code });
|
|
67261
|
+
}
|
|
67262
|
+
throw error;
|
|
67263
|
+
}
|
|
67264
|
+
}
|
|
67041
67265
|
try {
|
|
67042
67266
|
acceptContract(req.body.contract, { appId: project.app, projectId: project.id, operation: "put" });
|
|
67043
67267
|
} catch (e) {
|
|
@@ -67059,8 +67283,6 @@ function registerRevisionRoutes(app) {
|
|
|
67059
67283
|
throw e;
|
|
67060
67284
|
}
|
|
67061
67285
|
clearApproval(project.id);
|
|
67062
|
-
const message = typeof req.body?.message === "string" && req.body.message.trim() ? req.body.message.trim() : "Re-read a revised drawing set";
|
|
67063
|
-
const source = request.sourceRefs && request.sourceRefs.length ? { files: request.sourceRefs, requestId: request.id } : void 0;
|
|
67064
67286
|
const version = createVersion(project.id, req.body.contract, { author: "AI", message, gate: null, kind: "revision-read", source });
|
|
67065
67287
|
broadcast(contractChangedWithReason(project.app, project.id, "revision-read"));
|
|
67066
67288
|
deleteRequest(request.id);
|
|
@@ -70939,6 +71161,14 @@ function registerContractAccessRoutes(app, deps) {
|
|
|
70939
71161
|
let publication = false;
|
|
70940
71162
|
if (req.body && "contract" in req.body) {
|
|
70941
71163
|
candidate = req.body.contract;
|
|
71164
|
+
} else if (project) {
|
|
71165
|
+
candidate = deps.readAcceptedForRequest(req.params.appId, project);
|
|
71166
|
+
if (candidate == null) {
|
|
71167
|
+
return reply.status(404).send({
|
|
71168
|
+
ok: false,
|
|
71169
|
+
error: `no contract for project ${project} to render`
|
|
71170
|
+
});
|
|
71171
|
+
}
|
|
70942
71172
|
} else {
|
|
70943
71173
|
const resolved = deps.resolveAppContract(req.params.appId);
|
|
70944
71174
|
candidate = resolvedDocument(resolved);
|
|
@@ -72159,8 +72389,8 @@ function indexJoints(contract, lib, mapRef) {
|
|
|
72159
72389
|
for (const sigs of idx.values()) sigs.sort();
|
|
72160
72390
|
return idx;
|
|
72161
72391
|
}
|
|
72162
|
-
var
|
|
72163
|
-
var MOVE_TOL_MM = MOVE_TOL_FT *
|
|
72392
|
+
var FT_MM3 = 304.8;
|
|
72393
|
+
var MOVE_TOL_MM = MOVE_TOL_FT * FT_MM3;
|
|
72164
72394
|
var knownZof = (wp) => {
|
|
72165
72395
|
const z = wp?.z;
|
|
72166
72396
|
if (!z || typeof z !== "object") return null;
|
|
@@ -72395,7 +72625,7 @@ function diffV2V2(a, b, ctx, tonnage) {
|
|
|
72395
72625
|
} else {
|
|
72396
72626
|
pairing = pair3d(am.seg, bm.seg);
|
|
72397
72627
|
if (pairing.mm > MOVE_TOL_MM) {
|
|
72398
|
-
out.moved.push({ ref: refOfV2(bm), feet: Math.round(pairing.mm /
|
|
72628
|
+
out.moved.push({ ref: refOfV2(bm), feet: Math.round(pairing.mm / FT_MM3 * 10) / 10 });
|
|
72399
72629
|
changed = true;
|
|
72400
72630
|
}
|
|
72401
72631
|
}
|
|
@@ -80803,6 +81033,7 @@ async function startServer() {
|
|
|
80803
81033
|
// UI + launcher branch on this
|
|
80804
81034
|
};
|
|
80805
81035
|
});
|
|
81036
|
+
app.get("/api/schema/steel-model-v2", async () => loadSteelModelSchema());
|
|
80806
81037
|
app.get("/api/license/status", async () => ({ ok: true, ...await getLicenseStatus() }));
|
|
80807
81038
|
app.post("/api/license/start", async () => ({ ok: true, ...await startLogin() }));
|
|
80808
81039
|
app.post("/api/license/logout", async () => {
|
|
@@ -109,8 +109,11 @@
|
|
|
109
109
|
"section": {
|
|
110
110
|
"type": "object",
|
|
111
111
|
"additionalProperties": false,
|
|
112
|
-
"description": "Explicit section box override (display/bake), when the profile lookup has none.
|
|
113
|
-
"properties": {
|
|
112
|
+
"description": "Explicit section box override (display/bake), when the profile lookup has none. **MILLIMETRES**, like every other length in this document — the same numbers `contract-to-scene` feeds straight into the mm scene. Saying so is not pedantry: the unit was never written down anywhere, and the 2D plan drew these numbers as inches for a whole release, making every traced column 25.4x oversize (#502). A resolved `profile` WINS over this box; it is the pre-resolution placeholder.",
|
|
113
|
+
"properties": {
|
|
114
|
+
"w": { "type": "number", "description": "Section width in mm." },
|
|
115
|
+
"d": { "type": "number", "description": "Section depth in mm." }
|
|
116
|
+
}
|
|
114
117
|
},
|
|
115
118
|
"bf": { "type": "boolean", "description": "Bottom-flange flag. Undeclared in v1, present in real contracts." },
|
|
116
119
|
"rfi": { "type": "boolean", "description": "True when the SIZE is unresolved (excluded from the BOM). A boolean about the profile — unrelated to elevation.rfiRef." },
|
|
@@ -154,11 +157,12 @@
|
|
|
154
157
|
},
|
|
155
158
|
"plan": {
|
|
156
159
|
"type": "object",
|
|
157
|
-
"required": ["sheet"],
|
|
160
|
+
"required": ["sheet", "viewKind"],
|
|
158
161
|
"additionalProperties": false,
|
|
159
162
|
"description": "One framing sheet, as a horizontal CUT PLANE. It no longer owns members: `elevation_in` fixes it in height, the authored controls fix it in plan, `memberObservations` records what its drawing actually showed, and `memberRefs` assigns presentation for members it displays but never observed. Ownership and observation are different things and only ownership disappears (epic §4) — a sheet whose drawing supplied 2 column observations must still DISPLAY the 20 columns crossing its elevation.",
|
|
160
163
|
"properties": {
|
|
161
164
|
"sheet": { "type": "string", "minLength": 1, "description": "Sheet number, e.g. S-202. Unique across plans." },
|
|
165
|
+
"viewKind": { "enum": ["plan", "elevation", "section", "unknown"], "description": "The reader's explicit classification of this sheet. `unknown` means the source did not establish a kind; it is not a default. Only `plan` currently has a coordinate transform, so every other value is refused by name instead of being projected heuristically." },
|
|
162
166
|
"title": { "type": "string" },
|
|
163
167
|
"elevation_in": { "type": "number", "description": "This sheet's CUT elevation, inches. NOT v1's `default_tos` — that was the fallback top-of-steel for blank ends, which happens to carry the same number on a typical framing plan. Conflating them is easy and wrong, so v1's default_tos is materialized into explicit member elevations at migration and does not survive here." },
|
|
164
168
|
"pt_per_ft": { "type": "number", "description": "Display points per foot (the drawing scale). Still needed: observations record local geometry in display px." },
|
|
@@ -300,7 +304,8 @@
|
|
|
300
304
|
"description": "Canonical members this evidence is bound to, 0..n. Plural because a SPLIT rebinds one observation to both results without cloning its evidence."
|
|
301
305
|
},
|
|
302
306
|
"status": { "enum": ["active", "superseded", "archived"] },
|
|
303
|
-
"verified": { "type": "boolean", "description": "True = a human confirmed this trace against its source." }
|
|
307
|
+
"verified": { "type": "boolean", "description": "True = a human confirmed this trace against its source." },
|
|
308
|
+
"inherited": { "type": "boolean", "description": "True when a user split attached this immutable read evidence to both replacement segments." }
|
|
304
309
|
}
|
|
305
310
|
},
|
|
306
311
|
"modelGrid": {
|
|
@@ -510,6 +510,13 @@
|
|
|
510
510
|
"role": { "enum": ["beam", "column"], "description": "Defaults to beam when absent." },
|
|
511
511
|
"position": { "enum": ["top", "middle", "bottom"], "description": "Profile placement relative to the reference line (the work-line between the two work-points) — the section's depth position. top = line at the section top (steel hangs below); middle = line through the centroid; bottom = line at the section bottom. When absent the editor defaults a flat beam to top (line = top of steel), and a column, a VERTICAL brace (whatever its slope — its work-points sit on the column centre-lines) or a steep beam to middle." },
|
|
512
512
|
"rfi": { "type": "boolean", "description": "True when the size is unresolved (excluded from the BOM)." },
|
|
513
|
+
"section": {
|
|
514
|
+
"description": "The reader's traced section box `{w,d}` for a column whose `profile` has not resolved yet, so it still draws at its real footprint instead of a generic marker. **MILLIMETRES** — NOT display space, unlike `wp`. Declared here because it was previously carried by `additionalProperties` alone with its unit written down nowhere, and the 2D plan consequently drew it as inches for a whole release, making every traced column 25.4x oversize (#502). A resolved `profile` WINS over this box. DELIBERATELY unconstrained: this entry documents the unit and must not narrow what already validates, so no `type` is asserted here — v1 is the open, forward-compatible contract, and tightening it belongs in its own change, not in a rendering bugfix.",
|
|
515
|
+
"properties": {
|
|
516
|
+
"w": { "description": "Section width in mm." },
|
|
517
|
+
"d": { "description": "Section depth in mm." }
|
|
518
|
+
}
|
|
519
|
+
},
|
|
513
520
|
"mf": { "type": "boolean", "description": "Moment-frame member (persistent flag)." },
|
|
514
521
|
"memberType": { "type": "string", "description": "Member category driving the legend (e.g. beam, ledger, brace). 'brace' is special: the member draws with the brace symbology and is excluded from every beam-only path (merge, reversed-beams, shear plates)." },
|
|
515
522
|
"brace": {
|