@floless/app 0.138.1 → 0.138.2
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
CHANGED
|
@@ -51021,6 +51021,7 @@ function busyMeta(owner2) {
|
|
|
51021
51021
|
function subjectFor(kind2) {
|
|
51022
51022
|
if (kind2 === "project") return "This project";
|
|
51023
51023
|
if (kind2 === "app") return "This workflow";
|
|
51024
|
+
if (kind2 === "steel-extraction") return "Steel drawing preparation";
|
|
51024
51025
|
return "This app";
|
|
51025
51026
|
}
|
|
51026
51027
|
function remainingPhrase(remainingMs) {
|
|
@@ -51331,10 +51332,12 @@ async function acquire(path, kind2, key3, options) {
|
|
|
51331
51332
|
const generation = staleGeneration(path);
|
|
51332
51333
|
if (generation) {
|
|
51333
51334
|
if (retireStaleLock(path, generation)) continue;
|
|
51335
|
+
if (options.failFast) throw busyError(kind2, key3, null);
|
|
51334
51336
|
} else {
|
|
51335
51337
|
const owner2 = readOwner(path);
|
|
51336
51338
|
const startedMs = owner2 ? Date.parse(owner2.acquiredAt) : NaN;
|
|
51337
51339
|
const expected = owner2 ? busyMeta(owner2).expectedMs : null;
|
|
51340
|
+
if (options.failFast) throw busyError(kind2, key3, owner2);
|
|
51338
51341
|
if (owner2 && expected != null && startedMs + expected > deadline) {
|
|
51339
51342
|
throw busyError(kind2, key3, owner2);
|
|
51340
51343
|
}
|
|
@@ -51351,6 +51354,9 @@ async function withLifecycleLock(kind2, key3, fn, options = {}) {
|
|
|
51351
51354
|
const budget = options.timeoutMsForTest ?? TIMEOUT_MS;
|
|
51352
51355
|
const enteredAt = Date.now();
|
|
51353
51356
|
const { at: freeAt, blocker } = localProjectedFreeAt(token2, enteredAt);
|
|
51357
|
+
if (options.failFast && localIntents.get(token2)?.size) {
|
|
51358
|
+
throw blocker ? localBusyError(kind2, key3, freeAt, blocker, enteredAt) : busyError(kind2, key3, null);
|
|
51359
|
+
}
|
|
51354
51360
|
if (freeAt > enteredAt + budget) {
|
|
51355
51361
|
throw blocker ? localBusyError(kind2, key3, freeAt, blocker, enteredAt) : busyError(kind2, key3, null);
|
|
51356
51362
|
}
|
|
@@ -62040,116 +62046,155 @@ function buildCandidate(args) {
|
|
|
62040
62046
|
if (!now2) return null;
|
|
62041
62047
|
if (now2.familyId !== was.familyId || now2.i !== was.i || now2.j !== was.j) return null;
|
|
62042
62048
|
}
|
|
62043
|
-
|
|
62044
|
-
|
|
62045
|
-
|
|
62046
|
-
|
|
62047
|
-
|
|
62048
|
-
|
|
62049
|
-
const
|
|
62050
|
-
|
|
62051
|
-
|
|
62052
|
-
|
|
62053
|
-
|
|
62054
|
-
|
|
62055
|
-
|
|
62056
|
-
const
|
|
62057
|
-
|
|
62058
|
-
|
|
62059
|
-
|
|
62060
|
-
|
|
62061
|
-
|
|
62062
|
-
|
|
62063
|
-
|
|
62064
|
-
|
|
62065
|
-
const
|
|
62066
|
-
|
|
62067
|
-
|
|
62068
|
-
|
|
62069
|
-
|
|
62070
|
-
|
|
62071
|
-
|
|
62072
|
-
|
|
62073
|
-
|
|
62074
|
-
|
|
62075
|
-
|
|
62076
|
-
|
|
62077
|
-
if (
|
|
62078
|
-
|
|
62079
|
-
|
|
62080
|
-
|
|
62081
|
-
|
|
62049
|
+
const buildChains = (value, assignment) => {
|
|
62050
|
+
const chains2 = { x: null, y: null };
|
|
62051
|
+
const chainResidual = { x: 0, y: 0 };
|
|
62052
|
+
const members = { x: null, y: null };
|
|
62053
|
+
const anchorElementIds = [];
|
|
62054
|
+
let implausible = false;
|
|
62055
|
+
for (const { family, axes } of ordered) {
|
|
62056
|
+
const seats = args.familyTexts.get(family.familyId) ?? EMPTY_SEATING;
|
|
62057
|
+
if (!seats.seats.length) continue;
|
|
62058
|
+
let chain2 = null;
|
|
62059
|
+
let sawImplausible = false;
|
|
62060
|
+
let trims = 0;
|
|
62061
|
+
const longestFirst = (a, b) => b.length - a.length || a[0].i - b[0].i || byCodeUnit(a[0].textId, b[0].textId);
|
|
62062
|
+
for (const row of seats.rows) {
|
|
62063
|
+
const queue = tilingRuns(row, assignment, family.familyId);
|
|
62064
|
+
while (queue.length) {
|
|
62065
|
+
const members2 = queue.shift();
|
|
62066
|
+
const fromPt2 = axes[members2[0].i].atRaw;
|
|
62067
|
+
const toPt2 = axes[members2[members2.length - 1].j].atRaw;
|
|
62068
|
+
const used = new Set(members2.map((m) => m.textId));
|
|
62069
|
+
let acrossLo = Infinity;
|
|
62070
|
+
let acrossHi = -Infinity;
|
|
62071
|
+
for (const m of members2) {
|
|
62072
|
+
const seat2 = seats.byId.get(m.textId);
|
|
62073
|
+
acrossLo = Math.min(acrossLo, seat2.acrossPt);
|
|
62074
|
+
acrossHi = Math.max(acrossHi, seat2.acrossPt);
|
|
62075
|
+
}
|
|
62076
|
+
let barrier = null;
|
|
62077
|
+
for (const seat2 of seats.seats) {
|
|
62078
|
+
if (used.has(seat2.textId)) continue;
|
|
62079
|
+
if (!(seat2.alongPt > fromPt2 && seat2.alongPt < toPt2)) continue;
|
|
62080
|
+
if (!(seat2.acrossPt > acrossLo - BARRIER_TOL_PT && seat2.acrossPt < acrossHi + BARRIER_TOL_PT)) continue;
|
|
62081
|
+
if (!barrier || seat2.alongPt < barrier.alongPt || seat2.alongPt === barrier.alongPt && byCodeUnit(seat2.textId, barrier.textId) < 0) barrier = seat2;
|
|
62082
|
+
}
|
|
62083
|
+
if (!barrier) {
|
|
62084
|
+
if (members2.some((m) => {
|
|
62085
|
+
const mm3 = mmUnder(m, unit2);
|
|
62086
|
+
return mm3 < MIN_BAY_MM || mm3 > MAX_BAY_MM;
|
|
62087
|
+
})) {
|
|
62088
|
+
sawImplausible = true;
|
|
62089
|
+
continue;
|
|
62090
|
+
}
|
|
62091
|
+
const totalMm = members2.reduce((sum2, m) => sum2 + mmUnder(m, unit2), 0);
|
|
62092
|
+
const residual = members2.reduce((sum2, m) => sum2 + Math.abs(mmUnder(m, unit2) / value - m.spanPt), 0);
|
|
62093
|
+
const found = { from: members2[0].i, to: members2[members2.length - 1].j, totalMm, members: members2, residual };
|
|
62094
|
+
if (!chain2 || found.members.length > chain2.members.length || found.members.length === chain2.members.length && found.residual < chain2.residual) chain2 = found;
|
|
62082
62095
|
continue;
|
|
62083
62096
|
}
|
|
62084
|
-
|
|
62085
|
-
|
|
62086
|
-
|
|
62087
|
-
|
|
62097
|
+
if (chain2 && members2.length <= chain2.members.length) continue;
|
|
62098
|
+
if (trims >= MAX_RUN_TRIMS) continue;
|
|
62099
|
+
trims += 1;
|
|
62100
|
+
const at = barrier.alongPt;
|
|
62101
|
+
for (const half of [
|
|
62102
|
+
members2.filter((m) => axes[m.j].atRaw <= at),
|
|
62103
|
+
members2.filter((m) => axes[m.i].atRaw >= at)
|
|
62104
|
+
]) {
|
|
62105
|
+
if (half.length >= MIN_CHAIN) queue.push(half);
|
|
62106
|
+
}
|
|
62107
|
+
queue.sort(longestFirst);
|
|
62088
62108
|
}
|
|
62089
|
-
|
|
62090
|
-
|
|
62091
|
-
|
|
62092
|
-
|
|
62093
|
-
|
|
62094
|
-
|
|
62095
|
-
|
|
62096
|
-
|
|
62109
|
+
}
|
|
62110
|
+
if (!chain2) {
|
|
62111
|
+
implausible = implausible || sawImplausible;
|
|
62112
|
+
continue;
|
|
62113
|
+
}
|
|
62114
|
+
const memberSpansMm = chain2.members.map((h) => mmUnder(h, unit2));
|
|
62115
|
+
const fromLabel = axes[chain2.from].label;
|
|
62116
|
+
const toLabel = axes[chain2.to].label;
|
|
62117
|
+
if (!usableLabel(fromLabel) || !usableLabel(toLabel)) continue;
|
|
62118
|
+
const fromPt = axes[chain2.from].atRaw;
|
|
62119
|
+
const toPt = axes[chain2.to].atRaw;
|
|
62120
|
+
const runPt = toPt - fromPt;
|
|
62121
|
+
const memberIds = new Set(chain2.members.map((m) => m.textId));
|
|
62122
|
+
const centreAllowance = Math.max(runPt * ANCHOR_CENTRE_FRAC, ANCHOR_CENTRE_MIN_PT);
|
|
62123
|
+
const seatOf = seats.byId;
|
|
62124
|
+
const anchor = printed.filter((p) => {
|
|
62125
|
+
const mm3 = p.explicitUnit === "mm" ? p.magnitude : p.magnitude * (unit2 === "cm" ? 10 : 1);
|
|
62126
|
+
if (mm3 !== chain2.totalMm || Math.abs(mm3 / value - runPt) > METRIC_INLIER_TOL_PT) return false;
|
|
62127
|
+
if (memberIds.has(p.id)) return false;
|
|
62128
|
+
const seat2 = seatOf.get(p.id);
|
|
62129
|
+
return !!seat2 && Math.abs(seat2.alongPt - (fromPt + toPt) / 2) <= centreAllowance;
|
|
62130
|
+
}).sort((a, b) => byCodeUnit(a.id, b.id))[0] ?? null;
|
|
62131
|
+
if (anchor) anchorElementIds.push(anchor.id);
|
|
62132
|
+
const evidence = {
|
|
62133
|
+
familyId: family.familyId,
|
|
62134
|
+
fromLabel,
|
|
62135
|
+
toLabel,
|
|
62136
|
+
length: chain2.members.length,
|
|
62137
|
+
worldTotalMm: chain2.totalMm,
|
|
62138
|
+
anchoredByOverall: anchor !== null,
|
|
62139
|
+
anchorElementId: anchor ? anchor.id : null,
|
|
62140
|
+
memberSpansMm: memberSpansMm.slice(0, MAX_CHAIN_MEMBERS)
|
|
62141
|
+
};
|
|
62142
|
+
const held2 = family.axis === "x" ? chains2.x : chains2.y;
|
|
62143
|
+
const heldResidual = family.axis === "x" ? chainResidual.x : chainResidual.y;
|
|
62144
|
+
if (!held2 || evidence.length > held2.length || evidence.length === held2.length && chain2.residual < heldResidual) {
|
|
62145
|
+
if (family.axis === "x") {
|
|
62146
|
+
chains2.x = evidence;
|
|
62147
|
+
chainResidual.x = chain2.residual;
|
|
62148
|
+
members.x = chain2.members;
|
|
62149
|
+
} else {
|
|
62150
|
+
chains2.y = evidence;
|
|
62151
|
+
chainResidual.y = chain2.residual;
|
|
62152
|
+
members.y = chain2.members;
|
|
62097
62153
|
}
|
|
62098
|
-
queue.sort(longestFirst);
|
|
62099
62154
|
}
|
|
62100
62155
|
}
|
|
62101
|
-
|
|
62102
|
-
|
|
62103
|
-
|
|
62104
|
-
|
|
62105
|
-
|
|
62106
|
-
|
|
62107
|
-
|
|
62108
|
-
|
|
62109
|
-
const
|
|
62110
|
-
|
|
62111
|
-
|
|
62112
|
-
|
|
62113
|
-
|
|
62114
|
-
|
|
62115
|
-
|
|
62116
|
-
|
|
62117
|
-
|
|
62118
|
-
|
|
62119
|
-
|
|
62120
|
-
|
|
62121
|
-
|
|
62122
|
-
|
|
62123
|
-
|
|
62124
|
-
|
|
62125
|
-
|
|
62126
|
-
|
|
62127
|
-
length: chain2.members.length,
|
|
62128
|
-
worldTotalMm: chain2.totalMm,
|
|
62129
|
-
anchoredByOverall: anchor !== null,
|
|
62130
|
-
anchorElementId: anchor ? anchor.id : null,
|
|
62131
|
-
memberSpansMm: memberSpansMm.slice(0, MAX_CHAIN_MEMBERS)
|
|
62132
|
-
};
|
|
62133
|
-
if (family.axis === "x" && (!chains.x || evidence.length > chains.x.length)) chains.x = evidence;
|
|
62134
|
-
if (family.axis === "y" && (!chains.y || evidence.length > chains.y.length)) chains.y = evidence;
|
|
62135
|
-
}
|
|
62136
|
-
if (!chains.x && !chains.y) return implausible ? "span-implausible" : "no-chain";
|
|
62156
|
+
return { chains: chains2, chainResidual, members, anchorElementIds, implausible };
|
|
62157
|
+
};
|
|
62158
|
+
const admitted = buildChains(mmPerPx, refined);
|
|
62159
|
+
if (!admitted.chains.x && !admitted.chains.y) return admitted.implausible ? "span-implausible" : "no-chain";
|
|
62160
|
+
const chainMembers = [...admitted.members.x ?? [], ...admitted.members.y ?? []];
|
|
62161
|
+
let chainNumerator = 0;
|
|
62162
|
+
let chainDenominator = 0;
|
|
62163
|
+
for (const h of chainMembers) {
|
|
62164
|
+
const mm3 = mmUnder(h, unit2);
|
|
62165
|
+
chainNumerator += mm3 * h.spanPt;
|
|
62166
|
+
chainDenominator += mm3 * mm3;
|
|
62167
|
+
}
|
|
62168
|
+
if (!(chainDenominator > 0)) return null;
|
|
62169
|
+
const chainQ = chainNumerator / chainDenominator;
|
|
62170
|
+
if (!finite3(chainQ) || chainQ <= 0) return null;
|
|
62171
|
+
const emitted = round6(1 / chainQ);
|
|
62172
|
+
if (!finite3(emitted) || emitted <= 0 || emitted < lo || emitted > hi) return null;
|
|
62173
|
+
const atEmitted = selectPerText(hypotheses, unit2, emitted);
|
|
62174
|
+
const rebuilt = buildChains(emitted, atEmitted);
|
|
62175
|
+
if (!rebuilt.chains.x && !rebuilt.chains.y) return rebuilt.implausible ? "span-implausible" : "no-chain";
|
|
62176
|
+
const runIdentity = (members) => (members ?? []).map((m) => `${m.textId} ${m.familyId} ${m.i} ${m.j}`).join(" | ");
|
|
62177
|
+
if (runIdentity(rebuilt.members.x) !== runIdentity(admitted.members.x)) return null;
|
|
62178
|
+
if (runIdentity(rebuilt.members.y) !== runIdentity(admitted.members.y)) return null;
|
|
62179
|
+
const chains = rebuilt.chains;
|
|
62180
|
+
const unrounded = 1 / chainQ;
|
|
62181
|
+
const rankResidual = chainMembers.reduce((sum2, m) => sum2 + Math.abs(mmUnder(m, unit2) / unrounded - m.spanPt), 0);
|
|
62137
62182
|
return {
|
|
62138
62183
|
candidate: {
|
|
62139
62184
|
standard: `1:${ratio}`,
|
|
62140
62185
|
unit: unit2,
|
|
62141
62186
|
componentIndex,
|
|
62142
|
-
mmPerPx:
|
|
62143
|
-
plottedAtPct: Number((100 * nominal /
|
|
62144
|
-
stringsExplained:
|
|
62187
|
+
mmPerPx: emitted,
|
|
62188
|
+
plottedAtPct: Number((100 * nominal / emitted).toFixed(2)),
|
|
62189
|
+
stringsExplained: atEmitted.size,
|
|
62145
62190
|
chainX: chains.x ? chains.x.length : 0,
|
|
62146
62191
|
chainY: chains.y ? chains.y.length : 0,
|
|
62147
62192
|
componentsSurvived: 1
|
|
62148
62193
|
},
|
|
62149
62194
|
chains,
|
|
62150
|
-
evidenceElementIds: [...
|
|
62151
|
-
anchorElementIds: [...new Set(anchorElementIds)].sort(byCodeUnit),
|
|
62152
|
-
|
|
62195
|
+
evidenceElementIds: [...atEmitted.keys()].sort(byCodeUnit),
|
|
62196
|
+
anchorElementIds: [...new Set(rebuilt.anchorElementIds)].sort(byCodeUnit),
|
|
62197
|
+
chainResidual: rankResidual
|
|
62153
62198
|
};
|
|
62154
62199
|
}
|
|
62155
62200
|
function selectPerText(hypotheses, unit2, mmPerPx) {
|
|
@@ -62166,11 +62211,23 @@ function selectPerText(hypotheses, unit2, mmPerPx) {
|
|
|
62166
62211
|
for (const [id, held2] of best) out.set(id, held2.hypothesis);
|
|
62167
62212
|
return out;
|
|
62168
62213
|
}
|
|
62214
|
+
function compareChainScores(a, b) {
|
|
62215
|
+
const weaker = weakerChain(b) - weakerChain(a);
|
|
62216
|
+
if (weaker !== 0) return weaker;
|
|
62217
|
+
const stronger = strongerChain(b) - strongerChain(a);
|
|
62218
|
+
if (stronger !== 0) return stronger;
|
|
62219
|
+
if (fitOf(a) < fitOf(b)) return -1;
|
|
62220
|
+
if (fitOf(a) > fitOf(b)) return 1;
|
|
62221
|
+
return 0;
|
|
62222
|
+
}
|
|
62223
|
+
function orderSurvivors(a, b) {
|
|
62224
|
+
return compareChainScores(scoreOf(a), scoreOf(b));
|
|
62225
|
+
}
|
|
62169
62226
|
function rankSurvivors(a, b) {
|
|
62170
|
-
return
|
|
62227
|
+
return orderSurvivors(a, b) || byCodeUnit(survivorIdentity(a), survivorIdentity(b));
|
|
62171
62228
|
}
|
|
62172
62229
|
function separatesSurvivors(a, b) {
|
|
62173
|
-
return
|
|
62230
|
+
return orderSurvivors(a, b) !== 0;
|
|
62174
62231
|
}
|
|
62175
62232
|
function fitMetricScale(input) {
|
|
62176
62233
|
const empty = { leader: null, runnersUp: [], tied: [], hypothesesConsidered: 0 };
|
|
@@ -62274,7 +62331,7 @@ function fitMetricScale(input) {
|
|
|
62274
62331
|
continue;
|
|
62275
62332
|
}
|
|
62276
62333
|
if (components.length) sawInBand = true;
|
|
62277
|
-
components.sort((a, b) =>
|
|
62334
|
+
components.sort((a, b) => a.start - b.start || a.end - b.end);
|
|
62278
62335
|
const perReading = [];
|
|
62279
62336
|
components.forEach((component, componentIndex) => {
|
|
62280
62337
|
const built = buildCandidate({ component, componentIndex, ratio, unit: unit2, nominal, lo, hi, hypotheses, ordered, printed, familyTexts });
|
|
@@ -62302,7 +62359,7 @@ function fitMetricScale(input) {
|
|
|
62302
62359
|
if (sawInBand) {
|
|
62303
62360
|
return { ...empty, hypothesesConsidered: hypotheses.length, refusal: { code: "no-chain", detail: "dimension strings agree on a scale, but none of them form a run of consecutive bays, so there is no dimension chain to read this sheet from" } };
|
|
62304
62361
|
}
|
|
62305
|
-
return { ...empty, hypothesesConsidered: hypotheses.length, refusal: { code: "out-of-band", detail: `no scale within ${Math.round((MAX_PLOT_SCALING - 1) * 100)}% of a ratio this sheet prints
|
|
62362
|
+
return { ...empty, hypothesesConsidered: hypotheses.length, refusal: { code: "out-of-band", detail: `no scale within ${Math.round((MAX_PLOT_SCALING - 1) * 100)}% of a ratio this sheet prints has ${METRIC_MIN_INLIERS} or more of its dimension strings agreeing on it` } };
|
|
62306
62363
|
}
|
|
62307
62364
|
survivors.sort(rankSurvivors);
|
|
62308
62365
|
const best = survivors[0];
|
|
@@ -62334,7 +62391,7 @@ function fitMetricScale(input) {
|
|
|
62334
62391
|
hypothesesConsidered: hypotheses.length
|
|
62335
62392
|
};
|
|
62336
62393
|
}
|
|
62337
|
-
var METRIC_INLIER_TOL_PT, METRIC_MIN_INLIERS, METRIC_MIN_SPAN_PT, METRIC_MAX_ACROSS_PT, ROW_TOL_PT, BARRIER_TOL_PT, ANCHOR_CENTRE_FRAC, ANCHOR_CENTRE_MIN_PT, MAX_RUN_TRIMS, MAX_PLOT_SCALING, MIN_BAY_MM, MAX_BAY_MM, MAX_METRIC_RATIOS, MAX_RETAINED_COMPONENTS, MAX_METRIC_CANDIDATES, METRIC_UNITS_PER_RATIO, MAX_CHAIN_MEMBERS, MIN_CHAIN, MAX_AXIS_LABEL_CHARS, METRIC_MAX_AXES_PER_FAMILY, METRIC_MAX_HYPOTHESES, METRIC_RATIOS, PT_PER_INCH, MM_PER_PT_AT_1_TO_1, nominalMmPerPx, centreOf2, finite3, round6, mmUnder, usableLabel, EMPTY_SEATING, weakerChain, strongerChain, survivorIdentity;
|
|
62394
|
+
var METRIC_INLIER_TOL_PT, METRIC_MIN_INLIERS, METRIC_MIN_SPAN_PT, METRIC_MAX_ACROSS_PT, ROW_TOL_PT, BARRIER_TOL_PT, ANCHOR_CENTRE_FRAC, ANCHOR_CENTRE_MIN_PT, MAX_RUN_TRIMS, MAX_PLOT_SCALING, MIN_BAY_MM, MAX_BAY_MM, MAX_METRIC_RATIOS, MAX_RETAINED_COMPONENTS, MAX_METRIC_CANDIDATES, METRIC_UNITS_PER_RATIO, MAX_CHAIN_MEMBERS, MIN_CHAIN, MAX_AXIS_LABEL_CHARS, METRIC_MAX_AXES_PER_FAMILY, METRIC_MAX_HYPOTHESES, METRIC_RATIOS, PT_PER_INCH, MM_PER_PT_AT_1_TO_1, nominalMmPerPx, centreOf2, finite3, round6, mmUnder, usableLabel, EMPTY_SEATING, weakerChain, strongerChain, survivorIdentity, fitOf, scoreOf;
|
|
62338
62395
|
var init_steel_scale_metric = __esm({
|
|
62339
62396
|
"steel-scale-metric.ts"() {
|
|
62340
62397
|
"use strict";
|
|
@@ -62371,9 +62428,11 @@ var init_steel_scale_metric = __esm({
|
|
|
62371
62428
|
mmUnder = (h, unit2) => h.explicitUnit === "mm" ? h.magnitude : h.magnitude * (unit2 === "cm" ? 10 : 1);
|
|
62372
62429
|
usableLabel = (label2) => typeof label2 === "string" && label2.length > 0 && label2.length <= MAX_AXIS_LABEL_CHARS;
|
|
62373
62430
|
EMPTY_SEATING = Object.freeze({ seats: [], rows: [], byId: /* @__PURE__ */ new Map() });
|
|
62374
|
-
weakerChain = (s) => Math.min(s.
|
|
62375
|
-
strongerChain = (s) => Math.max(s.
|
|
62431
|
+
weakerChain = (s) => Math.min(s.chainX, s.chainY);
|
|
62432
|
+
strongerChain = (s) => Math.max(s.chainX, s.chainY);
|
|
62376
62433
|
survivorIdentity = (s) => `${s.candidate.standard} ${s.candidate.unit} ${String(s.candidate.componentIndex).padStart(4, "0")}`;
|
|
62434
|
+
fitOf = (s) => Number.isFinite(s.chainResidual) ? s.chainResidual : Infinity;
|
|
62435
|
+
scoreOf = (s) => ({ chainX: s.candidate.chainX, chainY: s.candidate.chainY, chainResidual: s.chainResidual });
|
|
62377
62436
|
}
|
|
62378
62437
|
});
|
|
62379
62438
|
|
|
@@ -64103,6 +64162,27 @@ function listLeases() {
|
|
|
64103
64162
|
function getLease(leaseId) {
|
|
64104
64163
|
return listLeases().find((l) => l.leaseId === leaseId) ?? null;
|
|
64105
64164
|
}
|
|
64165
|
+
function expectedLeasePresence(expectedLeaseId, canonicalCwd) {
|
|
64166
|
+
const file = (0, import_node_path20.join)(LEASE_DIR(), leaseKey(canonicalCwd));
|
|
64167
|
+
const pathState = (path) => {
|
|
64168
|
+
try {
|
|
64169
|
+
(0, import_node_fs24.statSync)(path);
|
|
64170
|
+
return "present";
|
|
64171
|
+
} catch (error) {
|
|
64172
|
+
return error?.code === "ENOENT" ? "absent" : "unknown";
|
|
64173
|
+
}
|
|
64174
|
+
};
|
|
64175
|
+
const primary = pathState(file);
|
|
64176
|
+
const backup = pathState(lastGoodPath(file));
|
|
64177
|
+
if (primary === "unknown" || backup === "unknown") return { state: "unreadable" };
|
|
64178
|
+
if (primary === "absent" && backup === "absent") return { state: "absent" };
|
|
64179
|
+
const lease = readAttributableLease(file);
|
|
64180
|
+
if (!lease) return { state: "unreadable" };
|
|
64181
|
+
if (lease.leaseId !== expectedLeaseId || leaseKey(lease.cwd) !== leaseKey(canonicalCwd)) {
|
|
64182
|
+
return { state: "mismatched", lease };
|
|
64183
|
+
}
|
|
64184
|
+
return { state: "present", lease };
|
|
64185
|
+
}
|
|
64106
64186
|
function leaseForToken(token2) {
|
|
64107
64187
|
if (typeof token2 !== "string" || !token2) return null;
|
|
64108
64188
|
const given = Buffer.from(token2);
|
|
@@ -64450,23 +64530,36 @@ function steelStreamBytesOf(pages) {
|
|
|
64450
64530
|
let total = 0;
|
|
64451
64531
|
for (const page of pages) {
|
|
64452
64532
|
const value = page.streamBytes;
|
|
64453
|
-
if (Number.isSafeInteger(value) && value >= 0) total
|
|
64533
|
+
if (Number.isSafeInteger(value) && value >= 0) total = saturatingAdd(total, value);
|
|
64454
64534
|
}
|
|
64455
|
-
return
|
|
64535
|
+
return total;
|
|
64456
64536
|
}
|
|
64457
64537
|
function steelExtractionBudgetMs(totalPages, sourceCount, sourceBytes, streamBytes = 0) {
|
|
64458
|
-
const
|
|
64459
|
-
const
|
|
64460
|
-
const
|
|
64461
|
-
|
|
64538
|
+
const pages = nonNegativeSafeInteger(totalPages);
|
|
64539
|
+
const sources = nonNegativeSafeInteger(sourceCount);
|
|
64540
|
+
const fileMib = Math.ceil(nonNegativeSafeInteger(sourceBytes) / MIB);
|
|
64541
|
+
const streamMib = Math.ceil(nonNegativeSafeInteger(streamBytes) / MIB);
|
|
64542
|
+
const sourceAllowance = saturatingMultiply(2e3, sources);
|
|
64543
|
+
const legacy = saturatingAdd(
|
|
64544
|
+
6e4,
|
|
64545
|
+
saturatingMultiply(15e3, pages),
|
|
64546
|
+
sourceAllowance,
|
|
64547
|
+
saturatingMultiply(1e3, fileMib)
|
|
64548
|
+
);
|
|
64549
|
+
const density = saturatingAdd(
|
|
64550
|
+
3e4,
|
|
64551
|
+
saturatingMultiply(8e3, streamMib),
|
|
64552
|
+
sourceAllowance
|
|
64553
|
+
);
|
|
64554
|
+
return clamp2(12e4, Math.max(legacy, density), STEEL_EXTRACTION_MAX_ATTEMPT_MS);
|
|
64462
64555
|
}
|
|
64463
64556
|
function steelOperationDeadlineAt(subprocessStartedAt) {
|
|
64464
64557
|
return subprocessStartedAt + STEEL_OPERATION_HARD_DEADLINE_MS;
|
|
64465
64558
|
}
|
|
64466
64559
|
function steelExtractionDeadlineAt(subprocessStartedAt, totalPages, sourceCount, sourceBytes, streamBytes = 0) {
|
|
64467
|
-
return
|
|
64468
|
-
|
|
64469
|
-
|
|
64560
|
+
return saturatingAdd(
|
|
64561
|
+
nonNegativeSafeInteger(subprocessStartedAt),
|
|
64562
|
+
steelExtractionBudgetMs(totalPages, sourceCount, sourceBytes, streamBytes)
|
|
64470
64563
|
);
|
|
64471
64564
|
}
|
|
64472
64565
|
function breachedScopes(counts2, bytes3, limits, perPage = { linework: counts2, text: [] }) {
|
|
@@ -64578,10 +64671,14 @@ function dropQuarantinedScriptDir(scriptDir) {
|
|
|
64578
64671
|
function readCleanupMarker(path) {
|
|
64579
64672
|
try {
|
|
64580
64673
|
const raw = JSON.parse((0, import_node_fs25.readFileSync)(path, "utf8"));
|
|
64581
|
-
if (raw.v !== 1 || !Number.isInteger(raw.pid) || raw.pid <= 0 || !Number.isFinite(raw.procStartedAt) || !Number.isInteger(raw.ownerPid) || raw.ownerPid <= 0 || !Number.isFinite(raw.ownerStartedAt) || raw.state !== "active" && raw.state !== "cleanup"
|
|
64674
|
+
if (raw.v !== 1 || !Number.isInteger(raw.pid) || raw.pid <= 0 || !Number.isFinite(raw.procStartedAt) || !Number.isInteger(raw.ownerPid) || raw.ownerPid <= 0 || !Number.isFinite(raw.ownerStartedAt) || raw.state !== "active" && raw.state !== "cleanup") {
|
|
64582
64675
|
return { state: "unknown", path };
|
|
64583
64676
|
}
|
|
64584
|
-
return {
|
|
64677
|
+
return {
|
|
64678
|
+
state: "valid",
|
|
64679
|
+
path,
|
|
64680
|
+
marker: { ...raw, expectedUntil: Number.isFinite(raw.expectedUntil) ? raw.expectedUntil : null }
|
|
64681
|
+
};
|
|
64585
64682
|
} catch {
|
|
64586
64683
|
return { state: "unknown", path };
|
|
64587
64684
|
}
|
|
@@ -64637,6 +64734,27 @@ function markCleanupState(pid, procStartedAt) {
|
|
|
64637
64734
|
if (read2.state !== "valid" || read2.marker.pid !== pid || read2.marker.procStartedAt !== procStartedAt) return;
|
|
64638
64735
|
durableReplace(path, JSON.stringify({ ...read2.marker, state: "cleanup" }), { mode: 384 });
|
|
64639
64736
|
}
|
|
64737
|
+
function cleanupRetryAfterMs(expectedUntil) {
|
|
64738
|
+
if (!Number.isFinite(expectedUntil) || expectedUntil <= Date.now()) return 1e4;
|
|
64739
|
+
return Math.max(1e3, Math.min(3e4, Math.round(expectedUntil - Date.now())));
|
|
64740
|
+
}
|
|
64741
|
+
function timeoutCleanupDisposition(pid, procStartedAt, contained) {
|
|
64742
|
+
if (contained) {
|
|
64743
|
+
clearCleanupMarker(pid, procStartedAt);
|
|
64744
|
+
return (0, import_node_fs25.existsSync)(cleanupMarkerPath(pid, procStartedAt)) ? { state: "blocked", retryAfterMs: null } : { state: "contained", retryAfterMs: 1e3 };
|
|
64745
|
+
}
|
|
64746
|
+
const path = cleanupMarkerPath(pid, procStartedAt);
|
|
64747
|
+
if (!(0, import_node_fs25.existsSync)(path)) return { state: "blocked", retryAfterMs: null };
|
|
64748
|
+
try {
|
|
64749
|
+
const raw = JSON.parse((0, import_node_fs25.readFileSync)(path, "utf8"));
|
|
64750
|
+
if (raw.v !== 1 || raw.pid !== pid || raw.procStartedAt !== procStartedAt || !Number.isInteger(raw.ownerPid) || raw.ownerPid <= 0 || !Number.isFinite(raw.ownerStartedAt) || raw.state !== "cleanup") {
|
|
64751
|
+
return { state: "blocked", retryAfterMs: null };
|
|
64752
|
+
}
|
|
64753
|
+
return { state: "pending", retryAfterMs: cleanupRetryAfterMs(Number.isFinite(raw.expectedUntil) ? raw.expectedUntil : null) };
|
|
64754
|
+
} catch {
|
|
64755
|
+
return { state: "blocked", retryAfterMs: null };
|
|
64756
|
+
}
|
|
64757
|
+
}
|
|
64640
64758
|
async function persistedCleanupPending() {
|
|
64641
64759
|
const reads = readCleanupMarkers();
|
|
64642
64760
|
if (reads.some((read2) => read2.state === "unknown")) throw new SteelFilterCleanupStateError();
|
|
@@ -64661,11 +64779,11 @@ async function persistedCleanupPending() {
|
|
|
64661
64779
|
continue;
|
|
64662
64780
|
}
|
|
64663
64781
|
if (marker.state === "cleanup") {
|
|
64664
|
-
const remaining2 =
|
|
64782
|
+
const remaining2 = cleanupRetryAfterMs(marker.expectedUntil);
|
|
64665
64783
|
return new SteelFilterCleanupPendingError(remaining2, "cleanup");
|
|
64666
64784
|
}
|
|
64667
64785
|
if (marker.ownerPid !== process.pid || Math.abs(marker.ownerStartedAt - serverStartedAt) >= 2e3) {
|
|
64668
|
-
const remaining2 =
|
|
64786
|
+
const remaining2 = cleanupRetryAfterMs(marker.expectedUntil);
|
|
64669
64787
|
return new SteelFilterCleanupPendingError(remaining2, "active");
|
|
64670
64788
|
}
|
|
64671
64789
|
}
|
|
@@ -64685,7 +64803,7 @@ async function executePython(script, input, options) {
|
|
|
64685
64803
|
for (const [pid, tracked] of unclosedPythonTrees) {
|
|
64686
64804
|
if (tracked.durableClaim) {
|
|
64687
64805
|
const stillClaimed = durableMarkers.some((marker) => marker.pid === pid && marker.procStartedAt === tracked.procStartedAt);
|
|
64688
|
-
if (!stillClaimed) {
|
|
64806
|
+
if (!stillClaimed && await killTreeAndVerify(pid, tracked.procStartedAt)) {
|
|
64689
64807
|
dropQuarantinedScriptDir(tracked.scriptDir);
|
|
64690
64808
|
unclosedPythonTrees.delete(pid);
|
|
64691
64809
|
}
|
|
@@ -64809,15 +64927,19 @@ async function executePython(script, input, options) {
|
|
|
64809
64927
|
let cleanupTimer;
|
|
64810
64928
|
let cleanupDeadlineAt;
|
|
64811
64929
|
let terminationOutcome;
|
|
64930
|
+
let terminationPromise;
|
|
64931
|
+
let terminationContained;
|
|
64812
64932
|
let timer;
|
|
64813
64933
|
const settleTermination = () => {
|
|
64814
64934
|
if (settled2 || !terminationOutcome) return;
|
|
64815
|
-
|
|
64816
|
-
|
|
64817
|
-
|
|
64935
|
+
const cleanup = child.pid ? timeoutCleanupDisposition(child.pid, procStartedAt, terminationContained) : { state: "contained", retryAfterMs: 1e3 };
|
|
64936
|
+
if (child.pid && cleanup.state === "contained") {
|
|
64937
|
+
unclosedPythonTrees.delete(child.pid);
|
|
64938
|
+
dropScriptDir();
|
|
64939
|
+
}
|
|
64818
64940
|
settled2 = true;
|
|
64819
64941
|
if (terminationOutcome === "timeout") {
|
|
64820
|
-
reject2(new SteelFilterTimeoutError(options.phase, Math.max(0, Math.round(now2() - started)), timeoutMs, options.workload, child.pid));
|
|
64942
|
+
reject2(new SteelFilterTimeoutError(options.phase, Math.max(0, Math.round(now2() - started)), timeoutMs, options.workload, child.pid, cleanup));
|
|
64821
64943
|
} else if (terminationOutcome === "stdout") {
|
|
64822
64944
|
reject2(new SteelFilterOutputTooLargeError());
|
|
64823
64945
|
} else {
|
|
@@ -64842,7 +64964,17 @@ async function executePython(script, input, options) {
|
|
|
64842
64964
|
cleanupDeadlineAt = Date.now() + (options.cleanupTimeoutMs ?? 1e4);
|
|
64843
64965
|
cleanupTimer = setTimeout(settleTermination, options.cleanupTimeoutMs ?? 1e4);
|
|
64844
64966
|
cleanupTimer.unref?.();
|
|
64845
|
-
|
|
64967
|
+
terminationPromise = Promise.resolve(terminate(child)).catch(() => false);
|
|
64968
|
+
void terminationPromise.then((contained) => {
|
|
64969
|
+
terminationContained = contained;
|
|
64970
|
+
if (!contained) return;
|
|
64971
|
+
if (child.pid) {
|
|
64972
|
+
unclosedPythonTrees.delete(child.pid);
|
|
64973
|
+
clearCleanupMarker(child.pid, procStartedAt);
|
|
64974
|
+
dropScriptDir();
|
|
64975
|
+
}
|
|
64976
|
+
if (!settled2) settleTermination();
|
|
64977
|
+
});
|
|
64846
64978
|
};
|
|
64847
64979
|
child.on("error", (error) => {
|
|
64848
64980
|
spawnError = error;
|
|
@@ -64868,7 +65000,7 @@ async function executePython(script, input, options) {
|
|
|
64868
65000
|
child.on("close", async (code, signal) => {
|
|
64869
65001
|
clearTimeout(timer);
|
|
64870
65002
|
const containmentRequired = timerWon || streamOverflow !== null;
|
|
64871
|
-
const containment = containmentRequired ? Promise.resolve(terminate(child)) : Promise.resolve(true);
|
|
65003
|
+
const containment = containmentRequired ? terminationPromise ?? Promise.resolve(terminate(child)).catch(() => false) : Promise.resolve(true);
|
|
64872
65004
|
let deadlineTimer;
|
|
64873
65005
|
const raced = containmentRequired && cleanupDeadlineAt !== void 0 ? await Promise.race([
|
|
64874
65006
|
containment.then((contained) => ({ kind: "contained", contained })),
|
|
@@ -64892,6 +65024,7 @@ async function executePython(script, input, options) {
|
|
|
64892
65024
|
return;
|
|
64893
65025
|
}
|
|
64894
65026
|
const treeContained = raced.contained;
|
|
65027
|
+
terminationContained = treeContained;
|
|
64895
65028
|
if (cleanupTimer) clearTimeout(cleanupTimer);
|
|
64896
65029
|
if (child.pid && treeContained) {
|
|
64897
65030
|
unclosedPythonTrees.delete(child.pid);
|
|
@@ -64901,7 +65034,10 @@ async function executePython(script, input, options) {
|
|
|
64901
65034
|
if (settled2) return;
|
|
64902
65035
|
settled2 = true;
|
|
64903
65036
|
const elapsedMs = Math.max(0, Math.round(now2() - started));
|
|
64904
|
-
if (timerWon)
|
|
65037
|
+
if (timerWon) {
|
|
65038
|
+
const cleanup = child.pid ? timeoutCleanupDisposition(child.pid, procStartedAt, treeContained) : { state: "contained", retryAfterMs: 1e3 };
|
|
65039
|
+
return reject2(new SteelFilterTimeoutError(options.phase, elapsedMs, timeoutMs, options.workload, child.pid, cleanup));
|
|
65040
|
+
}
|
|
64905
65041
|
const error = streamError ?? spawnError;
|
|
64906
65042
|
if (error) {
|
|
64907
65043
|
if (streamOverflow === "stdout" && isStdoutTooLarge(error)) return reject2(new SteelFilterOutputTooLargeError());
|
|
@@ -65201,7 +65337,7 @@ async function inspectSteelSourcePages(sources, options = {}) {
|
|
|
65201
65337
|
return row;
|
|
65202
65338
|
});
|
|
65203
65339
|
}
|
|
65204
|
-
var import_node_child_process6, import_node_crypto19, import_node_fs25, import_promises, import_node_os18, import_node_path21, PYTHON, PAGE_INSPECTOR, STEEL_FILTER_EXTRACTOR_PYTHON, SteelFilterBudgetError, SteelFilterOutputTooLargeError, MIB, clamp2, STEEL_OPERATION_HARD_DEADLINE_MS, SteelFilterTimeoutError, SteelFilterProcessError, SteelFilterCleanupPendingError, SteelFilterCleanupStateError, STEEL_FILTER_MAX_STDOUT_BYTES, STEEL_FILTER_MAX_OUTPUT_BYTES, STEEL_FILTER_BUDGET_LIMITS, unclosedPythonTrees, cleanupMarkerDir, cleanupMarkerPath, RFI_DRAWING_SVG, RfiDrawingRenderError, MAX_RFI_DRAWING_SOURCE_BYTES, RFI_DRAWING_READ_CHUNK_BYTES, RFI_DRAWING_SNAPSHOT_PREFIX, rfiDrawingRenderTail, available;
|
|
65340
|
+
var import_node_child_process6, import_node_crypto19, import_node_fs25, import_promises, import_node_os18, import_node_path21, PYTHON, PAGE_INSPECTOR, STEEL_FILTER_EXTRACTOR_PYTHON, SteelFilterBudgetError, SteelFilterOutputTooLargeError, MIB, clamp2, nonNegativeSafeInteger, saturatingMultiply, saturatingAdd, STEEL_EXTRACTION_MAX_ATTEMPT_MS, STEEL_OPERATION_HARD_DEADLINE_MS, SteelFilterTimeoutError, SteelFilterProcessError, SteelFilterCleanupPendingError, SteelFilterCleanupStateError, STEEL_FILTER_MAX_STDOUT_BYTES, STEEL_FILTER_MAX_OUTPUT_BYTES, STEEL_FILTER_BUDGET_LIMITS, unclosedPythonTrees, cleanupMarkerDir, cleanupMarkerPath, RFI_DRAWING_SVG, RfiDrawingRenderError, MAX_RFI_DRAWING_SOURCE_BYTES, RFI_DRAWING_READ_CHUNK_BYTES, RFI_DRAWING_SNAPSHOT_PREFIX, rfiDrawingRenderTail, available;
|
|
65205
65341
|
var init_steel_filter_prepass = __esm({
|
|
65206
65342
|
"steel-filter-prepass.ts"() {
|
|
65207
65343
|
"use strict";
|
|
@@ -66209,15 +66345,35 @@ json.dump({"pages":pages}, sys.stdout, separators=(",", ":"))
|
|
|
66209
66345
|
};
|
|
66210
66346
|
MIB = 1024 * 1024;
|
|
66211
66347
|
clamp2 = (minimum, value, maximum) => Math.max(minimum, Math.min(maximum, value));
|
|
66348
|
+
nonNegativeSafeInteger = (value) => {
|
|
66349
|
+
if (Number.isNaN(value) || value <= 0) return 0;
|
|
66350
|
+
if (!Number.isFinite(value) || value >= Number.MAX_SAFE_INTEGER) return Number.MAX_SAFE_INTEGER;
|
|
66351
|
+
return Math.ceil(value);
|
|
66352
|
+
};
|
|
66353
|
+
saturatingMultiply = (left, right) => {
|
|
66354
|
+
if (left === 0 || right === 0) return 0;
|
|
66355
|
+
if (left > Math.floor(Number.MAX_SAFE_INTEGER / right)) return Number.MAX_SAFE_INTEGER;
|
|
66356
|
+
return left * right;
|
|
66357
|
+
};
|
|
66358
|
+
saturatingAdd = (...values2) => {
|
|
66359
|
+
let total = 0;
|
|
66360
|
+
for (const value of values2) {
|
|
66361
|
+
if (value >= Number.MAX_SAFE_INTEGER - total) return Number.MAX_SAFE_INTEGER;
|
|
66362
|
+
total += value;
|
|
66363
|
+
}
|
|
66364
|
+
return total;
|
|
66365
|
+
};
|
|
66366
|
+
STEEL_EXTRACTION_MAX_ATTEMPT_MS = 72e5;
|
|
66212
66367
|
STEEL_OPERATION_HARD_DEADLINE_MS = 36e4;
|
|
66213
66368
|
SteelFilterTimeoutError = class extends Error {
|
|
66214
|
-
constructor(phase2, elapsedMs, timeoutMs, workload, processId) {
|
|
66369
|
+
constructor(phase2, elapsedMs, timeoutMs, workload, processId, cleanup = { state: "contained", retryAfterMs: 1e3 }) {
|
|
66215
66370
|
super("Steel Filter preparation did not finish within the allowed time.");
|
|
66216
66371
|
this.phase = phase2;
|
|
66217
66372
|
this.elapsedMs = elapsedMs;
|
|
66218
66373
|
this.timeoutMs = timeoutMs;
|
|
66219
66374
|
this.workload = workload;
|
|
66220
66375
|
this.processId = processId;
|
|
66376
|
+
this.cleanup = cleanup;
|
|
66221
66377
|
this.name = "SteelFilterTimeoutError";
|
|
66222
66378
|
}
|
|
66223
66379
|
phase;
|
|
@@ -66225,6 +66381,7 @@ json.dump({"pages":pages}, sys.stdout, separators=(",", ":"))
|
|
|
66225
66381
|
timeoutMs;
|
|
66226
66382
|
workload;
|
|
66227
66383
|
processId;
|
|
66384
|
+
cleanup;
|
|
66228
66385
|
diagnosticId = (0, import_node_crypto19.randomUUID)();
|
|
66229
66386
|
};
|
|
66230
66387
|
SteelFilterProcessError = class extends Error {
|
|
@@ -83546,7 +83703,7 @@ function appVersion() {
|
|
|
83546
83703
|
return resolveVersion({
|
|
83547
83704
|
isSea: isSea2(),
|
|
83548
83705
|
sqVersionXml: readSqVersionXml(),
|
|
83549
|
-
define: true ? "0.138.
|
|
83706
|
+
define: true ? "0.138.2" : void 0,
|
|
83550
83707
|
pkgVersion: readPkgVersion()
|
|
83551
83708
|
});
|
|
83552
83709
|
}
|
|
@@ -83562,7 +83719,7 @@ function resolveChannel(s) {
|
|
|
83562
83719
|
function appChannel() {
|
|
83563
83720
|
return resolveChannel({
|
|
83564
83721
|
isSea: isSea2(),
|
|
83565
|
-
define: true ? "0.138.
|
|
83722
|
+
define: true ? "0.138.2" : void 0,
|
|
83566
83723
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
83567
83724
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
83568
83725
|
modulePath: process.argv[1]
|
|
@@ -86246,19 +86403,54 @@ var RUN_POLICY = {
|
|
|
86246
86403
|
},
|
|
86247
86404
|
"new-workflow": { runnable: false, why: "this one is a conversation \u2014 headless would talk to nobody" }
|
|
86248
86405
|
};
|
|
86406
|
+
function isRetryableRevisionPrepassResult(value) {
|
|
86407
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && value.ok === false && value.retryable === true;
|
|
86408
|
+
}
|
|
86249
86409
|
function steelPreparationTimeoutWhy(req) {
|
|
86250
86410
|
const base = "Steel Filter preparation timed out. Do not retry this request unchanged. Close it and attach a smaller drawing set.";
|
|
86251
86411
|
const detail = req.steelPreparationTimeout ?? req.run?.steelPreparationTimeout;
|
|
86252
86412
|
if (!detail || typeof detail.diagnosticId !== "string" || !/^[0-9a-f-]{36}$/i.test(detail.diagnosticId) || !["inspection", "evidence", "model"].includes(detail.phase) || !Number.isSafeInteger(detail.elapsedMs) || detail.elapsedMs < 0 || !Number.isSafeInteger(detail.timeoutMs) || detail.timeoutMs < 0 || !Number.isSafeInteger(detail.workload?.sourceCount) || detail.workload.sourceCount < 0) return base;
|
|
86253
86413
|
return `${base} Diagnostic ${detail.diagnosticId}; ${detail.phase} phase; ${detail.elapsedMs} ms of ${detail.timeoutMs} ms; ${detail.workload.sourceCount} source(s).`;
|
|
86254
86414
|
}
|
|
86255
|
-
function
|
|
86415
|
+
function hasRetryablePreparationRefusal(req) {
|
|
86256
86416
|
const authorities = [
|
|
86257
86417
|
...req.refusalCode === "steel-manifest-extraction-timeout" ? [req.steelPreparationTimeout] : [],
|
|
86258
86418
|
...req.run?.refusalCode === "steel-manifest-extraction-timeout" ? [req.run.steelPreparationTimeout] : []
|
|
86259
86419
|
];
|
|
86260
86420
|
const nonNegativeIntegerOrNull = (value) => value === null || Number.isSafeInteger(value) && Number(value) >= 0;
|
|
86261
|
-
return authorities.length > 0 && authorities.every((detail) => detail !== void 0 && detail !== null && typeof detail === "object" && !Array.isArray(detail) && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(detail.diagnosticId) && detail.phase === "inspection" && Number.isSafeInteger(detail.elapsedMs) && detail.elapsedMs >= 0 && Number.isSafeInteger(detail.timeoutMs) && detail.timeoutMs >= 0 && Number.isSafeInteger(detail.workload?.sourceCount) && detail.workload.sourceCount >= 0 && Number.isSafeInteger(detail.workload?.sourceBytes) && detail.workload.sourceBytes >= 0 && nonNegativeIntegerOrNull(detail.workload?.totalPageCount) && nonNegativeIntegerOrNull(detail.workload?.selectedPageCount));
|
|
86421
|
+
return authorities.length > 0 && authorities.every((detail) => detail !== void 0 && detail !== null && typeof detail === "object" && !Array.isArray(detail) && detail.cleanupState !== "blocked" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(detail.diagnosticId) && (detail.phase === "inspection" || detail.phase === "evidence" || detail.phase === "model") && Number.isSafeInteger(detail.elapsedMs) && detail.elapsedMs >= 0 && Number.isSafeInteger(detail.timeoutMs) && detail.timeoutMs >= 0 && Number.isSafeInteger(detail.workload?.sourceCount) && detail.workload.sourceCount >= 0 && Number.isSafeInteger(detail.workload?.sourceBytes) && detail.workload.sourceBytes >= 0 && nonNegativeIntegerOrNull(detail.workload?.totalPageCount) && nonNegativeIntegerOrNull(detail.workload?.selectedPageCount));
|
|
86422
|
+
}
|
|
86423
|
+
function hasPreparationInterruptionDiagnostic(req) {
|
|
86424
|
+
const detail = req.steelPreparationTimeout ?? req.run?.steelPreparationTimeout;
|
|
86425
|
+
if (!detail || typeof detail !== "object" || Array.isArray(detail)) return false;
|
|
86426
|
+
const nonNegativeIntegerOrNull = (value) => value === null || Number.isSafeInteger(value) && Number(value) >= 0;
|
|
86427
|
+
return (detail.cleanupState === void 0 || ["contained", "pending", "blocked"].includes(detail.cleanupState)) && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(detail.diagnosticId) && (detail.phase === "inspection" || detail.phase === "evidence" || detail.phase === "model") && Number.isSafeInteger(detail.elapsedMs) && detail.elapsedMs >= 0 && Number.isSafeInteger(detail.timeoutMs) && detail.timeoutMs >= 0 && Number.isSafeInteger(detail.workload?.sourceCount) && detail.workload.sourceCount >= 0 && Number.isSafeInteger(detail.workload?.sourceBytes) && detail.workload.sourceBytes >= 0 && nonNegativeIntegerOrNull(detail.workload?.totalPageCount) && nonNegativeIntegerOrNull(detail.workload?.selectedPageCount);
|
|
86428
|
+
}
|
|
86429
|
+
function hasBlockedPreparationCleanup(req) {
|
|
86430
|
+
const detail = req.steelPreparationTimeout ?? req.run?.steelPreparationTimeout;
|
|
86431
|
+
return hasPreparationInterruptionDiagnostic(req) && detail?.cleanupState === "blocked";
|
|
86432
|
+
}
|
|
86433
|
+
function steelPreparationEntryFor(req) {
|
|
86434
|
+
if (hasBlockedPreparationCleanup(req)) {
|
|
86435
|
+
return {
|
|
86436
|
+
allowed: false,
|
|
86437
|
+
state: "blocked",
|
|
86438
|
+
why: "the interrupted Steel Filter process could not be verified safe \u2014 check the prior process or restart FloLess before retrying"
|
|
86439
|
+
};
|
|
86440
|
+
}
|
|
86441
|
+
if (typeof req.steelManifestHash === "string" && req.steelManifestHash.length > 0) {
|
|
86442
|
+
return {
|
|
86443
|
+
allowed: false,
|
|
86444
|
+
state: "manifest-published",
|
|
86445
|
+
why: "Steel Filter extraction is complete \u2014 continue in the terminal AI that prepared it"
|
|
86446
|
+
};
|
|
86447
|
+
}
|
|
86448
|
+
return { allowed: true, state: "available" };
|
|
86449
|
+
}
|
|
86450
|
+
function preparationInterruptionDiagnosticText(req) {
|
|
86451
|
+
if (!hasPreparationInterruptionDiagnostic(req)) return null;
|
|
86452
|
+
const detail = req.steelPreparationTimeout ?? req.run?.steelPreparationTimeout;
|
|
86453
|
+
return `Diagnostic ${detail.diagnosticId}; ${detail.phase} phase; ${detail.elapsedMs} ms of ${detail.timeoutMs} ms; ${detail.workload.sourceCount} source(s).`;
|
|
86262
86454
|
}
|
|
86263
86455
|
function runEligibilityFor(req) {
|
|
86264
86456
|
const policy = policyFor(req.type);
|
|
@@ -86267,23 +86459,19 @@ function runEligibilityFor(req) {
|
|
|
86267
86459
|
return { runnable: false, why: "workflow tours are conversations \u2014 use Copy to continue in your terminal" };
|
|
86268
86460
|
}
|
|
86269
86461
|
if (req.type !== "revision-read") return { runnable: true, policy };
|
|
86270
|
-
const
|
|
86271
|
-
if (
|
|
86272
|
-
|
|
86273
|
-
runnable: false,
|
|
86274
|
-
why: steelPreparationTimeoutWhy(req)
|
|
86275
|
-
};
|
|
86276
|
-
}
|
|
86462
|
+
const preparationEntry = steelPreparationEntryFor(req);
|
|
86463
|
+
if (preparationEntry.state === "blocked") return { runnable: false, why: preparationEntry.why };
|
|
86464
|
+
const retryablePreparation = hasRetryablePreparationRefusal(req);
|
|
86277
86465
|
if (req.settledVersion !== void 0) {
|
|
86278
86466
|
return { runnable: false, why: "this drawing read already committed \u2014 FloLess is only retrying settlement cleanup" };
|
|
86279
86467
|
}
|
|
86280
86468
|
if (req.status === "staged") {
|
|
86281
86469
|
return { runnable: false, why: "this drawing read is complete and waiting for review in Drawing Filter" };
|
|
86282
86470
|
}
|
|
86283
|
-
if (req.status === "failed" && !
|
|
86471
|
+
if (req.status === "failed" && !retryablePreparation) {
|
|
86284
86472
|
return { runnable: false, why: "this drawing read failed \u2014 attach the drawing set again to retry" };
|
|
86285
86473
|
}
|
|
86286
|
-
if (req.status !== "pending" && !
|
|
86474
|
+
if (req.status !== "pending" && !retryablePreparation) {
|
|
86287
86475
|
return { runnable: false, why: "this drawing read has a status this version of FloLess cannot safely start \u2014 open Requests for details or update FloLess" };
|
|
86288
86476
|
}
|
|
86289
86477
|
if (req.prepassReady === true) {
|
|
@@ -86292,6 +86480,13 @@ function runEligibilityFor(req) {
|
|
|
86292
86480
|
why: req.filterCheckpointCurrent === true ? "this Drawing Filter is saved \u2014 continue the drawing read in the terminal AI that prepared it" : "this Drawing Filter is ready \u2014 review it and press Save filter, then continue in the terminal AI that prepared it"
|
|
86293
86481
|
};
|
|
86294
86482
|
}
|
|
86483
|
+
if (!preparationEntry.allowed) return { runnable: false, why: preparationEntry.why };
|
|
86484
|
+
if (!retryablePreparation && (req.refusalCode === "steel-manifest-extraction-timeout" || req.run?.refusalCode === "steel-manifest-extraction-timeout")) {
|
|
86485
|
+
return {
|
|
86486
|
+
runnable: false,
|
|
86487
|
+
why: steelPreparationTimeoutWhy(req)
|
|
86488
|
+
};
|
|
86489
|
+
}
|
|
86295
86490
|
if (!req.project || !req.appId || !Number.isInteger(req.baseVersion) || Number(req.baseVersion) <= 0) {
|
|
86296
86491
|
return { runnable: false, why: "this is the first drawing read for the project \u2014 your terminal AI must create the starting project checkpoint and wait for you to review and save the Drawing Filter" };
|
|
86297
86492
|
}
|
|
@@ -86432,8 +86627,8 @@ function registerRunRelay(app, deps, origin) {
|
|
|
86432
86627
|
return reply.send(jsonRpc(msg.id, toolRefusal(`no such tool: ${String(params?.name)}`)));
|
|
86433
86628
|
}
|
|
86434
86629
|
const durableRequest = deps.codex.getRequest(lease);
|
|
86435
|
-
const
|
|
86436
|
-
if (
|
|
86630
|
+
const retryablePreparation = hasRetryablePreparationRefusal(durableRequest ?? {});
|
|
86631
|
+
if (lease.terminalRefusalCode === "steel-manifest-extraction-timeout" || !retryablePreparation && durableRequest?.run?.refusalCode === "steel-manifest-extraction-timeout") {
|
|
86437
86632
|
completedRevisionPrepasses.add(lease.leaseId);
|
|
86438
86633
|
recordCodexTool(lease, params.name, "denied");
|
|
86439
86634
|
return reply.send(jsonRpc(msg.id, toolRefusal("Steel Filter preparation timed out. Do not retry this request unchanged. Close it and attach a smaller drawing set.")));
|
|
@@ -86445,8 +86640,10 @@ function registerRunRelay(app, deps, origin) {
|
|
|
86445
86640
|
activeRevisionPrepasses.add(lease.leaseId);
|
|
86446
86641
|
try {
|
|
86447
86642
|
const result = await deps.runRevisionPrepass(lease);
|
|
86448
|
-
|
|
86449
|
-
|
|
86643
|
+
if (!isRetryableRevisionPrepassResult(result)) {
|
|
86644
|
+
deps.markResolved(lease);
|
|
86645
|
+
completedRevisionPrepasses.add(lease.leaseId);
|
|
86646
|
+
}
|
|
86450
86647
|
recordCodexTool(lease, params.name, "allowed");
|
|
86451
86648
|
return reply.send(jsonRpc(msg.id, { content: [{ type: "text", text: boundedJson(result) }] }));
|
|
86452
86649
|
} catch (err2) {
|
|
@@ -86538,8 +86735,8 @@ function registerRunRelay(app, deps, origin) {
|
|
|
86538
86735
|
return reply.send(jsonRpc(msg.id, toolRefusal(`no such tool: ${String(params?.name)}`)));
|
|
86539
86736
|
}
|
|
86540
86737
|
const durableRequest = deps.codex?.getRequest(lease);
|
|
86541
|
-
const
|
|
86542
|
-
if (
|
|
86738
|
+
const retryablePreparation = hasRetryablePreparationRefusal(durableRequest ?? {});
|
|
86739
|
+
if (lease.terminalRefusalCode === "steel-manifest-extraction-timeout" || !retryablePreparation && durableRequest?.run?.refusalCode === "steel-manifest-extraction-timeout") {
|
|
86543
86740
|
completedRevisionPrepasses.add(lease.leaseId);
|
|
86544
86741
|
return reply.send(jsonRpc(msg.id, toolRefusal("Steel Filter preparation timed out. Do not retry this request unchanged. Close it and attach a smaller drawing set.")));
|
|
86545
86742
|
}
|
|
@@ -86547,8 +86744,10 @@ function registerRunRelay(app, deps, origin) {
|
|
|
86547
86744
|
activeRevisionPrepasses.add(lease.leaseId);
|
|
86548
86745
|
try {
|
|
86549
86746
|
const result = await deps.runRevisionPrepass(lease);
|
|
86550
|
-
|
|
86551
|
-
|
|
86747
|
+
if (!isRetryableRevisionPrepassResult(result)) {
|
|
86748
|
+
deps.markResolved(lease);
|
|
86749
|
+
completedRevisionPrepasses.add(lease.leaseId);
|
|
86750
|
+
}
|
|
86552
86751
|
return reply.send(jsonRpc(msg.id, { content: [{ type: "text", text: boundedJson(result) }] }));
|
|
86553
86752
|
} catch (err2) {
|
|
86554
86753
|
if (err2?.name === "SteelManifestTerminalRefusalPersistenceError") {
|
|
@@ -87104,7 +87303,7 @@ For an unbuilt-connection relationship question, a verified connection marker is
|
|
|
87104
87303
|
const messageHint = isInitialRead ? "<plain-English what was read>" : "<plain-English what changed>";
|
|
87105
87304
|
const vectorPost = `GET the current contract again and keep its ETag, then POST /api/projects/${req.project}/revision-read with { contract, message: "${messageHint}", requestId: "${req.id}" } and If-Match: <that current ETag>. The server derives the base version and source provenance from this queued request. The first completed vector drawing publishes History version 1; later reads stage a review and publish only after confirmation. Do NOT DELETE the request yourself. If you can't read the drawing, POST /api/projects/${req.project}/revision-requests/${req.id}/fail with { error }.`;
|
|
87106
87305
|
const post = `After Filter Save, GET /api/projects/${req.project}/revision-requests/${req.id}/steel-manifest and GET the current contract with its ETag. Preserve every server-owned id. Account for every manifest page, layer, human-excluded line weight and colour, candidate line, reference/detail/connection marker, and every new or changed joint in a closed steel-read/v6 attestation. Where the drawings genuinely do not tell you what something is, SAY SO rather than guessing or leaving it out: disposition "unresolved" on a layers[] or facetExclusions[] row, and kind "unreviewed" on a pageReviews[] row (still copying its real candidateShardHash), each with a note giving the reason a person needs. Each publishes the model with a question attached instead of refusing the read. "unresolved" never authorises the wholesale dismissal below, so every line failing an unresolved dimension still needs its own row. A candidate line you neither model nor write a row for no longer refuses the read either: it publishes as a question against its sheet. That is a gap RECORDED, not a line accounted for, and it is a worse outcome than saying "unresolved" \u2014 the question states how many lines and names a bounded sample of them per sheet, NEVER all of them, so lines you leave out can reach the user as a number nobody can trace back to a drawing. Account for every line; leave silence as what happens when you fail to, not as a way of working. An endpoint elevation the drawings do not settle is submitted {"unknown":true} with why (one sentence on what the set does say) and checked ([{sourceHash,pageId,sheet}] for the pages you read): that publishes with a question attached, while an unknown carrying neither is refused. The SERVER then places that endpoint at the elevation of the plan it was read from and marks it {known, assumed:true, why, checked}, so the member is BUILT and visible instead of dropping out of the model, and the question still reaches the user. You may NOT write assumed yourself - it is the server saying it could not prove a height, and a reader that stamped its own number with it would be claiming server authority for a guess. Submit unknown and let the server place it. It follows that a plan view any member is read from MUST state its own elevation_mm: without one there is nowhere to place that member, so if you cannot establish a plan view elevation from the set, ASK THE USER for it before you read members from that sheet - one question per view, not one per member. The manifest response carries derived fields you cannot compute yourself and must copy exactly: pageShards (one candidateShardHash per page \u2014 give every page exactly one { pageId, kind: "whole" or "unreviewed", candidateShardHash, note } pageReview, and never a second one), layerLineCounts (each layers[] row states its own { model, evidence } lineCounts, verified against the server's ledger), dismissibleFacetValues (every { dim, value } the human excluded \u2014 each thickness or color one needs exactly one facetExclusions[] row; layer ones are covered by layers[] instead), facetLineCounts (copy the matching { model, evidence } into that row's lineCounts; a dismissible value with no row there carries zero lines, so state zeros rather than omitting it), and referenceCandidates (every element owing a references[] row \u2014 decided by its text, so detail/connection markers count too, never a candidate-kind filter). The response also carries scaleProposals: one row per plan page, the server's deterministic reading of that sheet's OWN drawing scale, fitted over every printed dimension string between its grid bubbles rather than the two runs you would otherwise pick by eye. It is ADVISORY \u2014 you still author mm_per_px, and the two-control 2 pt proof is unchanged and still required, so if a proposed value fails that proof the PROOF wins. Each row's outcome.action says what to do with it, and you follow that rather than deciding for yourself. "author": the sheet's dimensions settled it in both directions, so use outcome.mmPerPx and SAY SO in the chat, naming the standard and how many dimension strings agreed. Only an IMPERIAL sheet ever reaches this action; a metric one never does, however well its dimensions agree. "ask-and-confirm": SHOW THE USER that number and the sheet, and use it ONLY if they confirm. WHICH fact they are confirming depends on outcome.decidedBy, and describing the wrong one would say something untrue about the drawing. "printed-unverified" means only the printed title-block note claims a scale and the sheet's own dimensions do not corroborate it. "metric-unverified" is the opposite case, and it is metric: the sheet's dimension strings DO agree on a value, inside the band its own printed 1:N ratio opens, and it still needs confirming because nothing automatic can tell a genuine dimension chain apart from a coincidence assembled out of a neighbouring row of dimensions. On that arm quote outcome.standard, outcome.unit (whether the sheet's bare numbers were read as millimetres or centimetres \u2014 a real drawing set uses either), and outcome.plottedAtPct (how far the drawn content sits from that ratio, which is why a fixed table cannot read these sheets). Say whether outcome.chains.x and outcome.chains.y report anchoredByOverall: a printed overall dimension that matches the chain is the best corroboration the sheet offers, and its ABSENCE is the thing to say plainly when it is missing rather than a detail to skip. It is CORROBORATION AND NOT A VERDICT \u2014 it does not decide which reading the proposer chose, so do not present it as the reason the number is right. Name every outcome.runnersUp row too. A competing reading is now RARER than it was: the proposer reads each chain out of a single printed dimension row and refuses one that skips a dimension sitting alongside it, which removes most sub-multiple readings before they are ever reported. So an EMPTY runnersUp is the normal case and is not itself reassurance, while a row that does survive is a reading the drawing genuinely supports twice over \u2014 say so, and never as a footnote. An unconfirmed scale is never registered silently, because a world scale nobody checked must not reach a model with nothing recording that nobody checked it. "ask-and-wait": a real question, so put it in the chat naming the sheet and listing outcome.candidates -- each carries only its standard, its mmPerPx and how many dimension strings supported it, so quote THOSE and do not describe evidence you were not given. A metric sheet whose readings could not be separated carries outcome.metricCandidates INSTEAD, and those rows additionally carry the unit each reading assumes, so name the unit as well: "1:100 read in centimetres, or 1:10 read in millimetres" is the actual question, and dropping the unit makes it unanswerable. Then WAIT \u2014 the user may answer with a hand measurement of their own, and that is a legitimate scale you then author. "fallback-hand-fit": nothing the user could answer would help (the elements arrived carrying no ids, the sheet prints more different drawing ratios than this reader will weigh, or the work budget stopped that sheet), so derive the scale by hand exactly as you always have and do NOT put it to the user as a question \u2014 asking somebody to resolve a server budget is a question with no answer. "report-defect": the proposer itself failed on that sheet; say so rather than working around it. A row may ALSO carry bubbleTokenQuestion, and that one is INDEPENDENT of outcome.action - put it to the user even on "fallback-hand-fit", which silences the SCALE question and not this one. It means every circle on that sheet holding more than one text repeats the same token, so the grid can be read two ways and nothing in the drawing data settles which: the token may be a zone or building code drawn beside each grid reference (ISO 19650), or it may be the sheet a row of detail callouts points at. Ask ONE question naming the sheet, the token(s) and bubbleTokenQuestion.bubbleCount, and offer exactly these answers, which are mutually exclusive: one named candidate token is the CONTEXTUAL one to ignore when reading the remaining grid label; or DO NOT USE THESE CIRCLES AS GRID BUBBLES (they are callouts or something else) - say that rather than "this sheet has no grid", because the sheet may carry a grid elsewhere that this question is not about; or NEITHER, when the two texts together form one grid label or the office uses a convention neither answer describes, in which case ask the user what that convention is and follow it. Offer all three: a forced choice between two readings that are both wrong would put back the wrong grid this question exists to avoid. With two candidates ask which of them is contextual - never as two separate yes/no questions, because stripping one and stripping the other give grids that cannot both be right. Each candidate carries wouldRead: a PREVIEW of the grid that reading would give, labels only and no coordinates. SHOW it, never copy it as the grid - after the user answers, re-read the matching bubbles and their positions from the sheet itself. It is bounded, so say what is missing: whenever a family's labelsTotal exceeds the labels shown, or wouldReadTotal exceeds the families shown, state how many are not listed, and an empty wouldRead with a positive wouldReadTotal means the preview COULD NOT BE SHOWN (its labels are too long to carry), never that the reading yields nothing - a person deciding from four of five families without being told is deciding from evidence they believe is complete. WAIT for the answer before using any candidate label or the bubbles behind it; unrelated work on that sheet may go on only where it does not depend on which reading is right. Confirming a token settles the GRID and not the scale: you still derive mm_per_px yourself and the two-control 2 pt proof is unchanged. When scaleProposals is ABSENT entirely the manifest predates this and every scale is yours to derive by hand as before, while an EMPTY array means it ran and proposed nothing. If the response carries an unaccounted key, those derived fields are NOT all there to copy: this manifest holds pages its saved Drawing Filter cannot account for, so no line count folded from it would describe the drawing set, and unaccounted.withheld names EXACTLY which fields are absent. Do not invent them and do not attest a count you did not receive \u2014 the audit recomputes through the same fold and would block. Nothing else in the response has been narrowed: the manifest, pageShards, sourceSetDigest and referenceCandidates are all sound and still worth working from. Read unaccounted.questions instead: each row names a pageId, the sheets involved and a plain question. TELL THE USER IN THE CHAT about every row whose answerable is true \u2014 which page of the current set a sheet really is, which of two sheets claiming one page owns it, whether a drawing that has changed since the Filter was saved is the one to read \u2014 and act on the answer, which is normally to fix the Drawing Filter and Save it again, or to POST this request's /steel-manifest to regenerate the manifest. A row whose answerable is false is one no answer of the user's would settle, and its OWN why says what would \u2014 follow that, never one blanket remedy. Two shapes reach it: a page this drawing scan did not classify as a model page is fixed by RECLASSIFYING it in the Drawing Filter, and regenerating the manifest would reproduce the same classification and loop; a fault in the stored manifest (a candidate whose page is missing, whose element is unreadable, or whose kind disagrees with it) is fixed by POSTing this request's /steel-manifest to regenerate. Regeneration is not always available: it is refused with 409 revision-filter-prepared when this request has already published its Filter checkpoint and the saved Filter still matches the manifest's own copy of it. If that happens, STOP and tell the user what the questions say \u2014 do not retry, because nothing you can send will change that answer. Tell the user which of the two they are looking at, in that row's own terms. pageCount and candidateCount are the WHOLE population even when truncated is true and the list you were shown is shorter, so quote those numbers rather than counting the rows. For each resolved references[] row keep targetPageId. When the drawing identifies a specific destination detail, also state targetDetail: { tag, region } with the human-readable tag and the full detail-cell extent in manifest page coordinates; when the marker itself lies inside a detail, state that containing cell as sourceDetail: { tag, region }. A plan callout normally has no sourceDetail. A missing row may carry sourceDetail but never a target. These are reader observations: never substitute the small tag-text box for the detail cell, infer a cell from server geometry, or invent one on a raster/ambiguous sheet. Omit the locator and preserve the honest page-only reference instead. The server checks page ownership, raw bounds, whole-marker containment and repeated-locator consistency; it does not certify the semantic tag. Nonzero qualification or traversal capacity means transitive navigation is incomplete: say exact detail highlighting is unavailable for affected branches and never claim a fixed point. The response also carries exclusionBasis: when it is not "saved-filter" the human has not saved the Drawing Filter yet, dismissibleFacetValues and proofBudget are absent entirely, and there is nothing to build a proof against \u2014 wait for the Save. If the response's proofBudget says strained, one explicit row per line would not fit: this set only works if observations, the wholesale shorthand and grouping between them save enough bytes, so model what is genuinely a member, dismiss wholesale what the Filter authorises, group the rest by shared reason, and warn the human up front if none of that will be enough; impossible is a sound refusal but not a complete detector, so a set can pass it and still admit no proof that fits. If the response's proofBudget says impossible, stop: no proof over this Drawing Filter can fit the 8 MB cap however it is written, and the human has to switch more line weights off. Where many lines share one disposition and one reason, put them in a single lineDispositionGroups[] entry \u2014 { disposition, reason, elementIds: [...] }, plus one shared duplicateOf when the disposition is duplicate \u2014 instead of repeating the same sentence once per line. A line that needs a written disposition must appear EXACTLY ONCE, named literally, in either lineDispositions[] or one group, never in both (a line an observation accounts for, or one the rules below dismiss wholesale, belongs in neither): elementIds holds real ids and nothing else, there is no range, wildcard or "everything else", and a group's reason must be true of every line it names rather than of a typical one. Use a lineDispositions[] row when a reason is genuinely specific to one line, and keep THOSE concise because they are paid per line; a grouped reason is written once, so make it a full sentence worth reading. Prefer a modeling observation over any written disposition wherever a line is genuinely a member. A line the Filter does not select needs NO per-line disposition only when EVERY dimension it fails independently authorises that: the value is in dismissibleFacetValues AND you attested it annotation, existing or other (in layers[] for a layer, in facetExclusions[] for a line weight or colour; "unresolved" does NOT count). If even one failing dimension does not, that line needs its own row whatever the others say. When a valid-scale elevation or section observation traces a member but its view has no sourceRegistration, keep that member out of contract.members, keep its direct active observation and two endpoint-lineage rows in the contract, and add a viewFrameCandidates row with its id, profile, provenance, optional material / role / memberType, viewId, observationId, and exactly two { observationEnd, memberEnd, lineageId } endpoint identities. Send an empty viewFrameCandidates array when there are no such members. POST /api/projects/${req.project}/revision-read/audit with { requestId: "${req.id}", contract, viewFrameCandidates, attestation }; if that call itself is refused with code steel-attestation-invalid, act on THAT before anything else: its recovery names who must act and the one step they take, and its diagnosis names the exact version or keys. A blocked report is NOT a checklist to repeat until it goes green. Every blocking check carries recovery: an ordered list whose FIRST entry is the next step, each with an owner and an action. Take the heads of every blocking check and act on exactly one of them, in this order. Any head with owner "none" ends the request: relay its action and POST /fail - nobody can clear it and repeating cannot. Otherwise, if ANY head has owner "user", finish the run with outcome "needs-you" and ONE question carrying EVERY user-owned action together, and stop - do not re-submit, and do not do the reader or server work first, because a change the user makes to the drawing selection invalidates the scan built from it and the proof built from that. Otherwise act on the single highest-precedence remaining head, "server" before "reader": a "server" action is an API call this instruction names, and if it is refused - 409 revision-filter-prepared - nothing you send will change that answer, so relay it and POST /fail; a "reader" action is a repair to the contract or the attestation you submitted. After ANY of those, POST the audit again and re-read the heads: they are computed from the evidence you sent, so acting on a stale one repeats work that has already been undone. NEVER re-submit the same contract and attestation against an unchanged report - that is a loop, not a repair. source-accounting-floor shows why the owner matters rather than the check id: on a populated ledger it is a reader repair, and where the selection carries no linework at all it is not - no re-read can account for a line that is not there, and its route says whether a re-scan or a different drawing set is what is needed. The audit response carries audit.rfis: the questions this read could not settle, derived by the server -- you cannot author, merge or drop one. TELL THE USER ABOUT THEM IN THE CHAT before you move on, whether or not the read went through: group them by kind, lead with the ones that change the model most (a member with no elevation before a layer nobody could classify), name what each one is about the way a detailer would (the mark and the sheet, not an element id), and say how many there are in total when you summarise rather than listing hundreds. Each question carries at: WHERE it is, and you must SAY IT so the user can go and look -- {"where":"drawing"} names a page of audit.rfiPages by its pageIx, so quote that page's sheet and page number ("S-502, page 9"); role "detail" names a reader-identified destination cell, so quote its tag, sheet and page and say that bounded area is highlighted; role "supporting-reference" names a detail reached by following references from the direct detail, so call it supporting rather than direct; role "referenced-sheet" is the sheet a callout points AT rather than the callout itself, so say so ("referenced sheet S-502, from the callout on S-202") and never call it the detail -- nothing in the read proves which detail on that sheet it is; role "page" is a WHOLE SHEET with no rectangle on it, and which sheet depends on the question: on an unreviewed-page question it is the sheet NOBODY reviewed ("S-201 was never reviewed"), and on a question about a member it is a sheet you told the audit you CHECKED and could not settle it from ("checked S-201; nothing on it settles the size") -- never say the thing is drawn there, and never call an unreviewed sheet checked; {"where":"model"} names a member or connection the user can select in the editor; {"where":"filter"} is a Drawing Filter row for a question about a setting no line carries. A question about something the drawings never showed has only a model or filter target, and that is the honest answer -- say the set does not draw it rather than pointing at a page it is not on. Then offer to work through them: the user can give you the value, ask you to carry it as an RFI, or tell you to proceed on a stated assumption -- and every one of those ends with the member built. audit.rfisOmitted, when present, is how many questions did not fit the report; say that number rather than implying the list is complete. Publishing a model and saying nothing about its open questions is the one outcome this whole flow exists to prevent. Then, ONLY IF the audit came back with status "read-complete", POST the exact same contract and attestation to /api/projects/${req.project}/revision-read with { contract, viewFrameCandidates, attestation, message: "${messageHint}", requestId: "${req.id}" } and If-Match: <that exact ETag>. A blocked report never reaches this step: you have already taken its one next action above, or parked, or failed the request. A later read returns 202 for human review; when replacing an existing staged generation, also send If-Match-Stage with its exact stageId. Do NOT DELETE the request yourself. If you can't read the set, POST /api/projects/${req.project}/revision-requests/${req.id}/fail with { error }.`;
|
|
87107
|
-
const manifestPhase = `FIRST POST /api/projects/${req.project}/revision-requests/${req.id}/steel-manifest with {}; only it inventories pages and mints Filter ids. On sheet-identification-required, inspect listed pages, identify each, then retry with { bindings: [{ pageId, sheet, title?, evidenceKind }] }; never guess from other pages or build Filter geometry. On steel-manifest-preparation-busy,
|
|
87306
|
+
const manifestPhase = `FIRST POST /api/projects/${req.project}/revision-requests/${req.id}/steel-manifest with {}; only it inventories pages and mints Filter ids. On sheet-identification-required, inspect listed pages, identify each, then retry with { bindings: [{ pageId, sheet, title?, evidenceKind }] }; never guess from other pages or build Filter geometry. On steel-manifest-preparation-busy, steel-manifest-inspection-interrupted, or steel-manifest-extraction-interrupted, wait at least retryAfterMs and retry this step for the SAME request; the request, completed page identification, and drawing set remain attached. On steel-manifest-preparation-blocked, STOP and relay recovery; do not retry until an operator clears it. For an interruption, relay error and recovery, then phase, elapsed/limit, counts and diagnostic id; null page counts are unknown. Never relay commands, stderr, source, filenames, or paths. On steel-manifest-over-budget, STOP and relay recovery. Page scope: remove or split that dense sheet. Total scope: smaller revisions. Bytes scope is drawing-data weight, not element count: move or split the heaviest sheets first; one sheet over the limit cannot be isolated to help. Null scope means extraction overflowed before measurement: no breakdown; the set must be far smaller. Only complete true covers the whole set; with false or null the figures are lower bounds and the recovery may not suffice. On steel-manifest-extraction-failed, STOP and relay the diagnostic; an identical retry fails. Never rename Filter geometry or mint element ids.`;
|
|
87108
87307
|
if ((req.appTemplateId || req.appId) === "vectorize") {
|
|
87109
87308
|
if (isInitialRead) {
|
|
87110
87309
|
return `In floless project "${req.project}" (app "${req.appId}"), an initial drawing was attached \u2014 trace it into this project as its first version (do NOT create a new project). Vectorize the drawing per the floless-app-vectorize skill into a drawing.vector/v1 contract: emit clean, editable 2D vector geometry (sheets \u2192 elements: lines / polylines / curves / text, each on its layer), NOT steel members or a takeoff. A vector PDF is read deterministically (exact geometry, no guessing); a photo, scan or hand sketch is traced by a fenced vision extraction that flags every uncertain stroke (low confidence) for the user's review. ${vectorPost}${snaps}${note}`;
|
|
@@ -87299,6 +87498,23 @@ function requestClearPolicyFor(r) {
|
|
|
87299
87498
|
clearState: "lifecycle-owned"
|
|
87300
87499
|
};
|
|
87301
87500
|
}
|
|
87501
|
+
if (r.type === "revision-read") {
|
|
87502
|
+
const preparationEntry = steelPreparationEntryFor(r);
|
|
87503
|
+
if (preparationEntry.state === "blocked") {
|
|
87504
|
+
return {
|
|
87505
|
+
canClear: false,
|
|
87506
|
+
clearWhy: "FloLess could not verify that the earlier Steel Filter extractor stopped. Restart FloLess; if this remains blocked, follow the operator repair in Technical details.",
|
|
87507
|
+
clearState: "unavailable"
|
|
87508
|
+
};
|
|
87509
|
+
}
|
|
87510
|
+
if (preparationEntry.state === "manifest-published" && r.prepassReady !== true) {
|
|
87511
|
+
return {
|
|
87512
|
+
canClear: false,
|
|
87513
|
+
clearWhy: "Drawing preparation is complete and saved. Continue in the same terminal AI session to create the Drawing Filter before clearing this request.",
|
|
87514
|
+
clearState: "lifecycle-owned"
|
|
87515
|
+
};
|
|
87516
|
+
}
|
|
87517
|
+
}
|
|
87302
87518
|
if (r.type === "revision-read" && r.status === "staged" && r.steelAuditPolicy === 1) {
|
|
87303
87519
|
const release = requestReleasePolicyFor(r);
|
|
87304
87520
|
if (!release.canClear) return release;
|
|
@@ -87325,19 +87541,28 @@ function withPrompt(r, base = selfOrigin()) {
|
|
|
87325
87541
|
const prompt = instructionFor(r);
|
|
87326
87542
|
const marker = markerFor(r, base, prompt);
|
|
87327
87543
|
const eligibility = runEligibilityFor(r);
|
|
87328
|
-
const
|
|
87329
|
-
const
|
|
87330
|
-
const
|
|
87544
|
+
const preparationEntry = r.type === "revision-read" ? steelPreparationEntryFor(r) : null;
|
|
87545
|
+
const retryablePreparationRefusal = r.type === "revision-read" && hasRetryablePreparationRefusal(r);
|
|
87546
|
+
const preparationRetryable = r.type === "revision-read" && preparationEntry?.allowed === true && (retryablePreparationRefusal || r.status === "pending" && hasPreparationInterruptionDiagnostic(r));
|
|
87547
|
+
const terminalPreparationRefusal = !retryablePreparationRefusal && r.type === "revision-read" && (r.refusalCode === "steel-manifest-extraction-timeout" || r.run?.refusalCode === "steel-manifest-extraction-timeout");
|
|
87548
|
+
const retryableAttempt = r.type === "revision-read" && r.run !== void 0 && (["failed", "contract-violation", "exited-unresolved"].includes(r.run.state) || r.run.state === "interrupted" && preparationRetryable) && (r.run.refusalCode !== "steel-manifest-extraction-timeout" || retryablePreparationRefusal) && expectedLeasePresence(r.run.leaseId, r.run.cwd).state === "absent";
|
|
87331
87549
|
const hasAttempt = r.type === "revision-read" && r.run !== void 0 && !retryableAttempt || r.type === "guide" && r.run?.state === "answered";
|
|
87332
|
-
const projectedRun = r.type === "revision-read" && r.status !== "pending" && !
|
|
87550
|
+
const projectedRun = preparationRetryable && ["failed", "contract-violation", "exited-unresolved", "interrupted"].includes(r.run?.state || "") ? void 0 : r.type === "revision-read" && r.status !== "pending" && !retryablePreparationRefusal ? void 0 : r.run?.state === "answered" && !validatedInstructorAnswer(r) ? { ...r.run, state: "contract-violation", answer: void 0, lastOutput: "The stored Instructor answer failed validation." } : r.run;
|
|
87333
87551
|
const clearPolicy = requestClearPolicyFor(r);
|
|
87552
|
+
const activeRun2 = projectedRun?.state === "queued" || projectedRun?.state === "running";
|
|
87553
|
+
const canCopy = marker !== "" && !activeRun2 && (r.type !== "revision-read" || r.status === "pending" && r.prepassReady !== true && preparationEntry?.allowed === true);
|
|
87334
87554
|
return {
|
|
87335
87555
|
...r,
|
|
87556
|
+
status: retryablePreparationRefusal && r.status === "failed" ? "pending" : r.status,
|
|
87336
87557
|
run: projectedRun,
|
|
87337
87558
|
prompt,
|
|
87338
87559
|
marker: terminalPreparationRefusal ? "" : marker,
|
|
87560
|
+
preparationState: preparationEntry?.state ?? null,
|
|
87561
|
+
preparationRetryable,
|
|
87562
|
+
preparationDiagnostic: hasPreparationInterruptionDiagnostic(r) ? preparationInterruptionDiagnosticText(r) : null,
|
|
87339
87563
|
canRun: eligibility.runnable && !hasAttempt,
|
|
87340
87564
|
runWhy: eligibility.runnable ? null : eligibility.why,
|
|
87565
|
+
canCopy,
|
|
87341
87566
|
...clearPolicy,
|
|
87342
87567
|
resumeCommand: terminalPreparationRefusal ? null : resumeCommandForRequest(r),
|
|
87343
87568
|
desktopHandoffs: terminalPreparationRefusal ? null : desktopHandoffsForRequest(r, base, prompt, marker)
|
|
@@ -87360,6 +87585,10 @@ function withPrompt(r, base = selfOrigin()) {
|
|
|
87360
87585
|
run: projectedRun,
|
|
87361
87586
|
prompt: r.instruction ? String(r.instruction).trim() : "",
|
|
87362
87587
|
marker: "",
|
|
87588
|
+
preparationState: null,
|
|
87589
|
+
preparationRetryable: false,
|
|
87590
|
+
preparationDiagnostic: null,
|
|
87591
|
+
canCopy: false,
|
|
87363
87592
|
canRun: false,
|
|
87364
87593
|
runWhy: null,
|
|
87365
87594
|
...clearPolicy,
|
|
@@ -95281,9 +95510,11 @@ function normalizedSheet(value) {
|
|
|
95281
95510
|
function steelTimeoutBody(error) {
|
|
95282
95511
|
return {
|
|
95283
95512
|
ok: false,
|
|
95284
|
-
code: "steel-manifest-extraction-
|
|
95285
|
-
error: "Steel Filter preparation
|
|
95286
|
-
recovery: "
|
|
95513
|
+
code: "steel-manifest-extraction-interrupted",
|
|
95514
|
+
error: "Steel Filter preparation was interrupted before it finished.",
|
|
95515
|
+
recovery: "Retry this request with the same drawing set. FloLess kept the request and completed page identification attached.",
|
|
95516
|
+
retryAfterMs: error.cleanup.retryAfterMs,
|
|
95517
|
+
cleanupState: error.cleanup.state,
|
|
95287
95518
|
diagnosticId: error.diagnosticId,
|
|
95288
95519
|
phase: error.phase,
|
|
95289
95520
|
elapsedMs: error.elapsedMs,
|
|
@@ -95291,12 +95522,34 @@ function steelTimeoutBody(error) {
|
|
|
95291
95522
|
workload: error.workload
|
|
95292
95523
|
};
|
|
95293
95524
|
}
|
|
95525
|
+
function steelTimeoutCleanupBlockedBody(error) {
|
|
95526
|
+
return {
|
|
95527
|
+
ok: false,
|
|
95528
|
+
code: "steel-manifest-preparation-blocked",
|
|
95529
|
+
error: "FloLess could not verify that the interrupted Steel Filter process is safely contained.",
|
|
95530
|
+
recovery: "Check the prior Steel Filter process or restart FloLess. If no process remains, remove the stale steel-filter process claim before retrying.",
|
|
95531
|
+
diagnosticId: error.diagnosticId,
|
|
95532
|
+
phase: error.phase,
|
|
95533
|
+
cleanupState: error.cleanup.state
|
|
95534
|
+
};
|
|
95535
|
+
}
|
|
95536
|
+
function steelLifecycleBusyBody(error) {
|
|
95537
|
+
const retryAfterMs = error.busy.remainingMs && error.busy.remainingMs > 0 ? Math.max(1e3, Math.ceil(error.busy.remainingMs)) : 1e4;
|
|
95538
|
+
return {
|
|
95539
|
+
ok: false,
|
|
95540
|
+
code: "steel-manifest-preparation-busy",
|
|
95541
|
+
error: error.message,
|
|
95542
|
+
recovery: "Wait for the other drawing preparation to finish, then retry this same request.",
|
|
95543
|
+
retryAfterMs
|
|
95544
|
+
};
|
|
95545
|
+
}
|
|
95294
95546
|
function steelTimeoutDiagnostics(error) {
|
|
95295
95547
|
return {
|
|
95296
95548
|
diagnosticId: error.diagnosticId,
|
|
95297
95549
|
phase: error.phase,
|
|
95298
95550
|
elapsedMs: error.elapsedMs,
|
|
95299
95551
|
timeoutMs: error.timeoutMs,
|
|
95552
|
+
cleanupState: error.cleanup.state,
|
|
95300
95553
|
workload: error.workload
|
|
95301
95554
|
};
|
|
95302
95555
|
}
|
|
@@ -95317,12 +95570,13 @@ function storedSteelTimeoutDiagnostics(raw) {
|
|
|
95317
95570
|
const w = workload;
|
|
95318
95571
|
const integer = (candidate2) => Number.isSafeInteger(candidate2) && Number(candidate2) >= 0;
|
|
95319
95572
|
const nullable = (candidate2) => candidate2 === null || integer(candidate2);
|
|
95320
|
-
if (typeof value.diagnosticId !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value.diagnosticId) || !["inspection", "evidence", "model"].includes(String(value.phase)) || !integer(value.elapsedMs) || !integer(value.timeoutMs) || !integer(w.sourceCount) || !integer(w.sourceBytes) || !nullable(w.totalPageCount) || !nullable(w.selectedPageCount)) return null;
|
|
95573
|
+
if (typeof value.diagnosticId !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value.diagnosticId) || !["inspection", "evidence", "model"].includes(String(value.phase)) || !integer(value.elapsedMs) || !integer(value.timeoutMs) || value.cleanupState !== void 0 && !["contained", "pending", "blocked"].includes(String(value.cleanupState)) || !integer(w.sourceCount) || !integer(w.sourceBytes) || !nullable(w.totalPageCount) || !nullable(w.selectedPageCount)) return null;
|
|
95321
95574
|
return {
|
|
95322
95575
|
diagnosticId: value.diagnosticId,
|
|
95323
95576
|
phase: value.phase,
|
|
95324
95577
|
elapsedMs: value.elapsedMs,
|
|
95325
95578
|
timeoutMs: value.timeoutMs,
|
|
95579
|
+
...value.cleanupState === void 0 ? {} : { cleanupState: value.cleanupState },
|
|
95326
95580
|
workload: {
|
|
95327
95581
|
sourceCount: w.sourceCount,
|
|
95328
95582
|
sourceBytes: w.sourceBytes,
|
|
@@ -95986,16 +96240,46 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
95986
96240
|
return await withLifecycleLock("project", req.params.id, async () => {
|
|
95987
96241
|
const project = getProject(req.params.id);
|
|
95988
96242
|
let request = getRequest(req.params.reqId);
|
|
95989
|
-
const
|
|
96243
|
+
const resumableLegacyPreparation = request ? hasRetryablePreparationRefusal(request) : false;
|
|
95990
96244
|
const hasPreparationTimeoutAuthority = request?.refusalCode === "steel-manifest-extraction-timeout" || request?.run?.refusalCode === "steel-manifest-extraction-timeout";
|
|
95991
96245
|
if (!project || !request || request.type !== "revision-read" || request.project !== project.id || request.appId !== project.app || request.status !== "pending" && !hasPreparationTimeoutAuthority || request.settledVersion !== void 0) {
|
|
95992
96246
|
return reply.status(404).send({ ok: false, error: "unknown pending steel revision request" });
|
|
95993
96247
|
}
|
|
95994
|
-
|
|
96248
|
+
const preparationEntry = steelPreparationEntryFor(request);
|
|
96249
|
+
if (preparationEntry.state === "blocked") {
|
|
96250
|
+
return reply.status(409).send({
|
|
96251
|
+
ok: false,
|
|
96252
|
+
code: "steel-manifest-preparation-blocked",
|
|
96253
|
+
error: preparationEntry.why,
|
|
96254
|
+
recovery: "Restart FloLess, then open Requests. If preparation remains blocked, use the operator repair in Technical details."
|
|
96255
|
+
});
|
|
96256
|
+
}
|
|
96257
|
+
if (preparationEntry.state === "manifest-published" && request.prepassReady !== true) {
|
|
96258
|
+
const stored3 = readSteelReadManifest(request.id);
|
|
96259
|
+
if (!stored3 || stored3.manifestHash !== request.steelManifestHash || stored3.manifest.requestId !== request.id || stored3.manifest.projectId !== project.id || stored3.manifest.appId !== project.app) {
|
|
96260
|
+
return reply.status(409).send({
|
|
96261
|
+
ok: false,
|
|
96262
|
+
code: "steel-manifest-preparation-blocked",
|
|
96263
|
+
error: "the published Steel Filter manifest is missing, corrupt, or no longer belongs to this request",
|
|
96264
|
+
recovery: "Do not retry extraction. Restart FloLess and inspect this request before continuing."
|
|
96265
|
+
});
|
|
96266
|
+
}
|
|
96267
|
+
return {
|
|
96268
|
+
ok: true,
|
|
96269
|
+
manifestHash: stored3.manifestHash,
|
|
96270
|
+
etag: request.prepassEtag ?? null,
|
|
96271
|
+
requiresCheckpointCreate: true,
|
|
96272
|
+
pages: stored3.manifest.pages,
|
|
96273
|
+
filter: stored3.manifest.filter,
|
|
96274
|
+
...stored3.scaleProposals === void 0 ? {} : { scaleProposals: stored3.scaleProposals }
|
|
96275
|
+
};
|
|
96276
|
+
}
|
|
95995
96277
|
let refusalLease = null;
|
|
96278
|
+
let refusalLeasePresence = null;
|
|
95996
96279
|
if (request.run?.leaseId) {
|
|
95997
96280
|
try {
|
|
95998
|
-
|
|
96281
|
+
refusalLeasePresence = expectedLeasePresence(request.run.leaseId, request.run.cwd);
|
|
96282
|
+
refusalLease = refusalLeasePresence.state === "present" ? refusalLeasePresence.lease : null;
|
|
95999
96283
|
} catch {
|
|
96000
96284
|
return reply.status(409).send({
|
|
96001
96285
|
ok: false,
|
|
@@ -96005,59 +96289,57 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96005
96289
|
});
|
|
96006
96290
|
}
|
|
96007
96291
|
}
|
|
96008
|
-
if (
|
|
96009
|
-
const
|
|
96010
|
-
|
|
96011
|
-
|
|
96012
|
-
|
|
96292
|
+
if (resumableLegacyPreparation) {
|
|
96293
|
+
const migrationHead = listVersions(project.id)[0]?.n ?? 0;
|
|
96294
|
+
if ((request.baseVersion ?? 0) !== migrationHead) {
|
|
96295
|
+
return reply.status(409).send({ ok: false, code: "revision-base-changed", error: `project changed since this read started (base v${request.baseVersion ?? 0}, now v${migrationHead})` });
|
|
96296
|
+
}
|
|
96297
|
+
try {
|
|
96298
|
+
verifiedSteelSources(project.id, request);
|
|
96299
|
+
} catch {
|
|
96013
96300
|
return reply.status(409).send({
|
|
96014
96301
|
ok: false,
|
|
96015
|
-
code: "revision-
|
|
96016
|
-
error: "
|
|
96302
|
+
code: "revision-source-changed",
|
|
96303
|
+
error: "The drawing source no longer matches the interrupted request, so its legacy refusal cannot be migrated."
|
|
96017
96304
|
});
|
|
96018
96305
|
}
|
|
96019
|
-
|
|
96020
|
-
}
|
|
96021
|
-
if (resumableLegacyInspection && !ownedHeadlessRun && refusalLease?.terminalRefusalCode === "steel-manifest-extraction-timeout") {
|
|
96022
|
-
const rawToken = req.headers["x-floless-run-token"];
|
|
96023
|
-
const token2 = Array.isArray(rawToken) ? rawToken[0] : rawToken;
|
|
96024
|
-
const lease = typeof token2 === "string" ? leaseForToken(token2) : null;
|
|
96025
|
-
if (!lease || lease.leaseId !== request.run?.leaseId || lease.requestId !== request.id || lease.requestType !== "revision-read" || lease.project !== project.id || lease.appId !== project.app) {
|
|
96306
|
+
if (request.run?.leaseId && refusalLeasePresence?.state !== "absent") {
|
|
96026
96307
|
return reply.status(409).send({
|
|
96027
96308
|
ok: false,
|
|
96028
|
-
code: "revision-read-owned",
|
|
96029
|
-
error: "this interrupted drawing
|
|
96309
|
+
code: refusalLeasePresence?.state === "present" || refusalLeasePresence?.state === "mismatched" ? "revision-read-owned" : "revision-read-lifecycle-unavailable",
|
|
96310
|
+
error: refusalLeasePresence?.state === "present" || refusalLeasePresence?.state === "mismatched" ? "this interrupted drawing preparation is still owned by a terminal run \u2014 stop or recover that run before retrying" : "FloLess could not prove that the interrupted drawing preparation released its terminal run."
|
|
96030
96311
|
});
|
|
96031
96312
|
}
|
|
96032
|
-
|
|
96033
|
-
}
|
|
96034
|
-
if (resumableLegacyInspection && ownedHeadlessRun && refusalLease?.terminalRefusalCode === "steel-manifest-extraction-timeout") {
|
|
96035
|
-
let cleared = null;
|
|
96036
|
-
try {
|
|
96037
|
-
cleared = (deps.patchLease ?? patchLease)(refusalLease.leaseId, refusalLease.generation, { terminalRefusalCode: null });
|
|
96038
|
-
} catch {
|
|
96039
|
-
}
|
|
96040
|
-
if (!cleared) {
|
|
96313
|
+
if (request.run && (request.run.state === "queued" || request.run.state === "running" || request.run.processContained === false)) {
|
|
96041
96314
|
return reply.status(409).send({
|
|
96042
96315
|
ok: false,
|
|
96043
96316
|
code: "revision-read-lifecycle-unavailable",
|
|
96044
|
-
error: "FloLess
|
|
96045
|
-
recovery: "Restart FloLess, then open Requests before trying again."
|
|
96317
|
+
error: "FloLess has not proved that the interrupted terminal process is contained."
|
|
96046
96318
|
});
|
|
96047
96319
|
}
|
|
96048
|
-
|
|
96049
|
-
}
|
|
96050
|
-
if (resumableLegacyInspection) {
|
|
96320
|
+
const diagnostic = request.steelPreparationTimeout ?? request.run?.steelPreparationTimeout;
|
|
96051
96321
|
request = (deps.patchRequestDurable ?? patchRequestDurable)(request.id, {
|
|
96052
96322
|
status: "pending",
|
|
96053
96323
|
refusalCode: void 0,
|
|
96054
|
-
steelPreparationTimeout:
|
|
96324
|
+
steelPreparationTimeout: diagnostic,
|
|
96055
96325
|
error: void 0,
|
|
96056
|
-
...request.run ? { run: { ...request.run, refusalCode: void 0
|
|
96326
|
+
...request.run ? { run: { ...request.run, refusalCode: void 0 } } : {}
|
|
96057
96327
|
});
|
|
96058
|
-
if (!request) return reply.status(409).send({ ok: false, code: "revision-request-changed", error: "the drawing read changed while making its interrupted
|
|
96328
|
+
if (!request) return reply.status(409).send({ ok: false, code: "revision-request-changed", error: "the drawing read changed while making its interrupted preparation resumable" });
|
|
96059
96329
|
broadcast({ type: "requests-changed" });
|
|
96060
96330
|
}
|
|
96331
|
+
if (request.run && (request.run.state === "queued" || request.run.state === "running")) {
|
|
96332
|
+
const rawToken = req.headers["x-floless-run-token"];
|
|
96333
|
+
const token2 = Array.isArray(rawToken) ? rawToken[0] : rawToken;
|
|
96334
|
+
const lease = typeof token2 === "string" ? leaseForToken(token2) : null;
|
|
96335
|
+
if (!lease || lease.leaseId !== request.run.leaseId || lease.requestId !== request.id || lease.requestType !== "revision-read" || lease.project !== project.id || lease.appId !== project.app) {
|
|
96336
|
+
return reply.status(409).send({
|
|
96337
|
+
ok: false,
|
|
96338
|
+
code: "revision-read-owned",
|
|
96339
|
+
error: "this drawing read is already running \u2014 wait for it to prepare the Drawing Filter or stop it in Requests"
|
|
96340
|
+
});
|
|
96341
|
+
}
|
|
96342
|
+
}
|
|
96061
96343
|
const copiedTerminalRefusal = request.refusalCode === "steel-manifest-extraction-timeout";
|
|
96062
96344
|
if (copiedTerminalRefusal || request.run?.refusalCode === "steel-manifest-extraction-timeout" || refusalLease?.terminalRefusalCode === "steel-manifest-extraction-timeout") {
|
|
96063
96345
|
const diagnostics = storedSteelTimeoutDiagnostics(
|
|
@@ -96126,7 +96408,6 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96126
96408
|
}
|
|
96127
96409
|
inspectionEndedAt = now2();
|
|
96128
96410
|
subprocessStartedAt = now2();
|
|
96129
|
-
hardDeadline = steelOperationDeadlineAt(subprocessStartedAt);
|
|
96130
96411
|
} catch (error) {
|
|
96131
96412
|
if (error instanceof SteelFilterCleanupStateError) {
|
|
96132
96413
|
return reply.status(409).send({
|
|
@@ -96142,28 +96423,27 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96142
96423
|
}
|
|
96143
96424
|
if (error instanceof SteelFilterTimeoutError) {
|
|
96144
96425
|
req.log.warn({ projectId: project.id, requestId: request.id, diagnosticId: error.diagnosticId, phase: error.phase, elapsedMs: error.elapsedMs, timeoutMs: error.timeoutMs, ...error.workload }, "steel manifest preparation timed out");
|
|
96426
|
+
const written = (deps.patchRequestDurable ?? patchRequestDurable)(request.id, {
|
|
96427
|
+
status: "pending",
|
|
96428
|
+
refusalCode: void 0,
|
|
96429
|
+
steelPreparationTimeout: steelTimeoutDiagnostics(error),
|
|
96430
|
+
error: void 0
|
|
96431
|
+
});
|
|
96432
|
+
if (!written) return reply.status(409).send({ ok: false, code: "revision-request-changed", error: "the drawing read changed while recording its retryable interruption" });
|
|
96433
|
+
request = written;
|
|
96434
|
+
broadcast({ type: "requests-changed" });
|
|
96435
|
+
if (error.cleanup.state === "blocked") return reply.status(409).send(steelTimeoutCleanupBlockedBody(error));
|
|
96436
|
+
reply.header("Retry-After", String(Math.ceil(error.cleanup.retryAfterMs / 1e3)));
|
|
96145
96437
|
if (error.phase === "inspection") {
|
|
96146
|
-
reply.header("Retry-After", "1");
|
|
96147
96438
|
return reply.status(409).send({
|
|
96148
96439
|
...steelTimeoutBody(error),
|
|
96149
96440
|
code: "steel-manifest-inspection-interrupted",
|
|
96150
96441
|
error: "Drawing page inspection was interrupted before it finished.",
|
|
96151
96442
|
recovery: "Retry this request. FloLess will continue with the same drawing set.",
|
|
96152
|
-
retryAfterMs:
|
|
96153
|
-
});
|
|
96154
|
-
}
|
|
96155
|
-
if (!ownedHeadlessRun) {
|
|
96156
|
-
const body = steelTimeoutBody(error);
|
|
96157
|
-
const written = (deps.patchRequestDurable ?? patchRequestDurable)(request.id, {
|
|
96158
|
-
status: "failed",
|
|
96159
|
-
refusalCode: "steel-manifest-extraction-timeout",
|
|
96160
|
-
steelPreparationTimeout: steelTimeoutDiagnostics(error),
|
|
96161
|
-
error: `${body.error} ${body.recovery} Diagnostic id: ${body.diagnosticId}.`
|
|
96443
|
+
retryAfterMs: error.cleanup.retryAfterMs
|
|
96162
96444
|
});
|
|
96163
|
-
if (!written) return reply.status(409).send({ ok: false, code: "revision-request-changed", error: "the drawing read changed while recording its terminal refusal" });
|
|
96164
|
-
broadcast({ type: "requests-changed" });
|
|
96165
96445
|
}
|
|
96166
|
-
return reply.status(
|
|
96446
|
+
return reply.status(409).send(steelTimeoutBody(error));
|
|
96167
96447
|
}
|
|
96168
96448
|
if (error instanceof SteelFilterProcessError) {
|
|
96169
96449
|
req.log.warn({ projectId: project.id, requestId: request.id, diagnosticId: error.diagnosticId, phase: error.phase, category: error.category, exitCode: error.exitCode, signal: error.signal, stderrSha256: error.stderrSha256 }, "steel manifest source inspection refused");
|
|
@@ -96242,13 +96522,14 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96242
96522
|
const extractor = deps.extractSteelFilter ?? extractSteelFilter;
|
|
96243
96523
|
const sourceBytes = sources.manifestSources.reduce((sum2, source) => sum2 + source.bytes, 0);
|
|
96244
96524
|
const streamBytes = steelStreamBytesOf(inspected);
|
|
96525
|
+
const extractionBudgetMs = steelExtractionBudgetMs(inspected.length, sources.extractorSources.length, sourceBytes, streamBytes);
|
|
96245
96526
|
const extractionDeadline = steelExtractionDeadlineAt(subprocessStartedAt, inspected.length, sources.extractorSources.length, sourceBytes, streamBytes);
|
|
96246
96527
|
req.log.info({
|
|
96247
96528
|
projectId: project.id,
|
|
96248
96529
|
requestId: request.id,
|
|
96249
96530
|
deadlineMs: Math.round(extractionDeadline - subprocessStartedAt),
|
|
96250
|
-
|
|
96251
|
-
budgetMs:
|
|
96531
|
+
maxAttemptMs: STEEL_EXTRACTION_MAX_ATTEMPT_MS,
|
|
96532
|
+
budgetMs: extractionBudgetMs,
|
|
96252
96533
|
inspectionMs: Math.round(inspectionEndedAt - inspectionStartedAt),
|
|
96253
96534
|
// Logged beside the budget it selected, so a timeout can be read against the input that
|
|
96254
96535
|
// chose its deadline rather than leaving the reader to guess which arm won.
|
|
@@ -96273,22 +96554,29 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96273
96554
|
);
|
|
96274
96555
|
return Math.max(1, value);
|
|
96275
96556
|
};
|
|
96276
|
-
|
|
96277
|
-
|
|
96278
|
-
|
|
96279
|
-
|
|
96280
|
-
|
|
96281
|
-
|
|
96282
|
-
|
|
96283
|
-
|
|
96284
|
-
|
|
96285
|
-
|
|
96286
|
-
|
|
96287
|
-
|
|
96288
|
-
|
|
96289
|
-
|
|
96290
|
-
|
|
96557
|
+
await withLifecycleLock("steel-extraction", "global", async () => {
|
|
96558
|
+
const evidenceWorkload = workloadFor(pages.length);
|
|
96559
|
+
evidenceFilter = await extractor({
|
|
96560
|
+
sources: sources.extractorSources,
|
|
96561
|
+
plans: pages.map((_page, index) => ({ sheet: `E${index + 1}` })),
|
|
96562
|
+
pages: pages.map((page, index) => ({ sourceHash: page.sourceHash, page: page.page, sheet: `E${index + 1}` }))
|
|
96563
|
+
}, { phase: "evidence", timeoutMs: remaining2("evidence", evidenceWorkload), workload: evidenceWorkload });
|
|
96564
|
+
const modelWorkload = workloadFor(modelPages.length);
|
|
96565
|
+
filter = await extractor({
|
|
96566
|
+
sources: sources.extractorSources,
|
|
96567
|
+
plans: modelPages.map((page) => ({ sheet: page.sheet, ...page.title ? { title: page.title } : {} })),
|
|
96568
|
+
pages: modelPages.map((page) => ({ sourceHash: page.sourceHash, page: page.page, sheet: page.sheet })),
|
|
96569
|
+
...currentObj?.filter === void 0 ? {} : { filter: currentObj.filter }
|
|
96570
|
+
}, { phase: "model", timeoutMs: remaining2("model", modelWorkload), workload: modelWorkload });
|
|
96571
|
+
evidenceFilter = currentSteelFilterResult(evidenceFilter);
|
|
96572
|
+
filter = currentSteelFilterResult(filter);
|
|
96573
|
+
}, { label: "preparing steel drawings", expectedMs: extractionBudgetMs, failFast: true });
|
|
96291
96574
|
} catch (error) {
|
|
96575
|
+
if (error instanceof LifecycleLockBusyError) {
|
|
96576
|
+
const body = steelLifecycleBusyBody(error);
|
|
96577
|
+
reply.header("Retry-After", String(Math.ceil(body.retryAfterMs / 1e3)));
|
|
96578
|
+
return reply.status(409).send(body);
|
|
96579
|
+
}
|
|
96292
96580
|
if (error instanceof SteelFilterCleanupStateError) {
|
|
96293
96581
|
return reply.status(409).send({
|
|
96294
96582
|
ok: false,
|
|
@@ -96303,18 +96591,18 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96303
96591
|
}
|
|
96304
96592
|
if (error instanceof SteelFilterTimeoutError) {
|
|
96305
96593
|
req.log.warn({ projectId: project.id, requestId: request.id, diagnosticId: error.diagnosticId, phase: error.phase, elapsedMs: error.elapsedMs, timeoutMs: error.timeoutMs, ...error.workload }, "steel manifest preparation timed out");
|
|
96306
|
-
|
|
96307
|
-
|
|
96308
|
-
|
|
96309
|
-
|
|
96310
|
-
|
|
96311
|
-
|
|
96312
|
-
|
|
96313
|
-
|
|
96314
|
-
|
|
96315
|
-
|
|
96316
|
-
|
|
96317
|
-
return reply.status(
|
|
96594
|
+
const written = (deps.patchRequestDurable ?? patchRequestDurable)(request.id, {
|
|
96595
|
+
status: "pending",
|
|
96596
|
+
refusalCode: void 0,
|
|
96597
|
+
steelPreparationTimeout: steelTimeoutDiagnostics(error),
|
|
96598
|
+
error: void 0
|
|
96599
|
+
});
|
|
96600
|
+
if (!written) return reply.status(409).send({ ok: false, code: "revision-request-changed", error: "the drawing read changed while recording its retryable interruption" });
|
|
96601
|
+
request = written;
|
|
96602
|
+
broadcast({ type: "requests-changed" });
|
|
96603
|
+
if (error.cleanup.state === "blocked") return reply.status(409).send(steelTimeoutCleanupBlockedBody(error));
|
|
96604
|
+
reply.header("Retry-After", String(Math.ceil(error.cleanup.retryAfterMs / 1e3)));
|
|
96605
|
+
return reply.status(409).send(steelTimeoutBody(error));
|
|
96318
96606
|
}
|
|
96319
96607
|
if (error instanceof SteelFilterBudgetError) {
|
|
96320
96608
|
const labelByPage = new Map(pages.map((page) => [`${page.sourceHash} ${page.page}`, page.sheet]));
|
|
@@ -96422,6 +96710,7 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96422
96710
|
let stored2;
|
|
96423
96711
|
try {
|
|
96424
96712
|
const manifestPages = buildCompactManifestPages(pages, evidenceSheets, filter);
|
|
96713
|
+
hardDeadline = steelOperationDeadlineAt(now2());
|
|
96425
96714
|
const scaleProposals = proposeSheetScales({
|
|
96426
96715
|
filter,
|
|
96427
96716
|
pages: manifestPages.map((page) => ({
|
|
@@ -96432,11 +96721,11 @@ function registerRevisionRoutes(app, deps = {}) {
|
|
|
96432
96721
|
...page.viewKind === void 0 ? {} : { viewKind: page.viewKind }
|
|
96433
96722
|
})).filter((page) => page.sheet !== ""),
|
|
96434
96723
|
environment: project.environment,
|
|
96435
|
-
//
|
|
96724
|
+
// Scale fitting gets its own operation deadline after extraction, WITH the clock it is expressed in —
|
|
96436
96725
|
// one object, because they are meaningless apart: this deadline is a `performance.now()`
|
|
96437
96726
|
// value, and comparing it against a `Date.now()` clock would exceed the budget on every
|
|
96438
|
-
// sheet and silently return the reader to hand-fitting.
|
|
96439
|
-
//
|
|
96727
|
+
// sheet and silently return the reader to hand-fitting. `steelOperationDeadlineAt` keeps
|
|
96728
|
+
// the bounded addition in one home while this phase starts from its own current clock.
|
|
96440
96729
|
budget: { deadlineAt: hardDeadline, now: now2 }
|
|
96441
96730
|
});
|
|
96442
96731
|
stored2 = writeSteelReadManifest({
|
|
@@ -116533,8 +116822,10 @@ async function finish(deps, lease, patch2, options = {}) {
|
|
|
116533
116822
|
cleanupMcpConfig(lease.leaseId);
|
|
116534
116823
|
if (contained) {
|
|
116535
116824
|
let leaseTerminalRefusal;
|
|
116825
|
+
let durableLease = lease;
|
|
116536
116826
|
try {
|
|
116537
|
-
|
|
116827
|
+
durableLease = (deps.readLease ?? getLease)(lease.leaseId) ?? lease;
|
|
116828
|
+
leaseTerminalRefusal = durableLease.terminalRefusalCode === "steel-manifest-extraction-timeout";
|
|
116538
116829
|
} catch (error) {
|
|
116539
116830
|
locallyRevokedRelayLeases.add(lease.leaseId);
|
|
116540
116831
|
try {
|
|
@@ -116605,7 +116896,7 @@ async function finish(deps, lease, patch2, options = {}) {
|
|
|
116605
116896
|
return;
|
|
116606
116897
|
}
|
|
116607
116898
|
}
|
|
116608
|
-
const terminalRecoveryForbidden = leaseTerminalRefusal || requestTerminalRefusal;
|
|
116899
|
+
const terminalRecoveryForbidden = leaseTerminalRefusal || requestTerminalRefusal || lease.requestType === "revision-read" && !durableLease.resolvedAt;
|
|
116609
116900
|
const interactive = Boolean(
|
|
116610
116901
|
lease.requestType !== "guide" && !terminalRecoveryForbidden && lease.sessionId && patch2.state && INTERACTIVE_RECOVERY_STATES.has(patch2.state) && canOfferInteractiveRecovery(lease)
|
|
116611
116902
|
);
|
|
@@ -116943,8 +117234,7 @@ function exactLeasedRequest(deps, lease) {
|
|
|
116943
117234
|
}
|
|
116944
117235
|
return req;
|
|
116945
117236
|
}
|
|
116946
|
-
function
|
|
116947
|
-
const req = exactLeasedRequest(deps, lease);
|
|
117237
|
+
function verifyRevisionRequestSources(deps, req) {
|
|
116948
117238
|
if (req.type !== "revision-read" || !req.sourceRefs?.length || req.sourceRefs.length !== req.snapshots?.length) {
|
|
116949
117239
|
throw new Error("the queued revision PDF set no longer matches this run");
|
|
116950
117240
|
}
|
|
@@ -116957,6 +117247,9 @@ function verifyRevisionSources(deps, lease) {
|
|
|
116957
117247
|
}
|
|
116958
117248
|
});
|
|
116959
117249
|
}
|
|
117250
|
+
function verifyRevisionSources(deps, lease) {
|
|
117251
|
+
verifyRevisionRequestSources(deps, exactLeasedRequest(deps, lease));
|
|
117252
|
+
}
|
|
116960
117253
|
async function runRevisionPrepass(deps, lease) {
|
|
116961
117254
|
verifyRevisionSources(deps, lease);
|
|
116962
117255
|
const req = exactLeasedRequest(deps, lease);
|
|
@@ -116974,6 +117267,25 @@ async function runRevisionPrepass(deps, lease) {
|
|
|
116974
117267
|
if (written.status === 409 && written.body?.code === "sheet-identification-required") {
|
|
116975
117268
|
return { ok: false, needsInput: true, code: "sheet-identification-required", pages: written.body.pages };
|
|
116976
117269
|
}
|
|
117270
|
+
if (written.status === 409 && ["steel-manifest-extraction-interrupted", "steel-manifest-inspection-interrupted", "steel-manifest-preparation-busy"].includes(String(written.body?.code ?? ""))) {
|
|
117271
|
+
const body = written.body;
|
|
117272
|
+
if (!Number.isSafeInteger(body.retryAfterMs) || Number(body.retryAfterMs) < 1) {
|
|
117273
|
+
throw new Error("Steel Filter preparation returned a retryable response without a valid retry delay.");
|
|
117274
|
+
}
|
|
117275
|
+
return {
|
|
117276
|
+
ok: false,
|
|
117277
|
+
retryable: true,
|
|
117278
|
+
code: body.code,
|
|
117279
|
+
retryAfterMs: body.retryAfterMs,
|
|
117280
|
+
...typeof body.error === "string" ? { error: body.error } : {},
|
|
117281
|
+
...typeof body.recovery === "string" ? { recovery: body.recovery } : {},
|
|
117282
|
+
...typeof body.diagnosticId === "string" ? { diagnosticId: body.diagnosticId } : {},
|
|
117283
|
+
...typeof body.phase === "string" ? { phase: body.phase } : {},
|
|
117284
|
+
...Number.isSafeInteger(body.elapsedMs) ? { elapsedMs: body.elapsedMs } : {},
|
|
117285
|
+
...Number.isSafeInteger(body.timeoutMs) ? { timeoutMs: body.timeoutMs } : {},
|
|
117286
|
+
...body.workload && typeof body.workload === "object" && !Array.isArray(body.workload) ? { workload: body.workload } : {}
|
|
117287
|
+
};
|
|
117288
|
+
}
|
|
116977
117289
|
if (written.status === 409 && written.body?.code === "steel-manifest-preparation-blocked") {
|
|
116978
117290
|
const blocked = new Error("Steel Filter preparation is blocked by an unverifiable prior process claim. Check or repair that claim before retrying.");
|
|
116979
117291
|
blocked.name = "SteelManifestPreparationBlockedError";
|
|
@@ -117194,13 +117506,33 @@ function registerTerminalRunRoutes(app, deps) {
|
|
|
117194
117506
|
const eligibility = deps.eligibility?.(req) ?? runEligibilityFor(req);
|
|
117195
117507
|
if (!eligibility.runnable) return reply.status(400).send({ ok: false, error: eligibility.why, code: "not-runnable" });
|
|
117196
117508
|
const policy = eligibility.policy;
|
|
117197
|
-
if (req.type === "revision-read" && req.status === "failed" &&
|
|
117509
|
+
if (req.type === "revision-read" && req.status === "failed" && hasRetryablePreparationRefusal(req)) {
|
|
117198
117510
|
try {
|
|
117511
|
+
verifyRevisionRequestSources(deps, req);
|
|
117512
|
+
if (req.run?.leaseId) {
|
|
117513
|
+
const presence2 = expectedLeasePresence(req.run.leaseId, req.run.cwd);
|
|
117514
|
+
if (presence2.state !== "absent") {
|
|
117515
|
+
return reply.status(409).send({
|
|
117516
|
+
ok: false,
|
|
117517
|
+
code: presence2.state === "present" || presence2.state === "mismatched" ? "revision-read-owned" : "revision-read-lifecycle-unavailable",
|
|
117518
|
+
error: presence2.state === "present" || presence2.state === "mismatched" ? "This interrupted drawing preparation is still owned by a terminal run. Stop or recover that run before retrying." : "FloLess could not prove that the interrupted drawing preparation released its terminal run."
|
|
117519
|
+
});
|
|
117520
|
+
}
|
|
117521
|
+
}
|
|
117522
|
+
if (req.run && (req.run.state === "queued" || req.run.state === "running" || req.run.processContained === false)) {
|
|
117523
|
+
return reply.status(409).send({
|
|
117524
|
+
ok: false,
|
|
117525
|
+
code: "revision-read-lifecycle-unavailable",
|
|
117526
|
+
error: "FloLess has not proved that the interrupted terminal process is contained."
|
|
117527
|
+
});
|
|
117528
|
+
}
|
|
117529
|
+
const diagnostic = req.steelPreparationTimeout ?? req.run?.steelPreparationTimeout;
|
|
117199
117530
|
const migrated = deps.patchRequestDurable(req.id, {
|
|
117200
117531
|
status: "pending",
|
|
117201
117532
|
refusalCode: void 0,
|
|
117202
|
-
steelPreparationTimeout:
|
|
117203
|
-
error: void 0
|
|
117533
|
+
steelPreparationTimeout: diagnostic,
|
|
117534
|
+
error: void 0,
|
|
117535
|
+
...req.run ? { run: { ...req.run, refusalCode: void 0 } } : {}
|
|
117204
117536
|
});
|
|
117205
117537
|
if (!migrated) {
|
|
117206
117538
|
return reply.status(409).send({ ok: false, code: "revision-request-changed", error: "The drawing read changed before its interrupted inspection could resume." });
|
|
@@ -117212,11 +117544,11 @@ function registerTerminalRunRoutes(app, deps) {
|
|
|
117212
117544
|
req = Object.freeze({ ...enriched });
|
|
117213
117545
|
deps.broadcast({ type: "requests-changed" });
|
|
117214
117546
|
} catch (error) {
|
|
117215
|
-
request.log.error({ err: String(error) }, "legacy
|
|
117547
|
+
request.log.error({ err: String(error) }, "legacy preparation retry migration failed");
|
|
117216
117548
|
return reply.status(503).send({
|
|
117217
117549
|
ok: false,
|
|
117218
117550
|
code: "revision-request-unavailable",
|
|
117219
|
-
error: "FloLess could not make the interrupted drawing
|
|
117551
|
+
error: "FloLess could not make the interrupted drawing preparation resumable. Restart FloLess and try again."
|
|
117220
117552
|
});
|
|
117221
117553
|
}
|
|
117222
117554
|
}
|