@hcmai/sdk 0.3.16 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1206 -1
- package/dist/index.js +2783 -279
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1083,18 +1083,18 @@ async function action(http, model, actionName, input) {
|
|
|
1083
1083
|
if (scope === "object" && !input.id) {
|
|
1084
1084
|
throw new Error(`object action ${model}.${actionName} requires id`);
|
|
1085
1085
|
}
|
|
1086
|
-
const
|
|
1086
|
+
const path22 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
|
|
1087
1087
|
const resp = await (async () => {
|
|
1088
1088
|
if (method === "GET") {
|
|
1089
|
-
return http.get(
|
|
1089
|
+
return http.get(path22, { params: queryParams(input) });
|
|
1090
1090
|
}
|
|
1091
1091
|
if (method === "DELETE") {
|
|
1092
|
-
return http.delete(
|
|
1092
|
+
return http.delete(path22, { params: queryParams(input) });
|
|
1093
1093
|
}
|
|
1094
1094
|
if (method === "PUT") {
|
|
1095
|
-
return http.put(
|
|
1095
|
+
return http.put(path22, scope === "object" ? objectBody(input) : classBody(input));
|
|
1096
1096
|
}
|
|
1097
|
-
return http.post(
|
|
1097
|
+
return http.post(path22, scope === "object" ? objectBody(input) : classBody(input));
|
|
1098
1098
|
})();
|
|
1099
1099
|
return resp.data;
|
|
1100
1100
|
}
|
|
@@ -5215,18 +5215,18 @@ async function listTenantMeta(http, opts = {}) {
|
|
|
5215
5215
|
const items = payload?.items ?? payload?.list ?? payload?.records ?? [];
|
|
5216
5216
|
return { items, total: payload?.total, raw: payload };
|
|
5217
5217
|
}
|
|
5218
|
-
async function getTenantMeta(http,
|
|
5219
|
-
const resp = await http.get("/api/tenant-meta/meta", { params: { path:
|
|
5218
|
+
async function getTenantMeta(http, path22) {
|
|
5219
|
+
const resp = await http.get("/api/tenant-meta/meta", { params: { path: path22 } });
|
|
5220
5220
|
const payload = resp.data?.data ?? resp.data;
|
|
5221
5221
|
if (typeof payload === "string") return payload;
|
|
5222
5222
|
return String(payload?.content ?? "");
|
|
5223
5223
|
}
|
|
5224
|
-
async function saveTenantMeta(http,
|
|
5225
|
-
const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path:
|
|
5224
|
+
async function saveTenantMeta(http, path22, content) {
|
|
5225
|
+
const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path22 } });
|
|
5226
5226
|
return resp.data?.data ?? resp.data;
|
|
5227
5227
|
}
|
|
5228
|
-
async function deleteTenantMeta(http,
|
|
5229
|
-
const resp = await http.delete("/api/tenant-meta/meta", { params: { path:
|
|
5228
|
+
async function deleteTenantMeta(http, path22) {
|
|
5229
|
+
const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path22 } });
|
|
5230
5230
|
return resp.data?.data ?? resp.data;
|
|
5231
5231
|
}
|
|
5232
5232
|
|
|
@@ -5328,14 +5328,14 @@ function resolveSkillInstallOrder(manifest2, targetId) {
|
|
|
5328
5328
|
throw invalid(`\u6280\u80FD\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${targetId}`);
|
|
5329
5329
|
}
|
|
5330
5330
|
const state = /* @__PURE__ */ new Map();
|
|
5331
|
-
const
|
|
5331
|
+
const path22 = [];
|
|
5332
5332
|
const order = [];
|
|
5333
5333
|
const visit = (id, requiredBy) => {
|
|
5334
5334
|
const current = state.get(id);
|
|
5335
5335
|
if (current === "done") return;
|
|
5336
5336
|
if (current === "visiting") {
|
|
5337
|
-
const cycleStart =
|
|
5338
|
-
const cycle = [...
|
|
5337
|
+
const cycleStart = path22.indexOf(id);
|
|
5338
|
+
const cycle = [...path22.slice(Math.max(0, cycleStart)), id];
|
|
5339
5339
|
throw invalid(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${cycle.join(" -> ")}`);
|
|
5340
5340
|
}
|
|
5341
5341
|
const skill = byId.get(id);
|
|
@@ -5344,11 +5344,11 @@ function resolveSkillInstallOrder(manifest2, targetId) {
|
|
|
5344
5344
|
}
|
|
5345
5345
|
assertSafeSkillId(skill.id);
|
|
5346
5346
|
state.set(id, "visiting");
|
|
5347
|
-
|
|
5347
|
+
path22.push(id);
|
|
5348
5348
|
for (const required2 of normalizeRequirements(skill.requires, skill.id)) {
|
|
5349
5349
|
visit(required2, skill.id);
|
|
5350
5350
|
}
|
|
5351
|
-
|
|
5351
|
+
path22.pop();
|
|
5352
5352
|
state.set(id, "done");
|
|
5353
5353
|
order.push(skill);
|
|
5354
5354
|
};
|
|
@@ -5439,11 +5439,11 @@ async function resetSettingItem(http, domain, namespace, settingKey, revision) {
|
|
|
5439
5439
|
function parseSettingAssignment(raw) {
|
|
5440
5440
|
const eq = raw.indexOf("=");
|
|
5441
5441
|
if (eq <= 0) throw new Error(`--set \u9700\u8981 namespace.key=value \u5F62\u6001\uFF0C\u6536\u5230 "${raw}"`);
|
|
5442
|
-
const
|
|
5442
|
+
const path22 = raw.slice(0, eq).trim();
|
|
5443
5443
|
const value = raw.slice(eq + 1);
|
|
5444
|
-
const dot =
|
|
5445
|
-
if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${
|
|
5446
|
-
return { namespace:
|
|
5444
|
+
const dot = path22.lastIndexOf(".");
|
|
5445
|
+
if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path22}"`);
|
|
5446
|
+
return { namespace: path22.slice(0, dot), settingKey: path22.slice(dot + 1), value };
|
|
5447
5447
|
}
|
|
5448
5448
|
|
|
5449
5449
|
// src/fde/layout.ts
|
|
@@ -5832,11 +5832,11 @@ function classifyStatus(status) {
|
|
|
5832
5832
|
return "bad-response";
|
|
5833
5833
|
}
|
|
5834
5834
|
var CAPABILITIES_HEADER = "x-hcm-capabilities";
|
|
5835
|
-
function buildUrl(
|
|
5835
|
+
function buildUrl(path22, params) {
|
|
5836
5836
|
const entries = Object.entries(params ?? {}).filter(([, v]) => v !== void 0 && v !== null);
|
|
5837
|
-
if (entries.length === 0) return
|
|
5837
|
+
if (entries.length === 0) return path22;
|
|
5838
5838
|
const qs = entries.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
|
|
5839
|
-
return `${
|
|
5839
|
+
return `${path22}${path22.includes("?") ? "&" : "?"}${qs}`;
|
|
5840
5840
|
}
|
|
5841
5841
|
function lowerHeaders(raw) {
|
|
5842
5842
|
const out = {};
|
|
@@ -5878,14 +5878,14 @@ function httpProbe(http, capabilities) {
|
|
|
5878
5878
|
const headers = { [CAPABILITIES_HEADER]: capabilities };
|
|
5879
5879
|
const probe = {
|
|
5880
5880
|
capabilities,
|
|
5881
|
-
get(
|
|
5881
|
+
get(path22, params) {
|
|
5882
5882
|
return once(
|
|
5883
|
-
() => http.get(buildUrl(
|
|
5883
|
+
() => http.get(buildUrl(path22, params), { headers, validateStatus: () => true })
|
|
5884
5884
|
);
|
|
5885
5885
|
},
|
|
5886
|
-
post(
|
|
5886
|
+
post(path22, body) {
|
|
5887
5887
|
return once(
|
|
5888
|
-
() => http.post(
|
|
5888
|
+
() => http.post(path22, body, {
|
|
5889
5889
|
headers: { ...headers, "content-type": "application/json" },
|
|
5890
5890
|
validateStatus: () => true
|
|
5891
5891
|
})
|
|
@@ -5976,7 +5976,7 @@ async function crawlModels(probe) {
|
|
|
5976
5976
|
const healthy = Boolean(out.body) && typeof out.body === "object" && !Array.isArray(out.body);
|
|
5977
5977
|
const body = healthy ? { ...out.body } : { totalCount: 0, typeCounts: {}, models: [] };
|
|
5978
5978
|
const rows = Array.isArray(body.models) ? body.models : void 0;
|
|
5979
|
-
const
|
|
5979
|
+
const premise2 = {
|
|
5980
5980
|
// 前提显式断言:totalCount 与 models 长度不符时,后续任何「共 N 个模型」都不成立。
|
|
5981
5981
|
totalCountMatchesListLength: Boolean(healthy && rows !== void 0 && body.totalCount === rows.length),
|
|
5982
5982
|
responseShape: shapeOf(out.body),
|
|
@@ -5985,10 +5985,10 @@ async function crawlModels(probe) {
|
|
|
5985
5985
|
// 撞键与否**恒有值**:没有这个键时「没撞」与「没检查过」在产物里同形。
|
|
5986
5986
|
collidedWithServerKey: Object.prototype.hasOwnProperty.call(body, KIT_PREMISE_KEY)
|
|
5987
5987
|
};
|
|
5988
|
-
if (
|
|
5989
|
-
|
|
5988
|
+
if (premise2.collidedWithServerKey) {
|
|
5989
|
+
premise2.serverValue = body[KIT_PREMISE_KEY];
|
|
5990
5990
|
}
|
|
5991
|
-
body[KIT_PREMISE_KEY] =
|
|
5991
|
+
body[KIT_PREMISE_KEY] = premise2;
|
|
5992
5992
|
return body;
|
|
5993
5993
|
}
|
|
5994
5994
|
async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
|
|
@@ -5997,8 +5997,8 @@ async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
|
|
|
5997
5997
|
const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
|
|
5998
5998
|
const metas = {};
|
|
5999
5999
|
const unavailable = [];
|
|
6000
|
-
for (const [
|
|
6001
|
-
const out = results[
|
|
6000
|
+
for (const [path22, key] of paths) {
|
|
6001
|
+
const out = results[path22];
|
|
6002
6002
|
if (out === void 0) {
|
|
6003
6003
|
unavailable.push({
|
|
6004
6004
|
modelKey: key,
|
|
@@ -6009,8 +6009,8 @@ async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
|
|
|
6009
6009
|
});
|
|
6010
6010
|
continue;
|
|
6011
6011
|
}
|
|
6012
|
-
const
|
|
6013
|
-
if (out.error === "ok" &&
|
|
6012
|
+
const isObject3 = Boolean(out.body) && typeof out.body === "object" && !Array.isArray(out.body);
|
|
6013
|
+
if (out.error === "ok" && isObject3) {
|
|
6014
6014
|
metas[key] = out.body;
|
|
6015
6015
|
continue;
|
|
6016
6016
|
}
|
|
@@ -6125,9 +6125,9 @@ function extractFieldRows(metas) {
|
|
|
6125
6125
|
const rows = [];
|
|
6126
6126
|
const dropped = [];
|
|
6127
6127
|
for (const [model, body] of Object.entries(metas)) {
|
|
6128
|
-
const { fields, problem:
|
|
6129
|
-
if (
|
|
6130
|
-
dropped.push(`${model}: ${
|
|
6128
|
+
const { fields, problem: problem6 } = metaFields(body);
|
|
6129
|
+
if (problem6) {
|
|
6130
|
+
dropped.push(`${model}: ${problem6}\uFF0C\u6574\u4E2A\u6A21\u578B\u6CA1\u6709\u5B57\u6BB5\u8FDB\u7D22\u5F15`);
|
|
6131
6131
|
continue;
|
|
6132
6132
|
}
|
|
6133
6133
|
fields.forEach((f, index) => {
|
|
@@ -6214,8 +6214,8 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
6214
6214
|
const statesEchoed = /* @__PURE__ */ new Set();
|
|
6215
6215
|
let noStateEcho = 0;
|
|
6216
6216
|
let answered = 0;
|
|
6217
|
-
for (const [
|
|
6218
|
-
const out = results[
|
|
6217
|
+
for (const [path22, model] of paths) {
|
|
6218
|
+
const out = results[path22];
|
|
6219
6219
|
if (out === void 0) {
|
|
6220
6220
|
unavailable.push({
|
|
6221
6221
|
modelKey: model,
|
|
@@ -6594,8 +6594,8 @@ async function collectMutation(probe, modelKeys2) {
|
|
|
6594
6594
|
const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
|
|
6595
6595
|
const mutation = {};
|
|
6596
6596
|
const problems = [];
|
|
6597
|
-
for (const [
|
|
6598
|
-
const out = results[
|
|
6597
|
+
for (const [path22, key] of paths) {
|
|
6598
|
+
const out = results[path22];
|
|
6599
6599
|
if (out === void 0) {
|
|
6600
6600
|
problems.push(`${key}: mutation-capability ${BATCH_LOST}`);
|
|
6601
6601
|
mutation[key] = Object.fromEntries(
|
|
@@ -6666,7 +6666,7 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
6666
6666
|
for (const e of edges) byField.set(`${e.fromModel} ${e.fromField}`, e);
|
|
6667
6667
|
const sheets = [];
|
|
6668
6668
|
for (const modelKey2 of Object.keys(metas).sort()) {
|
|
6669
|
-
const { fields, problem:
|
|
6669
|
+
const { fields, problem: problem6 } = metaFields(metas[modelKey2]);
|
|
6670
6670
|
const rows = [];
|
|
6671
6671
|
for (const f of fields) {
|
|
6672
6672
|
if (!isRecord2(f)) continue;
|
|
@@ -6716,7 +6716,7 @@ function buildMapping(metas, edges, mutation, codeTables = []) {
|
|
|
6716
6716
|
fieldCount: rows.length,
|
|
6717
6717
|
// 🔴 `null` = 载荷判读正常(fieldCount=0 就是「这个模型确实没字段」);
|
|
6718
6718
|
// 非 null = **爬过、但判不出字段**,此时 fieldCount=0 不代表「没字段」。
|
|
6719
|
-
fieldsProblem:
|
|
6719
|
+
fieldsProblem: problem6 ?? null,
|
|
6720
6720
|
fields: rows
|
|
6721
6721
|
});
|
|
6722
6722
|
}
|
|
@@ -6862,10 +6862,10 @@ function renderModelsMd(modelsBody, metas, gates, dropped = []) {
|
|
|
6862
6862
|
for (const d of dropped) parts.push(`> - ${d}`);
|
|
6863
6863
|
parts.push("");
|
|
6864
6864
|
}
|
|
6865
|
-
const
|
|
6865
|
+
const listed3 = /* @__PURE__ */ new Set();
|
|
6866
6866
|
for (const m of modelEntries(modelsBody)) {
|
|
6867
6867
|
const key = String(m.modelKey ?? "");
|
|
6868
|
-
|
|
6868
|
+
listed3.add(key);
|
|
6869
6869
|
const name = m.name || "";
|
|
6870
6870
|
parts.push(name ? `## ${key} \xB7 ${name}` : `## ${key}`);
|
|
6871
6871
|
parts.push("");
|
|
@@ -6873,9 +6873,9 @@ function renderModelsMd(modelsBody, metas, gates, dropped = []) {
|
|
|
6873
6873
|
if (!Object.prototype.hasOwnProperty.call(metas, key)) {
|
|
6874
6874
|
parts.push(FIELDS_NOT_CRAWLED);
|
|
6875
6875
|
} else {
|
|
6876
|
-
const { fields, problem:
|
|
6876
|
+
const { fields, problem: problem6 } = metaFields(metas[key]);
|
|
6877
6877
|
parts.push(
|
|
6878
|
-
|
|
6878
|
+
problem6 === void 0 ? `- \u5B57\u6BB5\u6570\uFF1A${fields.length}` : `- \u5B57\u6BB5\u6570\uFF1A\u65E0\u6CD5\u5224\u8BFB\uFF08${problem6}\uFF09\uFF0C\u8BE5\u6A21\u578B\u6CA1\u6709\u5B57\u6BB5\u8FDB\u7D22\u5F15`
|
|
6879
6879
|
);
|
|
6880
6880
|
}
|
|
6881
6881
|
const gs = byModel.get(key) ?? [];
|
|
@@ -6887,7 +6887,7 @@ function renderModelsMd(modelsBody, metas, gates, dropped = []) {
|
|
|
6887
6887
|
}
|
|
6888
6888
|
parts.push("");
|
|
6889
6889
|
}
|
|
6890
|
-
const orphans = gates.filter((g) => !
|
|
6890
|
+
const orphans = gates.filter((g) => !listed3.has(String(g.model ?? "")));
|
|
6891
6891
|
if (orphans.length > 0) {
|
|
6892
6892
|
parts.push(ORPHAN_TITLE);
|
|
6893
6893
|
parts.push("");
|
|
@@ -7040,11 +7040,11 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
|
7040
7040
|
keys.push(key);
|
|
7041
7041
|
}
|
|
7042
7042
|
for (const key of [...new Set(keys)].sort()) {
|
|
7043
|
-
const
|
|
7043
|
+
const path22 = listPath(key);
|
|
7044
7044
|
const started = tick();
|
|
7045
7045
|
let requests = 0;
|
|
7046
7046
|
let truncatedBy = null;
|
|
7047
|
-
const probeOut = await post.call(probe,
|
|
7047
|
+
const probeOut = await post.call(probe, path22, { page: 0, size: 0 });
|
|
7048
7048
|
requests += 1;
|
|
7049
7049
|
let total = null;
|
|
7050
7050
|
let reason = null;
|
|
@@ -7093,7 +7093,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
|
7093
7093
|
failed = `\u89E6\u53D1\u5DE5\u5177\u7684\u6BCF\u8868${which === "requests" ? "\u8BF7\u6C42" : "\u5899\u949F"}\u4E0A\u9650\uFF08${which === "requests" ? `\u5DF2\u53D1 ${requests} \u6B21\u8BF7\u6C42` : `\u5DF2\u82B1 ${elapsed.toFixed(3)}s`}\uFF09\uFF0C\u505C\u5728\u7B2C ${page} \u9875\uFF0C\u5DF2\u6536 ${rows.length} \u884C / \u8BA1\u6570 ${total} \u884C\uFF0C\u672C\u8868\u6807 partial\u3002**\u8FD9\u662F\u5DE5\u5177\u7684\u622A\u65AD\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\u7684\u6BDB\u75C5** \u2014\u2014 \u8C03\u5927 valuedomain.${which === "requests" ? "MAX_REQUESTS_PER_TABLE" : "MAX_SECONDS_PER_TABLE"} \u6216\u7ED9 collectCodeTables \u4F20 ${which === "requests" ? "maxRequests" : "maxSeconds"} \u540E\u91CD\u8DD1\u5C31\u80FD\u53D6\u5168`;
|
|
7094
7094
|
break;
|
|
7095
7095
|
}
|
|
7096
|
-
const out = await post.call(probe,
|
|
7096
|
+
const out = await post.call(probe, path22, { page, size: PAGE_SIZE });
|
|
7097
7097
|
requests += 1;
|
|
7098
7098
|
if (out.error !== "ok") {
|
|
7099
7099
|
failed = `\u7B2C ${page} \u9875\u5931\u8D25\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
|
|
@@ -7833,7 +7833,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
|
|
|
7833
7833
|
for (const name of ["id", ...fields]) {
|
|
7834
7834
|
if (!projected.includes(name)) projected.push(name);
|
|
7835
7835
|
}
|
|
7836
|
-
const
|
|
7836
|
+
const path22 = listPath2(model);
|
|
7837
7837
|
const idx = /* @__PURE__ */ new Map();
|
|
7838
7838
|
let total = null;
|
|
7839
7839
|
let pages = 0;
|
|
@@ -7850,7 +7850,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
|
|
|
7850
7850
|
let repeatedIds = 0;
|
|
7851
7851
|
while (total === null || received < total) {
|
|
7852
7852
|
const pageNo = pages;
|
|
7853
|
-
const out = await client.post(
|
|
7853
|
+
const out = await client.post(path22, {
|
|
7854
7854
|
page: pageNo,
|
|
7855
7855
|
size: pageSize,
|
|
7856
7856
|
fields: projected,
|
|
@@ -8042,8 +8042,8 @@ var CFB_MAGIC = Buffer.from([208, 207, 17, 224, 161, 177, 26, 225]);
|
|
|
8042
8042
|
var ENCRYPTED_PACKAGE = Buffer.from("EncryptedPackage", "utf16le");
|
|
8043
8043
|
var MAX_ENTRY_BYTES = 128 * 1024 * 1024;
|
|
8044
8044
|
var SCAN_CHUNK_BYTES = 1024 * 1024;
|
|
8045
|
-
function scanFor(
|
|
8046
|
-
const fd = openSync2(
|
|
8045
|
+
function scanFor(path22, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
|
|
8046
|
+
const fd = openSync2(path22, "r");
|
|
8047
8047
|
try {
|
|
8048
8048
|
let tail = Buffer.alloc(0);
|
|
8049
8049
|
let seen = 0;
|
|
@@ -8064,9 +8064,9 @@ function scanFor(path20, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
|
|
|
8064
8064
|
closeSync2(fd);
|
|
8065
8065
|
}
|
|
8066
8066
|
}
|
|
8067
|
-
function isCfb(
|
|
8068
|
-
if (statSync2(
|
|
8069
|
-
const fd = openSync2(
|
|
8067
|
+
function isCfb(path22) {
|
|
8068
|
+
if (statSync2(path22).size < CFB_MAGIC.length) return false;
|
|
8069
|
+
const fd = openSync2(path22, "r");
|
|
8070
8070
|
try {
|
|
8071
8071
|
const head = Buffer.alloc(CFB_MAGIC.length);
|
|
8072
8072
|
const n = readSync(fd, head, 0, CFB_MAGIC.length, 0);
|
|
@@ -8075,9 +8075,9 @@ function isCfb(path20) {
|
|
|
8075
8075
|
closeSync2(fd);
|
|
8076
8076
|
}
|
|
8077
8077
|
}
|
|
8078
|
-
function classifyCfb(
|
|
8079
|
-
if (!isCfb(
|
|
8080
|
-
switch (scanFor(
|
|
8078
|
+
function classifyCfb(path22, budget = MAX_ENTRY_BYTES) {
|
|
8079
|
+
if (!isCfb(path22)) return "not-cfb";
|
|
8080
|
+
switch (scanFor(path22, ENCRYPTED_PACKAGE, budget)) {
|
|
8081
8081
|
case "found":
|
|
8082
8082
|
return "encrypted";
|
|
8083
8083
|
case "absent":
|
|
@@ -10306,14 +10306,14 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
|
|
|
10306
10306
|
byCode.set(got.code, list);
|
|
10307
10307
|
}
|
|
10308
10308
|
});
|
|
10309
|
-
const
|
|
10309
|
+
const listed3 = (items) => items.slice(0, MAX_LISTED).join("\u3001") + (items.length > MAX_LISTED ? `\u2026\uFF08\u5171 ${items.length} \u884C\uFF09` : "");
|
|
10310
10310
|
if (byCode.has("BUSINESS_KEY_VALUE_MISSING")) {
|
|
10311
10311
|
const unusable = byCode.get("BUSINESS_KEY_VALUE_MISSING");
|
|
10312
10312
|
problems.push(
|
|
10313
10313
|
problem2(
|
|
10314
10314
|
"BUSINESS_KEY_VALUE_MISSING",
|
|
10315
10315
|
mm.model,
|
|
10316
|
-
`${mm.model} \u6709 ${unusable.length} \u884C\u53D6\u4E0D\u5230\u53EF\u7528\u7684\u4E1A\u52A1\u952E [${keyFields.map((f) => `'${f}'`).join(", ")}]\uFF1A${
|
|
10316
|
+
`${mm.model} \u6709 ${unusable.length} \u884C\u53D6\u4E0D\u5230\u53EF\u7528\u7684\u4E1A\u52A1\u952E [${keyFields.map((f) => `'${f}'`).join(", ")}]\uFF1A${listed3(unusable)}`,
|
|
10317
10317
|
"\u7A7A\u4E1A\u52A1\u952E\u5F53\u4E0D\u4E86\u5E42\u7B49\u652F\u70B9\uFF1A\u8FD9\u4E9B\u884C\u5EFA\u8FDB\u53BB\u4E4B\u540E\uFF0C\u4E0B\u4E00\u8F6E\u56DE\u8BFB\u5339\u914D\u4E0D\u4E0A\uFF0C\u4E8E\u662F\u518D\u5EFA\u4E00\u904D\u3002\u5148\u628A\u6E90\u8868\u91CC\u8FD9\u51E0\u884C\u7684\u952E\u5217\u8865\u9F50\uFF0C\u6216\u628A\u5B83\u4EEC\u4ECE\u8FD9\u4E00\u8F6E\u91CC\u53BB\u6389",
|
|
10318
10318
|
entry
|
|
10319
10319
|
)
|
|
@@ -10326,7 +10326,7 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
|
|
|
10326
10326
|
problem2(
|
|
10327
10327
|
"BUSINESS_KEY_REFERENCE_UNRESOLVED",
|
|
10328
10328
|
mm.model,
|
|
10329
|
-
`${mm.model} \u6709 ${unresolved.length} \u884C\u7684**\u4E1A\u52A1\u952E\u91CC\u6709\u5F15\u7528\u5B57\u6BB5\u6362\u4E0D\u51FA id** \u21D2 \u7B97\u4E0D\u51FA\u8FD9\u4E00\u884C\u7684\u8EAB\u4EFD\uFF1A${
|
|
10329
|
+
`${mm.model} \u6709 ${unresolved.length} \u884C\u7684**\u4E1A\u52A1\u952E\u91CC\u6709\u5F15\u7528\u5B57\u6BB5\u6362\u4E0D\u51FA id** \u21D2 \u7B97\u4E0D\u51FA\u8FD9\u4E00\u884C\u7684\u8EAB\u4EFD\uFF1A${listed3(unresolved)}`,
|
|
10330
10330
|
"\u{1F534} \u4E1A\u52A1\u952E\u5E26 resolveBy \u65F6\uFF0C\u884C\u952E\u53D6\u7684\u662F**\u89E3\u6790\u540E\u7684 id** \u2014\u2014 \u670D\u52A1\u7AEF\u5B58\u7684\u3001\u56DE\u8BFB\u641C\u7684\u3001\u65E2\u5B58\u7D22\u5F15\u5EFA\u7684\u90FD\u662F\u90A3\u4E2A id\uFF0C\u53D6\u6E90\u8868\u503C\u4F1A\u4E0E\u5B83\u4EEC\u5168\u4F53\u9519\u4F4D\u3002\u6362\u4E0D\u51FA id \u5C31\u6CA1\u6709\u8EAB\u4EFD\uFF0C\u8FD9\u4E00\u884C**\u4E0D\u8FDB\u8BA1\u5212**\u3002\u89E3\u6790**\u53EA\u67E5\u65E2\u5B58\u7D22\u5F15**\uFF08\u672C kit \u4E0D\u5EFA\u8DE8\u6A21\u578B\u7684\u6CE2\uFF09\uFF0C\u6240\u4EE5\u5173\u8054\u8868\u8FD9\u4E00\u65CF\u8981\u8D70**\u4E24\u8D9F**\uFF1A\u5148\u5355\u72EC\u8DD1\u4E00\u8F6E\u628A\u88AB\u5F15\u7528\u7684\u90A3\u4E2A\u6A21\u578B\u5BFC\u5B8C\uFF0C**\u518D\u91CD\u8DD1 plan** \u5BFC\u8FD9\u4E00\u4E2A\u3002\u9010\u884C\u62EC\u53F7\u91CC\u90A3\u4E2A\u6863\u8BF4\u7684\u662F\u6362\u4E0D\u51FA\u7684\u539F\u56E0\uFF1Aref-not-found = \u7D22\u5F15\u91CC\u6CA1\u6709\u8FD9\u4E2A\u503C\uFF1Bunresolved-no-index = \u5DE5\u4EF6\u7684 models[] \u91CC\u6CA1\u6709\u90A3\u4E2A\u6A21\u578B\uFF1Bref-key-mismatch = \u90A3\u4E2A\u6A21\u578B\u7684 businessKey \u4E0E\u8FD9\u91CC\u7684 keyField \u4E0D\u662F\u540C\u4E00\u4E2A\u952E",
|
|
10331
10331
|
entry
|
|
10332
10332
|
)
|
|
@@ -10604,16 +10604,16 @@ function rowCycles(parents) {
|
|
|
10604
10604
|
const cycles = [];
|
|
10605
10605
|
for (const start of [...parents.keys()].sort((a, b) => a - b)) {
|
|
10606
10606
|
if (done.has(start)) continue;
|
|
10607
|
-
const
|
|
10607
|
+
const path22 = [];
|
|
10608
10608
|
const seen = /* @__PURE__ */ new Map();
|
|
10609
10609
|
let node = start;
|
|
10610
10610
|
while (node !== void 0 && !seen.has(node) && !done.has(node)) {
|
|
10611
|
-
seen.set(node,
|
|
10612
|
-
|
|
10611
|
+
seen.set(node, path22.length);
|
|
10612
|
+
path22.push(node);
|
|
10613
10613
|
node = parents.get(node);
|
|
10614
10614
|
}
|
|
10615
|
-
if (node !== void 0 && seen.has(node)) cycles.push(
|
|
10616
|
-
for (const n of
|
|
10615
|
+
if (node !== void 0 && seen.has(node)) cycles.push(path22.slice(seen.get(node)));
|
|
10616
|
+
for (const n of path22) done.add(n);
|
|
10617
10617
|
}
|
|
10618
10618
|
return cycles;
|
|
10619
10619
|
}
|
|
@@ -11837,14 +11837,14 @@ var ROUND_HINT_ASSESSED = "\u4E0B\u9762\u6BCF\u4E00\u6761\u300C\u6CA1\u62A5\u51F
|
|
|
11837
11837
|
var ROUND_HINT_NOT_ASSESSED = "\u26A0\uFE0F \u8FD9\u4E00\u4EFD\u6E05\u5355**\u6CA1\u6709\u300C\u4E0B\u9762\u6BCF\u4E00\u6761\u300D**\uFF1A\u5DE5\u4EF6\u81EA\u5DF1\u5148\u6CA1\u8FC7\u6821\u9A8C\uFF0C\u4E00\u6761\u5224\u636E\u90FD\u6CA1\u8DD1\uFF08\u770B RISK_NOT_BUILT \u4E0E modelsAssessed\uFF09\u3002\u6240\u4EE5\u672C\u6761\u6B64\u523B\u8FD8\u6CA1\u6709\u6CE2\u53CA\u5230\u4EFB\u4F55\u7ED3\u8BBA \u2014\u2014\u4F46\u5B83**\u4E0E\u90A3\u4EF6\u4E8B\u4E92\u4E0D\u66FF\u4EE3**\uFF1A\u5DE5\u4EF6\u4FEE\u597D\u4E4B\u540E\u5B83\u7167\u6837\u5728\uFF0C\u4E24\u4EF6\u4E8B\u5206\u522B\u4FEE\u3002";
|
|
11838
11838
|
function roundProblems(roundPremise, assessed = true) {
|
|
11839
11839
|
const out = [];
|
|
11840
|
-
for (const
|
|
11841
|
-
const p = rec(
|
|
11840
|
+
for (const premise2 of roundPremise ?? []) {
|
|
11841
|
+
const p = rec(premise2);
|
|
11842
11842
|
const raw = p === null ? void 0 : p.message;
|
|
11843
11843
|
let message;
|
|
11844
11844
|
if (typeof raw === "string" && raw) {
|
|
11845
11845
|
message = raw;
|
|
11846
11846
|
} else {
|
|
11847
|
-
message = `\u95E8 0 \u7ED9\u7684\u8F6E\u6B21\u5224\u8BCD\u6E32\u67D3\u4E0D\u51FA\u6765\uFF08\u62FF\u5230\u7684\u662F ${JSON.stringify(
|
|
11847
|
+
message = `\u95E8 0 \u7ED9\u7684\u8F6E\u6B21\u5224\u8BCD\u6E32\u67D3\u4E0D\u51FA\u6765\uFF08\u62FF\u5230\u7684\u662F ${JSON.stringify(premise2)}\uFF0C\u5B83\u7684 \`message\` \u4E0D\u662F\u4E00\u53E5\u975E\u7A7A\u7684\u8BDD\uFF09\u2014\u2014 \u672C\u5C42\u4E0D\u66FF\u5B83\u5224\uFF0C\u4E5F**\u4E0D\u5F53\u6210 complete**`;
|
|
11848
11848
|
}
|
|
11849
11849
|
out.push(
|
|
11850
11850
|
problem3(
|
|
@@ -12268,8 +12268,8 @@ function seedBaselines(out, tenant) {
|
|
|
12268
12268
|
}
|
|
12269
12269
|
var RC_DECIDING_FIELDS = ["plan.problems", "risk.problems", "risk.blocking"];
|
|
12270
12270
|
function planRc(plan, risk) {
|
|
12271
|
-
const
|
|
12272
|
-
if (
|
|
12271
|
+
const premise2 = plan.problems.some((p) => p.kind === "premise") || risk.problems.some((p) => p.kind === "premise");
|
|
12272
|
+
if (premise2) return INIT_EXIT_CODES.premise;
|
|
12273
12273
|
if (risk.blocking || plan.problems.length > 0) return INIT_EXIT_CODES.blocked;
|
|
12274
12274
|
return INIT_EXIT_CODES.clean;
|
|
12275
12275
|
}
|
|
@@ -12278,14 +12278,14 @@ function discardedColumnLines(notes) {
|
|
|
12278
12278
|
return [`\u88AB\u4E22\u5F03\u7684\u65E0\u540D\u7A7A\u5217\uFF1A${notes.length} \u6761`, ...notes.map((n) => ` \xB7 ${JSON.stringify(n)}`)];
|
|
12279
12279
|
}
|
|
12280
12280
|
function planSummaryLine(plan, risk) {
|
|
12281
|
-
const
|
|
12281
|
+
const premise2 = risk.problems.filter((p) => p.kind === "premise");
|
|
12282
12282
|
const content = risk.problems.filter((p) => p.kind !== "premise");
|
|
12283
12283
|
const blocking = risk.problems.filter(
|
|
12284
12284
|
(p) => BLOCKING_CODES.includes(p.code) && !p.exempted
|
|
12285
12285
|
);
|
|
12286
12286
|
const where = [...new Set(blocking.map((p) => p.kind))].sort();
|
|
12287
12287
|
const spread = where.length > 1 ? "\u6A2A\u8DE8\u4E0A\u9762\u4E24\u6863" : where.length === 1 ? `\u5168\u5728${where[0] === "premise" ? "\u524D\u63D0\u672A\u6210\u7ACB" : "\u5185\u5BB9\u7EA7"}\u6863` : "\u672C\u8F6E\u6CA1\u6709\u62E6\u8DEF\u9879";
|
|
12288
|
-
return `\u98CE\u9669\uFF1Ablocking=${risk.blocking}\uFF0C\u5171 ${risk.problems.length} \u6761 = \u524D\u63D0\u672A\u6210\u7ACB ${
|
|
12288
|
+
return `\u98CE\u9669\uFF1Ablocking=${risk.blocking}\uFF0C\u5171 ${risk.problems.length} \u6761 = \u524D\u63D0\u672A\u6210\u7ACB ${premise2.length} \u6761 + \u5185\u5BB9\u7EA7 ${content.length} \u6761\uFF1B\u5176\u4E2D\u62E6\u8DEF ${blocking.length} \u6761\uFF08${spread}\uFF0C\u4E0D\u53E6\u8BA1\uFF09\uFF1B\u8BA1\u5212\u95EE\u9898 ${plan.problems.length} \u6761`;
|
|
12289
12289
|
}
|
|
12290
12290
|
function planProblemLines(plan, risk) {
|
|
12291
12291
|
const lines = [];
|
|
@@ -12332,6 +12332,65 @@ function roundWarning(round) {
|
|
|
12332
12332
|
return ROUND_WARNINGS[state ?? ""] ?? ROUND_WARNING_FALLBACK.replace("{state}", String(state));
|
|
12333
12333
|
}
|
|
12334
12334
|
var WARNED_ROUND_STATES = ROUND_STATES.filter((s) => s !== "complete");
|
|
12335
|
+
var RC_DECIDING_REPORT_FIELDS = ["aborted", "writeFailed", "quarantined", "blocked"];
|
|
12336
|
+
function applyRc(report) {
|
|
12337
|
+
if (report.aborted !== null || report.writeFailed || report.quarantined || report.blocked) {
|
|
12338
|
+
return INIT_EXIT_CODES.blocked;
|
|
12339
|
+
}
|
|
12340
|
+
return INIT_EXIT_CODES.clean;
|
|
12341
|
+
}
|
|
12342
|
+
var JOURNAL_STOP_KINDS = {
|
|
12343
|
+
"journal-unwritable": [
|
|
12344
|
+
"\u8FD9\u4E00\u8F6E**\u8DD1\u5230\u4E00\u534A\u505C\u4E86**\uFF1A\u53F0\u8D26\u5199\u4E0D\u4E0B\u53BB",
|
|
12345
|
+
"\u{1F534} \u5148\u5904\u7406\u78C1\u76D8 / \u6743\u9650\uFF0C\u518D\u5E26 `--resume` \u7EED\u8DD1\u3002",
|
|
12346
|
+
"\u{1F534} **\u8FD9\u4E00\u8F6E\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\uFF0C\u53EA\u5728\u8FD9\u4EFD\u53F0\u8D26\u91CC\u6709\u8BB0\u5F55 \u2014\u2014 \u5148\u5907\u4EFD\u8D70\u518D\u52A8\u78C1\u76D8\uFF1B\u4E0D\u8981\u5220\u6389\u5B83\u91CD\u8DD1**\uFF0C\u90A3\u4F1A\u628A\u5DF2\u7ECF\u5EFA\u597D\u7684\u884C\u518D\u5EFA\u4E00\u904D\u3002"
|
|
12347
|
+
],
|
|
12348
|
+
"bad-entry": [
|
|
12349
|
+
"\u8FD9\u4E00\u8F6E**\u505C\u5728\u8FD9\u91CC**\uFF1A\u8BA1\u5212\u91CC\u6709\u4E00\u884C\u7684\u4E1A\u52A1\u952E\u4E0D\u5408\u6CD5",
|
|
12350
|
+
"\u{1F534} \u8FD9\u662F `import-plan.json` **\u81EA\u5DF1**\u524D\u540E\u5BF9\u4E0D\u4E0A\uFF08\u884C\u952E\u6052\u662F\u4E00\u7EC4\u975E\u7A7A\u5B57\u7B26\u4E32\uFF09\uFF0C\u8DDF\u53F0\u8D26\u5199\u5F97\u4E0B\u5199\u4E0D\u4E0B**\u6CA1\u6709\u5173\u7CFB**\u3002\u505A\u5F97\u5230\u7684\u4E0B\u4E00\u6B65\uFF1A\u5728\u8FD9\u4E2A work \u76EE\u5F55\u4E0A\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`\uFF0C\u8BA9\u5B83\u7167\u5DE5\u4EF6\u4E0E\u6E90\u8868\u91CD\u7B97\u4E00\u4EFD\u884C\u952E\uFF1B\u90A3\u4E00\u884C\u7684\u539F\u6587\u89C1\u4E0A\u9762\u65B9\u62EC\u53F7\u540E\u9762\u90A3\u53E5\u3002",
|
|
12351
|
+
""
|
|
12352
|
+
]
|
|
12353
|
+
};
|
|
12354
|
+
var JOURNAL_STOP_UNKNOWN = [
|
|
12355
|
+
"\u8FD9\u4E00\u8F6E**\u505C\u5728\u8FD9\u91CC**\uFF1A\u53F0\u8D26\u8FD9\u4E00\u5C42\u62A5\u4E86\u4E00\u6761\u672C\u5C42\u8BA4\u4E0D\u51FA\u7684\u6210\u56E0",
|
|
12356
|
+
"\u672C\u5C42**\u8BF4\u4E0D\u51FA**\u5B83\u5C5E\u4E8E\u54EA\u4E00\u6863\uFF08\u65B9\u62EC\u53F7\u91CC\u90A3\u4E2A reason \u4E0D\u5728\u672C\u5C42\u7684\u5206\u6863\u8868\u91CC\uFF09\u2014\u2014 \u7167\u4E0A\u9762\u7684\u539F\u6587\u4E0E\u5B83\u81EA\u5E26\u7684 hint \u5904\u7406\u3002\u672C\u5C42\u4E0D\u66FF\u4F60\u731C\u65B9\u5411\uFF1A\u6307\u9519\u65B9\u5411\u6BD4\u4E0D\u6307\u65B9\u5411\u66F4\u8D35\u3002",
|
|
12357
|
+
""
|
|
12358
|
+
];
|
|
12359
|
+
function journalNote(journalPath, whenPresent = "") {
|
|
12360
|
+
if (!existsSync7(journalPath)) {
|
|
12361
|
+
return ` \u53F0\u8D26 \`${journalPath}\` **\u6B64\u523B\u4E0D\u5728\u76D8\u4E0A**\uFF08\u672C\u5C42\u521A\u67E5\u8FC7\uFF09\u2014\u2014\u6240\u4EE5\u6CA1\u6709\u300C\u5DF2\u7ECF\u8BB0\u4E0B\u6765\u7684\u5199\u300D\u53EF\u4EE5\u62FF\u3002`;
|
|
12362
|
+
}
|
|
12363
|
+
return ` \u53F0\u8D26\u5728 \`${journalPath}\`\u3002${whenPresent}`;
|
|
12364
|
+
}
|
|
12365
|
+
var APPLY_CAVEAT = "\u26A0\uFE0F \u8BA1\u5212\u4E0E\u5DE5\u4EF6\u53EA\u5BF9\u8FC7\u4E24\u683C\uFF08\u6A21\u578B\u6E05\u5355\u3001businessKey.fields\uFF09\u3002\u5DE5\u4EF6\u91CC**\u8FD9\u4E24\u683C\u4E4B\u5916\u7684\u4E00\u5207**\u6539\u4E86 kit \u90FD**\u5BF9\u4E0D\u51FA\u6765** \u2014\u2014 \u5217\u6620\u5C04 / valueMap / \u5E38\u91CF / source.file / source.sheet / onExisting / headerRow / businessKey.sourceColumns \u90FD\u7B97\uFF08\u8BA1\u5212\u91CC\u6CA1\u6709\u5DE5\u4EF6\u6307\u7EB9\uFF09\u2014\u2014 \u5DE5\u4EF6\u6539\u8FC7\u5C31\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`\u3002";
|
|
12366
|
+
var DRY_RUN_TAIL = "\u2191 \u8FD9\u662F**\u5E72\u8DD1**\uFF1A\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u6CA1\u6709\u53D1\u3002\u8981\u771F\u5199\uFF0C\u52A0 `--execute`\u3002";
|
|
12367
|
+
function planVsBaselinePremise(baselinePath, plannedRound, nowRound) {
|
|
12368
|
+
if (plannedRound === nowRound) return null;
|
|
12369
|
+
const notWaived = `\`${FORCE_STALE_FLAG_TEXT}\` \u4E0D\u8C41\u514D\u8FD9\u4E00\u6761 \u2014\u2014 \u5B83\u7BA1\u7684\u662F\u300C\u57FA\u7EBF\u5BF9\u4E0D\u5BF9\u5F97\u4E0A\u8FD9\u4E2A\u73AF\u5883\u300D\uFF0C\u4E0D\u662F\u300C\u8BA1\u5212\u5BF9\u4E0D\u5BF9\u5F97\u4E0A\u57FA\u7EBF\u300D\u3002`;
|
|
12370
|
+
if (plannedRound === null) {
|
|
12371
|
+
return [
|
|
12372
|
+
`\u8FD9\u4EFD\u8BA1\u5212**\u6CA1\u8BB0**\u57FA\u7EBF\u662F\u54EA\u4E00\u8F6E\uFF0C\u800C \`${baselinePath}\` \u73B0\u5728\u7ED9\u5F97\u51FA\u8F6E\u6B21 \`${nowRound}\` \u2014\u2014 **\u5224\u4E0D\u51FA**\u8FD9\u4EFD\u8BA1\u5212\u7167\u7684\u8FD8\u662F\u4E0D\u662F\u76D8\u4E0A\u8FD9\u4E00\u4EFD`,
|
|
12373
|
+
"\u8001\u57FA\u7EBF\u6CA1\u6709\u8F6E\u6B21\u6233\uFF0C\u6240\u4EE5\u8FD9\u91CC**\u6CA1\u6709**\u8BF4\u5B83\u53D8\u8FC7 \u2014\u2014 \u8BF4\u7684\u662F**\u67E5\u4E0D\u51FA\u6765**\uFF08\u91CD\u722C\u540C\u4E00\u4E2A\u73AF\u5883\u4E5F\u4F1A\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6233\uFF0C\u90A3\u79CD\u60C5\u51B5\u4E0B\u8FD9\u4EFD\u8BA1\u5212\u4ECD\u7136\u6709\u6548\uFF09\u3002\u91CD\u8DD1\u4E00\u6B21 `plan`\uFF08\u96F6\u5199\uFF1A`plan` \u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\uFF0C\u65B0\u8BA1\u5212\u4F1A\u5E26\u4E0A\u8F6E\u6B21\u6233\u3002" + notWaived
|
|
12374
|
+
];
|
|
12375
|
+
}
|
|
12376
|
+
if (nowRound === null) {
|
|
12377
|
+
return [
|
|
12378
|
+
`\u8FD9\u4EFD\u8BA1\u5212\u8BB0\u7684\u57FA\u7EBF\u8F6E\u6B21\u662F \`${plannedRound}\`\uFF0C\u800C \`${baselinePath}\` \u73B0\u5728**\u8BFB\u4E0D\u51FA**\u8F6E\u6B21\u6233\uFF08\u90A3\u4EFD\u6839\u90E8\u53F0\u8D26\u4E0D\u5728 / \u8BFB\u4E0D\u51FA\u6765 / \u91CC\u9762\u6CA1\u6709\u8F6E\u6B21\u6233\uFF09\u2014\u2014 **\u5224\u4E0D\u6E05**\u76D8\u4E0A\u8FD9\u4E00\u4EFD\u8FD8\u662F\u4E0D\u662F \`plan\` \u8BFB\u7684\u90A3\u4E00\u4EFD`,
|
|
12379
|
+
"\u8F6E\u6B21\u6233\u53EA\u6765\u81EA\u57FA\u7EBF\u76EE\u5F55\u91CC\u7684\u90A3\u4EFD\u6839\u90E8\u53F0\u8D26\uFF0C\u800C\u672C\u5C42\u53EA\u89C2\u6D4B\u5230\u300C\u8FD9\u4E00\u523B\u53D6\u4E0D\u5230\u5B83\u300D\u2014\u2014\u662F\u8C01\u52A8\u7684\u3001\u52A8\u6CA1\u52A8\uFF0C\u672C\u5C42**\u6CA1\u6709\u67E5\u8FC7**\u3002\u4E09\u6761\u51FA\u8DEF\u5E76\u5217\uFF0C\u4ECE\u6700\u4FBF\u5B9C\u7684\u5F00\u59CB\uFF1A\u2460 \u5148\u53BB\u770B\u4E00\u773C\u90A3\u4EFD\u6587\u4EF6\u5728\u4E0D\u5728\u3001\u6743\u9650\u5BF9\u4E0D\u5BF9\u3001\u5185\u5BB9\u662F\u4E0D\u662F\u88AB\u5199\u574F\u4E86\uFF08\u6743\u9650\u4E0D\u5BF9 / \u5199\u5230\u4E00\u534A\u8FD9\u4E24\u79CD\uFF0C\u57FA\u7EBF\u5185\u5BB9\u4E00\u4E2A\u5B57\u8282\u90FD\u6CA1\u53D8\uFF0C**\u522B\u52A8\u4EA7\u7269**\uFF09\uFF1B\u2461 \u786E\u5B9E\u662F\u62F7\u8D1D\u3001\u538B\u7F29\u5305\u6F0F\u5E26\uFF0C\u5C31\u628A\u90A3\u4EFD recon \u4EA7\u7269\u539F\u6837\u62F7\u56DE\u6765\uFF1B\u2462 \u90FD\u6392\u9664\u6389\uFF0C\u518D\u91CD\u8DD1\u4E00\u6B21 `hcm delivery recon` \u52A0\u4E00\u6B21 `plan`\uFF08\u96F6\u5199\uFF09\u3002\u{1F534} \u2461 \u4E0E \u2462 \u90FD\u6362\u6389\u76D8\u4E0A\u7684\u4EA7\u7269\uFF0C\u800C\u8FD9\u4EFD\u8BA1\u5212\u6B63\u662F\u7167\u65E7\u5185\u5BB9\u7B97\u7684 \u2014\u2014 \u6240\u4EE5\u5B83\u4EEC\u6392\u5728 \u2460 \u540E\u9762\u3002" + notWaived
|
|
12380
|
+
];
|
|
12381
|
+
}
|
|
12382
|
+
return [
|
|
12383
|
+
`\u8FD9\u4EFD\u8BA1\u5212\u7B97\u7684\u662F\u53E6\u4E00\u8F6E\u57FA\u7EBF\uFF1A\u8BA1\u5212\u91CC\u8BB0\u7684\u662F \`${plannedRound}\`\uFF0C\u800C \`${baselinePath}\` \u73B0\u5728\u662F \`${nowRound}\``,
|
|
12384
|
+
"\u8BA1\u5212\u91CC\u7684\u884C\u52A8\u4F5C\u3001\u65E2\u5B58\u7D22\u5F15\u4E0E\u98CE\u9669\u6E05\u5355\u90FD\u662F\u7167**\u90A3\u4E00\u8F6E\u7684\u57FA\u7EBF\u5185\u5BB9**\u7B97\u51FA\u6765\u7684\uFF0C\u6362\u4E86\u4E00\u8F6E\u4E4B\u540E\u5B83\u4EEC\u8BF4\u7684\u8FD8\u662F\u4E0A\u4E00\u7248\u3002\u91CD\u8DD1\u4E00\u6B21 `plan`\uFF08\u96F6\u5199\uFF1A`plan` \u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\u3002" + notWaived
|
|
12385
|
+
];
|
|
12386
|
+
}
|
|
12387
|
+
var FORCE_STALE_FLAG_TEXT = "--force-stale";
|
|
12388
|
+
function existingJournalStop(journalPath, entries) {
|
|
12389
|
+
return [
|
|
12390
|
+
`\u8FD9\u4E2A work \u76EE\u5F55\u5DF2\u7ECF\u6709\u4E00\u8F6E\u7684\u53F0\u8D26\uFF1A${journalPath}\uFF08${entries} \u6761\uFF09`,
|
|
12391
|
+
"\u8981**\u63A5\u7740\u8DD1**\u5C31\u52A0 `--resume`\uFF08\u53F0\u8D26\u672C\u6765\u5C31\u662F append-only\u3001\u6700\u540E\u4E00\u6761\u8D62\uFF0C\u7B2C\u4E8C\u8F6E\u6BCF\u884C\u600E\u4E48\u8D70\u7531\u53F0\u8D26\u81EA\u5DF1\u5224\uFF09\uFF1B\u8981**\u91CD\u6765**\u5C31\u6362\u4E00\u4E2A `--out` / `--work`\uFF0C\u6216\u8005\u4F60\u81EA\u5DF1\u5220\u6389\u90A3\u4EFD\u53F0\u8D26 \u2014\u2014 kit \u4E0D\u66FF\u4F60\u5220\uFF0C\u90A3\u662F\u4E0D\u53EF\u9006\u7684\u3002"
|
|
12392
|
+
];
|
|
12393
|
+
}
|
|
12335
12394
|
|
|
12336
12395
|
// src/fde/seed/plan-io.ts
|
|
12337
12396
|
import * as path15 from "path";
|
|
@@ -12499,166 +12558,2533 @@ function readImportPlan(out) {
|
|
|
12499
12558
|
"\u8FD9\u4EFD\u4EA7\u7269\u662F kit \u81EA\u5DF1\u5199\u7684 UTF-8 JSON\uFF0C\u800C\u8FD9\u4E00\u4EFD\u89E3\u4E0D\u51FA UTF-8\u3002\u5B83\u662F\u8C01\u5199\u7684\u3001\u88AB\u4EC0\u4E48\u52A8\u8FC7\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7** \u2014\u2014 \u5148\u81EA\u5DF1\u53BB\u770B\u4E00\u773C\u8FD9\u4EFD\u6587\u4EF6\uFF1B\u5185\u5BB9\u5B58\u7591\u7684\u8BA1\u5212\u4F1A\u628A\u4E0D\u8BE5\u5EFA\u7684\u884C\u5EFA\u8FDB\u5BA2\u6237\u5E93"
|
|
12500
12559
|
);
|
|
12501
12560
|
}
|
|
12502
|
-
let body;
|
|
12503
|
-
try {
|
|
12504
|
-
body = JSON.parse(raw);
|
|
12505
|
-
} catch (e) {
|
|
12506
|
-
throw new PlanReadError(
|
|
12507
|
-
"plan-bad-json",
|
|
12508
|
-
`${target} \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${e.message}`,
|
|
12509
|
-
"\u8FD9\u4EFD\u6587\u4EF6\u662F\u600E\u4E48\u53D8\u6210\u8FD9\u6837\u7684\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7**\u3002\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`\uFF0C\u5B83\u4F1A\u88AB\u6574\u4EFD\u91CD\u5199"
|
|
12561
|
+
let body;
|
|
12562
|
+
try {
|
|
12563
|
+
body = JSON.parse(raw);
|
|
12564
|
+
} catch (e) {
|
|
12565
|
+
throw new PlanReadError(
|
|
12566
|
+
"plan-bad-json",
|
|
12567
|
+
`${target} \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${e.message}`,
|
|
12568
|
+
"\u8FD9\u4EFD\u6587\u4EF6\u662F\u600E\u4E48\u53D8\u6210\u8FD9\u6837\u7684\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7**\u3002\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`\uFF0C\u5B83\u4F1A\u88AB\u6574\u4EFD\u91CD\u5199"
|
|
12569
|
+
);
|
|
12570
|
+
}
|
|
12571
|
+
if (isObject(body) && !("version" in body)) {
|
|
12572
|
+
throw new PlanReadError(
|
|
12573
|
+
"plan-version-missing",
|
|
12574
|
+
`${target} \u6CA1\u6709 version \u5B57\u6BB5`,
|
|
12575
|
+
"\u8FD9\u4E0D\u662F\u672C kit \u5199\u51FA\u6765\u7684 `import-plan.json`\uFF08\u5B83\u4E00\u5B9A\u5E26 version\uFF09\u3002\u5728\u8FD9\u4E2A work \u76EE\u5F55\u4E0A\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`"
|
|
12576
|
+
);
|
|
12577
|
+
}
|
|
12578
|
+
if (isObject(body) && body.version !== VERSION2) {
|
|
12579
|
+
throw new PlanReadError(
|
|
12580
|
+
"plan-unsupported-version",
|
|
12581
|
+
`${target} \u7684 version \u662F ${JSON.stringify(body.version)}\uFF0C\u672C\u5DE5\u5177\u53EA\u8BA4 ${VERSION2}`,
|
|
12582
|
+
"\u5199\u51FA\u8FD9\u4E2A\u7248\u672C\u53F7\u7684\u662F\u54EA\u4E00\u7248 kit\u3001\u8FD9\u4EFD\u4EA7\u7269\u4ECE\u54EA\u6765\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7**\u3002\u{1F534} \u522B\u6539\u8FD9\u4E2A\u6570\u5B57\u9A97\u8FC7\u95F8\u95E8\uFF1A\u5F62\u72B6\u8BFB\u5F97\u56DE\u6765\u4E0D\u7B49\u4E8E\u8BED\u4E49\u76F8\u540C\u3002\u7528\u5199\u51FA\u5B83\u7684\u90A3\u4E00\u7248 kit\uFF0C\u6216\u5728\u672C\u673A\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`"
|
|
12583
|
+
);
|
|
12584
|
+
}
|
|
12585
|
+
try {
|
|
12586
|
+
return planFromJson(body);
|
|
12587
|
+
} catch (e) {
|
|
12588
|
+
throw new PlanReadError(
|
|
12589
|
+
"plan-bad-shape",
|
|
12590
|
+
`${target} \u7684\u5F62\u72B6\u4E0D\u5BF9\uFF08${e.name}: ${e.message}\uFF09`,
|
|
12591
|
+
`\u5B83\u5E94\u5F53\u662F writeImportPlan \u5199\u51FA\u6765\u7684\u90A3\u4EFD\u5F62\u72B6\uFF08${PLAN_JSON_KEYS.join(" / ")}\uFF09\u3002\u91CD\u65B0\u8DD1\u4E00\u6B21 \`plan\``
|
|
12592
|
+
);
|
|
12593
|
+
}
|
|
12594
|
+
}
|
|
12595
|
+
function isObject(v) {
|
|
12596
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
12597
|
+
}
|
|
12598
|
+
function need(o, key) {
|
|
12599
|
+
if (!(key in o)) throw new Error(`\u5C11\u4E86 ${key} \u952E`);
|
|
12600
|
+
return o[key];
|
|
12601
|
+
}
|
|
12602
|
+
function objectOf(v, what) {
|
|
12603
|
+
if (!isObject(v)) throw new TypeError(`${what} \u5FC5\u987B\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF0C\u8FD9\u4E00\u4EFD\u662F ${describe2(v)}`);
|
|
12604
|
+
return v;
|
|
12605
|
+
}
|
|
12606
|
+
function arrayOf(v, what) {
|
|
12607
|
+
if (!Array.isArray(v)) throw new TypeError(`${what} \u5FC5\u987B\u662F JSON \u6570\u7EC4\uFF0C\u8FD9\u4E00\u4EFD\u662F ${describe2(v)}`);
|
|
12608
|
+
return v;
|
|
12609
|
+
}
|
|
12610
|
+
function describe2(v) {
|
|
12611
|
+
if (v === null) return "null";
|
|
12612
|
+
if (Array.isArray(v)) return `\u6570\u7EC4\uFF1A${JSON.stringify(v)}`;
|
|
12613
|
+
return `${typeof v}\uFF1A${JSON.stringify(v)}`;
|
|
12614
|
+
}
|
|
12615
|
+
function planFromJson(body) {
|
|
12616
|
+
const o = objectOf(body, "\u9876\u5C42");
|
|
12617
|
+
return {
|
|
12618
|
+
version: need(o, "version"),
|
|
12619
|
+
roundId: need(o, "roundId"),
|
|
12620
|
+
models: arrayOf(need(o, "models"), "models").map(modelFromJson),
|
|
12621
|
+
problems: arrayOf(need(o, "problems"), "problems").map((p) => ({
|
|
12622
|
+
...objectOf(p, "problems[]")
|
|
12623
|
+
})),
|
|
12624
|
+
notes: arrayOf(need(o, "notes"), "notes").map((n) => objectOf(n, "notes[]")),
|
|
12625
|
+
crossModelOrder: { ...objectOf(need(o, "crossModelOrder"), "crossModelOrder") },
|
|
12626
|
+
baseline: baselineFromJson(o)
|
|
12627
|
+
};
|
|
12628
|
+
}
|
|
12629
|
+
function baselineFromJson(body) {
|
|
12630
|
+
if (!("baseline" in body)) return null;
|
|
12631
|
+
const raw = body.baseline;
|
|
12632
|
+
if (raw === null) return null;
|
|
12633
|
+
if (!isObject(raw)) {
|
|
12634
|
+
throw new TypeError(
|
|
12635
|
+
`baseline \u5FC5\u987B\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF08planToJson \u5199\u51FA\u53BB\u7684\u5C31\u662F\u5BF9\u8C61\uFF0C\u6216\u8005\u6574\u4E2A\u662F null\uFF09\uFF0C\u8FD9\u4E00\u4EFD\u662F ${describe2(raw)}`
|
|
12636
|
+
);
|
|
12637
|
+
}
|
|
12638
|
+
const missing = ["path", "roundId"].filter((k) => !(k in raw));
|
|
12639
|
+
if (missing.length) {
|
|
12640
|
+
throw new Error(`baseline \u5C11\u4E86\u8FD9\u4E9B\u952E\uFF1A${missing.join("\u3001")}\uFF08\u5199\u51FA\u53BB\u7684\u4E24\u4E2A\u952E\u662F path / roundId\uFF09`);
|
|
12641
|
+
}
|
|
12642
|
+
if (typeof raw.path !== "string") {
|
|
12643
|
+
throw new TypeError(`baseline.path \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\uFF0C\u8FD9\u4E00\u4EFD\u662F ${describe2(raw.path)}`);
|
|
12644
|
+
}
|
|
12645
|
+
if (raw.roundId !== null && typeof raw.roundId !== "string") {
|
|
12646
|
+
throw new TypeError(
|
|
12647
|
+
`baseline.roundId \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216 null\uFF08\u8001\u57FA\u7EBF\u7ED9\u4E0D\u51FA\u8F6E\u6B21\u6233\u65F6\u5C31\u662F null\uFF09\uFF0C\u8FD9\u4E00\u4EFD\u662F ${describe2(raw.roundId)}`
|
|
12648
|
+
);
|
|
12649
|
+
}
|
|
12650
|
+
return { path: raw.path, roundId: raw.roundId };
|
|
12651
|
+
}
|
|
12652
|
+
function modelFromJson(m) {
|
|
12653
|
+
const o = objectOf(m, "models[]");
|
|
12654
|
+
const waves = need(o, "waves");
|
|
12655
|
+
return {
|
|
12656
|
+
model: need(o, "model"),
|
|
12657
|
+
businessKeyFields: arrayOf(need(o, "businessKeyFields"), "businessKeyFields"),
|
|
12658
|
+
rowCount: need(o, "rowCount"),
|
|
12659
|
+
waves: waves === null ? null : arrayOf(waves, "waves").map(waveFromJson),
|
|
12660
|
+
existingMatched: need(o, "existingMatched"),
|
|
12661
|
+
toCreate: need(o, "toCreate"),
|
|
12662
|
+
plannedToCreate: need(o, "plannedToCreate"),
|
|
12663
|
+
onExisting: need(o, "onExisting"),
|
|
12664
|
+
planned: need(o, "planned"),
|
|
12665
|
+
blockedChecks: new Map(
|
|
12666
|
+
Object.entries(objectOf(need(o, "blockedChecks"), "blockedChecks")).map(([k, v]) => [
|
|
12667
|
+
k,
|
|
12668
|
+
arrayOf(v, `blockedChecks.${k}`)
|
|
12669
|
+
])
|
|
12670
|
+
),
|
|
12671
|
+
rowsNotInWaves: new Map(
|
|
12672
|
+
Object.entries(objectOf(need(o, "rowsNotInWaves"), "rowsNotInWaves"))
|
|
12673
|
+
),
|
|
12674
|
+
selfReference: { ...objectOf(need(o, "selfReference"), "selfReference") }
|
|
12675
|
+
};
|
|
12676
|
+
}
|
|
12677
|
+
function waveFromJson(w) {
|
|
12678
|
+
const o = objectOf(w, "waves[]");
|
|
12679
|
+
return {
|
|
12680
|
+
wave: need(o, "wave"),
|
|
12681
|
+
kind: need(o, "kind"),
|
|
12682
|
+
rows: arrayOf(need(o, "rows"), "waves[].rows").map(rowFromJson)
|
|
12683
|
+
};
|
|
12684
|
+
}
|
|
12685
|
+
function keyFromJson(r) {
|
|
12686
|
+
const key = need(r, "key");
|
|
12687
|
+
if (!Array.isArray(key)) {
|
|
12688
|
+
throw new TypeError(
|
|
12689
|
+
`rows[].key \u5FC5\u987B\u662F JSON \u6570\u7EC4\uFF08planToJson \u5199\u51FA\u53BB\u7684\u5C31\u662F\u6570\u7EC4\uFF09\uFF0C\u8FD9\u4E00\u884C\u662F ${describe2(key)}`
|
|
12690
|
+
);
|
|
12691
|
+
}
|
|
12692
|
+
const bad = key.findIndex((part) => typeof part !== "string");
|
|
12693
|
+
if (bad >= 0) {
|
|
12694
|
+
throw new TypeError(
|
|
12695
|
+
`rows[].key \u7684\u7B2C ${bad + 1} \u683C\u4E0D\u662F\u5B57\u7B26\u4E32\uFF08\u4E1A\u52A1\u952E\u7684\u6BCF\u4E00\u683C\u90FD\u662F\u5B57\u7B26\u4E32\uFF09\uFF0C\u8FD9\u4E00\u683C\u662F ${describe2(key[bad])}`
|
|
12696
|
+
);
|
|
12697
|
+
}
|
|
12698
|
+
return key;
|
|
12699
|
+
}
|
|
12700
|
+
function rowFromJson(r) {
|
|
12701
|
+
const o = objectOf(r, "waves[].rows[]");
|
|
12702
|
+
return {
|
|
12703
|
+
row: need(o, "row"),
|
|
12704
|
+
key: keyFromJson(o),
|
|
12705
|
+
action: need(o, "action"),
|
|
12706
|
+
existingId: need(o, "existingId"),
|
|
12707
|
+
fields: new Map(Object.entries(objectOf(need(o, "fields"), "rows[].fields"))),
|
|
12708
|
+
refs: arrayOf(need(o, "refs"), "rows[].refs").map((f) => {
|
|
12709
|
+
const g = objectOf(f, "rows[].refs[]");
|
|
12710
|
+
return {
|
|
12711
|
+
field: need(g, "field"),
|
|
12712
|
+
model: need(g, "model"),
|
|
12713
|
+
keyField: need(g, "keyField"),
|
|
12714
|
+
value: need(g, "value"),
|
|
12715
|
+
resolvedId: need(g, "resolvedId"),
|
|
12716
|
+
resolveFrom: need(g, "resolveFrom"),
|
|
12717
|
+
parentWave: need(g, "parentWave")
|
|
12718
|
+
};
|
|
12719
|
+
})
|
|
12720
|
+
};
|
|
12721
|
+
}
|
|
12722
|
+
|
|
12723
|
+
// src/fde/seed/journal.ts
|
|
12724
|
+
import { createHash as createHash4 } from "crypto";
|
|
12725
|
+
import { existsSync as existsSync8, statSync as statSync7 } from "fs";
|
|
12726
|
+
import * as os3 from "os";
|
|
12727
|
+
import * as path16 from "path";
|
|
12728
|
+
var JOURNAL_FILE = "journal.jsonl";
|
|
12729
|
+
var STATUSES = ["done", "skipped", "failed", "unknown", "quarantined"];
|
|
12730
|
+
var STEP_SEND = "send";
|
|
12731
|
+
var STEP_READBACK = "readback";
|
|
12732
|
+
var STEP_NOTHING = "nothing";
|
|
12733
|
+
var STEP_STOP = "stop";
|
|
12734
|
+
var NEXT_STEP = {
|
|
12735
|
+
// 用字符串 `'null'` 当键会与一个真叫 "null" 的状态撞;这里用 `Map` 的等价写法:
|
|
12736
|
+
// 键就是 `String(status)`,而 `STATUSES` 里没有 `"null"` 这个值(值域守卫钉着)。
|
|
12737
|
+
null: STEP_SEND,
|
|
12738
|
+
done: STEP_NOTHING,
|
|
12739
|
+
skipped: STEP_NOTHING,
|
|
12740
|
+
// 收到过明确拒绝 ⇒ 服务端那边**什么都没建** ⇒ 重发是安全的。
|
|
12741
|
+
// 🔴 **写这一档的调用方必须已经查证过「没建成」**:只是「按这个业务键查不到」**不够** ——
|
|
12742
|
+
// 服务端可能刚接受了一次写、只是存成了别的键,那时重发会再造一条野行。那一档归
|
|
12743
|
+
// `quarantined`。⚠️ 「可以重放」不等于「重放会成功」:多半要顾问先改数据。
|
|
12744
|
+
failed: STEP_SEND,
|
|
12745
|
+
// 🔴 承重:既不是 send 也不是 readback。回读已经问过了,答案是「按这个键没有」,
|
|
12746
|
+
// 而服务端那边**可能有一行别的键的**。自动做任何事都只会让情况更糟。
|
|
12747
|
+
quarantined: STEP_STOP,
|
|
12748
|
+
// 🔴 承重:**不许**退化成 STEP_SEND。
|
|
12749
|
+
unknown: STEP_READBACK
|
|
12750
|
+
};
|
|
12751
|
+
var NEEDS_PRIOR_RECORD = ["done", "failed", "quarantined"];
|
|
12752
|
+
var ENTRY_KEYS2 = [
|
|
12753
|
+
"sourceRowId",
|
|
12754
|
+
"model",
|
|
12755
|
+
"businessKey",
|
|
12756
|
+
"payloadHash",
|
|
12757
|
+
"serverId",
|
|
12758
|
+
"status",
|
|
12759
|
+
"attempts",
|
|
12760
|
+
"roundId"
|
|
12761
|
+
];
|
|
12762
|
+
var KIND_KEY = "kind";
|
|
12763
|
+
var KIND_ENTRY = "entry";
|
|
12764
|
+
var KIND_DRIFT_WAIVER = "drift-waiver";
|
|
12765
|
+
var KINDS = [KIND_ENTRY, KIND_DRIFT_WAIVER];
|
|
12766
|
+
var WAIVER_KEYS = [
|
|
12767
|
+
"kind",
|
|
12768
|
+
"roundId",
|
|
12769
|
+
"at",
|
|
12770
|
+
"verdict",
|
|
12771
|
+
"causes",
|
|
12772
|
+
"gateDiffs",
|
|
12773
|
+
"incomplete",
|
|
12774
|
+
"advisory",
|
|
12775
|
+
"baseline"
|
|
12776
|
+
];
|
|
12777
|
+
var JournalError = class extends Error {
|
|
12778
|
+
reason;
|
|
12779
|
+
detail;
|
|
12780
|
+
hint;
|
|
12781
|
+
constructor(reason, detail, hint = "") {
|
|
12782
|
+
super(`[${reason}] ${detail}${hint ? ` \u2014\u2014 ${hint}` : ""}`);
|
|
12783
|
+
this.name = "JournalError";
|
|
12784
|
+
this.reason = reason;
|
|
12785
|
+
this.detail = detail;
|
|
12786
|
+
this.hint = hint;
|
|
12787
|
+
}
|
|
12788
|
+
};
|
|
12789
|
+
function nowStamp(at = /* @__PURE__ */ new Date()) {
|
|
12790
|
+
return stampOf(at);
|
|
12791
|
+
}
|
|
12792
|
+
function stampOf(at) {
|
|
12793
|
+
return at.toISOString().replace(/Z$/, "+00:00");
|
|
12794
|
+
}
|
|
12795
|
+
function parseStamp(text2) {
|
|
12796
|
+
if (typeof text2 !== "string" || !text2.trim()) {
|
|
12797
|
+
return [null, `\u4E0D\u662F\u4E00\u4E2A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF1A${JSON.stringify(text2)}`];
|
|
12798
|
+
}
|
|
12799
|
+
let normalised = text2.trim();
|
|
12800
|
+
if (/[Zz]$/.test(normalised)) normalised = `${normalised.slice(0, -1)}+00:00`;
|
|
12801
|
+
if (!/(?:[+-]\d{2}:?\d{2})$/.test(normalised)) {
|
|
12802
|
+
return [
|
|
12803
|
+
null,
|
|
12804
|
+
`${JSON.stringify(text2)} \u6CA1\u6709\u65F6\u533A\u504F\u79FB \u2014\u2014 \u5B83\u662F\u672C\u673A\u65F6\u95F4\u8FD8\u662F UTC \u65E0\u4ECE\u5F97\u77E5\uFF0C\u4E24\u79CD\u89E3\u91CA\u5DEE\u51FA\u6765\u7684\u5C0F\u65F6\u6570\u8DB3\u4EE5\u628A\u300C\u9648\u65E7\u300D\u5224\u6210\u300C\u6D3B\u7740\u300D`
|
|
12805
|
+
];
|
|
12806
|
+
}
|
|
12807
|
+
const moment = new Date(normalised);
|
|
12808
|
+
if (Number.isNaN(moment.getTime())) {
|
|
12809
|
+
return [null, `\u4E0D\u662F\u80FD\u89E3\u6790\u7684 ISO 8601 \u65F6\u95F4\u6233\uFF1A${JSON.stringify(text2)}`];
|
|
12810
|
+
}
|
|
12811
|
+
return [moment, ""];
|
|
12812
|
+
}
|
|
12813
|
+
function canonicalise(value, at = "$") {
|
|
12814
|
+
if (value === null) return null;
|
|
12815
|
+
const t = typeof value;
|
|
12816
|
+
if (t === "string" || t === "boolean") return value;
|
|
12817
|
+
if (t === "number") {
|
|
12818
|
+
if (!Number.isFinite(value)) {
|
|
12819
|
+
throw new TypeError(`${at} \u662F ${String(value)}\uFF0CJSON \u8868\u793A\u4E0D\u4E86\u5B83 \u2014\u2014 \u6362\u4E2A\u8868\u793A\u6CD5\u5C31\u7B49\u4E8E\u4E24\u6B21\u8C03\u7528\u7ED9\u51FA\u4E24\u4E2A\u54C8\u5E0C`);
|
|
12820
|
+
}
|
|
12821
|
+
return value;
|
|
12822
|
+
}
|
|
12823
|
+
if (t === "undefined" || t === "function" || t === "symbol" || t === "bigint") {
|
|
12824
|
+
throw new TypeError(`${at} \u662F ${t}\uFF0CJSON \u5E8F\u5217\u5316\u4E0D\u4E86\u5B83\uFF08JSON.stringify \u4F1A\u9759\u9ED8\u4E22\u6389\u8FD9\u4E2A\u952E\uFF09`);
|
|
12825
|
+
}
|
|
12826
|
+
if (Array.isArray(value)) return value.map((v, i) => canonicalise(v, `${at}[${i}]`));
|
|
12827
|
+
const obj = value;
|
|
12828
|
+
const out = {};
|
|
12829
|
+
for (const key of Object.keys(obj).sort()) out[key] = canonicalise(obj[key], `${at}.${key}`);
|
|
12830
|
+
return out;
|
|
12831
|
+
}
|
|
12832
|
+
function payloadHash(payload) {
|
|
12833
|
+
const text2 = JSON.stringify(canonicalise(payload));
|
|
12834
|
+
return `sha256:${createHash4("sha256").update(text2, "utf8").digest("hex")}`;
|
|
12835
|
+
}
|
|
12836
|
+
function businessKeyOf(value) {
|
|
12837
|
+
if (typeof value === "string" || !Array.isArray(value)) {
|
|
12838
|
+
throw new JournalError(
|
|
12839
|
+
"bad-entry",
|
|
12840
|
+
`businessKey \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7684\u6570\u7EC4\uFF0C\u6536\u5230 ${JSON.stringify(value)}`,
|
|
12841
|
+
"\u4E1A\u52A1\u952E\u662F\u590D\u5408\u7684\uFF08\u5DE5\u4EF6\u5C42 businessKey.fields \u53EF\u4EE5\u6709\u591A\u4E2A\u5B57\u6BB5\uFF09\uFF0C\u6240\u4EE5\u8FD9\u91CC\u6052\u662F\u4E00\u4E2A\u5E8F\u5217\uFF0C\u54EA\u6015\u53EA\u6709\u4E00\u4E2A\u5B57\u6BB5"
|
|
12842
|
+
);
|
|
12843
|
+
}
|
|
12844
|
+
if (value.length === 0) {
|
|
12845
|
+
throw new JournalError(
|
|
12846
|
+
"bad-entry",
|
|
12847
|
+
"businessKey \u662F\u7A7A\u7684",
|
|
12848
|
+
"\u7A7A\u4E1A\u52A1\u952E\u5F53\u4E0D\u4E86\u5E42\u7B49\u7684\u652F\u70B9 \u2014\u2014 \u8BA1\u5212\u5C42\u7684 BUSINESS_KEY_VALUE_MISSING \u5C31\u662F\u62E6\u8FD9\u4E2A\u7684\uFF0C\u8D70\u5230\u8FD9\u91CC\u8BF4\u660E\u90A3\u4E00\u6B65\u88AB\u8DF3\u8FC7\u4E86"
|
|
12849
|
+
);
|
|
12850
|
+
}
|
|
12851
|
+
for (const part of value) {
|
|
12852
|
+
if (typeof part !== "string" || !part.trim()) {
|
|
12853
|
+
throw new JournalError(
|
|
12854
|
+
"bad-entry",
|
|
12855
|
+
`businessKey \u91CC\u6709\u5143\u7D20\u4E0D\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\uFF1A${JSON.stringify(part)}\uFF08\u6574\u4E2A\u952E ${JSON.stringify(value)}\uFF09`,
|
|
12856
|
+
"\u53F0\u8D26\u8981\u5199\u5230\u78C1\u76D8\u518D\u8BFB\u56DE\u6765\uFF0C\u975E\u5B57\u7B26\u4E32\u7684\u952E\u5728 JSON \u5F80\u8FD4\u4E4B\u540E\u4E0E\u8BA1\u5212\u90A3\u8FB9\u7684\u5B57\u7B26\u4E32\u952E**\u6C38\u8FDC\u914D\u4E0D\u4E0A**\uFF0C\u8868\u73B0\u662F\u8FD9\u4E00\u884C\u88AB\u5F53\u6210\u300C\u4ECE\u6CA1\u8BB0\u8FC7\u300D\u800C\u91CD\u653E"
|
|
12857
|
+
);
|
|
12858
|
+
}
|
|
12859
|
+
}
|
|
12860
|
+
return [...value];
|
|
12861
|
+
}
|
|
12862
|
+
function entryJson(entry) {
|
|
12863
|
+
const out = {
|
|
12864
|
+
sourceRowId: entry.sourceRowId,
|
|
12865
|
+
model: entry.model,
|
|
12866
|
+
businessKey: [...entry.businessKey],
|
|
12867
|
+
payloadHash: entry.payloadHash,
|
|
12868
|
+
serverId: entry.serverId,
|
|
12869
|
+
status: entry.status,
|
|
12870
|
+
attempts: entry.attempts,
|
|
12871
|
+
roundId: entry.roundId
|
|
12872
|
+
};
|
|
12873
|
+
if (entry.error !== void 0 && entry.error !== null) out.error = entry.error;
|
|
12874
|
+
return out;
|
|
12875
|
+
}
|
|
12876
|
+
function entryFromJson(row, where) {
|
|
12877
|
+
const missing = ENTRY_KEYS2.filter((k) => !(k in row));
|
|
12878
|
+
if (missing.length > 0) {
|
|
12879
|
+
throw new JournalError(
|
|
12880
|
+
"journal-bad-line",
|
|
12881
|
+
`${where} \u7F3A\u4E86 ${JSON.stringify(missing)} \u8FD9\u51E0\u4E2A\u952E`,
|
|
12882
|
+
`\u53F0\u8D26\u6BCF\u4E00\u884C\u7684\u952E\u96C6\u662F\u5B9A\u6B7B\u7684\uFF08${JSON.stringify([...ENTRY_KEYS2])}\uFF09\u3002\u7F3A\u952E\u7684\u884C\u8BFB\u4E0D\u51FA\u7ED3\u8BBA \u2014\u2014 \u800C\u300C\u8BFB\u4E0D\u51FA\u300D\u88AB\u5F53\u6210\u300C\u6CA1\u8BB0\u8FC7\u300D\u5C31\u4F1A\u91CD\u653E\u8FD9\u4E00\u884C`
|
|
12883
|
+
);
|
|
12884
|
+
}
|
|
12885
|
+
if (!STATUSES.includes(row.status)) {
|
|
12886
|
+
throw new JournalError(
|
|
12887
|
+
"journal-bad-line",
|
|
12888
|
+
`${where} \u7684 status \u662F ${JSON.stringify(row.status)}\uFF0C\u4E0D\u5728 ${JSON.stringify([...STATUSES])} \u91CC`,
|
|
12889
|
+
"\u8BA4\u4E0D\u51FA\u7684\u72B6\u6001\u6CA1\u6709\u5BF9\u5E94\u7684\u5904\u7F6E \u2014\u2014 \u731C\u4E00\u4E2A\uFF08\u6BD4\u5982\u5F53\u6210 failed \u53BB\u91CD\u653E\uFF09\u6B63\u597D\u662F\u6700\u574F\u7684\u90A3\u79CD\u731C\u6CD5"
|
|
12890
|
+
);
|
|
12891
|
+
}
|
|
12892
|
+
for (const field of ["attempts", "sourceRowId"]) {
|
|
12893
|
+
const value = row[field];
|
|
12894
|
+
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
12895
|
+
throw new JournalError(
|
|
12896
|
+
"journal-bad-line",
|
|
12897
|
+
`${where} \u7684 ${field} \u662F ${JSON.stringify(value)}\uFF0C\u4E0D\u662F\u6574\u6570`,
|
|
12898
|
+
"\u8FD9\u4E24\u4E2A\u952E\u90FD\u662F\u6570\uFF1Aattempts \u662F\u300C\u53D1\u8FC7\u51E0\u6B21\u8BF7\u6C42\u300D\uFF0CsourceRowId \u662F\u6E90\u8868\u884C\u53F7\u3002\u88AB\u522B\u7684\u5DE5\u5177\u6539\u8FC7\u7684\u53F0\u8D26\u4E0D\u53EF\u4FE1 \u2014\u2014 \u800C\u4E0D\u53EF\u4FE1\u7684\u53F0\u8D26\u6BD4\u6CA1\u6709\u53F0\u8D26\u66F4\u5371\u9669"
|
|
12899
|
+
);
|
|
12900
|
+
}
|
|
12901
|
+
}
|
|
12902
|
+
return {
|
|
12903
|
+
sourceRowId: row.sourceRowId,
|
|
12904
|
+
model: row.model,
|
|
12905
|
+
businessKey: businessKeyOf(row.businessKey),
|
|
12906
|
+
payloadHash: row.payloadHash ?? null,
|
|
12907
|
+
serverId: row.serverId ?? null,
|
|
12908
|
+
status: row.status,
|
|
12909
|
+
attempts: row.attempts,
|
|
12910
|
+
roundId: row.roundId,
|
|
12911
|
+
error: row.error
|
|
12912
|
+
};
|
|
12913
|
+
}
|
|
12914
|
+
function waiverJson(waiver) {
|
|
12915
|
+
return {
|
|
12916
|
+
kind: KIND_DRIFT_WAIVER,
|
|
12917
|
+
roundId: waiver.roundId,
|
|
12918
|
+
at: waiver.at,
|
|
12919
|
+
verdict: waiver.verdict,
|
|
12920
|
+
causes: [...waiver.causes],
|
|
12921
|
+
gateDiffs: [...waiver.gateDiffs],
|
|
12922
|
+
incomplete: [...waiver.incomplete],
|
|
12923
|
+
advisory: [...waiver.advisory],
|
|
12924
|
+
baseline: waiver.baseline
|
|
12925
|
+
};
|
|
12926
|
+
}
|
|
12927
|
+
function strArray(value, key, where) {
|
|
12928
|
+
if (!Array.isArray(value) || value.some((x) => typeof x !== "string")) {
|
|
12929
|
+
throw new JournalError(
|
|
12930
|
+
"journal-bad-line",
|
|
12931
|
+
`${where} \u7684 ${key} \u662F ${JSON.stringify(value)}\uFF0C\u4E0D\u662F\u4E00\u4E2A\u5B57\u7B26\u4E32\u6570\u7EC4`,
|
|
12932
|
+
"\u8FD9\u56DB\u683C\u662F\u653E\u884C\u90A3\u4E00\u523B\u5224\u636E\u8BF4\u7684\u8BDD\uFF0C\u539F\u6837\u843D\u76D8\uFF1B\u5F62\u72B6\u4E0D\u5BF9\u7684\u884C\u8BFB\u4E0D\u51FA\u7ED3\u8BBA\uFF0C\u800C\u8BFB\u4E0D\u51FA\u7684\u653E\u884C\u8BB0\u5F55\u4E0E\u300C\u6CA1\u6709\u653E\u884C\u8BB0\u5F55\u300D\u5728\u5C4F\u5E55\u4E0A\u957F\u5F97\u4E00\u6837"
|
|
12933
|
+
);
|
|
12934
|
+
}
|
|
12935
|
+
return [...value];
|
|
12936
|
+
}
|
|
12937
|
+
function waiverFromJson(row, where) {
|
|
12938
|
+
const missing = WAIVER_KEYS.filter((k) => !(k in row));
|
|
12939
|
+
if (missing.length > 0) {
|
|
12940
|
+
throw new JournalError(
|
|
12941
|
+
"journal-bad-line",
|
|
12942
|
+
`${where} \u7F3A\u4E86 ${JSON.stringify(missing)} \u8FD9\u51E0\u4E2A\u952E`,
|
|
12943
|
+
`\u653E\u884C\u8BB0\u5F55\u6BCF\u4E00\u884C\u7684\u952E\u96C6\u662F\u5B9A\u6B7B\u7684\uFF08${JSON.stringify([...WAIVER_KEYS])}\uFF09`
|
|
12944
|
+
);
|
|
12945
|
+
}
|
|
12946
|
+
for (const key of ["roundId", "at", "verdict"]) {
|
|
12947
|
+
if (typeof row[key] !== "string") {
|
|
12948
|
+
throw new JournalError(
|
|
12949
|
+
"journal-bad-line",
|
|
12950
|
+
`${where} \u7684 ${key} \u662F ${JSON.stringify(row[key])}\uFF0C\u4E0D\u662F\u5B57\u7B26\u4E32`,
|
|
12951
|
+
"\u8FD9\u4E09\u4E2A\u952E\u90FD\u662F\u4E32\u3002\u8FD9\u4E00\u884C\u662F\u8C01\u5199\u7684\u3001\u88AB\u4EC0\u4E48\u52A8\u8FC7\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7** \u2014\u2014 \u5185\u5BB9\u5B58\u7591\u7684\u53F0\u8D26\u6BD4\u6CA1\u6709\u53F0\u8D26\u66F4\u5371\u9669"
|
|
12952
|
+
);
|
|
12953
|
+
}
|
|
12954
|
+
}
|
|
12955
|
+
if (!(row.baseline === null || typeof row.baseline === "string")) {
|
|
12956
|
+
throw new JournalError(
|
|
12957
|
+
"journal-bad-line",
|
|
12958
|
+
`${where} \u7684 baseline \u662F ${JSON.stringify(row.baseline)}\uFF0C\u4E0D\u662F\u5B57\u7B26\u4E32\u6216 null`,
|
|
12959
|
+
"`null` \u7684\u610F\u601D\u662F\u300C\u90A3\u4E00\u8F6E\u7684\u8BA1\u5212\u91CC\u6CA1\u8BF4\u662F\u54EA\u4E00\u4EFD\u57FA\u7EBF\u300D\uFF0C\u4E0E\u300C\u51FA\u5904\u662F\u7A7A\u4E32\u300D\u4E0D\u662F\u4E00\u56DE\u4E8B"
|
|
12960
|
+
);
|
|
12961
|
+
}
|
|
12962
|
+
return {
|
|
12963
|
+
roundId: row.roundId,
|
|
12964
|
+
at: row.at,
|
|
12965
|
+
verdict: row.verdict,
|
|
12966
|
+
causes: strArray(row.causes, "causes", where),
|
|
12967
|
+
gateDiffs: strArray(row.gateDiffs, "gateDiffs", where),
|
|
12968
|
+
incomplete: strArray(row.incomplete, "incomplete", where),
|
|
12969
|
+
advisory: strArray(row.advisory, "advisory", where),
|
|
12970
|
+
baseline: row.baseline
|
|
12971
|
+
};
|
|
12972
|
+
}
|
|
12973
|
+
function workDirOf(p) {
|
|
12974
|
+
if (existsSync8(p) && !statSync7(p).isDirectory()) {
|
|
12975
|
+
throw new JournalError(
|
|
12976
|
+
"not-a-work-dir",
|
|
12977
|
+
`${p} \u5DF2\u5B58\u5728\uFF0C\u4F46\u5B83\u4E0D\u662F\u76EE\u5F55 \u2014\u2014 \u53F0\u8D26\u6536\u7684\u662F **work \u76EE\u5F55**\uFF0C\u4E0D\u662F\u53F0\u8D26\u6587\u4EF6`,
|
|
12978
|
+
`\u4F20 \`work/\`\uFF08\u4E0E\u79DF\u7EA6\u540C\u4E00\u4E2A\u5165\u53C2\uFF09\uFF0C\u53F0\u8D26\u56FA\u5B9A\u843D\u5728\u5B83\u4E0B\u9762\u7684 ${JOURNAL_FILE}\u3002\u{1F534} \u8FD9\u91CC\u786C\u5931\u8D25\u662F\u6709\u610F\u7684\uFF1A\u4F20\u6210\u6587\u4EF6\u65F6\u300C${JOURNAL_FILE} \u5728\u4E0D\u5728\u300D\u6052\u7B54\u300C\u4E0D\u5728\u300D\uFF0C\u9759\u9ED8\u8D70\u8FDB\u300C\u7B2C\u4E00\u8F6E\u3001\u7A7A\u53F0\u8D26\u300D\u90A3\u4E00\u6863\uFF0C\u800C\u7A7A\u53F0\u8D26\u7684\u610F\u601D\u662F\u300C\u6BCF\u4E00\u884C\u90FD\u6CA1\u8BB0\u8FC7\u300D\u21D2 \u7167\u5B83\u8DD1\u4E00\u904D\u5C31\u662F**\u5168\u91CF\u91CD\u590D\u884C**`
|
|
12979
|
+
);
|
|
12980
|
+
}
|
|
12981
|
+
return p;
|
|
12982
|
+
}
|
|
12983
|
+
function keyOf(model, businessKey) {
|
|
12984
|
+
return JSON.stringify([model, businessKey]);
|
|
12985
|
+
}
|
|
12986
|
+
var Journal = class _Journal {
|
|
12987
|
+
workDir;
|
|
12988
|
+
path;
|
|
12989
|
+
entries;
|
|
12990
|
+
waivers;
|
|
12991
|
+
/**
|
|
12992
|
+
* 🔴 `entries === []` 有两种成因,这个布尔把它们分开:
|
|
12993
|
+
* true = 文件在、里面一条都没有;false = 文件**根本不存在**(第一轮)。
|
|
12994
|
+
*/
|
|
12995
|
+
exists;
|
|
12996
|
+
layout;
|
|
12997
|
+
latestByKey = /* @__PURE__ */ new Map();
|
|
12998
|
+
constructor(workDir, entries = [], exists = false, waivers = []) {
|
|
12999
|
+
this.workDir = workDirOf(workDir);
|
|
13000
|
+
this.layout = new WorkLayout(this.workDir);
|
|
13001
|
+
this.path = path16.join(this.workDir, JOURNAL_FILE);
|
|
13002
|
+
this.entries = [...entries];
|
|
13003
|
+
this.waivers = [...waivers];
|
|
13004
|
+
this.exists = exists;
|
|
13005
|
+
for (const entry of this.entries) this.latestByKey.set(keyOf(entry.model, entry.businessKey), entry);
|
|
13006
|
+
}
|
|
13007
|
+
/**
|
|
13008
|
+
* 读回台账。`path` 是 **work 目录**,台账固定落在它下面的 `journal.jsonl`。
|
|
13009
|
+
*
|
|
13010
|
+
* 🔴 **读不了就抛,不返回空台账**:空台账的下游语义是「每一行都没记过 ⇒ 全部重放」,
|
|
13011
|
+
* 也就是全量重复。
|
|
13012
|
+
*/
|
|
13013
|
+
static load(p) {
|
|
13014
|
+
const work = workDirOf(p);
|
|
13015
|
+
const target = path16.join(work, JOURNAL_FILE);
|
|
13016
|
+
if (!existsSync8(target)) return new _Journal(work, [], false);
|
|
13017
|
+
let text2;
|
|
13018
|
+
try {
|
|
13019
|
+
text2 = new WorkLayout(work).readText(JOURNAL_FILE);
|
|
13020
|
+
} catch (e) {
|
|
13021
|
+
if (e instanceof TypeError) {
|
|
13022
|
+
throw new JournalError(
|
|
13023
|
+
"journal-unreadable",
|
|
13024
|
+
`${target} \u4E0D\u662F UTF-8 \u7F16\u7801`,
|
|
13025
|
+
"\u53F0\u8D26\u662F kit \u81EA\u5DF1\u5199\u7684 UTF-8 jsonl\uFF0C\u800C\u8FD9\u4E00\u4EFD\u89E3\u4E0D\u51FA UTF-8\u3002\u5B83\u662F\u8C01\u5199\u7684\u3001\u88AB\u4EC0\u4E48\u52A8\u8FC7\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7** \u2014\u2014 \u5148\u81EA\u5DF1\u53BB\u770B\u4E00\u773C\u8FD9\u4EFD\u6587\u4EF6\uFF1B\u5185\u5BB9\u5B58\u7591\u7684\u53F0\u8D26\u6BD4\u6CA1\u6709\u53F0\u8D26\u66F4\u5371\u9669"
|
|
13026
|
+
);
|
|
13027
|
+
}
|
|
13028
|
+
throw new JournalError(
|
|
13029
|
+
"journal-unreadable",
|
|
13030
|
+
`${target} \u8BFB\u4E0D\u4E86\uFF1A${String(e)}`,
|
|
13031
|
+
"\u53F0\u8D26\u8BFB\u4E0D\u4E86\u65F6**\u4E0D\u8BB8**\u5F53\u6210\u7A7A\u53F0\u8D26\u5F80\u4E0B\u8D70\uFF1A\u7A7A\u53F0\u8D26\u7684\u610F\u601D\u662F\u300C\u6BCF\u4E00\u884C\u90FD\u6CA1\u8BB0\u8FC7\u300D\uFF0C\u7167\u5B83\u8DD1\u4E00\u904D\u5C31\u662F\u5168\u91CF\u91CD\u590D\u3002\u5148\u628A\u6587\u4EF6\u6743\u9650/\u4ECB\u8D28\u95EE\u9898\u89E3\u51B3"
|
|
13032
|
+
);
|
|
13033
|
+
}
|
|
13034
|
+
const entries = [];
|
|
13035
|
+
const waivers = [];
|
|
13036
|
+
text2.split("\n").forEach((line, i) => {
|
|
13037
|
+
if (!line.trim()) return;
|
|
13038
|
+
const where = `${target} \u7B2C ${i + 1} \u884C`;
|
|
13039
|
+
let row;
|
|
13040
|
+
try {
|
|
13041
|
+
row = JSON.parse(line);
|
|
13042
|
+
} catch (e) {
|
|
13043
|
+
throw new JournalError(
|
|
13044
|
+
"journal-bad-line",
|
|
13045
|
+
`${where} \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${String(e)}`,
|
|
13046
|
+
"\u8FD9\u4E00\u884C\u662F\u8C01\u5199\u7684\u3001\u65AD\u5728\u54EA\u91CC\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7**\u3002\u786E\u8BA4\u90A3\u4E00\u884C\u5C5E\u4E8E\u54EA\u4E00\u6B21\u5C1D\u8BD5\u4E4B\u540E\uFF0C\u628A\u5B83**\u6574\u884C**\u5220\u6389\u518D\u8DD1 \u2014\u2014 \u5220\u6389\u4E4B\u540E\u90A3\u4E00\u884C\u4F1A\u6309\u300C\u6CA1\u8BB0\u8FC7\u300D\u5904\u7406\uFF0C\u6240\u4EE5\u5220\u4E4B\u524D\u5148\u6309\u4E1A\u52A1\u952E\u53BB\u7CFB\u7EDF\u91CC\u770B\u4E00\u773C\u5B83\u5728\u4E0D\u5728"
|
|
13047
|
+
);
|
|
13048
|
+
}
|
|
13049
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) {
|
|
13050
|
+
throw new JournalError(
|
|
13051
|
+
"journal-bad-line",
|
|
13052
|
+
`${where} \u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61`,
|
|
13053
|
+
"\u53F0\u8D26\u6BCF\u4E00\u884C\u90FD\u662F\u4E00\u4E2A JSON \u5BF9\u8C61\uFF1B\u4E0D\u662F\u7684\u8BDD\u8FD9\u4EFD\u6587\u4EF6\u4E0D\u662F kit \u5199\u7684"
|
|
13054
|
+
);
|
|
13055
|
+
}
|
|
13056
|
+
const obj = row;
|
|
13057
|
+
const kind = obj[KIND_KEY];
|
|
13058
|
+
if (kind === void 0 || kind === null) entries.push(entryFromJson(obj, where));
|
|
13059
|
+
else if (kind === KIND_DRIFT_WAIVER) waivers.push(waiverFromJson(obj, where));
|
|
13060
|
+
else {
|
|
13061
|
+
throw new JournalError(
|
|
13062
|
+
"journal-bad-line",
|
|
13063
|
+
`${where} \u7684 kind \u662F ${JSON.stringify(kind)}\uFF0C\u4E0D\u5728 ${JSON.stringify([...KINDS])} \u91CC`,
|
|
13064
|
+
"\u8BA4\u4E0D\u51FA\u7684\u884C\u6CA1\u6709\u5BF9\u5E94\u7684\u8BFB\u6CD5 \u2014\u2014 \u731C\u4E00\u4E2A\uFF08\u6BD4\u5982\u5F53\u6210\u884C\u8BB0\u5F55\uFF09\u7B49\u4E8E\u628A\u8FD9\u4E00\u884C\u7684\u7ED3\u5C40\u8BFB\u6210\u53E6\u4E00\u4EF6\u4E8B\u3002\u8FD9\u4EFD\u53F0\u8D26\u662F\u8C01\u5199\u7684\u3001\u88AB\u4EC0\u4E48\u52A8\u8FC7\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7**"
|
|
13065
|
+
);
|
|
13066
|
+
}
|
|
13067
|
+
});
|
|
13068
|
+
return new _Journal(work, entries, true, waivers);
|
|
13069
|
+
}
|
|
13070
|
+
/** 这个模型 + 业务键**最后一条**记录;从没记过返回 `null`。 */
|
|
13071
|
+
latest(model, key) {
|
|
13072
|
+
return this.latestByKey.get(keyOf(model, businessKeyOf(key))) ?? null;
|
|
13073
|
+
}
|
|
13074
|
+
/**
|
|
13075
|
+
* → {@link STATUSES} 里的一档,或 `null`。
|
|
13076
|
+
*
|
|
13077
|
+
* 🔴 `null` = **这一行本模块从没记过**,与 `'failed'` 是两回事,也与 `'skipped'`
|
|
13078
|
+
* 是两回事。三者的下一步动作分别是「发」「发」「什么都不做」—— 看着有两档相同,
|
|
13079
|
+
* 但**理由**不同,合并就没法解释产物了。
|
|
13080
|
+
*/
|
|
13081
|
+
statusOf(model, key) {
|
|
13082
|
+
const entry = this.latest(model, key);
|
|
13083
|
+
return entry === null ? null : entry.status;
|
|
13084
|
+
}
|
|
13085
|
+
/**
|
|
13086
|
+
* 这一行接下来该做什么 —— 取值域恒等于 `NEXT_STEP` 的值集。
|
|
13087
|
+
*
|
|
13088
|
+
* 🔴 **推荐调用方只读这一个**:两个布尔(`needsReadback` / `shouldReplay`)是从这里
|
|
13089
|
+
* 派生的**投影**,它们「都为 false」时有**三**种完全不同的含义
|
|
13090
|
+
* (已建好 / 已跳过 / **中毒了要人处理**),单看任何一个都读不出来。
|
|
13091
|
+
*/
|
|
13092
|
+
nextStep(model, key) {
|
|
13093
|
+
return NEXT_STEP[String(this.statusOf(model, key))];
|
|
13094
|
+
}
|
|
13095
|
+
/** 这一行要不要**先按业务键回读**再决定 —— 只有 `unknown` 是 true。 */
|
|
13096
|
+
needsReadback(model, key) {
|
|
13097
|
+
return this.nextStep(model, key) === STEP_READBACK;
|
|
13098
|
+
}
|
|
13099
|
+
/**
|
|
13100
|
+
* 这一行可不可以**直接重发**请求。
|
|
13101
|
+
*
|
|
13102
|
+
* 🔴 `unknown` / `quarantined` 恒为 false:那两条路正是产生重复行的路。
|
|
13103
|
+
* ⚠️ true 的含义是「重发是安全的」,**不是**「重发会成功」—— `failed` 那一档多半要
|
|
13104
|
+
* 顾问先把源表改对。
|
|
13105
|
+
*/
|
|
13106
|
+
shouldReplay(model, key) {
|
|
13107
|
+
return this.nextStep(model, key) === STEP_SEND;
|
|
13108
|
+
}
|
|
13109
|
+
/**
|
|
13110
|
+
* **发请求之前**先落一条 `unknown`(写前落账)。
|
|
13111
|
+
*
|
|
13112
|
+
* `attempts` 在这里自动 +1(前一条没有就从 1 起)—— 让调用方自己数,两处状态迟早漂,
|
|
13113
|
+
* 而漂的方向是「重试了 5 次,台账里写着 1」。
|
|
13114
|
+
*/
|
|
13115
|
+
begin(sourceRowId, model, key, payloadHashValue, roundId) {
|
|
13116
|
+
const businessKey = businessKeyOf(key);
|
|
13117
|
+
const previous = this.latest(model, businessKey);
|
|
13118
|
+
return this.append({
|
|
13119
|
+
sourceRowId,
|
|
13120
|
+
model,
|
|
13121
|
+
businessKey,
|
|
13122
|
+
payloadHash: payloadHashValue,
|
|
13123
|
+
// 🔴 沿用上一条的 `serverId`:一行可能先 unknown、回读判成 done 拿到 id,
|
|
13124
|
+
// 之后又因为 payload 变了要 update —— 那次 `begin` 不该把已知的 id 抹掉。
|
|
13125
|
+
serverId: previous === null ? null : previous.serverId,
|
|
13126
|
+
status: "unknown",
|
|
13127
|
+
attempts: previous === null ? 1 : previous.attempts + 1,
|
|
13128
|
+
roundId
|
|
13129
|
+
});
|
|
13130
|
+
}
|
|
13131
|
+
/**
|
|
13132
|
+
* 把一条结局追加进台账(内存 + 磁盘)。
|
|
13133
|
+
*
|
|
13134
|
+
* 校验三件事,任一不成立**硬失败**:状态在取值域内 · 业务键是字符串序列 ·
|
|
13135
|
+
* 终态必须有前置记录(写前落账协议)。
|
|
13136
|
+
*/
|
|
13137
|
+
append(entry) {
|
|
13138
|
+
if (entry === null || typeof entry !== "object") {
|
|
13139
|
+
throw new JournalError(
|
|
13140
|
+
"bad-entry",
|
|
13141
|
+
`append \u6536\u7684\u662F Entry\uFF0C\u4E0D\u662F ${typeof entry}`,
|
|
13142
|
+
"\u7528\u4E00\u4E2A Entry \u5B57\u9762\u91CF\u6784\u9020\uFF0C\u6216\u4ECE latest(...) \u62FF\u5230\u4E0A\u4E00\u6761\u518D\u5C55\u5F00\u6539"
|
|
13143
|
+
);
|
|
13144
|
+
}
|
|
13145
|
+
if (!STATUSES.includes(entry.status)) {
|
|
13146
|
+
throw new JournalError(
|
|
13147
|
+
"bad-entry",
|
|
13148
|
+
`status \u662F ${JSON.stringify(entry.status)}\uFF0C\u4E0D\u5728 ${JSON.stringify([...STATUSES])} \u91CC`,
|
|
13149
|
+
"\u4E94\u6863\u7684\u8BED\u4E49\u89C1\u6A21\u5757\u5934\u6CE8\u91CA\uFF1Adone/skipped/failed/quarantined \u90FD\u662F**\u67E5\u8FC7\u4E4B\u540E**\u7684\u7ED3\u8BBA\uFF0C\u5206\u4E0D\u6E05\u5C31\u5199 unknown"
|
|
13150
|
+
);
|
|
13151
|
+
}
|
|
13152
|
+
const businessKey = businessKeyOf(entry.businessKey);
|
|
13153
|
+
const settled = { ...entry, businessKey };
|
|
13154
|
+
const mapKey = keyOf(settled.model, businessKey);
|
|
13155
|
+
if (NEEDS_PRIOR_RECORD.includes(settled.status) && !this.latestByKey.has(mapKey)) {
|
|
13156
|
+
throw new JournalError(
|
|
13157
|
+
"write-ahead-missing",
|
|
13158
|
+
`${settled.model} ${JSON.stringify(businessKey)} \u76F4\u63A5\u843D\u4E86 ${settled.status}\uFF0C\u800C\u5B83\u6B64\u524D**\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709**`,
|
|
13159
|
+
"\u5199\u524D\u843D\u8D26\u534F\u8BAE\uFF1A\u53D1\u8BF7\u6C42**\u4E4B\u524D**\u5148 begin() \u843D\u4E00\u6761 unknown\uFF0C\u62FF\u5230\u54CD\u5E94\u4E4B\u540E\u518D append() \u843D\u7EC8\u6001\u3002\u5C11\u4E86\u524D\u7F6E\u90A3\u4E00\u6761\u65F6\uFF0C\u8FDB\u7A0B\u5728\u300C\u670D\u52A1\u7AEF\u5DF2\u5EFA\u6210\u3001\u53F0\u8D26\u8FD8\u6CA1\u5199\u300D\u4E4B\u95F4\u88AB\u6253\u65AD\uFF0C\u7EED\u8DD1\u5C31\u4F1A\u628A\u8FD9\u4E00\u884C\u5F53\u6210\u4ECE\u6CA1\u8BD5\u8FC7\u800C\u91CD\u53D1 \u2014\u2014 \u90A3\u5C31\u662F\u91CD\u590D\u884C\u3002\u26A0\uFE0F \u672C\u95F8\u53EA\u8BA4\u300C\u6709\u6CA1\u6709\u524D\u7F6E\u8BB0\u5F55\u300D\uFF0C\u4E0D\u8BA4\u300C\u8FD9\u4E00\u8F6E\u6709\u6CA1\u6709 begin \u8FC7\u300D\uFF1A\u7EED\u8DD1\u65F6\u62FF\u4E0A\u4E00\u8F6E\u7684 unknown \u53BB\u5199 done \u662F\u56DE\u8BFB\u5224\u5B9A\u7684\u6B63\u5E38\u7ED3\u5C40\uFF0C\u5FC5\u987B\u653E\u884C"
|
|
13160
|
+
);
|
|
13161
|
+
}
|
|
13162
|
+
this.writeLine(JSON.stringify(entryJson(settled)), settled.status === "unknown");
|
|
13163
|
+
this.entries.push(settled);
|
|
13164
|
+
this.latestByKey.set(mapKey, settled);
|
|
13165
|
+
this.exists = true;
|
|
13166
|
+
return settled;
|
|
13167
|
+
}
|
|
13168
|
+
/**
|
|
13169
|
+
* 把一次 `--force-stale` 放行追加进台账(内存 + 磁盘)。
|
|
13170
|
+
*
|
|
13171
|
+
* 🔴 **不 fsync**:它不是崩溃标记 —— 丢了不会让任何一行被重放,而写前落账那一条丢了
|
|
13172
|
+
* 就等于那一行没落过账。
|
|
13173
|
+
* 🔴 走 `append` 同一条落盘路径与同一条错误边界:写失败时内存态一个字节都不许动,
|
|
13174
|
+
* 否则「台账里有据可查」这句话会在盘上落空而在内存里成立。
|
|
13175
|
+
*/
|
|
13176
|
+
appendWaiver(waiver) {
|
|
13177
|
+
if (waiver === null || typeof waiver !== "object" || typeof waiver.verdict !== "string") {
|
|
13178
|
+
throw new JournalError(
|
|
13179
|
+
"bad-entry",
|
|
13180
|
+
`appendWaiver \u6536\u7684\u662F Waiver\uFF0C\u4E0D\u662F ${typeof waiver}`,
|
|
13181
|
+
"\u7528\u4E00\u4E2A Waiver \u5B57\u9762\u91CF\u6784\u9020 \u2014\u2014 \u5B83\u4E0E Entry \u662F\u4E24\u79CD\u884C\uFF0C\u4E0D\u8BB8\u4E92\u76F8\u9876\u66FF"
|
|
13182
|
+
);
|
|
13183
|
+
}
|
|
13184
|
+
this.writeLine(JSON.stringify(waiverJson(waiver)), false);
|
|
13185
|
+
this.waivers.push(waiver);
|
|
13186
|
+
this.exists = true;
|
|
13187
|
+
return waiver;
|
|
13188
|
+
}
|
|
13189
|
+
/**
|
|
13190
|
+
* 真正落盘的那一步。单独拆出来只为**让写失败有一个明确的边界** ——
|
|
13191
|
+
* 内存态的更新必须留在这个边界之外(写失败时台账不许在内存里「已经有了」)。
|
|
13192
|
+
*
|
|
13193
|
+
* 🔴 `sync` 由调用方给,不在这里按行的内容判:两种行走的是**同一条**落盘路径,
|
|
13194
|
+
* 而「值不值得 fsync」是各自的语义。
|
|
13195
|
+
*/
|
|
13196
|
+
writeLine(line, sync) {
|
|
13197
|
+
try {
|
|
13198
|
+
this.layout.appendLine(JOURNAL_FILE, line, sync);
|
|
13199
|
+
} catch (e) {
|
|
13200
|
+
throw new JournalError(
|
|
13201
|
+
"journal-unwritable",
|
|
13202
|
+
`\u53F0\u8D26\u5199\u4E0D\u4E0B\u53BB\uFF1A${this.path}\uFF08${String(e)}\uFF09`,
|
|
13203
|
+
"\u78C1\u76D8\u6EE1 / \u53EA\u8BFB\u6302\u8F7D / \u6743\u9650 / \u4ECB\u8D28\u51FA\u9519\u90FD\u4F1A\u8D70\u5230\u8FD9\u91CC\u3002\u{1F534} **\u8FD9\u4E00\u8F6E\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\uFF0C\u53EA\u5728\u53F0\u8D26\u91CC\u6709\u8BB0\u5F55**\uFF1B\u800C\u672C\u5C42\u5224\u4E0D\u51FA\u90A3\u4EFD\u6587\u4EF6\u6B64\u523B\u5728\u4E0D\u5728\uFF08\u8FD9\u4E00\u6B21\u843D\u8D26\u6B63\u662F\u5728\u5B83\u4E0A\u9762\u5931\u8D25\u7684\uFF09\u2014\u2014 \u6240\u4EE5\u8FD9\u91CC**\u4E0D\u7ED9\u300C\u5BF9\u5B83\u505A\u4EC0\u4E48\u300D\u7684\u6307\u4EE4**\uFF0C\u90A3\u53E5\u8BDD\u7531\u62FF\u5F97\u5230\u76D8\u4E0A\u4E8B\u5B9E\u7684\u90A3\u4E00\u5C42\u8BF4"
|
|
13204
|
+
);
|
|
13205
|
+
}
|
|
13206
|
+
}
|
|
13207
|
+
};
|
|
13208
|
+
function readbackFields(model, keyFields, key) {
|
|
13209
|
+
if (!Array.isArray(keyFields) || keyFields.length === 0 || keyFields.some((f) => typeof f !== "string" || !f.trim())) {
|
|
13210
|
+
throw new JournalError(
|
|
13211
|
+
"bad-entry",
|
|
13212
|
+
`${model} \u7684\u4E1A\u52A1\u952E\u5B57\u6BB5\u540D\u4E0D\u53EF\u7528\uFF08${JSON.stringify(keyFields)}\uFF09`,
|
|
13213
|
+
"\u56DE\u8BFB\u6309 filter \u9010\u5B57\u6BB5 eq\uFF0C\u5B57\u6BB5\u540D\u5FC5\u987B\u662F\u5DE5\u4EF6\u91CC businessKey.fields \u90A3\u51E0\u4E2A"
|
|
13214
|
+
);
|
|
13215
|
+
}
|
|
13216
|
+
const fields = keyFields;
|
|
13217
|
+
if (new Set(fields).size !== fields.length) {
|
|
13218
|
+
throw new JournalError(
|
|
13219
|
+
"bad-entry",
|
|
13220
|
+
`${model} \u7684\u4E1A\u52A1\u952E\u5B57\u6BB5\u91CC\u6709\u91CD\u540D\uFF1A${JSON.stringify(fields)}`,
|
|
13221
|
+
"\u540C\u4E00\u4E2A\u5B57\u6BB5\u88AB\u8981\u6C42\u540C\u65F6\u7B49\u4E8E\u4E24\u4E2A\u503C\u65F6\uFF0C\u56DE\u8BFB\u6052 0 \u884C \u21D2 \u88AB\u5224\u6210\u300C\u6CA1\u5EFA\u6210\u300D\u21D2 \u91CD\u5EFA\u4E00\u884C\u672C\u6765\u5C31\u5728\u7684\u8BB0\u5F55\u3002\u5148\u53BB\u5DE5\u4EF6\u91CC\u628A businessKey.fields \u7684\u91CD\u590D\u53BB\u6389"
|
|
13222
|
+
);
|
|
13223
|
+
}
|
|
13224
|
+
const parts = businessKeyOf(key);
|
|
13225
|
+
if (fields.length !== parts.length) {
|
|
13226
|
+
throw new JournalError(
|
|
13227
|
+
"bad-entry",
|
|
13228
|
+
`${model} \u7684\u4E1A\u52A1\u952E\u5B57\u6BB5\u6709 ${fields.length} \u4E2A\uFF0C\u800C\u8FD9\u4E00\u884C\u7684\u952E\u6709 ${parts.length} \u4E2A`,
|
|
13229
|
+
"\u4E24\u8005\u5FC5\u987B\u4E00\u4E00\u5BF9\u5E94 \u2014\u2014 \u6570\u76EE\u5BF9\u4E0D\u4E0A\u65F6\u62FC\u51FA\u6765\u7684 filter \u4F1A\u5C11\u4E00\u4E2A\u6761\u4EF6\uFF0C\u800C\u5C11\u4E00\u4E2A\u6761\u4EF6\u7684\u56DE\u8BFB\u4F1A\u5339\u914D\u5230**\u522B\u7684\u884C**"
|
|
13230
|
+
);
|
|
13231
|
+
}
|
|
13232
|
+
const projected = [];
|
|
13233
|
+
for (const name of ["id", ...fields]) if (!projected.includes(name)) projected.push(name);
|
|
13234
|
+
return projected;
|
|
13235
|
+
}
|
|
13236
|
+
async function resolveUnknown(client, model, keyFields, key) {
|
|
13237
|
+
const fields = readbackFields(model, keyFields, key);
|
|
13238
|
+
const parts = businessKeyOf(key);
|
|
13239
|
+
const body = {
|
|
13240
|
+
page: 0,
|
|
13241
|
+
// 2 就够:要的只是「0 / 1 / 更多」这个三分。多取一行是白花的服务端开销。
|
|
13242
|
+
size: 2,
|
|
13243
|
+
fields,
|
|
13244
|
+
// 🔴 一律用 `{and: [...]}` 包,哪怕只有一个 leaf(真服务器上实测两种写法同结果)——
|
|
13245
|
+
// 单键与复合键一条代码路径,少一处「只在复合键上才走到」的分支。
|
|
13246
|
+
filter: { and: keyFields.map((f, i) => ({ field: f, op: "eq", value: parts[i] })) }
|
|
13247
|
+
// ⚠️ 不带 `orders`:只取 2 行、不翻页,稳定排序在这里没有可守的前提;
|
|
13248
|
+
// 而实测有模型带不带 orders 都 400,少一个入参就少一类无谓的失败面。
|
|
13249
|
+
};
|
|
13250
|
+
const out = await client.post(listPath2(model), body);
|
|
13251
|
+
if (out.error !== "ok") {
|
|
13252
|
+
throw new JournalError(
|
|
13253
|
+
"readback-failed",
|
|
13254
|
+
`${model} \u6309\u4E1A\u52A1\u952E ${JSON.stringify(parts)} \u56DE\u8BFB\u5931\u8D25\uFF08HTTP ${out.status} / ${out.error}\uFF09`,
|
|
13255
|
+
"\u8FD9\u4E00\u884C\u7684\u72B6\u6001\u662F unknown\uFF08\u670D\u52A1\u7AEF\u53EF\u80FD\u5DF2\u7ECF\u5EFA\u6210\u3001\u54CD\u5E94\u5728\u56DE\u7A0B\u4E22\u4E86\uFF09\u3002\u56DE\u8BFB\u95EE\u4E0D\u51FA\u6765\u65F6**\u4E0D\u8BB8**\u5F53\u6210\u300C\u6CA1\u5EFA\u6210\u300D\u53BB\u91CD\u5EFA \u2014\u2014 \u90A3\u6B63\u662F\u4EA7\u751F\u91CD\u590D\u884C\u7684\u90A3\u6761\u8DEF\u3002\u5148\u6309 error \u90A3\u4E00\u7EF4\u5904\u7F6E\uFF08unauthorized=\u91CD\u767B / forbidden=\u8981\u6743\u9650 / network=\u901A\u9053 / server-error=\u770B\u670D\u52A1\u7AEF\uFF09\u518D\u8DD1\u4E00\u6B21\u3002\u26A0\uFE0F \u82E5 details \u91CC\u5199\u7740\u67D0\u4E2A\u5B57\u6BB5\u4E0D\u5B58\u5728\uFF0C\u90A3\u662F**\u4E1A\u52A1\u952E\u5B57\u6BB5\u540D\u5199\u9519\u4E86**\uFF1Afilter \u5BF9\u4E0D\u5B58\u5728\u7684\u5B57\u6BB5\u540D\u662F\u786C\u5931\u8D25\u7684\u3002\u{1F534} **\u522B\u6309 code \u5206\u652F**\uFF1A\u9876\u5C42 error.code \u4E24\u4E2A\u6A21\u578B\u90FD\u662F BUSINESS_RULE_VIOLATION\uFF08\u592A\u7C97\uFF09\uFF0C\u800C details \u91CC\u65B9\u62EC\u53F7\u90A3\u4E2A token \u968F\u6A21\u578B\u53D8\uFF08\u4E0D\u7A33\uFF09\u2014\u2014 \u4E24\u5904\u90FD\u4E0D\u53EF\u673A\u8BFB"
|
|
13256
|
+
);
|
|
13257
|
+
}
|
|
13258
|
+
const { rows, total, defect } = readPage(out.body);
|
|
13259
|
+
if (rows === null) {
|
|
13260
|
+
throw new JournalError(
|
|
13261
|
+
"readback-bad-shape",
|
|
13262
|
+
`${model} \u56DE\u8BFB HTTP ${out.status} \u4F46\u54CD\u5E94\u5F62\u72B6\u7528\u4E0D\u4E86\uFF1A${defect}`,
|
|
13263
|
+
"\u8FD9\u4EFD\u54CD\u5E94\u662F\u8C01\u7ED9\u7684\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7**\uFF0C\u4E5F**\u4E0D\u731C\u5F62\u72B6**\uFF1A\u731C\u9519\u7684\u4EE3\u4EF7\u662F\u628A\u4E00\u884C\u5DF2\u7ECF\u5EFA\u597D\u7684\u8BB0\u5F55\u5224\u6210\u300C\u6CA1\u5EFA\u6210\u300D\uFF0C\u7136\u540E\u518D\u5EFA\u4E00\u904D\u3002\u4E0A\u9762\u90A3\u53E5\u91CC\u662F\u8FD9\u6B21\u6536\u5230\u7684\u5F62\u72B6\uFF0C\u7167\u539F\u6837\u628A\u8FD9\u4E2A\u8BF7\u6C42\u91CD\u6253\u4E00\u6B21\uFF08curl \u5373\u53EF\uFF09\u770B\u770B\u662F\u8C01\u5728\u7B54"
|
|
13264
|
+
);
|
|
13265
|
+
}
|
|
13266
|
+
if (total > 1) {
|
|
13267
|
+
throw new JournalError(
|
|
13268
|
+
"readback-ambiguous",
|
|
13269
|
+
`${model} \u7684\u4E1A\u52A1\u952E ${JSON.stringify(parts)} \u5728\u7CFB\u7EDF\u91CC\u5339\u914D\u5230 ${total} \u884C`,
|
|
13270
|
+
"\u4E1A\u52A1\u952E\u662F\u5E42\u7B49\u7684\u652F\u70B9\uFF0C\u5B83\u5728\u672C\u79DF\u6237\u4E0D\u552F\u4E00\u7684\u8BDD\u300C\u8FD9\u4E00\u884C\u5EFA\u6210\u6CA1\u6709\u300D\u6839\u672C\u6CA1\u6709\u7B54\u6848\u3002\u26A0\uFE0F \u8FD9\u53EF\u80FD\u662F\u4E0A\u4E00\u8F6E**\u5DF2\u7ECF**\u91CD\u590D\u5EFA\u8FC7\u4E86 \u2014\u2014 \u5148\u53BB\u7CFB\u7EDF\u91CC\u628A\u91CD\u590D\u884C\u5904\u7406\u6389\uFF0C\u518D\u51B3\u5B9A\u8FD9\u4E00\u884C\u600E\u4E48\u529E\u3002kit \u4E0D\u66FF\u4F60\u6311\u4E00\u884C\u8BA4\u9886"
|
|
13271
|
+
);
|
|
13272
|
+
}
|
|
13273
|
+
if (total === 0) return { status: "failed", serverId: null, total: 0 };
|
|
13274
|
+
const serverId = rows.length > 0 ? rows[0].id : void 0;
|
|
13275
|
+
if (typeof serverId !== "string" || !serverId) {
|
|
13276
|
+
throw new JournalError(
|
|
13277
|
+
"readback-bad-shape",
|
|
13278
|
+
`${model} \u56DE\u8BFB\u8BF4\u6709 1 \u884C\uFF0C\u4F46\u90A3\u4E00\u884C\u7684 id \u662F ${JSON.stringify(serverId ?? null)}`,
|
|
13279
|
+
"id \u662F\u540E\u7EED update / \u5F15\u7528\u56DE\u586B\u8981\u7528\u7684\u4E1C\u897F\u3002\u62FF\u4E0D\u5230\u5B83\u65F6\u8FD9\u6761\u56DE\u8BFB**\u6CA1\u6709\u7ED3\u8BBA**\uFF0C\u8BB0\u6210 done \u4F1A\u8BA9\u4E0B\u6E38\u62FF\u7740\u4E00\u4E2A null \u53BB\u53D1\u8BF7\u6C42"
|
|
13280
|
+
);
|
|
13281
|
+
}
|
|
13282
|
+
return { status: "done", serverId, total };
|
|
13283
|
+
}
|
|
13284
|
+
var LEASE_FILE = ".lease.json";
|
|
13285
|
+
var LEASE_KEYS = ["host", "pid", "roundId", "acquiredAt", "heartbeatAt"];
|
|
13286
|
+
var LEASE_STALE_SECONDS = DEFAULT_HTTP_TIMEOUT_MS / 1e3 * 4;
|
|
13287
|
+
var LEASE_HEARTBEAT_SECONDS = LEASE_STALE_SECONDS / 4;
|
|
13288
|
+
var LeaseViolation = class extends Error {
|
|
13289
|
+
reason;
|
|
13290
|
+
detail;
|
|
13291
|
+
hint;
|
|
13292
|
+
constructor(reason, detail, hint = "") {
|
|
13293
|
+
super(`[${reason}] ${detail}${hint ? ` \u2014\u2014 ${hint}` : ""}`);
|
|
13294
|
+
this.name = "LeaseViolation";
|
|
13295
|
+
this.reason = reason;
|
|
13296
|
+
this.detail = detail;
|
|
13297
|
+
this.hint = hint;
|
|
13298
|
+
}
|
|
13299
|
+
};
|
|
13300
|
+
var SYSTEM_CLOCK = {
|
|
13301
|
+
now: () => /* @__PURE__ */ new Date(),
|
|
13302
|
+
monotonic: () => Number(process.hrtime.bigint() / 1000000n) / 1e3
|
|
13303
|
+
};
|
|
13304
|
+
function leaseIdentity(payload) {
|
|
13305
|
+
return [payload.host, payload.pid, payload.roundId];
|
|
13306
|
+
}
|
|
13307
|
+
function sameIdentity(a, b) {
|
|
13308
|
+
return a.length === b.length && a.every((x, i) => x === b[i]);
|
|
13309
|
+
}
|
|
13310
|
+
function readLease(layout, file = LEASE_FILE) {
|
|
13311
|
+
const p = path16.join(layout.dir, file);
|
|
13312
|
+
if (!existsSync8(p)) return [null, `${p} \u4E0D\u5B58\u5728`];
|
|
13313
|
+
let text2;
|
|
13314
|
+
try {
|
|
13315
|
+
text2 = layout.readText(file);
|
|
13316
|
+
} catch (e) {
|
|
13317
|
+
if (e instanceof TypeError) return [null, `${p} \u4E0D\u662F UTF-8 \u7F16\u7801`];
|
|
13318
|
+
return [null, `${p} \u8BFB\u4E0D\u4E86\uFF1A${String(e)}`];
|
|
13319
|
+
}
|
|
13320
|
+
let body;
|
|
13321
|
+
try {
|
|
13322
|
+
body = JSON.parse(text2);
|
|
13323
|
+
} catch (e) {
|
|
13324
|
+
return [null, `${p} \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${String(e)}`];
|
|
13325
|
+
}
|
|
13326
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) {
|
|
13327
|
+
return [null, `${p} \u7684\u5185\u5BB9\u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61`];
|
|
13328
|
+
}
|
|
13329
|
+
const obj = body;
|
|
13330
|
+
const missing = LEASE_KEYS.filter((k) => !(k in obj));
|
|
13331
|
+
if (missing.length > 0) return [null, `${p} \u7F3A\u4E86 ${JSON.stringify(missing)} \u8FD9\u51E0\u4E2A\u952E`];
|
|
13332
|
+
return [obj, ""];
|
|
13333
|
+
}
|
|
13334
|
+
function serialiseLease(payload) {
|
|
13335
|
+
return `${JSON.stringify(payload, null, 2)}
|
|
13336
|
+
`;
|
|
13337
|
+
}
|
|
13338
|
+
function hostname2() {
|
|
13339
|
+
try {
|
|
13340
|
+
return os3.hostname() || "unknown-host";
|
|
13341
|
+
} catch {
|
|
13342
|
+
return "unknown-host";
|
|
13343
|
+
}
|
|
13344
|
+
}
|
|
13345
|
+
var LEASE_JUDGE_SIGNPOST = "\u89E3\u51B3\u4E4B\u540E\u5E26 `--resume` \u518D\u8DD1\uFF1B\u5982\u679C\u90A3\u4E00\u6B21\u62A5\u4E86\u79DF\u7EA6\u76F8\u5173\u7684\u95EE\u9898\uFF0C**\u7167\u90A3\u6761\u6D88\u606F\u8D70**\u3002";
|
|
13346
|
+
function leaseStampNote(raw, beat, at) {
|
|
13347
|
+
if (beat === null) {
|
|
13348
|
+
return `\u76D8\u4E0A\u90A3\u4E2A\u503C\u539F\u6837\u662F ${JSON.stringify(raw)} \u2014\u2014 \u672C kit \u89E3\u6790\u4E0D\u51FA\u5B83\u7684\u5E74\u9F84\u3002`;
|
|
13349
|
+
}
|
|
13350
|
+
const seconds = (at.getTime() - beat.getTime()) / 1e3;
|
|
13351
|
+
if (seconds < 0) {
|
|
13352
|
+
return `\u76D8\u4E0A\u90A3\u4E2A\u503C\u539F\u6837\u662F ${String(raw)}\uFF0C\u6BD4\u5F53\u4E0B\u665A ${(-seconds).toFixed(0)} \u79D2\u3002`;
|
|
13353
|
+
}
|
|
13354
|
+
return `\u76D8\u4E0A\u90A3\u4E2A\u503C\u539F\u6837\u662F ${String(raw)}\uFF0C\u8DDD\u5F53\u4E0B ${seconds.toFixed(0)} \u79D2\u3002`;
|
|
13355
|
+
}
|
|
13356
|
+
var Lease = class {
|
|
13357
|
+
layout;
|
|
13358
|
+
path;
|
|
13359
|
+
host;
|
|
13360
|
+
pid;
|
|
13361
|
+
roundId;
|
|
13362
|
+
acquiredAt;
|
|
13363
|
+
heartbeatAt;
|
|
13364
|
+
reclaimed;
|
|
13365
|
+
clock;
|
|
13366
|
+
/** 节流用的**单调**标记,与 `heartbeatAt`(墙钟、要落盘)分开两个钟。 */
|
|
13367
|
+
beatMark;
|
|
13368
|
+
constructor(layout, spec, reclaimed = null, clock = SYSTEM_CLOCK) {
|
|
13369
|
+
this.layout = layout;
|
|
13370
|
+
this.path = path16.join(layout.dir, LEASE_FILE);
|
|
13371
|
+
this.host = spec.host;
|
|
13372
|
+
this.pid = spec.pid;
|
|
13373
|
+
this.roundId = spec.roundId;
|
|
13374
|
+
this.acquiredAt = spec.acquiredAt;
|
|
13375
|
+
this.heartbeatAt = spec.heartbeatAt;
|
|
13376
|
+
this.reclaimed = reclaimed;
|
|
13377
|
+
this.clock = clock;
|
|
13378
|
+
this.beatMark = clock.monotonic();
|
|
13379
|
+
}
|
|
13380
|
+
/**
|
|
13381
|
+
* 🔴 身份是 `(host, pid, roundId)` 三件套。
|
|
13382
|
+
*
|
|
13383
|
+
* 单靠 `pid` 不行:`kill -9` 之后 pid 会被复用,一个**别的**进程会被认成自己。
|
|
13384
|
+
* `roundId` 后半截是随机的,撞不上。
|
|
13385
|
+
*/
|
|
13386
|
+
get identity() {
|
|
13387
|
+
return [this.host, this.pid, this.roundId];
|
|
13388
|
+
}
|
|
13389
|
+
payload() {
|
|
13390
|
+
return {
|
|
13391
|
+
host: this.host,
|
|
13392
|
+
pid: this.pid,
|
|
13393
|
+
roundId: this.roundId,
|
|
13394
|
+
acquiredAt: stampOf(this.acquiredAt),
|
|
13395
|
+
heartbeatAt: stampOf(this.heartbeatAt)
|
|
13396
|
+
};
|
|
13397
|
+
}
|
|
13398
|
+
/**
|
|
13399
|
+
* 盖一次心跳。**先核对这份租约还是不是自己的**,不是就抛 `lost`。
|
|
13400
|
+
*
|
|
13401
|
+
* 🔴 不核对的话,本进程会把一份**已经被别人回收**的租约悄悄抢回来 ——
|
|
13402
|
+
* 于是两个写者都以为自己独占。核对一次的代价是一次读文件。
|
|
13403
|
+
*
|
|
13404
|
+
* 🔴 **这个方法无条件盖章,不看间隔** —— 想要节流的走 {@link heartbeatIfDue}。
|
|
13405
|
+
* 两种语义**不塞进一个名字**:真正想强制盖一次的地方拿到的必须是「一定盖」,
|
|
13406
|
+
* 而不是「可能盖了、可能没盖」。
|
|
13407
|
+
*
|
|
13408
|
+
* ⚠️ 本模块**不起后台线程**:要调用方自己调。心跳与请求在同一个线程上,
|
|
13409
|
+
* 一次阻塞的请求期间它发不出去 —— {@link LEASE_STALE_SECONDS} 就是照这一点定的。
|
|
13410
|
+
*/
|
|
13411
|
+
heartbeat() {
|
|
13412
|
+
const [held, why] = readLease(this.layout);
|
|
13413
|
+
if (held === null) {
|
|
13414
|
+
throw new LeaseViolation(
|
|
13415
|
+
"lost",
|
|
13416
|
+
`\u79DF\u7EA6\u6587\u4EF6\u4E0D\u89C1\u4E86\u6216\u8BFB\u4E0D\u4E86\uFF08${this.path}\uFF09\uFF1A${why}`,
|
|
13417
|
+
"\u672C\u6A21\u5757\u53EA\u77E5\u9053**\u8FD9\u4E00\u6B21\u8BFB\u4E0D\u5230\u5B83**\uFF08\u539F\u56E0\u5728\u4E0A\u9762\u90A3\u53E5\u62EC\u53F7\u91CC\uFF09\uFF0C\u8FD9\u4E2A\u6587\u4EF6\u662F\u600E\u4E48\u6CA1\u7684\u5B83**\u6CA1\u6709\u67E5\u8FC7**\u3002\u65E0\u8BBA\u5982\u4F55\uFF0C\u6211\u65B9\u5DF2\u7ECF\u4E0D\u80FD\u8BC1\u660E\u81EA\u5DF1\u662F\u552F\u4E00\u5199\u8005 \u2014\u2014 \u505C\u4E0B\u6765\uFF0C\u522B\u63A5\u7740\u5199"
|
|
13418
|
+
);
|
|
13419
|
+
}
|
|
13420
|
+
if (!sameIdentity(leaseIdentity(held), this.identity)) {
|
|
13421
|
+
throw new LeaseViolation(
|
|
13422
|
+
"lost",
|
|
13423
|
+
`\u79DF\u7EA6\u5DF2\u7ECF\u4E0D\u662F\u6211\u65B9\u7684\u4E86\uFF1A\u6587\u4EF6\u91CC\u662F ${JSON.stringify(leaseIdentity(held))}\uFF0C\u6211\u65B9\u662F ${JSON.stringify(this.identity)}`,
|
|
13424
|
+
"\u672C\u6A21\u5757\u53EA\u6BD4\u5BF9\u4E86\u521A\u8BFB\u5230\u7684\u8FD9\u4E00\u4EFD\u8EAB\u4EFD\uFF1A\u76D8\u4E0A\u662F\u8C01\u3001\u6211\u65B9\u662F\u4EC0\u4E48\u65F6\u5019\u88AB\u9876\u6389\u7684\uFF0C\u5B83**\u4E00\u6B21\u90FD\u6CA1\u67E5\u8FC7**\u3002**\u7ACB\u523B\u505C\u624B**\uFF1A\u6211\u65B9\u5DF2\u7ECF\u4E0D\u80FD\u8BC1\u660E\u81EA\u5DF1\u662F\u552F\u4E00\u5199\u8005\uFF0C\u800C\u53F0\u8D26\u53EA\u6709\u4E00\u4EFD \u2014\u2014 \u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728\u53F0\u8D26\u91CC\uFF0C\u522B\u5220\u5B83"
|
|
13425
|
+
);
|
|
13426
|
+
}
|
|
13427
|
+
const previousBeat = this.heartbeatAt;
|
|
13428
|
+
const attemptedAt = this.clock.now();
|
|
13429
|
+
this.heartbeatAt = attemptedAt;
|
|
13430
|
+
try {
|
|
13431
|
+
this.layout.replaceAtomically(LEASE_FILE, serialiseLease(this.payload()));
|
|
13432
|
+
} catch (e) {
|
|
13433
|
+
this.heartbeatAt = previousBeat;
|
|
13434
|
+
const [beat] = parseStamp(held.heartbeatAt);
|
|
13435
|
+
throw new LeaseViolation(
|
|
13436
|
+
"lease-unwritable",
|
|
13437
|
+
`\u76D6\u5FC3\u8DF3\u65F6\u5199\u4E0D\u8FDB\u79DF\u7EA6\u6587\u4EF6 ${this.path}\uFF1A${String(e)}`,
|
|
13438
|
+
`**\u8FD9\u4E00\u6B21\u5FC3\u8DF3\u6CA1\u6709\u76D6\u4E0A**\uFF0C\u79DF\u7EA6\u6587\u4EF6\u7684\u5185\u5BB9**\u6CA1\u6709\u88AB\u6539\u52A8**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002${leaseStampNote(held.heartbeatAt, beat, attemptedAt)}\u5199\u4E4B\u524D\u521A\u6838\u5BF9\u8FC7\u8EAB\u4EFD \u2014\u2014 **\u90A3\u4E00\u6B21\u8BFB\u5230\u7684**\u79DF\u7EA6\u662F\u6211\u65B9\u7684\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002**\u5148\u505C\u624B\u518D\u5904\u7406**\uFF1A\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728 ${path16.dirname(this.path)} \u7684\u53F0\u8D26\u91CC\uFF08\u5199\u524D\u843D\u8D26\uFF1A\u53D1\u8BF7\u6C42\u4E4B\u524D\u5148 begin \u843D\u4E00\u6761 unknown\uFF09\u3002${LEASE_JUDGE_SIGNPOST}`
|
|
13439
|
+
);
|
|
13440
|
+
}
|
|
13441
|
+
this.beatMark = this.clock.monotonic();
|
|
13442
|
+
return this;
|
|
13443
|
+
}
|
|
13444
|
+
/**
|
|
13445
|
+
* 距上一次盖章不足 {@link LEASE_HEARTBEAT_SECONDS} 就**不盖**,够了才盖一次。
|
|
13446
|
+
*
|
|
13447
|
+
* 🔴 **节流住在这一侧**:执行器每花掉一次请求就调它一次,而「多久算够」是租约的事
|
|
13448
|
+
* —— 执行器不该知道那两个时间常量。少了这一层,一轮 3000 行就是 3000 次
|
|
13449
|
+
* 「读租约 + 写租约」。
|
|
13450
|
+
*
|
|
13451
|
+
* 比的是**本对象上一次盖章以来的单调秒**,既不是盘上那个值、也不是墙钟差:
|
|
13452
|
+
* 盘上的值可能是别人写的;而墙钟被 NTP 往回拨一次,「距上次多久」会变成负数,
|
|
13453
|
+
* 从此再也不到钟。**盘上写的仍然是墙钟** —— 别的进程要拿它比阈值,两个钟别串。
|
|
13454
|
+
*
|
|
13455
|
+
* ⚠️ {@link heartbeat} 写失败时不推进那个标记 ⇒ 下一次调用照样够钟。
|
|
13456
|
+
* ⚠️ 没到钟的那一次**什么都不做**,原样返回 `this`(不读文件、不写文件)——
|
|
13457
|
+
* 也就**不核身份**:本方法**不是**「租约还归我吗」的探针。
|
|
13458
|
+
*/
|
|
13459
|
+
heartbeatIfDue() {
|
|
13460
|
+
if (this.clock.monotonic() - this.beatMark < LEASE_HEARTBEAT_SECONDS) return this;
|
|
13461
|
+
return this.heartbeat();
|
|
13462
|
+
}
|
|
13463
|
+
/**
|
|
13464
|
+
* 释放租约(删文件)。→ 真的删了没有。
|
|
13465
|
+
*
|
|
13466
|
+
* 🔴 **只删自己的那一份**:文件已经易主时什么都不做并返回 false。
|
|
13467
|
+
* 删别人的租约等于给下一个进程发一张假的通行证。
|
|
13468
|
+
*/
|
|
13469
|
+
release() {
|
|
13470
|
+
const [held] = readLease(this.layout);
|
|
13471
|
+
if (held === null || !sameIdentity(leaseIdentity(held), this.identity)) return false;
|
|
13472
|
+
return this.layout.remove(LEASE_FILE);
|
|
13473
|
+
}
|
|
13474
|
+
};
|
|
13475
|
+
function acquireLease(workDir, roundId, clock = SYSTEM_CLOCK) {
|
|
13476
|
+
if (typeof roundId !== "string" || !roundId.trim()) {
|
|
13477
|
+
throw new LeaseViolation(
|
|
13478
|
+
"held-by-another",
|
|
13479
|
+
`roundId \u4E0D\u53EF\u7528\uFF08${JSON.stringify(roundId)}\uFF09`,
|
|
13480
|
+
"\u79DF\u7EA6\u7684\u8EAB\u4EFD\u662F (host, pid, roundId)\uFF1BroundId \u7A7A\u6389\u7684\u8BDD pid \u590D\u7528\u4F1A\u8BA9\u4E00\u4E2A\u522B\u7684\u8FDB\u7A0B\u88AB\u8BA4\u6210\u81EA\u5DF1\u3002\u7528\u8BA1\u5212\u91CC\u7684\u90A3\u4E2A roundId"
|
|
13481
|
+
);
|
|
13482
|
+
}
|
|
13483
|
+
const layout = new WorkLayout(workDirOf(workDir));
|
|
13484
|
+
const p = path16.join(layout.dir, LEASE_FILE);
|
|
13485
|
+
const me = [hostname2(), process.pid, roundId];
|
|
13486
|
+
const now = clock.now();
|
|
13487
|
+
const fresh = new Lease(
|
|
13488
|
+
layout,
|
|
13489
|
+
{ host: me[0], pid: me[1], roundId, acquiredAt: now, heartbeatAt: now },
|
|
13490
|
+
null,
|
|
13491
|
+
clock
|
|
13492
|
+
);
|
|
13493
|
+
try {
|
|
13494
|
+
layout.createExclusive(LEASE_FILE, serialiseLease(fresh.payload()));
|
|
13495
|
+
return fresh;
|
|
13496
|
+
} catch (e) {
|
|
13497
|
+
const code = e.code;
|
|
13498
|
+
if (code !== "EEXIST") {
|
|
13499
|
+
throw new LeaseViolation(
|
|
13500
|
+
"lease-unwritable",
|
|
13501
|
+
`${p} \u5EFA\u4E0D\u51FA\u6765\uFF1A${String(e)}`,
|
|
13502
|
+
"\u79DF\u7EA6\u662F\u7528\u300C\u5199\u4E34\u65F6\u6587\u4EF6 + \u786C\u94FE\u63A5\u539F\u5B50\u6302\u4E0A\u53BB\u300D\u843D\u5730\u7684\uFF08\u8FD9\u6837\u5B83\u4E00\u51FA\u73B0\u5C31\u662F\u5B8C\u6574\u7684\uFF09\u3002\u8D70\u5230\u8FD9\u91CC\u7684\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u8FD9\u4E2A\u76EE\u5F55\u6240\u5728\u7684\u6587\u4EF6\u7CFB\u7EDF**\u4E0D\u652F\u6301\u786C\u94FE\u63A5**\uFF08FAT / exFAT / \u90E8\u5206 SMB \u5171\u4EAB\uFF09\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u78C1\u76D8\u6EE1\u3002\u2460 \u7684\u8BDD\u628A work \u76EE\u5F55\u632A\u5230\u672C\u5730\u76D8\u4E0A\u518D\u8DD1"
|
|
13503
|
+
);
|
|
13504
|
+
}
|
|
13505
|
+
}
|
|
13506
|
+
const [held, why] = readLease(layout);
|
|
13507
|
+
if (held === null) {
|
|
13508
|
+
throw new LeaseViolation(
|
|
13509
|
+
"lease-unreadable",
|
|
13510
|
+
`${p} \u5728\uFF0C\u4F46\u8BFB\u4E0D\u51FA\u5185\u5BB9\uFF1A${why}`,
|
|
13511
|
+
`\u8BFB\u4E0D\u51FA\u5185\u5BB9\u5C31\u5224\u4E0D\u51FA\u5B83\u662F\u6D3B\u7684\u8FD8\u662F\u9648\u65E7\u7684\uFF0C\u800C\u300C\u5224\u4E0D\u51FA\u300D\u5F53\u6210\u300C\u9648\u65E7\u300D\u5C31\u662F\u5141\u8BB8\u53CC\u5199\u3002\u786E\u8BA4\u8FD9\u4E2A work \u76EE\u5F55\u4E0A**\u6CA1\u6709\u522B\u7684 kit \u8FDB\u7A0B\u5728\u8DD1**\u4E4B\u540E\uFF0C\u624B\u5DE5\u5220\u6389 ${p} \u518D\u8DD1\u4E00\u6B21`
|
|
13512
|
+
);
|
|
13513
|
+
}
|
|
13514
|
+
if (sameIdentity(leaseIdentity(held), me)) {
|
|
13515
|
+
const [acquired] = parseStamp(held.acquiredAt);
|
|
13516
|
+
const again = new Lease(
|
|
13517
|
+
layout,
|
|
13518
|
+
{ host: me[0], pid: me[1], roundId, acquiredAt: acquired ?? now, heartbeatAt: now },
|
|
13519
|
+
null,
|
|
13520
|
+
clock
|
|
13521
|
+
);
|
|
13522
|
+
try {
|
|
13523
|
+
layout.replaceAtomically(LEASE_FILE, serialiseLease(again.payload()));
|
|
13524
|
+
} catch (e) {
|
|
13525
|
+
throw new LeaseViolation(
|
|
13526
|
+
"lease-unwritable",
|
|
13527
|
+
`\u5E42\u7B49\u91CD\u5165\u65F6\u5237\u65B0\u79DF\u7EA6\u5199\u4E0D\u8FDB\u53BB\uFF08${String(e)}\uFF09\u3002\u79DF\u7EA6\u6587\u4EF6\uFF1A${p}`,
|
|
13528
|
+
"\u79DF\u7EA6\u6587\u4EF6\u5DF2\u7ECF\u5728\u3001\u800C\u4E14**\u5C31\u662F\u6211\u65B9\u7684**\uFF08\u540C host + pid + roundId\uFF09\uFF0C\u5199\u5931\u8D25\u53EA\u662F\u6CA1\u80FD\u628A heartbeatAt \u5237\u5230\u5F53\u4E0B \u2014\u2014 \u6587\u4EF6\u5185\u5BB9\u4ECD\u662F\u539F\u6837\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002**\u8FD9\u4E00\u6B21\u8C03\u7528\u6CA1\u6709\u4EA4\u51FA Lease**\uFF0C\u4EC0\u4E48\u90FD\u6CA1\u505A\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002\u89E3\u51B3\u4E4B\u540E\u518D\u8DD1\u4E00\u6B21\uFF1B\u26A0\uFE0F \u8FD9\u4E00\u8F6E\u6B64\u524D\u53D1\u51FA\u53BB\u7684\u5199\uFF08\u5982\u679C\u6709\uFF09\u90FD\u8BB0\u5728\u53F0\u8D26\u91CC\uFF0C\u7EED\u8DD1\u9760\u5B83\u5224"
|
|
13529
|
+
);
|
|
13530
|
+
}
|
|
13531
|
+
return again;
|
|
13532
|
+
}
|
|
13533
|
+
const [beat, beatWhy] = parseStamp(held.heartbeatAt);
|
|
13534
|
+
if (beat === null) {
|
|
13535
|
+
throw new LeaseViolation(
|
|
13536
|
+
"age-unknown",
|
|
13537
|
+
`${p} \u7684 heartbeatAt \u8BFB\u4E0D\u51FA\u5E74\u9F84\uFF08${beatWhy}\uFF09\uFF0C\u6301\u6709\u8005\u662F ${JSON.stringify(leaseIdentity(held))}`,
|
|
13538
|
+
`\u5224\u4E0D\u51FA\u8FD9\u4EFD\u79DF\u7EA6\u662F\u65B0\u662F\u65E7\u65F6**\u4E0D\u8BB8**\u628A\u5B83\u5F53\u9648\u65E7\u7684\u62A2\u8FC7\u6765 \u2014\u2014 \u300C\u6CA1\u67E5\u51FA\u6765\u300D\u5F53\u6210\u300C\u67E5\u8FC7\u3001\u6CA1\u95EE\u9898\u300D\u6B63\u662F\u672C kit \u53CD\u590D\u5728\u6CBB\u7684\u75C5\u3002\u786E\u8BA4\u90A3\u4E2A\u8FDB\u7A0B\u786E\u5B9E\u4E0D\u5728\u4E86\u4E4B\u540E\uFF0C\u624B\u5DE5\u5220\u6389 ${p} \u518D\u8DD1\u4E00\u6B21`
|
|
13539
|
+
);
|
|
13540
|
+
}
|
|
13541
|
+
const age = (now.getTime() - beat.getTime()) / 1e3;
|
|
13542
|
+
if (age < LEASE_STALE_SECONDS) {
|
|
13543
|
+
throw new LeaseViolation(
|
|
13544
|
+
"held-by-another",
|
|
13545
|
+
`${p} \u5DF2\u88AB ${JSON.stringify(leaseIdentity(held))} \u6301\u6709\uFF0C\u6700\u8FD1\u4E00\u6B21\u5FC3\u8DF3\u5728 ${age.toFixed(0)} \u79D2\u524D\uFF08\u9608\u503C ${LEASE_STALE_SECONDS} \u79D2\uFF09`,
|
|
13546
|
+
"\u540C\u4E00\u4E2A work \u76EE\u5F55\u540C\u65F6\u53EA\u5141\u8BB8\u4E00\u4E2A\u5199\u8005\uFF1A\u4E24\u4E2A\u5199\u8005\u5171\u7528\u4E00\u4EFD\u53F0\u8D26\uFF0C\u800C\u53F0\u8D26\u662F\u300C\u8FD9\u4E00\u884C\u5EFA\u8FC7\u6CA1\u6709\u300D\u7684\u552F\u4E00\u4F9D\u636E\u3002\u7B49\u90A3\u4E00\u8F6E\u8DD1\u5B8C\uFF0C\u6216\u8005\u786E\u8BA4\u90A3\u4E2A\u6301\u6709\u8005\u771F\u7684\u4E0D\u5728\u4E86\uFF0C\u518D\u8DD1\u4E00\u6B21 \u2014\u2014 \u786E\u8BA4\u4E0D\u4E86\u5C31\u522B\u62A2"
|
|
13547
|
+
);
|
|
13548
|
+
}
|
|
13549
|
+
const taken = new Lease(
|
|
13550
|
+
layout,
|
|
13551
|
+
{ host: me[0], pid: me[1], roundId, acquiredAt: now, heartbeatAt: now },
|
|
13552
|
+
{ identity: leaseIdentity(held), heartbeatAt: held.heartbeatAt, ageSeconds: Math.round(age * 10) / 10 },
|
|
13553
|
+
clock
|
|
13554
|
+
);
|
|
13555
|
+
try {
|
|
13556
|
+
layout.replaceAtomically(LEASE_FILE, serialiseLease(taken.payload()));
|
|
13557
|
+
} catch (e) {
|
|
13558
|
+
throw new LeaseViolation(
|
|
13559
|
+
"lease-unwritable",
|
|
13560
|
+
`\u56DE\u6536\u9648\u65E7\u79DF\u7EA6\u65F6\u5199\u4E0D\u8FDB\u53BB\uFF08${String(e)}\uFF09\u3002\u79DF\u7EA6\u6587\u4EF6\uFF1A${p}`,
|
|
13561
|
+
`\u90A3\u4EFD\u9648\u65E7\u79DF\u7EA6\uFF08${JSON.stringify(leaseIdentity(held))}\uFF0C\u5FC3\u8DF3\u5728 ${age.toFixed(0)} \u79D2\u524D\uFF09**\u6CA1\u6709\u88AB\u9876\u6389\uFF0C\u6587\u4EF6\u4ECD\u662F\u539F\u6837**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002\u8FD9\u4E00\u8F6E**\u6CA1\u6709\u62FF\u5230\u79DF\u7EA6**\uFF1B\u5199\u8BF7\u6C42\u662F\u62FF\u5230\u79DF\u7EA6\u4E4B\u540E\u624D\u5F00\u59CB\u53D1\u7684\uFF0C\u6240\u4EE5\u6B64\u523B\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u6CA1\u6709\u53D1\u51FA\u53BB\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002\u89E3\u51B3\u4E4B\u540E\u518D\u8DD1\u4E00\u6B21`
|
|
13562
|
+
);
|
|
13563
|
+
}
|
|
13564
|
+
return taken;
|
|
13565
|
+
}
|
|
13566
|
+
|
|
13567
|
+
// src/fde/seed/execute.ts
|
|
13568
|
+
var VERSION4 = 1;
|
|
13569
|
+
var EXECUTABLE_ACTIONS = ["create", "skip"];
|
|
13570
|
+
var RESOLVABLE_REFS = ["no-parent", "existing-index", "wave-row"];
|
|
13571
|
+
var UNRESOLVABLE_REFS = [
|
|
13572
|
+
"unchecked-no-index",
|
|
13573
|
+
"unresolved-no-index",
|
|
13574
|
+
"ref-key-mismatch",
|
|
13575
|
+
"ref-target-key-space",
|
|
13576
|
+
"ref-not-found"
|
|
13577
|
+
];
|
|
13578
|
+
var REF_NEXT_STEPS = {
|
|
13579
|
+
"unchecked-no-index": "\u8FD9\u4E2A\u6A21\u578B\u8FD9\u4E00\u8F6E\u6CA1\u6709\u65E2\u5B58\u7D22\u5F15\uFF08\u7236\u6307\u9488\u6CA1\u67E5\u8FC7\u65E2\u5B58\uFF09\u2014\u2014 \u5148\u8BA9\u5B83\u7684\u65E2\u5B58\u7D22\u5F15\u53D6\u6570\u6210\u529F\uFF0C\u518D\u8DD1\u4E00\u6B21 plan",
|
|
13580
|
+
"unresolved-no-index": "\u5DE5\u4EF6\u7684 models[] \u91CC**\u6CA1\u6709**\u88AB\u5F15\u7528\u7684\u90A3\u4E2A\u6A21\u578B \u21D2 \u6CA1\u4EBA\u53BB\u5EFA\u5B83\u7684\u7D22\u5F15\u3002\u628A\u90A3\u4E2A\u6A21\u578B\u4E5F\u5217\u8FDB models[]\uFF08\u54EA\u6015\u5B83\u8FD9\u4E00\u8F6E\u4E00\u884C\u90FD\u4E0D\u5BFC\uFF0C\u6709\u4E86\u5B83\u7684 businessKey\uFF0C\u7D22\u5F15\u5C31\u4F1A\u88AB\u5EFA\u51FA\u6765\uFF09",
|
|
13581
|
+
"ref-key-mismatch": "\u90A3\u4E2A\u6A21\u578B\u7684\u7D22\u5F15**\u5EFA\u6210\u4E86**\uFF0C\u4F46\u5B83\u662F\u6309\u5DE5\u4EF6\u7ED9\u5B83\u58F0\u660E\u7684 businessKey \u5EFA\u7684\uFF0C\u4E0E\u8FD9\u91CC\u7684 resolveBy.keyField \u4E0D\u662F\u540C\u4E00\u4E2A\u952E \u21D2 \u6362\u4E0D\u51FA id\u3002\u628A\u4E24\u8005\u5BF9\u9F50\uFF08\u6539 keyField\uFF0C\u6216\u6539\u90A3\u4E2A\u6A21\u578B\u7684 businessKey\uFF09\u3002\u{1F534} \u76EE\u6807\u6A21\u578B\u662F**\u590D\u5408\u4E1A\u52A1\u952E**\u65F6\u5FC5\u7136\u843D\u8FD9\u4E00\u6863\uFF1A\u4E00\u4E2A\u5355\u503C keyField \u6362\u4E0D\u51FA\u4E00\u4E2A\u590D\u5408\u952E\uFF0C\u8FD9\u65F6\u53EA\u80FD\u6539\u6570\u636E\u6A21\u578B\u6216\u8D70\u4EBA\u5DE5",
|
|
13582
|
+
"ref-target-key-space": "\u88AB\u5F15\u7528\u7684\u90A3\u4E2A\u6A21\u578B\uFF0C**\u5B83\u81EA\u5DF1\u7684\u4E1A\u52A1\u952E**\u5E26 resolveBy \u21D2 \u5B83\u7684\u884C\u952E\u4E0E\u65E2\u5B58\u7D22\u5F15\u90FD\u5728**\u89E3\u6790\u540E\u7684 id** \u7A7A\u95F4\uFF0C\u800C\u8FD9\u6761\u5F15\u7528\u624B\u4E0A\u662F**\u6E90\u8868\u91CC\u7684\u503C**\uFF0C\u4E24\u8FB9\u6C38\u4E0D\u76F8\u7B49\u3002\u{1F534} **\u91CD\u8DD1\u4E0D\u4F1A\u53D8**\uFF1A\u76EE\u6807\u884C\u65E9\u5C31\u5BFC\u8FDB\u53BB\u4E86\u4E5F\u4E00\u6837\uFF0C\u522B\u518D\u53BB\u5BFC\u4E00\u904D\u90A3\u4E2A\u6A21\u578B\u3002\u505A\u5F97\u5230\u7684\u662F\u6539\u6570\u636E\u6A21\u578B\uFF08\u7ED9\u90A3\u4E2A\u6A21\u578B\u4E00\u4E2A\u771F\u6B63\u7684\u81EA\u7136\u952E\u5217\uFF0C\u518D\u628A keyField \u6307\u5411\u5B83\uFF09\u6216\u8FD9\u6761\u5F15\u7528\u8D70\u4EBA\u5DE5",
|
|
13583
|
+
"ref-not-found": "\u7D22\u5F15\u5728\u3001\u952E\u4E5F\u5BF9\u5F97\u4E0A\uFF0C\u53EA\u662F\u8FD9\u4E2A\u503C**\u4E0D\u5728\u65E2\u5B58\u7D22\u5F15\u91CC**\u3002\u5148\u628A\u90A3\u4E2A\u6A21\u578B\u7684\u76EE\u6807\u884C\u5BFC\u8FDB\u53BB\uFF08\u6216\u786E\u8BA4\u5B83\u5728\u7CFB\u7EDF\u91CC\u7684\u952E\u5C31\u662F\u8FD9\u4E2A\u5199\u6CD5\uFF09\uFF0C\u518D\u8DD1\u4E00\u6B21 plan\u3002\u26A0\uFE0F \u672C kit \u4E0D\u5EFA\u8DE8\u6A21\u578B\u7684\u6CE2\uFF0C\u6240\u4EE5\u300C\u5B83\u4E5F\u5728\u8FD9\u4E00\u8F6E\u91CC\u7B49\u7740\u88AB\u5EFA\u300D\u540C\u6837\u843D\u8FD9\u4E00\u6863 \u2014\u2014 \u90A3\u5C31\u5148\u5355\u72EC\u8DD1\u4E00\u8F6E\u628A\u90A3\u4E2A\u6A21\u578B\u5BFC\u5B8C"
|
|
13584
|
+
};
|
|
13585
|
+
var REF_STEP_UNKNOWN = "\u8BA1\u5212\u5C42\u51FA\u4E86\u4E00\u6863\u672C\u6267\u884C\u5668**\u4E0D\u8BA4\u8BC6**\u7684 resolveFrom\uFF0C\u6309\u300C\u672A\u77E5\u5373\u62D2\u300D\u505C\u624B\u4E86 \u2014\u2014 \u8FD9\u4E0D\u7B49\u4E8E\u8BF4\u5B83\u6362\u4E0D\u51FA id\uFF0C\u672C\u6267\u884C\u5668\u5224\u4E0D\u4E86\u3002\u53BB\u8BA1\u5212\u5C42\u7684 RESOLVE_FROM \u770B\u5B83\u7684\u8BED\u4E49\uFF1A\u8BE5\u7B97\u300C\u6362\u5F97\u51FA\u300D\u5C31\u628A\u5B83\u52A0\u8FDB RESOLVABLE_REFS\uFF0C\u8BE5\u7B97\u300C\u6362\u4E0D\u51FA\u300D\u5C31\u7ED9\u5B83\u5199\u4E00\u6761 REF_NEXT_STEPS";
|
|
13586
|
+
var DRY_RUN_ID = "<dry-run:\u6267\u884C\u65F6\u624D\u6709 id>";
|
|
13587
|
+
var APPLY_PROBLEM_CODES = [
|
|
13588
|
+
// ── 前置闸(零请求)──
|
|
13589
|
+
"PLAN_NOT_CLEAN",
|
|
13590
|
+
"PLAN_MAPPING_MISMATCH",
|
|
13591
|
+
"PLAN_ROW_KEY_ARITY_MISMATCH",
|
|
13592
|
+
"PLAN_ROW_KEY_INVALID",
|
|
13593
|
+
"ACTION_NOT_EXECUTABLE",
|
|
13594
|
+
"REF_UNRESOLVED",
|
|
13595
|
+
// ── 执行期(逐行)──
|
|
13596
|
+
"CREATE_REJECTED",
|
|
13597
|
+
"BUSINESS_KEY_NOT_ROUND_TRIPPED",
|
|
13598
|
+
"READBACK_FAILED",
|
|
13599
|
+
"CREATE_OUTCOME_UNKNOWN",
|
|
13600
|
+
"PARENT_NOT_WRITTEN",
|
|
13601
|
+
"SAMPLE_VERIFY_FAILED",
|
|
13602
|
+
"ROW_QUARANTINED",
|
|
13603
|
+
"LEASE_HEARTBEAT_FAILED"
|
|
13604
|
+
];
|
|
13605
|
+
var MAX_LISTED3 = 20;
|
|
13606
|
+
var BUCKETS = [
|
|
13607
|
+
"created",
|
|
13608
|
+
"skipped",
|
|
13609
|
+
"already",
|
|
13610
|
+
"writeFailed",
|
|
13611
|
+
"unverified",
|
|
13612
|
+
"blocked",
|
|
13613
|
+
"quarantined",
|
|
13614
|
+
"notAttempted",
|
|
13615
|
+
"wouldCreate"
|
|
13616
|
+
];
|
|
13617
|
+
var ApplyPremiseError = class extends Error {
|
|
13618
|
+
reason;
|
|
13619
|
+
detail;
|
|
13620
|
+
hint;
|
|
13621
|
+
constructor(reason, detail, hint = "") {
|
|
13622
|
+
super(`[${reason}] ${detail}${hint ? ` \u2014\u2014 ${hint}` : ""}`);
|
|
13623
|
+
this.name = "ApplyPremiseError";
|
|
13624
|
+
this.reason = reason;
|
|
13625
|
+
this.detail = detail;
|
|
13626
|
+
this.hint = hint;
|
|
13627
|
+
}
|
|
13628
|
+
};
|
|
13629
|
+
var ApplyInvariantError = class extends Error {
|
|
13630
|
+
constructor(message) {
|
|
13631
|
+
super(message);
|
|
13632
|
+
this.name = "ApplyInvariantError";
|
|
13633
|
+
}
|
|
13634
|
+
};
|
|
13635
|
+
function problem4(code, model, message, hint, row = null, key = null, rawError = null) {
|
|
13636
|
+
return { code, model, row, key, message, hint, rawError };
|
|
13637
|
+
}
|
|
13638
|
+
function createPath(model) {
|
|
13639
|
+
return `/api/models/${model}`;
|
|
13640
|
+
}
|
|
13641
|
+
function assertBusinessKeySent(payload, keyFields, key, model, rowNo2) {
|
|
13642
|
+
keyFields.forEach((field, position) => {
|
|
13643
|
+
if (!(field in payload)) {
|
|
13644
|
+
throw new ApplyInvariantError(
|
|
13645
|
+
`${model} \u7B2C ${rowNo2} \u884C\u7684 payload \u91CC\u6CA1\u6709\u4E1A\u52A1\u952E\u5B57\u6BB5 ${JSON.stringify(field)} \u2014\u2014 \u5B9E\u6D4B\uFF1A\u4E0D\u9001\u4E1A\u52A1\u952E\u65F6\u670D\u52A1\u7AEF\u4F1A\u8865\u4E00\u4E2A\u6D41\u6C34\u7801\uFF08OU2026\u2026\uFF09\uFF0C\u4E0B\u4E00\u8F6E\u6309\u539F\u952E\u56DE\u8BFB 0 \u884C \u21D2 \u518D\u5EFA\u4E00\u6761 \u21D2 \u91CD\u590D\u884C\u3002payload \u7684\u952E\uFF1A${JSON.stringify(Object.keys(payload).sort())}`
|
|
13646
|
+
);
|
|
13647
|
+
}
|
|
13648
|
+
const sent = norm(payload[field]);
|
|
13649
|
+
if (sent !== key[position]) {
|
|
13650
|
+
throw new ApplyInvariantError(
|
|
13651
|
+
`${model} \u7B2C ${rowNo2} \u884C\u9001\u51FA\u53BB\u7684 ${field} \u662F ${JSON.stringify(payload[field])}\uFF08\u5F52\u4E00\u540E ${JSON.stringify(sent)}\uFF09\uFF0C\u800C\u8BA1\u5212\u7B97\u51FA\u6765\u7684\u884C\u952E\u662F ${JSON.stringify(key[position])} \u2014\u2014 \u4E24\u8005\u5FC5\u987B\u9010\u5B57\u76F8\u540C\uFF0C\u5426\u5219\u56DE\u8BFB\u6BD4\u5BF9\u65AD\u7684\u5C31\u4E0D\u662F\u8FD9\u4E00\u884C`
|
|
13652
|
+
);
|
|
13653
|
+
}
|
|
13654
|
+
});
|
|
13655
|
+
}
|
|
13656
|
+
function buildPayload(row, createdIds, journal) {
|
|
13657
|
+
const body = Object.fromEntries(row.fields);
|
|
13658
|
+
for (const ref of row.refs) {
|
|
13659
|
+
if (ref.resolveFrom === "no-parent") continue;
|
|
13660
|
+
if (ref.resolvedId) {
|
|
13661
|
+
body[ref.field] = ref.resolvedId;
|
|
13662
|
+
continue;
|
|
13663
|
+
}
|
|
13664
|
+
const target = [norm(ref.value) ?? ""];
|
|
13665
|
+
let found = createdIds.get(createdKey(ref.model, target));
|
|
13666
|
+
if (found === void 0) {
|
|
13667
|
+
const previous = journal.latest(ref.model, target);
|
|
13668
|
+
if (previous !== null && previous.status === "done") found = previous.serverId ?? void 0;
|
|
13669
|
+
}
|
|
13670
|
+
if (!found) return [null, ref];
|
|
13671
|
+
body[ref.field] = found;
|
|
13672
|
+
}
|
|
13673
|
+
return [body, null];
|
|
13674
|
+
}
|
|
13675
|
+
function createdKey(model, key) {
|
|
13676
|
+
return JSON.stringify([model, key]);
|
|
13677
|
+
}
|
|
13678
|
+
var ACTION_HINTS = {
|
|
13679
|
+
update: "\u672C\u6267\u884C\u5668\u8FD9\u4E00\u8F6E**\u4E0D\u5199 update**\uFF08\u6682\u65F6\u4E0D\u505A\uFF0C\u4E0D\u662F\u505A\u4E0D\u5230\uFF09\uFF1A\u5B9E\u6D4B\u53EA\u8DD1\u8FC7 create\uFF0C\u300Cupdate \u8DEF\u5F84\u80FD\u5426\u6539 auto-generated \u7684 code\u300D\u6CA1\u6709\u5B9E\u6D4B\u80CC\u4E66\uFF0C\u800C\u627F\u91CD\u89C4\u5219 2 \u7684\u56DE\u8BFB\u6BD4\u5BF9\u6B63\u662F\u9760\u5B83\u3002\u8981\u4E48\u628A onExisting \u6539\u6210 skip \u53EA\u8865\u589E\u91CF\uFF0C\u8981\u4E48\u8FD9\u51E0\u884C\u8D70\u4EBA\u5DE5",
|
|
13680
|
+
fail: '\u5DE5\u4EF6\u5199\u7684\u662F onExisting: "fail" \u2014\u2014 \u547D\u4E2D\u65E2\u5B58\u65F6**\u672C\u610F\u5C31\u662F\u505C**\u3002\u5148\u786E\u8BA4\u8FD9\u4E9B\u884C\u5230\u5E95\u8BE5\u8DF3\u8FC7\u8FD8\u662F\u8BE5\u66F4\u65B0\uFF0C\u518D\u6539\u5DE5\u4EF6',
|
|
13681
|
+
unknown: "\u8BA1\u5212\u5C42\u6CA1\u6709\u67E5\u8FC7\u65E2\u5B58\uFF08\u7F3A\u7D22\u5F15\uFF09\uFF0C\u6240\u4EE5\u8BF4\u4E0D\u51FA\u8FD9\u51E0\u884C\u662F\u5EFA\u8FD8\u662F\u5BF9\u65E2\u5B58\u3002\u8FD9\u65F6\u5019\u5EFA = \u300C\u7D22\u5F15\u4E3A\u7A7A\u88AB\u8BFB\u6210\u5168\u662F\u65B0\u884C\u300D\u90A3\u4E2A\u6D1E\uFF0C\u4F1A\u9759\u9ED8\u9020\u51FA\u5168\u91CF\u91CD\u590D\u3002\u5148\u8BA9\u65E2\u5B58\u7D22\u5F15\u53D6\u6570\u6210\u529F"
|
|
13682
|
+
};
|
|
13683
|
+
function listed2(items, total) {
|
|
13684
|
+
return `${items.slice(0, MAX_LISTED3).join("\uFF1B")}${total > MAX_LISTED3 ? `\u2026\uFF08\u5171 ${total} \u6761\uFF09` : ""}`;
|
|
13685
|
+
}
|
|
13686
|
+
function preflight(plan, mapping) {
|
|
13687
|
+
const out = [];
|
|
13688
|
+
if (plan.problems.length > 0) {
|
|
13689
|
+
const codes = [...new Set(plan.problems.map((p) => p.code))].sort();
|
|
13690
|
+
out.push(
|
|
13691
|
+
problem4(
|
|
13692
|
+
"PLAN_NOT_CLEAN",
|
|
13693
|
+
"*",
|
|
13694
|
+
`\u8BA1\u5212\u91CC\u6709 ${plan.problems.length} \u6761\u95EE\u9898\uFF08${codes.join("\u3001")}\uFF09\uFF0C**\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u4F1A\u53D1**`,
|
|
13695
|
+
"\u8BA1\u5212\u5C42\u7684 problem \u5168\u90FD\u662F\u786C\u5931\u8D25\uFF0C\u6CA1\u6709\u300C\u5EFA\u8BAE\u300D\u6863\u3002\u9010\u6761\u6309\u5B83\u7684 hint \u4FEE\u5DE5\u4EF6/\u6E90\u8868\uFF0C\u91CD\u65B0\u8DD1\u4E00\u6B21 plan\uFF0C\u7EFF\u4E86\u518D apply"
|
|
13696
|
+
)
|
|
13697
|
+
);
|
|
13698
|
+
}
|
|
13699
|
+
const plannedModels = plan.models.map((m) => m.model);
|
|
13700
|
+
const artifactModels = mapping.models.map((m) => m.model);
|
|
13701
|
+
if (JSON.stringify(plannedModels) !== JSON.stringify(artifactModels)) {
|
|
13702
|
+
out.push(
|
|
13703
|
+
problem4(
|
|
13704
|
+
"PLAN_MAPPING_MISMATCH",
|
|
13705
|
+
"*",
|
|
13706
|
+
`\u8BA1\u5212\u91CC\u7684\u6A21\u578B\u662F ${JSON.stringify(plannedModels)}\uFF0C\u5DE5\u4EF6\u91CC\u7684\u662F ${JSON.stringify(artifactModels)} \u2014\u2014 \u4E24\u4EFD\u5BF9\u4E0D\u4E0A`,
|
|
13707
|
+
"\u8BA1\u5212\u662F\u843D\u76D8\u4EA7\u7269\uFF08import-plan.json\uFF09\uFF0C\u5DE5\u4EF6\u4E5F\u662F\u3002\u5DE5\u4EF6\u6539\u8FC7\u4E4B\u540E\u5FC5\u987B\u91CD\u65B0\u8DD1 plan\uFF1A\u62FF\u65E7\u8BA1\u5212\u914D\u65B0\u5DE5\u4EF6\u5199\u51FA\u53BB\u7684\u662F**\u4E0A\u4E00\u7248\u7684\u53E3\u5F84**\uFF0C\u800C\u8FD9\u4EF6\u4E8B\u5728\u4EA7\u7269\u91CC\u770B\u4E0D\u51FA\u6765"
|
|
13708
|
+
)
|
|
13709
|
+
);
|
|
13710
|
+
} else {
|
|
13711
|
+
plan.models.forEach((modelPlan, i) => {
|
|
13712
|
+
const declared = mapping.models[i].businessKey?.fields ?? [];
|
|
13713
|
+
if (JSON.stringify(modelPlan.businessKeyFields) !== JSON.stringify([...declared])) {
|
|
13714
|
+
out.push(
|
|
13715
|
+
problem4(
|
|
13716
|
+
"PLAN_MAPPING_MISMATCH",
|
|
13717
|
+
modelPlan.model,
|
|
13718
|
+
`${modelPlan.model} \u7684\u4E1A\u52A1\u952E\uFF1A\u8BA1\u5212\u91CC\u662F ${JSON.stringify(modelPlan.businessKeyFields)}\uFF0C\u5DE5\u4EF6\u91CC\u662F ${JSON.stringify([...declared])}`,
|
|
13719
|
+
"\u4E1A\u52A1\u952E\u662F\u5E42\u7B49\u7684\u652F\u70B9\u3002\u4E24\u4EFD\u4E0D\u4E00\u81F4\u65F6\uFF0C\u56DE\u8BFB\u6BD4\u5BF9\u65AD\u7684\u662F\u4E00\u4E2A\u952E\u3001\u5199\u8FDB\u53BB\u7684\u662F\u53E6\u4E00\u4E2A\u952E \u2014\u2014 \u91CD\u65B0\u8DD1\u4E00\u6B21 plan"
|
|
13720
|
+
)
|
|
13721
|
+
);
|
|
13722
|
+
}
|
|
13723
|
+
});
|
|
13724
|
+
}
|
|
13725
|
+
for (const modelPlan of plan.models) {
|
|
13726
|
+
if (!modelPlan.planned || modelPlan.waves === null) continue;
|
|
13727
|
+
out.push(...modelGates(modelPlan));
|
|
13728
|
+
}
|
|
13729
|
+
return out;
|
|
13730
|
+
}
|
|
13731
|
+
function modelGates(modelPlan) {
|
|
13732
|
+
const out = [];
|
|
13733
|
+
const badActions = /* @__PURE__ */ new Map();
|
|
13734
|
+
const unresolved = [];
|
|
13735
|
+
const badArity = [];
|
|
13736
|
+
const badKeys = [];
|
|
13737
|
+
const arity = modelPlan.businessKeyFields.length;
|
|
13738
|
+
for (const wave of modelPlan.waves) {
|
|
13739
|
+
for (const row of wave.rows) {
|
|
13740
|
+
const rawKey = row.key;
|
|
13741
|
+
try {
|
|
13742
|
+
businessKeyOf(rawKey);
|
|
13743
|
+
} catch (e) {
|
|
13744
|
+
if (!(e instanceof JournalError)) throw e;
|
|
13745
|
+
badKeys.push([row.row, rawKey, e]);
|
|
13746
|
+
}
|
|
13747
|
+
const actual = Array.isArray(rawKey) ? rawKey.length : null;
|
|
13748
|
+
if (actual !== arity) badArity.push([row.row, rawKey, actual]);
|
|
13749
|
+
if (!EXECUTABLE_ACTIONS.includes(row.action)) {
|
|
13750
|
+
const at = badActions.get(row.action);
|
|
13751
|
+
if (at === void 0) badActions.set(row.action, [row.row]);
|
|
13752
|
+
else at.push(row.row);
|
|
13753
|
+
}
|
|
13754
|
+
for (const ref of row.refs) {
|
|
13755
|
+
if (!RESOLVABLE_REFS.includes(ref.resolveFrom)) {
|
|
13756
|
+
unresolved.push([row.row, ref]);
|
|
13757
|
+
}
|
|
13758
|
+
}
|
|
13759
|
+
}
|
|
13760
|
+
}
|
|
13761
|
+
if (badKeys.length > 0) {
|
|
13762
|
+
out.push(
|
|
13763
|
+
problem4(
|
|
13764
|
+
"PLAN_ROW_KEY_INVALID",
|
|
13765
|
+
modelPlan.model,
|
|
13766
|
+
`${modelPlan.model} \u6709 ${badKeys.length} \u884C\u7684 key \u4E0D\u662F\u4E00\u7EC4\u975E\u7A7A\u5B57\u7B26\u4E32\uFF1A` + listed2(
|
|
13767
|
+
badKeys.map(([n, k, e]) => `\u7B2C ${n} \u884C\uFF08${JSON.stringify(k)}\uFF09\uFF1A[${e.reason}] ${e.detail}`),
|
|
13768
|
+
badKeys.length
|
|
13769
|
+
),
|
|
13770
|
+
"\u{1F534} \u8FD9\u662F**\u8FD9\u4EFD `import-plan.json` \u81EA\u5DF1**\u524D\u540E\u5BF9\u4E0D\u4E0A\uFF0C\u4E0D\u662F\u6E90\u8868\u5185\u5BB9\u7684\u95EE\u9898\u3002\u8BA1\u5212\u5C42\u7B97\u51FA\u6765\u7684\u884C\u952E\u9010\u5B57\u6BB5\u90FD\u662F\u5B57\u7B26\u4E32\uFF0C\u8FD9\u4EFD\u8BA1\u5212**\u88AB\u4EC0\u4E48\u52A8\u8FC7\u3001\u8FD8\u662F\u522B\u7684\u4E1C\u897F\u5199\u7684**\uFF0C\u672C\u6A21\u5757\u6CA1\u6709\u67E5\u8FC7\u3002\u26A0\uFE0F \u522B\u53BB\u6539 `key` \u51D1\u4E00\u4E2A\u5B57\u7B26\u4E32\u4E0A\u53BB\uFF1A\u51D1\u51FA\u6765\u7684\u90A3\u4E00\u683C\u6CA1\u6709\u6E90\u8868\u503C\u515C\u7740\u3002\u5728\u8FD9\u4E2A work \u76EE\u5F55\u4E0A\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`\u3002\u{1F534} **\u4E3A\u4EC0\u4E48\u5FC5\u987B\u6574\u8F6E\u505C**\uFF1A\u53F0\u8D26\u662F\u5199\u5230\u78C1\u76D8\u518D\u8BFB\u56DE\u6765\u7684\uFF0C\u975E\u5B57\u7B26\u4E32\u7684\u952E\u5728 JSON \u5F80\u8FD4\u4E4B\u540E\u4E0E\u8BA1\u5212\u90A3\u8FB9\u7684\u5B57\u7B26\u4E32\u952E\u914D\u4E0D\u4E0A\uFF0C\u8868\u73B0\u662F\u8FD9\u4E00\u884C\u88AB\u5F53\u6210\u300C\u4ECE\u6CA1\u8BB0\u8FC7\u300D\u800C\u91CD\u653E \u2014\u2014 \u4E5F\u5C31\u662F\u91CD\u590D\u884C\u3002"
|
|
13771
|
+
)
|
|
13772
|
+
);
|
|
13773
|
+
}
|
|
13774
|
+
if (badArity.length > 0) {
|
|
13775
|
+
out.push(
|
|
13776
|
+
problem4(
|
|
13777
|
+
"PLAN_ROW_KEY_ARITY_MISMATCH",
|
|
13778
|
+
modelPlan.model,
|
|
13779
|
+
`${modelPlan.model} \u58F0\u660E\u7684\u4E1A\u52A1\u952E\u5B57\u6BB5\u6709 ${arity} \u4E2A\uFF08${JSON.stringify(modelPlan.businessKeyFields)}\uFF09\uFF0C\u800C\u6709 ${badArity.length} \u884C\u7684 key \u4E0D\u662F\u8FD9\u4E2A\u4E2A\u6570\uFF1A` + listed2(
|
|
13780
|
+
badArity.map(
|
|
13781
|
+
([n, k, actual]) => actual !== null ? `\u7B2C ${n} \u884C\u6709 ${actual} \u4E2A\uFF08${JSON.stringify(k)}\uFF09` : `\u7B2C ${n} \u884C\u7684 key \u6839\u672C\u4E0D\u662F\u4E00\u7EC4\uFF08${JSON.stringify(k)}\uFF09`
|
|
13782
|
+
),
|
|
13783
|
+
badArity.length
|
|
13784
|
+
),
|
|
13785
|
+
"\u{1F534} \u8FD9\u662F**\u8FD9\u4EFD `import-plan.json` \u81EA\u5DF1\u524D\u540E\u5BF9\u4E0D\u4E0A**\uFF0C\u4E0D\u662F\u6E90\u8868\u5185\u5BB9\u7684\u95EE\u9898 \u2014\u2014 \u540C\u4E00\u4EFD\u6587\u4EF6\u91CC\u4E24\u5904\u4E92\u76F8\u77DB\u76FE\uFF0C\u5FC5\u6709\u4E00\u5904\u662F\u5047\u7684\u3002\u8BA1\u5212\u5C42\u7B97\u51FA\u6765\u7684\u884C\u952E\u6052\u6309 businessKey.fields \u9010\u5B57\u6BB5\u53D6 \u21D2 \u4E24\u8005\u6052\u7B49\u957F\uFF1B\u8FD9\u4EFD\u8BA1\u5212**\u88AB\u4EC0\u4E48\u52A8\u8FC7\u3001\u8FD8\u662F\u522B\u7684\u4E1C\u897F\u5199\u7684**\uFF0C\u672C\u6A21\u5757\u6CA1\u6709\u67E5\u8FC7\u3002\u26A0\uFE0F \u522B\u53BB\u6539 `key` \u51D1\u4E2A\u6570\uFF1A\u51D1\u51FA\u6765\u7684\u90A3\u4E00\u683C\u6CA1\u6709\u6E90\u8868\u503C\u515C\u7740\u3002\u5728\u8FD9\u4E2A work \u76EE\u5F55\u4E0A\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`\u3002\u{1F534} **\u4E3A\u4EC0\u4E48\u6574\u8F6E\u505C**\uFF1A\u56DE\u8BFB\u6309 businessKeyFields \u4E0E\u884C\u952E**\u9010\u4F4D\u914D\u5BF9**\u62FC filter\uFF0C\u4E2A\u6570\u5BF9\u4E0D\u4E0A\u65F6\u62FC\u51FA\u6765\u7684 filter \u5C11\u4E00\u4E2A\u6761\u4EF6\uFF0C\u800C\u5C11\u4E00\u4E2A\u6761\u4EF6\u7684\u56DE\u8BFB\u4F1A\u5339\u914D\u5230**\u522B\u7684\u884C** \u2014\u2014 \u987A\u7740\u5B83\u5224\u300C\u5DF2\u7ECF\u5EFA\u8FC7\u4E86\u300D\u5C31\u662F\u6F0F\u5EFA\uFF0C\u5224\u300C\u6CA1\u5EFA\u6210\u300D\u5C31\u662F\u91CD\u5EFA"
|
|
13786
|
+
)
|
|
13787
|
+
);
|
|
13788
|
+
}
|
|
13789
|
+
for (const [action3, rows] of [...badActions.entries()].sort()) {
|
|
13790
|
+
out.push(
|
|
13791
|
+
problem4(
|
|
13792
|
+
"ACTION_NOT_EXECUTABLE",
|
|
13793
|
+
modelPlan.model,
|
|
13794
|
+
`${modelPlan.model} \u6709 ${rows.length} \u884C\u7684\u52A8\u4F5C\u662F ${JSON.stringify(action3)}\uFF0C\u672C\u6267\u884C\u5668\u6267\u884C\u4E0D\u4E86\uFF08\u80FD\u6267\u884C\u7684\u662F ${JSON.stringify([...EXECUTABLE_ACTIONS])}\uFF09\uFF1A\u7B2C ${rows.slice(0, MAX_LISTED3).join("\u3001")} \u884C${rows.length > MAX_LISTED3 ? `\u2026\uFF08\u5171 ${rows.length} \u884C\uFF09` : ""}`,
|
|
13795
|
+
ACTION_HINTS[action3] ?? "\u5148\u786E\u8BA4\u8FD9\u4E2A\u52A8\u4F5C\u8BE5\u7531\u8C01\u6765\u505A"
|
|
13796
|
+
)
|
|
13797
|
+
);
|
|
13798
|
+
}
|
|
13799
|
+
if (unresolved.length > 0) out.push(refProblem(modelPlan.model, unresolved));
|
|
13800
|
+
return out;
|
|
13801
|
+
}
|
|
13802
|
+
function refProblem(model, unresolved) {
|
|
13803
|
+
const detail = listed2(
|
|
13804
|
+
unresolved.map(
|
|
13805
|
+
([n, ref]) => `\u7B2C ${n} \u884C\u7684 ${ref.field} \u8981\u62FF ${ref.model}.${ref.keyField} \u6362 id\uFF08${ref.resolveFrom}\uFF09`
|
|
13806
|
+
),
|
|
13807
|
+
unresolved.length
|
|
13808
|
+
);
|
|
13809
|
+
const archetypes = [...new Set(unresolved.map(([, ref]) => ref.resolveFrom))].sort();
|
|
13810
|
+
const unknown = archetypes.filter((a) => !UNRESOLVABLE_REFS.includes(a));
|
|
13811
|
+
const headline = unknown.length > 0 ? `${model} \u6709 ${unresolved.length} \u6761\u5F15\u7528**\u8FD9\u4E00\u8F6E\u4E0D\u53D1**\uFF08\u5176\u4E2D ${unknown.join("\u3001")} \u8FD9 ${unknown.length} \u6863\u672C\u6267\u884C\u5668\u4E0D\u8BA4\u8BC6\uFF09\uFF1A${detail}` : `${model} \u6709 ${unresolved.length} \u6761\u5F15\u7528\u6362\u4E0D\u51FA id\uFF1A${detail}`;
|
|
13812
|
+
const preface = unknown.length > 0 ? "**\u672A\u77E5\u6863\u6309\u300C\u672A\u77E5\u5373\u62D2\u300D\u505C\u624B**\uFF0C\u672C\u6267\u884C\u5668\u8BF4\u4E0D\u51FA\u5B83\u4EEC\u6362\u4E0D\u6362\u5F97\u51FA id\u3002\u9010\u6863\u7684\u4E0B\u4E00\u6B65\uFF1A" : "\u6362\u4E0D\u51FA id \u5C31\u628A\u4E00\u4E2A**\u4E1A\u52A1\u952E\u5B57\u7B26\u4E32**\u5F53 id \u9001\u51FA\u53BB\u4E86 \u2014\u2014 \u597D\u7684\u60C5\u51B5\u662F 400\uFF0C\u574F\u7684\u60C5\u51B5\u662F\u5B83\u88AB\u5199\u8FDB\u4E00\u4E2A text \u5217\uFF0C\u770B\u7740\u50CF\u6210\u529F\u3002\u9010\u6863\u7684\u4E0B\u4E00\u6B65\uFF1A";
|
|
13813
|
+
return problem4(
|
|
13814
|
+
"REF_UNRESOLVED",
|
|
13815
|
+
model,
|
|
13816
|
+
headline,
|
|
13817
|
+
preface + archetypes.map((a) => `\u3010${a}\u3011${REF_NEXT_STEPS[a] ?? REF_STEP_UNKNOWN}`).join("\uFF1B")
|
|
13818
|
+
);
|
|
13819
|
+
}
|
|
13820
|
+
var TALLY_FIELDS = [...BUCKETS, "requests", "readbacks"];
|
|
13821
|
+
var Tally = class {
|
|
13822
|
+
counts = /* @__PURE__ */ new Map();
|
|
13823
|
+
constructor() {
|
|
13824
|
+
for (const name of TALLY_FIELDS) this.counts.set(name, 0);
|
|
13825
|
+
}
|
|
13826
|
+
get(name) {
|
|
13827
|
+
return this.counts.get(name);
|
|
13828
|
+
}
|
|
13829
|
+
add(name, count = 1) {
|
|
13830
|
+
this.counts.set(name, this.get(name) + count);
|
|
13831
|
+
}
|
|
13832
|
+
};
|
|
13833
|
+
function reportOf(plan, dryRun, sample, executed, aborted, models, totals, problems) {
|
|
13834
|
+
return {
|
|
13835
|
+
version: VERSION4,
|
|
13836
|
+
roundId: plan.roundId,
|
|
13837
|
+
dryRun,
|
|
13838
|
+
sample,
|
|
13839
|
+
executed,
|
|
13840
|
+
aborted,
|
|
13841
|
+
models: [...models],
|
|
13842
|
+
created: totals.get("created"),
|
|
13843
|
+
skipped: totals.get("skipped"),
|
|
13844
|
+
already: totals.get("already"),
|
|
13845
|
+
writeFailed: totals.get("writeFailed"),
|
|
13846
|
+
unverified: totals.get("unverified"),
|
|
13847
|
+
blocked: totals.get("blocked"),
|
|
13848
|
+
quarantined: totals.get("quarantined"),
|
|
13849
|
+
notAttempted: totals.get("notAttempted"),
|
|
13850
|
+
wouldCreate: totals.get("wouldCreate"),
|
|
13851
|
+
requests: totals.get("requests"),
|
|
13852
|
+
readbacks: totals.get("readbacks"),
|
|
13853
|
+
problems: [...problems]
|
|
13854
|
+
};
|
|
13855
|
+
}
|
|
13856
|
+
function errorEnvelope(body) {
|
|
13857
|
+
if (body !== null && typeof body === "object" && !Array.isArray(body)) {
|
|
13858
|
+
const err = body["error"];
|
|
13859
|
+
if (err !== null && typeof err === "object" && !Array.isArray(err)) return err;
|
|
13860
|
+
}
|
|
13861
|
+
return body;
|
|
13862
|
+
}
|
|
13863
|
+
function priorEntry(journal, model, key) {
|
|
13864
|
+
const previous = journal.latest(model, key);
|
|
13865
|
+
if (previous === null) {
|
|
13866
|
+
throw new ApplyInvariantError(
|
|
13867
|
+
`${model} ${JSON.stringify([...key])} \u5728\u53F0\u8D26\u91CC\u6CA1\u6709\u524D\u7F6E\u8BB0\u5F55\uFF0C\u800C\u8FD9\u91CC\u6B63\u8981\u6539\u5199\u5B83\u7684\u7EC8\u6001 \u2014\u2014 \u5199\u524D\u843D\u8D26\u534F\u8BAE\u8981\u6C42\u300C\u5148\u843D unknown \u518D\u843D\u7EC8\u6001\u300D\uFF0C\u8D70\u5230\u8FD9\u91CC\u5374\u6CA1\u6709\u90A3\u6761\u8BB0\u5F55\uFF0C\u8BF4\u660E\u672C\u6A21\u5757\u81EA\u5DF1\u7684\u987A\u5E8F\u88AB\u7834\u574F\u4E86`
|
|
13868
|
+
);
|
|
13869
|
+
}
|
|
13870
|
+
return previous;
|
|
13871
|
+
}
|
|
13872
|
+
function stampProgress(onRequestSpent, model, row, problems) {
|
|
13873
|
+
try {
|
|
13874
|
+
onRequestSpent();
|
|
13875
|
+
} catch (raw) {
|
|
13876
|
+
if (!(raw instanceof LeaseViolation)) throw raw;
|
|
13877
|
+
const e = raw;
|
|
13878
|
+
problems.push(
|
|
13879
|
+
problem4(
|
|
13880
|
+
"LEASE_HEARTBEAT_FAILED",
|
|
13881
|
+
model,
|
|
13882
|
+
`\u5904\u7406\u7B2C ${row.row} \u884C\uFF08\u5DF2\u7ECF\u53D1\u51FA\u8FC7\u8BF7\u6C42\uFF09\u4E4B\u540E\u76D6\u5FC3\u8DF3\u65F6\u79DF\u7EA6\u51FA\u4E86\u95EE\u9898\uFF1A[${e.reason}] ${e.message}`,
|
|
13883
|
+
e.hint || "",
|
|
13884
|
+
row.row,
|
|
13885
|
+
row.key
|
|
13886
|
+
)
|
|
13887
|
+
);
|
|
13888
|
+
return "lease-heartbeat-failed";
|
|
13889
|
+
}
|
|
13890
|
+
return null;
|
|
13891
|
+
}
|
|
13892
|
+
function quarantineRow(plan, model, row, journal, tally, problems, serverId, stored, evidence, how) {
|
|
13893
|
+
tally.add("writeFailed");
|
|
13894
|
+
journal.append({
|
|
13895
|
+
...priorEntry(journal, model, row.key),
|
|
13896
|
+
status: "quarantined",
|
|
13897
|
+
serverId,
|
|
13898
|
+
roundId: plan.roundId,
|
|
13899
|
+
error: {
|
|
13900
|
+
fdeKit: {
|
|
13901
|
+
reason: "business-key-not-round-tripped",
|
|
13902
|
+
sentKey: [...row.key],
|
|
13903
|
+
storedKey: stored === null ? null : [...stored],
|
|
13904
|
+
how
|
|
13905
|
+
},
|
|
13906
|
+
response: evidence
|
|
13907
|
+
}
|
|
13908
|
+
});
|
|
13909
|
+
problems.push(
|
|
13910
|
+
problem4(
|
|
13911
|
+
"BUSINESS_KEY_NOT_ROUND_TRIPPED",
|
|
13912
|
+
model,
|
|
13913
|
+
`\u7B2C ${row.row} \u884C\u7684**\u4E1A\u52A1\u952E\u672A\u539F\u6837\u5B58\u4E0B**\uFF1A\u9001\u51FA\u53BB\u7684\u662F ${JSON.stringify([...row.key])}\uFF0C${how}` + (stored !== null ? `\uFF1B\u670D\u52A1\u7AEF\u5B58\u4E0B\u6765\u7684\u952E\u662F ${JSON.stringify([...stored])}` : ""),
|
|
13914
|
+
"\u5B9E\u6D4B `OrgUnit` / `Position` \u7684 `code` \u5143\u6570\u636E\u6807 auto-generated\uFF0C\u4E0D\u9001\u5C31\u88AB\u6362\u6210 OU2026\u2026 \u7684\u6D41\u6C34\u7801\uFF1B\u672C\u5DE5\u5177\u662F**\u9001**\u4E86\u7684\uFF0C\u6240\u4EE5\u8D70\u5230\u8FD9\u91CC\u8BF4\u660E\u670D\u52A1\u7AEF\u4ECD\u7136\u6362\u6389\u4E86\u5B83\u3002" + (serverId ? `\u{1F534} \u670D\u52A1\u7AEF\u90A3\u8FB9\u6709\u4E00\u884C id=${serverId}\uFF0C\u5B83**\u4E0D\u5728**\u4F60\u7684\u4E1A\u52A1\u952E\u4E0B \u2014\u2014 \u5148\u4EBA\u5DE5\u786E\u8BA4/\u5904\u7406\u90A3\u4E00\u884C\u3002` : "\u{1F534} \u670D\u52A1\u7AEF\u5EFA\u4E86\u4EC0\u4E48\u3001id \u662F\u591A\u5C11\uFF0C\u8FD9\u6B21\u54CD\u5E94\u91CC\u6CA1\u7ED9 \u2014\u2014 \u53EA\u80FD\u53BB\u7CFB\u7EDF\u91CC\u627E\u3002") + "\u53F0\u8D26\u91CC\u8FD9\u4E00\u884C\u8BB0\u6210 **quarantined**\uFF1A\u672C\u5DE5\u5177**\u4E0D\u4F1A**\u81EA\u52A8\u91CD\u653E\u5B83\uFF08\u91CD\u653E\u4F1A\u518D\u9020\u4E00\u6761\u67E5\u4E0D\u56DE\u6765\u7684\u91CE\u884C\uFF09\u3002\u672C\u8F6E\u5230\u6B64\u4E2D\u6B62",
|
|
13915
|
+
row.row,
|
|
13916
|
+
row.key
|
|
13917
|
+
)
|
|
13918
|
+
);
|
|
13919
|
+
return [true, "business-key-not-round-tripped"];
|
|
13920
|
+
}
|
|
13921
|
+
function rejectedRow(plan, model, row, journal, tally, problems, out) {
|
|
13922
|
+
tally.add("writeFailed");
|
|
13923
|
+
journal.append({
|
|
13924
|
+
...priorEntry(journal, model, row.key),
|
|
13925
|
+
status: "failed",
|
|
13926
|
+
roundId: plan.roundId,
|
|
13927
|
+
error: { httpStatus: out.status, clientError: out.error, response: out.body }
|
|
13928
|
+
});
|
|
13929
|
+
problems.push(
|
|
13930
|
+
problem4(
|
|
13931
|
+
"CREATE_REJECTED",
|
|
13932
|
+
model,
|
|
13933
|
+
`\u7B2C ${row.row} \u884C\uFF08${row.key.join("+")}\uFF09\u88AB\u4EA7\u54C1\u62D2\u7EDD\uFF08HTTP ${out.status} / ${out.error}\uFF09 \u2014\u2014 \u539F\u59CB error \u4FE1\u5C01\u5DF2\u539F\u6837\u843D\u53F0\u8D26`,
|
|
13934
|
+
"\u{1F534} **\u672C\u5DE5\u5177\u4E0D\u89E3\u8BFB\u8FD9\u4E2A\u9519\u8BEF**\uFF1A\u5B9E\u6D4B\u4EA7\u54C1\u7528\u56DB\u79CD\u5F62\u6001\u4E0A\u62A5\u540C\u4E00\u7C7B\u4E8B\u4EF6\uFF0Cerror.code \u8DE8\u6A21\u578B\u7CCA\u6210\u540C\u4E00\u4E2A\u503C\u800C details \u91CC\u7684\u65B9\u62EC\u53F7 token \u8DE8\u6A21\u578B\u4E0D\u4E00\u81F4 \u2014\u2014 \u4E24\u5904\u90FD\u4E0D\u53EF\u673A\u8BFB\uFF0C\u8BFB\u51FA\u6765\u7684\u4EFB\u4F55\u7ED3\u8BBA\u90FD\u662F\u7F16\u7684\u3002\u82E5\u5B83\u8BF4\u7684\u662F\u300C\u5DF2\u5B58\u5728\u300D\uFF0C\u90A3\u610F\u5473\u7740**\u8DD1\u524D\u62CD\u7684\u65E2\u5B58\u7D22\u5F15\u4E0E\u73B0\u5B9E\u4E0D\u4E00\u81F4**\uFF08\u5FEB\u7167\u8FC7\u671F\uFF0C\u6216\u6709\u522B\u7684\u5199\u5165\u8005\uFF09\uFF1A\u91CD\u65B0\u8DD1\u4E00\u6B21 plan \u518D apply",
|
|
13935
|
+
row.row,
|
|
13936
|
+
row.key,
|
|
13937
|
+
errorEnvelope(out.body)
|
|
13938
|
+
)
|
|
13939
|
+
);
|
|
13940
|
+
return [true, null];
|
|
13941
|
+
}
|
|
13942
|
+
async function acceptRow(client, plan, model, row, journal, createdIds, tally, problems, serverId, keyFields, sample, verifiedAlready = false) {
|
|
13943
|
+
if (sample !== null && !verifiedAlready) {
|
|
13944
|
+
let verified;
|
|
13945
|
+
try {
|
|
13946
|
+
verified = await resolveUnknown(client, model, keyFields, row.key);
|
|
13947
|
+
} catch (raw) {
|
|
13948
|
+
if (!(raw instanceof JournalError)) throw raw;
|
|
13949
|
+
tally.add("readbacks");
|
|
13950
|
+
tally.add("unverified");
|
|
13951
|
+
problems.push(
|
|
13952
|
+
problem4(
|
|
13953
|
+
"SAMPLE_VERIFY_FAILED",
|
|
13954
|
+
model,
|
|
13955
|
+
`\u7B2C ${row.row} \u884C\uFF08${row.key.join("+")}\uFF09create \u56DE\u4E86 id=${serverId}\uFF0C\u4F46\u5C0F\u6837\u672C\u590D\u9A8C\u56DE\u8BFB**\u95EE\u4E0D\u51FA\u6765**\uFF1A[${raw.reason}] ${raw.message}`,
|
|
13956
|
+
`${raw.hint || ""} \u{1F534} \u53F0\u8D26\u91CC\u8FD9\u4E00\u884C**\u505C\u5728 unknown**\uFF08\u6CA1\u6709\u843D done\uFF09\uFF1A\u5C0F\u6837\u672C\u7684\u610F\u4E49\u5C31\u662F\u300C\u5148\u8BC1\u4E00\u904D\u518D\u5168\u91CF\u300D\uFF0C\u8FD9\u4E00\u6B65\u6CA1\u8BC1\u6210\u5C31\u4E0D\u8BB8\u5199\u300C\u786E\u8BA4\u5EFA\u6210\u4E86\u300D`,
|
|
13957
|
+
row.row,
|
|
13958
|
+
row.key
|
|
13959
|
+
)
|
|
13960
|
+
);
|
|
13961
|
+
return [true, "sample-verify-failed"];
|
|
13962
|
+
}
|
|
13963
|
+
tally.add("readbacks");
|
|
13964
|
+
if (verified.status !== "done" || verified.serverId !== serverId) {
|
|
13965
|
+
return quarantineRow(
|
|
13966
|
+
plan,
|
|
13967
|
+
model,
|
|
13968
|
+
row,
|
|
13969
|
+
journal,
|
|
13970
|
+
tally,
|
|
13971
|
+
problems,
|
|
13972
|
+
serverId,
|
|
13973
|
+
null,
|
|
13974
|
+
null,
|
|
13975
|
+
`create \u56DE\u4E86 id=${serverId}\uFF0C\u800C\u5C0F\u6837\u672C\u590D\u9A8C\u6309\u4E1A\u52A1\u952E\u56DE\u8BFB\u5F97\u5230\u7684\u662F ${verified.status}\uFF08id=${verified.serverId}\uFF09`
|
|
13976
|
+
);
|
|
13977
|
+
}
|
|
13978
|
+
}
|
|
13979
|
+
journal.append({
|
|
13980
|
+
...priorEntry(journal, model, row.key),
|
|
13981
|
+
status: "done",
|
|
13982
|
+
serverId,
|
|
13983
|
+
roundId: plan.roundId
|
|
13984
|
+
});
|
|
13985
|
+
createdIds.set(createdKey(model, row.key), serverId);
|
|
13986
|
+
tally.add("created");
|
|
13987
|
+
return [true, null];
|
|
13988
|
+
}
|
|
13989
|
+
async function judgeCreate(client, out, plan, modelPlan, row, journal, createdIds, tally, problems, sample) {
|
|
13990
|
+
const model = modelPlan.model;
|
|
13991
|
+
const keyFields = [...modelPlan.businessKeyFields];
|
|
13992
|
+
if (out.error !== "ok") {
|
|
13993
|
+
if (out.status >= 400 && out.status < 500) {
|
|
13994
|
+
return rejectedRow(plan, model, row, journal, tally, problems, out);
|
|
13995
|
+
}
|
|
13996
|
+
tally.add("unverified");
|
|
13997
|
+
problems.push(
|
|
13998
|
+
problem4(
|
|
13999
|
+
"CREATE_OUTCOME_UNKNOWN",
|
|
14000
|
+
model,
|
|
14001
|
+
`\u7B2C ${row.row} \u884C\uFF08${row.key.join("+")}\uFF09\u53D1\u51FA\u53BB\u4E86\uFF0C\u4F46**\u4E0D\u77E5\u9053\u670D\u52A1\u7AEF\u8BA4\u6CA1\u8BA4**\uFF08HTTP ${out.status} / ${out.error}\uFF09`,
|
|
14002
|
+
"\u8FD9\u6B63\u662F unknown \u90A3\u4E00\u6863\u7684\u5178\u578B\u6210\u56E0\uFF08\u670D\u52A1\u7AEF\u53EF\u80FD\u5DF2\u7ECF\u5EFA\u6210\u3001\u54CD\u5E94\u5728\u56DE\u7A0B\u4E22\u4E86\uFF09\u3002\u53F0\u8D26\u91CC\u8FD9\u4E00\u884C\u505C\u5728 unknown\uFF0C**\u4E0B\u4E00\u8F6E\u4F1A\u5148\u6309\u4E1A\u52A1\u952E\u56DE\u8BFB**\u518D\u51B3\u5B9A \u2014\u2014 \u522B\u624B\u5DE5\u628A\u5B83\u6539\u6210 failed\uFF0C\u90A3\u7B49\u4E8E\u6388\u6743\u4E00\u6B21\u76F2\u91CD\u53D1\u3002\u5148\u6309 error \u90A3\u4E00\u7EF4\u5904\u7F6E\uFF08network=\u901A\u9053 / server-error=\u770B\u670D\u52A1\u7AEF\uFF09",
|
|
14003
|
+
row.row,
|
|
14004
|
+
row.key
|
|
14005
|
+
)
|
|
14006
|
+
);
|
|
14007
|
+
return [true, "create-outcome-unknown"];
|
|
14008
|
+
}
|
|
14009
|
+
const body = out.body !== null && typeof out.body === "object" && !Array.isArray(out.body) ? out.body : {};
|
|
14010
|
+
const id = body["id"];
|
|
14011
|
+
const serverId = typeof id === "string" && id ? id : null;
|
|
14012
|
+
const echoed = keyFields.filter((f) => f in body).map((f) => norm(body[f]));
|
|
14013
|
+
if (echoed.length === keyFields.length && JSON.stringify(echoed) === JSON.stringify([...row.key]) && serverId) {
|
|
14014
|
+
return acceptRow(
|
|
14015
|
+
client,
|
|
14016
|
+
plan,
|
|
14017
|
+
model,
|
|
14018
|
+
row,
|
|
14019
|
+
journal,
|
|
14020
|
+
createdIds,
|
|
14021
|
+
tally,
|
|
14022
|
+
problems,
|
|
14023
|
+
serverId,
|
|
14024
|
+
keyFields,
|
|
14025
|
+
sample
|
|
14026
|
+
);
|
|
14027
|
+
}
|
|
14028
|
+
let result;
|
|
14029
|
+
try {
|
|
14030
|
+
result = await resolveUnknown(client, model, keyFields, row.key);
|
|
14031
|
+
} catch (raw) {
|
|
14032
|
+
if (!(raw instanceof JournalError)) throw raw;
|
|
14033
|
+
tally.add("readbacks");
|
|
14034
|
+
tally.add("unverified");
|
|
14035
|
+
problems.push(
|
|
14036
|
+
problem4(
|
|
14037
|
+
"READBACK_FAILED",
|
|
14038
|
+
model,
|
|
14039
|
+
`\u7B2C ${row.row} \u884C\uFF08${row.key.join("+")}\uFF09create \u56DE\u4E86 HTTP ${out.status}\uFF0C\u4F46\u56DE\u663E\u5BF9\u4E0D\u4E0A\u4E1A\u52A1\u952E\uFF08\u6216\u6CA1\u6709\u53EF\u7528 id\uFF09\uFF0C\u9000\u56DE\u6309\u4E1A\u52A1\u952E\u56DE\u8BFB\u53C8**\u95EE\u4E0D\u51FA\u6765**\uFF1A[${raw.reason}] ${raw.message}`,
|
|
14040
|
+
raw.hint || "\u53F0\u8D26\u91CC\u8FD9\u4E00\u884C\u505C\u5728 unknown\uFF08\u4E0D\u77E5\u9053\uFF09\uFF0C\u4E0B\u4E00\u8F6E\u8FD8\u4F1A\u5148\u56DE\u8BFB\u3002**\u4E0D\u8BB8**\u5F53\u6210\u300C\u6CA1\u5EFA\u6210\u300D\u53BB\u91CD\u5EFA",
|
|
14041
|
+
row.row,
|
|
14042
|
+
row.key
|
|
14043
|
+
)
|
|
14044
|
+
);
|
|
14045
|
+
return [true, "readback-failed"];
|
|
14046
|
+
}
|
|
14047
|
+
tally.add("readbacks");
|
|
14048
|
+
if (result.status === "done" && result.serverId) {
|
|
14049
|
+
return acceptRow(
|
|
14050
|
+
client,
|
|
14051
|
+
plan,
|
|
14052
|
+
model,
|
|
14053
|
+
row,
|
|
14054
|
+
journal,
|
|
14055
|
+
createdIds,
|
|
14056
|
+
tally,
|
|
14057
|
+
problems,
|
|
14058
|
+
result.serverId,
|
|
14059
|
+
keyFields,
|
|
14060
|
+
sample,
|
|
14061
|
+
true
|
|
14062
|
+
);
|
|
14063
|
+
}
|
|
14064
|
+
return quarantineRow(
|
|
14065
|
+
plan,
|
|
14066
|
+
model,
|
|
14067
|
+
row,
|
|
14068
|
+
journal,
|
|
14069
|
+
tally,
|
|
14070
|
+
problems,
|
|
14071
|
+
serverId,
|
|
14072
|
+
echoed.length === keyFields.length ? echoed : null,
|
|
14073
|
+
out.body,
|
|
14074
|
+
`create \u56DE\u4E86 HTTP ${out.status}\uFF0C\u518D\u6309\u4E1A\u52A1\u952E\u56DE\u8BFB**0 \u884C**`
|
|
14075
|
+
);
|
|
14076
|
+
}
|
|
14077
|
+
async function applyRow(client, plan, modelPlan, row, journal, createdIds, tally, problems, dryRun, budgetLeft, sample) {
|
|
14078
|
+
const model = modelPlan.model;
|
|
14079
|
+
const keyFields = [...modelPlan.businessKeyFields];
|
|
14080
|
+
if (row.action === "skip") {
|
|
14081
|
+
tally.add("skipped");
|
|
14082
|
+
if (!dryRun && journal.statusOf(model, row.key) === null) {
|
|
14083
|
+
journal.append({
|
|
14084
|
+
sourceRowId: row.row,
|
|
14085
|
+
model,
|
|
14086
|
+
businessKey: row.key,
|
|
14087
|
+
payloadHash: null,
|
|
14088
|
+
serverId: row.existingId,
|
|
14089
|
+
status: "skipped",
|
|
14090
|
+
attempts: 0,
|
|
14091
|
+
roundId: plan.roundId
|
|
14092
|
+
});
|
|
14093
|
+
}
|
|
14094
|
+
if (row.existingId) createdIds.set(createdKey(model, row.key), row.existingId);
|
|
14095
|
+
return [false, null];
|
|
14096
|
+
}
|
|
14097
|
+
const step = journal.nextStep(model, row.key);
|
|
14098
|
+
if (step === STEP_STOP) {
|
|
14099
|
+
tally.add("quarantined");
|
|
14100
|
+
const previous = journal.latest(model, row.key);
|
|
14101
|
+
problems.push(
|
|
14102
|
+
problem4(
|
|
14103
|
+
"ROW_QUARANTINED",
|
|
14104
|
+
model,
|
|
14105
|
+
`\u7B2C ${row.row} \u884C\uFF08${row.key.join("+")}\uFF09\u5728\u53F0\u8D26\u91CC\u662F quarantined \u2014\u2014 \u4E0A\u4E00\u8F6E\u670D\u52A1\u7AEF**\u63A5\u53D7**\u8FC7\u4E00\u6B21\u5199\uFF0C\u800C\u8FD9\u4E2A\u4E1A\u52A1\u952E**\u67E5\u4E0D\u56DE\u6765**` + (previous !== null && previous.serverId ? `\uFF08\u90A3\u6B21\u5199\u843D\u5728 id=${previous.serverId}\uFF09` : ""),
|
|
14106
|
+
"\u672C\u5DE5\u5177**\u4E0D\u4F1A**\u81EA\u52A8\u91CD\u653E\u5B83\uFF1A\u91CD\u653E\u4F1A\u518D\u9020\u4E00\u6761\u6309\u4E1A\u52A1\u952E\u67E5\u4E0D\u56DE\u6765\u7684\u91CE\u884C\u3002\u5148\u53BB\u7CFB\u7EDF\u91CC\u628A\u90A3\u4E00\u884C\u5904\u7406\u6389\uFF08\u5220\u6389\uFF0C\u6216\u628A\u5B83\u7684\u4E1A\u52A1\u952E\u6539\u6210\u5DE5\u4EF6\u91CC\u7684\u90A3\u4E2A\uFF09\uFF0C\u518D\u628A\u53F0\u8D26\u91CC\u8FD9\u4E00\u884C**\u6574\u884C\u5220\u6389**\u8BA9\u5B83\u6309\u300C\u6CA1\u8BB0\u8FC7\u300D\u91CD\u8DD1",
|
|
14107
|
+
row.row,
|
|
14108
|
+
row.key
|
|
14109
|
+
)
|
|
14110
|
+
);
|
|
14111
|
+
return [false, null];
|
|
14112
|
+
}
|
|
14113
|
+
if (step === STEP_NOTHING) {
|
|
14114
|
+
tally.add("already");
|
|
14115
|
+
const previous = journal.latest(model, row.key);
|
|
14116
|
+
if (previous !== null && previous.serverId) {
|
|
14117
|
+
createdIds.set(createdKey(model, row.key), previous.serverId);
|
|
14118
|
+
}
|
|
14119
|
+
return [false, null];
|
|
14120
|
+
}
|
|
14121
|
+
if (budgetLeft !== null && budgetLeft <= 0) {
|
|
14122
|
+
tally.add("notAttempted");
|
|
14123
|
+
return [false, null];
|
|
14124
|
+
}
|
|
14125
|
+
if (step === STEP_READBACK) {
|
|
14126
|
+
if (dryRun) {
|
|
14127
|
+
tally.add("wouldCreate");
|
|
14128
|
+
createdIds.set(createdKey(model, row.key), DRY_RUN_ID);
|
|
14129
|
+
return [false, null];
|
|
14130
|
+
}
|
|
14131
|
+
let result;
|
|
14132
|
+
try {
|
|
14133
|
+
result = await resolveUnknown(client, model, keyFields, row.key);
|
|
14134
|
+
} catch (raw) {
|
|
14135
|
+
if (!(raw instanceof JournalError)) throw raw;
|
|
14136
|
+
tally.add("readbacks");
|
|
14137
|
+
tally.add("unverified");
|
|
14138
|
+
problems.push(
|
|
14139
|
+
problem4(
|
|
14140
|
+
"READBACK_FAILED",
|
|
14141
|
+
model,
|
|
14142
|
+
`\u7B2C ${row.row} \u884C\uFF08${row.key.join("+")}\uFF09\u4E0A\u4E00\u8F6E\u505C\u5728 unknown\uFF0C\u8FD9\u4E00\u8F6E\u56DE\u8BFB**\u95EE\u4E0D\u51FA\u6765**\uFF1A[${raw.reason}] ${raw.message}`,
|
|
14143
|
+
raw.hint || "\u56DE\u8BFB\u95EE\u4E0D\u51FA\u6765\u65F6\u4E0D\u8BB8\u5F53\u6210\u300C\u6CA1\u5EFA\u6210\u300D\u53BB\u91CD\u5EFA \u2014\u2014 \u90A3\u6B63\u662F\u4EA7\u751F\u91CD\u590D\u884C\u7684\u90A3\u6761\u8DEF\u3002\u53F0\u8D26\u91CC\u8FD9\u4E00\u884C\u4ECD\u662F unknown\uFF0C\u4E0B\u4E00\u8F6E\u8FD8\u4F1A\u5148\u56DE\u8BFB",
|
|
14144
|
+
row.row,
|
|
14145
|
+
row.key
|
|
14146
|
+
)
|
|
14147
|
+
);
|
|
14148
|
+
return [true, "readback-failed"];
|
|
14149
|
+
}
|
|
14150
|
+
tally.add("readbacks");
|
|
14151
|
+
if (result.status === "done") {
|
|
14152
|
+
journal.append({
|
|
14153
|
+
...priorEntry(journal, model, row.key),
|
|
14154
|
+
status: "done",
|
|
14155
|
+
serverId: result.serverId,
|
|
14156
|
+
roundId: plan.roundId
|
|
14157
|
+
});
|
|
14158
|
+
tally.add("already");
|
|
14159
|
+
if (result.serverId) createdIds.set(createdKey(model, row.key), result.serverId);
|
|
14160
|
+
return [true, null];
|
|
14161
|
+
}
|
|
14162
|
+
}
|
|
14163
|
+
const [body, missing] = buildPayload(row, createdIds, journal);
|
|
14164
|
+
if (missing !== null) {
|
|
14165
|
+
tally.add("blocked");
|
|
14166
|
+
problems.push(
|
|
14167
|
+
problem4(
|
|
14168
|
+
"PARENT_NOT_WRITTEN",
|
|
14169
|
+
model,
|
|
14170
|
+
`\u7B2C ${row.row} \u884C\uFF08${row.key.join("+")}\uFF09\u7684 ${missing.field} \u8981\u62FF ${missing.model}.${missing.keyField} = ${JSON.stringify(missing.value)} \u6362 id\uFF0C\u800C\u90A3\u4E00\u884C\u8FD9\u4E00\u8F6E**\u6CA1\u6709\u5199\u6210** \u21D2 \u8FD9\u4E00\u884C\u4E0D\u53D1`,
|
|
14171
|
+
"\u5148\u770B\u90A3\u4E00\u884C**\u4E3A\u4EC0\u4E48\u6CA1\u7559\u4E0B id**\uFF0C\u4E24\u7C7B\uFF1A**\u7532 \xB7 \u6709\u7EC8\u6001\u4F46\u6CA1\u6709\u53EF\u7528 id** \u2014\u2014 \u53F0\u8D26\u8BF4\u5B83\u5EFA\u8FC7/\u8DF3\u8FC7\u3001\u6216\u56DE\u8BFB\u5224 done \u5374\u6CA1\u5E26 id\uFF08\u540E\u4E00\u652F\u4ECA\u5929\u5230\u4E0D\u4E86\uFF0C\u662F\u9632\u5FA1\u6027\u7684\uFF1B\u524D\u4E00\u652F\u662F**\u600E\u4E48\u6765\u7684\uFF0C\u672C\u6267\u884C\u5668\u6CA1\u6709\u67E5\u8FC7** \u2014\u2014 \u53F0\u8D26\u91CC\u90A3\u4E00\u884C\u539F\u6837\u5728\u76D8\u4E0A\uFF0C\u81EA\u5DF1\u770B\uFF09\uFF1B**\u4E59 \xB7 \u660E\u786E\u51FA\u4E8B** \u2014\u2014 \u4E0A\u9762\u90A3\u6761 `CREATE_REJECTED`\uFF08\u4EA7\u54C1\u62D2\u4E86\u5B83\uFF09\u6216 `ROW_QUARANTINED`\uFF08\u53F0\u8D26\u8BF4\u5B83\u4E0A\u4E00\u8F6E\u4E2D\u6BD2\u4E86\uFF09\u3002\u4E5F\u53EF\u80FD\u5B83\u81EA\u5DF1\u88AB\u4E0A\u6E38\u6321\u4F4F\uFF08\u7EA7\u8054\uFF09\u3002\u26A0\uFE0F \u8FD9\u53E5\u8BDD\u6539\u5230\u7B2C\u4E09\u7248\uFF1A\u524D\u4E24\u7248\u5206\u522B\u628A\u300C\u7532\u300D\u5199\u6210\u5931\u8D25\u3001\u628A\u540D\u989D\u95F8\u7B97\u6210\u4E00\u79CD\u53BB\u5904\uFF0C**\u90FD\u662F\u628A\u6CA1\u679A\u4E3E\u8FC7\u7684\u53D6\u503C\u57DF\u5199\u6210\u5168\u79F0\u53E5**\uFF0C\u6240\u4EE5\u8FD9\u4E00\u7248\u53EA\u5206\u7C7B\u3001\u4E0D\u6570\u6570\u3002\u7236\u884C\u843D\u5730\u4E4B\u540E\u91CD\u65B0\u8DD1\u4E00\u6B21 plan + apply\uFF0C\u8FD9\u4E00\u884C\u4F1A\u8DDF\u7740\u8865\u4E0A\uFF08\u53F0\u8D26\u8BB0\u5F97\u5B83\u6CA1\u5EFA\u8FC7\uFF09",
|
|
14172
|
+
row.row,
|
|
14173
|
+
row.key
|
|
14174
|
+
)
|
|
14175
|
+
);
|
|
14176
|
+
return [false, null];
|
|
14177
|
+
}
|
|
14178
|
+
assertBusinessKeySent(body, keyFields, row.key, model, row.row);
|
|
14179
|
+
if (dryRun) {
|
|
14180
|
+
tally.add("wouldCreate");
|
|
14181
|
+
createdIds.set(createdKey(model, row.key), DRY_RUN_ID);
|
|
14182
|
+
return [false, null];
|
|
14183
|
+
}
|
|
14184
|
+
journal.begin(row.row, model, row.key, payloadHash(body), plan.roundId);
|
|
14185
|
+
const out = await client.post(createPath(model), body);
|
|
14186
|
+
tally.add("requests");
|
|
14187
|
+
return judgeCreate(client, out, plan, modelPlan, row, journal, createdIds, tally, problems, sample);
|
|
14188
|
+
}
|
|
14189
|
+
async function applyPlan(client, plan, mapping, journal, options = {}) {
|
|
14190
|
+
const dryRun = options.dryRun ?? true;
|
|
14191
|
+
const sample = options.sample ?? null;
|
|
14192
|
+
const onRequestSpent = options.onRequestSpent ?? null;
|
|
14193
|
+
if (sample !== null && (typeof sample !== "number" || !Number.isInteger(sample) || sample < 1)) {
|
|
14194
|
+
throw new ApplyPremiseError(
|
|
14195
|
+
"bad-sample",
|
|
14196
|
+
`sample=${JSON.stringify(sample)} \u4E0D\u662F\u4E00\u4E2A \u22651 \u7684\u6574\u6570`,
|
|
14197
|
+
"sample \u7684\u8BED\u4E49\u662F\u300C\u5148\u8DD1 N \u884C\u770B\u770B\u300D\uFF1B\u4E0D\u60F3\u9650\u91CF\u5C31\u4F20 null\uFF08\u6216\u4E0D\u4F20\uFF09\uFF0C\u4F20 0 \u4F1A\u53D8\u6210\u4E00\u4E2A\u300C\u4EC0\u4E48\u90FD\u4E0D\u505A\u4F46\u770B\u7740\u50CF\u8DD1\u8FC7\u4E86\u300D\u7684\u4E00\u8F6E"
|
|
14198
|
+
);
|
|
14199
|
+
}
|
|
14200
|
+
if (typeof dryRun !== "boolean") {
|
|
14201
|
+
throw new ApplyPremiseError(
|
|
14202
|
+
"bad-dry-run",
|
|
14203
|
+
`dryRun=${JSON.stringify(dryRun)} \u4E0D\u662F\u5E03\u5C14`,
|
|
14204
|
+
"\u8FD9\u4E2A\u53C2\u6570\u51B3\u5B9A\u8FD9\u4E00\u8F6E\u4F1A\u4E0D\u4F1A\u771F\u7684\u5F80\u5BA2\u6237\u5E93\u91CC\u5199\uFF0C\u4E0D\u63A5\u53D7\u300C\u771F\u503C\u300D\u8FD9\u79CD\u6A21\u7CCA\u8BED\u4E49"
|
|
14205
|
+
);
|
|
14206
|
+
}
|
|
14207
|
+
if (onRequestSpent !== null && typeof onRequestSpent !== "function") {
|
|
14208
|
+
throw new ApplyPremiseError(
|
|
14209
|
+
"bad-on-request-spent",
|
|
14210
|
+
`onRequestSpent=${JSON.stringify(onRequestSpent)} \u4E0D\u662F\u53EF\u8C03\u7528\u5BF9\u8C61`,
|
|
14211
|
+
"\u5B83\u662F\u6BCF\u82B1\u6389\u4E00\u6B21\u8BF7\u6C42\u8981\u76D6\u7684\u90A3\u4E00\u6B21\u7AE0\uFF08\u751F\u4EA7\u4E0A = `Lease.heartbeatIfDue`\uFF09\u3002\u4E0D\u60F3\u76D6\u5C31\u4F20 null \u2014\u2014 \u4F20\u4E00\u4E2A\u8C03\u4E0D\u52A8\u7684\u4E1C\u897F\u4F1A\u5728\u7B2C\u4E00\u6B21\u8BF7\u6C42\u53D1\u51FA\u53BB\u4E4B\u540E\u70B8\u5728\u534A\u8DEF\u4E0A\uFF0C\u800C\u90A3\u4E00\u6B21\u8BF7\u6C42\u5DF2\u7ECF\u51FA\u53BB\u4E86"
|
|
14212
|
+
);
|
|
14213
|
+
}
|
|
14214
|
+
const problems = preflight(plan, mapping);
|
|
14215
|
+
if (problems.length > 0) {
|
|
14216
|
+
return reportOf(plan, dryRun, sample, false, "preflight", [], new Tally(), problems);
|
|
14217
|
+
}
|
|
14218
|
+
const createdIds = /* @__PURE__ */ new Map();
|
|
14219
|
+
const tally = new Tally();
|
|
14220
|
+
const perModel = [];
|
|
14221
|
+
let budget = sample;
|
|
14222
|
+
let aborted = null;
|
|
14223
|
+
for (const modelPlan of plan.models) {
|
|
14224
|
+
const local = new Tally();
|
|
14225
|
+
const rows = (modelPlan.waves ?? []).flatMap((w) => w.rows);
|
|
14226
|
+
for (const row of rows) {
|
|
14227
|
+
if (aborted !== null) {
|
|
14228
|
+
local.add("notAttempted");
|
|
14229
|
+
continue;
|
|
14230
|
+
}
|
|
14231
|
+
let spent;
|
|
14232
|
+
[spent, aborted] = await applyRow(
|
|
14233
|
+
client,
|
|
14234
|
+
plan,
|
|
14235
|
+
modelPlan,
|
|
14236
|
+
row,
|
|
14237
|
+
journal,
|
|
14238
|
+
createdIds,
|
|
14239
|
+
local,
|
|
14240
|
+
problems,
|
|
14241
|
+
dryRun,
|
|
14242
|
+
budget,
|
|
14243
|
+
sample
|
|
14244
|
+
);
|
|
14245
|
+
if (spent && budget !== null) budget -= 1;
|
|
14246
|
+
if (spent && aborted === null && onRequestSpent !== null) {
|
|
14247
|
+
aborted = stampProgress(onRequestSpent, modelPlan.model, row, problems);
|
|
14248
|
+
}
|
|
14249
|
+
}
|
|
14250
|
+
perModel.push({
|
|
14251
|
+
model: modelPlan.model,
|
|
14252
|
+
rows: rows.length,
|
|
14253
|
+
created: local.get("created"),
|
|
14254
|
+
skipped: local.get("skipped"),
|
|
14255
|
+
already: local.get("already"),
|
|
14256
|
+
writeFailed: local.get("writeFailed"),
|
|
14257
|
+
unverified: local.get("unverified"),
|
|
14258
|
+
blocked: local.get("blocked"),
|
|
14259
|
+
quarantined: local.get("quarantined"),
|
|
14260
|
+
notAttempted: local.get("notAttempted"),
|
|
14261
|
+
wouldCreate: local.get("wouldCreate"),
|
|
14262
|
+
requests: local.get("requests")
|
|
14263
|
+
});
|
|
14264
|
+
for (const name of TALLY_FIELDS) tally.add(name, local.get(name));
|
|
14265
|
+
}
|
|
14266
|
+
return reportOf(plan, dryRun, sample, true, aborted, perModel, tally, problems);
|
|
14267
|
+
}
|
|
14268
|
+
function applyReportToJson(report) {
|
|
14269
|
+
return {
|
|
14270
|
+
version: report.version,
|
|
14271
|
+
roundId: report.roundId,
|
|
14272
|
+
dryRun: report.dryRun,
|
|
14273
|
+
sample: report.sample,
|
|
14274
|
+
executed: report.executed,
|
|
14275
|
+
aborted: report.aborted,
|
|
14276
|
+
created: report.created,
|
|
14277
|
+
skipped: report.skipped,
|
|
14278
|
+
already: report.already,
|
|
14279
|
+
writeFailed: report.writeFailed,
|
|
14280
|
+
unverified: report.unverified,
|
|
14281
|
+
blocked: report.blocked,
|
|
14282
|
+
quarantined: report.quarantined,
|
|
14283
|
+
notAttempted: report.notAttempted,
|
|
14284
|
+
wouldCreate: report.wouldCreate,
|
|
14285
|
+
requests: report.requests,
|
|
14286
|
+
readbacks: report.readbacks,
|
|
14287
|
+
models: report.models.map((m) => ({ ...m })),
|
|
14288
|
+
problems: report.problems.map((p) => ({
|
|
14289
|
+
code: p.code,
|
|
14290
|
+
model: p.model,
|
|
14291
|
+
row: p.row,
|
|
14292
|
+
key: p.key === null ? null : [...p.key],
|
|
14293
|
+
message: p.message,
|
|
14294
|
+
hint: p.hint,
|
|
14295
|
+
// 🔴 `rawError` 恒在键集里(没有时是 `null`):让它时有时无,读者就得先判键在不在,
|
|
14296
|
+
// 而「这一条没有原始信封」与「这个版本还没有这个字段」会长成同一个样子。
|
|
14297
|
+
rawError: p.rawError ?? null
|
|
14298
|
+
}))
|
|
14299
|
+
};
|
|
14300
|
+
}
|
|
14301
|
+
function applyReportText(report) {
|
|
14302
|
+
return JSON.stringify(applyReportToJson(report), null, 2);
|
|
14303
|
+
}
|
|
14304
|
+
|
|
14305
|
+
// src/fde/seed/drift.ts
|
|
14306
|
+
import { existsSync as existsSync9, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync8 } from "fs";
|
|
14307
|
+
import * as path17 from "path";
|
|
14308
|
+
var VERDICT_SAME = "same";
|
|
14309
|
+
var VERDICT_DIVERGED = "diverged";
|
|
14310
|
+
var VERDICT_INCOMPARABLE = "incomparable";
|
|
14311
|
+
var VERDICTS = [VERDICT_SAME, VERDICT_DIVERGED, VERDICT_INCOMPARABLE];
|
|
14312
|
+
var INCOMPLETE_PREFIX = "incomplete:";
|
|
14313
|
+
var CAUSE_PLAN_HAS_NO_BASELINE = "plan-has-no-baseline";
|
|
14314
|
+
var CAUSE_BASELINE_NOT_ON_DISK = "baseline-not-on-disk";
|
|
14315
|
+
var CAUSE_FINGERPRINT_UNREADABLE = "fingerprint-unreadable";
|
|
14316
|
+
var CAUSE_INCOMPLETE_RECORDED = "incomplete-recorded";
|
|
14317
|
+
var CAUSE_INCOMPLETE_CURRENT = "incomplete-current";
|
|
14318
|
+
var INCOMPARABLE_CAUSES = [
|
|
14319
|
+
CAUSE_PLAN_HAS_NO_BASELINE,
|
|
14320
|
+
CAUSE_BASELINE_NOT_ON_DISK,
|
|
14321
|
+
CAUSE_FINGERPRINT_UNREADABLE,
|
|
14322
|
+
CAUSE_INCOMPLETE_RECORDED,
|
|
14323
|
+
CAUSE_INCOMPLETE_CURRENT
|
|
14324
|
+
];
|
|
14325
|
+
var FINGERPRINT_FILE = "fingerprint.json";
|
|
14326
|
+
var RECON_DIRNAME = "recon";
|
|
14327
|
+
var FORCE_STALE_FLAG = "--force-stale";
|
|
14328
|
+
var FORCE_STALE_COST = "\u8FD9\u4E00\u6279\u884C\u5C31\u662F\u5728\u300C\u5206\u4E0D\u6E05\u662F\u4E0D\u662F\u540C\u4E00\u4E2A\u73AF\u5883\u300D\u7684\u524D\u63D0\u4E0B\u5199\u51FA\u53BB\u7684\uFF0C\u53F0\u8D26\u91CC\u6709\u636E\u53EF\u67E5\uFF1B`apply` \u6CA1\u6709 `--rollback`\uFF0C\u5199\u51FA\u53BB\u7684\u884C\u7559\u5728\u5BA2\u6237\u5E93\u91CC\u3002";
|
|
14329
|
+
function resolveBaselineDir(outRoot, baselineRef) {
|
|
14330
|
+
if (baselineRef === null || baselineRef === void 0) {
|
|
14331
|
+
return [null, CAUSE_PLAN_HAS_NO_BASELINE];
|
|
14332
|
+
}
|
|
14333
|
+
const ref = String(baselineRef);
|
|
14334
|
+
const root = path17.join(outRoot, RECON_DIRNAME);
|
|
14335
|
+
const parts = ref.split(/[\\/]+/);
|
|
14336
|
+
if (!ref || parts.includes("..") || path17.isAbsolute(ref) || /^[A-Za-z]:/.test(ref)) {
|
|
14337
|
+
return [null, CAUSE_BASELINE_NOT_ON_DISK];
|
|
14338
|
+
}
|
|
14339
|
+
const base = path17.join(root, ref);
|
|
14340
|
+
let inside;
|
|
14341
|
+
try {
|
|
14342
|
+
const realRoot = realpathSync2(root);
|
|
14343
|
+
const realBase = realpathSync2(base);
|
|
14344
|
+
inside = realBase === realRoot || realBase.startsWith(realRoot + path17.sep);
|
|
14345
|
+
} catch {
|
|
14346
|
+
inside = false;
|
|
14347
|
+
}
|
|
14348
|
+
if (!inside || !existsSync9(base) || !statSync8(base).isDirectory()) {
|
|
14349
|
+
return [null, CAUSE_BASELINE_NOT_ON_DISK];
|
|
14350
|
+
}
|
|
14351
|
+
return [base, null];
|
|
14352
|
+
}
|
|
14353
|
+
function loadRecordedFingerprint(outRoot, baselineRef) {
|
|
14354
|
+
const [base, cause] = resolveBaselineDir(outRoot, baselineRef);
|
|
14355
|
+
if (cause !== null) return [null, cause];
|
|
14356
|
+
let body;
|
|
14357
|
+
try {
|
|
14358
|
+
body = JSON.parse(readFileSync8(path17.join(base, FINGERPRINT_FILE), "utf-8"));
|
|
14359
|
+
} catch {
|
|
14360
|
+
return [null, CAUSE_FINGERPRINT_UNREADABLE];
|
|
14361
|
+
}
|
|
14362
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) {
|
|
14363
|
+
return [null, CAUSE_FINGERPRINT_UNREADABLE];
|
|
14364
|
+
}
|
|
14365
|
+
return [body, null];
|
|
14366
|
+
}
|
|
14367
|
+
var SIDE_CAUSES = {
|
|
14368
|
+
recorded: CAUSE_INCOMPLETE_RECORDED,
|
|
14369
|
+
current: CAUSE_INCOMPLETE_CURRENT
|
|
14370
|
+
};
|
|
14371
|
+
var SIDE_WORDS = {
|
|
14372
|
+
recorded: "\u65E7\u6307\u7EB9\uFF08\u722C\u8FD9\u4EFD\u57FA\u7EBF\u90A3\u4E00\u8F6E\uFF09",
|
|
14373
|
+
current: "\u8FD9\u4E00\u6B21\u73B0\u7B97"
|
|
14374
|
+
};
|
|
14375
|
+
var MARKER_HINTS = {
|
|
14376
|
+
"X-HCM-Extension-Source": "\u6A21\u578B\u7B54\u5E94\u4E86\u3001\u4F46\u670D\u52A1\u7AEF\u6CA1\u56DE\u8FD9\u4E2A\u5934 \u21D2 \u67E5**\u53CD\u4EE3**\u662F\u4E0D\u662F\u628A `X-HCM-*` \u54CD\u5E94\u5934\u5265\u4E86",
|
|
14377
|
+
"no-meta-answered": "\u4E00\u4E2A\u6A21\u578B\u90FD\u6CA1\u7B54\u5E94 \u21D2 \u67E5**\u8FDE\u901A / \u6743\u9650 / \u6A21\u578B\u6E05\u5355\u662F\u4E0D\u662F\u7A7A\u7684**\uFF0C\u4E0E\u53CD\u4EE3\u65E0\u5173",
|
|
14378
|
+
"page-cap": "\u5206\u9875\u88AB\u5224\u4E3A\u5F02\u5E38\u5E76\u622A\u65AD \u21D2 \u67E5**\u7F51\u5173**\u628A `totalPages` \u62A5\u6210\u4E86\u4EC0\u4E48",
|
|
14379
|
+
"empty-model-list": "\u8BF7\u6C42\u6210\u529F\u4F46\u4E00\u4E2A\u53EF\u7528 `modelKey` \u90FD\u6CA1\u6709 \u21D2 \u67E5**\u6743\u9650 / \u7F51\u5173\u6539\u5199**\uFF08\u952E\u540D\u8BFB\u9519\u4E5F\u662F\u8FD9\u4E00\u6863\uFF09"
|
|
14380
|
+
};
|
|
14381
|
+
var NO_MARKER_HINT = "\u8FD9\u4E2A\u7AEF\u70B9\u6574\u4E2A\u6CA1\u53D6\u56DE\u6765 \u21D2 \u67E5**\u8FDE\u901A / \u6743\u9650 / \u7F51\u5173**";
|
|
14382
|
+
var NON_ENDPOINT_HINTS = {
|
|
14383
|
+
// 🔴 措辞必须**覆盖两种成因**:整节缺失**或**那一格被摘了,两种都发这条尾部,
|
|
14384
|
+
// 而 hint 是**一条常量**。写成「没有 coverageNotes 这一节」对第二种成因是**假的**
|
|
14385
|
+
//(那一节明明在),顾问打开文件看见它,会连带怀疑这条结论本身。
|
|
14386
|
+
"coverageNotes-missing": "\u8FD9\u4EFD\u6307\u7EB9\u53D6\u4E0D\u5230 `coverageNotes.fetchFailures`\uFF08\u6574\u8282\u7F3A\u5931\u3001\u6216\u90A3\u4E00\u683C\u88AB\u6458\u4E86\uFF09\u21D2 \u5B83\u662F\u65E7\u7248\u4EA7\u7684\u3001\u6216\u88AB\u624B\u6539\u8FC7 \u2014\u2014 \u300C\u6709\u6CA1\u6709\u53D6\u6570\u5931\u8D25\u300D\u5728\u5B83\u4E0A\u9762\u662F**\u672A\u77E5**\uFF0C\u4E0D\u662F\u300C\u5426\u300D\u21D2 \u91CD\u8DD1\u4E00\u6B21 `recon` \u6362\u4E00\u4EFD\u65B0\u7684\uFF08\u8981\u4FEE\u7684\u662F\u8FD9\u4EFD**\u6587\u4EF6**\uFF0C\u8FD9\u4E2A\u73AF\u5883\u672C\u8EAB\u6CA1\u6BDB\u75C5\uFF09"
|
|
14387
|
+
};
|
|
14388
|
+
var RERUN_PLAN_AFTER_RECON = "\u3002\u26A0\uFE0F **\u8FD9\u4E4B\u540E\u8FD8\u8981\u518D\u8DD1\u4E00\u6B21**\uFF1A`plan` \u2014\u2014 `recon` \u4F1A**\u5C31\u5730**\u8986\u5199\u8FD9\u4EFD\u57FA\u7EBF\u5E76\u76D6\u4E00\u4E2A\u65B0\u8F6E\u6B21\u6233\uFF0C\u800C\u8FD9\u4EFD\u8BA1\u5212\u7167\u7684\u662F\u65E7\u5185\u5BB9\uFF0C`apply` \u7684\u8F6E\u6B21\u524D\u63D0\u4F1A\u5F53\u573A\u628A\u5B83\u62E6\u4E0B\u3002";
|
|
14389
|
+
var CAUSE_NEXT_STEPS = {
|
|
14390
|
+
[CAUSE_PLAN_HAS_NO_BASELINE]: [
|
|
14391
|
+
"\u8FD9\u4EFD `import-plan.json` \u91CC\u6CA1\u6709 `baseline` \u6BB5 \u2014\u2014 \u5B83\u662F\u66F4\u65E9\u7248\u672C\u7B97\u51FA\u6765\u7684\u3002",
|
|
14392
|
+
"\u2192 \u91CD\u8DD1\u4E00\u6B21 `plan`\uFF08\u96F6\u5199\uFF1A`plan` \u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\uFF0C\u65B0\u8BA1\u5212\u4F1A\u5E26\u4E0A\u57FA\u7EBF\u51FA\u5904\u3002"
|
|
14393
|
+
],
|
|
14394
|
+
[CAUSE_BASELINE_NOT_ON_DISK]: [
|
|
14395
|
+
"\u8BA1\u5212\u70B9\u540D\u7684\u90A3\u4EFD\u57FA\u7EBF\u76EE\u5F55\u4E0D\u5728 `<out>/recon/` \u4E0B\uFF08\u542B `..` \u5206\u91CF\u3001\u6216\u843D\u5230 `recon/` \u4E4B\u5916\u7684\u5F15\u7528\uFF0C\u4E00\u5F8B\u6309**\u8D8A\u754C**\u62D2\u7EDD\uFF0C\u4E0D\u53BB\u8BFB\uFF09\u3002",
|
|
14396
|
+
"\u2192 \u628A\u90A3\u4EFD recon \u4EA7\u7269\u539F\u6837\u62F7\u56DE\u6765\uFF1B\u62F7\u4E0D\u56DE\u6765\u5C31\u91CD\u8DD1\u4E00\u6B21 `recon`" + RERUN_PLAN_AFTER_RECON
|
|
14397
|
+
],
|
|
14398
|
+
[CAUSE_FINGERPRINT_UNREADABLE]: [
|
|
14399
|
+
"\u57FA\u7EBF\u76EE\u5F55\u5728\uFF0C`fingerprint.json` \u4E0D\u5728 / \u8BFB\u4E0D\u51FA\u6765 / \u4E0D\u662F\u4E00\u4E2A JSON \u5BF9\u8C61\uFF08\u8FD9\u4EFD\u6587\u4EF6\u662F\u53EF\u5220\u7684\uFF0C\u6240\u4EE5\u8FD9\u4E00\u6863\u4F1A\u771F\u5B9E\u53D1\u751F\uFF0C\u4E0D\u662F\u8FB9\u89D2\uFF09\u3002",
|
|
14400
|
+
"\u2192 \u91CD\u8DD1\u4E00\u6B21 `recon`\uFF1A\u8FD9\u4EFD\u6587\u4EF6\u662F\u5B83\u6BCF\u8F6E\u6700\u540E\u5199\u7684\uFF0C\u91CD\u8DD1\u5C31\u6709" + RERUN_PLAN_AFTER_RECON
|
|
14401
|
+
],
|
|
14402
|
+
[CAUSE_INCOMPLETE_RECORDED]: [
|
|
14403
|
+
"\u65E7\u6307\u7EB9**\u81EA\u5DF1\u662F\u6B8B\u7684** \u2014\u2014 \u722C\u8FD9\u4EFD\u57FA\u7EBF\u7684\u90A3\u4E00\u8F6E\u5C31\u6CA1\u722C\u5168\uFF0C\u90A3\u51E0\u683C\u5728\u503C\u4E0A\u4E0E\u300C\u722C\u5230\u4E86\u800C\u4E14\u76F8\u7B49\u300D\u540C\u5F62\uFF0C\u4E0D\u80FD\u62FF\u6765\u5F53\u540C\u6E90\u7684\u8BC1\u636E\u3002",
|
|
14404
|
+
"\u2192 \u91CD\u8DD1\u4E00\u6B21 `recon`\uFF1A\u8981\u4FEE\u7684\u662F**\u57FA\u7EBF**\uFF0C\u4E0D\u662F\u8FD9\u4E2A\u73AF\u5883" + RERUN_PLAN_AFTER_RECON
|
|
14405
|
+
],
|
|
14406
|
+
[CAUSE_INCOMPLETE_CURRENT]: [
|
|
14407
|
+
"\u8FD9\u4E00\u6B21**\u7B97\u4E0D\u51FA\u6765** \u2014\u2014 \u95E8\u7AEF\u70B9\u5728\u8FD9\u4E2A\u73AF\u5883\u4E0A\u53D6\u4E0D\u5230\u3002",
|
|
14408
|
+
"\u2192 \u{1F534} \u91CD\u8DD1 `recon` **\u6CA1\u6709\u7528**\uFF08\u5B83\u6253\u7684\u662F\u540C\u4E00\u6279\u7AEF\u70B9\uFF09\u3002\u5148\u6309\u4E0B\u9762\u70B9\u540D\u7684\u7AEF\u70B9**\u4FEE\u73AF\u5883**\u3002"
|
|
14409
|
+
]
|
|
14410
|
+
};
|
|
14411
|
+
function splitIncomplete(item) {
|
|
14412
|
+
const rest = item.slice(INCOMPLETE_PREFIX.length);
|
|
14413
|
+
const at = rest.indexOf(":");
|
|
14414
|
+
return at === -1 ? [rest, ""] : [rest.slice(0, at), rest.slice(at + 1)];
|
|
14415
|
+
}
|
|
14416
|
+
function causesFromIncomplete(items) {
|
|
14417
|
+
const found = /* @__PURE__ */ new Set();
|
|
14418
|
+
for (const item of items) {
|
|
14419
|
+
const [side] = splitIncomplete(item);
|
|
14420
|
+
const cause = SIDE_CAUSES[side];
|
|
14421
|
+
if (cause === void 0) {
|
|
14422
|
+
throw new Error(
|
|
14423
|
+
`\u8BA4\u4E0D\u51FA\u7684 incomplete \u4FA7\u522B ${JSON.stringify(side)}\uFF08\u6761\u76EE ${JSON.stringify(item)}\uFF09\u3002compareFingerprint \u53EA\u4EA7\u51FA ${JSON.stringify(Object.keys(SIDE_CAUSES).sort())}\uFF1B\u591A\u51FA\u6765\u7684\u4E00\u4FA7\u6CA1\u6709\u5BF9\u5E94\u7684\u51FA\u8DEF\uFF0C\u4E0D\u8BB8\u731C\u4E00\u4E2A\u3002`
|
|
14424
|
+
);
|
|
14425
|
+
}
|
|
14426
|
+
found.add(cause);
|
|
14427
|
+
}
|
|
14428
|
+
return INCOMPARABLE_CAUSES.filter((c) => found.has(c));
|
|
14429
|
+
}
|
|
14430
|
+
function baselineWords(baseline) {
|
|
14431
|
+
return baseline ? `\u57FA\u7EBF \`${baseline}\`` : "\u57FA\u7EBF\uFF08\u8BA1\u5212\u91CC\u6CA1\u8BF4\u662F\u54EA\u4E00\u4EFD\uFF09";
|
|
14432
|
+
}
|
|
14433
|
+
function incompleteLines(items) {
|
|
14434
|
+
const lines = [];
|
|
14435
|
+
for (const item of [...items].sort()) {
|
|
14436
|
+
const [side, tail] = splitIncomplete(item);
|
|
14437
|
+
const who = SIDE_WORDS[side] ?? side;
|
|
14438
|
+
const nonEndpoint = NON_ENDPOINT_HINTS[tail];
|
|
14439
|
+
if (nonEndpoint !== void 0) {
|
|
14440
|
+
lines.push(` \xB7 ${who}\uFF1A\`${tail}\` \u2014\u2014 ${nonEndpoint}`);
|
|
14441
|
+
continue;
|
|
14442
|
+
}
|
|
14443
|
+
const at = tail.indexOf("#");
|
|
14444
|
+
const marker = at === -1 ? "" : tail.slice(at + 1);
|
|
14445
|
+
lines.push(` \xB7 ${who}\uFF1A\u7AEF\u70B9 \`${tail}\` \u2014\u2014 ${MARKER_HINTS[marker] ?? NO_MARKER_HINT}`);
|
|
14446
|
+
}
|
|
14447
|
+
return lines;
|
|
14448
|
+
}
|
|
14449
|
+
function forceStaleLines() {
|
|
14450
|
+
return [
|
|
14451
|
+
` \u2192 \u4FEE\u4E0D\u52A8\u3001\u53C8\u5FC5\u987B\u4ECA\u5929\u5C31\u5199\uFF1A\`${FORCE_STALE_FLAG}\` \u653E\u884C\u3002**\u8FD9\u4E0D\u662F\u300C\u52A0\u4E2A\u53C2\u6570\u5C31\u597D\u4E86\u300D** \u2014\u2014 ${FORCE_STALE_COST}`
|
|
14452
|
+
];
|
|
14453
|
+
}
|
|
14454
|
+
function driftMessage(verdict, gateDiffs, incomplete, advisory, causes, baseline) {
|
|
14455
|
+
const lines = [];
|
|
14456
|
+
if (verdict === VERDICT_SAME) {
|
|
14457
|
+
lines.push(
|
|
14458
|
+
`\u2705 \u540C\u6E90\uFF1A${baselineWords(baseline)} \u4E0E\u773C\u524D\u8FD9\u4E2A\u73AF\u5883\u7684\u4E09\u4E2A\u95E8\u5206\u91CF\uFF08${GATE_COMPONENTS.join(" / ")}\uFF09\u9010\u4E2A\u76F8\u7B49\u3002`
|
|
14459
|
+
);
|
|
14460
|
+
lines.push(" \u2192 \u53EF\u4EE5\u63A5\u7740\u8DD1 `apply --execute`\u3002");
|
|
14461
|
+
} else if (verdict === VERDICT_DIVERGED) {
|
|
14462
|
+
lines.push(`\u{1F534} \u4E0D\u540C\u6E90\uFF1A${baselineWords(baseline)} **\u4E0D\u662F**\u773C\u524D\u8FD9\u4E2A\u73AF\u5883\u7684\u3002`);
|
|
14463
|
+
lines.push(
|
|
14464
|
+
` \u4E0D\u76F8\u7B49\u7684\u95E8\u5206\u91CF\uFF08${gateDiffs.length} \u683C\uFF09\uFF1A${gateDiffs.map((d) => `\`${d}\``).join("\u3001")}`
|
|
14465
|
+
);
|
|
14466
|
+
if (incomplete.length > 0) {
|
|
14467
|
+
lines.push(` \u53E6\u6709 ${incomplete.length} \u683C**\u6CA1\u67E5\u6210**\uFF08\u4E0D\u5F71\u54CD\u4E0A\u9762\u90A3\u4E2A\u7ED3\u8BBA\uFF0C\u4F46\u4E00\u5E76\u62A5\u51FA\u6765\uFF09\uFF1A`);
|
|
14468
|
+
lines.push(...incompleteLines(incomplete));
|
|
14469
|
+
}
|
|
14470
|
+
lines.push(
|
|
14471
|
+
" \u2192 \u91CD\u8DD1\u4E00\u6B21 `recon`\uFF0C\u518D\u91CD\u8DD1\u4E00\u6B21 `plan` \u2014\u2014 \u7528**\u8FD9\u4E2A\u73AF\u5883**\u7684\u57FA\u7EBF\u91CD\u65B0\u7B97\u8FD9\u4E00\u6279\u5199\u3002\u5DE5\u4EF6\u4E00\u884C\u90FD\u4E0D\u7528\u6539\u3002"
|
|
14472
|
+
);
|
|
14473
|
+
lines.push(...forceStaleLines());
|
|
14474
|
+
} else {
|
|
14475
|
+
lines.push(
|
|
14476
|
+
`\u{1F534} \u6BD4\u4E0D\u4E86\uFF1A${baselineWords(baseline)} \u4E0E\u773C\u524D\u8FD9\u4E2A\u73AF\u5883\u662F\u4E0D\u662F\u540C\u4E00\u4E2A\uFF0C**\u5206\u4E0D\u6E05** \u2014\u2014 **\u8FD9\u4E0D\u662F\u300C\u6BD4\u8FC7\u4E86\u3001\u4E00\u6837\u300D**\u3002`
|
|
14477
|
+
);
|
|
14478
|
+
for (const cause of causes) {
|
|
14479
|
+
const [why, how] = CAUSE_NEXT_STEPS[cause];
|
|
14480
|
+
lines.push(` \xB7 [${cause}] ${why}`);
|
|
14481
|
+
lines.push(` ${how}`);
|
|
14482
|
+
if (cause === CAUSE_INCOMPLETE_RECORDED || cause === CAUSE_INCOMPLETE_CURRENT) {
|
|
14483
|
+
const side = cause === CAUSE_INCOMPLETE_RECORDED ? "recorded" : "current";
|
|
14484
|
+
lines.push(...incompleteLines(incomplete.filter((i) => splitIncomplete(i)[0] === side)));
|
|
14485
|
+
}
|
|
14486
|
+
}
|
|
14487
|
+
lines.push(...forceStaleLines());
|
|
14488
|
+
}
|
|
14489
|
+
if (advisory.length > 0) {
|
|
14490
|
+
lines.push(
|
|
14491
|
+
" \u24D8 \u53E6\u6709\u975E\u95E8\u4E0A\u62A5\u9879\uFF08**\u4E0D\u6539\u4E0A\u9762\u90A3\u4E2A\u7ED3\u8BBA**\uFF0C\u53EA\u662F\u4E24\u4EFD\u4EA7\u7269\u7684\u722C\u6CD5\u4E0D\u540C\uFF09\uFF1A" + advisory.map((a) => `\`${a}\``).join("\u3001")
|
|
12510
14492
|
);
|
|
12511
14493
|
}
|
|
12512
|
-
|
|
12513
|
-
|
|
12514
|
-
|
|
12515
|
-
|
|
12516
|
-
|
|
12517
|
-
|
|
14494
|
+
return lines.join("\n");
|
|
14495
|
+
}
|
|
14496
|
+
function judgeDrift(recorded, current, options = {}) {
|
|
14497
|
+
const baseline = options.baseline ?? null;
|
|
14498
|
+
const loadCause = options.loadCause ?? null;
|
|
14499
|
+
if (loadCause !== null) {
|
|
14500
|
+
if (!INCOMPARABLE_CAUSES.includes(loadCause)) {
|
|
14501
|
+
throw new Error(
|
|
14502
|
+
`\u8BA4\u4E0D\u51FA\u7684\u88C5\u8F7D\u6210\u56E0 ${JSON.stringify(loadCause)}\uFF1B\u53D6\u503C\u57DF\u662F ${JSON.stringify([...INCOMPARABLE_CAUSES])}\u3002`
|
|
14503
|
+
);
|
|
14504
|
+
}
|
|
14505
|
+
const causes2 = [loadCause];
|
|
14506
|
+
return {
|
|
14507
|
+
verdict: VERDICT_INCOMPARABLE,
|
|
14508
|
+
gateDiffs: [],
|
|
14509
|
+
incomplete: [],
|
|
14510
|
+
advisory: [],
|
|
14511
|
+
causes: causes2,
|
|
14512
|
+
baseline,
|
|
14513
|
+
message: driftMessage(VERDICT_INCOMPARABLE, [], [], [], causes2, baseline)
|
|
14514
|
+
};
|
|
12518
14515
|
}
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
"\u5199\u51FA\u8FD9\u4E2A\u7248\u672C\u53F7\u7684\u662F\u54EA\u4E00\u7248 kit\u3001\u8FD9\u4EFD\u4EA7\u7269\u4ECE\u54EA\u6765\uFF0C\u672C\u6A21\u5757**\u6CA1\u6709\u67E5\u8FC7**\u3002\u{1F534} \u522B\u6539\u8FD9\u4E2A\u6570\u5B57\u9A97\u8FC7\u95F8\u95E8\uFF1A\u5F62\u72B6\u8BFB\u5F97\u56DE\u6765\u4E0D\u7B49\u4E8E\u8BED\u4E49\u76F8\u540C\u3002\u7528\u5199\u51FA\u5B83\u7684\u90A3\u4E00\u7248 kit\uFF0C\u6216\u5728\u672C\u673A\u91CD\u65B0\u8DD1\u4E00\u6B21 `plan`"
|
|
14516
|
+
const ok = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
14517
|
+
if (!ok(recorded) || !ok(current)) {
|
|
14518
|
+
throw new Error(
|
|
14519
|
+
`judgeDrift \u62FF\u5230\u4E86\u975E\u6307\u7EB9\u8F93\u5165\uFF08recorded=${recorded === null ? "null" : typeof recorded}, current=${current === null ? "null" : typeof current}\uFF09\u3002\u88C5\u8F7D\u5931\u8D25\u5FC5\u987B\u8D70 \`loadCause\`\uFF08\u89C1 loadRecordedFingerprint \u7684\u8FD4\u56DE\u5951\u7EA6\uFF09\uFF0C\u4E0D\u8BB8\u628A null \u76F4\u63A5\u9012\u8FDB\u6765\u3002`
|
|
12524
14520
|
);
|
|
12525
14521
|
}
|
|
14522
|
+
const diffs = compareFingerprint(recorded, current);
|
|
14523
|
+
const gateDiffs = diffs.filter((d) => GATE_COMPONENTS.includes(d));
|
|
14524
|
+
const incomplete = diffs.filter((d) => d.startsWith(INCOMPLETE_PREFIX));
|
|
14525
|
+
const advisory = diffs.filter((d) => !gateDiffs.includes(d) && !incomplete.includes(d));
|
|
14526
|
+
let verdict;
|
|
14527
|
+
let causes;
|
|
14528
|
+
if (gateDiffs.length > 0) {
|
|
14529
|
+
verdict = VERDICT_DIVERGED;
|
|
14530
|
+
causes = [];
|
|
14531
|
+
} else if (incomplete.length > 0) {
|
|
14532
|
+
verdict = VERDICT_INCOMPARABLE;
|
|
14533
|
+
causes = causesFromIncomplete(incomplete);
|
|
14534
|
+
} else {
|
|
14535
|
+
verdict = VERDICT_SAME;
|
|
14536
|
+
causes = [];
|
|
14537
|
+
}
|
|
14538
|
+
return {
|
|
14539
|
+
verdict,
|
|
14540
|
+
gateDiffs,
|
|
14541
|
+
incomplete,
|
|
14542
|
+
advisory,
|
|
14543
|
+
causes,
|
|
14544
|
+
baseline,
|
|
14545
|
+
message: driftMessage(verdict, gateDiffs, incomplete, advisory, causes, baseline)
|
|
14546
|
+
};
|
|
14547
|
+
}
|
|
14548
|
+
var DRY_RUN_NOTE = "\u26A0\uFE0F \u4E0B\u9762\u8FD9\u6BB5\u5224\u65AD**\u6CA1\u6709\u62E6\u8FD9\u4E00\u8F6E** \u2014\u2014 \u8FD9\u662F\u5E72\u8DD1\uFF0C\u4E00\u53D1\u5199\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF0C\u6CA1\u6709\u53EF\u62E6\u7684\u4E1C\u897F\u3002\u540C\u4E00\u6BB5\u5224\u65AD\u5728 `--execute` \u90A3\u4E00\u8F6E\u662F\u786C\u505C\u3002\n{message}";
|
|
14549
|
+
var WAIVER_NOTE = "\u26A0\uFE0F `{flag}` \u653E\u884C\u4E86\u8FD9\u4E00\u8F6E\uFF0C\u5E76\u8BB0\u8FDB\u4E86\u53F0\u8D26\uFF08`{file}` \u91CC\u591A\u4E86\u4E00\u7B14 `{kind}`\uFF09\u3002{cost}\n{message}";
|
|
14550
|
+
var FORCE_STALE_UNUSED = "\u24D8 \u672C\u8F6E\u6CA1\u6709\u6F02\u79FB\uFF0C`{flag}` \u6CA1\u6709\u7528\u4E0A \u2014\u2014 \u95F8\u672C\u6765\u5C31\u662F\u653E\u884C\u7684\uFF0C\u53F0\u8D26\u91CC\u4E5F\u4E0D\u8BB0\u8FD9\u4E00\u7B14\uFF08\u6CA1\u6709\u653E\u884C\u53D1\u751F\uFF09\u3002";
|
|
14551
|
+
var WAIVER_REPLAY = "\u26A0\uFE0F \u8FD9\u4E2A work \u76EE\u5F55\u91CC\u5DF2\u6709 `{flag}` \u653E\u884C\u8BB0\u5F55\uFF1A{detail}";
|
|
14552
|
+
var DriftDetected = class extends Error {
|
|
14553
|
+
verdict;
|
|
14554
|
+
constructor(verdict) {
|
|
14555
|
+
super(verdict.message);
|
|
14556
|
+
this.name = "DriftDetected";
|
|
14557
|
+
this.verdict = verdict;
|
|
14558
|
+
}
|
|
14559
|
+
};
|
|
14560
|
+
function describeWaiver(waiver) {
|
|
14561
|
+
const where = waiver.baseline ? `\u57FA\u7EBF \`${waiver.baseline}\`` : "\u57FA\u7EBF\uFF08\u90A3\u4E00\u8F6E\u7684\u8BA1\u5212\u91CC\u6CA1\u8BF4\u662F\u54EA\u4E00\u4EFD\uFF09";
|
|
14562
|
+
let tail = "";
|
|
14563
|
+
if (waiver.causes.length > 0) {
|
|
14564
|
+
tail = `\uFF08\u6210\u56E0 ${waiver.causes.map((c) => `\`${c}\``).join("\u3001")}\uFF09`;
|
|
14565
|
+
} else if (waiver.gateDiffs.length > 0) {
|
|
14566
|
+
tail = `\uFF08\u4E0D\u76F8\u7B49\u7684\u95E8\u5206\u91CF ${waiver.gateDiffs.map((d) => `\`${d}\``).join("\u3001")}\uFF09`;
|
|
14567
|
+
}
|
|
14568
|
+
return `${waiver.at} \u90A3\u4E00\u8F6E roundId \`${waiver.roundId}\` \u5224\u4E3A \`${waiver.verdict}\`${tail}\uFF0C${where} \u2014\u2014 \u90A3\u4E00\u8F6E\u5199\u51FA\u53BB\u7684\u884C\uFF0C\u5C31\u662F\u5E26\u7740\u8FD9\u4E2A\u524D\u63D0\u5199\u7684\u3002`;
|
|
14569
|
+
}
|
|
14570
|
+
function enforceDriftGate(verdict, options) {
|
|
14571
|
+
const { journal, roundId, forced, dryRun } = options;
|
|
14572
|
+
if (verdict.verdict === VERDICT_SAME) {
|
|
14573
|
+
return forced ? FORCE_STALE_UNUSED.replace("{flag}", FORCE_STALE_FLAG) : null;
|
|
14574
|
+
}
|
|
14575
|
+
if (dryRun) return DRY_RUN_NOTE.replace("{message}", verdict.message);
|
|
14576
|
+
if (!forced) throw new DriftDetected(verdict);
|
|
14577
|
+
journal.appendWaiver({
|
|
14578
|
+
roundId,
|
|
14579
|
+
at: nowStamp(),
|
|
14580
|
+
verdict: verdict.verdict,
|
|
14581
|
+
causes: [...verdict.causes],
|
|
14582
|
+
gateDiffs: [...verdict.gateDiffs],
|
|
14583
|
+
incomplete: [...verdict.incomplete],
|
|
14584
|
+
advisory: [...verdict.advisory],
|
|
14585
|
+
baseline: verdict.baseline
|
|
14586
|
+
});
|
|
14587
|
+
return WAIVER_NOTE.replace("{flag}", FORCE_STALE_FLAG).replace("{file}", JOURNAL_FILE).replace("{kind}", KIND_DRIFT_WAIVER).replace("{cost}", FORCE_STALE_COST).replace("{message}", verdict.message);
|
|
14588
|
+
}
|
|
14589
|
+
|
|
14590
|
+
// src/fde/verify/run.ts
|
|
14591
|
+
var STATUS_UNKNOWN = "unknown";
|
|
14592
|
+
var PREMISE_JOURNAL_ON_DISK = "journal-on-disk";
|
|
14593
|
+
var PREMISE_JOURNAL_HAS_ENTRIES = "journal-has-entries";
|
|
14594
|
+
var PREMISE_PLAN_READABLE = "plan-readable";
|
|
14595
|
+
var PREMISE_CODES4 = [
|
|
14596
|
+
PREMISE_JOURNAL_ON_DISK,
|
|
14597
|
+
PREMISE_JOURNAL_HAS_ENTRIES,
|
|
14598
|
+
PREMISE_PLAN_READABLE
|
|
14599
|
+
];
|
|
14600
|
+
var PREMISE_UNMET = "\u524D\u63D0\u672A\u6210\u7ACB";
|
|
14601
|
+
var WHY_NO_JOURNAL = "\u8FD9\u4E2A work \u76EE\u5F55\u4E0B\u6CA1\u6709\u53F0\u8D26\u6587\u4EF6 \u2014\u2014 \u672C\u5DE5\u5177\u5728**\u8FD9\u4E2A\u76EE\u5F55**\u4E0A\u4E00\u8F6E\u90FD\u6CA1\u843D\u8FC7\u8D26\u3002\u26A0\uFE0F\u300Cwork \u76EE\u5F55\u6307\u9519\u4E86\u300D\u4E0E\u300C\u7B2C\u4E00\u8F6E\u5929\u7136\u6CA1\u6709\u53F0\u8D26\u300D\u5728\u5BA2\u6237\u7AEF\u5206\u4E0D\u51FA\u6765\uFF0C\u6240\u4EE5\u300C0 \u884C\u300D\u5728\u8FD9\u91CC\u4E0D\u662F\u4E00\u53E5\u4E1A\u52A1\u7ED3\u8BBA\u3002";
|
|
14602
|
+
var WHY_NO_ENTRIES = {
|
|
14603
|
+
true: "\u53F0\u8D26\u6587\u4EF6\u5728\uFF0C\u91CC\u9762\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709\u3002\u843D\u8FC7\u8D26\u7684\u4E00\u8F6E\u81F3\u5C11\u7559\u5F97\u4E0B\u4E00\u6761\u5199\u524D\u843D\u8D26\u7684\u8BB0\u5F55\uFF0C\u6240\u4EE5\u300C\u6587\u4EF6\u5728\u3001\u96F6\u884C\u300D\u8FD9\u4E00\u6863\u8981\u4EBA\u53BB\u770B\u4E00\u773C\u90A3\u4EFD\u6587\u4EF6\u672C\u8EAB\u3002",
|
|
14604
|
+
false: "\u53F0\u8D26\u6587\u4EF6\u6839\u672C\u4E0D\u5728\uFF0C\u6240\u4EE5**\u65E0\u4ECE\u8C08\u884C\u6570** \u2014\u2014 \u8FD9\u4E00\u6863\u4E0D\u662F\u300C\u8DD1\u8FC7\u3001\u96F6\u884C\u300D\u3002\u26A0\uFE0F \u522B\u628A\u5B83\u8BFB\u6210\u300C\u4EC0\u4E48\u90FD\u6CA1\u52A8\u300D\uFF1A\u4E0A\u9762\u90A3\u6761\u524D\u63D0\u5DF2\u7ECF\u8BF4\u4E86\uFF0C\u300Cwork \u76EE\u5F55\u6307\u9519\u4E86\u300D\u5728\u5BA2\u6237\u7AEF\u4E0E\u300C\u7B2C\u4E00\u8F6E\u5929\u7136\u6CA1\u6709\u53F0\u8D26\u300D\u5206\u4E0D\u51FA\u6765\u3002"
|
|
14605
|
+
};
|
|
14606
|
+
var WHY_PLAN_UNREADABLE = "\u8BFB\u4E0D\u56DE\u76D8\u4E0A\u90A3\u4EFD\u8BA1\u5212 \u21D2\u300C\u8BA1\u5212\u91CC\u6709\u3001\u53F0\u8D26\u91CC\u6CA1\u6709\u300D\u8FD9\u4E00\u683C**\u6CA1\u6709\u7B54\u6848**\u3002\u{1F534} \u8BA1\u5212\u4E0D\u5728\u7684\u65F6\u5019\u5DEE\u96C6\u7B97\u51FA\u6765\u662F\u7A7A\u96C6\uFF0C\u4E0E\u300C\u4E00\u4EF6\u6CA1\u843D\u4E0B\u300D\u9010\u5B57\u540C\u5F62 \u2014\u2014 \u6240\u4EE5\u8FD9\u4E00\u683C\u7ED9\u7684\u662F\u524D\u63D0\uFF0C\u800C\u4E0D\u662F\u4E00\u4E2A\u7A7A\u5DEE\u96C6\u3002";
|
|
14607
|
+
var ROUND_SPAN = " \u2026 ";
|
|
14608
|
+
var NOT_COVERED = [
|
|
14609
|
+
"\u300C\u8BA1\u5212\u91CC\u6709\u3001\u53F0\u8D26\u91CC\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709\u300D\u8FD9\u4E00\u683C\u53EA\u8BF4\u8FD9\u4E9B\u884C**\u6CA1\u52A8\u6210**\uFF0C**\u672A\u8BB0\u5F55\u539F\u56E0**\uFF1A\u88AB\u7236\u884C\u6321\u4F4F\uFF08blocked\uFF09\u3001\u6574\u8F6E\u4E2D\u6B62\u4E4B\u540E\u6CA1\u8F6E\u5230\uFF08notAttempted\uFF09\u3001dry-run \u53EA\u7B97\u4E0D\u5199\uFF08wouldCreate\uFF09\u2014\u2014 \u8FD9\u4E09\u6863\u5728\u53F0\u8D26\u91CC\u4E00\u6761\u8BB0\u5F55\u90FD\u4E0D\u7559\uFF0C\u800C apply \u7684\u62A5\u544A\u5168\u6811\u552F\u4E00\u53BB\u5904\u662F\u6253\u5370\u5230\u5C4F\u5E55\u3001\u4ECE\u4E0D\u843D\u76D8 \u21D2 \u76D8\u4E0A\u95EE\u4E0D\u51FA\u539F\u56E0\u3002",
|
|
14610
|
+
"\u5DEE\u96C6\u7684\u5DE6\u8FB9\u662F**\u76D8\u4E0A\u6B64\u523B\u90A3\u4EFD import-plan.json**\uFF1A\u987E\u95EE\u4E2D\u9014\u91CD\u8DD1\u8FC7 plan \u7684\u8BDD\uFF0C\u76D8\u4E0A\u662F\u65B0\u8BA1\u5212\u3001\u53F0\u8D26\u91CC\u5374\u662F\u4E0A\u4E00\u4EFD\u8BA1\u5212\u90A3\u4E00\u8F6E\u5199\u4E0B\u7684\u884C \u2014\u2014\u300C\u8FD9\u4EFD\u8BA1\u5212\u4E0E\u8FD9\u4EFD\u53F0\u8D26\u662F\u540C\u4E00\u4EFD\u5417\u300D\u672C\u805A\u5408\u5668\u5224\u4E0D\u51FA\u6765\u3002",
|
|
14611
|
+
"`byStatus` \u91CC\u7684 quarantined \u662F**\u53F0\u8D26\u53E3\u5F84 \xB7 \u5386\u8F6E\u7D2F\u8BA1**\uFF08`Entry.status`\uFF09\uFF0C**\u4E0D\u8BF4**\u300C\u8FD9\u4E00\u8F6E\u54EA\u4E9B\u884C\u4E2D\u6BD2\u4E86\u300D\uFF1A\u672C\u8F6E\u53E3\u5F84\u90A3\u4E00\u4EFD\u4F4F\u5728 apply \u62A5\u544A\u7684 quarantined \u6863\u91CC\uFF0C\u800C\u90A3\u4EFD\u62A5\u544A\u4ECE\u4E0D\u843D\u76D8\uFF0C\u672C\u805A\u5408\u5668\u591F\u4E0D\u5230\u5B83\u3002",
|
|
14612
|
+
"\u8BA1\u5212\u90A3\u4E00\u4FA7\u53EA\u679A\u4E3E\u5F97\u5230**\u8FDB\u5F97\u4E86\u6CE2\u6B21**\u7684\u884C\uFF1A`ModelPlan.rowsNotInWaves` \u53EA\u6709\u8BA1\u6570\u3001\u6CA1\u6709\u884C\uFF1B`planned=false` \u7684\u6A21\u578B waves \u662F null \u21D2 \u5B83\u4E00\u884C\u90FD\u4E0D\u8FDB\u5DEE\u96C6\u7684\u5DE6\u8FB9\u3002",
|
|
14613
|
+
// ⚠️ 病史留在**注释**里,不进产物散文:这一格曾写成「这份基线里**唯一**的时间信息是
|
|
14614
|
+
// 计划轮次 id 的前半截」,被**同一个返回对象**上的 `waivers[].at`(完整 ISO-8601)
|
|
14615
|
+
// 当场证伪 —— 又一次「把没枚举全的取值域写成全称句」。产物是给 FDE 签字看的证据,
|
|
14616
|
+
// 不是变更日志;病史写进去还会把自己的判据顶红(那条用例禁「唯一」二字)。
|
|
14617
|
+
"\u53F0\u8D26\u884C**\u6CA1\u6709\u65F6\u95F4\u6233**\uFF08`ENTRY_KEYS` \u91CC\u4E00\u4E2A\u65F6\u95F4\u5B57\u6BB5\u90FD\u6CA1\u6709\uFF09\uFF1A**\u884C\u8FD9\u4E00\u4FA7**\u80FD\u62FF\u5230\u7684\u65F6\u95F4\u53EA\u6709\u8BA1\u5212\u8F6E\u6B21 id \u7684\u524D\u534A\u622A\uFF0C\u79D2\u7CBE\u5EA6\u3002\u26A0\uFE0F \u8BF4\u51C6\u4E00\u683C\uFF1A\u8FD9\u4EFD\u57FA\u7EBF\u91CC**\u4E0D\u662F\u6CA1\u6709\u522B\u7684\u65F6\u95F4** \u2014\u2014 waiver \u90A3\u4E00\u4FA7\u5E26\u5B8C\u6574 ISO-8601 \u7684 at\uFF08`WAIVER_KEYS` \u91CC\u6709\u5B83\uFF09\uFF0C\u5B83\u8BF4\u7684\u662F\u300C\u54EA\u4E00\u8F6E\u5728\u4EC0\u4E48\u524D\u63D0\u4E0B\u8DD1\u7684\u300D\uFF0C**\u4E0D\u843D\u5230\u4EFB\u4F55\u4E00\u884C\u5934\u4E0A**\u3002"
|
|
14618
|
+
];
|
|
14619
|
+
function premise(code, ok, why, hint = "") {
|
|
14620
|
+
if (ok) return { code, ok: true, detail: "", hint: "" };
|
|
14621
|
+
return { code, ok: false, detail: `${PREMISE_UNMET}\uFF1A${why}`, hint };
|
|
14622
|
+
}
|
|
14623
|
+
function identityOf(model, key) {
|
|
14624
|
+
return JSON.stringify([model, key]);
|
|
14625
|
+
}
|
|
14626
|
+
function plannedWithoutRecordOf(plan, book) {
|
|
14627
|
+
const missing = [];
|
|
14628
|
+
for (const modelPlan of plan.models) {
|
|
14629
|
+
for (const wave of modelPlan.waves ?? []) {
|
|
14630
|
+
for (const row of wave.rows) {
|
|
14631
|
+
if (book.statusOf(modelPlan.model, row.key) === null) {
|
|
14632
|
+
missing.push({
|
|
14633
|
+
model: modelPlan.model,
|
|
14634
|
+
key: [...row.key],
|
|
14635
|
+
sourceRowId: row.row,
|
|
14636
|
+
action: row.action
|
|
14637
|
+
});
|
|
14638
|
+
}
|
|
14639
|
+
}
|
|
14640
|
+
}
|
|
14641
|
+
}
|
|
14642
|
+
return missing;
|
|
14643
|
+
}
|
|
14644
|
+
function labelOf(workDir, rounds) {
|
|
14645
|
+
if (rounds.length === 0) return `${workDir} \xB7 \u53F0\u8D26\u91CC\u6CA1\u6709\u4EFB\u4F55\u8BA1\u5212\u8F6E\u6B21`;
|
|
14646
|
+
const span = rounds.length === 1 ? rounds[0] : [rounds[0], rounds.at(-1)].join(ROUND_SPAN);
|
|
14647
|
+
return `${workDir} \xB7 \u8BA1\u5212\u8F6E\u6B21 ${span}\uFF08\u5171 ${rounds.length} \u8F6E\uFF09`;
|
|
14648
|
+
}
|
|
14649
|
+
function buildDeliveryRun(workDir) {
|
|
14650
|
+
const book = Journal.load(workDir);
|
|
14651
|
+
const rounds = [...new Set(book.entries.map((e) => e.roundId))];
|
|
14652
|
+
const identities = /* @__PURE__ */ new Map();
|
|
14653
|
+
for (const entry of book.entries) {
|
|
14654
|
+
const id = identityOf(entry.model, entry.businessKey);
|
|
14655
|
+
if (!identities.has(id)) identities.set(id, [entry.model, entry.businessKey]);
|
|
14656
|
+
}
|
|
14657
|
+
const rows = [...identities.values()].map(([model, key]) => book.latest(model, key));
|
|
14658
|
+
const byStatus = Object.fromEntries(STATUSES.map((s) => [s, 0]));
|
|
14659
|
+
for (const row of rows) byStatus[row.status] += 1;
|
|
14660
|
+
const unresolved = rows.filter((row) => row.status === STATUS_UNKNOWN);
|
|
14661
|
+
const premises = [
|
|
14662
|
+
premise(PREMISE_JOURNAL_ON_DISK, book.exists, WHY_NO_JOURNAL),
|
|
14663
|
+
premise(
|
|
14664
|
+
PREMISE_JOURNAL_HAS_ENTRIES,
|
|
14665
|
+
book.entries.length > 0,
|
|
14666
|
+
WHY_NO_ENTRIES[book.exists ? "true" : "false"]
|
|
14667
|
+
)
|
|
14668
|
+
];
|
|
14669
|
+
let plannedWithoutRecord;
|
|
12526
14670
|
try {
|
|
12527
|
-
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
14671
|
+
const plan = readImportPlan(book.workDir);
|
|
14672
|
+
premises.push(premise(PREMISE_PLAN_READABLE, true, WHY_PLAN_UNREADABLE));
|
|
14673
|
+
plannedWithoutRecord = plannedWithoutRecordOf(plan, book);
|
|
14674
|
+
} catch (raw) {
|
|
14675
|
+
if (!(raw instanceof PlanReadError)) throw raw;
|
|
14676
|
+
premises.push(
|
|
14677
|
+
premise(
|
|
14678
|
+
PREMISE_PLAN_READABLE,
|
|
14679
|
+
false,
|
|
14680
|
+
`${WHY_PLAN_UNREADABLE}\uFF08[${raw.reason}] ${raw.detail}\uFF09`,
|
|
14681
|
+
raw.hint
|
|
14682
|
+
)
|
|
12533
14683
|
);
|
|
14684
|
+
plannedWithoutRecord = null;
|
|
12534
14685
|
}
|
|
14686
|
+
return {
|
|
14687
|
+
workDir: book.workDir,
|
|
14688
|
+
journalExists: book.exists,
|
|
14689
|
+
rounds,
|
|
14690
|
+
rows,
|
|
14691
|
+
byStatus,
|
|
14692
|
+
unresolved,
|
|
14693
|
+
waivers: [...book.waivers],
|
|
14694
|
+
plannedWithoutRecord,
|
|
14695
|
+
premises,
|
|
14696
|
+
notCovered: NOT_COVERED,
|
|
14697
|
+
label: labelOf(book.workDir, rounds)
|
|
14698
|
+
};
|
|
12535
14699
|
}
|
|
12536
|
-
function
|
|
12537
|
-
return
|
|
14700
|
+
function deliveryRunFields(run) {
|
|
14701
|
+
return Object.keys(run).sort();
|
|
12538
14702
|
}
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
14703
|
+
|
|
14704
|
+
// src/fde/verify/reconcile.ts
|
|
14705
|
+
var STATUS_FAILED = "failed";
|
|
14706
|
+
var VERDICT_CONFIRMED = "confirmed";
|
|
14707
|
+
var VERDICT_ID_DIFFERS = "id-differs";
|
|
14708
|
+
var VERDICT_CONTRADICTS = "contradicts";
|
|
14709
|
+
var VERDICT_UNATTRIBUTED = "unattributed";
|
|
14710
|
+
var VERDICT_INVISIBLE = "invisible";
|
|
14711
|
+
var VERDICT_UNREADABLE = "unreadable";
|
|
14712
|
+
var VERDICT_NOT_CHECKED = "not-checked";
|
|
14713
|
+
var VERDICTS2 = [
|
|
14714
|
+
VERDICT_CONFIRMED,
|
|
14715
|
+
VERDICT_ID_DIFFERS,
|
|
14716
|
+
VERDICT_CONTRADICTS,
|
|
14717
|
+
VERDICT_UNATTRIBUTED,
|
|
14718
|
+
VERDICT_INVISIBLE,
|
|
14719
|
+
VERDICT_UNREADABLE,
|
|
14720
|
+
VERDICT_NOT_CHECKED
|
|
14721
|
+
];
|
|
14722
|
+
var AGREEING_VERDICTS = [VERDICT_CONFIRMED];
|
|
14723
|
+
var DIFFERENCE_VERDICTS = [VERDICT_ID_DIFFERS, VERDICT_CONTRADICTS];
|
|
14724
|
+
var UNDECIDED_VERDICTS = [
|
|
14725
|
+
VERDICT_UNATTRIBUTED,
|
|
14726
|
+
VERDICT_INVISIBLE,
|
|
14727
|
+
VERDICT_UNREADABLE,
|
|
14728
|
+
VERDICT_NOT_CHECKED
|
|
14729
|
+
];
|
|
14730
|
+
var VERDICT_WORDS = {
|
|
14731
|
+
[VERDICT_CONFIRMED]: "\u6309\u8FD9\u4E2A\u4E1A\u52A1\u952E\u770B\u5F97\u89C1\u4E00\u884C\uFF0C\u4E14\u5B83\u7684 id \u4E0E\u53F0\u8D26\u8BB0\u4E0B\u7684**\u662F\u540C\u4E00\u4E2A** \u21D2 \u8D26\u672C\u8BF4\u7684\u90A3\u4E00\u884C\u6B64\u523B\u5728\u5E93\u91CC\u3002\u26A0\uFE0F \u8BF4\u51C6\u4E00\u683C\uFF1A\u8FD9\u8BF4\u7684\u662F\u300C\u8FD9\u4E00\u884C\u5728\u300D\uFF0C\u4E0D\u662F\u300C\u5B83\u7684\u5B57\u6BB5\u503C\u90FD\u5BF9\u300D\u2014\u2014\u672C\u5C42\u53EA\u5BF9\u8EAB\u4EFD\uFF0C\u4E0D\u6BD4\u5B57\u6BB5\u3002\u{1F534} \u53F0\u8D26\u72B6\u6001\u662F quarantined \u7684\u884C**\u5373\u4F7F\u5224 confirmed \u4E5F\u4ECD\u7136\u8981\u4EBA\u770B**\uFF1A\u8FD9\u4E00\u6863\u8BF4\u7684\u662F**\u8FD9\u4E2A\u952E**\u5728\uFF0C\u8BF4\u4E0D\u4E86\u670D\u52A1\u7AEF\u6709\u6CA1\u6709\u4E00\u6761**\u522B\u7684\u952E**\u7684\u91CE\u884C\uFF08\u53F0\u8D26\u90A3\u4E00\u6863\u7684\u4E0B\u4E00\u6B65\u9010\u5B57\u5199\u7740\u300C\u505C\u4E0B\u6765\u70B9\u540D\u8981\u4EBA\u300D\uFF0C\u672C\u5C42\u7684\u786E\u8BA4\u6E05\u4E0D\u6389\u90A3\u4E2A\u5ACC\u7591\uFF09\u3002",
|
|
14732
|
+
[VERDICT_ID_DIFFERS]: "\u6309\u8FD9\u4E2A\u4E1A\u52A1\u952E\u770B\u5F97\u89C1\u4E00\u884C\uFF0C\u4F46\u5B83\u7684 id \u4E0E\u53F0\u8D26\u8BB0\u4E0B\u7684**\u4E0D\u662F\u540C\u4E00\u4E2A** \u21D2 \u8981\u4E48\u8FD9\u4E2A\u952E\u5728\u672C\u79DF\u6237\u4E0D\u552F\u4E00\uFF0C\u8981\u4E48\u90A3\u4E00\u884C\u88AB\u5220\u8FC7\u53C8\u91CD\u5EFA\u8FC7\u3002\u5148\u53BB\u7CFB\u7EDF\u91CC\u770B\u90A3\u4E24\u4E2A id\u3002",
|
|
14733
|
+
[VERDICT_CONTRADICTS]: "\u53F0\u8D26\u8BF4\u8FD9\u4E00\u884C failed\uFF08\u8FD9\u4E00\u6863\u7684**\u627F\u8BFA**\u662F\u300C\u786E\u8BA4\u670D\u52A1\u7AEF\u4EC0\u4E48\u90FD\u6CA1\u5EFA\u300D\uFF09\uFF0C\u5E93\u91CC\u5374\u6309\u8FD9\u4E2A\u4E1A\u52A1\u952E\u770B\u5F97\u89C1\u4E00\u884C \u21D2 \u4E24\u4FA7\u5BF9\u4E0D\u4E0A\u3002\u{1F534} **\u8FD9\u4E2A\u300C\u5BF9\u4E0D\u4E0A\u300D\u6709\u591A\u786C\uFF0C\u53D6\u51B3\u4E8E\u90A3\u6761\u627F\u8BFA**\uFF1A\u53F0\u8D26\u7684 failed \u662F\u4ECE\u4EA7\u54C1\u7684 4xx **\u63A8\u65AD**\u51FA\u6765\u7684\uFF0C\u672C\u5DE5\u5177**\u6CA1\u6709**\u5728\u62D2\u7EDD\u4E4B\u540E\u56DE\u8BFB\u786E\u8BA4\u8FC7\u3002\u21D2 \u6700\u5E38\u89C1\u7684\u4E00\u79CD\u60C5\u5F62\u6070\u6070\u662F**\u8FD9\u4E00\u884C\u672C\u6765\u5C31\u5728**\u3001create \u56E0\u6B64\u88AB\u62D2\uFF08\u90A3\u8BF4\u660E\u8DD1\u524D\u62CD\u7684\u65E2\u5B58\u7D22\u5F15\u4E0E\u73B0\u5B9E\u4E0D\u4E00\u81F4\uFF09\uFF0C\u5176\u6B21\u624D\u662F**\u522B\u4EBA**\u5EFA\u7684\u540C\u952E\u884C\u3002**\u522B\u6025\u7740\u5220\u90A3\u4E00\u884C**\uFF1A\u5148\u53BB\u770B\u90A3\u6761 4xx \u7684\u539F\u6587\u3002",
|
|
14734
|
+
[VERDICT_UNATTRIBUTED]: "\u6309\u8FD9\u4E2A\u4E1A\u52A1\u952E\u770B\u5F97\u89C1\u4E00\u884C\uFF0C\u800C\u53F0\u8D26**\u6CA1\u6709**\u8BB0\u4E0B\u5B83\u7684 id \u21D2 \u300C\u8FD9\u4E00\u884C\u662F\u4E0D\u662F\u8FD9\u6B21\u4EA4\u4ED8\u5199\u8FDB\u53BB\u7684\u300D\u5BA2\u6237\u7AEF**\u5206\u4E0D\u51FA\u6765**\uFF08\u540C\u952E\u884C\u53EF\u80FD\u672C\u6765\u5C31\u5728\uFF0C\u4E5F\u53EF\u80FD\u662F\u522B\u4EBA\u5EFA\u7684\uFF09\u3002\u8FD9\u4E0D\u662F\u7ED3\u8BBA\uFF0C\u662F\u4E00\u5904\u5F85\u4EBA\u5224\u7684\u8D26\u3002",
|
|
14735
|
+
[VERDICT_INVISIBLE]: "**\u8FD9\u4E2A\u8D26\u53F7\u3001\u8FD9\u4E00\u523B**\u6309\u8FD9\u4E2A\u4E1A\u52A1\u952E\u67E5\u4E0D\u5230 \u2014\u2014 \u{1F534} \u8FD9**\u4E0D\u662F**\u300C\u6CA1\u5199\u8FDB\u53BB\u300D\u3002\u81F3\u5C11\u4E09\u79CD\u6210\u56E0\u5206\u4E0D\u5F00\uFF1A\u2460 \u6743\u9650\u88C1\u526A\uFF08\u53EF\u89C1\u603B\u6570\u672C\u8EAB\u5C31\u662F\u88C1\u526A\u540E\u7684\u6570\uFF09\xB7 \u2461 \u8BFB\u7684\u90A3\u4E00\u523B\u670D\u52A1\u7AEF\u4E8B\u52A1\u8FD8\u6CA1\u63D0\u4EA4 \xB7 \u2462 \u771F\u7684\u6CA1\u5199\u8FDB\u53BB\u3002\u{1F534} **\u5148\u770B\u8FD9\u4E2A\u6A21\u578B\u90A3\u4E00\u683C\u7684 visibleTotal**\uFF1A\u5B83\u662F 0 \u5C31\u8BF4\u660E**\u8FD9\u4E2A\u8D26\u53F7\u8FDE\u8FD9\u5F20\u8868\u90FD\u770B\u4E0D\u89C1**\uFF0C\u76F4\u63A5\u8D70\u2460\u3001\u522B\u5728\u2461\u4E0A\u5E72\u7B49\uFF1B\u5B83\u4E0D\u662F 0\uFF0C\u8BF4\u660E\u8868\u770B\u5F97\u89C1\u800C**\u8FD9\u4E2A\u952E**\u770B\u4E0D\u89C1\u3002\uFF08visibleTotal \u662F null \u65F6\u662F\u53E6\u4E00\u56DE\u4E8B\uFF1A\u90A3\u4E00\u6863\u7684\u5224\u5B9A\u662F unreadable\uFF0C\u4E0D\u662F\u672C\u6863\u3002\uFF09\u4E0B\u4E00\u6B65\u6709\u4E24\u6761\uFF0C**\u5206\u522B\u5BF9\u7740\u4E0D\u540C\u7684\u6210\u56E0**\uFF1A\u2460 \u6362\u4E00\u4E2A\u770B\u5F97\u89C1\u8FD9\u5F20\u8868\u7684\u8D26\u53F7\u518D\u8DD1\u4E00\u6B21\uFF0C\u4E24\u4EFD\u7ED3\u8BBA\u4E00\u8D77\u770B\uFF08\u6CBB\u2460\uFF09\uFF1B\u2461 \u9694\u4E00\u4F1A\u513F\u539F\u6837\u518D\u8DD1\u4E00\u6B21 \u2014\u2014 \u82E5\u6210\u56E0\u662F\u8BFB\u5EF6\u8FDF\uFF0C\u5B83\u4F1A\u53D8\uFF08\u6CBB\u2461\uFF09\u3002\u{1F534} \u4E24\u6761\u90FD\u505A\u5B8C\u4ECD\u7136\u67E5\u4E0D\u5230\uFF0C**\u4E5F\u8FD8\u4E0D\u662F**\u300C\u6CA1\u5199\u8FDB\u53BB\u300D\uFF1A\u90A3\u65F6\u8BE5\u62FF\u4E1A\u52A1\u952E\u53BB\u5E93\u91CC\u624B\u67E5\u4E00\u6B21\u3002",
|
|
14736
|
+
[VERDICT_UNREADABLE]: "\u8FD9\u4E2A\u6A21\u578B\u7684\u65E2\u5B58\u7D22\u5F15**\u6CA1\u5EFA\u6210**\uFF0C\u6240\u4EE5\u5B83\u540D\u4E0B\u6BCF\u4E00\u884C\u90FD**\u6CA1\u6709**\u5BF9\u8D26\u7ED3\u8BBA\u3002\u6210\u56E0\u539F\u6837\u8BB0\u5728\u8FD9\u4E2A\u6A21\u578B\u90A3\u4E00\u683C\u7684 problem \u91CC\uFF08\u53D6\u6570\u5931\u8D25 / \u54CD\u5E94\u5F62\u72B6\u4E0D\u5BF9 / \u4E1A\u52A1\u952E\u5728\u672C\u79DF\u6237\u4E0D\u552F\u4E00 \u2026\uFF09\u2014\u2014 \u5148\u6309\u90A3\u53E5\u8BDD\u5904\u7F6E\uFF0C\u518D\u8DD1\u4E00\u6B21\u3002",
|
|
14737
|
+
[VERDICT_NOT_CHECKED]: "**\u4E00\u53D1\u8BF7\u6C42\u90FD\u6CA1\u4E3A\u5B83\u53D1\u8FC7**\uFF1A\u76D8\u4E0A\u90A3\u4EFD\u8BA1\u5212\u91CC\u95EE\u4E0D\u51FA\u8FD9\u4E2A\u6A21\u578B\u7684\u4E1A\u52A1\u952E\u5B57\u6BB5\uFF08\u53F0\u8D26\u91CC\u6709\u8FD9\u4E2A\u6A21\u578B\u3001\u8BA1\u5212\u91CC\u6CA1\u6709\uFF0C\u5178\u578B\u6210\u56E0\u662F\u4E2D\u9014\u91CD\u8DD1\u8FC7 plan\uFF09\u3002\u6CA1\u6709\u4E1A\u52A1\u952E\u5C31\u6CA1\u6709\u56DE\u8BFB\u7684\u652F\u70B9\uFF0C\u672C\u5C42\u4E0D\u731C\u4E00\u4E2A\u3002"
|
|
14738
|
+
};
|
|
14739
|
+
var PREMISE_ROWS_TO_CHECK = "journal-rows-to-check";
|
|
14740
|
+
var PREMISE_KEY_FIELDS = "plan-business-key-fields";
|
|
14741
|
+
var PREMISE_CLIENT = "client-on-hand";
|
|
14742
|
+
var PREMISE_IDENTITY = "readback-identity";
|
|
14743
|
+
var NETWORK_GATES = [PREMISE_ROWS_TO_CHECK, PREMISE_KEY_FIELDS, PREMISE_CLIENT];
|
|
14744
|
+
var WHY_NO_ROWS = "\u53F0\u8D26\u91CC\u4E00\u884C\u90FD\u6CA1\u6709 \u21D2 **\u6CA1\u6709\u4EFB\u4F55\u4E00\u884C\u53EF\u4EE5\u62FF\u53BB\u548C\u5E93\u91CC\u5BF9**\uFF0C\u672C\u5C42\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\u3002\u4E0B\u9762\u539F\u6837\u8F6C\u8F7D\u7B2C\u4E00\u5C42\u90A3\u51E0\u6761\u4E0D\u6210\u7ACB\u7684\u524D\u63D0 \u2014\u2014 \u300C\u96F6\u884C\u300D\u7684\u6210\u56E0\u4E0D\u6B62\u4E00\u79CD\uFF0C\u672C\u5C42**\u4E0D\u628A\u5B83\u4EEC\u5408\u6210\u4E00\u53E5**\u3002";
|
|
14745
|
+
var WHY_NO_KEY_FIELDS = "\u76D8\u4E0A\u90A3\u4EFD\u8BA1\u5212\u8BFB\u4E0D\u56DE\u6765 \u21D2 **\u95EE\u4E0D\u51FA\u4E1A\u52A1\u952E\u5B57\u6BB5\u540D**\uFF0C\u800C\u6309\u4E1A\u52A1\u952E\u56DE\u8BFB\u662F\u672C\u5C42\u552F\u4E00\u7684\u652F\u70B9\uFF08\u4EA7\u54C1\u7684\u884C\u4E0A\u6CA1\u6709\u3001\u4E5F\u4E0D\u8BB8\u6709\u4EFB\u4F55\u672C\u5DE5\u5177\u7684\u6807\u8BB0\uFF09\u3002\u21D2 \u8FD9\u4E00\u95EE**\u6CA1\u6709\u7B54\u6848**\uFF0C\u672C\u5C42\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF0C\u9010\u6761\u90A3\u51E0\u683C\u7ED9\u7684\u662F null \u800C\u4E0D\u662F\u7A7A\u8868\u3002";
|
|
14746
|
+
var WHY_NO_CLIENT = "\u624B\u4E0A\u6CA1\u6709\u5BA2\u6237\u7AEF \u21D2 **\u5BF9\u4E0D\u4E86\u8D26**\u3002\u5E93\u91CC\u73B0\u5728\u957F\u4EC0\u4E48\u6837\uFF0C\u76D8\u4E0A\u4EFB\u4F55\u4E00\u4EFD\u4EA7\u7269\u90FD\u7B54\u4E0D\u4E86\uFF1A\u53F0\u8D26\u81EA\u5DF1\u7684 serverId \u4E0E\u8D26\u672C\u540C\u6E90\uFF08\u62FF\u5B83\u5F53\u53E6\u4E00\u4FA7\u662F\u81EA\u8BC1\uFF09\u3001\u8BA1\u5212\u91CC\u7684 existingId \u662F**\u8DD1\u4E4B\u524D**\u90A3\u4E00\u523B\u7684\u5FEB\u7167\u3001apply \u7684\u62A5\u544A\u4ECE\u4E0D\u843D\u76D8\u3002\u{1F534} **\u8FD9\u6761\u51FA\u8DEF\u5728\u6C14\u9699\u673A\u5668\u4E0A\u8D70\u4E0D\u901A** \u2014\u2014 \u672C\u5C42\u4E0D\u5047\u88C5\u8FD8\u6709\u522B\u7684\u8DEF\uFF0C\u4E5F**\u4E0D**\u4EA7\u51FA\u4E00\u4EFD\u300C\u5BF9\u8D26\u901A\u8FC7\u300D\u3002";
|
|
14747
|
+
var WHY_NO_IDENTITY = {
|
|
14748
|
+
false: "**\u4E0D\u77E5\u9053\u8FD9\u4E00\u4EFD\u662F\u7528\u8C01\u7684\u8EAB\u4EFD\u8BFB\u7684**\uFF1A\u672C\u5DE5\u5177**\u6CA1\u6709\u7ECF\u624B\u8FD9\u6B21\u767B\u5F55**\uFF08\u624B\u4E0A\u662F\u522B\u5904\u7ED9\u7684 token\uFF09\u3002\u53EF\u89C1\u8303\u56F4\u968F\u89D2\u8272\u53D8\uFF0C\u800C\u300C\u67E5\u4E0D\u5230\u300D\u8FD9\u4E00\u6863\u7684\u7B2C\u4E00\u79CD\u6210\u56E0\u6B63\u662F\u6743\u9650\u88C1\u526A \u21D2 \u8FD9\u4EFD\u5BF9\u8D26**\u8BF4\u4E0D\u51FA\u81EA\u5DF1\u7684\u53E3\u5F84**\u3002\u4E0B\u4E00\u6B65\uFF1A\u7528\u672C\u5DE5\u5177\u81EA\u5DF1\u7684\u767B\u5F55\u8DD1\u4E00\u6B21\u3002",
|
|
14749
|
+
true: "**\u670D\u52A1\u7AEF\u6CA1\u5728\u54CD\u5E94\u91CC\u7ED9 user**\uFF1A\u767B\u5F55**\u7ECF\u624B\u8FC7**\uFF08\u672C\u5DE5\u5177\u586B\u7684 requestedTenantId \u8FD8\u5728\uFF09\uFF0C\u4F46 tenantId / username / roles \u5168\u662F\u7A7A\u7684 \u2014\u2014 \u8FD9\u4EFD\u5BF9\u8D26**\u8BF4\u4E0D\u51FA\u662F\u8C01\u8DD1\u7684**\u3002\u{1F534} \u5C24\u5176\u522B\u628A\u7A7A\u7684 roles \u8BFB\u6210\u300C\u8FD9\u4E2A\u8D26\u53F7\u4EC0\u4E48\u90FD\u770B\u4E0D\u89C1\u300D\uFF1A\u90A3\u662F**\u6CA1\u62FF\u5230**\uFF0C\u4E0D\u662F**\u770B\u5230\u4E86\u7A7A\u7684**\u3002\u21D2 \u5BF9\u8D26\u7167\u6837\u8DD1\u5F97\u5B8C\uFF0C\u4F46\u6362\u4E2A\u4EBA\u590D\u6838\u65F6\u65E0\u4ECE\u6BD4\u5BF9\u4E24\u4EFD\u4E3A\u4EC0\u4E48\u4E0D\u4E00\u6837\u3002\u4E0B\u4E00\u6B65\uFF1A\u53BB\u95EE\u670D\u52A1\u7AEF\u4E3A\u4EC0\u4E48\u4E0D\u7ED9 user\uFF0C**\u4E0D\u662F**\u91CD\u767B\uFF08\u91CD\u767B\u6CBB\u7684\u662F\u4E0A\u9762\u90A3\u4E00\u6863\uFF09\u3002"
|
|
14750
|
+
};
|
|
14751
|
+
var NOT_COVERED2 = [
|
|
14752
|
+
"\u672C\u5C42\u53EA\u5BF9**\u53F0\u8D26\u91CC\u6709\u8BB0\u5F55**\u7684\u90A3\u4E9B\u884C\u3002\u300C\u8BA1\u5212\u91CC\u6709\u3001\u53F0\u8D26\u91CC\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709\u300D\u90A3\u4E00\u8F74\u5728\u7B2C\u4E00\u5C42\uFF08plannedWithoutRecord\uFF09\u2014\u2014 \u90A3\u4E9B\u884C\u672C\u5C42**\u4E00\u6B21\u90FD\u6CA1\u6709\u56DE\u8BFB\u8FC7**\uFF0C\u5B83\u4EEC\u6B64\u523B\u5728\u4E0D\u5728\u5E93\u91CC\uFF0C\u8FD9\u4EFD\u5BF9\u8D26\u8BF4\u4E0D\u51FA\u6765\u3002",
|
|
14753
|
+
"\u5BF9\u8D26**\u53EA\u5BF9\u8EAB\u4EFD\u3001\u4E0D\u6BD4\u5B57\u6BB5**\uFF1A\u6309\u8FD9\u4E2A\u4E1A\u52A1\u952E\u770B\u5F97\u89C1\u4E00\u884C\u3001\u4E14 id \u4E0E\u8D26\u672C\u8BB0\u7684\u76F8\u540C\uFF0C\u53EA\u8BF4\u660E**\u90A3\u4E00\u884C\u5728**\uFF0C**\u4E0D\u8BF4\u660E**\u5B83\u7684\u5B57\u6BB5\u503C\u4E0E\u6E90\u8868\u4E00\u81F4 \u2014\u2014 \u6709\u4EBA\u540E\u6765\u6539\u8FC7\u5B83\uFF0C\u672C\u5C42\u770B\u4E0D\u89C1\u3002",
|
|
14754
|
+
"\u540C\u4E00\u4E2A\u4E1A\u52A1\u952E\u5728\u5E93\u91CC\u6709**\u591A\u884C**\u65F6\uFF0C\u672C\u5C42**\u4E0D\u662F\u884C\u7EA7\u5224\u5B9A**\uFF1A\u6279\u91CF\u7D22\u5F15\u628A\u5B83\u538B\u6210\u6574\u4E2A\u6A21\u578B\u7684\u524D\u63D0\u5931\u8D25\uFF08key-count-mismatch\uFF09\uFF0C\u90A3\u4E2A\u6A21\u578B\u540D\u4E0B\u6BCF\u4E00\u884C\u843D unreadable\u3002\u{1F534} \u672C\u5C42**\u4E0D\u9000\u5316\u6210\u9010\u884C\u56DE\u8BFB**\uFF1A\u90A3\u4F1A\u9020\u51FA\u7B2C\u4E8C\u4E2A\u771F\u76F8\u6E90\uFF08\u4E24\u6761\u901A\u9053\u7684\u5B8C\u6574\u6027\u524D\u63D0\u4E0D\u540C\uFF09\u3002\u26A0\uFE0F \u90A3\u6761\u7ECF\u6D4E\u6027\u8BBA\u8BC1**\u6709\u524D\u63D0**\uFF0C\u522B\u5F53\u6210\u65E0\u6761\u4EF6\u7684\uFF1A\u300C\u9010\u884C 17396 \u53D1 \u224858 \u5206\u949F vs \u6279\u91CF 10 \u53D1 \u224822s\u300D\u6210\u7ACB\u4E8E**\u4EA4\u4ED8\u8986\u76D6\u6574\u5F20\u8868**\u7684\u573A\u666F\uFF08\u521D\u6B21\u5EFA\u5E93\u5BFC\u5165\uFF0C\u672C\u5DE5\u5177\u7684\u4E3B\u573A\u666F\uFF09\uFF1B\u8868 20 \u4E07\u884C\u800C\u8FD9\u4E00\u8F6E\u53EA\u52A8 5 \u884C\u65F6\u5B83**\u53CD\u8FC7\u6765** \u2014\u2014 \u6279\u91CF\u8981 100 \u53D1\u8BF7\u6C42 + 20 \u4E07\u884C\u8FC7\u7EBF\uFF0C\u9010\u884C\u53EA\u8981 5 \u53D1\uFF08\u4EE3\u4EF7\u4ECD\u5728\u53EF\u63A5\u53D7\u533A\u95F4\uFF0C\u6545\u5B9E\u73B0\u4E0D\u53D8\uFF09\u3002",
|
|
14755
|
+
"\u300C\u6070\u597D\u770B\u5F97\u89C1\u4E00\u884C\u300D\u4E5F\u53EF\u80FD\u662F**\u522B\u4EBA**\u5EFA\u7684\u540C\u952E\u884C \u2014\u2014 \u5BA2\u6237\u7AEF\u5206\u4E0D\u51FA\u6765\u3002\u6240\u4EE5 confirmed \u8BF4\u7684\u662F\u300C\u6309\u8FD9\u4E2A\u952E\u770B\u5F97\u89C1\u4E00\u884C\u3001\u4E14 id \u4E0E\u8D26\u672C\u8BB0\u7684\u76F8\u540C\u300D\uFF0C\u4EC5\u6B64\u800C\u5DF2\u3002",
|
|
14756
|
+
"\u7ED3\u8BBA\u53EA\u662F**\u8BFB\u7684\u90A3\u4E00\u523B**\u7684\u4E8B\u5B9E\uFF1A\u8FD9\u4E00\u4EFD\u5BF9\u8D26\u8DD1\u5B8C\u4E4B\u540E\u6709\u4EBA\u518D\u52A8\u5E93\uFF0C\u5B83\u5C31\u8FC7\u671F\u4E86\uFF1B\u800C\u672C\u5C42**\u6CA1\u6709**\u4EFB\u4F55\u673A\u5236\u80FD\u53D1\u73B0\u90A3\u4EF6\u4E8B\u3002",
|
|
14757
|
+
"contradicts \u7684\u5F3A\u5EA6**\u53D7\u9650\u4E8E\u53F0\u8D26 failed \u90A3\u6761\u672A\u7ECF\u67E5\u8BC1\u7684\u63A8\u65AD**\uFF1A\u5199 failed \u7684\u552F\u4E00\u90A3\u5904\u81EA\u5DF1\u5199\u7740\u300C4xx \u21D2 \u4EC0\u4E48\u90FD\u6CA1\u5EFA\u300D\u662F**\u63A8\u65AD**\u3001\u62D2\u7EDD\u4E4B\u540E**\u6CA1\u6709\u56DE\u8BFB\u786E\u8BA4\u8FC7**\u3002\u21D2 \u8FD9\u4E00\u6863\u8BF4\u7684\u662F\u300C\u4EA7\u54C1\u62D2\u4E86\u5B83\uFF0C\u800C\u8FD9\u4E2A\u952E\u6B64\u523B\u770B\u5F97\u89C1\u300D\uFF0C**\u4E0D\u662F**\u300C\u670D\u52A1\u7AEF\u786E\u5B9E\u4EC0\u4E48\u90FD\u6CA1\u5EFA\u3001\u5374\u53C8\u6709\u4E00\u884C\u300D\u3002\u6700\u5E38\u89C1\u7684\u4E00\u79CD\u5C31\u662F\u8FD9\u4E00\u884C\u672C\u6765\u5C31\u5728\u3001create \u56E0\u6B64\u88AB\u62D2 \u2014\u2014 \u90A3\u662F**\u7D22\u5F15\u8FC7\u671F**\uFF0C\u4E0D\u662F\u77DB\u76FE\u3002",
|
|
14758
|
+
"\u53F0\u8D26\u72B6\u6001\u662F quarantined \u7684\u884C**\u4F1A\u843D\u8FDB\u300C\u5BF9\u5F97\u4E0A\u300D\u90A3\u5F20\u67B6\u5B50**\uFF08\u5B83\u5E26\u7740 serverId\uFF0C\u56DE\u8BFB\u53C8\u786E\u8BA4\u8FD9\u4E2A\u952E\u5728\uFF09\u3002\u26A0\uFE0F \u53F0\u8D26\u90A3\u4E00\u6863\u7684\u4E0B\u4E00\u6B65\u662F\u300C\u505C\u4E0B\u6765\u70B9\u540D\u8981\u4EBA\u300D\uFF0C\u7406\u7531\u662F\u670D\u52A1\u7AEF**\u53EF\u80FD\u6709\u4E00\u6761\u522B\u7684\u952E\u7684\u91CE\u884C** \u2014\u2014 \u800C\u672C\u5C42\u6309\u4E1A\u52A1\u952E\u56DE\u8BFB\uFF0C**\u6E05\u4E0D\u6389\u90A3\u4E2A\u5ACC\u7591**\u3002\u21D2 \u7B7E\u5B57\u524D\u628A\u8FD9\u4E9B\u884C\u5355\u72EC\u6311\u51FA\u6765\u770B\uFF0C\u522B\u53EA\u770B\u67B6\u5B50\u3002",
|
|
14759
|
+
"\u53EF\u89C1\u603B\u6570\uFF08visibleTotal\uFF09\u662F**\u88C1\u526A\u540E**\u7684\u6570\uFF1A\u67E5\u8BE2\u5F15\u64CE\u5148\u6CE8\u5165\u6743\u9650\u8FC7\u6EE4\u518D\u5206\u9875\u4E0E\u8BA1\u6570\u3002\u21D2 \u5B83\u8BF4\u7684\u662F\u300C**\u8FD9\u4E2A\u8D26\u53F7**\u770B\u5F97\u89C1\u51E0\u884C\u300D\uFF0C**\u4E0D\u662F**\u300C\u8FD9\u5F20\u8868\u6709\u51E0\u884C\u300D\u2014\u2014\u4E24\u8005\u5728\u540C\u4E00\u4E2A\u6570\u4E0A\u540C\u5F62\uFF0C\u522B\u5F53\u6210\u540E\u8005\u53BB\u548C\u6E90\u8868\u7684\u884C\u6570\u5BF9\u3002"
|
|
14760
|
+
];
|
|
14761
|
+
function isObject2(v) {
|
|
14762
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
12542
14763
|
}
|
|
12543
|
-
function
|
|
12544
|
-
|
|
12545
|
-
return v;
|
|
14764
|
+
function identityKnown(identity) {
|
|
14765
|
+
return isObject2(identity) && String(identity["tenantId"] ?? "").trim().length > 0;
|
|
12546
14766
|
}
|
|
12547
|
-
function
|
|
12548
|
-
|
|
12549
|
-
|
|
14767
|
+
function rowsWhy(delivery) {
|
|
14768
|
+
const upstream = delivery.premises.filter(
|
|
14769
|
+
(p) => (p.code === PREMISE_JOURNAL_ON_DISK || p.code === PREMISE_JOURNAL_HAS_ENTRIES) && !p.ok
|
|
14770
|
+
).map((p) => p.detail);
|
|
14771
|
+
return [WHY_NO_ROWS, ...upstream].join("\n");
|
|
12550
14772
|
}
|
|
12551
|
-
function
|
|
12552
|
-
|
|
12553
|
-
if (
|
|
12554
|
-
|
|
14773
|
+
function keyFieldsOf(delivery) {
|
|
14774
|
+
const upstream = delivery.premises.filter((p) => p.code === PREMISE_PLAN_READABLE);
|
|
14775
|
+
if (upstream.length > 0 && !upstream[0].ok) {
|
|
14776
|
+
return [
|
|
14777
|
+
/* @__PURE__ */ new Map(),
|
|
14778
|
+
premise(
|
|
14779
|
+
PREMISE_KEY_FIELDS,
|
|
14780
|
+
false,
|
|
14781
|
+
`${WHY_NO_KEY_FIELDS}
|
|
14782
|
+
${upstream[0].detail}`,
|
|
14783
|
+
upstream[0].hint
|
|
14784
|
+
)
|
|
14785
|
+
];
|
|
14786
|
+
}
|
|
14787
|
+
try {
|
|
14788
|
+
const plan = readImportPlan(delivery.workDir);
|
|
14789
|
+
const table = /* @__PURE__ */ new Map();
|
|
14790
|
+
for (const m of plan.models) {
|
|
14791
|
+
if (m.businessKeyFields.length > 0) table.set(m.model, [...m.businessKeyFields]);
|
|
14792
|
+
}
|
|
14793
|
+
return [table, premise(PREMISE_KEY_FIELDS, true, WHY_NO_KEY_FIELDS)];
|
|
14794
|
+
} catch (raw) {
|
|
14795
|
+
if (!(raw instanceof PlanReadError)) throw raw;
|
|
14796
|
+
return [
|
|
14797
|
+
/* @__PURE__ */ new Map(),
|
|
14798
|
+
premise(
|
|
14799
|
+
PREMISE_KEY_FIELDS,
|
|
14800
|
+
false,
|
|
14801
|
+
`${WHY_NO_KEY_FIELDS}\uFF08[${raw.reason}] ${raw.detail}\uFF09`,
|
|
14802
|
+
raw.hint
|
|
14803
|
+
)
|
|
14804
|
+
];
|
|
14805
|
+
}
|
|
12555
14806
|
}
|
|
12556
|
-
function
|
|
12557
|
-
|
|
12558
|
-
return {
|
|
12559
|
-
version: need(o, "version"),
|
|
12560
|
-
roundId: need(o, "roundId"),
|
|
12561
|
-
models: arrayOf(need(o, "models"), "models").map(modelFromJson),
|
|
12562
|
-
problems: arrayOf(need(o, "problems"), "problems").map((p) => ({
|
|
12563
|
-
...objectOf(p, "problems[]")
|
|
12564
|
-
})),
|
|
12565
|
-
notes: arrayOf(need(o, "notes"), "notes").map((n) => objectOf(n, "notes[]")),
|
|
12566
|
-
crossModelOrder: { ...objectOf(need(o, "crossModelOrder"), "crossModelOrder") },
|
|
12567
|
-
baseline: baselineFromJson(o)
|
|
12568
|
-
};
|
|
14807
|
+
function modelsInOrder(rows) {
|
|
14808
|
+
return [...new Set(rows.map((r) => r.model))];
|
|
12569
14809
|
}
|
|
12570
|
-
function
|
|
12571
|
-
if (
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
if (
|
|
12575
|
-
|
|
12576
|
-
`baseline \u5FC5\u987B\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF08planToJson \u5199\u51FA\u53BB\u7684\u5C31\u662F\u5BF9\u8C61\uFF0C\u6216\u8005\u6574\u4E2A\u662F null\uFF09\uFF0C\u8FD9\u4E00\u4EFD\u662F ${describe2(raw)}`
|
|
12577
|
-
);
|
|
14810
|
+
function verdictOf(row, readback, index) {
|
|
14811
|
+
if (readback.keyFields === null) return [VERDICT_NOT_CHECKED, null];
|
|
14812
|
+
if (index === void 0) return [VERDICT_UNREADABLE, null];
|
|
14813
|
+
const found = index.rows.get(encodeKeyTuple([...row.businessKey]));
|
|
14814
|
+
if (found === void 0) {
|
|
14815
|
+
return [VERDICT_INVISIBLE, null];
|
|
12578
14816
|
}
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
throw new Error(`baseline \u5C11\u4E86\u8FD9\u4E9B\u952E\uFF1A${missing.join("\u3001")}\uFF08\u5199\u51FA\u53BB\u7684\u4E24\u4E2A\u952E\u662F path / roundId\uFF09`);
|
|
14817
|
+
if (row.status === STATUS_FAILED) {
|
|
14818
|
+
return [VERDICT_CONTRADICTS, found];
|
|
12582
14819
|
}
|
|
12583
|
-
if (
|
|
12584
|
-
|
|
14820
|
+
if (row.serverId === null) return [VERDICT_UNATTRIBUTED, found];
|
|
14821
|
+
if (found === row.serverId) return [VERDICT_CONFIRMED, found];
|
|
14822
|
+
return [VERDICT_ID_DIFFERS, found];
|
|
14823
|
+
}
|
|
14824
|
+
function judge(row, readback, index) {
|
|
14825
|
+
const [verdict, serverNow] = verdictOf(row, readback, index);
|
|
14826
|
+
return {
|
|
14827
|
+
sourceRowId: row.sourceRowId,
|
|
14828
|
+
model: row.model,
|
|
14829
|
+
businessKey: [...row.businessKey],
|
|
14830
|
+
ledgerStatus: row.status,
|
|
14831
|
+
ledgerServerId: row.serverId,
|
|
14832
|
+
serverNow,
|
|
14833
|
+
verdict
|
|
14834
|
+
};
|
|
14835
|
+
}
|
|
14836
|
+
async function buildReconciliation(delivery, client) {
|
|
14837
|
+
const premises = [
|
|
14838
|
+
premise(PREMISE_ROWS_TO_CHECK, delivery.rows.length > 0, rowsWhy(delivery))
|
|
14839
|
+
];
|
|
14840
|
+
const [keyFieldsByModel, keyPremise] = keyFieldsOf(delivery);
|
|
14841
|
+
premises.push(keyPremise);
|
|
14842
|
+
premises.push(premise(PREMISE_CLIENT, client !== null, WHY_NO_CLIENT));
|
|
14843
|
+
const identity = client === null ? null : client.identity ?? null;
|
|
14844
|
+
premises.push(
|
|
14845
|
+
premise(
|
|
14846
|
+
PREMISE_IDENTITY,
|
|
14847
|
+
identityKnown(identity),
|
|
14848
|
+
WHY_NO_IDENTITY[isObject2(identity) ? "true" : "false"]
|
|
14849
|
+
)
|
|
14850
|
+
);
|
|
14851
|
+
const known = isObject2(identity) ? identity : null;
|
|
14852
|
+
const blocked = premises.filter(
|
|
14853
|
+
(p) => NETWORK_GATES.includes(p.code) && !p.ok
|
|
14854
|
+
);
|
|
14855
|
+
if (blocked.length > 0) {
|
|
14856
|
+
return {
|
|
14857
|
+
workDir: delivery.workDir,
|
|
14858
|
+
label: delivery.label,
|
|
14859
|
+
identity: known,
|
|
14860
|
+
findings: null,
|
|
14861
|
+
byVerdict: null,
|
|
14862
|
+
differences: null,
|
|
14863
|
+
undecided: null,
|
|
14864
|
+
models: null,
|
|
14865
|
+
premises,
|
|
14866
|
+
notCovered: NOT_COVERED2,
|
|
14867
|
+
verdictWords: VERDICT_WORDS
|
|
14868
|
+
};
|
|
12585
14869
|
}
|
|
12586
|
-
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
);
|
|
14870
|
+
const models = [];
|
|
14871
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
14872
|
+
for (const model of modelsInOrder(delivery.rows)) {
|
|
14873
|
+
const keyFields = keyFieldsByModel.get(model);
|
|
14874
|
+
if (keyFields === void 0 || keyFields.length === 0) {
|
|
14875
|
+
models.push({ model, keyFields: null, visibleTotal: null, pages: null, problem: null });
|
|
14876
|
+
continue;
|
|
14877
|
+
}
|
|
14878
|
+
try {
|
|
14879
|
+
const index = await loadKeyIndex(client, model, keyFields);
|
|
14880
|
+
indexes.set(model, index);
|
|
14881
|
+
models.push({
|
|
14882
|
+
model,
|
|
14883
|
+
keyFields: [...keyFields],
|
|
14884
|
+
visibleTotal: index.total,
|
|
14885
|
+
pages: index.pages,
|
|
14886
|
+
problem: null
|
|
14887
|
+
});
|
|
14888
|
+
} catch (raw) {
|
|
14889
|
+
if (!(raw instanceof IndexPremiseError)) throw raw;
|
|
14890
|
+
models.push({
|
|
14891
|
+
model,
|
|
14892
|
+
keyFields: [...keyFields],
|
|
14893
|
+
visibleTotal: null,
|
|
14894
|
+
pages: null,
|
|
14895
|
+
problem: `[${raw.reason}] ${raw.detail} \u2014\u2014 ${raw.hint || "\u5148\u628A\u8FD9\u6761\u89E3\u51B3\u518D\u8DD1\u4E00\u6B21\u5BF9\u8D26"}`
|
|
14896
|
+
});
|
|
14897
|
+
}
|
|
12590
14898
|
}
|
|
12591
|
-
|
|
14899
|
+
const byModel = new Map(models.map((m) => [m.model, m]));
|
|
14900
|
+
const findings = delivery.rows.map((row) => judge(row, byModel.get(row.model), indexes.get(row.model)));
|
|
14901
|
+
const byVerdict = Object.fromEntries(VERDICTS2.map((v) => [v, 0]));
|
|
14902
|
+
for (const f of findings) byVerdict[f.verdict] = (byVerdict[f.verdict] ?? 0) + 1;
|
|
14903
|
+
return {
|
|
14904
|
+
workDir: delivery.workDir,
|
|
14905
|
+
label: delivery.label,
|
|
14906
|
+
identity: known,
|
|
14907
|
+
findings,
|
|
14908
|
+
byVerdict,
|
|
14909
|
+
differences: findings.filter((f) => DIFFERENCE_VERDICTS.includes(f.verdict)),
|
|
14910
|
+
undecided: findings.filter((f) => UNDECIDED_VERDICTS.includes(f.verdict)),
|
|
14911
|
+
models,
|
|
14912
|
+
premises,
|
|
14913
|
+
notCovered: NOT_COVERED2,
|
|
14914
|
+
verdictWords: VERDICT_WORDS
|
|
14915
|
+
};
|
|
12592
14916
|
}
|
|
12593
|
-
function
|
|
12594
|
-
const o = objectOf(m, "models[]");
|
|
12595
|
-
const waves = need(o, "waves");
|
|
14917
|
+
function notAsked(delivery) {
|
|
12596
14918
|
return {
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
arrayOf(v, `blockedChecks.${k}`)
|
|
12610
|
-
])
|
|
12611
|
-
),
|
|
12612
|
-
rowsNotInWaves: new Map(
|
|
12613
|
-
Object.entries(objectOf(need(o, "rowsNotInWaves"), "rowsNotInWaves"))
|
|
12614
|
-
),
|
|
12615
|
-
selfReference: { ...objectOf(need(o, "selfReference"), "selfReference") }
|
|
14919
|
+
workDir: delivery.workDir,
|
|
14920
|
+
label: delivery.label,
|
|
14921
|
+
identity: null,
|
|
14922
|
+
findings: null,
|
|
14923
|
+
byVerdict: null,
|
|
14924
|
+
differences: null,
|
|
14925
|
+
undecided: null,
|
|
14926
|
+
models: null,
|
|
14927
|
+
premises: [],
|
|
14928
|
+
// 🔴 **更长的那一份**:把「库里现在怎么样,这一趟一个字都没问」逐字带上。
|
|
14929
|
+
notCovered: [...NOT_COVERED2, WHY_NO_CLIENT],
|
|
14930
|
+
verdictWords: VERDICT_WORDS
|
|
12616
14931
|
};
|
|
12617
14932
|
}
|
|
12618
|
-
function
|
|
12619
|
-
const
|
|
14933
|
+
function shelfPartition() {
|
|
14934
|
+
const domain = new Set(VERDICTS2);
|
|
14935
|
+
const shelves = [AGREEING_VERDICTS, DIFFERENCE_VERDICTS, UNDECIDED_VERDICTS];
|
|
14936
|
+
const union = new Set(shelves.flatMap((s) => [...s]));
|
|
14937
|
+
const seen = /* @__PURE__ */ new Map();
|
|
14938
|
+
for (const shelf of shelves) for (const v of shelf) seen.set(v, (seen.get(v) ?? 0) + 1);
|
|
12620
14939
|
return {
|
|
12621
|
-
|
|
12622
|
-
|
|
12623
|
-
|
|
14940
|
+
missing: [...domain].filter((v) => !union.has(v)).sort(),
|
|
14941
|
+
extra: [...union].filter((v) => !domain.has(v)).sort(),
|
|
14942
|
+
overlap: [...seen.entries()].filter(([, n]) => n > 1).map(([v]) => v).sort()
|
|
12624
14943
|
};
|
|
12625
14944
|
}
|
|
12626
|
-
|
|
12627
|
-
|
|
12628
|
-
|
|
12629
|
-
|
|
12630
|
-
|
|
14945
|
+
|
|
14946
|
+
// src/fde/verify/face.ts
|
|
14947
|
+
var LEDGER_ONLY_FLAG = "--ledger-only";
|
|
14948
|
+
var NOT_COVERED_SELF = "\u5DF2\u77E5\u4E0D\u8986\u76D6 \xB7 \u672C\u547D\u4EE4";
|
|
14949
|
+
var NOT_COVERED_LAYER1 = "\u5DF2\u77E5\u4E0D\u8986\u76D6 \xB7 \u7B2C\u4E00\u5C42";
|
|
14950
|
+
var NOT_COVERED_LAYER2 = "\u5DF2\u77E5\u4E0D\u8986\u76D6 \xB7 \u7B2C\u4E8C\u5C42";
|
|
14951
|
+
function ledgerOnlySignpost(cmd) {
|
|
14952
|
+
if (cmd !== "verify") return "";
|
|
14953
|
+
return `
|
|
14954
|
+
\u2192 \u8FD9\u53F0\u673A\u5668\u8FDE\u4E0D\u4E0A\u5BA2\u6237\u5185\u7F51\u65F6\uFF0C\u7528 \`seed verify ${LEDGER_ONLY_FLAG}\`\uFF1A\u5B83\u53EA\u51FA**\u53F0\u8D26\u90A3\u4E00\u5C42**\uFF08\u96F6\u7F51\u7EDC\uFF0C\u4E00\u53D1\u8BF7\u6C42\u90FD\u4E0D\u53D1\uFF09\uFF1B**\u5E93\u91CC\u73B0\u5728\u600E\u4E48\u6837\uFF0C\u90A3\u4E00\u8D9F\u4E00\u4E2A\u5B57\u90FD\u6CA1\u95EE** \u2014\u2014 \u5BF9\u8D26\u8FD9\u4E00\u95EE\u5728\u8FD9\u53F0\u673A\u5668\u4E0A\u6CA1\u6709\u7B54\u6848\uFF0C\u522B\u62FF\u5B83\u5F53\u9A8C\u6536\u901A\u8FC7\u3002`;
|
|
14955
|
+
}
|
|
14956
|
+
function isZeroNetwork(args) {
|
|
14957
|
+
return args.ledgerOnly === true;
|
|
14958
|
+
}
|
|
14959
|
+
function askedTheDatabase(recon) {
|
|
14960
|
+
return recon.premises.length > 0;
|
|
14961
|
+
}
|
|
14962
|
+
function indent(text2) {
|
|
14963
|
+
return text2.split("\n").join("\n ");
|
|
14964
|
+
}
|
|
14965
|
+
function verifyAttention(delivery, recon) {
|
|
14966
|
+
const agreeing = new Set(AGREEING_VERDICTS);
|
|
14967
|
+
return [
|
|
14968
|
+
delivery.rows.filter((row) => NEXT_STEP[row.status] !== STEP_NOTHING),
|
|
14969
|
+
[...delivery.plannedWithoutRecord ?? []],
|
|
14970
|
+
(recon.findings ?? []).filter((f) => !agreeing.has(f.verdict))
|
|
14971
|
+
];
|
|
14972
|
+
}
|
|
14973
|
+
function premiseLines(lines, title, premises) {
|
|
14974
|
+
lines.push(`[${title}]`);
|
|
14975
|
+
for (const item of premises) {
|
|
14976
|
+
lines.push(
|
|
14977
|
+
` [${item.ok ? "\u6210\u7ACB " : "\u672A\u6210\u7ACB"}] ${item.code}` + (item.ok ? "" : `\uFF1A${indent(item.detail)}`)
|
|
12631
14978
|
);
|
|
14979
|
+
if (item.hint) lines.push(" \u2192 " + indent(item.hint));
|
|
12632
14980
|
}
|
|
12633
|
-
|
|
12634
|
-
|
|
14981
|
+
}
|
|
14982
|
+
function reconciliationLines(recon, findings) {
|
|
14983
|
+
const lines = [];
|
|
14984
|
+
if (!askedTheDatabase(recon)) {
|
|
14985
|
+
lines.push("[\u5BF9\u8D26] **\u8FD9\u4E00\u8D9F\u6CA1\u95EE\u8FC7\u5E93** \u2014\u2014 \u672C\u547D\u4EE4\u53EA\u51FA\u4E86\u53F0\u8D26\u90A3\u4E00\u5C42\u3002");
|
|
14986
|
+
lines.push(" \u5224\u5B9A\u9010\u6863 / \u4E09\u5F20\u67B6\u5B50 / \u9010\u6863\u4EBA\u8BDD**\u90FD\u4E0D\u5728\u8FD9\u9875\u7EB8\u4E0A**\uFF1A\u5B83\u4EEC\u53EA\u6709\u771F\u56DE\u8BFB\u8FC7\u624D\u4EA7\u5F97\u51FA\u3002");
|
|
14987
|
+
lines.push(
|
|
14988
|
+
` \u26A0\uFE0F \u8FD9**\u4E0D\u662F**\u300C\u67E5\u8FC7\u3001\u4E00\u6761\u5DEE\u5F02\u90FD\u6CA1\u6709\u300D\u3002\u300C\u5E93\u91CC\u73B0\u5728\u600E\u4E48\u6837\u300D\u8FD9\u4E00\u95EE\u7684\u4E0B\u573A\uFF0C\u9010\u5B57\u5199\u5728\u4E0B\u9762\u90A3\u4EFD\u300C${NOT_COVERED_LAYER2}\u300D\u7684\u6700\u540E\u4E00\u6761\u91CC\u3002`
|
|
14989
|
+
);
|
|
14990
|
+
return lines;
|
|
14991
|
+
}
|
|
14992
|
+
premiseLines(lines, "\u7B2C\u4E8C\u5C42 \xB7 \u5BF9\u8D26\uFF08\u8D26\u672C\u8BF4\u7684 vs \u5E93\u91CC\u73B0\u5728\u7684\uFF09", recon.premises);
|
|
14993
|
+
if (recon.identity === null || recon.identity === void 0) {
|
|
14994
|
+
lines.push(" \u8EAB\u4EFD\uFF1A**\u8FD9\u4E00\u4EFD\u8BF4\u4E0D\u51FA\u662F\u7528\u8C01\u7684\u8EAB\u4EFD\u8BFB\u7684** \u2014\u2014 \u53EF\u89C1\u8303\u56F4\u968F\u89D2\u8272\u53D8\u3002");
|
|
14995
|
+
} else {
|
|
14996
|
+
lines.push(` \u8EAB\u4EFD\uFF1A${JSON.stringify(recon.identity)}`);
|
|
14997
|
+
}
|
|
14998
|
+
if (recon.findings === null) {
|
|
14999
|
+
lines.push(
|
|
15000
|
+
"[\u5BF9\u8D26] **\u8FD9\u4E00\u95EE\u6CA1\u6709\u7B54\u6848** \u2014\u2014 \u4E0A\u9762\u90A3\u6761\u672A\u6210\u7ACB\u7684\u524D\u63D0\u8BF4\u4E86\u4E3A\u4EC0\u4E48\uFF1B\u9010\u6761\u90A3\u51E0\u683C\u7ED9\u7684\u662F\u300C\u6CA1\u6709\u7B54\u6848\u300D\uFF0C**\u4E0D\u662F**\u300C\u67E5\u8FC7\u3001\u4E00\u6761\u5DEE\u5F02\u90FD\u6CA1\u6709\u300D\u3002"
|
|
15001
|
+
);
|
|
15002
|
+
return lines;
|
|
15003
|
+
}
|
|
15004
|
+
if (recon.byVerdict === null || recon.models === null || recon.verdictWords === null) {
|
|
12635
15005
|
throw new TypeError(
|
|
12636
|
-
|
|
15006
|
+
"reconcile \u7684\u4E94\u4E2A\u7B54\u6848\u683C\u6CA1\u6709\u540C\u751F\u540C\u6B7B\uFF1Afindings \u6709\u503C\u800C " + [
|
|
15007
|
+
recon.byVerdict === null ? "byVerdict" : null,
|
|
15008
|
+
recon.models === null ? "models" : null,
|
|
15009
|
+
recon.verdictWords === null ? "verdictWords" : null
|
|
15010
|
+
].filter(Boolean).join("\u3001") + " \u662F null \u2014\u2014 \u8FD9\u662F\u5F15\u64CE\u7684\u4E0D\u53D8\u91CF\uFF0C\u6E32\u67D3\u5C42\u4E0D\u66FF\u5B83\u515C\u5E95"
|
|
12637
15011
|
);
|
|
12638
15012
|
}
|
|
12639
|
-
|
|
15013
|
+
lines.push("[\u5BF9\u8D26] \u9010\u4E2A\u6A21\u578B\u56DE\u8BFB\u5230\u4E86\u4EC0\u4E48\uFF1A");
|
|
15014
|
+
for (const model of recon.models) {
|
|
15015
|
+
lines.push(
|
|
15016
|
+
` \xB7 ${model.model} \u4E1A\u52A1\u952E\u5B57\u6BB5=${model.keyFields && model.keyFields.length ? JSON.stringify(model.keyFields) : "\uFF08\u8BA1\u5212\u91CC\u95EE\u4E0D\u51FA\uFF09"} \u53EF\u89C1\u603B\u6570=${model.visibleTotal === null ? "\uFF08\u6CA1\u5EFA\u6210\u7D22\u5F15\uFF09" : model.visibleTotal} \u53D6\u6570\u8BF7\u6C42=${model.pages === null ? "\uFF08\u6CA1\u53D1\u8FC7\uFF09" : model.pages} ${model.problem ?? ""}`.trimEnd()
|
|
15017
|
+
);
|
|
15018
|
+
}
|
|
15019
|
+
lines.push(" \u26A0\uFE0F \u53EF\u89C1\u603B\u6570\u662F**\u88C1\u526A\u540E**\u7684\u6570\uFF08\u67E5\u8BE2\u5F15\u64CE\u5148\u6CE8\u5165\u6743\u9650\u8FC7\u6EE4\u518D\u8BA1\u6570\uFF09\uFF0C\u5B83\u8BF4\u7684\u662F\u300C\u8FD9\u4E2A\u8D26\u53F7\u770B\u5F97\u89C1\u51E0\u884C\u300D\u3002");
|
|
15020
|
+
lines.push(` \u5224\u5B9A\u9010\u6863\uFF08\u5171 ${recon.findings.length} \u884C\uFF09\uFF1A`);
|
|
15021
|
+
for (const [verdict, count] of Object.entries(recon.byVerdict)) {
|
|
15022
|
+
lines.push(` \xB7 ${verdict}\uFF1A${count} \u884C`);
|
|
15023
|
+
}
|
|
15024
|
+
lines.push(" \u6709\u884C\u843D\u8FDB\u53BB\u7684\u6BCF\u4E00\u6863\uFF0C\u9010\u6863\u8BF4\u6E05\u5B83\u662F\u4EC0\u4E48\u610F\u601D\uFF1A");
|
|
15025
|
+
for (const [verdict, count] of Object.entries(recon.byVerdict)) {
|
|
15026
|
+
if (!count) continue;
|
|
15027
|
+
lines.push(` \xB7 ${verdict}\uFF1A${recon.verdictWords[verdict]}`);
|
|
15028
|
+
}
|
|
15029
|
+
lines.push(` \u8981\u4EBA\u770B\u7684 ${findings.length} \u884C\uFF08\u5224\u5B9A\u4E0D\u843D\u5728\u300C\u5BF9\u5F97\u4E0A\u300D\u90A3\u5F20\u67B6\u5B50\u4E0A\u7684\uFF09${findings.length ? "\uFF1A" : "\u3002"}`);
|
|
15030
|
+
for (const f of findings) {
|
|
15031
|
+
lines.push(
|
|
15032
|
+
` - ${f.model} ${JSON.stringify(f.businessKey)} \u8D26\u672C\u8BF4 ${f.ledgerStatus} / \u5E93\u91CC\u73B0\u5728 ${f.serverNow || "\uFF08\u6CA1\u8BFB\u56DE\u503C \u2014\u2014 \u662F\u54EA\u4E00\u79CD\u770B\u53F3\u8FB9\u7684\u5224\u5B9A\uFF09"} \u21D2 ${f.verdict}`
|
|
15033
|
+
);
|
|
15034
|
+
}
|
|
15035
|
+
return lines;
|
|
12640
15036
|
}
|
|
12641
|
-
function
|
|
12642
|
-
const
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
}
|
|
15037
|
+
function verifyText(delivery, recon) {
|
|
15038
|
+
const lines = [
|
|
15039
|
+
`\u4EA4\u4ED8\u8BC1\u636E\u94FE${askedTheDatabase(recon) ? "" : "\uFF08**\u4EC5\u53F0\u8D26\u90A3\u4E00\u5C42 \xB7 \u8FD9\u4E00\u8D9F\u6CA1\u95EE\u8FC7\u5E93**\uFF09"}\uFF1A${delivery.label}`
|
|
15040
|
+
];
|
|
15041
|
+
premiseLines(lines, "\u7B2C\u4E00\u5C42 \xB7 \u53F0\u8D26\u4E0E\u8BA1\u5212\uFF08\u96F6\u7F51\u7EDC\uFF09", delivery.premises);
|
|
15042
|
+
lines.push(`[\u53F0\u8D26] **\u53F0\u8D26\u53E3\u5F84 \xB7 \u5386\u8F6E\u7D2F\u8BA1**\uFF08\u540C\u4E00\u4E2A\u4E1A\u52A1\u952E\u6700\u540E\u4E00\u6761\u8D62\uFF09\uFF0C\u5171 ${delivery.rows.length} \u884C`);
|
|
15043
|
+
for (const [status, count] of Object.entries(delivery.byStatus)) {
|
|
15044
|
+
lines.push(` \xB7 ${status}\uFF1A${count} \u884C`);
|
|
15045
|
+
}
|
|
15046
|
+
const [rows, planned, findings] = verifyAttention(delivery, recon);
|
|
15047
|
+
lines.push(` \u8981\u4EBA\u770B\u7684 ${rows.length} \u884C\uFF08\u4E0B\u4E00\u6B65\u4E0D\u662F\u300C\u4E0D\u5FC5\u518D\u52A8\u300D\u7684\u90A3\u4E9B\uFF09${rows.length ? "\uFF1A" : "\u3002"}`);
|
|
15048
|
+
for (const row of rows) {
|
|
15049
|
+
lines.push(
|
|
15050
|
+
` - ${row.model} ${JSON.stringify(row.businessKey)} status=${row.status} \u4E0B\u4E00\u6B65=${NEXT_STEP[row.status]}`
|
|
15051
|
+
);
|
|
15052
|
+
}
|
|
15053
|
+
if (delivery.plannedWithoutRecord === null) {
|
|
15054
|
+
lines.push(
|
|
15055
|
+
"[\u8BA1\u5212\u91CC\u6709\u3001\u53F0\u8D26\u91CC\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709] **\u8FD9\u4E00\u95EE\u6CA1\u6709\u7B54\u6848** \u2014\u2014 \u89C1\u4E0A\u9762\u90A3\u6761\u672A\u6210\u7ACB\u7684\u524D\u63D0\u3002\u26A0\uFE0F \u8FD9\u4E00\u683C**\u4E0D\u662F**\u300C\u4E00\u4EF6\u6CA1\u843D\u4E0B\u300D\u3002"
|
|
15056
|
+
);
|
|
15057
|
+
} else {
|
|
15058
|
+
lines.push(
|
|
15059
|
+
`[\u8BA1\u5212\u91CC\u6709\u3001\u53F0\u8D26\u91CC\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709] ${planned.length} \u884C\uFF08\u5DEE\u96C6\u7B97\u8FC7\u4E86\uFF1B\u5DE6\u8FB9\u53EA\u542B**\u8FDB\u5F97\u4E86\u6CE2\u6B21**\u7684\u884C \u2014\u2014 \u5C04\u7A0B\u89C1\u300C${NOT_COVERED_LAYER1}\u300D\uFF09`
|
|
15060
|
+
);
|
|
15061
|
+
for (const row of planned) {
|
|
15062
|
+
lines.push(` - ${row.model} ${JSON.stringify(row.key)} \u6E90\u8868\u7B2C ${row.sourceRowId} \u884C \u8BA1\u5212\u5224\u5B83 ${row.action}`);
|
|
15063
|
+
}
|
|
15064
|
+
}
|
|
15065
|
+
lines.push(
|
|
15066
|
+
`[\u653E\u884C\u8BB0\u5F55] ${delivery.waivers.length} \u7B14\uFF08\u6BCF\u4E00\u7B14\u8BF4\u7684\u662F**\u6574\u6574\u4E00\u8F6E**\u5728\u4EC0\u4E48\u524D\u63D0\u4E0B\u8DD1\u7684\uFF0C\u4E0D\u843D\u5230\u4EFB\u4F55\u4E00\u884C\u5934\u4E0A\uFF1B\u4E0B\u9762\u6BCF\u4E00\u7B14\u91CC\u7684 roundId \u662F**\u8BA1\u5212\u8F6E\u6B21** id\uFF09`
|
|
15067
|
+
);
|
|
15068
|
+
for (const waiver of delivery.waivers) lines.push(" - " + describeWaiver(waiver));
|
|
15069
|
+
lines.push(...reconciliationLines(recon, findings));
|
|
15070
|
+
lines.push(`[${NOT_COVERED_SELF}]`);
|
|
15071
|
+
lines.push(
|
|
15072
|
+
` \xB7 **\u672C\u547D\u4EE4\u4E0D\u843D\u76D8**\uFF1A\u4EA7\u51FA\u7269\u5C31\u662F\u5C4F\u5E55\u4E0A\u8FD9\u4E00\u9875\uFF1B\u8981\u7559\u4E00\u4EFD\u5B58\u6863\uFF0C\u81EA\u5DF1\u91CD\u5B9A\u5411\u4E00\u6B21 \u2014\u2014 \`hcm delivery seed verify --work <work \u76EE\u5F55> ${LEDGER_ONLY_FLAG} > \u4EA4\u4ED8\u8BC1\u636E-<\u65E5\u671F>.txt 2>&1\`\u3002`
|
|
15073
|
+
);
|
|
15074
|
+
lines.push(
|
|
15075
|
+
" \u{1F534} \u522B\u63A5\u7BA1\u9053\u5B58\u6863\uFF08`| tee \u6587\u4EF6`\uFF09\uFF1A\u90A3\u4E4B\u540E\u62FF\u5230\u7684\u9000\u51FA\u7801\u662F tee \u7684\uFF0C**\u6052\u4E3A 0**\uFF0C\u8FD9\u4E00\u8D9F\u5224\u6210\u4EC0\u4E48\u5C31\u4E22\u4E86\u3002"
|
|
15076
|
+
);
|
|
15077
|
+
lines.push(`[${NOT_COVERED_LAYER1}]`);
|
|
15078
|
+
for (const note of delivery.notCovered) lines.push(" \xB7 " + note);
|
|
15079
|
+
lines.push(`[${NOT_COVERED_LAYER2}]`);
|
|
15080
|
+
for (const note of recon.notCovered) lines.push(" \xB7 " + note);
|
|
15081
|
+
return lines.join("\n") + "\n";
|
|
15082
|
+
}
|
|
15083
|
+
function verifyRc(delivery, recon) {
|
|
15084
|
+
if ([...delivery.premises, ...recon.premises].some((p) => !p.ok)) return INIT_EXIT_CODES.premise;
|
|
15085
|
+
const [rows, planned, findings] = verifyAttention(delivery, recon);
|
|
15086
|
+
if (rows.length || planned.length || findings.length) return INIT_EXIT_CODES.blocked;
|
|
15087
|
+
return INIT_EXIT_CODES.clean;
|
|
12662
15088
|
}
|
|
12663
15089
|
|
|
12664
15090
|
// src/fde/seed/risk-io.ts
|
|
@@ -12778,11 +15204,11 @@ function writeRisk(risk, out) {
|
|
|
12778
15204
|
}
|
|
12779
15205
|
|
|
12780
15206
|
// src/fde/gate0/aclass.ts
|
|
12781
|
-
import { existsSync as
|
|
12782
|
-
import * as
|
|
15207
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10, readdirSync as readdirSync3, statSync as statSync9 } from "fs";
|
|
15208
|
+
import * as path18 from "path";
|
|
12783
15209
|
|
|
12784
15210
|
// src/fde/gate0/mapping-artifact.ts
|
|
12785
|
-
import { readFileSync as
|
|
15211
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
12786
15212
|
var MAPPING_ARTIFACT_VERSION = 1;
|
|
12787
15213
|
var MappingArtifactError = class extends Error {
|
|
12788
15214
|
constructor(reason, message) {
|
|
@@ -12800,7 +15226,7 @@ function isRecord6(value) {
|
|
|
12800
15226
|
function readBusinessKeyFields(file) {
|
|
12801
15227
|
let text2;
|
|
12802
15228
|
try {
|
|
12803
|
-
text2 =
|
|
15229
|
+
text2 = readFileSync9(file, "utf8");
|
|
12804
15230
|
} catch (e) {
|
|
12805
15231
|
const code = e?.code;
|
|
12806
15232
|
if (code === "ENOENT") throw new MappingArtifactError("not-found", `\u627E\u4E0D\u5230\u6620\u5C04\u5DE5\u4EF6 ${file}`);
|
|
@@ -12883,13 +15309,13 @@ var REASON_EMPTY = "empty";
|
|
|
12883
15309
|
var CLASS_REASONS = [REASON_UNREAD, REASON_EMPTY];
|
|
12884
15310
|
function unguardedKinds(problems) {
|
|
12885
15311
|
const out = /* @__PURE__ */ new Set();
|
|
12886
|
-
for (const
|
|
12887
|
-
if (!SCOPES.includes(
|
|
15312
|
+
for (const problem6 of problems) {
|
|
15313
|
+
if (!SCOPES.includes(problem6.scope)) {
|
|
12888
15314
|
throw new Error(
|
|
12889
|
-
`\u53F0\u8D26\u7684 scope \u53EA\u6709 ${SCOPES.join("/")} \u4E24\u4E2A\u53D6\u503C\uFF0C\u62FF\u5230\u7684\u662F ${JSON.stringify(
|
|
15315
|
+
`\u53F0\u8D26\u7684 scope \u53EA\u6709 ${SCOPES.join("/")} \u4E24\u4E2A\u53D6\u503C\uFF0C\u62FF\u5230\u7684\u662F ${JSON.stringify(problem6.scope)}\uFF08${problem6.message}\uFF09`
|
|
12890
15316
|
);
|
|
12891
15317
|
}
|
|
12892
|
-
if (
|
|
15318
|
+
if (problem6.scope === CLASS_SCOPE) for (const kind of problem6.kinds) out.add(kind);
|
|
12893
15319
|
}
|
|
12894
15320
|
return out;
|
|
12895
15321
|
}
|
|
@@ -12911,10 +15337,10 @@ function scalarsWithin(value) {
|
|
|
12911
15337
|
}
|
|
12912
15338
|
function readText(file, kinds, scope, problems) {
|
|
12913
15339
|
try {
|
|
12914
|
-
return
|
|
15340
|
+
return readFileSync10(file, "utf8");
|
|
12915
15341
|
} catch (e) {
|
|
12916
15342
|
const code = e?.code;
|
|
12917
|
-
const name =
|
|
15343
|
+
const name = path18.basename(file);
|
|
12918
15344
|
problems.push({
|
|
12919
15345
|
scope,
|
|
12920
15346
|
reason: REASON_UNREAD,
|
|
@@ -12927,7 +15353,7 @@ function readText(file, kinds, scope, problems) {
|
|
|
12927
15353
|
function readJsonl(file, kinds, scope, problems) {
|
|
12928
15354
|
const text2 = readText(file, kinds, scope, problems);
|
|
12929
15355
|
if (text2 === null) return [];
|
|
12930
|
-
const name =
|
|
15356
|
+
const name = path18.basename(file);
|
|
12931
15357
|
const rows = [];
|
|
12932
15358
|
text2.split("\n").forEach((raw, i) => {
|
|
12933
15359
|
const line = raw.trim();
|
|
@@ -12968,13 +15394,13 @@ function readJson(file, kinds, scope, problems) {
|
|
|
12968
15394
|
scope,
|
|
12969
15395
|
reason: REASON_UNREAD,
|
|
12970
15396
|
kinds,
|
|
12971
|
-
message: `\u4EA7\u7269 ${
|
|
15397
|
+
message: `\u4EA7\u7269 ${path18.basename(file)} \u4E0D\u662F\u5408\u6CD5 JSON\uFF08${String(e)}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
|
|
12972
15398
|
});
|
|
12973
15399
|
return UNREADABLE;
|
|
12974
15400
|
}
|
|
12975
15401
|
}
|
|
12976
15402
|
function listUnder(payload, key, file, kinds, scope, problems) {
|
|
12977
|
-
const name =
|
|
15403
|
+
const name = path18.basename(file);
|
|
12978
15404
|
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
12979
15405
|
problems.push({
|
|
12980
15406
|
scope,
|
|
@@ -13010,7 +15436,7 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
13010
15436
|
const problems = [];
|
|
13011
15437
|
const out = Object.fromEntries(ACLASS_KINDS.map((k) => [k, /* @__PURE__ */ new Set()]));
|
|
13012
15438
|
for (const row of readJsonl(
|
|
13013
|
-
|
|
15439
|
+
path18.join(root, ...FIELDS_INDEX),
|
|
13014
15440
|
["fieldKey", "fieldLabel", "caliber"],
|
|
13015
15441
|
CLASS_SCOPE,
|
|
13016
15442
|
problems
|
|
@@ -13026,7 +15452,7 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
13026
15452
|
}
|
|
13027
15453
|
}
|
|
13028
15454
|
for (const row of readJsonl(
|
|
13029
|
-
|
|
15455
|
+
path18.join(root, ...ENUM_MIRROR),
|
|
13030
15456
|
["enumValue"],
|
|
13031
15457
|
CLASS_SCOPE,
|
|
13032
15458
|
problems
|
|
@@ -13040,7 +15466,7 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
13040
15466
|
}
|
|
13041
15467
|
}
|
|
13042
15468
|
}
|
|
13043
|
-
const rosterPath =
|
|
15469
|
+
const rosterPath = path18.join(root, ...MODEL_ROSTER);
|
|
13044
15470
|
const roster = readJson(rosterPath, ["modelName"], CLASS_SCOPE, problems);
|
|
13045
15471
|
if (roster !== UNREADABLE) {
|
|
13046
15472
|
const rows = listUnder(roster, "models", rosterPath, ["modelName"], CLASS_SCOPE, problems);
|
|
@@ -13068,11 +15494,11 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
13068
15494
|
});
|
|
13069
15495
|
}
|
|
13070
15496
|
}
|
|
13071
|
-
const valueDomain =
|
|
13072
|
-
if (
|
|
15497
|
+
const valueDomain = path18.join(root, VALUE_DOMAIN_DIR);
|
|
15498
|
+
if (existsSync10(valueDomain) && statSync9(valueDomain).isDirectory()) {
|
|
13073
15499
|
const tables = readdirSync3(valueDomain).filter((f) => f.endsWith(".json") && !RESERVED_FILENAMES.includes(f)).sort();
|
|
13074
15500
|
for (const name of tables) {
|
|
13075
|
-
const file =
|
|
15501
|
+
const file = path18.join(valueDomain, name);
|
|
13076
15502
|
const payload = readJson(file, ["codeValue"], ENTRY_SCOPE, problems);
|
|
13077
15503
|
if (payload === UNREADABLE) continue;
|
|
13078
15504
|
for (const row of listUnder(payload, "rows", file, ["codeValue"], ENTRY_SCOPE, problems)) {
|
|
@@ -13138,8 +15564,8 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
13138
15564
|
}
|
|
13139
15565
|
|
|
13140
15566
|
// src/fde/gate0/facts.ts
|
|
13141
|
-
import { existsSync as
|
|
13142
|
-
import * as
|
|
15567
|
+
import { existsSync as existsSync11, readFileSync as readFileSync11 } from "fs";
|
|
15568
|
+
import * as path19 from "path";
|
|
13143
15569
|
var REGISTRY_SCOPE = "registry";
|
|
13144
15570
|
var ENTRY_SCOPE2 = "entry";
|
|
13145
15571
|
var REASON_NO_ENTRIES = "no-entries";
|
|
@@ -13221,9 +15647,9 @@ function loadProtocolFacts(entries = PROTOCOL_FACTS, options = {}) {
|
|
|
13221
15647
|
return;
|
|
13222
15648
|
}
|
|
13223
15649
|
if (probeRoot !== void 0) {
|
|
13224
|
-
const file =
|
|
15650
|
+
const file = path19.join(probeRoot, shape.groups.file);
|
|
13225
15651
|
const mark = `${PROBE_MARK_PREFIX} ${shape.groups.mark}`;
|
|
13226
|
-
const found =
|
|
15652
|
+
const found = existsSync11(file) && readFileSync11(file, "utf8").includes(mark);
|
|
13227
15653
|
if (!found) {
|
|
13228
15654
|
problems.push({
|
|
13229
15655
|
scope: ENTRY_SCOPE2,
|
|
@@ -13241,8 +15667,8 @@ function loadProtocolFacts(entries = PROTOCOL_FACTS, options = {}) {
|
|
|
13241
15667
|
}
|
|
13242
15668
|
|
|
13243
15669
|
// src/fde/gate0/scan.ts
|
|
13244
|
-
import { readFileSync as
|
|
13245
|
-
import * as
|
|
15670
|
+
import { readFileSync as readFileSync12, readdirSync as readdirSync4, readlinkSync, statSync as statSync10 } from "fs";
|
|
15671
|
+
import * as path20 from "path";
|
|
13246
15672
|
var CHANNEL_ACLASS = "aclass";
|
|
13247
15673
|
var CHANNEL_ARTIFACT = "artifact-path";
|
|
13248
15674
|
var CHANNEL_UNREGISTERED = "protocol-unregistered";
|
|
@@ -13305,7 +15731,7 @@ var PRODUCT_FILE_RE = new RegExp(
|
|
|
13305
15731
|
);
|
|
13306
15732
|
var PLACEHOLDER_RE2 = /\{[A-Za-z0-9_]*\}/g;
|
|
13307
15733
|
var ARTIFACT_ROOT = ".hcmnx";
|
|
13308
|
-
var
|
|
15734
|
+
var RECON_DIRNAME2 = "recon";
|
|
13309
15735
|
var RECON_SEGMENTS_BELOW_ROOT = 2;
|
|
13310
15736
|
var PRODUCT_RELATIVE_SHAPES = [
|
|
13311
15737
|
["index", ".md"],
|
|
@@ -13381,10 +15807,10 @@ function checkGaps(gaps) {
|
|
|
13381
15807
|
return [...gaps];
|
|
13382
15808
|
}
|
|
13383
15809
|
function checkPremise(problems) {
|
|
13384
|
-
for (const
|
|
13385
|
-
if (!PREMISE_REASONS.includes(
|
|
15810
|
+
for (const problem6 of problems) {
|
|
15811
|
+
if (!PREMISE_REASONS.includes(problem6.reason)) {
|
|
13386
15812
|
throw new Error(
|
|
13387
|
-
`\u524D\u63D0\u7EA7\u53F0\u8D26\u7684 reason \u4E0D\u5728\u53D6\u503C\u57DF\u91CC\uFF1A${JSON.stringify(
|
|
15813
|
+
`\u524D\u63D0\u7EA7\u53F0\u8D26\u7684 reason \u4E0D\u5728\u53D6\u503C\u57DF\u91CC\uFF1A${JSON.stringify(problem6.reason)}\uFF08${problem6.message}\uFF09`
|
|
13388
15814
|
);
|
|
13389
15815
|
}
|
|
13390
15816
|
}
|
|
@@ -13465,7 +15891,7 @@ function artifactReason(token2) {
|
|
|
13465
15891
|
const last = segments[segments.length - 1] ?? "";
|
|
13466
15892
|
if (head.includes(ARTIFACT_ROOT)) return REASON_PRODUCT_TREE_PATH;
|
|
13467
15893
|
for (let i = 0; i < head.length; i += 1) {
|
|
13468
|
-
if (head[i] ===
|
|
15894
|
+
if (head[i] === RECON_DIRNAME2 && segments.length - i - 1 > RECON_SEGMENTS_BELOW_ROOT) {
|
|
13469
15895
|
return REASON_PRODUCT_TREE_PATH;
|
|
13470
15896
|
}
|
|
13471
15897
|
}
|
|
@@ -13565,9 +15991,9 @@ var Matcher = class {
|
|
|
13565
15991
|
};
|
|
13566
15992
|
function classReasons(problems) {
|
|
13567
15993
|
const out = /* @__PURE__ */ new Map();
|
|
13568
|
-
for (const
|
|
13569
|
-
if (
|
|
13570
|
-
for (const kind of
|
|
15994
|
+
for (const problem6 of problems ?? []) {
|
|
15995
|
+
if (problem6.scope === CLASS_SCOPE) {
|
|
15996
|
+
for (const kind of problem6.kinds) out.set(kind, problem6.reason);
|
|
13571
15997
|
}
|
|
13572
15998
|
}
|
|
13573
15999
|
return out;
|
|
@@ -13720,7 +16146,7 @@ function judgeProtocol(token2, reason, shape, lineno, rel, matcher, index, reds)
|
|
|
13720
16146
|
}
|
|
13721
16147
|
function scan(skillRoot, aclass, facts, options = {}) {
|
|
13722
16148
|
const reds = [];
|
|
13723
|
-
const
|
|
16149
|
+
const premise2 = [];
|
|
13724
16150
|
const gaps = [];
|
|
13725
16151
|
const scanned = [];
|
|
13726
16152
|
const matcher = new Matcher(aclass);
|
|
@@ -13738,44 +16164,44 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
13738
16164
|
}
|
|
13739
16165
|
why = ACLASS_EMPTY_WHY[reason];
|
|
13740
16166
|
}
|
|
13741
|
-
|
|
16167
|
+
premise2.push({
|
|
13742
16168
|
reason: REASON_ACLASS_EMPTY,
|
|
13743
16169
|
message: `A \u7C7B\u5B50\u96C6 ${kind} \u662F\u7A7A\u7684${why} \u21D2 \u95E8 0 \u5BF9\u8FD9\u4E00\u7C7B**\u6052\u7EFF**\uFF0C\u8FD9\u4E00\u8F6E\u7684\u7EFF\u4E0D\u7B97\u6570`
|
|
13744
16170
|
});
|
|
13745
16171
|
}
|
|
13746
|
-
for (const
|
|
13747
|
-
if (
|
|
13748
|
-
|
|
16172
|
+
for (const problem6 of options.aclassProblems ?? []) {
|
|
16173
|
+
if (problem6.scope !== ENTRY_SCOPE) continue;
|
|
16174
|
+
premise2.push({
|
|
13749
16175
|
reason: REASON_ACLASS_PARTIALLY_UNREAD,
|
|
13750
|
-
message: `A \u7C7B\u5B50\u96C6 ${
|
|
16176
|
+
message: `A \u7C7B\u5B50\u96C6 ${problem6.kinds.join("/")} \u5C11\u4E86\u4E00\u90E8\u5206\uFF08${problem6.reason}\uFF09\uFF1A${problem6.message} \u21D2 \u5C11\u6389\u7684\u90A3\u90E8\u5206\u95E8 0 \u5224\u4E0D\u51FA\u6765\uFF0C\u8FD9\u4E00\u8F6E\u7684\u7EFF\u4E0D\u7B97\u6570`
|
|
13751
16177
|
});
|
|
13752
16178
|
}
|
|
13753
16179
|
let factsProblems = options.factsProblems;
|
|
13754
16180
|
if (factsProblems === void 0) {
|
|
13755
|
-
|
|
16181
|
+
premise2.push({
|
|
13756
16182
|
reason: REASON_CHANNEL_FOUR_UNCHECKED,
|
|
13757
16183
|
message: "\u6CA1\u6709\u628A loadProtocolFacts \u7684\u53F0\u8D26\u4F20\u8FDB\u6765 \u21D2 \u901A\u9053\u56DB\uFF08\u767B\u8BB0\u9879\u88AB\u62D2\uFF09\u4E00\u6761\u90FD\u6CA1\u67E5\u8FC7\u2014\u2014\u300C\u767B\u8BB0\u518C\u5E72\u51C0\u300D\u4E0E\u300C\u6CA1\u67E5\u767B\u8BB0\u518C\u300D\u5728\u8FD4\u56DE\u503C\u4E0A\u540C\u5F62"
|
|
13758
16184
|
});
|
|
13759
16185
|
factsProblems = [];
|
|
13760
16186
|
}
|
|
13761
|
-
for (const
|
|
13762
|
-
if (
|
|
13763
|
-
|
|
16187
|
+
for (const problem6 of factsProblems) {
|
|
16188
|
+
if (problem6.scope === REGISTRY_SCOPE && PREMISE_REGISTRY_REASONS.includes(problem6.reason)) {
|
|
16189
|
+
premise2.push({
|
|
13764
16190
|
reason: REASON_REGISTRY,
|
|
13765
|
-
message: `\u767B\u8BB0\u518C\u8FD9\u4E00\u5C42\u6CA1\u7ACB\u4F4F\uFF08${
|
|
16191
|
+
message: `\u767B\u8BB0\u518C\u8FD9\u4E00\u5C42\u6CA1\u7ACB\u4F4F\uFF08${problem6.reason}\uFF09\uFF1A${problem6.message} \u21D2 \u8C41\u514D\u901A\u9053 P \u4E0D\u53EF\u4FE1`
|
|
13766
16192
|
});
|
|
13767
16193
|
}
|
|
13768
16194
|
}
|
|
13769
|
-
for (const
|
|
13770
|
-
if (
|
|
16195
|
+
for (const problem6 of factsProblems) {
|
|
16196
|
+
if (problem6.scope === REGISTRY_SCOPE) continue;
|
|
13771
16197
|
reds.push({
|
|
13772
16198
|
channel: CHANNEL_NO_PROBE,
|
|
13773
16199
|
reason: REASON_REJECTED_REGISTRATION,
|
|
13774
|
-
token:
|
|
16200
|
+
token: problem6.token ?? `(\u7B2C${problem6.index}\u6761)`,
|
|
13775
16201
|
path: null,
|
|
13776
16202
|
line: 0,
|
|
13777
16203
|
kinds: [],
|
|
13778
|
-
message: `\u767B\u8BB0\u518C\u7B2C ${
|
|
16204
|
+
message: `\u767B\u8BB0\u518C\u7B2C ${problem6.index} \u6761\u88AB\u62D2\uFF08${problem6.reason}\uFF09\uFF1A${problem6.message}`
|
|
13779
16205
|
});
|
|
13780
16206
|
}
|
|
13781
16207
|
for (const token2 of [...facts].sort()) {
|
|
@@ -13793,7 +16219,7 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
13793
16219
|
}
|
|
13794
16220
|
let files = [];
|
|
13795
16221
|
if (!isDirectory(skillRoot)) {
|
|
13796
|
-
|
|
16222
|
+
premise2.push({
|
|
13797
16223
|
reason: REASON_NO_SKILL_ROOT,
|
|
13798
16224
|
message: `\u626B\u63CF\u9762 ${skillRoot} \u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55 \u21D2 \u4E00\u4E2A\u5B57\u90FD\u6CA1\u626B\u8FC7\uFF08\u8FD9\u4E0D\u662F\u300C\u626B\u8FC7\u3001\u5E72\u51C0\u300D\uFF09`
|
|
13799
16225
|
});
|
|
@@ -13807,13 +16233,13 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
13807
16233
|
} catch {
|
|
13808
16234
|
target = "(\u8BFB\u4E0D\u51FA\u94FE\u63A5\u76EE\u6807)";
|
|
13809
16235
|
}
|
|
13810
|
-
|
|
16236
|
+
premise2.push({
|
|
13811
16237
|
reason: REASON_SYMLINK_NOT_SCANNED,
|
|
13812
|
-
message: `${
|
|
16238
|
+
message: `${path20.relative(skillRoot, link)} \u662F\u4E00\u4E2A\u7B26\u53F7\u94FE\u63A5\uFF08\u6307\u5411 ${JSON.stringify(target)}\uFF09\u21D2 \u95E8 0 **\u6CA1\u6709\u987A\u7740\u5B83\u626B\u8FC7\u4E00\u4E2A\u5B57**\uFF0C\u8FD9\u4E00\u8F6E\u7684\u7EFF\u4E0D\u7B97\u6570\u3002\u51FA\u8DEF\uFF1A\u628A\u8FD9\u6761\u94FE\u4ECE skill \u91CC\u53BB\u6389 \u2014\u2014 \u94FE\u540E\u9762\u90A3\u4EFD\u5185\u5BB9\u672C\u8BE5\u88AB\u5224\u5C31 \`cp -RL\` \u62F7\u6210\u771F\u5185\u5BB9\uFF08\u26A0\uFE0F \u73AF\u8DEF\u4E0E\u65AD\u94FE\u4E0A\u5B83\u4F1A\u5F53\u573A\u62A5\u9519\uFF0C\u90A3\u4E24\u79CD\u76F4\u63A5\u5220\uFF09\uFF1B\u5185\u5BB9\u5DF2\u7ECF\u5728 skill \u91CC\uFF08\u6307\u5411\u540C\u6811\u7684\u522B\u540D\uFF09\u4E5F\u76F4\u63A5\u5220\u3002**\u4E0D\u8DDF\u968F**\u662F\u523B\u610F\u7684 \u2014\u2014 \u8DDF\u8FC7\u53BB\u4F1A\u8FDE\u4E0A\u73AF\u8DEF\u3001\u6216\u8D8A\u51FA skill \u76EE\u5F55\u626B\u5230\u65E0\u5173\u6587\u4EF6`
|
|
13813
16239
|
});
|
|
13814
16240
|
}
|
|
13815
16241
|
if (files.length === 0) {
|
|
13816
|
-
|
|
16242
|
+
premise2.push({
|
|
13817
16243
|
reason: REASON_NOTHING_SCANNED,
|
|
13818
16244
|
message: `\u626B\u63CF\u9762 ${skillRoot} \u5728\u76D8\u4E0A\uFF0C\u4F46\u91CC\u9762\u4E00\u4E2A\u6587\u4EF6\u90FD\u6CA1\u6709 \u2014\u2014 \u67E5\u8FC7\u4E14\u4E3A\u7A7A`
|
|
13819
16245
|
});
|
|
@@ -13822,15 +16248,15 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
13822
16248
|
for (const file of files) {
|
|
13823
16249
|
let text2;
|
|
13824
16250
|
try {
|
|
13825
|
-
text2 =
|
|
16251
|
+
text2 = readFileSync12(file, "utf8");
|
|
13826
16252
|
} catch (e) {
|
|
13827
|
-
|
|
16253
|
+
premise2.push({
|
|
13828
16254
|
reason: REASON_FILE_UNREADABLE,
|
|
13829
16255
|
message: `${file} \u8BFB\u4E0D\u52A8\uFF08${String(e)}\uFF09\u21D2 \u5224\u4E0D\u4E86\u5B83\u5E72\u4E0D\u5E72\u51C0\uFF0C\u95E8 0 \u4E0D\u80FD\u5BF9\u7740\u5B83\u8BF4\u7EFF`
|
|
13830
16256
|
});
|
|
13831
16257
|
continue;
|
|
13832
16258
|
}
|
|
13833
|
-
const rel =
|
|
16259
|
+
const rel = path20.relative(skillRoot, file);
|
|
13834
16260
|
scanned.push(rel);
|
|
13835
16261
|
text2.split("\n").forEach((line, i) => {
|
|
13836
16262
|
judgeLine(line, i + 1, rel, matcher, index, reds, gaps);
|
|
@@ -13852,12 +16278,12 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
13852
16278
|
channels,
|
|
13853
16279
|
scanned,
|
|
13854
16280
|
gaps: checkGaps(gaps),
|
|
13855
|
-
premise: checkPremise(
|
|
16281
|
+
premise: checkPremise(premise2)
|
|
13856
16282
|
};
|
|
13857
16283
|
}
|
|
13858
16284
|
function isDirectory(target) {
|
|
13859
16285
|
try {
|
|
13860
|
-
return
|
|
16286
|
+
return statSync10(target).isDirectory();
|
|
13861
16287
|
} catch {
|
|
13862
16288
|
return false;
|
|
13863
16289
|
}
|
|
@@ -13867,10 +16293,10 @@ function walk3(root) {
|
|
|
13867
16293
|
const unscannedLinks = [];
|
|
13868
16294
|
const visit = (dir) => {
|
|
13869
16295
|
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
13870
|
-
const full =
|
|
16296
|
+
const full = path20.join(dir, entry.name);
|
|
13871
16297
|
let followed = null;
|
|
13872
16298
|
try {
|
|
13873
|
-
followed =
|
|
16299
|
+
followed = statSync10(full);
|
|
13874
16300
|
} catch {
|
|
13875
16301
|
followed = null;
|
|
13876
16302
|
}
|
|
@@ -13951,8 +16377,8 @@ function buildCarrierResult(carrier, verdict, options = {}) {
|
|
|
13951
16377
|
}
|
|
13952
16378
|
|
|
13953
16379
|
// src/fde/triage/probe.ts
|
|
13954
|
-
import { readFileSync as
|
|
13955
|
-
import * as
|
|
16380
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
16381
|
+
import * as path21 from "path";
|
|
13956
16382
|
var WORKSPACES_PATH = "/api/tenant-extension/workspaces";
|
|
13957
16383
|
var MODELS_REL = "models.json";
|
|
13958
16384
|
var FIELDS_REL = "index/fields.jsonl";
|
|
@@ -13975,10 +16401,10 @@ function unavailableCell(carrier, err) {
|
|
|
13975
16401
|
});
|
|
13976
16402
|
}
|
|
13977
16403
|
function readArtifactJson(dir, rel) {
|
|
13978
|
-
return JSON.parse(
|
|
16404
|
+
return JSON.parse(readFileSync13(path21.join(dir, rel), "utf8"));
|
|
13979
16405
|
}
|
|
13980
16406
|
function readArtifactJsonl(dir, rel) {
|
|
13981
|
-
const body =
|
|
16407
|
+
const body = readFileSync13(path21.join(dir, rel), "utf8");
|
|
13982
16408
|
const rows = [];
|
|
13983
16409
|
for (const line of body.split("\n")) {
|
|
13984
16410
|
const trimmed = line.trim();
|
|
@@ -14133,7 +16559,7 @@ var CONFIG = "CONFIG";
|
|
|
14133
16559
|
function fill(template, value) {
|
|
14134
16560
|
return template.replace("{}", value);
|
|
14135
16561
|
}
|
|
14136
|
-
function
|
|
16562
|
+
function problem5(rule, note) {
|
|
14137
16563
|
return { rule, note };
|
|
14138
16564
|
}
|
|
14139
16565
|
function cellsOf(entry) {
|
|
@@ -14148,13 +16574,13 @@ function withVerdict(cells, want) {
|
|
|
14148
16574
|
function checkR1(entry) {
|
|
14149
16575
|
const out = [];
|
|
14150
16576
|
for (const field of REQUIRED_SECTIONS) {
|
|
14151
|
-
if (!entry[field]) out.push(
|
|
16577
|
+
if (!entry[field]) out.push(problem5("R1", fill(R1_MISSING_SECTION, field)));
|
|
14152
16578
|
}
|
|
14153
16579
|
const cells = cellsOf(entry);
|
|
14154
16580
|
for (const key of CARRIER_KEYS) {
|
|
14155
16581
|
const cell = cells[key];
|
|
14156
16582
|
if (!cell || typeof cell !== "object" || !cell.verdict) {
|
|
14157
|
-
out.push(
|
|
16583
|
+
out.push(problem5("R1", fill(R1_EMPTY_CELL, key)));
|
|
14158
16584
|
}
|
|
14159
16585
|
}
|
|
14160
16586
|
return out;
|
|
@@ -14163,19 +16589,19 @@ function checkR2(entry) {
|
|
|
14163
16589
|
if (entry.verdict !== GAP) return [];
|
|
14164
16590
|
const hits = withVerdict(cellsOf(entry), CARRIER_HIT);
|
|
14165
16591
|
if (hits.length === 0) return [];
|
|
14166
|
-
return [
|
|
16592
|
+
return [problem5("R2", fill(R2_HITS_UNDER_GAP, hits.join("\u3001")))];
|
|
14167
16593
|
}
|
|
14168
16594
|
function checkR3(entry) {
|
|
14169
16595
|
if (entry.verdict !== CONFIG) return [];
|
|
14170
16596
|
if (withVerdict(cellsOf(entry), CARRIER_HIT).length > 0) return [];
|
|
14171
|
-
return [
|
|
16597
|
+
return [problem5("R3", R3_CONFIG_WITHOUT_HIT)];
|
|
14172
16598
|
}
|
|
14173
16599
|
function checkR4(entry) {
|
|
14174
16600
|
if (entry.verdict !== GAP) return [];
|
|
14175
16601
|
const blinds = withVerdict(cellsOf(entry), CARRIER_BLIND);
|
|
14176
16602
|
if (blinds.length === 0) return [];
|
|
14177
16603
|
if (entry.blindAcknowledged) return [];
|
|
14178
|
-
return [
|
|
16604
|
+
return [problem5("R4", fill(R4_BLIND_AS_GAP, blinds.join("\u3001")))];
|
|
14179
16605
|
}
|
|
14180
16606
|
var RULES = [checkR1, checkR2, checkR3, checkR4];
|
|
14181
16607
|
function checkCoherence(entry) {
|
|
@@ -14185,7 +16611,7 @@ function checkCoherence(entry) {
|
|
|
14185
16611
|
}
|
|
14186
16612
|
|
|
14187
16613
|
// src/fde/triage/report.ts
|
|
14188
|
-
var
|
|
16614
|
+
var VERDICTS3 = ["REUSE", "CONFIG", "EXTEND", "GAP"];
|
|
14189
16615
|
var GAP2 = "GAP";
|
|
14190
16616
|
var DEBT_PREFIX = "# DEBT: \u7F3A ";
|
|
14191
16617
|
var DEBT_UNKNOWN = "\uFF08\u8FD8\u8BF4\u4E0D\u51FA\u7F3A\u54EA\u4E2A Action \u2014\u2014 \u7559\u75D5\u5148\uFF0C\u522B\u8BA9\u8FD9\u6761 GAP \u4ECE\u6E05\u5355\u91CC\u6D88\u5931\uFF09";
|
|
@@ -14210,9 +16636,9 @@ function require_(entry, idx) {
|
|
|
14210
16636
|
}
|
|
14211
16637
|
}
|
|
14212
16638
|
const verdict = entry.verdict;
|
|
14213
|
-
if (!
|
|
16639
|
+
if (!VERDICTS3.includes(verdict)) {
|
|
14214
16640
|
throw new Error(
|
|
14215
|
-
`\u7B2C ${idx} \u6761\u7684\u7ED3\u8BBA ${JSON.stringify(verdict)} \u4E0D\u5728\u53D6\u503C\u57DF ${
|
|
16641
|
+
`\u7B2C ${idx} \u6761\u7684\u7ED3\u8BBA ${JSON.stringify(verdict)} \u4E0D\u5728\u53D6\u503C\u57DF ${VERDICTS3.join("\u3001")} \u5185`
|
|
14216
16642
|
);
|
|
14217
16643
|
}
|
|
14218
16644
|
const cells = entry.cells ?? {};
|
|
@@ -14300,12 +16726,19 @@ async function runTriageRound(probe, artifactsDir, entriesIn) {
|
|
|
14300
16726
|
export {
|
|
14301
16727
|
ACLASS_EMPTY_WHY,
|
|
14302
16728
|
ACLASS_KINDS,
|
|
16729
|
+
ADVISORY_CODES,
|
|
16730
|
+
AGREEING_VERDICTS,
|
|
16731
|
+
APPLY_CAVEAT,
|
|
16732
|
+
APPLY_PROBLEM_CODES,
|
|
14303
16733
|
ARTIFACT_ROOT,
|
|
14304
16734
|
ARTIFACT_SUFFIXES,
|
|
14305
16735
|
ARTIFACT_WORDING,
|
|
14306
16736
|
AUTH_INFO_PATH,
|
|
16737
|
+
ApplyInvariantError,
|
|
16738
|
+
ApplyPremiseError,
|
|
14307
16739
|
BLIND_SPOTS,
|
|
14308
16740
|
BLOCKING_CODES,
|
|
16741
|
+
BUCKETS,
|
|
14309
16742
|
CARRIER_BLIND,
|
|
14310
16743
|
CARRIER_HIT,
|
|
14311
16744
|
CARRIER_KEYS,
|
|
@@ -14313,12 +16746,14 @@ export {
|
|
|
14313
16746
|
CARRIER_MISS,
|
|
14314
16747
|
CARRIER_UNAVAILABLE,
|
|
14315
16748
|
CARRIER_VERDICTS,
|
|
16749
|
+
CAUSE_INCOMPLETE_CURRENT,
|
|
14316
16750
|
CHANNELS,
|
|
14317
16751
|
CHANNEL_ACLASS,
|
|
14318
16752
|
CHANNEL_ARTIFACT,
|
|
14319
16753
|
CHANNEL_NO_PROBE,
|
|
14320
16754
|
CHANNEL_REGISTERED_IS_ACLASS,
|
|
14321
16755
|
CHANNEL_UNREGISTERED,
|
|
16756
|
+
CHECK_GROUPS2 as CHECK_GROUPS,
|
|
14322
16757
|
CLASS_REASONS,
|
|
14323
16758
|
CLASS_SCOPE,
|
|
14324
16759
|
CliError,
|
|
@@ -14328,14 +16763,23 @@ export {
|
|
|
14328
16763
|
DEBT_UNKNOWN,
|
|
14329
16764
|
DEFAULT_AGENT_ID,
|
|
14330
16765
|
DEFAULT_SESSION_TTL_SECONDS,
|
|
16766
|
+
PREMISE_CODES4 as DELIVERY_PREMISE_CODES,
|
|
14331
16767
|
DOCTOR_ANCHORS,
|
|
16768
|
+
DRY_RUN_NOTE,
|
|
16769
|
+
DRY_RUN_TAIL,
|
|
16770
|
+
DriftDetected,
|
|
14332
16771
|
ENDPOINT_PREFIXES,
|
|
14333
16772
|
ENTRY_SCOPE,
|
|
14334
16773
|
ENUM_ELEMENT_KEYS,
|
|
16774
|
+
EXEMPTIBLE_CODES,
|
|
16775
|
+
EXEMPTION_CODES,
|
|
16776
|
+
EXEMPTION_REQUIRED_KEYS,
|
|
14335
16777
|
EXTENSION_SOURCE_HEADER,
|
|
14336
16778
|
ExitCode,
|
|
14337
16779
|
FACTS_REASONS,
|
|
14338
16780
|
FOLDED_NOTE,
|
|
16781
|
+
FORCE_STALE_FLAG,
|
|
16782
|
+
FORCE_STALE_FLAG_TEXT,
|
|
14339
16783
|
FULLWIDTH_ALNUM_RANGES,
|
|
14340
16784
|
GAP_CJK_INSIDE_LONGER_RUN,
|
|
14341
16785
|
GAP_NOISE_TOKEN,
|
|
@@ -14344,10 +16788,19 @@ export {
|
|
|
14344
16788
|
HcmClient,
|
|
14345
16789
|
IMPORT_PLAN_FILE,
|
|
14346
16790
|
INIT_EXIT_CODES,
|
|
16791
|
+
JOURNAL_FILE,
|
|
16792
|
+
JOURNAL_STOP_KINDS,
|
|
16793
|
+
JOURNAL_STOP_UNKNOWN,
|
|
16794
|
+
Journal,
|
|
16795
|
+
JournalError,
|
|
14347
16796
|
KIT_CARRY_OVER_KEY,
|
|
14348
16797
|
KIT_CRAWLED_AT_FILE,
|
|
16798
|
+
LEASE_FILE,
|
|
14349
16799
|
LEDGER_MISSING_WORD,
|
|
16800
|
+
LEDGER_ONLY_FLAG,
|
|
14350
16801
|
LayoutContainmentError,
|
|
16802
|
+
Lease,
|
|
16803
|
+
LeaseViolation,
|
|
14351
16804
|
MANIFEST_PATH,
|
|
14352
16805
|
MAPPING_ARTIFACT_VERSION,
|
|
14353
16806
|
MAPPING_FILE,
|
|
@@ -14364,10 +16817,23 @@ export {
|
|
|
14364
16817
|
MappingArtifactError,
|
|
14365
16818
|
MappingError,
|
|
14366
16819
|
Matcher,
|
|
16820
|
+
NETWORK_GATES,
|
|
16821
|
+
NEXT_STEP,
|
|
16822
|
+
NOT_COVERED_LAYER1,
|
|
16823
|
+
NOT_COVERED_LAYER2,
|
|
16824
|
+
NOT_COVERED_SELF,
|
|
14367
16825
|
OFFLINE_COMMANDS,
|
|
14368
16826
|
PASSWORD_CHANGE_REQUIRED,
|
|
16827
|
+
PREMISE_CLIENT,
|
|
16828
|
+
PREMISE_IDENTITY,
|
|
16829
|
+
PREMISE_JOURNAL_HAS_ENTRIES,
|
|
16830
|
+
PREMISE_JOURNAL_ON_DISK,
|
|
16831
|
+
PREMISE_KEY_FIELDS,
|
|
16832
|
+
PREMISE_PLAN_READABLE,
|
|
14369
16833
|
PREMISE_REASONS,
|
|
14370
16834
|
PREMISE_REGISTRY_REASONS,
|
|
16835
|
+
PREMISE_ROWS_TO_CHECK,
|
|
16836
|
+
PREMISE_UNMET,
|
|
14371
16837
|
PROACTIVE_REFRESH_MARGIN_SECONDS,
|
|
14372
16838
|
PROBE_MARK_PREFIX,
|
|
14373
16839
|
PRODUCT_RELATIVE_SHAPES,
|
|
@@ -14375,6 +16841,7 @@ export {
|
|
|
14375
16841
|
PROTOCOL_FACTS,
|
|
14376
16842
|
PlanReadError,
|
|
14377
16843
|
RC_DECIDING_FIELDS,
|
|
16844
|
+
RC_DECIDING_REPORT_FIELDS,
|
|
14378
16845
|
REASON_DUPLICATE_TOKEN,
|
|
14379
16846
|
REASON_EMPTY,
|
|
14380
16847
|
REASON_NO_ENTRIES,
|
|
@@ -14382,12 +16849,14 @@ export {
|
|
|
14382
16849
|
REASON_PROBE_SHAPE,
|
|
14383
16850
|
REASON_PROBE_UNVERIFIED,
|
|
14384
16851
|
REASON_UNREAD,
|
|
14385
|
-
|
|
16852
|
+
VERDICTS2 as RECONCILE_VERDICTS,
|
|
16853
|
+
RECON_DIRNAME2 as RECON_DIRNAME,
|
|
14386
16854
|
RECON_SEGMENTS_BELOW_ROOT,
|
|
14387
16855
|
RED_REASONS,
|
|
14388
16856
|
REGISTRY_REASONS,
|
|
14389
16857
|
REGISTRY_SCOPE,
|
|
14390
16858
|
REQUIRED_SECTIONS,
|
|
16859
|
+
RISK_CODES,
|
|
14391
16860
|
RISK_FILE,
|
|
14392
16861
|
ROUND_ANCHORS,
|
|
14393
16862
|
ROUND_EXIT_CODES,
|
|
@@ -14401,20 +16870,35 @@ export {
|
|
|
14401
16870
|
SCOPES,
|
|
14402
16871
|
SDK_VERSION,
|
|
14403
16872
|
SEGMENT_SEPARATOR,
|
|
16873
|
+
STATUSES,
|
|
16874
|
+
STEP_NOTHING,
|
|
16875
|
+
STEP_STOP,
|
|
14404
16876
|
CONFIG as TRIAGE_CONFIG,
|
|
14405
16877
|
GAP as TRIAGE_GAP,
|
|
14406
|
-
|
|
16878
|
+
VERDICTS3 as TRIAGE_VERDICTS,
|
|
14407
16879
|
TargetModelNotFound,
|
|
14408
16880
|
TokenStore,
|
|
16881
|
+
VERDICTS,
|
|
16882
|
+
VERDICT_DIVERGED,
|
|
16883
|
+
VERDICT_INCOMPARABLE,
|
|
16884
|
+
VERDICT_SAME,
|
|
16885
|
+
VERDICT_WORDS,
|
|
14409
16886
|
VERSION_PATH,
|
|
16887
|
+
WAIVER_REPLAY,
|
|
14410
16888
|
WARNED_ROUND_STATES,
|
|
14411
16889
|
WORKSPACES_PATH,
|
|
14412
16890
|
WORK_DIRNAME,
|
|
14413
16891
|
WsClient,
|
|
14414
16892
|
absoluteDownloadUrl,
|
|
16893
|
+
acquireLease,
|
|
14415
16894
|
adminResetPassword,
|
|
16895
|
+
applyPlan,
|
|
16896
|
+
applyRc,
|
|
16897
|
+
applyReportText,
|
|
16898
|
+
applyReportToJson,
|
|
14416
16899
|
archiveDir,
|
|
14417
16900
|
artifactReason,
|
|
16901
|
+
askedTheDatabase,
|
|
14418
16902
|
assertSafeReferencePath,
|
|
14419
16903
|
assertSafeSkillFilePath,
|
|
14420
16904
|
assertSafeSkillId,
|
|
@@ -14424,10 +16908,12 @@ export {
|
|
|
14424
16908
|
buildAnswer,
|
|
14425
16909
|
buildCarrierResult,
|
|
14426
16910
|
buildConfirm,
|
|
16911
|
+
buildDeliveryRun,
|
|
14427
16912
|
buildInterrupt,
|
|
14428
16913
|
buildMiniAppTemplateFiles,
|
|
14429
16914
|
buildMiniPreviewTargets,
|
|
14430
16915
|
buildMiniVerifyAgentReport,
|
|
16916
|
+
buildReconciliation,
|
|
14431
16917
|
buildReject,
|
|
14432
16918
|
buildResumeSummary,
|
|
14433
16919
|
buildSteer,
|
|
@@ -14458,9 +16944,11 @@ export {
|
|
|
14458
16944
|
deleteIdentity,
|
|
14459
16945
|
deleteTenantMeta,
|
|
14460
16946
|
deleteWorkspaceFile,
|
|
16947
|
+
deliveryRunFields,
|
|
14461
16948
|
deriveAclass,
|
|
14462
16949
|
deriveNamelessToolLabel,
|
|
14463
16950
|
describePrincipal,
|
|
16951
|
+
describeWaiver,
|
|
14464
16952
|
detectDelegationPause,
|
|
14465
16953
|
detectDirectInteractionPending,
|
|
14466
16954
|
detectPasswordChangeChallenge,
|
|
@@ -14468,10 +16956,12 @@ export {
|
|
|
14468
16956
|
displayWidth,
|
|
14469
16957
|
downloadDocument,
|
|
14470
16958
|
endpointsIn,
|
|
16959
|
+
enforceDriftGate,
|
|
14471
16960
|
ensureSessionFresh,
|
|
14472
16961
|
envDir,
|
|
14473
16962
|
envFile,
|
|
14474
16963
|
envsDir,
|
|
16964
|
+
existingJournalStop,
|
|
14475
16965
|
exitCode,
|
|
14476
16966
|
exitCodeFor,
|
|
14477
16967
|
extractNextSteps,
|
|
@@ -14503,6 +16993,7 @@ export {
|
|
|
14503
16993
|
httpProbe,
|
|
14504
16994
|
identitiesDir,
|
|
14505
16995
|
identityDir,
|
|
16996
|
+
identityKnown,
|
|
14506
16997
|
identityMetaFile,
|
|
14507
16998
|
inGap,
|
|
14508
16999
|
inferEnvName,
|
|
@@ -14513,6 +17004,10 @@ export {
|
|
|
14513
17004
|
isDelegationToolName,
|
|
14514
17005
|
isReadOnly,
|
|
14515
17006
|
isServerSlidingSession,
|
|
17007
|
+
isZeroNetwork,
|
|
17008
|
+
journalNote,
|
|
17009
|
+
judgeDrift,
|
|
17010
|
+
ledgerOnlySignpost,
|
|
14516
17011
|
listEnvs,
|
|
14517
17012
|
listIdentities,
|
|
14518
17013
|
listModels,
|
|
@@ -14524,8 +17019,10 @@ export {
|
|
|
14524
17019
|
loadExemptions,
|
|
14525
17020
|
loadGlobalConfig,
|
|
14526
17021
|
loadIdentity,
|
|
17022
|
+
loadMapping,
|
|
14527
17023
|
loadProfile,
|
|
14528
17024
|
loadProtocolFacts,
|
|
17025
|
+
loadRecordedFingerprint,
|
|
14529
17026
|
loadWorkspaceFileContent,
|
|
14530
17027
|
loginClientCredentials,
|
|
14531
17028
|
loginPairing,
|
|
@@ -14539,6 +17036,7 @@ export {
|
|
|
14539
17036
|
newRoundId,
|
|
14540
17037
|
normalize,
|
|
14541
17038
|
normalizeReferences,
|
|
17039
|
+
notAsked,
|
|
14542
17040
|
oneShot,
|
|
14543
17041
|
parseConfirmToolName,
|
|
14544
17042
|
parseFixture,
|
|
@@ -14553,6 +17051,7 @@ export {
|
|
|
14553
17051
|
planProblemLines,
|
|
14554
17052
|
planRc,
|
|
14555
17053
|
planSummaryLine,
|
|
17054
|
+
planVsBaselinePremise,
|
|
14556
17055
|
probeAll,
|
|
14557
17056
|
probeExtensionSource,
|
|
14558
17057
|
profileDir,
|
|
@@ -14573,6 +17072,7 @@ export {
|
|
|
14573
17072
|
resolveActiveIdentity,
|
|
14574
17073
|
resolveActiveProfile,
|
|
14575
17074
|
resolveAllSkillsInstallOrder,
|
|
17075
|
+
resolveBaselineDir,
|
|
14576
17076
|
resolveChironBase,
|
|
14577
17077
|
resolveRefs,
|
|
14578
17078
|
resolveSkillInstallOrder,
|
|
@@ -14598,6 +17098,7 @@ export {
|
|
|
14598
17098
|
seedWorkDir,
|
|
14599
17099
|
segmentsOf,
|
|
14600
17100
|
sendMessageAndStream,
|
|
17101
|
+
shelfPartition,
|
|
14601
17102
|
snakeToCamel,
|
|
14602
17103
|
tenantSegment,
|
|
14603
17104
|
toJson,
|
|
@@ -14610,6 +17111,9 @@ export {
|
|
|
14610
17111
|
update,
|
|
14611
17112
|
uploadDocument,
|
|
14612
17113
|
validateMiniProject,
|
|
17114
|
+
verifyAttention,
|
|
17115
|
+
verifyRc,
|
|
17116
|
+
verifyText,
|
|
14613
17117
|
writeImportPlan,
|
|
14614
17118
|
writeRisk
|
|
14615
17119
|
};
|