@floless/app 0.135.0 → 0.136.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 +890 -263
- package/dist/schemas/steel.model.v2.schema.json +11 -11
- package/dist/skills/floless-app-report-issue/SKILL.md +46 -9
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +57 -59
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +92 -0
- package/dist/templates/steel-model.flo +44 -4
- package/dist/web/aware-update-client.js +137 -25
- package/dist/web/aware.js +269 -28
- package/dist/web/commands-shell.js +35 -4
- package/dist/web/commands-steel.js +6 -0
- package/dist/web/instructor.js +1 -0
- package/dist/web/steel-editor.html +238 -13
- package/dist/web/steel-model-v2-client-validation.js +20 -14
- package/dist/web/steel-model-v2-commands.js +8 -23
- package/dist/web/steel-model-v2-projection.js +96 -3
- package/dist/web/steel-plan-transform.js +123 -25
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -563,14 +563,14 @@ var require_time_tree = __commonJS({
|
|
|
563
563
|
* @param {number} start
|
|
564
564
|
* @returns {TimeTreeNode["id"]}
|
|
565
565
|
*/
|
|
566
|
-
[kAddNode](parent,
|
|
566
|
+
[kAddNode](parent, label, start2) {
|
|
567
567
|
const parentNode = this[kGetParent](parent);
|
|
568
568
|
const isRoot = parentNode === null;
|
|
569
569
|
if (isRoot) {
|
|
570
570
|
this.root = {
|
|
571
571
|
parent: null,
|
|
572
572
|
id: "root",
|
|
573
|
-
label
|
|
573
|
+
label,
|
|
574
574
|
nodes: [],
|
|
575
575
|
start: start2,
|
|
576
576
|
stop: null,
|
|
@@ -579,11 +579,11 @@ var require_time_tree = __commonJS({
|
|
|
579
579
|
this[kTrackNode](this.root);
|
|
580
580
|
return this.root.id;
|
|
581
581
|
}
|
|
582
|
-
const nodeId = `${
|
|
582
|
+
const nodeId = `${label}-${Math.random()}`;
|
|
583
583
|
const childNode = {
|
|
584
584
|
parent,
|
|
585
585
|
id: nodeId,
|
|
586
|
-
label
|
|
586
|
+
label,
|
|
587
587
|
nodes: [],
|
|
588
588
|
start: start2,
|
|
589
589
|
stop: null,
|
|
@@ -599,8 +599,8 @@ var require_time_tree = __commonJS({
|
|
|
599
599
|
* @param {number|undefined} start
|
|
600
600
|
* @returns {TimeTreeNode["id"]}
|
|
601
601
|
*/
|
|
602
|
-
start(parent,
|
|
603
|
-
return this[kAddNode](parent,
|
|
602
|
+
start(parent, label, start2 = Date.now()) {
|
|
603
|
+
return this[kAddNode](parent, label, start2);
|
|
604
604
|
}
|
|
605
605
|
/**
|
|
606
606
|
* @param {string} nodeId
|
|
@@ -6622,9 +6622,9 @@ var require_levels = __commonJS({
|
|
|
6622
6622
|
const formatter = instance[formattersSym].level;
|
|
6623
6623
|
const { labels } = instance.levels;
|
|
6624
6624
|
const cache2 = {};
|
|
6625
|
-
for (const
|
|
6626
|
-
const level = formatter(labels[
|
|
6627
|
-
cache2[
|
|
6625
|
+
for (const label in labels) {
|
|
6626
|
+
const level = formatter(labels[label], Number(label));
|
|
6627
|
+
cache2[label] = JSON.stringify(level).slice(0, -1);
|
|
6628
6628
|
}
|
|
6629
6629
|
instance[lsCacheSym] = cache2;
|
|
6630
6630
|
return instance;
|
|
@@ -7839,7 +7839,7 @@ var require_pino = __commonJS({
|
|
|
7839
7839
|
bindings(bindings) {
|
|
7840
7840
|
return bindings;
|
|
7841
7841
|
},
|
|
7842
|
-
level(
|
|
7842
|
+
level(label, number) {
|
|
7843
7843
|
return { level: number };
|
|
7844
7844
|
}
|
|
7845
7845
|
}),
|
|
@@ -12777,9 +12777,9 @@ var require_codegen = __commonJS({
|
|
|
12777
12777
|
}
|
|
12778
12778
|
};
|
|
12779
12779
|
var Label = class extends Node {
|
|
12780
|
-
constructor(
|
|
12780
|
+
constructor(label) {
|
|
12781
12781
|
super();
|
|
12782
|
-
this.label =
|
|
12782
|
+
this.label = label;
|
|
12783
12783
|
this.names = {};
|
|
12784
12784
|
}
|
|
12785
12785
|
render({ _n }) {
|
|
@@ -12787,14 +12787,14 @@ var require_codegen = __commonJS({
|
|
|
12787
12787
|
}
|
|
12788
12788
|
};
|
|
12789
12789
|
var Break = class extends Node {
|
|
12790
|
-
constructor(
|
|
12790
|
+
constructor(label) {
|
|
12791
12791
|
super();
|
|
12792
|
-
this.label =
|
|
12792
|
+
this.label = label;
|
|
12793
12793
|
this.names = {};
|
|
12794
12794
|
}
|
|
12795
12795
|
render({ _n }) {
|
|
12796
|
-
const
|
|
12797
|
-
return `break${
|
|
12796
|
+
const label = this.label ? ` ${this.label}` : "";
|
|
12797
|
+
return `break${label};` + _n;
|
|
12798
12798
|
}
|
|
12799
12799
|
};
|
|
12800
12800
|
var Throw = class extends Node {
|
|
@@ -13206,12 +13206,12 @@ var require_codegen = __commonJS({
|
|
|
13206
13206
|
return this._endBlockNode(For);
|
|
13207
13207
|
}
|
|
13208
13208
|
// `label` statement
|
|
13209
|
-
label(
|
|
13210
|
-
return this._leafNode(new Label(
|
|
13209
|
+
label(label) {
|
|
13210
|
+
return this._leafNode(new Label(label));
|
|
13211
13211
|
}
|
|
13212
13212
|
// `break` statement
|
|
13213
|
-
break(
|
|
13214
|
-
return this._leafNode(new Break(
|
|
13213
|
+
break(label) {
|
|
13214
|
+
return this._leafNode(new Break(label));
|
|
13215
13215
|
}
|
|
13216
13216
|
// `return` statement
|
|
13217
13217
|
return(value) {
|
|
@@ -19728,15 +19728,15 @@ var require_quote = __commonJS({
|
|
|
19728
19728
|
'"': '\\"',
|
|
19729
19729
|
"\\": "\\\\"
|
|
19730
19730
|
};
|
|
19731
|
-
function
|
|
19731
|
+
function quote3(s) {
|
|
19732
19732
|
rxEscapable.lastIndex = 0;
|
|
19733
19733
|
return '"' + (rxEscapable.test(s) ? s.replace(rxEscapable, (a) => {
|
|
19734
19734
|
const c = escaped[a];
|
|
19735
19735
|
return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
|
|
19736
19736
|
}) : s) + '"';
|
|
19737
19737
|
}
|
|
19738
|
-
exports2.default =
|
|
19739
|
-
|
|
19738
|
+
exports2.default = quote3;
|
|
19739
|
+
quote3.code = 'require("ajv/dist/runtime/quote").default';
|
|
19740
19740
|
}
|
|
19741
19741
|
});
|
|
19742
19742
|
|
|
@@ -28554,9 +28554,9 @@ var require_node = __commonJS({
|
|
|
28554
28554
|
}
|
|
28555
28555
|
return staticChild.createStaticChild(path.slice(i));
|
|
28556
28556
|
}
|
|
28557
|
-
const
|
|
28558
|
-
this.staticChildren[
|
|
28559
|
-
return this.staticChildren[
|
|
28557
|
+
const label = path.charAt(0);
|
|
28558
|
+
this.staticChildren[label] = new StaticNode(path);
|
|
28559
|
+
return this.staticChildren[label];
|
|
28560
28560
|
}
|
|
28561
28561
|
};
|
|
28562
28562
|
var StaticNode = class _StaticNode extends ParentNode {
|
|
@@ -49443,9 +49443,9 @@ var require_lexer = __commonJS({
|
|
|
49443
49443
|
}
|
|
49444
49444
|
}
|
|
49445
49445
|
*parseQuotedScalar() {
|
|
49446
|
-
const
|
|
49447
|
-
let end = this.buffer.indexOf(
|
|
49448
|
-
if (
|
|
49446
|
+
const quote3 = this.charAt(0);
|
|
49447
|
+
let end = this.buffer.indexOf(quote3, this.pos + 1);
|
|
49448
|
+
if (quote3 === "'") {
|
|
49449
49449
|
while (end !== -1 && this.buffer[end + 1] === "'")
|
|
49450
49450
|
end = this.buffer.indexOf("'", end + 2);
|
|
49451
49451
|
} else {
|
|
@@ -51122,9 +51122,9 @@ var import_node_perf_hooks = require("node:perf_hooks");
|
|
|
51122
51122
|
var MAX_EXPECTED_MS = 2 * 60 * 6e4;
|
|
51123
51123
|
var MAX_LABEL_LENGTH = 60;
|
|
51124
51124
|
function busyMeta(owner2) {
|
|
51125
|
-
const
|
|
51125
|
+
const label = typeof owner2.label === "string" && owner2.label.trim() && owner2.label.length <= MAX_LABEL_LENGTH ? owner2.label.trim() : null;
|
|
51126
51126
|
const expectedMs = typeof owner2.expectedMs === "number" && Number.isFinite(owner2.expectedMs) && owner2.expectedMs > 0 && owner2.expectedMs <= MAX_EXPECTED_MS ? owner2.expectedMs : null;
|
|
51127
|
-
return { label
|
|
51127
|
+
return { label, expectedMs };
|
|
51128
51128
|
}
|
|
51129
51129
|
var LifecycleLockBusyError = class extends Error {
|
|
51130
51130
|
constructor(message, busy) {
|
|
@@ -51146,7 +51146,7 @@ function remainingPhrase(remainingMs) {
|
|
|
51146
51146
|
return `about ${minutes} minute${minutes === 1 ? "" : "s"} left`;
|
|
51147
51147
|
}
|
|
51148
51148
|
function busyDetail(kind, key2, owner2) {
|
|
51149
|
-
const { label
|
|
51149
|
+
const { label, expectedMs } = busyMeta(owner2);
|
|
51150
51150
|
const startedMs = Date.parse(owner2.acquiredAt);
|
|
51151
51151
|
const elapsedMs = Number.isFinite(startedMs) ? Math.max(0, Date.now() - startedMs) : 0;
|
|
51152
51152
|
const usableEta = expectedMs != null && Number.isFinite(startedMs) ? expectedMs : null;
|
|
@@ -51154,7 +51154,7 @@ function busyDetail(kind, key2, owner2) {
|
|
|
51154
51154
|
return {
|
|
51155
51155
|
kind,
|
|
51156
51156
|
key: key2,
|
|
51157
|
-
label
|
|
51157
|
+
label,
|
|
51158
51158
|
startedAt: owner2.acquiredAt,
|
|
51159
51159
|
expectedMs: usableEta,
|
|
51160
51160
|
elapsedMs,
|
|
@@ -51195,8 +51195,8 @@ var held = new import_node_async_hooks.AsyncLocalStorage();
|
|
|
51195
51195
|
var localTails = /* @__PURE__ */ new Map();
|
|
51196
51196
|
var localIntents = /* @__PURE__ */ new Map();
|
|
51197
51197
|
function registerIntent(token2, options) {
|
|
51198
|
-
const { label
|
|
51199
|
-
const intent = { label
|
|
51198
|
+
const { label, expectedMs } = busyMeta(options);
|
|
51199
|
+
const intent = { label, expectedMs, acquiredAt: null };
|
|
51200
51200
|
const set2 = localIntents.get(token2) ?? /* @__PURE__ */ new Set();
|
|
51201
51201
|
set2.add(intent);
|
|
51202
51202
|
localIntents.set(token2, set2);
|
|
@@ -52967,8 +52967,8 @@ function runRawWithEnvUnlocked(args, env2, timeoutMs, onSpawn, signal) {
|
|
|
52967
52967
|
function runRawWithEnv(args, env2, timeoutMs, onSpawn, signal) {
|
|
52968
52968
|
return withAwareShared(() => runRawWithEnvUnlocked(args, env2, timeoutMs, onSpawn, signal), signal);
|
|
52969
52969
|
}
|
|
52970
|
-
async function runJson(args, timeoutMs) {
|
|
52971
|
-
const { code, stdout, stderr } = await runRawWithEnv([...args, "--json"], void 0, timeoutMs);
|
|
52970
|
+
async function runJson(args, timeoutMs, signal) {
|
|
52971
|
+
const { code, stdout, stderr } = await runRawWithEnv([...args, "--json"], void 0, timeoutMs, void 0, signal);
|
|
52972
52972
|
let env2;
|
|
52973
52973
|
try {
|
|
52974
52974
|
env2 = JSON.parse(stdout);
|
|
@@ -53823,10 +53823,18 @@ async function connectList() {
|
|
|
53823
53823
|
}
|
|
53824
53824
|
var awareImpl = {
|
|
53825
53825
|
npmVersion: awareNpmVersion,
|
|
53826
|
-
/**
|
|
53827
|
-
|
|
53826
|
+
/**
|
|
53827
|
+
* Cheap readiness probe — true if `aware app list --json` returns ok.
|
|
53828
|
+
*
|
|
53829
|
+
* "Cheap" is relative: this is a real child process with a RUN_TIMEOUT_MS (60s) ceiling, and it
|
|
53830
|
+
* is the call observed timing out at exactly that in the field. Recovery runs it while holding
|
|
53831
|
+
* the exclusive lease, so it takes a signal — without one, an abort could only release the lease
|
|
53832
|
+
* after the full 60s, which is precisely the unbounded hold the budget exists to prevent.
|
|
53833
|
+
* Callers with no deadline (bootstrap, startup recovery) pass nothing and keep today's behaviour.
|
|
53834
|
+
*/
|
|
53835
|
+
async smoke(signal) {
|
|
53828
53836
|
try {
|
|
53829
|
-
await this.list();
|
|
53837
|
+
await this.list(signal);
|
|
53830
53838
|
return true;
|
|
53831
53839
|
} catch {
|
|
53832
53840
|
return false;
|
|
@@ -53837,8 +53845,8 @@ var awareImpl = {
|
|
|
53837
53845
|
hostBridgeStatus,
|
|
53838
53846
|
hostInstances,
|
|
53839
53847
|
/** GET /api/apps */
|
|
53840
|
-
async list() {
|
|
53841
|
-
const { data } = await runJson(["app", "list"]);
|
|
53848
|
+
async list(signal) {
|
|
53849
|
+
const { data } = await runJson(["app", "list"], void 0, signal);
|
|
53842
53850
|
return data.apps ?? [];
|
|
53843
53851
|
},
|
|
53844
53852
|
/** GET /api/agents — installed agent catalog (honors --json). */
|
|
@@ -55050,7 +55058,7 @@ function appVersion() {
|
|
|
55050
55058
|
return resolveVersion({
|
|
55051
55059
|
isSea: isSea2(),
|
|
55052
55060
|
sqVersionXml: readSqVersionXml(),
|
|
55053
|
-
define: true ? "0.
|
|
55061
|
+
define: true ? "0.136.0" : void 0,
|
|
55054
55062
|
pkgVersion: readPkgVersion()
|
|
55055
55063
|
});
|
|
55056
55064
|
}
|
|
@@ -55066,7 +55074,7 @@ function resolveChannel(s) {
|
|
|
55066
55074
|
function appChannel() {
|
|
55067
55075
|
return resolveChannel({
|
|
55068
55076
|
isSea: isSea2(),
|
|
55069
|
-
define: true ? "0.
|
|
55077
|
+
define: true ? "0.136.0" : void 0,
|
|
55070
55078
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
55071
55079
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
55072
55080
|
modulePath: process.argv[1]
|
|
@@ -55869,9 +55877,9 @@ function partFrame(from, to, up = [0, 0, 1], upX = [1, 0, 0]) {
|
|
|
55869
55877
|
const len = Math.sqrt(dSq);
|
|
55870
55878
|
if (!(len > 0) || !isFinite(len)) return null;
|
|
55871
55879
|
const x = [d[0] / len, d[1] / len, d[2] / len];
|
|
55872
|
-
const unit2 = (v,
|
|
55880
|
+
const unit2 = (v, label, min = 0) => {
|
|
55873
55881
|
const l = Math.hypot(v[0], v[1], v[2]);
|
|
55874
|
-
if (!(l > min) || !isFinite(l)) throw new Error(`partFrame ${
|
|
55882
|
+
if (!(l > min) || !isFinite(l)) throw new Error(`partFrame ${label} must be finite and non-degenerate`);
|
|
55875
55883
|
return [v[0] / l, v[1] / l, v[2] / l];
|
|
55876
55884
|
};
|
|
55877
55885
|
const u = unit2(up, "up");
|
|
@@ -55931,6 +55939,25 @@ var SUPPORT_CENTERLINE_V1 = Object.freeze({
|
|
|
55931
55939
|
minCrossingAngleDeg: 15,
|
|
55932
55940
|
absoluteReachCapMm: 914.4,
|
|
55933
55941
|
geometryReviewToleranceMm: 6.35,
|
|
55942
|
+
/**
|
|
55943
|
+
* How far a reader's submitted endpoint may sit from the server-derived drawing observation before
|
|
55944
|
+
* the read is refused (world mm — one micron).
|
|
55945
|
+
*
|
|
55946
|
+
* The comparison used to be exact JSON equality, which asked an independent reader to reproduce a
|
|
55947
|
+
* trig-laden similarity transform and land on the same side of `clean()`'s 1e-9 rounding boundary for
|
|
55948
|
+
* every endpoint. Nothing can hold that: a 250-member read was refused because three endpoints out of
|
|
55949
|
+
* 430 landed one 1e-9 quantum away, while the worst geometric disagreement across all 430 was
|
|
55950
|
+
* 6.77e-10 mm (#934). Quantising both sides does not help — it only relocates the same cliff — so the
|
|
55951
|
+
* comparison has to be a DISTANCE.
|
|
55952
|
+
*
|
|
55953
|
+
* 1e-3 mm is ~6 orders above the observed float noise and ~4 orders below the smallest thing the
|
|
55954
|
+
* check must still catch. A pre-extended endpoint hides the outward intersection by a drawing
|
|
55955
|
+
* setback, and this policy's own floor for a meaningful endpoint distance is
|
|
55956
|
+
* `geometryReviewToleranceMm` (6.35 mm) — 3.8 orders above this tolerance — so nothing the check
|
|
55957
|
+
* exists to catch fits inside it. Anything in 1e-5..1e-2 works; the point of the number is that it
|
|
55958
|
+
* sits in the middle of a very wide safe band, not that it is tuned.
|
|
55959
|
+
*/
|
|
55960
|
+
literalEvidenceToleranceMm: 1e-3,
|
|
55934
55961
|
maxSubjectEnds: 2e4,
|
|
55935
55962
|
maxObservationsPerEnd: 16,
|
|
55936
55963
|
maxMemberIdsPerTarget: 16,
|
|
@@ -56186,14 +56213,25 @@ function checkModelReferences(doc) {
|
|
|
56186
56213
|
});
|
|
56187
56214
|
arr(p.memberRefs).forEach((id, ri) => memberRef(str(id), `$.plans[${pi}].memberRefs[${ri}]`, "member-ref-unresolved"));
|
|
56188
56215
|
const has = (k) => p[k] !== void 0 && p[k] !== null;
|
|
56189
|
-
if (
|
|
56190
|
-
|
|
56191
|
-
|
|
56192
|
-
|
|
56193
|
-
|
|
56194
|
-
|
|
56216
|
+
if (p.viewKind === "plan") {
|
|
56217
|
+
if (has("control2_at") && !has("control2_ref")) {
|
|
56218
|
+
add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has control2_at with no control2_ref; a second control is never the model origin, so the intersection it names must be stated`);
|
|
56219
|
+
}
|
|
56220
|
+
for (const side2 of ["datum", "control2"]) {
|
|
56221
|
+
if (has(`${side2}_ref`) && !has(`${side2}_at`)) {
|
|
56222
|
+
add(`$.plans[${pi}]`, "control-pair-incomplete", `sheet "${sheet ?? pi}" has ${side2}_ref with no ${side2}_at; naming an intersection without its point on the sheet registers nothing`);
|
|
56223
|
+
}
|
|
56195
56224
|
}
|
|
56196
56225
|
}
|
|
56226
|
+
const planStyleControls = ["datum_at", "datum_ref", "control2_at", "control2_ref"].filter((k) => has(k));
|
|
56227
|
+
if (p.viewKind !== "plan" && !isObj(p.sourceRegistration) && planStyleControls.length) {
|
|
56228
|
+
const kind = str(p.viewKind) ?? "";
|
|
56229
|
+
add(
|
|
56230
|
+
`$.plans[${pi}]`,
|
|
56231
|
+
"plan-controls-on-non-plan-view",
|
|
56232
|
+
`sheet "${sheet ?? pi}" is ${kind === "elevation" ? "an elevation" : kind ? `a ${kind}` : "an unclassified"} view carrying ${planStyleControls.map((k) => `$.${k}`).join(", ")} and nothing else; those register a PLAN and are ignored here \u2014 an elevation or section registers through $.sourceRegistration`
|
|
56233
|
+
);
|
|
56234
|
+
}
|
|
56197
56235
|
const registration = isObj(p.sourceRegistration) ? p.sourceRegistration : null;
|
|
56198
56236
|
if (registration) {
|
|
56199
56237
|
const rp = `$.plans[${pi}].sourceRegistration`;
|
|
@@ -56495,6 +56533,29 @@ function checkModelReferences(doc) {
|
|
|
56495
56533
|
else compare("z", parsed.levels.length);
|
|
56496
56534
|
}
|
|
56497
56535
|
const axisIds = new Set(axes.map((a) => isObj(a) ? str(a.id) : null).filter((v) => !!v));
|
|
56536
|
+
const axisDir = /* @__PURE__ */ new Map();
|
|
56537
|
+
for (const a of axes) {
|
|
56538
|
+
if (isObj(a)) {
|
|
56539
|
+
const id = str(a.id), dir = str(a.dir);
|
|
56540
|
+
if (id && dir) axisDir.set(id, dir);
|
|
56541
|
+
}
|
|
56542
|
+
}
|
|
56543
|
+
plans.forEach((p, pi) => {
|
|
56544
|
+
if (!isObj(p)) return;
|
|
56545
|
+
for (const key2 of ["datum_ref", "control2_ref"]) {
|
|
56546
|
+
const ref = isObj(p[key2]) ? p[key2] : null;
|
|
56547
|
+
if (!ref) continue;
|
|
56548
|
+
for (const [field, want] of [["xAxisId", "x"], ["yAxisId", "y"]]) {
|
|
56549
|
+
const id = str(ref[field]);
|
|
56550
|
+
const path = `$.plans[${pi}].${key2}.${field}`;
|
|
56551
|
+
if (!id || !axisIds.has(id)) {
|
|
56552
|
+
add(path, "control-ref-unresolved", `${field} "${id ?? ""}" does not name a $.grid.axes[].id \u2014 registration controls resolve against stable axis IDS, never the editable display label`);
|
|
56553
|
+
} else if (axisDir.get(id) !== want) {
|
|
56554
|
+
add(path, "control-ref-direction", `${field} names axis "${id}", which runs in ${axisDir.get(id) ?? "no"} \u2014 ${field} must name a ${want}-direction axis`);
|
|
56555
|
+
}
|
|
56556
|
+
}
|
|
56557
|
+
}
|
|
56558
|
+
});
|
|
56498
56559
|
if (isObj(grid.ends)) {
|
|
56499
56560
|
for (const [key2, span] of Object.entries(grid.ends)) {
|
|
56500
56561
|
if (!axisIds.has(key2)) {
|
|
@@ -56575,12 +56636,12 @@ function checkModelReferences(doc) {
|
|
|
56575
56636
|
if (gen) {
|
|
56576
56637
|
const sheet = str(gen.sheet);
|
|
56577
56638
|
if (sheet && !planSheets.has(sheet)) add(`$.views[${vi}].generated.sheet`, "view-generated-unresolved", `"${sheet}" does not name a plan`);
|
|
56578
|
-
const
|
|
56639
|
+
const axisId2 = str(gen.axisId);
|
|
56579
56640
|
const wantDir = gen.kind === "level" ? "z" : gen.kind === "grid-x" ? "x" : gen.kind === "grid-y" ? "y" : null;
|
|
56580
56641
|
if (wantDir === null) add(`$.views[${vi}].generated.kind`, "view-generated-unresolved", `unknown generated kind "${str(gen.kind)}"`);
|
|
56581
|
-
const axis = arr(grid?.axes).find((a) => isObj(a) && str(a.id) ===
|
|
56582
|
-
if (
|
|
56583
|
-
add(`$.views[${vi}].generated.axisId`, "view-generated-unresolved", `"${
|
|
56642
|
+
const axis = arr(grid?.axes).find((a) => isObj(a) && str(a.id) === axisId2);
|
|
56643
|
+
if (axisId2 && (!axis || axis.dir !== wantDir)) {
|
|
56644
|
+
add(`$.views[${vi}].generated.axisId`, "view-generated-unresolved", `"${axisId2}" does not name a grid axis with dir "${wantDir}"`);
|
|
56584
56645
|
}
|
|
56585
56646
|
}
|
|
56586
56647
|
});
|
|
@@ -60213,12 +60274,12 @@ function writePhase(txnDir, journal) {
|
|
|
60213
60274
|
}
|
|
60214
60275
|
}
|
|
60215
60276
|
}
|
|
60216
|
-
function validateProof(value,
|
|
60277
|
+
function validateProof(value, label) {
|
|
60217
60278
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
60218
|
-
throw new IfcPublicationError(`${
|
|
60279
|
+
throw new IfcPublicationError(`${label} proof is invalid.`);
|
|
60219
60280
|
}
|
|
60220
60281
|
const p = value;
|
|
60221
|
-
if (typeof p.exists !== "boolean" || typeof p.bytes !== "number" || !Number.isSafeInteger(p.bytes) || p.bytes < 0 || !(p.exists && typeof p.sha256 === "string" && /^[a-f0-9]{64}$/i.test(p.sha256) && p.bytes > 0 || !p.exists && p.sha256 === null && p.bytes === 0)) throw new IfcPublicationError(`${
|
|
60282
|
+
if (typeof p.exists !== "boolean" || typeof p.bytes !== "number" || !Number.isSafeInteger(p.bytes) || p.bytes < 0 || !(p.exists && typeof p.sha256 === "string" && /^[a-f0-9]{64}$/i.test(p.sha256) && p.bytes > 0 || !p.exists && p.sha256 === null && p.bytes === 0)) throw new IfcPublicationError(`${label} proof is invalid.`);
|
|
60222
60283
|
return p;
|
|
60223
60284
|
}
|
|
60224
60285
|
function validateJournal(raw, txnDir, expectedTxnId) {
|
|
@@ -60944,9 +61005,9 @@ var navLeaf = (family) => ({
|
|
|
60944
61005
|
families: [family],
|
|
60945
61006
|
count: PROFILE_FAMILY_COUNTS[family]
|
|
60946
61007
|
});
|
|
60947
|
-
var navParent = (id,
|
|
61008
|
+
var navParent = (id, label, families) => ({
|
|
60948
61009
|
id,
|
|
60949
|
-
label
|
|
61010
|
+
label,
|
|
60950
61011
|
families,
|
|
60951
61012
|
count: families.reduce((sum, family) => sum + PROFILE_FAMILY_COUNTS[family], 0),
|
|
60952
61013
|
children: families.map(navLeaf)
|
|
@@ -62485,14 +62546,14 @@ function durableReplace2(path, text5) {
|
|
|
62485
62546
|
function safeLease(value) {
|
|
62486
62547
|
if (!SAFE_LEASE.test(value)) throw new Error("invalid Codex lease id");
|
|
62487
62548
|
}
|
|
62488
|
-
function rejectLink(path,
|
|
62549
|
+
function rejectLink(path, label) {
|
|
62489
62550
|
let st;
|
|
62490
62551
|
try {
|
|
62491
62552
|
st = (0, import_node_fs30.lstatSync)(path);
|
|
62492
62553
|
} catch {
|
|
62493
|
-
throw new Error(`${
|
|
62554
|
+
throw new Error(`${label} not found`);
|
|
62494
62555
|
}
|
|
62495
|
-
if (st.isSymbolicLink()) throw new Error(`${
|
|
62556
|
+
if (st.isSymbolicLink()) throw new Error(`${label} is a filesystem link/reparse point`);
|
|
62496
62557
|
}
|
|
62497
62558
|
var ps = (value) => value.replace(/'/g, "''");
|
|
62498
62559
|
var sh = (value) => value.replace(/'/g, `'"'"'`);
|
|
@@ -64451,20 +64512,20 @@ var INTERNAL_VISIBLE_WORDS = /\b(?:schema|api|manifest|ledger|registration|bindi
|
|
|
64451
64512
|
var ITEM_STATES = /* @__PURE__ */ new Set(["pending", "done", "now", "blocked", "waiting", "provisional"]);
|
|
64452
64513
|
var STATUSES = /* @__PURE__ */ new Set(["active", "waiting", "blocked", "complete", "cancelled"]);
|
|
64453
64514
|
var SOURCE_SKILLS = new Set(STEEL_PROGRESS_SOURCE_SKILLS);
|
|
64454
|
-
function exactKeys(value, allowed,
|
|
64515
|
+
function exactKeys(value, allowed, label) {
|
|
64455
64516
|
const unexpected = Object.keys(value).filter((key2) => !allowed.includes(key2));
|
|
64456
|
-
if (unexpected.length) throw new SteelProgressError(`${
|
|
64517
|
+
if (unexpected.length) throw new SteelProgressError(`${label} contains unsupported fields`);
|
|
64457
64518
|
}
|
|
64458
|
-
function boundedText(value,
|
|
64519
|
+
function boundedText(value, label, max2, nullable = false) {
|
|
64459
64520
|
if (nullable && value === null) return null;
|
|
64460
64521
|
if (typeof value !== "string" || !value.trim() || value.length > max2 || /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/.test(value)) {
|
|
64461
|
-
throw new SteelProgressError(`${
|
|
64522
|
+
throw new SteelProgressError(`${label} must be plain text within ${max2} characters`);
|
|
64462
64523
|
}
|
|
64463
64524
|
return value.trim();
|
|
64464
64525
|
}
|
|
64465
|
-
function rejectInternalVisibleTerms(value,
|
|
64526
|
+
function rejectInternalVisibleTerms(value, label) {
|
|
64466
64527
|
if (value && INTERNAL_VISIBLE_WORDS.test(value)) {
|
|
64467
|
-
throw new SteelProgressError(`${
|
|
64528
|
+
throw new SteelProgressError(`${label} must use plain English without internal terms`);
|
|
64468
64529
|
}
|
|
64469
64530
|
}
|
|
64470
64531
|
function validateSteelProgressInput(value, requestId) {
|
|
@@ -66671,7 +66732,7 @@ function expandCustom(joint, review) {
|
|
|
66671
66732
|
positions[k + 2] = g.positions[k + 2] + dz;
|
|
66672
66733
|
}
|
|
66673
66734
|
const role = typeof g.role === "string" ? g.role : void 0;
|
|
66674
|
-
const
|
|
66735
|
+
const label = role ? role.charAt(0).toUpperCase() + role.slice(1) : "Imported part";
|
|
66675
66736
|
const lift = review && review.get(joint.id);
|
|
66676
66737
|
out.push({
|
|
66677
66738
|
id: `${joint.id}:${g.id || `m${i}`}`,
|
|
@@ -66679,7 +66740,7 @@ function expandCustom(joint, review) {
|
|
|
66679
66740
|
kind: "mesh",
|
|
66680
66741
|
positions,
|
|
66681
66742
|
indices: g.indices.slice(),
|
|
66682
|
-
meta: { label
|
|
66743
|
+
meta: { label, role, ...lift ? { connReview: lift } : {} }
|
|
66683
66744
|
});
|
|
66684
66745
|
});
|
|
66685
66746
|
return out;
|
|
@@ -67437,18 +67498,18 @@ function buildManifest(scene) {
|
|
|
67437
67498
|
if (ref.axes.length === 0) fail2(`the scene's grid "${id}" must state at least one axis.`);
|
|
67438
67499
|
for (const axisRaw of ref.axes) {
|
|
67439
67500
|
const axis = obj2(axisRaw);
|
|
67440
|
-
const
|
|
67501
|
+
const label = typeof axis.label === "string" ? axis.label : str2(axis.id);
|
|
67441
67502
|
const direction = axis.direction;
|
|
67442
67503
|
if (direction !== "x" && direction !== "y") {
|
|
67443
|
-
fail2(`the scene's grid axis "${
|
|
67504
|
+
fail2(`the scene's grid axis "${label}" direction must be exactly "x" or "y".`);
|
|
67444
67505
|
}
|
|
67445
67506
|
const offset = axis.offsetMm;
|
|
67446
|
-
if (typeof offset !== "number" || !Number.isFinite(offset)) fail2(`the scene's grid axis "${
|
|
67507
|
+
if (typeof offset !== "number" || !Number.isFinite(offset)) fail2(`the scene's grid axis "${label}" states no offsetMm, so the checker cannot say where it belongs.`);
|
|
67447
67508
|
const finiteEnd = (key2, fallback2) => {
|
|
67448
67509
|
const value = axis[key2];
|
|
67449
67510
|
if (value === void 0) return fallback2;
|
|
67450
67511
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
67451
|
-
fail2(`the scene's grid axis "${
|
|
67512
|
+
fail2(`the scene's grid axis "${label}" ${key2} must be a finite number when stated.`);
|
|
67452
67513
|
}
|
|
67453
67514
|
return value;
|
|
67454
67515
|
};
|
|
@@ -67456,7 +67517,7 @@ function buildManifest(scene) {
|
|
|
67456
67517
|
const lo = finiteEnd("startMm", bound(isU ? "minY" : "minX"));
|
|
67457
67518
|
const hi = finiteEnd("endMm", bound(isU ? "maxY" : "maxX"));
|
|
67458
67519
|
const o = offset;
|
|
67459
|
-
(isU ? u : v).push(isU ? { label
|
|
67520
|
+
(isU ? u : v).push(isU ? { label, p0: [o, lo], p1: [o, hi] } : { label, p0: [lo, o], p1: [hi, o] });
|
|
67460
67521
|
}
|
|
67461
67522
|
gridAxes.push({ sceneId: id, gridGuid: guid, origin, u, v });
|
|
67462
67523
|
for (const levelRaw of arr2(ref.levels)) {
|
|
@@ -67837,9 +67898,9 @@ function checkGridAxes(index, manifest) {
|
|
|
67837
67898
|
}
|
|
67838
67899
|
}
|
|
67839
67900
|
function checkSpatialStructure(index, manifest) {
|
|
67840
|
-
for (const [type,
|
|
67901
|
+
for (const [type, label] of [["IFCPROJECT", "project"], ["IFCSITE", "site"], ["IFCBUILDING", "building"], ["IFCBUILDINGSTOREY", "storey"]]) {
|
|
67841
67902
|
const found = index.byType(type).length;
|
|
67842
|
-
if (found !== 1) fail2(`the IFC has ${found} ${
|
|
67903
|
+
if (found !== 1) fail2(`the IFC has ${found} ${label} records, expected exactly 1.`);
|
|
67843
67904
|
}
|
|
67844
67905
|
const aggregates = index.byType("IFCRELAGGREGATES");
|
|
67845
67906
|
if (aggregates.length !== 3) fail2(`the IFC has ${aggregates.length} spatial aggregations, expected 3.`);
|
|
@@ -67976,9 +68037,9 @@ function checkIfcArtifact(sceneInput, receipt, emitted, index, bytes2) {
|
|
|
67976
68037
|
}
|
|
67977
68038
|
|
|
67978
68039
|
// export-receipt.ts
|
|
67979
|
-
function record2(value,
|
|
68040
|
+
function record2(value, label) {
|
|
67980
68041
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
67981
|
-
throw new ReceiptReconciliationError(`${
|
|
68042
|
+
throw new ReceiptReconciliationError(`${label} must be an object.`);
|
|
67982
68043
|
}
|
|
67983
68044
|
return value;
|
|
67984
68045
|
}
|
|
@@ -68634,8 +68695,8 @@ function readSelectionFromBody(body) {
|
|
|
68634
68695
|
return Object.keys(own2).length === 0 ? null : "invalid";
|
|
68635
68696
|
}
|
|
68636
68697
|
const raw = own2.memberIds;
|
|
68637
|
-
const
|
|
68638
|
-
if (!
|
|
68698
|
+
const wellFormed2 = Array.isArray(raw) && raw.length > 0 && raw.length <= MAX_SELECTION_MEMBERS && raw.every((id) => typeof id === "string" && id.trim() !== "");
|
|
68699
|
+
if (!wellFormed2) return "invalid";
|
|
68639
68700
|
return [...new Set(raw)];
|
|
68640
68701
|
}
|
|
68641
68702
|
function selectionMemberCount(contractInput) {
|
|
@@ -68937,8 +68998,8 @@ function modelGridRecords(grid) {
|
|
|
68937
68998
|
const axes = [];
|
|
68938
68999
|
X.offsets.forEach((offsetMm, index) => {
|
|
68939
69000
|
const axis = xAxes[index];
|
|
68940
|
-
const
|
|
68941
|
-
if (!
|
|
69001
|
+
const label = labelX[index] || "";
|
|
69002
|
+
if (!label) throw new SceneContractError("The model grid has a blank X-axis label.");
|
|
68942
69003
|
const span = ends[axis.id];
|
|
68943
69004
|
const start2 = span ? Math.min(span[0], span[1]) - oy : bounds.minY;
|
|
68944
69005
|
const end = span ? Math.max(span[0], span[1]) - oy : bounds.maxY;
|
|
@@ -68946,15 +69007,15 @@ function modelGridRecords(grid) {
|
|
|
68946
69007
|
id: `${root6}:${axis.id}`,
|
|
68947
69008
|
direction: "x",
|
|
68948
69009
|
offsetMm,
|
|
68949
|
-
label
|
|
69010
|
+
label,
|
|
68950
69011
|
...Math.abs(start2 - bounds.minY) > 0.5 ? { startMm: start2 } : {},
|
|
68951
69012
|
...Math.abs(end - bounds.maxY) > 0.5 ? { endMm: end } : {}
|
|
68952
69013
|
});
|
|
68953
69014
|
});
|
|
68954
69015
|
Y.offsets.forEach((offsetMm, index) => {
|
|
68955
69016
|
const axis = yAxes[index];
|
|
68956
|
-
const
|
|
68957
|
-
if (!
|
|
69017
|
+
const label = labelY[index] || "";
|
|
69018
|
+
if (!label) throw new SceneContractError("The model grid has a blank Y-axis label.");
|
|
68958
69019
|
const span = ends[axis.id];
|
|
68959
69020
|
const start2 = span ? Math.min(span[0], span[1]) - ox : bounds.minX;
|
|
68960
69021
|
const end = span ? Math.max(span[0], span[1]) - ox : bounds.maxX;
|
|
@@ -68962,7 +69023,7 @@ function modelGridRecords(grid) {
|
|
|
68962
69023
|
id: `${root6}:${axis.id}`,
|
|
68963
69024
|
direction: "y",
|
|
68964
69025
|
offsetMm,
|
|
68965
|
-
label
|
|
69026
|
+
label,
|
|
68966
69027
|
...Math.abs(start2 - bounds.minX) > 0.5 ? { startMm: start2 } : {},
|
|
68967
69028
|
...Math.abs(end - bounds.maxX) > 0.5 ? { endMm: end } : {}
|
|
68968
69029
|
});
|
|
@@ -68972,9 +69033,9 @@ function modelGridRecords(grid) {
|
|
|
68972
69033
|
[...parsedLevels].sort((a, b) => a.sourceIndex - b.sourceIndex).forEach((level, index) => axisBySourceIndex.set(level.sourceIndex, zAxes[index]));
|
|
68973
69034
|
const levels = parsedLevels.map((level) => {
|
|
68974
69035
|
const axis = axisBySourceIndex.get(level.sourceIndex);
|
|
68975
|
-
const
|
|
68976
|
-
if (!
|
|
68977
|
-
return { id: `${root6}:${axis.id}`, elevationMm: level.mm, label
|
|
69036
|
+
const label = (axis.label ?? "").trim() || level.label;
|
|
69037
|
+
if (!label) throw new SceneContractError("The model grid has a blank elevation label.");
|
|
69038
|
+
return { id: `${root6}:${axis.id}`, elevationMm: level.mm, label };
|
|
68978
69039
|
});
|
|
68979
69040
|
const record4 = {
|
|
68980
69041
|
id: root6,
|
|
@@ -69837,6 +69898,8 @@ var clean = (n) => {
|
|
|
69837
69898
|
return Object.is(q, -0) ? 0 : q;
|
|
69838
69899
|
};
|
|
69839
69900
|
var finite2 = (p) => Array.isArray(p) && p.length === 2 && p.every(Number.isFinite);
|
|
69901
|
+
var round2 = (n) => Math.round(n * 100) / 100;
|
|
69902
|
+
var REGISTRATION_SPAN_TOLERANCE_PT = 2;
|
|
69840
69903
|
var PlanTransformError = class extends Error {
|
|
69841
69904
|
constructor(code, message, viewKind = null) {
|
|
69842
69905
|
super(message);
|
|
@@ -69848,28 +69911,51 @@ var PlanTransformError = class extends Error {
|
|
|
69848
69911
|
var refuse = (code, message, plan) => {
|
|
69849
69912
|
throw new PlanTransformError(code, message, plan && plan.viewKind);
|
|
69850
69913
|
};
|
|
69851
|
-
|
|
69852
|
-
|
|
69853
|
-
|
|
69914
|
+
var MAX_QUOTED_CHARS = 48;
|
|
69915
|
+
var CONTROL_CHARS = new RegExp("[\\u0000-\\u001f\\u007f]", "g");
|
|
69916
|
+
var LONE_SURROGATE = new RegExp("[\\ud800-\\udbff](?![\\udc00-\\udfff])|(?<![\\ud800-\\udbff])[\\udc00-\\udfff]", "g");
|
|
69917
|
+
var wellFormed = (text5) => typeof text5.toWellFormed === "function" ? text5.toWellFormed() : text5.replace(LONE_SURROGATE, "\uFFFD");
|
|
69918
|
+
var clipQuoted = (value, max2 = MAX_QUOTED_CHARS) => {
|
|
69919
|
+
const text5 = wellFormed(typeof value === "string" && value ? value : "?").replace(CONTROL_CHARS, " ");
|
|
69920
|
+
if (max2 <= 0) return "";
|
|
69921
|
+
if (text5.length <= max2) return text5;
|
|
69922
|
+
let end = max2 - 1;
|
|
69923
|
+
const code = text5.charCodeAt(end - 1);
|
|
69924
|
+
if (end > 0 && code >= 55296 && code <= 56319) end--;
|
|
69925
|
+
return `${text5.slice(0, end)}\u2026`;
|
|
69926
|
+
};
|
|
69927
|
+
var quote = (value) => clipQuoted(value);
|
|
69928
|
+
function gridIntersection(grid, ref, plan, field) {
|
|
69929
|
+
if (!grid || typeof grid !== "object") {
|
|
69930
|
+
return refuse("grid-unavailable", `sheet "${quote(plan.sheet)}" has no model grid to resolve its registration controls`, plan);
|
|
69931
|
+
}
|
|
69932
|
+
if (!finite2(grid.origin)) {
|
|
69933
|
+
return refuse(
|
|
69934
|
+
"grid-unavailable",
|
|
69935
|
+
`sheet "${quote(plan.sheet)}" cannot resolve its registration controls: $.grid.origin is missing or unreadable \u2014 it must be two finite world-mm numbers giving where the first x and y grid axes cross`,
|
|
69936
|
+
plan
|
|
69937
|
+
);
|
|
69854
69938
|
}
|
|
69855
|
-
if (!ref || typeof ref !== "object" || typeof ref.
|
|
69856
|
-
return refuse("control-ref-invalid", `sheet "${plan.sheet
|
|
69939
|
+
if (!ref || typeof ref !== "object" || typeof ref.xAxisId !== "string" || typeof ref.yAxisId !== "string") {
|
|
69940
|
+
return refuse("control-ref-invalid", `sheet "${quote(plan.sheet)}" has an unreadable ${field}: a registration control needs string xAxisId and yAxisId grid axis ids`, plan);
|
|
69857
69941
|
}
|
|
69858
69942
|
const X = parseSpacings(grid.x), Y = parseSpacings(grid.y);
|
|
69859
69943
|
if (X.err || Y.err) {
|
|
69860
|
-
|
|
69861
|
-
|
|
69862
|
-
|
|
69863
|
-
const
|
|
69864
|
-
const
|
|
69865
|
-
|
|
69944
|
+
const bad = X.err ? "$.grid.x" : "$.grid.y";
|
|
69945
|
+
return refuse("grid-spacing-invalid", `sheet "${quote(plan.sheet)}" cannot use ${bad}: ${quote(X.err || Y.err)}`, plan);
|
|
69946
|
+
}
|
|
69947
|
+
const idsFor = (dir) => (Array.isArray(grid.axes) ? grid.axes.filter((a) => a && a.dir === dir) : []).map((a) => typeof a.id === "string" ? a.id : null);
|
|
69948
|
+
const xs = idsFor("x"), ys = idsFor("y");
|
|
69949
|
+
const uniqueIndex = (ids, wanted, count2) => {
|
|
69950
|
+
if (ids.length !== count2) return -1;
|
|
69951
|
+
const hits = ids.map((id, i) => id === wanted ? i : -1).filter((i) => i >= 0);
|
|
69866
69952
|
return hits.length === 1 ? hits[0] : -1;
|
|
69867
69953
|
};
|
|
69868
|
-
const xi = uniqueIndex(xs, ref.
|
|
69954
|
+
const xi = uniqueIndex(xs, ref.xAxisId, X.offsets.length), yi = uniqueIndex(ys, ref.yAxisId, Y.offsets.length);
|
|
69869
69955
|
if (xi < 0 || yi < 0) {
|
|
69870
69956
|
return refuse(
|
|
69871
69957
|
"control-ref-unresolved",
|
|
69872
|
-
`sheet "${plan.sheet
|
|
69958
|
+
`sheet "${quote(plan.sheet)}" ${field} names ${quote(ref.xAxisId)}/${quote(ref.yAxisId)}, which is not exactly one x and one y axis id on the model grid`,
|
|
69873
69959
|
plan
|
|
69874
69960
|
);
|
|
69875
69961
|
}
|
|
@@ -69878,27 +69964,27 @@ function gridIntersection(grid, ref, plan) {
|
|
|
69878
69964
|
function planTransform(plan) {
|
|
69879
69965
|
const kind = plan && plan.viewKind;
|
|
69880
69966
|
if (kind !== "plan") {
|
|
69881
|
-
const named = typeof kind === "string" ? kind : "unknown";
|
|
69967
|
+
const named = typeof kind === "string" && kind ? quote(kind) : "unknown";
|
|
69882
69968
|
return refuse(
|
|
69883
69969
|
"view-kind-unsupported",
|
|
69884
|
-
`sheet "${plan && plan.sheet
|
|
69970
|
+
`sheet "${quote(plan && plan.sheet)}" is a ${named} view; ${named} views are not supported by the plan transform`,
|
|
69885
69971
|
plan
|
|
69886
69972
|
);
|
|
69887
69973
|
}
|
|
69888
69974
|
if (!finite2(plan.datum_at) || !finite2(plan.control2_at) || !plan.control2_ref) {
|
|
69889
69975
|
return refuse(
|
|
69890
69976
|
"registration-incomplete",
|
|
69891
|
-
`sheet "${plan.sheet
|
|
69977
|
+
`sheet "${quote(plan.sheet)}" needs $.datum_at, $.control2_at and $.control2_ref before it can be edited`,
|
|
69892
69978
|
plan
|
|
69893
69979
|
);
|
|
69894
69980
|
}
|
|
69895
69981
|
const ptPerFt = Number(plan.pt_per_ft);
|
|
69896
69982
|
if (!(ptPerFt > 0) || !Number.isFinite(ptPerFt)) {
|
|
69897
|
-
return refuse("scale-invalid", `sheet "${plan.sheet
|
|
69983
|
+
return refuse("scale-invalid", `sheet "${quote(plan.sheet)}" has no positive $.pt_per_ft, so it has no drawing scale`, plan);
|
|
69898
69984
|
}
|
|
69899
69985
|
const registrationGrid = plan.modelGrid || plan.grid;
|
|
69900
|
-
const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan) : [0, 0];
|
|
69901
|
-
const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan);
|
|
69986
|
+
const world0 = plan.datum_ref ? gridIntersection(registrationGrid, plan.datum_ref, plan, "$.datum_ref") : [0, 0];
|
|
69987
|
+
const world1 = gridIntersection(registrationGrid, plan.control2_ref, plan, "$.control2_ref");
|
|
69902
69988
|
const scale = mmPerPx(ptPerFt);
|
|
69903
69989
|
const local1 = [
|
|
69904
69990
|
(plan.control2_at[0] - plan.datum_at[0]) * scale,
|
|
@@ -69907,15 +69993,28 @@ function planTransform(plan) {
|
|
|
69907
69993
|
const worldDelta = [world1[0] - world0[0], world1[1] - world0[1]];
|
|
69908
69994
|
const localLen = Math.hypot(local1[0], local1[1]);
|
|
69909
69995
|
const worldLen = Math.hypot(worldDelta[0], worldDelta[1]);
|
|
69910
|
-
if (!(localLen > 1e-9)
|
|
69911
|
-
return refuse("registration-degenerate", `sheet "${plan.sheet
|
|
69996
|
+
if (!(localLen > 1e-9)) {
|
|
69997
|
+
return refuse("registration-degenerate", `sheet "${quote(plan.sheet)}" has coincident registration controls: $.datum_at and $.control2_at are the same point on the sheet`, plan);
|
|
69998
|
+
}
|
|
69999
|
+
if (!(worldLen > 1e-9)) {
|
|
70000
|
+
const datum = plan.datum_ref ? "$.datum_ref and $.control2_ref resolve to the same grid intersection" : "$.control2_ref resolves to the model origin, which is where an absent $.datum_ref already puts the datum";
|
|
70001
|
+
return refuse("registration-degenerate", `sheet "${quote(plan.sheet)}" has coincident registration controls: ${datum}`, plan);
|
|
70002
|
+
}
|
|
70003
|
+
const actualSpanPt = localLen / scale;
|
|
70004
|
+
const expectedSpanPt = worldLen / scale;
|
|
70005
|
+
if (Math.abs(actualSpanPt - expectedSpanPt) > REGISTRATION_SPAN_TOLERANCE_PT) {
|
|
70006
|
+
return refuse(
|
|
70007
|
+
"registration-span-mismatch",
|
|
70008
|
+
`sheet "${quote(plan.sheet)}" registration controls span ${round2(actualSpanPt)} pt on the sheet, but ${plan.datum_ref ? "$.datum_ref" : "the model origin"} and $.control2_ref are ${round2(worldLen)} mm apart, which at ${plan.pt_per_ft} pt/ft is ${round2(expectedSpanPt)} pt \u2014 a difference of ${round2(Math.abs(actualSpanPt - expectedSpanPt))} pt, past the ${REGISTRATION_SPAN_TOLERANCE_PT} pt allowed. Either a control names the wrong grid axis or $.pt_per_ft is wrong`,
|
|
70009
|
+
plan
|
|
70010
|
+
);
|
|
69912
70011
|
}
|
|
69913
70012
|
const fitScale = worldLen / localLen;
|
|
69914
70013
|
const rotation = Math.atan2(worldDelta[1], worldDelta[0]) - Math.atan2(local1[1], local1[0]);
|
|
69915
70014
|
const c = Math.cos(rotation) * fitScale;
|
|
69916
70015
|
const s = Math.sin(rotation) * fitScale;
|
|
69917
70016
|
if (![c, s, fitScale, world0[0], world0[1]].every(Number.isFinite)) {
|
|
69918
|
-
return refuse("registration-invalid", `sheet "${plan.sheet
|
|
70017
|
+
return refuse("registration-invalid", `sheet "${quote(plan.sheet)}" has a non-finite registration transform`, plan);
|
|
69919
70018
|
}
|
|
69920
70019
|
return { datumPx: plan.datum_at, world0, mmPerPx: scale, fitScale, rotation, c, s };
|
|
69921
70020
|
}
|
|
@@ -70378,21 +70477,113 @@ function observationZ(observation, observationEnd) {
|
|
|
70378
70477
|
const z = observationEnd === 0 ? observation.evidence.observed?.fromZ?.value : observation.evidence.observed?.toZ?.value;
|
|
70379
70478
|
return z && "known" in z && Number.isFinite(z.known) ? { known: z.known } : null;
|
|
70380
70479
|
}
|
|
70381
|
-
|
|
70480
|
+
var MAX_EVIDENCE_NOTE_JSON_BYTES = 260;
|
|
70481
|
+
var MAX_NOTES_PER_REASON = 2;
|
|
70482
|
+
var quote2 = (value) => clipQuoted(value);
|
|
70483
|
+
var ENDPOINT_EVIDENCE_BLOCKING_REASONS = /* @__PURE__ */ new Set([
|
|
70484
|
+
"endpoint-elevation-missing",
|
|
70485
|
+
"view-scale-invalid",
|
|
70486
|
+
"observation-scale-mismatch",
|
|
70487
|
+
"view-unregistered",
|
|
70488
|
+
"cross-view-conflict"
|
|
70489
|
+
]);
|
|
70490
|
+
var EvidenceNotes = class _EvidenceNotes {
|
|
70491
|
+
byEndpoint = /* @__PURE__ */ new Map();
|
|
70492
|
+
static key(memberId, end, reason) {
|
|
70493
|
+
return `${memberId}\0${end}\0${reason}`;
|
|
70494
|
+
}
|
|
70495
|
+
/**
|
|
70496
|
+
* What `publish` collapses duplicates ON — the note text unless a caller supplies something coarser.
|
|
70497
|
+
*
|
|
70498
|
+
* #925's whole property is that ONE shared defect states itself once however many endpoints it
|
|
70499
|
+
* blocks, and that worked because a shared defect produced a byte-identical sentence. A note carrying
|
|
70500
|
+
* a per-endpoint MEASUREMENT breaks it: 500 endpoints on one wrong-scale sheet became 500 distinct
|
|
70501
|
+
* notes and an audit line reading "2 diagnoses; and 498 further distinct diagnoses" for one fault.
|
|
70502
|
+
* So a note whose text varies per endpoint names the part that does NOT — the reason and the
|
|
70503
|
+
* allowance — and one exemplar is published carrying its own numbers.
|
|
70504
|
+
*/
|
|
70505
|
+
dedupeKeys = /* @__PURE__ */ new Map();
|
|
70506
|
+
/**
|
|
70507
|
+
* First note wins for an endpoint+reason — it is the first failure the reader has to fix anyway —
|
|
70508
|
+
* EXCEPT when `comprehensive` says this one accounts for every offender at once. A scope-level
|
|
70509
|
+
* refusal names all the unregistered sheets in the scope, where a per-observation one names the one
|
|
70510
|
+
* sheet that observation came from; publishing the narrower of the two is true but sends the author
|
|
70511
|
+
* round the repair-and-re-audit loop once per sheet, which is what #925 is about.
|
|
70512
|
+
*/
|
|
70513
|
+
record(memberId, end, reason, note, comprehensive = false, dedupeKey) {
|
|
70514
|
+
const key2 = _EvidenceNotes.key(memberId, end, reason);
|
|
70515
|
+
if (this.byEndpoint.has(key2) && !comprehensive) return;
|
|
70516
|
+
this.dedupeKeys.set(key2, dedupeKey ?? note);
|
|
70517
|
+
let text5 = note;
|
|
70518
|
+
while (text5.length > 0 && Buffer.byteLength(JSON.stringify(text5), "utf8") > MAX_EVIDENCE_NOTE_JSON_BYTES) {
|
|
70519
|
+
text5 = clipQuoted(text5, text5.length - 1);
|
|
70520
|
+
}
|
|
70521
|
+
this.byEndpoint.set(key2, text5);
|
|
70522
|
+
}
|
|
70523
|
+
/**
|
|
70524
|
+
* Sorted so the report is deterministic whatever order plans and endpoints were visited in.
|
|
70525
|
+
*
|
|
70526
|
+
* `omitted` is the count the per-reason cap left out, and it exists so the REFUSAL can be honest:
|
|
70527
|
+
* without it the audit could only count what it received, and would say "1 further diagnosis" while
|
|
70528
|
+
* three were dropped here. A message that undercounts what is left to fix is its own version of the
|
|
70529
|
+
* bug this issue reports.
|
|
70530
|
+
*/
|
|
70531
|
+
publish(findings, retainedMemberIds) {
|
|
70532
|
+
const byReason = /* @__PURE__ */ new Map();
|
|
70533
|
+
const seen = /* @__PURE__ */ new Map();
|
|
70534
|
+
const kept = /* @__PURE__ */ new Set();
|
|
70535
|
+
for (const finding of findings) {
|
|
70536
|
+
if (retainedMemberIds.has(finding.memberId)) continue;
|
|
70537
|
+
for (const reason of finding.reasonCodes) {
|
|
70538
|
+
if (!ENDPOINT_EVIDENCE_BLOCKING_REASONS.has(reason)) continue;
|
|
70539
|
+
const endpointKey = _EvidenceNotes.key(finding.memberId, finding.end, reason);
|
|
70540
|
+
const note = this.byEndpoint.get(endpointKey);
|
|
70541
|
+
if (note === void 0) continue;
|
|
70542
|
+
const dedupeKey = this.dedupeKeys.get(endpointKey) ?? note;
|
|
70543
|
+
let all = seen.get(reason);
|
|
70544
|
+
if (!all) {
|
|
70545
|
+
all = /* @__PURE__ */ new Set();
|
|
70546
|
+
seen.set(reason, all);
|
|
70547
|
+
}
|
|
70548
|
+
all.add(dedupeKey);
|
|
70549
|
+
let notes2 = byReason.get(reason);
|
|
70550
|
+
if (!notes2) {
|
|
70551
|
+
notes2 = /* @__PURE__ */ new Set();
|
|
70552
|
+
byReason.set(reason, notes2);
|
|
70553
|
+
}
|
|
70554
|
+
if (!kept.has(dedupeKey) && notes2.size < MAX_NOTES_PER_REASON) {
|
|
70555
|
+
kept.add(dedupeKey);
|
|
70556
|
+
notes2.add(note);
|
|
70557
|
+
}
|
|
70558
|
+
}
|
|
70559
|
+
}
|
|
70560
|
+
const notes = [...byReason].flatMap(([reason, kept2]) => [...kept2].sort().map((note) => ({ reason, note }))).sort((a, b) => a.reason.localeCompare(b.reason) || a.note.localeCompare(b.note));
|
|
70561
|
+
const distinct = [...seen.values()].reduce((total, all) => total + all.size, 0);
|
|
70562
|
+
return { notes, omitted: distinct - notes.length };
|
|
70563
|
+
}
|
|
70564
|
+
};
|
|
70565
|
+
function observationPoint(model, plan, observation, observationEnd, memberId, memberEnd, diagnoses) {
|
|
70382
70566
|
const local = observation.evidence.local.wp[observationEnd];
|
|
70567
|
+
const fail3 = (reason, note) => {
|
|
70568
|
+
diagnoses.record(memberId, memberEnd, reason, note({
|
|
70569
|
+
sheet: `sheet "${quote2(plan.sheet)}"`,
|
|
70570
|
+
obs: `observation "${quote2(observation.id)}"`
|
|
70571
|
+
}));
|
|
70572
|
+
return { kind: "failure", reason };
|
|
70573
|
+
};
|
|
70383
70574
|
if (!(typeof plan.pt_per_ft === "number" && Number.isFinite(plan.pt_per_ft) && plan.pt_per_ft > 0)) {
|
|
70384
|
-
return
|
|
70575
|
+
return fail3("view-scale-invalid", ({ sheet }) => `${sheet} has no positive $.pt_per_ft, so its drawing scale cannot place an observation`);
|
|
70385
70576
|
}
|
|
70386
70577
|
if (observation.evidence.local.pt_per_ft !== plan.pt_per_ft) {
|
|
70387
|
-
return
|
|
70578
|
+
return fail3("observation-scale-mismatch", ({ sheet, obs }) => `${sheet} is registered at ${plan.pt_per_ft} pt/ft but ${obs} records ${observation.evidence.local.pt_per_ft} pt/ft`);
|
|
70388
70579
|
}
|
|
70389
70580
|
try {
|
|
70390
70581
|
if (plan.viewKind === "plan") {
|
|
70391
70582
|
const z = observationZ(observation, observationEnd);
|
|
70392
|
-
if (!z) return {
|
|
70583
|
+
if (!z) return fail3("endpoint-elevation-missing", ({ sheet, obs }) => `${sheet} is a plan view, so this endpoint's elevation must come from ${obs} observed.${observationEnd === 0 ? "fromZ" : "toZ"}, which is absent or unknown`);
|
|
70393
70584
|
const transformed = sheetPxToWorld(local, { ...plan, modelGrid: model.grid }, z);
|
|
70394
70585
|
const point3 = known(transformed);
|
|
70395
|
-
return point3 ? { kind: "point", point: point3 } :
|
|
70586
|
+
return point3 ? { kind: "point", point: point3 } : fail3("view-unregistered", ({ sheet, obs }) => `${sheet} registration maps ${obs} to a non-finite world point`);
|
|
70396
70587
|
}
|
|
70397
70588
|
if ((plan.viewKind === "elevation" || plan.viewKind === "section") && plan.sourceRegistration) {
|
|
70398
70589
|
const registration = plan.sourceRegistration;
|
|
@@ -70405,14 +70596,14 @@ function observationPoint(model, plan, observation, observationEnd) {
|
|
|
70405
70596
|
y: origin.y + registration.worldU[1] * du + registration.worldV[1] * dv,
|
|
70406
70597
|
z: { known: origin.z.known + registration.worldU[2] * du + registration.worldV[2] * dv }
|
|
70407
70598
|
};
|
|
70408
|
-
return known(point3) ? { kind: "point", point: point3 } :
|
|
70599
|
+
return known(point3) ? { kind: "point", point: point3 } : fail3("view-unregistered", ({ sheet, obs }) => `${sheet} sourceRegistration maps ${obs} to a non-finite world point`);
|
|
70409
70600
|
}
|
|
70410
70601
|
} catch (error) {
|
|
70411
|
-
if (error instanceof PlanTransformError) return
|
|
70602
|
+
if (error instanceof PlanTransformError) return fail3("view-unregistered", () => error.message);
|
|
70412
70603
|
const identity = `${plan.sheet}/${observation.id}/end-${observationEnd + 1}`;
|
|
70413
70604
|
throw new Error(`member-end evidence transform failed unexpectedly for ${identity}`, { cause: error });
|
|
70414
70605
|
}
|
|
70415
|
-
return {
|
|
70606
|
+
return fail3("view-unregistered", ({ sheet }) => plan.viewKind === "elevation" || plan.viewKind === "section" ? `${sheet} is ${plan.viewKind === "section" ? "a section" : "an elevation"} view with no sourceRegistration, so a drawing observation on it cannot be placed in the model` : `${sheet} has viewKind "${plan.viewKind}"; only a registered plan, elevation or section view can place a drawing observation`);
|
|
70416
70607
|
}
|
|
70417
70608
|
var evidenceKey = (memberId, end) => `${memberId}\0${end}`;
|
|
70418
70609
|
function finalizedEvidence(accumulator) {
|
|
@@ -70423,26 +70614,43 @@ function finalizedEvidence(accumulator) {
|
|
|
70423
70614
|
if (unique.length > SUPPORT_CENTERLINE_V1.maxObservationsPerEnd) {
|
|
70424
70615
|
throw new MemberEndAnalysisWorkLimitError("Member-end analysis exceeded the per-end drawing-observation budget.");
|
|
70425
70616
|
}
|
|
70426
|
-
const points = new Set(unique.map((origin) => JSON.stringify(origin.observedPoint)));
|
|
70427
70617
|
const strictest = tolerances.length ? Math.min(...tolerances.map((item) => item.faceToleranceMm)) : void 0;
|
|
70618
|
+
const thresholds = strictest === void 0 ? void 0 : {
|
|
70619
|
+
faceToleranceMm: strictest,
|
|
70620
|
+
targetSpanToleranceMm: strictest,
|
|
70621
|
+
clusterToleranceMm: Math.min(strictest, 25.4),
|
|
70622
|
+
ambiguityMarginMm: 2 * strictest,
|
|
70623
|
+
viewAgreementToleranceMm: strictest
|
|
70624
|
+
};
|
|
70428
70625
|
const elevation2 = scopes.find((item) => item.kind === "elevation");
|
|
70429
70626
|
const selectedScope = elevation2 ?? scopes.find((item) => item.kind === "plan");
|
|
70627
|
+
const spread2 = observedSpreadMm(unique);
|
|
70430
70628
|
return {
|
|
70431
70629
|
...unique.length ? { basis: { kind: "drawing", origins: unique, originSetHash: drawingOriginSetHash(unique) } } : {},
|
|
70432
|
-
...
|
|
70433
|
-
faceToleranceMm: strictest,
|
|
70434
|
-
targetSpanToleranceMm: strictest,
|
|
70435
|
-
clusterToleranceMm: Math.min(strictest, 25.4),
|
|
70436
|
-
ambiguityMarginMm: 2 * strictest,
|
|
70437
|
-
viewAgreementToleranceMm: strictest
|
|
70438
|
-
} } : {},
|
|
70630
|
+
...thresholds ? { thresholds } : {},
|
|
70439
70631
|
...selectedScope ? { analysisScope: selectedScope } : {},
|
|
70440
70632
|
hasLineage,
|
|
70441
70633
|
failures: sortedReasons(failures),
|
|
70442
|
-
conflict:
|
|
70634
|
+
conflict: spread2 > viewAgreementToleranceOf(thresholds) + AGREEMENT_EPS_MM,
|
|
70635
|
+
spreadMm: spread2
|
|
70443
70636
|
};
|
|
70444
70637
|
}
|
|
70445
|
-
function
|
|
70638
|
+
function observedSpreadMm(origins) {
|
|
70639
|
+
let worst = 0;
|
|
70640
|
+
for (let i = 0; i < origins.length; i += 1) {
|
|
70641
|
+
for (let j = i + 1; j < origins.length; j += 1) {
|
|
70642
|
+
const a = origins[i].observedPoint, b = origins[j].observedPoint;
|
|
70643
|
+
const gap = Math.hypot(a.x - b.x, a.y - b.y, a.z.known - b.z.known);
|
|
70644
|
+
if (gap > worst) worst = gap;
|
|
70645
|
+
}
|
|
70646
|
+
}
|
|
70647
|
+
return worst;
|
|
70648
|
+
}
|
|
70649
|
+
function viewAgreementToleranceOf(thresholds) {
|
|
70650
|
+
return thresholds ? thresholds.viewAgreementToleranceMm : 0;
|
|
70651
|
+
}
|
|
70652
|
+
var AGREEMENT_EPS_MM = 1e-7;
|
|
70653
|
+
function buildEvidenceIndex(model, plans, deadlineMs, diagnoses) {
|
|
70446
70654
|
const accumulators = /* @__PURE__ */ new Map();
|
|
70447
70655
|
for (const plan of plans) for (const observation of plan.memberObservations ?? []) {
|
|
70448
70656
|
if (Date.now() > deadlineMs) {
|
|
@@ -70470,7 +70678,7 @@ function buildEvidenceIndex(model, plans, deadlineMs) {
|
|
|
70470
70678
|
if (accumulator.contributionIds.size > SUPPORT_CENTERLINE_V1.maxObservationsPerEnd) {
|
|
70471
70679
|
throw new MemberEndAnalysisWorkLimitError("Member-end analysis exceeded the per-end drawing-observation budget.");
|
|
70472
70680
|
}
|
|
70473
|
-
const observed = observationPoint(model, plan, observation, row.observationEnd);
|
|
70681
|
+
const observed = observationPoint(model, plan, observation, row.observationEnd, row.memberId, row.memberEnd, diagnoses);
|
|
70474
70682
|
const tolerance = thresholdsForDrawingScale(observation.evidence.local.pt_per_ft);
|
|
70475
70683
|
if (observed.kind === "failure") {
|
|
70476
70684
|
accumulator.failures.add(observed.reason);
|
|
@@ -70551,7 +70759,33 @@ function fromDecision(member, end, role) {
|
|
|
70551
70759
|
invalidationId: decision.invalidationId
|
|
70552
70760
|
};
|
|
70553
70761
|
}
|
|
70554
|
-
function
|
|
70762
|
+
function unregisteredScopeNote(plans) {
|
|
70763
|
+
const offenders = plans.filter((plan) => !((plan.viewKind === "elevation" || plan.viewKind === "section") && !!plan.sourceRegistration));
|
|
70764
|
+
const remedy = offenders.every((plan) => plan.viewKind === "elevation" || plan.viewKind === "section") ? "every selected view in this elevation/section scope needs sourceRegistration before any endpoint in it can be analysed; missing on" : "only an elevation or section view carrying sourceRegistration can place geometry in this scope, and no other view kind can carry one; not usable";
|
|
70765
|
+
const named = offenders.slice(0, 3).map((plan) => `"${quote2(plan.sheet)}"`).join(", ");
|
|
70766
|
+
const more = offenders.length > 3 ? ` and ${offenders.length - 3} more` : "";
|
|
70767
|
+
return `${remedy}: ${named}${more}`;
|
|
70768
|
+
}
|
|
70769
|
+
function recordDerivedNotes(plans, analysis, evidence, subjectReasons, memberId, end, diagnoses) {
|
|
70770
|
+
if (subjectReasons.includes("view-unregistered") && analysis.kind === "elevation" && !analysis.registered) {
|
|
70771
|
+
diagnoses.record(memberId, end, "view-unregistered", unregisteredScopeNote(plans), true);
|
|
70772
|
+
}
|
|
70773
|
+
if (evidence.conflict) {
|
|
70774
|
+
const spread2 = evidence.spreadMm ?? 0;
|
|
70775
|
+
const allowed = viewAgreementToleranceOf(evidence.thresholds);
|
|
70776
|
+
diagnoses.record(
|
|
70777
|
+
memberId,
|
|
70778
|
+
end,
|
|
70779
|
+
"cross-view-conflict",
|
|
70780
|
+
`a member endpoint's drawing observations disagree \u2014 its ${(evidence.basis?.origins ?? []).length} readings span ${spread2} mm, past the ${allowed} mm two views of one point may differ by, so no single drawing-backed point exists`,
|
|
70781
|
+
false,
|
|
70782
|
+
// Collapsed on the ALLOWANCE, not on the sentence: the spread is this endpoint's own measurement
|
|
70783
|
+
// and would otherwise split one systemic defect into one note per endpoint.
|
|
70784
|
+
`cross-view-conflict\0${allowed}`
|
|
70785
|
+
);
|
|
70786
|
+
}
|
|
70787
|
+
}
|
|
70788
|
+
function freshFinding(member, end, role, scope, plans, analysis, evidence, result, diagnoses) {
|
|
70555
70789
|
const currentPoint = end === 0 ? member.from : member.to;
|
|
70556
70790
|
const geometryOnly = !evidence.basis;
|
|
70557
70791
|
const completeTargets = targetsOf(result);
|
|
@@ -70577,6 +70811,9 @@ function freshFinding(member, end, role, scope, evidence, result) {
|
|
|
70577
70811
|
...evidence.basis ? { basis: evidence.basis } : {}
|
|
70578
70812
|
};
|
|
70579
70813
|
const subjectReasons = result.kind === "not-checkable" ? result.reasons.map((reason) => reasonMap[reason]) : [];
|
|
70814
|
+
if (evidence.conflict || subjectReasons.includes("view-unregistered")) {
|
|
70815
|
+
recordDerivedNotes(plans, analysis, evidence, subjectReasons, member.id, end, diagnoses);
|
|
70816
|
+
}
|
|
70580
70817
|
if (evidence.failures.length) return {
|
|
70581
70818
|
...base,
|
|
70582
70819
|
classification: "not-checkable",
|
|
@@ -70647,7 +70884,7 @@ function counts(findings) {
|
|
|
70647
70884
|
notCheckable: findings.filter((item) => item.classification === "not-checkable").length
|
|
70648
70885
|
};
|
|
70649
70886
|
}
|
|
70650
|
-
function analyzeSteelMemberEnds(model, scope) {
|
|
70887
|
+
function analyzeSteelMemberEnds(model, scope, retainedMemberIds = /* @__PURE__ */ new Set()) {
|
|
70651
70888
|
const normalizedScope2 = scope.kind === "conversion" ? { kind: "conversion", viewIds: [...new Set(scope.viewIds)].sort((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b))) } : scope;
|
|
70652
70889
|
if (normalizedScope2.kind === "conversion" && normalizedScope2.viewIds.length === 0) {
|
|
70653
70890
|
throw new TypeError("conversion endpoint analysis requires at least one view id");
|
|
@@ -70661,7 +70898,8 @@ function analyzeSteelMemberEnds(model, scope) {
|
|
|
70661
70898
|
const targetMembers = model.members.map(targetMember).filter((item) => !!item);
|
|
70662
70899
|
const targetMap = new Map(targetMembers.map((member) => [member.id, member]));
|
|
70663
70900
|
const deadlineMs = Date.now() + SUPPORT_CENTERLINE_V1.watchdogMs;
|
|
70664
|
-
const
|
|
70901
|
+
const diagnoses = new EvidenceNotes();
|
|
70902
|
+
const evidenceIndex = buildEvidenceIndex(model, plans, deadlineMs, diagnoses);
|
|
70665
70903
|
const spatialIndex = new MemberEndSpatialIndex(orderedCandidateRecords(targetMembers), deadlineMs);
|
|
70666
70904
|
const findings = [];
|
|
70667
70905
|
let subjectEnds = 0;
|
|
@@ -70690,10 +70928,10 @@ function analyzeSteelMemberEnds(model, scope) {
|
|
|
70690
70928
|
continue;
|
|
70691
70929
|
}
|
|
70692
70930
|
if (!analyzed) {
|
|
70693
|
-
const finding2 = freshFinding(member, end, role.finding, normalizedScope2, evidence, {
|
|
70931
|
+
const finding2 = freshFinding(member, end, role.finding, normalizedScope2, plans, evidence.analysisScope ?? aScope, evidence, {
|
|
70694
70932
|
kind: "not-checkable",
|
|
70695
70933
|
reasons: Object.freeze(["subject-geometry-invalid"])
|
|
70696
|
-
});
|
|
70934
|
+
}, diagnoses);
|
|
70697
70935
|
if (finding2) findings.push(finding2);
|
|
70698
70936
|
continue;
|
|
70699
70937
|
}
|
|
@@ -70709,20 +70947,52 @@ function analyzeSteelMemberEnds(model, scope) {
|
|
|
70709
70947
|
targets: targetMap,
|
|
70710
70948
|
consumeExactGeometryTest
|
|
70711
70949
|
});
|
|
70712
|
-
const finding = freshFinding(member, end, role.finding, normalizedScope2, evidence, result);
|
|
70950
|
+
const finding = freshFinding(member, end, role.finding, normalizedScope2, plans, evidence.analysisScope ?? aScope, evidence, result, diagnoses);
|
|
70713
70951
|
if (finding) findings.push(finding);
|
|
70714
70952
|
}
|
|
70715
70953
|
}
|
|
70716
70954
|
findings.sort((a, b) => Buffer.compare(Buffer.from(findingSortKey(a)), Buffer.from(findingSortKey(b))));
|
|
70955
|
+
const { notes: evidenceNotes, omitted } = diagnoses.publish(findings, retainedMemberIds);
|
|
70717
70956
|
return {
|
|
70718
70957
|
version: 1,
|
|
70719
70958
|
policy: SUPPORT_CENTERLINE_POLICY,
|
|
70720
70959
|
contractHash: asHash(model),
|
|
70721
70960
|
scope: normalizedScope2,
|
|
70722
70961
|
findings,
|
|
70723
|
-
counts: counts(findings)
|
|
70962
|
+
counts: counts(findings),
|
|
70963
|
+
...evidenceNotes.length ? { evidenceNotes } : {},
|
|
70964
|
+
...omitted > 0 ? { evidenceNotesOmitted: omitted } : {}
|
|
70724
70965
|
};
|
|
70725
70966
|
}
|
|
70967
|
+
var coords = (point3) => `(${point3.x}, ${point3.y}, ${point3.z.known})`;
|
|
70968
|
+
var NAMED_MISMATCHES = 3;
|
|
70969
|
+
var LiteralEvidenceMismatches = class {
|
|
70970
|
+
count = 0;
|
|
70971
|
+
worst = [];
|
|
70972
|
+
record(row) {
|
|
70973
|
+
this.count += 1;
|
|
70974
|
+
const at = this.worst.findIndex((seen) => row.gapMm > seen.gapMm);
|
|
70975
|
+
if (at >= 0) this.worst.splice(at, 0, row);
|
|
70976
|
+
else if (this.worst.length < NAMED_MISMATCHES) this.worst.push(row);
|
|
70977
|
+
if (this.worst.length > NAMED_MISMATCHES) this.worst.pop();
|
|
70978
|
+
}
|
|
70979
|
+
/**
|
|
70980
|
+
* One refusal for ALL mismatched ends, carrying the numbers a reader needs to act.
|
|
70981
|
+
*
|
|
70982
|
+
* The old refusal named a single member end and nothing else: no expected value, no submitted
|
|
70983
|
+
* value, no gap and no count. A reader could not tell one bad endpoint from all 430, could not see
|
|
70984
|
+
* that the true cause was three layers upstream in their grid, and spent days on it (#934). Count
|
|
70985
|
+
* first, then the worst offenders with both points and the distance between them.
|
|
70986
|
+
*/
|
|
70987
|
+
error() {
|
|
70988
|
+
const named = this.worst.map((row) => `member "${quote2(row.memberId)}" end ${row.end + 1} ` + (row.submitted ? `is ${row.gapMm} mm away \u2014 submitted ${coords(row.submitted)}, drawing ${coords(row.expected)}` : `has no finite point with a known elevation \u2014 drawing ${coords(row.expected)}`));
|
|
70989
|
+
const rest = this.count - named.length;
|
|
70990
|
+
return new ContractPolicyError(
|
|
70991
|
+
`${this.count} reader member ${this.count === 1 ? "end does not match its" : "ends do not match their"} immutable drawing observation by more than ${SUPPORT_CENTERLINE_V1.literalEvidenceToleranceMm} mm: ${named.join("; ")}${rest > 0 ? `; and ${rest} more` : ""}`,
|
|
70992
|
+
"member-end-literal-evidence-mismatch"
|
|
70993
|
+
);
|
|
70994
|
+
}
|
|
70995
|
+
};
|
|
70726
70996
|
function normalizeSteelMemberEndsForRead(literal, existingMemberIds = /* @__PURE__ */ new Set(), currentModel) {
|
|
70727
70997
|
const sanitized = cloneModel(literal);
|
|
70728
70998
|
const currentMembers = currentModel ? new Map(currentModel.members.map((member) => [member.id, member])) : null;
|
|
@@ -70749,31 +71019,51 @@ function normalizeSteelMemberEndsForRead(literal, existingMemberIds = /* @__PURE
|
|
|
70749
71019
|
const literalContractHash = asHash(literal);
|
|
70750
71020
|
const retainedMemberIdsHash = hashRetainedMemberIds(existingMemberIds);
|
|
70751
71021
|
if (viewIds.length === 0) {
|
|
70752
|
-
const report2 = analyzeSteelMemberEnds(sanitized, { kind: "model-3d" });
|
|
71022
|
+
const report2 = analyzeSteelMemberEnds(sanitized, { kind: "model-3d" }, existingMemberIds);
|
|
70753
71023
|
return { literalContractHash, finalContractHash: asHash(sanitized), model: sanitized, report: report2, retainedMemberIdsHash };
|
|
70754
71024
|
}
|
|
70755
71025
|
const conversionScope = { kind: "conversion", viewIds };
|
|
70756
71026
|
const evidenceIndex = buildEvidenceIndex(
|
|
70757
71027
|
sanitized,
|
|
70758
71028
|
selectedPlans(sanitized, conversionScope),
|
|
70759
|
-
Date.now() + SUPPORT_CENTERLINE_V1.watchdogMs
|
|
71029
|
+
Date.now() + SUPPORT_CENTERLINE_V1.watchdogMs,
|
|
71030
|
+
// Discarded on purpose: this index only decides which literal endpoints match their immutable
|
|
71031
|
+
// observation. Nothing is published from here — `analyzeSteelMemberEnds` below builds the report.
|
|
71032
|
+
new EvidenceNotes()
|
|
70760
71033
|
);
|
|
71034
|
+
const evidenceMismatches = new LiteralEvidenceMismatches();
|
|
70761
71035
|
for (const member of sanitized.members) {
|
|
70762
71036
|
if (existingMemberIds.has(member.id) || !roleOf(member)) continue;
|
|
70763
71037
|
for (const end of [0, 1]) {
|
|
70764
71038
|
const evidence = evidenceForEnd(evidenceIndex, member.id, end);
|
|
70765
71039
|
if (!evidence.basis || evidence.conflict || evidence.failures.length) continue;
|
|
70766
|
-
const expected = evidence.basis.origins[0]?.observedPoint;
|
|
70767
71040
|
const literalPoint = known(end === 0 ? member.from : member.to);
|
|
70768
|
-
|
|
70769
|
-
|
|
70770
|
-
|
|
70771
|
-
|
|
70772
|
-
|
|
71041
|
+
const gapTo = (origin) => literalPoint ? Math.hypot(
|
|
71042
|
+
literalPoint.x - origin.observedPoint.x,
|
|
71043
|
+
literalPoint.y - origin.observedPoint.y,
|
|
71044
|
+
literalPoint.z.known - origin.observedPoint.z.known
|
|
71045
|
+
) : Number.POSITIVE_INFINITY;
|
|
71046
|
+
let matched = evidence.basis.origins[0];
|
|
71047
|
+
let gapMm = matched ? gapTo(matched) : Number.POSITIVE_INFINITY;
|
|
71048
|
+
for (const origin of evidence.basis.origins) {
|
|
71049
|
+
const candidate = gapTo(origin);
|
|
71050
|
+
if (candidate < gapMm) {
|
|
71051
|
+
matched = origin;
|
|
71052
|
+
gapMm = candidate;
|
|
71053
|
+
}
|
|
71054
|
+
}
|
|
71055
|
+
const expected = matched?.observedPoint;
|
|
71056
|
+
if (!expected) continue;
|
|
71057
|
+
if (!(gapMm <= SUPPORT_CENTERLINE_V1.literalEvidenceToleranceMm)) {
|
|
71058
|
+
evidenceMismatches.record({ memberId: member.id, end, expected, submitted: literalPoint, gapMm });
|
|
71059
|
+
continue;
|
|
70773
71060
|
}
|
|
71061
|
+
if (end === 0) member.from = expected;
|
|
71062
|
+
else member.to = expected;
|
|
70774
71063
|
}
|
|
70775
71064
|
}
|
|
70776
|
-
|
|
71065
|
+
if (evidenceMismatches.count) throw evidenceMismatches.error();
|
|
71066
|
+
const conversion = analyzeSteelMemberEnds(sanitized, conversionScope, existingMemberIds);
|
|
70777
71067
|
const model = cloneModel(sanitized);
|
|
70778
71068
|
for (const finding of conversion.findings) {
|
|
70779
71069
|
if (finding.classification !== "aligned-auto" || existingMemberIds.has(finding.memberId)) continue;
|
|
@@ -70810,7 +71100,7 @@ function normalizeSteelMemberEndsForRead(literal, existingMemberIds = /* @__PURE
|
|
|
70810
71100
|
)
|
|
70811
71101
|
};
|
|
70812
71102
|
}
|
|
70813
|
-
let report = analyzeSteelMemberEnds(model, { kind: "conversion", viewIds });
|
|
71103
|
+
let report = analyzeSteelMemberEnds(model, { kind: "conversion", viewIds }, existingMemberIds);
|
|
70814
71104
|
if (existingMemberIds.size) {
|
|
70815
71105
|
const findings = report.findings.map((finding) => {
|
|
70816
71106
|
if (finding.classification !== "aligned-auto" || !existingMemberIds.has(finding.memberId)) return finding;
|
|
@@ -70850,7 +71140,9 @@ function reportTrustedFinalSteelMemberEnds(model, retainedMemberIds) {
|
|
|
70850
71140
|
const freshEvidence = viewIds.length ? buildEvidenceIndex(
|
|
70851
71141
|
model,
|
|
70852
71142
|
selectedPlans(model, { kind: "conversion", viewIds }),
|
|
70853
|
-
Date.now() + SUPPORT_CENTERLINE_V1.watchdogMs
|
|
71143
|
+
Date.now() + SUPPORT_CENTERLINE_V1.watchdogMs,
|
|
71144
|
+
// Discarded on purpose, as above: this index feeds the replay comparison, not the report.
|
|
71145
|
+
new EvidenceNotes()
|
|
70854
71146
|
) : /* @__PURE__ */ new Map();
|
|
70855
71147
|
const literalized = cloneModel(model);
|
|
70856
71148
|
const literalMembers = new Map(literalized.members.map((member) => [member.id, member]));
|
|
@@ -70889,7 +71181,8 @@ function reportTrustedFinalSteelMemberEnds(model, retainedMemberIds) {
|
|
|
70889
71181
|
}
|
|
70890
71182
|
const replay = analyzeSteelMemberEnds(
|
|
70891
71183
|
literalized,
|
|
70892
|
-
viewIds.length ? { kind: "conversion", viewIds } : { kind: "model-3d" }
|
|
71184
|
+
viewIds.length ? { kind: "conversion", viewIds } : { kind: "model-3d" },
|
|
71185
|
+
retainedMemberIds
|
|
70893
71186
|
);
|
|
70894
71187
|
const replayFindings = new Map(replay.findings.map((finding) => [evidenceKey(finding.memberId, finding.end), finding]));
|
|
70895
71188
|
for (const [key2, { member, end, observedPoint, decision }] of replaySubjects) {
|
|
@@ -70904,7 +71197,7 @@ function reportTrustedFinalSteelMemberEnds(model, retainedMemberIds) {
|
|
|
70904
71197
|
);
|
|
70905
71198
|
}
|
|
70906
71199
|
}
|
|
70907
|
-
let report = analyzeSteelMemberEnds(model, viewIds.length ? { kind: "conversion", viewIds } : { kind: "model-3d" });
|
|
71200
|
+
let report = analyzeSteelMemberEnds(model, viewIds.length ? { kind: "conversion", viewIds } : { kind: "model-3d" }, retainedMemberIds);
|
|
70908
71201
|
if (retainedMemberIds.size) {
|
|
70909
71202
|
const findings = report.findings.map((finding) => {
|
|
70910
71203
|
if (finding.classification !== "aligned-auto" || !retainedMemberIds.has(finding.memberId)) return finding;
|
|
@@ -70951,6 +71244,7 @@ var MAX_FACET_EXCLUSIONS = 5e3;
|
|
|
70951
71244
|
var MAX_FACET_VALUE_CHARS = 200;
|
|
70952
71245
|
var MAX_DISPOSITION_GROUPS = 5e3;
|
|
70953
71246
|
var MAX_JOINTS = 1e4;
|
|
71247
|
+
var MAX_REPORTED_NOTES_PER_REASON = 1;
|
|
70954
71248
|
var MAX_MEMBERS = 1e4;
|
|
70955
71249
|
var MAX_TEXT = 1e3;
|
|
70956
71250
|
var SHA = /^[0-9a-f]{64}$/;
|
|
@@ -71425,18 +71719,20 @@ function evaluateSteelRead(context) {
|
|
|
71425
71719
|
const observationAudit = activeObservationElements(candidate, retainedMemberIds);
|
|
71426
71720
|
const observations2 = observationAudit.elements;
|
|
71427
71721
|
if (validation.valid) {
|
|
71428
|
-
const evidenceReasons =
|
|
71429
|
-
|
|
71430
|
-
|
|
71431
|
-
|
|
71432
|
-
|
|
71433
|
-
|
|
71434
|
-
]);
|
|
71435
|
-
const
|
|
71722
|
+
const evidenceReasons = ENDPOINT_EVIDENCE_BLOCKING_REASONS;
|
|
71723
|
+
const blockingFindings = context.normalization.report.findings.filter((finding) => !retainedMemberIds.has(finding.memberId)).filter((finding) => finding.reasonCodes.some((reason) => evidenceReasons.has(reason)));
|
|
71724
|
+
const endpointEvidence = blockingFindings.flatMap((finding) => finding.reasonCodes.filter((reason) => evidenceReasons.has(reason)).map((reason) => `${finding.memberId}:${finding.end}:${reason}`));
|
|
71725
|
+
const blockingReasons = new Set(blockingFindings.flatMap((finding) => finding.reasonCodes.filter((reason) => evidenceReasons.has(reason))));
|
|
71726
|
+
const relevant = (context.normalization.report.evidenceNotes ?? []).filter((row) => blockingReasons.has(row.reason));
|
|
71727
|
+
const byReason = /* @__PURE__ */ new Map();
|
|
71728
|
+
for (const row of relevant) byReason.set(row.reason, [...byReason.get(row.reason) ?? [], row.note]);
|
|
71729
|
+
const shown = [...byReason].sort(([a], [b]) => a.localeCompare(b)).flatMap(([, notes]) => [...new Set(notes)].sort().slice(0, MAX_REPORTED_NOTES_PER_REASON));
|
|
71730
|
+
const rest = new Set(relevant.map((row) => row.note)).size - shown.length + (context.normalization.report.evidenceNotesOmitted ?? 0);
|
|
71731
|
+
const diagnosis = shown.length ? `: ${shown.join("; ")}${rest > 0 ? `; and ${rest} further distinct ${rest === 1 ? "diagnosis" : "diagnoses"}` : ""}` : "";
|
|
71436
71732
|
add(
|
|
71437
71733
|
"endpoint-evidence",
|
|
71438
71734
|
endpointEvidence.length ? "block" : "pass",
|
|
71439
|
-
endpointEvidence.length ? `${endpointEvidence.length} new-member endpoint
|
|
71735
|
+
endpointEvidence.length ? `${endpointEvidence.length} new-member endpoint-evidence ${endpointEvidence.length === 1 ? "diagnostic requires" : "diagnostics require"} correction${diagnosis}` : "new-member endpoint drawing evidence is complete and consistent",
|
|
71440
71736
|
endpointEvidence
|
|
71441
71737
|
);
|
|
71442
71738
|
} else add("endpoint-evidence", "block", "endpoint evidence cannot be evaluated until the v2 contract is valid");
|
|
@@ -77294,14 +77590,14 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
77294
77590
|
});
|
|
77295
77591
|
}
|
|
77296
77592
|
const dims = new Set(MODE_ORDER);
|
|
77297
|
-
const
|
|
77593
|
+
const wellFormed2 = submitted.every((row) => {
|
|
77298
77594
|
if (!row || typeof row !== "object" || Array.isArray(row)) return false;
|
|
77299
77595
|
const entry2 = row;
|
|
77300
77596
|
if (Object.keys(entry2).length !== 2 || typeof entry2.dim !== "string" || !dims.has(entry2.dim)) return false;
|
|
77301
77597
|
if (entry2.dim === "thickness") return typeof entry2.value === "number" && Number.isFinite(entry2.value);
|
|
77302
77598
|
return typeof entry2.value === "string" && entry2.value.length > 0 && entry2.value.length <= MAX_SIGNOFF_STRING_VALUE;
|
|
77303
77599
|
});
|
|
77304
|
-
if (!
|
|
77600
|
+
if (!wellFormed2 || typeof bodyObj.mode !== "string" || typeof bodyObj.manifestHash !== "string" || typeof bodyObj.controlsHash !== "string") {
|
|
77305
77601
|
return reply.status(400).send({
|
|
77306
77602
|
ok: false,
|
|
77307
77603
|
code: "steel-exclusion-signoff-invalid",
|
|
@@ -78663,7 +78959,7 @@ function registerConnectionRoutes(app) {
|
|
|
78663
78959
|
}
|
|
78664
78960
|
|
|
78665
78961
|
// steel-intersection-ref.ts
|
|
78666
|
-
var
|
|
78962
|
+
var axisId = (v) => {
|
|
78667
78963
|
if (typeof v !== "string") return null;
|
|
78668
78964
|
const t = v.trim();
|
|
78669
78965
|
return t.length > 0 ? t : null;
|
|
@@ -78672,19 +78968,19 @@ var isObj7 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
|
78672
78968
|
function intersectionRef(v) {
|
|
78673
78969
|
if (v === void 0 || v === null) return { state: "absent" };
|
|
78674
78970
|
if (isObj7(v)) {
|
|
78675
|
-
const unknown = Object.keys(v).filter((k) => k !== "
|
|
78971
|
+
const unknown = Object.keys(v).filter((k) => k !== "xAxisId" && k !== "yAxisId");
|
|
78676
78972
|
if (unknown.length) {
|
|
78677
|
-
return { state: "invalid", why: `an intersection has only \`
|
|
78973
|
+
return { state: "invalid", why: `an intersection has only \`xAxisId\` and \`yAxisId\` \u2014 ${unknown.map((k) => `\`${k}\``).join(", ")} ${unknown.length > 1 ? "are" : "is"} not recognised${unknown.some((k) => k === "axis_x" || k === "axis_y") ? "; registration names grid axis IDS now, never labels" : ""}` };
|
|
78678
78974
|
}
|
|
78679
|
-
const x =
|
|
78975
|
+
const x = axisId(v.xAxisId), y = axisId(v.yAxisId);
|
|
78680
78976
|
if (x && y) return { state: "valid", x, y };
|
|
78681
|
-
const missing = [!x ? "
|
|
78682
|
-
return { state: "invalid", why: `${missing} must each be a non-blank
|
|
78977
|
+
const missing = [!x ? "xAxisId" : null, !y ? "yAxisId" : null].filter(Boolean).join(" and ");
|
|
78978
|
+
return { state: "invalid", why: `${missing} must each be a non-blank grid axis id` };
|
|
78683
78979
|
}
|
|
78684
|
-
return { state: "invalid", why: `a ${Array.isArray(v) ? "list" : typeof v} names no grid intersection; expected {
|
|
78980
|
+
return { state: "invalid", why: `a ${Array.isArray(v) ? "list" : typeof v} names no grid intersection; expected { xAxisId, yAxisId }` };
|
|
78685
78981
|
}
|
|
78686
78982
|
function canonicalRef(r) {
|
|
78687
|
-
return {
|
|
78983
|
+
return { xAxisId: r.x, yAxisId: r.y };
|
|
78688
78984
|
}
|
|
78689
78985
|
|
|
78690
78986
|
// steel-prepass-route.ts
|
|
@@ -78760,6 +79056,13 @@ function registerSteelPrepassRoute(app, deps) {
|
|
|
78760
79056
|
const sheet = String(plan.sheet ?? "");
|
|
78761
79057
|
const patch2 = sheets[sheet];
|
|
78762
79058
|
if (!isObj8(patch2)) continue;
|
|
79059
|
+
if (plan.viewKind !== "plan" && PLAN_KEYS.some((key2) => patch2[key2] !== void 0)) {
|
|
79060
|
+
return reply.status(400).send({
|
|
79061
|
+
ok: false,
|
|
79062
|
+
code: "prepass-plan-controls-on-non-plan-view",
|
|
79063
|
+
error: `sheet "${sheet}" is a ${String(plan.viewKind ?? "unclassified")} view; ${PLAN_KEYS.filter((key2) => patch2[key2] !== void 0).join(", ")} register a plan and do nothing here \u2014 a non-plan view registers through sourceRegistration`
|
|
79064
|
+
});
|
|
79065
|
+
}
|
|
78763
79066
|
for (const key2 of PLAN_KEYS) {
|
|
78764
79067
|
if (patch2[key2] === void 0) continue;
|
|
78765
79068
|
if (key2 === "datum_ref" || key2 === "control2_ref") {
|
|
@@ -78779,7 +79082,7 @@ function registerSteelPrepassRoute(app, deps) {
|
|
|
78779
79082
|
return reply.status(400).send({
|
|
78780
79083
|
ok: false,
|
|
78781
79084
|
code: "prepass-ref-unreadable",
|
|
78782
|
-
error: `Grid references must use {
|
|
79085
|
+
error: `Grid references must use { xAxisId, yAxisId }: ${refErrors.join(", ")}. Nothing was written.`
|
|
78783
79086
|
});
|
|
78784
79087
|
}
|
|
78785
79088
|
if (request) {
|
|
@@ -84718,8 +85021,8 @@ function bomTable(bom, selection = DEFAULT_BOM_COLUMNS) {
|
|
|
84718
85021
|
cells[m.label] = priced.reduce((t, r) => t + (Number(r.cells[m.label]) || 0), 0);
|
|
84719
85022
|
}
|
|
84720
85023
|
if (columns.some((c) => c.id === "length")) {
|
|
84721
|
-
const
|
|
84722
|
-
cells[
|
|
85024
|
+
const label = BOM_COLUMNS.find((c) => c.id === "length").label;
|
|
85025
|
+
cells[label] = round1(Number(cells[label]) || 0);
|
|
84723
85026
|
}
|
|
84724
85027
|
rows2.push({ kind: "total", cells });
|
|
84725
85028
|
}
|
|
@@ -84727,7 +85030,7 @@ function bomTable(bom, selection = DEFAULT_BOM_COLUMNS) {
|
|
|
84727
85030
|
if (!rfi.length) return { columns: labels, rows: rows2 };
|
|
84728
85031
|
const profileLabel = BOM_COLUMNS.find((c) => c.id === "profile").label;
|
|
84729
85032
|
const qtyLabel = BOM_COLUMNS.find((c) => c.id === "qty").label;
|
|
84730
|
-
const locators = [["profile", profileLabel], ["qty", qtyLabel]].filter(([id]) => !selection.includes(id)).map(([,
|
|
85033
|
+
const locators = [["profile", profileLabel], ["qty", qtyLabel]].filter(([id]) => !selection.includes(id)).map(([, label]) => label);
|
|
84731
85034
|
const unionColumns = [...locators, ...RFI_COLUMNS];
|
|
84732
85035
|
const blanks = Object.fromEntries(unionColumns.map((c) => [c, ""]));
|
|
84733
85036
|
return {
|
|
@@ -86611,9 +86914,9 @@ function assertSameVolume(a, b) {
|
|
|
86611
86914
|
}
|
|
86612
86915
|
if (aDev !== bDev) throw new FilePublicationError("publication paths are not on the same volume", "different-volume", [a, b]);
|
|
86613
86916
|
}
|
|
86614
|
-
function uniqueArtifact(dir,
|
|
86917
|
+
function uniqueArtifact(dir, label, livePath) {
|
|
86615
86918
|
(0, import_node_fs56.mkdirSync)(dir, { recursive: true });
|
|
86616
|
-
return (0, import_node_path49.join)(dir, `.floless-${
|
|
86919
|
+
return (0, import_node_path49.join)(dir, `.floless-${label}-${(0, import_node_crypto39.randomUUID)()}-${(0, import_node_path49.basename)(livePath)}`);
|
|
86617
86920
|
}
|
|
86618
86921
|
function publishFileExclusive(input) {
|
|
86619
86922
|
const { livePath, stagedPath, expectedLive, artifactDir } = input;
|
|
@@ -86699,7 +87002,7 @@ function activeCodexJournal(appId) {
|
|
|
86699
87002
|
}
|
|
86700
87003
|
return null;
|
|
86701
87004
|
}
|
|
86702
|
-
function withAppSourceLock(appId,
|
|
87005
|
+
function withAppSourceLock(appId, label, fn, options = {}) {
|
|
86703
87006
|
return withLifecycleLock("app", appId, () => {
|
|
86704
87007
|
const active2 = activeApprovalTransaction(appId);
|
|
86705
87008
|
if (active2 && active2 !== options.approvalTransactionId) throw new AppSourcePublicationBusyError();
|
|
@@ -86708,7 +87011,7 @@ function withAppSourceLock(appId, label2, fn, options = {}) {
|
|
|
86708
87011
|
throw new AppSourcePublicationBusyError();
|
|
86709
87012
|
}
|
|
86710
87013
|
return fn();
|
|
86711
|
-
}, { label
|
|
87014
|
+
}, { label });
|
|
86712
87015
|
}
|
|
86713
87016
|
|
|
86714
87017
|
// app-publication-manifest.ts
|
|
@@ -89489,7 +89792,7 @@ async function hostReadiness(host, deps = DEFAULT_DEPS3, targetPid) {
|
|
|
89489
89792
|
return withAwareShared(() => withSidecarRead(() => hostReadinessUnlocked(host, deps, targetPid)));
|
|
89490
89793
|
}
|
|
89491
89794
|
async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
89492
|
-
const
|
|
89795
|
+
const label = HOST_LABELS[host];
|
|
89493
89796
|
const floor = HOST_BAKE_AWARE_FLOORS[host];
|
|
89494
89797
|
const awareVersion = deps.npmVersion();
|
|
89495
89798
|
const awareCurrent = !!awareVersion && compareDotted(awareVersion, floor) >= 0;
|
|
@@ -89515,8 +89818,8 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89515
89818
|
...base,
|
|
89516
89819
|
ok: false,
|
|
89517
89820
|
state: "bridge-missing",
|
|
89518
|
-
message: `Couldn\u2019t send \u2014 the connection to ${
|
|
89519
|
-
recovery: { action: "install-bridge", label: `Install ${
|
|
89821
|
+
message: `Couldn\u2019t send \u2014 the connection to ${label} isn\u2019t installed yet. Install it, then try again.`,
|
|
89822
|
+
recovery: { action: "install-bridge", label: `Install ${label} bridge` }
|
|
89520
89823
|
};
|
|
89521
89824
|
}
|
|
89522
89825
|
if (!bridgeCurrent) {
|
|
@@ -89524,8 +89827,8 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89524
89827
|
...base,
|
|
89525
89828
|
ok: false,
|
|
89526
89829
|
state: "bridge-update-required",
|
|
89527
|
-
message: `Couldn\u2019t send \u2014 the connection to ${
|
|
89528
|
-
recovery: { action: "install-bridge", label: `Update ${
|
|
89830
|
+
message: `Couldn\u2019t send \u2014 the connection to ${label} is stale (${bridge.version || "unversioned"}, needs ${awareVersion}). Update it, then try again.`,
|
|
89831
|
+
recovery: { action: "install-bridge", label: `Update ${label} bridge` }
|
|
89529
89832
|
};
|
|
89530
89833
|
}
|
|
89531
89834
|
let probe;
|
|
@@ -89536,7 +89839,7 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89536
89839
|
...base,
|
|
89537
89840
|
ok: false,
|
|
89538
89841
|
state: "error",
|
|
89539
|
-
message: error instanceof Error ? error.message : `Couldn\u2019t check whether ${
|
|
89842
|
+
message: error instanceof Error ? error.message : `Couldn\u2019t check whether ${label} is ready.`,
|
|
89540
89843
|
recovery: { action: "retry", label: "Check again" }
|
|
89541
89844
|
};
|
|
89542
89845
|
}
|
|
@@ -89546,7 +89849,7 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89546
89849
|
...base,
|
|
89547
89850
|
ok: false,
|
|
89548
89851
|
state: "error",
|
|
89549
|
-
message: `Couldn\u2019t send \u2014 the ${
|
|
89852
|
+
message: `Couldn\u2019t send \u2014 the ${label} connection isn\u2019t responding${probe.error ? ` (${probe.error.slice(0, 120)})` : ""}. Try again, and reinstall the ${label} bridge if it keeps happening.`,
|
|
89550
89853
|
recovery: { action: "retry", label: "Check again" }
|
|
89551
89854
|
};
|
|
89552
89855
|
}
|
|
@@ -89555,8 +89858,8 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89555
89858
|
...base,
|
|
89556
89859
|
ok: false,
|
|
89557
89860
|
state: "host-closed",
|
|
89558
|
-
message: probe.instances.length ? `Couldn\u2019t send \u2014 that ${
|
|
89559
|
-
recovery: probe.instances.length ? { action: "retry", label: "Check again" } : { action: "open-host", label: `Open ${
|
|
89861
|
+
message: probe.instances.length ? `Couldn\u2019t send \u2014 that ${label} window isn\u2019t open any more. Try the drag again.` : `Couldn\u2019t send \u2014 ${label} isn\u2019t open. Start it and try again.`,
|
|
89862
|
+
recovery: probe.instances.length ? { action: "retry", label: "Check again" } : { action: "open-host", label: `Open ${label}` }
|
|
89560
89863
|
};
|
|
89561
89864
|
}
|
|
89562
89865
|
if (!probe.ok || !session) {
|
|
@@ -89570,7 +89873,7 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89570
89873
|
...base,
|
|
89571
89874
|
ok: false,
|
|
89572
89875
|
state: "error",
|
|
89573
|
-
message: `Couldn\u2019t send \u2014 ${
|
|
89876
|
+
message: `Couldn\u2019t send \u2014 ${label} is running, but FloLess can\u2019t reach it. Restart ${label} so its FloLess connection reloads, then try again.`,
|
|
89574
89877
|
recovery: { action: "retry", label: "Check again" }
|
|
89575
89878
|
};
|
|
89576
89879
|
}
|
|
@@ -89578,8 +89881,8 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89578
89881
|
...base,
|
|
89579
89882
|
ok: false,
|
|
89580
89883
|
state: "host-closed",
|
|
89581
|
-
message: `Couldn\u2019t send \u2014 ${
|
|
89582
|
-
recovery: { action: "open-host", label: `Open ${
|
|
89884
|
+
message: `Couldn\u2019t send \u2014 ${label} isn\u2019t open. Start it and try again.`,
|
|
89885
|
+
recovery: { action: "open-host", label: `Open ${label}` }
|
|
89583
89886
|
};
|
|
89584
89887
|
}
|
|
89585
89888
|
const found = { open: true, version: session.version, pid: session.pid, rhinoId: session.rhinoId ?? null };
|
|
@@ -89588,7 +89891,7 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89588
89891
|
...base,
|
|
89589
89892
|
ok: false,
|
|
89590
89893
|
state: "ambiguous-session",
|
|
89591
|
-
message: `Couldn\u2019t send \u2014 ${probe.instances.length} ${
|
|
89894
|
+
message: `Couldn\u2019t send \u2014 ${probe.instances.length} ${label} windows are open and there\u2019s no way to tell which model you meant. Close all but one, or drag the members onto the window you want.`,
|
|
89592
89895
|
recovery: { action: "retry", label: "Check again" }
|
|
89593
89896
|
};
|
|
89594
89897
|
}
|
|
@@ -89648,7 +89951,7 @@ async function hostReadinessUnlocked(host, deps, targetPid) {
|
|
|
89648
89951
|
bakeEnv: probe.env,
|
|
89649
89952
|
ok: true,
|
|
89650
89953
|
state: "ready",
|
|
89651
|
-
message: `Ready to send to ${
|
|
89954
|
+
message: `Ready to send to ${label}${session.version ? ` ${session.version}` : ""}.`,
|
|
89652
89955
|
recovery: null
|
|
89653
89956
|
};
|
|
89654
89957
|
}
|
|
@@ -92617,14 +92920,30 @@ function createMaintenanceMarkerStore(markerPath2, options = {}) {
|
|
|
92617
92920
|
});
|
|
92618
92921
|
}
|
|
92619
92922
|
},
|
|
92620
|
-
async clear() {
|
|
92923
|
+
async clear(expectTransaction) {
|
|
92924
|
+
if (expectTransaction !== void 0) {
|
|
92925
|
+
const current = await this.read();
|
|
92926
|
+
if (current.kind === "valid" && current.marker.transaction !== expectTransaction) return false;
|
|
92927
|
+
if (current.kind === "corrupt") return false;
|
|
92928
|
+
}
|
|
92621
92929
|
await io.rm(markerPath2, { force: true });
|
|
92930
|
+
return true;
|
|
92622
92931
|
},
|
|
92623
|
-
async
|
|
92932
|
+
async replaceCorrupt(replacement) {
|
|
92624
92933
|
const quarantinePath = `${markerPath2}.corrupt`;
|
|
92625
|
-
|
|
92626
|
-
|
|
92627
|
-
|
|
92934
|
+
let corrupt = null;
|
|
92935
|
+
try {
|
|
92936
|
+
corrupt = await io.readFile(markerPath2, "utf8");
|
|
92937
|
+
} catch {
|
|
92938
|
+
corrupt = null;
|
|
92939
|
+
}
|
|
92940
|
+
await this.write(replacement);
|
|
92941
|
+
if (corrupt === null) return;
|
|
92942
|
+
try {
|
|
92943
|
+
await io.rm(quarantinePath, { force: true });
|
|
92944
|
+
await io.writeFile(quarantinePath, corrupt, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
92945
|
+
} catch {
|
|
92946
|
+
}
|
|
92628
92947
|
}
|
|
92629
92948
|
};
|
|
92630
92949
|
}
|
|
@@ -93003,8 +93322,10 @@ var import_node_child_process14 = require("node:child_process");
|
|
|
93003
93322
|
var import_promises9 = require("node:fs/promises");
|
|
93004
93323
|
var import_node_util7 = require("node:util");
|
|
93005
93324
|
var execFileAsync3 = (0, import_node_util7.promisify)(import_node_child_process14.execFile);
|
|
93325
|
+
var TIMED_OUT = /* @__PURE__ */ Symbol("installer-tree-probe-deadline");
|
|
93006
93326
|
var INSTALLER_COMMAND_LINE_PATTERN = "@aware-aeco/cli@|\\baware(?:\\.cmd|\\.js)?\\W?\\s+sidecar\\s+install";
|
|
93007
93327
|
var INSTALLER_RE = new RegExp(INSTALLER_COMMAND_LINE_PATTERN);
|
|
93328
|
+
var PROBE_TIMEOUT_MS = 5e3;
|
|
93008
93329
|
function matchesInstallerCommandLine(commandLine) {
|
|
93009
93330
|
return INSTALLER_RE.test(commandLine);
|
|
93010
93331
|
}
|
|
@@ -93055,9 +93376,37 @@ async function anyAwareInstallerTreeAlive(deps = {}) {
|
|
|
93055
93376
|
}
|
|
93056
93377
|
}
|
|
93057
93378
|
if (platform === "linux") {
|
|
93379
|
+
const now = deps.now ?? (() => performance.now());
|
|
93380
|
+
const deadline = now() + PROBE_TIMEOUT_MS;
|
|
93381
|
+
const withinDeadline = async (work) => {
|
|
93382
|
+
const settled2 = work.then(
|
|
93383
|
+
(value) => ({ ok: true, value }),
|
|
93384
|
+
(error) => ({ ok: false, error })
|
|
93385
|
+
);
|
|
93386
|
+
const left = deadline - now();
|
|
93387
|
+
if (left <= 0) return TIMED_OUT;
|
|
93388
|
+
let timer;
|
|
93389
|
+
let outcome;
|
|
93390
|
+
try {
|
|
93391
|
+
outcome = await Promise.race([
|
|
93392
|
+
settled2,
|
|
93393
|
+
new Promise((resolve21) => {
|
|
93394
|
+
timer = setTimeout(() => resolve21(TIMED_OUT), left);
|
|
93395
|
+
timer.unref?.();
|
|
93396
|
+
})
|
|
93397
|
+
]);
|
|
93398
|
+
} finally {
|
|
93399
|
+
if (timer) clearTimeout(timer);
|
|
93400
|
+
}
|
|
93401
|
+
if (outcome === TIMED_OUT) return TIMED_OUT;
|
|
93402
|
+
if (!outcome.ok) throw outcome.error;
|
|
93403
|
+
return outcome.value;
|
|
93404
|
+
};
|
|
93058
93405
|
let entries;
|
|
93059
93406
|
try {
|
|
93060
|
-
|
|
93407
|
+
const listed = await withinDeadline((deps.listProcDir ?? (() => (0, import_promises9.readdir)("/proc")))());
|
|
93408
|
+
if (listed === TIMED_OUT) return true;
|
|
93409
|
+
entries = listed;
|
|
93061
93410
|
} catch {
|
|
93062
93411
|
return true;
|
|
93063
93412
|
}
|
|
@@ -93066,7 +93415,9 @@ async function anyAwareInstallerTreeAlive(deps = {}) {
|
|
|
93066
93415
|
if (!/^\d+$/.test(entry2) || Number(entry2) === selfPid) continue;
|
|
93067
93416
|
let raw;
|
|
93068
93417
|
try {
|
|
93069
|
-
|
|
93418
|
+
const value = await withinDeadline(read2(entry2));
|
|
93419
|
+
if (value === TIMED_OUT) return true;
|
|
93420
|
+
raw = value;
|
|
93070
93421
|
} catch (err2) {
|
|
93071
93422
|
if (isVanishedProcessError(err2)) continue;
|
|
93072
93423
|
return true;
|
|
@@ -93083,6 +93434,7 @@ async function anyAwareInstallerTreeAlive(deps = {}) {
|
|
|
93083
93434
|
}
|
|
93084
93435
|
|
|
93085
93436
|
// aware-update-jobs.ts
|
|
93437
|
+
var MAINTENANCE_RECOVERY = "maintenance-recovery";
|
|
93086
93438
|
var AwareUpdateConflictError = class extends Error {
|
|
93087
93439
|
status = 409;
|
|
93088
93440
|
};
|
|
@@ -93094,6 +93446,10 @@ var AwareUpdateGoneError = class extends Error {
|
|
|
93094
93446
|
};
|
|
93095
93447
|
var DEFAULT_OPERATION_TIMEOUT = 10 * 6e4;
|
|
93096
93448
|
var DEFAULT_JOB_TIMEOUT = 30 * 6e4;
|
|
93449
|
+
var RECOVERY_BUDGET_MS = 15 * 6e4;
|
|
93450
|
+
var RECOVERY_UNCANCELLABLE_TAIL_MS = IDENTITY_ATTEMPTS * IDENTITY_ATTEMPT_TIMEOUT_MS + PROBE_TIMEOUT_MS;
|
|
93451
|
+
var RECOVERY_GRACE_MS = 2 * 6e4;
|
|
93452
|
+
var RECOVERY_WORK_BUDGET_MS = RECOVERY_BUDGET_MS - RECOVERY_GRACE_MS;
|
|
93097
93453
|
var DEFAULT_RETENTION_TTL = 30 * 6e4;
|
|
93098
93454
|
var DEFAULT_MAX_RETAINED = 24;
|
|
93099
93455
|
function frozenHosts(hosts) {
|
|
@@ -93130,6 +93486,25 @@ var DeadlineError = class extends Error {
|
|
|
93130
93486
|
function remaining(deadline, now) {
|
|
93131
93487
|
return Math.max(0, deadline - now());
|
|
93132
93488
|
}
|
|
93489
|
+
function settledWithin(work, budgetMs, fallback2, signal) {
|
|
93490
|
+
const guarded = work.then((value) => value, () => fallback2);
|
|
93491
|
+
if (budgetMs <= 0 || signal?.aborted) return Promise.resolve(fallback2);
|
|
93492
|
+
return new Promise((resolve21) => {
|
|
93493
|
+
const done = (value) => {
|
|
93494
|
+
cleanup();
|
|
93495
|
+
resolve21(value);
|
|
93496
|
+
};
|
|
93497
|
+
const onAbort = () => done(fallback2);
|
|
93498
|
+
const timer = setTimeout(() => done(fallback2), budgetMs);
|
|
93499
|
+
timer.unref?.();
|
|
93500
|
+
const cleanup = () => {
|
|
93501
|
+
clearTimeout(timer);
|
|
93502
|
+
signal?.removeEventListener("abort", onAbort);
|
|
93503
|
+
};
|
|
93504
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
93505
|
+
void guarded.then(done);
|
|
93506
|
+
});
|
|
93507
|
+
}
|
|
93133
93508
|
async function bounded(operation, budgetMs, parentSignal) {
|
|
93134
93509
|
if (budgetMs <= 0) throw new DeadlineError();
|
|
93135
93510
|
const controller = new AbortController();
|
|
@@ -93195,6 +93570,7 @@ var AwareUpdateJobManager = class {
|
|
|
93195
93570
|
let operation = requestedOperation;
|
|
93196
93571
|
let preResolved = null;
|
|
93197
93572
|
let target;
|
|
93573
|
+
let recoveryMarker = null;
|
|
93198
93574
|
if (operation === "bridge-repair") {
|
|
93199
93575
|
const resolved = await this.#deps.resolveBridgeRepair(this.#currentOwnerOrThrow());
|
|
93200
93576
|
if (!resolved) throw new AwareUpdateConflictError("No installed AWARE bridge needs repair.");
|
|
@@ -93202,9 +93578,22 @@ var AwareUpdateJobManager = class {
|
|
|
93202
93578
|
preResolved = resolved.hosts;
|
|
93203
93579
|
if (!preResolved.length) throw new AwareUpdateConflictError("No installed AWARE bridge needs repair.");
|
|
93204
93580
|
} else {
|
|
93205
|
-
const
|
|
93206
|
-
|
|
93207
|
-
|
|
93581
|
+
const recovery = await this.#deps.probeRecovery();
|
|
93582
|
+
if (recovery.pending) {
|
|
93583
|
+
if (!recovery.target) {
|
|
93584
|
+
throw Object.assign(
|
|
93585
|
+
new Error("An earlier AWARE update did not finish, and FloLess cannot tell which version to return to. Reinstall AWARE, then relaunch FloLess."),
|
|
93586
|
+
{ code: "recovery-target-unknown" }
|
|
93587
|
+
);
|
|
93588
|
+
}
|
|
93589
|
+
target = requireExactAwareTarget(recovery.target);
|
|
93590
|
+
recoveryMarker = recovery.marker;
|
|
93591
|
+
operation = MAINTENANCE_RECOVERY;
|
|
93592
|
+
} else {
|
|
93593
|
+
const resolved = await this.#deps.resolveCurrentTarget();
|
|
93594
|
+
target = requireExactAwareTarget(resolved.target);
|
|
93595
|
+
operation = resolved.operation;
|
|
93596
|
+
}
|
|
93208
93597
|
}
|
|
93209
93598
|
if (this.#active || this.#retrying) throw new AwareUpdateConflictError("An AWARE update is already in progress.");
|
|
93210
93599
|
if (this.#shuttingDown) throw new AwareUpdateConflictError("FloLess is shutting down.");
|
|
@@ -93226,7 +93615,8 @@ var AwareUpdateJobManager = class {
|
|
|
93226
93615
|
snapshot: frozenHosts([]),
|
|
93227
93616
|
startedAt,
|
|
93228
93617
|
touchedAt: startedAt,
|
|
93229
|
-
...preResolved ? { preResolved } : {}
|
|
93618
|
+
...preResolved ? { preResolved } : {},
|
|
93619
|
+
...operation === MAINTENANCE_RECOVERY ? { recoveryMarker } : {}
|
|
93230
93620
|
});
|
|
93231
93621
|
this.#active = transaction;
|
|
93232
93622
|
const settled2 = this.#execute(transaction).catch((error) => this.#unexpectedFailure(transaction, error));
|
|
@@ -93313,6 +93703,16 @@ var AwareUpdateJobManager = class {
|
|
|
93313
93703
|
if (this.#gone.has(transaction)) throw new AwareUpdateGoneError("This AWARE update result has expired.");
|
|
93314
93704
|
throw new AwareUpdateNotFoundError("AWARE update transaction not found.");
|
|
93315
93705
|
}
|
|
93706
|
+
/**
|
|
93707
|
+
* A recovery job can never reach `partial`, so bridge retry has nothing to act on. Asserted
|
|
93708
|
+
* rather than left implicit: the invariant is what makes `retry()` safe, and an invariant nobody
|
|
93709
|
+
* checks is a comment.
|
|
93710
|
+
*/
|
|
93711
|
+
#assertRetryable(status) {
|
|
93712
|
+
if (status.operation === MAINTENANCE_RECOVERY) {
|
|
93713
|
+
throw new AwareUpdateConflictError("A maintenance recovery has no bridges to retry.");
|
|
93714
|
+
}
|
|
93715
|
+
}
|
|
93316
93716
|
async retry(transaction, hostValue) {
|
|
93317
93717
|
this.#purge();
|
|
93318
93718
|
if (!AWARE_BRIDGE_HOSTS.includes(hostValue)) {
|
|
@@ -93324,6 +93724,7 @@ var AwareUpdateJobManager = class {
|
|
|
93324
93724
|
if (this.#gone.has(transaction)) throw new AwareUpdateGoneError("This AWARE update result has expired.");
|
|
93325
93725
|
throw new AwareUpdateNotFoundError("AWARE update transaction not found.");
|
|
93326
93726
|
}
|
|
93727
|
+
this.#assertRetryable(record4.status);
|
|
93327
93728
|
if (record4.retry) {
|
|
93328
93729
|
if (record4.retry.host !== host) throw new AwareUpdateConflictError("Another bridge retry is already in progress.");
|
|
93329
93730
|
return cloneStatus(await record4.retry.reserved);
|
|
@@ -93350,7 +93751,7 @@ var AwareUpdateJobManager = class {
|
|
|
93350
93751
|
const record4 = this.#jobs.get(transaction);
|
|
93351
93752
|
if (!record4 || record4.status.state !== "running") return;
|
|
93352
93753
|
const started = this.#now();
|
|
93353
|
-
const jobBudget = this.#deps.jobTimeoutMs ?? DEFAULT_JOB_TIMEOUT;
|
|
93754
|
+
const jobBudget = record4.status.operation === MAINTENANCE_RECOVERY ? this.#deps.recoveryBudgetMs ?? RECOVERY_BUDGET_MS : this.#deps.jobTimeoutMs ?? DEFAULT_JOB_TIMEOUT;
|
|
93354
93755
|
const deadline = started + jobBudget;
|
|
93355
93756
|
const jobController = new AbortController();
|
|
93356
93757
|
this.#activeController = jobController;
|
|
@@ -93359,6 +93760,10 @@ var AwareUpdateJobManager = class {
|
|
|
93359
93760
|
try {
|
|
93360
93761
|
await this.#deps.withExclusive(async (owner2) => this.#deps.withMutationContainment(transaction, owner2, async () => {
|
|
93361
93762
|
const operation = record4.status.operation;
|
|
93763
|
+
if (operation === MAINTENANCE_RECOVERY) {
|
|
93764
|
+
await this.#executeRecovery(record4, owner2, jobController, deadline);
|
|
93765
|
+
return;
|
|
93766
|
+
}
|
|
93362
93767
|
this.#running(record4, "snapshot", 0, 0, []);
|
|
93363
93768
|
const snapshot = record4.preResolved ?? await this.#deps.snapshotPersistentBridges(owner2, record4.status.target);
|
|
93364
93769
|
this.#assertSnapshot(snapshot);
|
|
@@ -93370,7 +93775,7 @@ var AwareUpdateJobManager = class {
|
|
|
93370
93775
|
stage: "runtime-install",
|
|
93371
93776
|
target: record4.status.target,
|
|
93372
93777
|
snapshot: record4.snapshot,
|
|
93373
|
-
operation,
|
|
93778
|
+
operation: markerOperationOf(operation),
|
|
93374
93779
|
origin: record4.status.origin
|
|
93375
93780
|
};
|
|
93376
93781
|
await this.#deps.maintenance.write(marker);
|
|
@@ -93503,6 +93908,126 @@ var AwareUpdateJobManager = class {
|
|
|
93503
93908
|
this.#purge();
|
|
93504
93909
|
}
|
|
93505
93910
|
}
|
|
93911
|
+
/**
|
|
93912
|
+
* Discharge an interrupted update, then STOP.
|
|
93913
|
+
*
|
|
93914
|
+
* Deliberately does not fall through into snapshot/install/verify. Recovery already verifies the
|
|
93915
|
+
* runtime it repaired, and a second verifier that can disagree would fail a machine the first one
|
|
93916
|
+
* just declared healthy — turning a successful recovery into a fresh marker.
|
|
93917
|
+
*/
|
|
93918
|
+
async #executeRecovery(record4, owner2, jobController, deadline) {
|
|
93919
|
+
const transaction = record4.status.transaction;
|
|
93920
|
+
const target = record4.status.target;
|
|
93921
|
+
const authority = await this.#deps.probeRecovery();
|
|
93922
|
+
if (!authority.pending) {
|
|
93923
|
+
const observed = await this.#deps.probeRuntime(owner2);
|
|
93924
|
+
const good = !!observed && compareExactAwareVersions(observed, target) >= 0 && await this.#deps.smokeRuntime(owner2, jobController.signal);
|
|
93925
|
+
if (!good) {
|
|
93926
|
+
this.#setTerminal(record4, {
|
|
93927
|
+
state: "runtime-failed",
|
|
93928
|
+
transaction,
|
|
93929
|
+
target,
|
|
93930
|
+
code: "recovery-unverified",
|
|
93931
|
+
message: observed ? `The interrupted AWARE update was already cleared, but AWARE v${observed} is not ready to use.` : "The interrupted AWARE update was already cleared, but AWARE did not report a version."
|
|
93932
|
+
});
|
|
93933
|
+
return;
|
|
93934
|
+
}
|
|
93935
|
+
this.#setTerminal(record4, {
|
|
93936
|
+
state: "success",
|
|
93937
|
+
transaction,
|
|
93938
|
+
target,
|
|
93939
|
+
observedVersion: observed,
|
|
93940
|
+
updated: frozenHosts([])
|
|
93941
|
+
});
|
|
93942
|
+
return;
|
|
93943
|
+
}
|
|
93944
|
+
if (authority.target !== target || authority.marker !== record4.recoveryMarker) {
|
|
93945
|
+
this.#setTerminal(record4, {
|
|
93946
|
+
state: "runtime-failed",
|
|
93947
|
+
transaction,
|
|
93948
|
+
target,
|
|
93949
|
+
code: "marker-superseded",
|
|
93950
|
+
message: "The interrupted AWARE update changed while this recovery was starting. Try again."
|
|
93951
|
+
});
|
|
93952
|
+
return;
|
|
93953
|
+
}
|
|
93954
|
+
this.#running(record4, "recovering", 0, 0, []);
|
|
93955
|
+
let outcome;
|
|
93956
|
+
try {
|
|
93957
|
+
outcome = await bounded(
|
|
93958
|
+
(signal) => this.#deps.recoverMaintenance(owner2, signal),
|
|
93959
|
+
// The grace comes off what is LEFT, not only off the whole budget. `#recoveryWorkBudget()`
|
|
93960
|
+
// reserved it once; the second term did not, so once the authority read and the probes
|
|
93961
|
+
// above had eaten most of the deadline, `remaining` alone became the smaller number and
|
|
93962
|
+
// handed the work every millisecond that was left — reserving nothing for a tail that
|
|
93963
|
+
// cannot be cancelled, which is the one thing the budget exists to bound. When nothing is
|
|
93964
|
+
// left, bounded() refuses immediately rather than starting work it cannot finish; that is
|
|
93965
|
+
// a DeadlineError, which is mapped to `recovery-incomplete` — paused, marker kept,
|
|
93966
|
+
// resumable — and not a failure.
|
|
93967
|
+
//
|
|
93968
|
+
// On a forward-running clock the second term always wins (`remaining <= total`), so the
|
|
93969
|
+
// first is not doing day-to-day work. It stays as the floor for a clock that steps
|
|
93970
|
+
// BACKWARDS — an NTP correction mid-job would otherwise inflate `remaining` past the whole
|
|
93971
|
+
// budget — and it is the reason no test can pin that arm on its own.
|
|
93972
|
+
Math.min(
|
|
93973
|
+
this.#recoveryWorkBudget(),
|
|
93974
|
+
remaining(deadline, () => this.#now()) - this.#recoveryGrace()
|
|
93975
|
+
),
|
|
93976
|
+
jobController.signal
|
|
93977
|
+
);
|
|
93978
|
+
} catch (error) {
|
|
93979
|
+
const still = await settledWithin(
|
|
93980
|
+
this.#deps.probeRecovery(),
|
|
93981
|
+
remaining(deadline, () => this.#now()),
|
|
93982
|
+
{ pending: true, target: null, marker: null },
|
|
93983
|
+
// The JOB's own signal, as well as the arithmetic. `remaining()` is wall-clock, so a clock
|
|
93984
|
+
// that steps backwards mid-job — a suspended laptop, an NTP correction — inflates it and
|
|
93985
|
+
// the arithmetic alone would grant far more than the reserve. The job timer is a real
|
|
93986
|
+
// setTimeout and is not fooled by that, so honouring its abort here is what keeps the
|
|
93987
|
+
// lease bounded when the arithmetic cannot be trusted.
|
|
93988
|
+
jobController.signal
|
|
93989
|
+
);
|
|
93990
|
+
const sanitized = sanitizeAwareError(error, "recovery-failed");
|
|
93991
|
+
const timedOut = error instanceof DeadlineError || error?.name === "AbortError";
|
|
93992
|
+
this.#setTerminal(record4, {
|
|
93993
|
+
state: "runtime-failed",
|
|
93994
|
+
transaction,
|
|
93995
|
+
target,
|
|
93996
|
+
// A typed refusal SURVIVES the pending-marker fallback. `marker-superseded` is thrown
|
|
93997
|
+
// precisely when a replacement marker exists, so the probe below always sees one — and the
|
|
93998
|
+
// generic 'maintenance-pending' then overwrote the one code that says what happened.
|
|
93999
|
+
code: timedOut ? "recovery-incomplete" : sanitized.code === "marker-superseded" ? "marker-superseded" : still.pending ? "maintenance-pending" : sanitized.code,
|
|
94000
|
+
message: timedOut ? "Recovering the interrupted AWARE update is taking longer than one attempt allows. It will continue where it left off." : sanitized.message
|
|
94001
|
+
});
|
|
94002
|
+
return;
|
|
94003
|
+
}
|
|
94004
|
+
if (!outcome.observedVersion) {
|
|
94005
|
+
this.#setTerminal(record4, {
|
|
94006
|
+
state: "runtime-failed",
|
|
94007
|
+
transaction,
|
|
94008
|
+
target,
|
|
94009
|
+
code: "recovery-unverified",
|
|
94010
|
+
message: "The interrupted AWARE update was cleared, but AWARE did not pass its readiness check."
|
|
94011
|
+
});
|
|
94012
|
+
return;
|
|
94013
|
+
}
|
|
94014
|
+
this.#setTerminal(record4, {
|
|
94015
|
+
state: "success",
|
|
94016
|
+
transaction,
|
|
94017
|
+
target,
|
|
94018
|
+
observedVersion: outcome.observedVersion,
|
|
94019
|
+
updated: frozenHosts([])
|
|
94020
|
+
});
|
|
94021
|
+
}
|
|
94022
|
+
#recoveryGrace() {
|
|
94023
|
+
return this.#deps.recoveryGraceMs ?? RECOVERY_GRACE_MS;
|
|
94024
|
+
}
|
|
94025
|
+
#recoveryWorkBudget() {
|
|
94026
|
+
const total = this.#deps.recoveryBudgetMs ?? RECOVERY_BUDGET_MS;
|
|
94027
|
+
const grace = this.#recoveryGrace();
|
|
94028
|
+
if (total === RECOVERY_BUDGET_MS && grace === RECOVERY_GRACE_MS) return RECOVERY_WORK_BUDGET_MS;
|
|
94029
|
+
return Math.max(1, total - grace);
|
|
94030
|
+
}
|
|
93506
94031
|
async #executeRetry(record4, host, resolveReserved, rejectReserved) {
|
|
93507
94032
|
let reserved = false;
|
|
93508
94033
|
const retryController = new AbortController();
|
|
@@ -93546,7 +94071,8 @@ var AwareUpdateJobManager = class {
|
|
|
93546
94071
|
target: status.target,
|
|
93547
94072
|
host,
|
|
93548
94073
|
snapshot: record4.snapshot,
|
|
93549
|
-
|
|
94074
|
+
// Unreachable — #assertRetryable refuses a recovery job before this — but proven, not assumed.
|
|
94075
|
+
operation: markerOperationOf(status.operation),
|
|
93550
94076
|
origin: status.origin
|
|
93551
94077
|
};
|
|
93552
94078
|
try {
|
|
@@ -93694,6 +94220,17 @@ var AwareUpdateJobManager = class {
|
|
|
93694
94220
|
#unexpectedFailure(transaction, error) {
|
|
93695
94221
|
const record4 = this.#jobs.get(transaction);
|
|
93696
94222
|
if (!record4 || isTerminal(record4.status)) return;
|
|
94223
|
+
const aborted = error instanceof DeadlineError || error?.name === "AbortError";
|
|
94224
|
+
if (aborted && record4.status.operation === MAINTENANCE_RECOVERY) {
|
|
94225
|
+
this.#setTerminal(record4, {
|
|
94226
|
+
state: "runtime-failed",
|
|
94227
|
+
transaction,
|
|
94228
|
+
target: record4.status.target,
|
|
94229
|
+
code: "recovery-incomplete",
|
|
94230
|
+
message: "Recovering the interrupted AWARE update is taking longer than one attempt allows. It will continue where it left off."
|
|
94231
|
+
});
|
|
94232
|
+
return;
|
|
94233
|
+
}
|
|
93697
94234
|
this.#setTerminal(record4, {
|
|
93698
94235
|
state: "runtime-failed",
|
|
93699
94236
|
transaction,
|
|
@@ -93750,22 +94287,31 @@ var AwareUpdateJobManager = class {
|
|
|
93750
94287
|
this.#gone.set(transaction, goneUntil);
|
|
93751
94288
|
}
|
|
93752
94289
|
};
|
|
94290
|
+
function markerOperationOf(operation) {
|
|
94291
|
+
if (operation === MAINTENANCE_RECOVERY) {
|
|
94292
|
+
throw new Error("a maintenance-recovery job must never write a maintenance marker");
|
|
94293
|
+
}
|
|
94294
|
+
return operation;
|
|
94295
|
+
}
|
|
93753
94296
|
function cryptoRandomId() {
|
|
93754
94297
|
return globalThis.crypto.randomUUID();
|
|
93755
94298
|
}
|
|
93756
94299
|
async function recoverInterruptedAwareMaintenance(deps) {
|
|
93757
|
-
const read2 = await deps.maintenance.read();
|
|
93758
|
-
if (read2.kind === "absent") return "clean";
|
|
93759
94300
|
return deps.withRecoveryExclusive(async (owner2) => {
|
|
94301
|
+
const read2 = await deps.maintenance.read();
|
|
94302
|
+
if (read2.kind === "absent") return "clean";
|
|
93760
94303
|
if (read2.kind === "corrupt") {
|
|
93761
94304
|
if (await deps.anyInstallerTreeAlive()) {
|
|
93762
94305
|
throw new Error("AWARE maintenance state is corrupt and an installer tree may still be running.");
|
|
93763
94306
|
}
|
|
93764
|
-
await deps.
|
|
93765
|
-
if (!
|
|
94307
|
+
const replacement = await deps.buildRecoveryMarker();
|
|
94308
|
+
if (!replacement) {
|
|
94309
|
+
throw new Error("AWARE maintenance state is corrupt and no usable recovery target could be derived.");
|
|
94310
|
+
}
|
|
94311
|
+
await deps.maintenance.replaceCorrupt(replacement);
|
|
94312
|
+
if (!await deps.repairAndVerify(replacement, owner2)) {
|
|
93766
94313
|
throw new Error("AWARE maintenance recovery could not verify a usable runtime and bridges.");
|
|
93767
94314
|
}
|
|
93768
|
-
await deps.maintenance.clear();
|
|
93769
94315
|
return "recovered";
|
|
93770
94316
|
}
|
|
93771
94317
|
if (await deps.matchingChildAlive(read2.marker)) {
|
|
@@ -93777,7 +94323,6 @@ async function recoverInterruptedAwareMaintenance(deps) {
|
|
|
93777
94323
|
if (!await deps.repairAndVerify({ ...read2.marker, stage: "recovery", child: void 0 }, owner2)) {
|
|
93778
94324
|
throw new Error("AWARE maintenance recovery could not verify a usable runtime and bridges.");
|
|
93779
94325
|
}
|
|
93780
|
-
await deps.maintenance.clear();
|
|
93781
94326
|
return "recovered";
|
|
93782
94327
|
});
|
|
93783
94328
|
}
|
|
@@ -93787,7 +94332,8 @@ function sendRouteError(reply, error) {
|
|
|
93787
94332
|
if (error instanceof AwareUpdateConflictError || error instanceof AwareUpdateGoneError || error instanceof AwareUpdateNotFoundError) {
|
|
93788
94333
|
return reply.status(error.status).send({ ok: false, error: error.message });
|
|
93789
94334
|
}
|
|
93790
|
-
|
|
94335
|
+
const sanitized = sanitizeAwareError(error, "invalid-update-request");
|
|
94336
|
+
return reply.status(400).send({ ok: false, error: sanitized.message, code: sanitized.code });
|
|
93791
94337
|
}
|
|
93792
94338
|
function registerAwareUpdateRoutes(app, manager) {
|
|
93793
94339
|
app.get("/api/aware/update/active", async (_request, reply) => reply.send({ ok: true, job: manager.activeStatus() }));
|
|
@@ -94450,14 +94996,14 @@ function safeLease2(value) {
|
|
|
94450
94996
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value)) throw new RunFileRelayError("unsafe lease id");
|
|
94451
94997
|
return value;
|
|
94452
94998
|
}
|
|
94453
|
-
function rejectLink2(path,
|
|
94999
|
+
function rejectLink2(path, label) {
|
|
94454
95000
|
let st;
|
|
94455
95001
|
try {
|
|
94456
95002
|
st = (0, import_node_fs75.lstatSync)(path);
|
|
94457
95003
|
} catch {
|
|
94458
|
-
throw new RunFileRelayError(`${
|
|
95004
|
+
throw new RunFileRelayError(`${label} does not exist`);
|
|
94459
95005
|
}
|
|
94460
|
-
if (st.isSymbolicLink()) throw new RunFileRelayError(`${
|
|
95006
|
+
if (st.isSymbolicLink()) throw new RunFileRelayError(`${label} is a filesystem link/reparse point`);
|
|
94461
95007
|
}
|
|
94462
95008
|
function sameIdentity(a, b) {
|
|
94463
95009
|
return a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs;
|
|
@@ -94472,11 +95018,11 @@ function structural(value) {
|
|
|
94472
95018
|
function hash2(value) {
|
|
94473
95019
|
return (0, import_node_crypto45.createHash)("sha256").update(value).digest("hex");
|
|
94474
95020
|
}
|
|
94475
|
-
function readRegularFile(path, maxBytes,
|
|
94476
|
-
rejectLink2(path,
|
|
95021
|
+
function readRegularFile(path, maxBytes, label) {
|
|
95022
|
+
rejectLink2(path, label);
|
|
94477
95023
|
const st = (0, import_node_fs75.statSync)(path);
|
|
94478
|
-
if (!st.isFile()) throw new RunFileRelayError(`${
|
|
94479
|
-
if (st.size > maxBytes) throw new RunFileRelayError(`${
|
|
95024
|
+
if (!st.isFile()) throw new RunFileRelayError(`${label} is not a regular file`);
|
|
95025
|
+
if (st.size > maxBytes) throw new RunFileRelayError(`${label} is too large`);
|
|
94480
95026
|
return (0, import_node_fs75.readFileSync)(path);
|
|
94481
95027
|
}
|
|
94482
95028
|
function durableWrite3(path, value) {
|
|
@@ -94742,25 +95288,25 @@ function createRunSkillReader(options) {
|
|
|
94742
95288
|
};
|
|
94743
95289
|
return { skillName: options.skillName, read: (resource) => readPacket(resource).text, readPacket };
|
|
94744
95290
|
}
|
|
94745
|
-
function checkedDirectory(path,
|
|
94746
|
-
rejectLink3(path,
|
|
95291
|
+
function checkedDirectory(path, label) {
|
|
95292
|
+
rejectLink3(path, label);
|
|
94747
95293
|
let real;
|
|
94748
95294
|
try {
|
|
94749
95295
|
real = import_node_fs77.realpathSync.native(path);
|
|
94750
95296
|
} catch {
|
|
94751
|
-
throw new RunSkillRelayError(`${
|
|
95297
|
+
throw new RunSkillRelayError(`${label} not found`);
|
|
94752
95298
|
}
|
|
94753
|
-
if (!(0, import_node_fs77.statSync)(real).isDirectory()) throw new RunSkillRelayError(`${
|
|
95299
|
+
if (!(0, import_node_fs77.statSync)(real).isDirectory()) throw new RunSkillRelayError(`${label} is not a directory`);
|
|
94754
95300
|
return real;
|
|
94755
95301
|
}
|
|
94756
|
-
function rejectLink3(path,
|
|
95302
|
+
function rejectLink3(path, label) {
|
|
94757
95303
|
let st;
|
|
94758
95304
|
try {
|
|
94759
95305
|
st = (0, import_node_fs77.lstatSync)(path);
|
|
94760
95306
|
} catch {
|
|
94761
|
-
throw new RunSkillRelayError(`${
|
|
95307
|
+
throw new RunSkillRelayError(`${label} not found`);
|
|
94762
95308
|
}
|
|
94763
|
-
if (st.isSymbolicLink()) throw new RunSkillRelayError(`${
|
|
95309
|
+
if (st.isSymbolicLink()) throw new RunSkillRelayError(`${label} is a filesystem link/reparse point`);
|
|
94764
95310
|
}
|
|
94765
95311
|
|
|
94766
95312
|
// terminal-run.ts
|
|
@@ -98333,14 +98879,69 @@ async function startServer() {
|
|
|
98333
98879
|
}));
|
|
98334
98880
|
}
|
|
98335
98881
|
const awareUpdateJobs = new AwareUpdateJobManager({
|
|
98336
|
-
|
|
98337
|
-
|
|
98338
|
-
|
|
98339
|
-
|
|
98882
|
+
/**
|
|
98883
|
+
* Is an interrupted update outstanding, and what would recovering it aim at?
|
|
98884
|
+
*
|
|
98885
|
+
* No registry call — `decideRecoveryTarget` reads the marker and the installed version — which is
|
|
98886
|
+
* what lets a recovery job carry a complete identity from creation and keeps a 15-second npm
|
|
98887
|
+
* fetch out of the exclusive lease.
|
|
98888
|
+
*/
|
|
98889
|
+
probeRecovery: async () => {
|
|
98890
|
+
const read2 = await awareMaintenance.read();
|
|
98891
|
+
if (read2.kind === "absent") return { pending: false, target: null, marker: null };
|
|
98892
|
+
const marker = read2.kind === "valid" ? read2.marker : null;
|
|
98893
|
+
return {
|
|
98894
|
+
pending: true,
|
|
98895
|
+
target: decideRecoveryTarget({
|
|
98896
|
+
markerTarget: marker?.target ?? null,
|
|
98897
|
+
markerOperation: marker?.operation ?? null,
|
|
98898
|
+
installed: aware.npmVersion()
|
|
98899
|
+
}),
|
|
98900
|
+
// A corrupt marker has no readable transaction; `null` is then its identity, and two corrupt
|
|
98901
|
+
// reads compare equal — which is correct, since neither can be told apart from the other.
|
|
98902
|
+
marker: marker?.transaction ?? null
|
|
98903
|
+
};
|
|
98904
|
+
},
|
|
98905
|
+
/**
|
|
98906
|
+
* Runs INSIDE the job's exclusive lease and is handed the job's own owner, so the recovery takes
|
|
98907
|
+
* no lease of its own. Awaiting a lease-acquiring promise while holding the lease would deadlock.
|
|
98908
|
+
*/
|
|
98909
|
+
recoverMaintenance: async (owner2, signal) => {
|
|
98910
|
+
await recoverInterruptedAwareMaintenance({
|
|
98911
|
+
maintenance: awareMaintenance,
|
|
98912
|
+
withRecoveryExclusive: (work) => work(owner2),
|
|
98913
|
+
matchingChildAlive: async (marker) => marker.child ? maintenanceChildMatches(marker.child) : false,
|
|
98914
|
+
anyInstallerTreeAlive: () => anyAwareInstallerTreeAlive(),
|
|
98915
|
+
repairAndVerify: (marker, repairOwner) => repairInterruptedAwareMaintenance(marker, repairOwner, signal),
|
|
98916
|
+
buildRecoveryMarker
|
|
98917
|
+
});
|
|
98918
|
+
const observedVersion = aware.npmVersion();
|
|
98919
|
+
const stale = await staleBridgesForInstalledRuntime().catch(() => null);
|
|
98920
|
+
if (stale?.hosts.length) {
|
|
98921
|
+
disarmAutoBridgeRepair();
|
|
98922
|
+
scheduleAutoBridgeRepair();
|
|
98340
98923
|
}
|
|
98924
|
+
return { observedVersion };
|
|
98925
|
+
},
|
|
98926
|
+
resolveCurrentTarget: async () => {
|
|
98341
98927
|
const check = await checkAwareUpdate(AWARE_BRIDGE_DIRECTORY);
|
|
98928
|
+
if (!check.updateAvailable) {
|
|
98929
|
+
if (!check.currentVersion && check.targetVersion) {
|
|
98930
|
+
return { target: check.targetVersion, operation: "runtime-update" };
|
|
98931
|
+
}
|
|
98932
|
+
if (!check.targetVersion) {
|
|
98933
|
+
throw Object.assign(
|
|
98934
|
+
new Error("FloLess could not reach the AWARE release feed, so it cannot tell whether an update is available. Check your connection and try again."),
|
|
98935
|
+
{ code: "registry-unreachable" }
|
|
98936
|
+
);
|
|
98937
|
+
}
|
|
98938
|
+
throw Object.assign(
|
|
98939
|
+
new Error(`AWARE v${check.currentVersion} is already the current release \u2014 there is nothing to update.`),
|
|
98940
|
+
{ code: "runtime-current" }
|
|
98941
|
+
);
|
|
98942
|
+
}
|
|
98342
98943
|
return {
|
|
98343
|
-
target: check.
|
|
98944
|
+
target: check.targetVersion ?? null,
|
|
98344
98945
|
// 'none' cannot reach a started job (the target is null and requireExactAwareTarget throws),
|
|
98345
98946
|
// but map it defensively rather than casting — the check type lets the two disagree.
|
|
98346
98947
|
operation: check.operation === "bridge-repair" ? "bridge-repair" : "runtime-update"
|
|
@@ -98388,7 +98989,10 @@ async function startServer() {
|
|
|
98388
98989
|
},
|
|
98389
98990
|
invalidateVersion: invalidateAwareVersion,
|
|
98390
98991
|
probeRuntime: () => aware.npmVersion(),
|
|
98391
|
-
|
|
98992
|
+
// The signal is threaded, not dropped. smoke() runs `aware app list --json` with a 60s
|
|
98993
|
+
// ceiling and recovery runs it holding the exclusive lease, so an unsignalled call can hold
|
|
98994
|
+
// that lease for a full minute past an expired deadline and then publish success.
|
|
98995
|
+
smokeRuntime: async (_owner, signal) => aware.smoke(signal),
|
|
98392
98996
|
installBridge: async (host, _target, context) => {
|
|
98393
98997
|
let identityRecorded = Promise.resolve();
|
|
98394
98998
|
await aware.sidecarInstall(host, {
|
|
@@ -98405,8 +99009,10 @@ async function startServer() {
|
|
|
98405
99009
|
maintenance: awareMaintenance,
|
|
98406
99010
|
log: (event) => app.log.info(event, "AWARE update transaction")
|
|
98407
99011
|
});
|
|
98408
|
-
|
|
99012
|
+
let recoveryGeneration = 0;
|
|
99013
|
+
async function repairInterruptedAwareMaintenance(marker, owner2, signal) {
|
|
98409
99014
|
if (owner2 !== upgradeOwner()) return false;
|
|
99015
|
+
const generation = ++recoveryGeneration;
|
|
98410
99016
|
refreshInvoker();
|
|
98411
99017
|
invalidateAwareVersion();
|
|
98412
99018
|
const target = decideRecoveryTarget({
|
|
@@ -98415,6 +99021,15 @@ async function startServer() {
|
|
|
98415
99021
|
installed: aware.npmVersion()
|
|
98416
99022
|
});
|
|
98417
99023
|
if (!target || !/^\d+\.\d+\.\d+$/.test(target)) return false;
|
|
99024
|
+
await awareMaintenance.write({
|
|
99025
|
+
schema: 2,
|
|
99026
|
+
transaction: marker?.transaction ?? (0, import_node_crypto48.randomUUID)(),
|
|
99027
|
+
stage: "recovery",
|
|
99028
|
+
target,
|
|
99029
|
+
snapshot: Object.freeze([]),
|
|
99030
|
+
operation: marker?.operation ?? LEGACY_MARKER_OPERATION,
|
|
99031
|
+
origin: marker?.origin ?? LEGACY_MARKER_ORIGIN
|
|
99032
|
+
});
|
|
98418
99033
|
const durable = await awareBridgePending.read();
|
|
98419
99034
|
const observedHosts = await snapshotPersistentBridges(AWARE_BRIDGE_DIRECTORY);
|
|
98420
99035
|
let snapshot = Object.freeze(AWARE_BRIDGE_HOSTS.filter((host) => (marker?.snapshot ?? []).includes(host) || observedHosts.includes(host) || durable?.target === target && durable.hosts.includes(host)));
|
|
@@ -98428,10 +99043,14 @@ async function startServer() {
|
|
|
98428
99043
|
origin: marker?.origin ?? LEGACY_MARKER_ORIGIN
|
|
98429
99044
|
};
|
|
98430
99045
|
await awareMaintenance.write(recoveryMarker);
|
|
98431
|
-
|
|
99046
|
+
const installedNow = aware.npmVersion();
|
|
99047
|
+
const superseded = !!installedNow && isExactAwareTarget(installedNow) && compareExactAwareVersions(installedNow, target) > 0;
|
|
99048
|
+
if (!superseded && (installedNow !== target || !await aware.smoke(signal))) {
|
|
98432
99049
|
await installAwareGlobal(target, () => {
|
|
98433
99050
|
}, {
|
|
99051
|
+
...signal ? { signal } : {},
|
|
98434
99052
|
onChild: async (child) => {
|
|
99053
|
+
if (generation !== recoveryGeneration) return;
|
|
98435
99054
|
recoveryMarker = { ...recoveryMarker, child };
|
|
98436
99055
|
await awareMaintenance.write(recoveryMarker);
|
|
98437
99056
|
}
|
|
@@ -98439,32 +99058,22 @@ async function startServer() {
|
|
|
98439
99058
|
refreshInvoker();
|
|
98440
99059
|
invalidateAwareVersion();
|
|
98441
99060
|
}
|
|
98442
|
-
|
|
99061
|
+
const after = aware.npmVersion();
|
|
99062
|
+
const good = !!after && isExactAwareTarget(after) && compareExactAwareVersions(after, target) >= 0 && await aware.smoke(signal);
|
|
99063
|
+
if (!good) return false;
|
|
99064
|
+
const outstanding = [];
|
|
98443
99065
|
for (const host of snapshot) {
|
|
98444
|
-
if (await persistentBridgeVersion(AWARE_BRIDGE_DIRECTORY, host)
|
|
98445
|
-
|
|
98446
|
-
|
|
98447
|
-
|
|
98448
|
-
|
|
98449
|
-
|
|
98450
|
-
|
|
98451
|
-
|
|
98452
|
-
|
|
98453
|
-
|
|
98454
|
-
await awareMaintenance.write(recoveryMarker);
|
|
98455
|
-
});
|
|
98456
|
-
childRecorded.catch(() => {
|
|
98457
|
-
});
|
|
98458
|
-
}
|
|
98459
|
-
});
|
|
98460
|
-
await childRecorded;
|
|
98461
|
-
if (await persistentBridgeVersion(AWARE_BRIDGE_DIRECTORY, host) !== target) {
|
|
98462
|
-
throw new Error(`The recovered ${host} bridge did not match AWARE ${target}`);
|
|
98463
|
-
}
|
|
98464
|
-
});
|
|
99066
|
+
if (await persistentBridgeVersion(AWARE_BRIDGE_DIRECTORY, host) !== target) outstanding.push(host);
|
|
99067
|
+
}
|
|
99068
|
+
if (outstanding.length) {
|
|
99069
|
+
await awareBridgePending.write({ schema: 1, target, hosts: Object.freeze(outstanding) });
|
|
99070
|
+
}
|
|
99071
|
+
if (!await awareMaintenance.clear(recoveryMarker.transaction)) {
|
|
99072
|
+
throw Object.assign(
|
|
99073
|
+
new Error("The interrupted AWARE update changed while it was being finished."),
|
|
99074
|
+
{ code: "marker-superseded" }
|
|
99075
|
+
);
|
|
98465
99076
|
}
|
|
98466
|
-
await awareBridgePending.clear().catch(() => {
|
|
98467
|
-
});
|
|
98468
99077
|
return true;
|
|
98469
99078
|
}
|
|
98470
99079
|
async function recoverAwareMaintenance() {
|
|
@@ -98473,9 +99082,23 @@ async function startServer() {
|
|
|
98473
99082
|
withRecoveryExclusive: (work) => withAwareExclusive(() => work(upgradeOwner())),
|
|
98474
99083
|
matchingChildAlive: async (marker) => marker.child ? maintenanceChildMatches(marker.child) : false,
|
|
98475
99084
|
anyInstallerTreeAlive: () => anyAwareInstallerTreeAlive(),
|
|
98476
|
-
repairAndVerify: repairInterruptedAwareMaintenance
|
|
99085
|
+
repairAndVerify: repairInterruptedAwareMaintenance,
|
|
99086
|
+
buildRecoveryMarker
|
|
98477
99087
|
});
|
|
98478
99088
|
}
|
|
99089
|
+
async function buildRecoveryMarker() {
|
|
99090
|
+
const target = decideRecoveryTarget({ markerTarget: null, markerOperation: null, installed: aware.npmVersion() });
|
|
99091
|
+
if (!target || !isExactAwareTarget(target)) return null;
|
|
99092
|
+
return {
|
|
99093
|
+
schema: 2,
|
|
99094
|
+
transaction: (0, import_node_crypto48.randomUUID)(),
|
|
99095
|
+
stage: "recovery",
|
|
99096
|
+
target,
|
|
99097
|
+
snapshot: Object.freeze([]),
|
|
99098
|
+
operation: LEGACY_MARKER_OPERATION,
|
|
99099
|
+
origin: LEGACY_MARKER_ORIGIN
|
|
99100
|
+
};
|
|
99101
|
+
}
|
|
98479
99102
|
const SKIP_AUTO_BRIDGE_REPAIR = process.env.FLOLESS_SKIP_AUTO_BRIDGE_REPAIR === "1";
|
|
98480
99103
|
let autoRepairScheduled = false;
|
|
98481
99104
|
let autoRepairInFlight = false;
|
|
@@ -98797,7 +99420,11 @@ async function startServer() {
|
|
|
98797
99420
|
setTimeout(() => process.exit(0), 250);
|
|
98798
99421
|
});
|
|
98799
99422
|
app.get("/api/aware/update", async () => {
|
|
98800
|
-
return withAwareShared(async () => ({
|
|
99423
|
+
return withAwareShared(async () => ({
|
|
99424
|
+
ok: true,
|
|
99425
|
+
...await checkAwareUpdate(AWARE_BRIDGE_DIRECTORY),
|
|
99426
|
+
recoveryPending: (await awareMaintenance.read()).kind !== "absent"
|
|
99427
|
+
}));
|
|
98801
99428
|
});
|
|
98802
99429
|
registerAwareUpdateRoutes(app, awareUpdateJobs);
|
|
98803
99430
|
app.get("/api/release-notes", async (req, reply) => {
|