@inerrata-corporation/errata 2.0.6-dev.2632 → 2.0.6-dev.2635
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/errata.mjs +57 -31
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -78515,7 +78515,7 @@ function createWatchBreaker(deps) {
|
|
|
78515
78515
|
}
|
|
78516
78516
|
|
|
78517
78517
|
// src/engine.ts
|
|
78518
|
-
var DAEMON_VERSION = true ? "2.0.6-dev.
|
|
78518
|
+
var DAEMON_VERSION = true ? "2.0.6-dev.2635" : "2.0.0-alpha.0";
|
|
78519
78519
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
78520
78520
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
78521
78521
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -82248,26 +82248,40 @@ function classifyAnchorVersion(cloudAttrs, localSymbol) {
|
|
|
82248
82248
|
return seen === have ? "current" : "pre-change";
|
|
82249
82249
|
}
|
|
82250
82250
|
function buildReverseSymbolMap(opts) {
|
|
82251
|
+
return collectFirstWins(reverseSymbolEntries(opts));
|
|
82252
|
+
}
|
|
82253
|
+
function* reverseSymbolEntries(opts) {
|
|
82251
82254
|
const { store, salt, projectId } = opts;
|
|
82252
|
-
const reverse = /* @__PURE__ */ new Map();
|
|
82253
82255
|
for (const kind of ANCHOR_SYMBOL_KINDS2) {
|
|
82254
82256
|
for (const n of store.findNodeIdentitiesByLabel(kind)) {
|
|
82255
82257
|
const { relPath, qname } = n;
|
|
82256
82258
|
if (relPath === null || qname === null) continue;
|
|
82257
82259
|
const sym = projectSymbolId(salt, projectId, relPath, qname, kind);
|
|
82258
|
-
|
|
82259
|
-
|
|
82260
|
-
if (!reverse.has(twin)) reverse.set(twin, n.id);
|
|
82260
|
+
yield [sym, n.id];
|
|
82261
|
+
yield [projectSaltedNodeId(sym, salt), n.id];
|
|
82261
82262
|
}
|
|
82262
82263
|
}
|
|
82263
82264
|
for (const n of store.findNodeIdentitiesByLabel("File")) {
|
|
82264
82265
|
if (n.relPath === null) continue;
|
|
82265
82266
|
const sym = projectSymbolId(salt, projectId, n.relPath, FILE_ANCHOR_QNAME, "File");
|
|
82266
|
-
|
|
82267
|
-
|
|
82268
|
-
if (!reverse.has(twin)) reverse.set(twin, n.id);
|
|
82267
|
+
yield [sym, n.id];
|
|
82268
|
+
yield [projectSaltedNodeId(sym, salt), n.id];
|
|
82269
82269
|
}
|
|
82270
|
-
|
|
82270
|
+
}
|
|
82271
|
+
function collectFirstWins(entries) {
|
|
82272
|
+
const m = /* @__PURE__ */ new Map();
|
|
82273
|
+
for (const [k, v] of entries) if (!m.has(k)) m.set(k, v);
|
|
82274
|
+
return m;
|
|
82275
|
+
}
|
|
82276
|
+
var MAP_BUILD_BATCH = 2e3;
|
|
82277
|
+
async function collectFirstWinsYielding(entries) {
|
|
82278
|
+
const m = /* @__PURE__ */ new Map();
|
|
82279
|
+
let i2 = 0;
|
|
82280
|
+
for (const [k, v] of entries) {
|
|
82281
|
+
if (++i2 % MAP_BUILD_BATCH === 0) await new Promise((r) => setImmediate(r));
|
|
82282
|
+
if (!m.has(k)) m.set(k, v);
|
|
82283
|
+
}
|
|
82284
|
+
return m;
|
|
82271
82285
|
}
|
|
82272
82286
|
function anchorConfidence(attrs) {
|
|
82273
82287
|
const v = typeof attrs["extractionConfidence"] === "number" ? attrs["extractionConfidence"] : attrs["confidence"];
|
|
@@ -82282,15 +82296,25 @@ var ANCHOR_SOURCE_KINDS = [
|
|
|
82282
82296
|
"AntiPattern"
|
|
82283
82297
|
];
|
|
82284
82298
|
function buildOwnKnowledgeMap(opts) {
|
|
82299
|
+
return new Map(ownKnowledgeEntries(opts));
|
|
82300
|
+
}
|
|
82301
|
+
function* ownKnowledgeEntries(opts) {
|
|
82285
82302
|
const { store, salt } = opts;
|
|
82286
|
-
const own = /* @__PURE__ */ new Map();
|
|
82287
82303
|
for (const kind of ANCHOR_SOURCE_KINDS) {
|
|
82288
82304
|
for (const n of store.findNodeIdentitiesByLabel(kind)) {
|
|
82289
82305
|
if (n.id.startsWith("projn_")) continue;
|
|
82290
|
-
|
|
82306
|
+
yield [projectSaltedNodeId(n.id, salt), n.id];
|
|
82291
82307
|
}
|
|
82292
82308
|
}
|
|
82293
|
-
|
|
82309
|
+
}
|
|
82310
|
+
async function collectLastWinsYielding(entries) {
|
|
82311
|
+
const m = /* @__PURE__ */ new Map();
|
|
82312
|
+
let i2 = 0;
|
|
82313
|
+
for (const [k, v] of entries) {
|
|
82314
|
+
if (++i2 % MAP_BUILD_BATCH === 0) await new Promise((r) => setImmediate(r));
|
|
82315
|
+
m.set(k, v);
|
|
82316
|
+
}
|
|
82317
|
+
return m;
|
|
82294
82318
|
}
|
|
82295
82319
|
function resolveAnchorSource(store, from, own) {
|
|
82296
82320
|
if (store.getNode(from)) return from;
|
|
@@ -82303,30 +82327,27 @@ function existingAnchor(store, from, to) {
|
|
|
82303
82327
|
var reverseCache = /* @__PURE__ */ new WeakMap();
|
|
82304
82328
|
var ownCache = /* @__PURE__ */ new WeakMap();
|
|
82305
82329
|
function cachedMap(cache2, store, key, build) {
|
|
82306
|
-
let
|
|
82330
|
+
let rebuild = null;
|
|
82307
82331
|
const put = () => {
|
|
82308
|
-
|
|
82309
|
-
|
|
82310
|
-
|
|
82332
|
+
rebuild ??= build().then((map2) => {
|
|
82333
|
+
cache2.set(store, { key, map: map2 });
|
|
82334
|
+
return map2;
|
|
82335
|
+
});
|
|
82336
|
+
return rebuild;
|
|
82311
82337
|
};
|
|
82312
82338
|
return {
|
|
82313
|
-
get: () => {
|
|
82339
|
+
get: async () => {
|
|
82314
82340
|
const hit = cache2.get(store);
|
|
82315
82341
|
if (hit && hit.key === key) return hit.map;
|
|
82316
|
-
refreshed = true;
|
|
82317
82342
|
return put();
|
|
82318
82343
|
},
|
|
82319
|
-
refresh: () =>
|
|
82320
|
-
if (refreshed) return cache2.get(store)?.map ?? put();
|
|
82321
|
-
refreshed = true;
|
|
82322
|
-
return put();
|
|
82323
|
-
}
|
|
82344
|
+
refresh: () => put()
|
|
82324
82345
|
};
|
|
82325
82346
|
}
|
|
82326
|
-
function lookupLive(store, m, id) {
|
|
82327
|
-
const first = m.get().get(id);
|
|
82347
|
+
async function lookupLive(store, m, id) {
|
|
82348
|
+
const first = (await m.get()).get(id);
|
|
82328
82349
|
if (first && isLive2(store, first)) return first;
|
|
82329
|
-
const second = m.refresh().get(id);
|
|
82350
|
+
const second = (await m.refresh()).get(id);
|
|
82330
82351
|
return second && isLive2(store, second) ? second : null;
|
|
82331
82352
|
}
|
|
82332
82353
|
function isLive2(store, id) {
|
|
@@ -82407,8 +82428,13 @@ async function syncProjectAnchors(opts) {
|
|
|
82407
82428
|
if (!profile.projectId) return { synced: false, reason: "no-project" };
|
|
82408
82429
|
const projectId = profile.projectId;
|
|
82409
82430
|
const key = `${projectId}|${salt}`;
|
|
82410
|
-
const reverse = cachedMap(
|
|
82411
|
-
|
|
82431
|
+
const reverse = cachedMap(
|
|
82432
|
+
reverseCache,
|
|
82433
|
+
store,
|
|
82434
|
+
key,
|
|
82435
|
+
() => collectFirstWinsYielding(reverseSymbolEntries({ store, salt, projectId }))
|
|
82436
|
+
);
|
|
82437
|
+
const own = cachedMap(ownCache, store, salt, () => collectLastWinsYielding(ownKnowledgeEntries({ store, salt })));
|
|
82412
82438
|
const limit = opts.limit ?? SYNC_PAGE;
|
|
82413
82439
|
const maxPages = opts.maxPages ?? SYNC_MAX_PAGES;
|
|
82414
82440
|
let anchors = 0;
|
|
@@ -82420,19 +82446,19 @@ async function syncProjectAnchors(opts) {
|
|
|
82420
82446
|
for (let page = 0; page < maxPages; page++) {
|
|
82421
82447
|
const res = await cloud.getProjectAnchors(projectId, cursor, limit);
|
|
82422
82448
|
if (res.anchors.length === 0) break;
|
|
82423
|
-
if (reverse.get().size === 0 && reverse.refresh().size === 0) {
|
|
82449
|
+
if ((await reverse.get()).size === 0 && (await reverse.refresh()).size === 0) {
|
|
82424
82450
|
return { synced: false, reason: "no-local-symbols" };
|
|
82425
82451
|
}
|
|
82426
82452
|
const byId = new Map(res.nodes.map((n) => [n.id, n]));
|
|
82427
82453
|
const now = Date.now();
|
|
82428
82454
|
for (const a of res.anchors) {
|
|
82429
82455
|
if (a.type !== "ANCHORED_AT") continue;
|
|
82430
|
-
const localTo = lookupLive(store, reverse, a.toSymbolId);
|
|
82456
|
+
const localTo = await lookupLive(store, reverse, a.toSymbolId);
|
|
82431
82457
|
if (!localTo) {
|
|
82432
82458
|
dropped++;
|
|
82433
82459
|
continue;
|
|
82434
82460
|
}
|
|
82435
|
-
let from = store.getNode(a.from) ? a.from : lookupLive(store, own, a.from);
|
|
82461
|
+
let from = store.getNode(a.from) ? a.from : await lookupLive(store, own, a.from);
|
|
82436
82462
|
if (!from) {
|
|
82437
82463
|
const node2 = byId.get(a.from);
|
|
82438
82464
|
if (!node2) {
|