@inerrata-corporation/errata 2.0.2-dev.417 → 2.0.2-dev.455
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/consolidate-worker.mjs +4 -4
- package/errata.mjs +485 -398
- package/package.json +1 -1
- package/pass-worker.mjs +91 -91
package/package.json
CHANGED
package/pass-worker.mjs
CHANGED
|
@@ -25316,6 +25316,97 @@ function backfillProblemContext(store2, ts) {
|
|
|
25316
25316
|
return report;
|
|
25317
25317
|
}
|
|
25318
25318
|
|
|
25319
|
+
// ../../packages/local-graph/src/problem-dedup.ts
|
|
25320
|
+
init_src();
|
|
25321
|
+
init_src();
|
|
25322
|
+
var REDIRECT_EDGES = [
|
|
25323
|
+
"CAUSED_BY",
|
|
25324
|
+
"SOLVED_BY",
|
|
25325
|
+
"FIXED_BY",
|
|
25326
|
+
"ANCHORED_AT",
|
|
25327
|
+
"MANIFESTED_IN",
|
|
25328
|
+
"EVIDENCED_BY"
|
|
25329
|
+
];
|
|
25330
|
+
function corroborations(n) {
|
|
25331
|
+
return Number(n.attrs["corroborations"] ?? 0);
|
|
25332
|
+
}
|
|
25333
|
+
function overlap(a, b) {
|
|
25334
|
+
if (a.size === 0 || b.size === 0) return 0;
|
|
25335
|
+
let inter = 0;
|
|
25336
|
+
for (const x of a) if (b.has(x)) inter++;
|
|
25337
|
+
return inter / Math.min(a.size, b.size);
|
|
25338
|
+
}
|
|
25339
|
+
function mergeDuplicateProblems(store2, opts) {
|
|
25340
|
+
const minOverlap = opts.minOverlap ?? 0.85;
|
|
25341
|
+
const minTokens = opts.minTokens ?? 4;
|
|
25342
|
+
const report = { clusters: 0, merged: 0 };
|
|
25343
|
+
const open = store2.findNodesByLabel("Problem").filter((p) => p.attrs["resolvedAt"] == null && p.attrs["mergedInto"] === void 0);
|
|
25344
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
25345
|
+
for (const p of open) tokens.set(p.id, new Set(conceptTokens(p.description)));
|
|
25346
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
25347
|
+
store2.transaction(() => {
|
|
25348
|
+
for (let i2 = 0; i2 < open.length; i2++) {
|
|
25349
|
+
const a = open[i2];
|
|
25350
|
+
if (consumed.has(a.id)) continue;
|
|
25351
|
+
const cluster = [a];
|
|
25352
|
+
const ta = tokens.get(a.id);
|
|
25353
|
+
for (let j = i2 + 1; j < open.length; j++) {
|
|
25354
|
+
const b = open[j];
|
|
25355
|
+
if (consumed.has(b.id)) continue;
|
|
25356
|
+
const tb = tokens.get(b.id);
|
|
25357
|
+
if (Math.min(ta.size, tb.size) < minTokens) continue;
|
|
25358
|
+
if (isConstraintProblem(a) !== isConstraintProblem(b)) continue;
|
|
25359
|
+
if (overlap(ta, tb) >= minOverlap) {
|
|
25360
|
+
cluster.push(b);
|
|
25361
|
+
consumed.add(b.id);
|
|
25362
|
+
}
|
|
25363
|
+
}
|
|
25364
|
+
if (cluster.length < 2) continue;
|
|
25365
|
+
report.clusters++;
|
|
25366
|
+
cluster.sort((x, y) => corroborations(y) - corroborations(x) || x.createdAt - y.createdAt);
|
|
25367
|
+
const survivor = cluster[0];
|
|
25368
|
+
for (const dup of cluster.slice(1)) {
|
|
25369
|
+
foldDuplicateProblem(store2, dup, survivor, opts.ts);
|
|
25370
|
+
report.merged++;
|
|
25371
|
+
}
|
|
25372
|
+
}
|
|
25373
|
+
});
|
|
25374
|
+
return report;
|
|
25375
|
+
}
|
|
25376
|
+
function foldDuplicateProblem(store2, dup, survivor, ts) {
|
|
25377
|
+
const surv = store2.getNode(survivor.id);
|
|
25378
|
+
if (!surv) return;
|
|
25379
|
+
const sources = new Set(surv.attrs["sources"] ?? []);
|
|
25380
|
+
for (const s of dup.attrs["sources"] ?? []) sources.add(s);
|
|
25381
|
+
store2.updateNode(survivor.id, {
|
|
25382
|
+
attrs: {
|
|
25383
|
+
...surv.attrs,
|
|
25384
|
+
sources: [...sources],
|
|
25385
|
+
corroborations: corroborations(surv) + corroborations(dup) + 1
|
|
25386
|
+
},
|
|
25387
|
+
cumulativeHits: (surv.cumulativeHits ?? 0) + (dup.cumulativeHits ?? 0),
|
|
25388
|
+
lastUpdatedAt: ts
|
|
25389
|
+
});
|
|
25390
|
+
for (const e of store2.outEdges(dup.id, REDIRECT_EDGES)) {
|
|
25391
|
+
if (e.to === survivor.id) continue;
|
|
25392
|
+
const id = `edge_${digest({ from: survivor.id, type: e.type, to: e.to })}`.slice(0, 24);
|
|
25393
|
+
if (store2.getEdge(id)) continue;
|
|
25394
|
+
const redirected = {
|
|
25395
|
+
...e,
|
|
25396
|
+
id,
|
|
25397
|
+
from: survivor.id,
|
|
25398
|
+
createdAt: ts,
|
|
25399
|
+
lastSeenAt: ts
|
|
25400
|
+
};
|
|
25401
|
+
store2.mergeEdge(redirected);
|
|
25402
|
+
}
|
|
25403
|
+
store2.updateNode(dup.id, {
|
|
25404
|
+
attrs: { ...dup.attrs, mergedInto: survivor.id, resolvedAs: "duplicate", resolvedAt: ts },
|
|
25405
|
+
lastUpdatedAt: ts
|
|
25406
|
+
});
|
|
25407
|
+
store2.closeNode(dup.id, ts);
|
|
25408
|
+
}
|
|
25409
|
+
|
|
25319
25410
|
// ../../packages/local-graph/src/design-problem.ts
|
|
25320
25411
|
function isConstraintProblem(node) {
|
|
25321
25412
|
return node.attrs["kind"] === "constraint";
|
|
@@ -25952,97 +26043,6 @@ var DRIFT_VALUES = new Set(Object.values(DRIFT_KIND));
|
|
|
25952
26043
|
// ../../packages/local-graph/src/community.ts
|
|
25953
26044
|
init_src2();
|
|
25954
26045
|
|
|
25955
|
-
// ../../packages/local-graph/src/problem-dedup.ts
|
|
25956
|
-
init_src();
|
|
25957
|
-
init_src();
|
|
25958
|
-
var REDIRECT_EDGES = [
|
|
25959
|
-
"CAUSED_BY",
|
|
25960
|
-
"SOLVED_BY",
|
|
25961
|
-
"FIXED_BY",
|
|
25962
|
-
"ANCHORED_AT",
|
|
25963
|
-
"MANIFESTED_IN",
|
|
25964
|
-
"EVIDENCED_BY"
|
|
25965
|
-
];
|
|
25966
|
-
function corroborations(n) {
|
|
25967
|
-
return Number(n.attrs["corroborations"] ?? 0);
|
|
25968
|
-
}
|
|
25969
|
-
function overlap(a, b) {
|
|
25970
|
-
if (a.size === 0 || b.size === 0) return 0;
|
|
25971
|
-
let inter = 0;
|
|
25972
|
-
for (const x of a) if (b.has(x)) inter++;
|
|
25973
|
-
return inter / Math.min(a.size, b.size);
|
|
25974
|
-
}
|
|
25975
|
-
function mergeDuplicateProblems(store2, opts) {
|
|
25976
|
-
const minOverlap = opts.minOverlap ?? 0.85;
|
|
25977
|
-
const minTokens = opts.minTokens ?? 4;
|
|
25978
|
-
const report = { clusters: 0, merged: 0 };
|
|
25979
|
-
const open = store2.findNodesByLabel("Problem").filter((p) => p.attrs["resolvedAt"] == null && p.attrs["mergedInto"] === void 0);
|
|
25980
|
-
const tokens = /* @__PURE__ */ new Map();
|
|
25981
|
-
for (const p of open) tokens.set(p.id, new Set(conceptTokens(p.description)));
|
|
25982
|
-
const consumed = /* @__PURE__ */ new Set();
|
|
25983
|
-
store2.transaction(() => {
|
|
25984
|
-
for (let i2 = 0; i2 < open.length; i2++) {
|
|
25985
|
-
const a = open[i2];
|
|
25986
|
-
if (consumed.has(a.id)) continue;
|
|
25987
|
-
const cluster = [a];
|
|
25988
|
-
const ta = tokens.get(a.id);
|
|
25989
|
-
for (let j = i2 + 1; j < open.length; j++) {
|
|
25990
|
-
const b = open[j];
|
|
25991
|
-
if (consumed.has(b.id)) continue;
|
|
25992
|
-
const tb = tokens.get(b.id);
|
|
25993
|
-
if (Math.min(ta.size, tb.size) < minTokens) continue;
|
|
25994
|
-
if (isConstraintProblem(a) !== isConstraintProblem(b)) continue;
|
|
25995
|
-
if (overlap(ta, tb) >= minOverlap) {
|
|
25996
|
-
cluster.push(b);
|
|
25997
|
-
consumed.add(b.id);
|
|
25998
|
-
}
|
|
25999
|
-
}
|
|
26000
|
-
if (cluster.length < 2) continue;
|
|
26001
|
-
report.clusters++;
|
|
26002
|
-
cluster.sort((x, y) => corroborations(y) - corroborations(x) || x.createdAt - y.createdAt);
|
|
26003
|
-
const survivor = cluster[0];
|
|
26004
|
-
for (const dup of cluster.slice(1)) {
|
|
26005
|
-
foldDuplicateProblem(store2, dup, survivor, opts.ts);
|
|
26006
|
-
report.merged++;
|
|
26007
|
-
}
|
|
26008
|
-
}
|
|
26009
|
-
});
|
|
26010
|
-
return report;
|
|
26011
|
-
}
|
|
26012
|
-
function foldDuplicateProblem(store2, dup, survivor, ts) {
|
|
26013
|
-
const surv = store2.getNode(survivor.id);
|
|
26014
|
-
if (!surv) return;
|
|
26015
|
-
const sources = new Set(surv.attrs["sources"] ?? []);
|
|
26016
|
-
for (const s of dup.attrs["sources"] ?? []) sources.add(s);
|
|
26017
|
-
store2.updateNode(survivor.id, {
|
|
26018
|
-
attrs: {
|
|
26019
|
-
...surv.attrs,
|
|
26020
|
-
sources: [...sources],
|
|
26021
|
-
corroborations: corroborations(surv) + corroborations(dup) + 1
|
|
26022
|
-
},
|
|
26023
|
-
cumulativeHits: (surv.cumulativeHits ?? 0) + (dup.cumulativeHits ?? 0),
|
|
26024
|
-
lastUpdatedAt: ts
|
|
26025
|
-
});
|
|
26026
|
-
for (const e of store2.outEdges(dup.id, REDIRECT_EDGES)) {
|
|
26027
|
-
if (e.to === survivor.id) continue;
|
|
26028
|
-
const id = `edge_${digest({ from: survivor.id, type: e.type, to: e.to })}`.slice(0, 24);
|
|
26029
|
-
if (store2.getEdge(id)) continue;
|
|
26030
|
-
const redirected = {
|
|
26031
|
-
...e,
|
|
26032
|
-
id,
|
|
26033
|
-
from: survivor.id,
|
|
26034
|
-
createdAt: ts,
|
|
26035
|
-
lastSeenAt: ts
|
|
26036
|
-
};
|
|
26037
|
-
store2.mergeEdge(redirected);
|
|
26038
|
-
}
|
|
26039
|
-
store2.updateNode(dup.id, {
|
|
26040
|
-
attrs: { ...dup.attrs, mergedInto: survivor.id, resolvedAs: "duplicate", resolvedAt: ts },
|
|
26041
|
-
lastUpdatedAt: ts
|
|
26042
|
-
});
|
|
26043
|
-
store2.closeNode(dup.id, ts);
|
|
26044
|
-
}
|
|
26045
|
-
|
|
26046
26046
|
// ../../packages/local-graph/src/tools.ts
|
|
26047
26047
|
init_src();
|
|
26048
26048
|
function rankToolsForHandles(store2, limit = 5) {
|