@inerrata-corporation/errata 2.0.2-dev.610 → 2.0.2-dev.615
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 +3 -1
- package/errata.mjs +310 -205
- package/package.json +1 -1
- package/pass-worker.mjs +3 -1
package/consolidate-worker.mjs
CHANGED
|
@@ -16728,11 +16728,13 @@ init_src();
|
|
|
16728
16728
|
// ../../packages/local-graph/src/design-problem.ts
|
|
16729
16729
|
init_src();
|
|
16730
16730
|
init_src();
|
|
16731
|
-
init_src2();
|
|
16732
16731
|
|
|
16733
16732
|
// ../../packages/local-graph/src/problem-package-link.ts
|
|
16734
16733
|
init_src();
|
|
16735
16734
|
|
|
16735
|
+
// ../../packages/local-graph/src/design-problem.ts
|
|
16736
|
+
init_src2();
|
|
16737
|
+
|
|
16736
16738
|
// ../../packages/local-graph/src/problem-dedup.ts
|
|
16737
16739
|
init_src();
|
|
16738
16740
|
init_src();
|
package/errata.mjs
CHANGED
|
@@ -18154,207 +18154,6 @@ var init_aggregate = __esm({
|
|
|
18154
18154
|
}
|
|
18155
18155
|
});
|
|
18156
18156
|
|
|
18157
|
-
// ../../packages/embedding/src/model.ts
|
|
18158
|
-
import { mkdirSync as mkdirSync3, existsSync as existsSync4 } from "node:fs";
|
|
18159
|
-
import { homedir } from "node:os";
|
|
18160
|
-
import { dirname as dirname3, join as join3 } from "node:path";
|
|
18161
|
-
import { createRequire } from "node:module";
|
|
18162
|
-
function semanticFloorFor(version2) {
|
|
18163
|
-
if (version2 === EMBEDDING_VERSION || version2 === MODEL_EMBEDDING_VERSION) return 0.25;
|
|
18164
|
-
return 0.5;
|
|
18165
|
-
}
|
|
18166
|
-
function noteHashFallback() {
|
|
18167
|
-
if (warnedHashFallback) return;
|
|
18168
|
-
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") return;
|
|
18169
|
-
warnedHashFallback = true;
|
|
18170
|
-
console.warn(
|
|
18171
|
-
`[errata] embedding model unavailable (${lastError?.message ?? "unknown"}) \u2014 falling back to ${EMBEDDING_VERSION} hash vectors; semantic ranking runs at reduced fidelity`
|
|
18172
|
-
);
|
|
18173
|
-
}
|
|
18174
|
-
function getCacheDir() {
|
|
18175
|
-
return process.env["ERRATA_MODEL_CACHE"] ?? join3(homedir(), ".errata", "models");
|
|
18176
|
-
}
|
|
18177
|
-
async function loadTransformers() {
|
|
18178
|
-
try {
|
|
18179
|
-
return await import("@huggingface/transformers");
|
|
18180
|
-
} catch (err2) {
|
|
18181
|
-
void err2;
|
|
18182
|
-
}
|
|
18183
|
-
try {
|
|
18184
|
-
const seaResourceBase = join3(
|
|
18185
|
-
// execPath dir is where errata.exe lives; resources/ rides alongside.
|
|
18186
|
-
dirname3(process.execPath),
|
|
18187
|
-
"resources",
|
|
18188
|
-
"_resolve.js"
|
|
18189
|
-
);
|
|
18190
|
-
const resourceRequire = createRequire(seaResourceBase);
|
|
18191
|
-
return resourceRequire("@huggingface/transformers");
|
|
18192
|
-
} catch (err2) {
|
|
18193
|
-
lastError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
18194
|
-
return null;
|
|
18195
|
-
}
|
|
18196
|
-
}
|
|
18197
|
-
async function loadPipeline() {
|
|
18198
|
-
const cacheDir = getCacheDir();
|
|
18199
|
-
if (!existsSync4(cacheDir)) mkdirSync3(cacheDir, { recursive: true });
|
|
18200
|
-
try {
|
|
18201
|
-
const tx = await loadTransformers();
|
|
18202
|
-
if (!tx) {
|
|
18203
|
-
throw lastError ?? new Error("transformers package unavailable");
|
|
18204
|
-
}
|
|
18205
|
-
tx.env.cacheDir = cacheDir;
|
|
18206
|
-
tx.env.useFSCache = true;
|
|
18207
|
-
tx.env.allowLocalModels = true;
|
|
18208
|
-
tx.env.allowRemoteModels = process.env["ERRATA_OFFLINE"] !== "1";
|
|
18209
|
-
const pipe2 = await tx.pipeline("feature-extraction", MODEL_NAME, {
|
|
18210
|
-
// Quantized weights cut size 4x; quality drop is negligible for
|
|
18211
|
-
// short-text similarity. Override via env if you want full
|
|
18212
|
-
// precision.
|
|
18213
|
-
dtype: process.env["ERRATA_MODEL_DTYPE"] ?? "q8"
|
|
18214
|
-
});
|
|
18215
|
-
return pipe2;
|
|
18216
|
-
} catch (err2) {
|
|
18217
|
-
lastError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
18218
|
-
return null;
|
|
18219
|
-
}
|
|
18220
|
-
}
|
|
18221
|
-
async function ensureModelLoaded() {
|
|
18222
|
-
if (!pipelinePromise) {
|
|
18223
|
-
pipelinePromise = loadPipeline();
|
|
18224
|
-
}
|
|
18225
|
-
return pipelinePromise;
|
|
18226
|
-
}
|
|
18227
|
-
async function embedTextWithModel(text) {
|
|
18228
|
-
const pipe2 = await ensureModelLoaded();
|
|
18229
|
-
if (!pipe2) {
|
|
18230
|
-
throw new Error(
|
|
18231
|
-
`embedding model could not be loaded: ${lastError?.message ?? "unknown"}`
|
|
18232
|
-
);
|
|
18233
|
-
}
|
|
18234
|
-
if (!text) return new Array(MODEL_EMBEDDING_DIM).fill(0);
|
|
18235
|
-
const out2 = await pipe2(text, { pooling: "mean", normalize: true });
|
|
18236
|
-
return Array.from(out2.data);
|
|
18237
|
-
}
|
|
18238
|
-
async function embedBatchWithModelOrHash(texts) {
|
|
18239
|
-
if (texts.length === 0) return [];
|
|
18240
|
-
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") {
|
|
18241
|
-
return texts.map((t) => {
|
|
18242
|
-
const v = embed(t);
|
|
18243
|
-
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18244
|
-
});
|
|
18245
|
-
}
|
|
18246
|
-
try {
|
|
18247
|
-
const pipe2 = await ensureModelLoaded();
|
|
18248
|
-
if (pipe2) {
|
|
18249
|
-
const out2 = await pipe2(texts, {
|
|
18250
|
-
pooling: "mean",
|
|
18251
|
-
normalize: true
|
|
18252
|
-
});
|
|
18253
|
-
const dim = out2.dims[out2.dims.length - 1] ?? MODEL_EMBEDDING_DIM;
|
|
18254
|
-
const total = texts.length;
|
|
18255
|
-
const results = [];
|
|
18256
|
-
for (let i2 = 0; i2 < total; i2++) {
|
|
18257
|
-
const v = Array.from(out2.data.subarray(i2 * dim, (i2 + 1) * dim));
|
|
18258
|
-
results.push({ vector: v, version: MODEL_EMBEDDING_VERSION, dim });
|
|
18259
|
-
}
|
|
18260
|
-
return results;
|
|
18261
|
-
}
|
|
18262
|
-
} catch {
|
|
18263
|
-
}
|
|
18264
|
-
noteHashFallback();
|
|
18265
|
-
return texts.map((t) => {
|
|
18266
|
-
const v = embed(t);
|
|
18267
|
-
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18268
|
-
});
|
|
18269
|
-
}
|
|
18270
|
-
async function embedTextWithModelOrHash(text) {
|
|
18271
|
-
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") {
|
|
18272
|
-
const v = embed(text);
|
|
18273
|
-
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18274
|
-
}
|
|
18275
|
-
try {
|
|
18276
|
-
const v = await embedTextWithModel(text);
|
|
18277
|
-
return { vector: v, version: MODEL_EMBEDDING_VERSION, dim: v.length };
|
|
18278
|
-
} catch {
|
|
18279
|
-
noteHashFallback();
|
|
18280
|
-
const v = embed(text);
|
|
18281
|
-
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18282
|
-
}
|
|
18283
|
-
}
|
|
18284
|
-
var MODEL_NAME, MODEL_EMBEDDING_DIM, MODEL_EMBEDDING_VERSION, pipelinePromise, lastError, warnedHashFallback;
|
|
18285
|
-
var init_model = __esm({
|
|
18286
|
-
"../../packages/embedding/src/model.ts"() {
|
|
18287
|
-
"use strict";
|
|
18288
|
-
init_src3();
|
|
18289
|
-
MODEL_NAME = "Xenova/all-MiniLM-L6-v2";
|
|
18290
|
-
MODEL_EMBEDDING_DIM = 384;
|
|
18291
|
-
MODEL_EMBEDDING_VERSION = "minilm-l6-v2";
|
|
18292
|
-
pipelinePromise = null;
|
|
18293
|
-
lastError = null;
|
|
18294
|
-
warnedHashFallback = false;
|
|
18295
|
-
}
|
|
18296
|
-
});
|
|
18297
|
-
|
|
18298
|
-
// ../../packages/embedding/src/index.ts
|
|
18299
|
-
function djb2(s) {
|
|
18300
|
-
let h = 5381;
|
|
18301
|
-
for (let i2 = 0; i2 < s.length; i2++) {
|
|
18302
|
-
h = (h << 5) + h + s.charCodeAt(i2) >>> 0;
|
|
18303
|
-
}
|
|
18304
|
-
return h;
|
|
18305
|
-
}
|
|
18306
|
-
function djb2Signed(s) {
|
|
18307
|
-
let h = 0;
|
|
18308
|
-
for (let i2 = 0; i2 < s.length; i2++) {
|
|
18309
|
-
h = h * 31 + s.charCodeAt(i2) | 0;
|
|
18310
|
-
}
|
|
18311
|
-
return h;
|
|
18312
|
-
}
|
|
18313
|
-
function tokenize2(text) {
|
|
18314
|
-
return text.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 0 && t.length <= 40);
|
|
18315
|
-
}
|
|
18316
|
-
function* charTrigrams(text) {
|
|
18317
|
-
const s = text.toLowerCase();
|
|
18318
|
-
for (let i2 = 0; i2 <= s.length - 3; i2++) {
|
|
18319
|
-
yield s.slice(i2, i2 + 3);
|
|
18320
|
-
}
|
|
18321
|
-
}
|
|
18322
|
-
function embed(text) {
|
|
18323
|
-
const vec = new Array(EMBEDDING_DIM).fill(0);
|
|
18324
|
-
if (!text) return vec;
|
|
18325
|
-
for (const tok of tokenize2(text)) {
|
|
18326
|
-
const idx = djb2(tok) % EMBEDDING_DIM;
|
|
18327
|
-
const sign = djb2Signed(tok) & 1 ? 1 : -1;
|
|
18328
|
-
vec[idx] = vec[idx] + sign;
|
|
18329
|
-
}
|
|
18330
|
-
for (const tri of charTrigrams(text)) {
|
|
18331
|
-
const idx = djb2("3:" + tri) % EMBEDDING_DIM;
|
|
18332
|
-
const sign = djb2Signed("3:" + tri) & 1 ? 1 : -1;
|
|
18333
|
-
vec[idx] = vec[idx] + 0.5 * sign;
|
|
18334
|
-
}
|
|
18335
|
-
let normSq = 0;
|
|
18336
|
-
for (const x of vec) normSq += x * x;
|
|
18337
|
-
if (normSq <= 0) return vec;
|
|
18338
|
-
const inv = 1 / Math.sqrt(normSq);
|
|
18339
|
-
for (let i2 = 0; i2 < vec.length; i2++) vec[i2] = vec[i2] * inv;
|
|
18340
|
-
return vec;
|
|
18341
|
-
}
|
|
18342
|
-
function cosine(a, b) {
|
|
18343
|
-
if (a.length !== b.length || a.length === 0) return 0;
|
|
18344
|
-
let dot = 0;
|
|
18345
|
-
for (let i2 = 0; i2 < a.length; i2++) dot += a[i2] * b[i2];
|
|
18346
|
-
return dot;
|
|
18347
|
-
}
|
|
18348
|
-
var EMBEDDING_DIM, EMBEDDING_VERSION;
|
|
18349
|
-
var init_src3 = __esm({
|
|
18350
|
-
"../../packages/embedding/src/index.ts"() {
|
|
18351
|
-
"use strict";
|
|
18352
|
-
init_model();
|
|
18353
|
-
EMBEDDING_DIM = 256;
|
|
18354
|
-
EMBEDDING_VERSION = "hash-v1";
|
|
18355
|
-
}
|
|
18356
|
-
});
|
|
18357
|
-
|
|
18358
18157
|
// ../../packages/local-graph/src/problem-package-link.ts
|
|
18359
18158
|
function buildPackageIndex(store) {
|
|
18360
18159
|
const idx = /* @__PURE__ */ new Map();
|
|
@@ -18680,6 +18479,207 @@ var init_problem_package_link = __esm({
|
|
|
18680
18479
|
}
|
|
18681
18480
|
});
|
|
18682
18481
|
|
|
18482
|
+
// ../../packages/embedding/src/model.ts
|
|
18483
|
+
import { mkdirSync as mkdirSync3, existsSync as existsSync4 } from "node:fs";
|
|
18484
|
+
import { homedir } from "node:os";
|
|
18485
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
18486
|
+
import { createRequire } from "node:module";
|
|
18487
|
+
function semanticFloorFor(version2) {
|
|
18488
|
+
if (version2 === EMBEDDING_VERSION || version2 === MODEL_EMBEDDING_VERSION) return 0.25;
|
|
18489
|
+
return 0.5;
|
|
18490
|
+
}
|
|
18491
|
+
function noteHashFallback() {
|
|
18492
|
+
if (warnedHashFallback) return;
|
|
18493
|
+
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") return;
|
|
18494
|
+
warnedHashFallback = true;
|
|
18495
|
+
console.warn(
|
|
18496
|
+
`[errata] embedding model unavailable (${lastError?.message ?? "unknown"}) \u2014 falling back to ${EMBEDDING_VERSION} hash vectors; semantic ranking runs at reduced fidelity`
|
|
18497
|
+
);
|
|
18498
|
+
}
|
|
18499
|
+
function getCacheDir() {
|
|
18500
|
+
return process.env["ERRATA_MODEL_CACHE"] ?? join3(homedir(), ".errata", "models");
|
|
18501
|
+
}
|
|
18502
|
+
async function loadTransformers() {
|
|
18503
|
+
try {
|
|
18504
|
+
return await import("@huggingface/transformers");
|
|
18505
|
+
} catch (err2) {
|
|
18506
|
+
void err2;
|
|
18507
|
+
}
|
|
18508
|
+
try {
|
|
18509
|
+
const seaResourceBase = join3(
|
|
18510
|
+
// execPath dir is where errata.exe lives; resources/ rides alongside.
|
|
18511
|
+
dirname3(process.execPath),
|
|
18512
|
+
"resources",
|
|
18513
|
+
"_resolve.js"
|
|
18514
|
+
);
|
|
18515
|
+
const resourceRequire = createRequire(seaResourceBase);
|
|
18516
|
+
return resourceRequire("@huggingface/transformers");
|
|
18517
|
+
} catch (err2) {
|
|
18518
|
+
lastError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
18519
|
+
return null;
|
|
18520
|
+
}
|
|
18521
|
+
}
|
|
18522
|
+
async function loadPipeline() {
|
|
18523
|
+
const cacheDir = getCacheDir();
|
|
18524
|
+
if (!existsSync4(cacheDir)) mkdirSync3(cacheDir, { recursive: true });
|
|
18525
|
+
try {
|
|
18526
|
+
const tx = await loadTransformers();
|
|
18527
|
+
if (!tx) {
|
|
18528
|
+
throw lastError ?? new Error("transformers package unavailable");
|
|
18529
|
+
}
|
|
18530
|
+
tx.env.cacheDir = cacheDir;
|
|
18531
|
+
tx.env.useFSCache = true;
|
|
18532
|
+
tx.env.allowLocalModels = true;
|
|
18533
|
+
tx.env.allowRemoteModels = process.env["ERRATA_OFFLINE"] !== "1";
|
|
18534
|
+
const pipe2 = await tx.pipeline("feature-extraction", MODEL_NAME, {
|
|
18535
|
+
// Quantized weights cut size 4x; quality drop is negligible for
|
|
18536
|
+
// short-text similarity. Override via env if you want full
|
|
18537
|
+
// precision.
|
|
18538
|
+
dtype: process.env["ERRATA_MODEL_DTYPE"] ?? "q8"
|
|
18539
|
+
});
|
|
18540
|
+
return pipe2;
|
|
18541
|
+
} catch (err2) {
|
|
18542
|
+
lastError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
18543
|
+
return null;
|
|
18544
|
+
}
|
|
18545
|
+
}
|
|
18546
|
+
async function ensureModelLoaded() {
|
|
18547
|
+
if (!pipelinePromise) {
|
|
18548
|
+
pipelinePromise = loadPipeline();
|
|
18549
|
+
}
|
|
18550
|
+
return pipelinePromise;
|
|
18551
|
+
}
|
|
18552
|
+
async function embedTextWithModel(text) {
|
|
18553
|
+
const pipe2 = await ensureModelLoaded();
|
|
18554
|
+
if (!pipe2) {
|
|
18555
|
+
throw new Error(
|
|
18556
|
+
`embedding model could not be loaded: ${lastError?.message ?? "unknown"}`
|
|
18557
|
+
);
|
|
18558
|
+
}
|
|
18559
|
+
if (!text) return new Array(MODEL_EMBEDDING_DIM).fill(0);
|
|
18560
|
+
const out2 = await pipe2(text, { pooling: "mean", normalize: true });
|
|
18561
|
+
return Array.from(out2.data);
|
|
18562
|
+
}
|
|
18563
|
+
async function embedBatchWithModelOrHash(texts) {
|
|
18564
|
+
if (texts.length === 0) return [];
|
|
18565
|
+
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") {
|
|
18566
|
+
return texts.map((t) => {
|
|
18567
|
+
const v = embed(t);
|
|
18568
|
+
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18569
|
+
});
|
|
18570
|
+
}
|
|
18571
|
+
try {
|
|
18572
|
+
const pipe2 = await ensureModelLoaded();
|
|
18573
|
+
if (pipe2) {
|
|
18574
|
+
const out2 = await pipe2(texts, {
|
|
18575
|
+
pooling: "mean",
|
|
18576
|
+
normalize: true
|
|
18577
|
+
});
|
|
18578
|
+
const dim = out2.dims[out2.dims.length - 1] ?? MODEL_EMBEDDING_DIM;
|
|
18579
|
+
const total = texts.length;
|
|
18580
|
+
const results = [];
|
|
18581
|
+
for (let i2 = 0; i2 < total; i2++) {
|
|
18582
|
+
const v = Array.from(out2.data.subarray(i2 * dim, (i2 + 1) * dim));
|
|
18583
|
+
results.push({ vector: v, version: MODEL_EMBEDDING_VERSION, dim });
|
|
18584
|
+
}
|
|
18585
|
+
return results;
|
|
18586
|
+
}
|
|
18587
|
+
} catch {
|
|
18588
|
+
}
|
|
18589
|
+
noteHashFallback();
|
|
18590
|
+
return texts.map((t) => {
|
|
18591
|
+
const v = embed(t);
|
|
18592
|
+
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18593
|
+
});
|
|
18594
|
+
}
|
|
18595
|
+
async function embedTextWithModelOrHash(text) {
|
|
18596
|
+
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") {
|
|
18597
|
+
const v = embed(text);
|
|
18598
|
+
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18599
|
+
}
|
|
18600
|
+
try {
|
|
18601
|
+
const v = await embedTextWithModel(text);
|
|
18602
|
+
return { vector: v, version: MODEL_EMBEDDING_VERSION, dim: v.length };
|
|
18603
|
+
} catch {
|
|
18604
|
+
noteHashFallback();
|
|
18605
|
+
const v = embed(text);
|
|
18606
|
+
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
18607
|
+
}
|
|
18608
|
+
}
|
|
18609
|
+
var MODEL_NAME, MODEL_EMBEDDING_DIM, MODEL_EMBEDDING_VERSION, pipelinePromise, lastError, warnedHashFallback;
|
|
18610
|
+
var init_model = __esm({
|
|
18611
|
+
"../../packages/embedding/src/model.ts"() {
|
|
18612
|
+
"use strict";
|
|
18613
|
+
init_src3();
|
|
18614
|
+
MODEL_NAME = "Xenova/all-MiniLM-L6-v2";
|
|
18615
|
+
MODEL_EMBEDDING_DIM = 384;
|
|
18616
|
+
MODEL_EMBEDDING_VERSION = "minilm-l6-v2";
|
|
18617
|
+
pipelinePromise = null;
|
|
18618
|
+
lastError = null;
|
|
18619
|
+
warnedHashFallback = false;
|
|
18620
|
+
}
|
|
18621
|
+
});
|
|
18622
|
+
|
|
18623
|
+
// ../../packages/embedding/src/index.ts
|
|
18624
|
+
function djb2(s) {
|
|
18625
|
+
let h = 5381;
|
|
18626
|
+
for (let i2 = 0; i2 < s.length; i2++) {
|
|
18627
|
+
h = (h << 5) + h + s.charCodeAt(i2) >>> 0;
|
|
18628
|
+
}
|
|
18629
|
+
return h;
|
|
18630
|
+
}
|
|
18631
|
+
function djb2Signed(s) {
|
|
18632
|
+
let h = 0;
|
|
18633
|
+
for (let i2 = 0; i2 < s.length; i2++) {
|
|
18634
|
+
h = h * 31 + s.charCodeAt(i2) | 0;
|
|
18635
|
+
}
|
|
18636
|
+
return h;
|
|
18637
|
+
}
|
|
18638
|
+
function tokenize2(text) {
|
|
18639
|
+
return text.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 0 && t.length <= 40);
|
|
18640
|
+
}
|
|
18641
|
+
function* charTrigrams(text) {
|
|
18642
|
+
const s = text.toLowerCase();
|
|
18643
|
+
for (let i2 = 0; i2 <= s.length - 3; i2++) {
|
|
18644
|
+
yield s.slice(i2, i2 + 3);
|
|
18645
|
+
}
|
|
18646
|
+
}
|
|
18647
|
+
function embed(text) {
|
|
18648
|
+
const vec = new Array(EMBEDDING_DIM).fill(0);
|
|
18649
|
+
if (!text) return vec;
|
|
18650
|
+
for (const tok of tokenize2(text)) {
|
|
18651
|
+
const idx = djb2(tok) % EMBEDDING_DIM;
|
|
18652
|
+
const sign = djb2Signed(tok) & 1 ? 1 : -1;
|
|
18653
|
+
vec[idx] = vec[idx] + sign;
|
|
18654
|
+
}
|
|
18655
|
+
for (const tri of charTrigrams(text)) {
|
|
18656
|
+
const idx = djb2("3:" + tri) % EMBEDDING_DIM;
|
|
18657
|
+
const sign = djb2Signed("3:" + tri) & 1 ? 1 : -1;
|
|
18658
|
+
vec[idx] = vec[idx] + 0.5 * sign;
|
|
18659
|
+
}
|
|
18660
|
+
let normSq = 0;
|
|
18661
|
+
for (const x of vec) normSq += x * x;
|
|
18662
|
+
if (normSq <= 0) return vec;
|
|
18663
|
+
const inv = 1 / Math.sqrt(normSq);
|
|
18664
|
+
for (let i2 = 0; i2 < vec.length; i2++) vec[i2] = vec[i2] * inv;
|
|
18665
|
+
return vec;
|
|
18666
|
+
}
|
|
18667
|
+
function cosine(a, b) {
|
|
18668
|
+
if (a.length !== b.length || a.length === 0) return 0;
|
|
18669
|
+
let dot = 0;
|
|
18670
|
+
for (let i2 = 0; i2 < a.length; i2++) dot += a[i2] * b[i2];
|
|
18671
|
+
return dot;
|
|
18672
|
+
}
|
|
18673
|
+
var EMBEDDING_DIM, EMBEDDING_VERSION;
|
|
18674
|
+
var init_src3 = __esm({
|
|
18675
|
+
"../../packages/embedding/src/index.ts"() {
|
|
18676
|
+
"use strict";
|
|
18677
|
+
init_model();
|
|
18678
|
+
EMBEDDING_DIM = 256;
|
|
18679
|
+
EMBEDDING_VERSION = "hash-v1";
|
|
18680
|
+
}
|
|
18681
|
+
});
|
|
18682
|
+
|
|
18683
18683
|
// ../../packages/local-graph/src/problem-dedup.ts
|
|
18684
18684
|
function corroborations(n) {
|
|
18685
18685
|
return Number(n.attrs["corroborations"] ?? 0);
|
|
@@ -19276,7 +19276,9 @@ function anchorProblemToWorkingFile(store, problemId, relPath, workspaceId2, ts,
|
|
|
19276
19276
|
from: problemId,
|
|
19277
19277
|
to: file2.id,
|
|
19278
19278
|
type: "ANCHORED_AT",
|
|
19279
|
-
// witnessed = the agent's own declaration, F2-grade; edited = soft heuristic
|
|
19279
|
+
// witnessed = the agent's own declaration, F2-grade; edited = soft heuristic;
|
|
19280
|
+
// hint-confirmed = a read-grade hint whose file was later edited while the
|
|
19281
|
+
// problem stayed open (AC-hint-upgrade) — same soft tier as edited.
|
|
19280
19282
|
confidence: provenance === "witnessed" ? 0.4 : 0.3,
|
|
19281
19283
|
extractionSource: "agent-observed",
|
|
19282
19284
|
createdAt: ts,
|
|
@@ -19296,6 +19298,54 @@ function recordAnchorHint(store, problemId, relPath, provenance, ts) {
|
|
|
19296
19298
|
});
|
|
19297
19299
|
return true;
|
|
19298
19300
|
}
|
|
19301
|
+
function openAnchorHint(p) {
|
|
19302
|
+
const h = p.attrs["anchorHint"];
|
|
19303
|
+
if (!h || typeof h.path !== "string" || h.upgradedAt) return null;
|
|
19304
|
+
return { path: h.path, ts: typeof h.ts === "number" ? h.ts : 0 };
|
|
19305
|
+
}
|
|
19306
|
+
function consumeAnchorHint(store, p, ts) {
|
|
19307
|
+
const hint = p.attrs["anchorHint"];
|
|
19308
|
+
store.updateNode(p.id, { attrs: { ...p.attrs, anchorHint: { ...hint, upgradedAt: ts } } });
|
|
19309
|
+
deriveContextFromAnchors(store, p.id, ts);
|
|
19310
|
+
}
|
|
19311
|
+
function upgradeAnchorHintsForFile(store, relPath, workspaceId2, ts) {
|
|
19312
|
+
let upgraded = 0;
|
|
19313
|
+
for (const p of store.findNodesByLabel("Problem")) {
|
|
19314
|
+
if (p.validTo != null || p.attrs["resolvedAt"]) continue;
|
|
19315
|
+
const hint = openAnchorHint(p);
|
|
19316
|
+
if (!hint || hint.path !== relPath) continue;
|
|
19317
|
+
if (anchorProblemToWorkingFile(store, p.id, relPath, workspaceId2, ts, "hint-confirmed")) {
|
|
19318
|
+
consumeAnchorHint(store, p, ts);
|
|
19319
|
+
upgraded++;
|
|
19320
|
+
}
|
|
19321
|
+
}
|
|
19322
|
+
return upgraded;
|
|
19323
|
+
}
|
|
19324
|
+
function upgradeAnchorHints(store, workspaceId2, ts) {
|
|
19325
|
+
let upgraded = 0;
|
|
19326
|
+
let standing = 0;
|
|
19327
|
+
const filesByPath = /* @__PURE__ */ new Map();
|
|
19328
|
+
for (const f of store.findNodesByLabel("File")) {
|
|
19329
|
+
if (f.attrs["workspaceId"] && f.attrs["workspaceId"] !== workspaceId2) continue;
|
|
19330
|
+
const rel = typeof f.attrs["relPath"] === "string" ? f.attrs["relPath"] : f.description;
|
|
19331
|
+
if (rel && !filesByPath.has(rel)) filesByPath.set(rel, f);
|
|
19332
|
+
}
|
|
19333
|
+
for (const p of store.findNodesByLabel("Problem")) {
|
|
19334
|
+
if (p.validTo != null || p.attrs["resolvedAt"]) continue;
|
|
19335
|
+
const hint = openAnchorHint(p);
|
|
19336
|
+
if (!hint) continue;
|
|
19337
|
+
standing++;
|
|
19338
|
+
const file2 = filesByPath.get(hint.path.trim().replace(/^\.?\//, ""));
|
|
19339
|
+
const changedAt = file2 ? Number(file2.attrs["contentChangedAt"] ?? 0) : 0;
|
|
19340
|
+
if (changedAt <= hint.ts) continue;
|
|
19341
|
+
if (anchorProblemToWorkingFile(store, p.id, hint.path, workspaceId2, ts, "hint-confirmed")) {
|
|
19342
|
+
consumeAnchorHint(store, p, ts);
|
|
19343
|
+
upgraded++;
|
|
19344
|
+
standing--;
|
|
19345
|
+
}
|
|
19346
|
+
}
|
|
19347
|
+
return { upgraded, standing };
|
|
19348
|
+
}
|
|
19299
19349
|
function resolveDesignProblemByStatement(store, statement, fixNote, t) {
|
|
19300
19350
|
const problemId = identityId({ kind: "DesignProblem", statement });
|
|
19301
19351
|
return closeDesignProblem(store, problemId, fixNote, t);
|
|
@@ -19507,6 +19557,7 @@ var init_design_problem = __esm({
|
|
|
19507
19557
|
"use strict";
|
|
19508
19558
|
init_src();
|
|
19509
19559
|
init_src();
|
|
19560
|
+
init_problem_package_link();
|
|
19510
19561
|
init_src3();
|
|
19511
19562
|
init_src2();
|
|
19512
19563
|
init_problem_package_link();
|
|
@@ -22060,6 +22111,22 @@ var init_mechanism_liveness = __esm({
|
|
|
22060
22111
|
effectCounter: "corroboratedEdges",
|
|
22061
22112
|
note: "expected STARVED until VS-corroboration-rate lands \u2014 the channel is genuinely starved"
|
|
22062
22113
|
},
|
|
22114
|
+
{
|
|
22115
|
+
id: "anchor-hint-upgrade",
|
|
22116
|
+
what: "promotes a read-grade anchor hint once its file is edited while the problem stays open",
|
|
22117
|
+
// The maintenance sweep is the reliable invoker (the harvest seam also
|
|
22118
|
+
// counts into capture's anchorHintsUpgraded, but only on edited turns).
|
|
22119
|
+
pass: "semantic-maintenance",
|
|
22120
|
+
// Conditional stamp: only flagged-during-read Problems carry a hint. 302
|
|
22121
|
+
// held one at mechanism birth (census 2026-08-09) — the fed floor is
|
|
22122
|
+
// "the field exists at all", the revisit-sweep precedent.
|
|
22123
|
+
fed: { labels: ["Problem"], attr: "anchorHint", minFraction: 0 },
|
|
22124
|
+
effectCounter: "anchorHintsUpgraded",
|
|
22125
|
+
// The standing hints ARE the queue — without the gauge, "found nothing"
|
|
22126
|
+
// and "runs forever against work it can never clear" read identically.
|
|
22127
|
+
backlogCounter: "anchorHintsStanding",
|
|
22128
|
+
note: "drains as hinted files change; contentChangedAt is forward-only so the backlog moves with real edits"
|
|
22129
|
+
},
|
|
22063
22130
|
{
|
|
22064
22131
|
id: "wm-reinforce-exposure",
|
|
22065
22132
|
what: "labels each paraphrase re-derivation with the prior's exposure (shown/evicted/unshown)",
|
|
@@ -22301,6 +22368,8 @@ __export(src_exports2, {
|
|
|
22301
22368
|
toolNodeId: () => toolNodeId,
|
|
22302
22369
|
toolPriorsFor: () => toolPriorsFor,
|
|
22303
22370
|
triageOf: () => triageOf,
|
|
22371
|
+
upgradeAnchorHints: () => upgradeAnchorHints,
|
|
22372
|
+
upgradeAnchorHintsForFile: () => upgradeAnchorHintsForFile,
|
|
22304
22373
|
walk: () => walk,
|
|
22305
22374
|
wmCalibrationCells: () => wmCalibrationCells
|
|
22306
22375
|
});
|
|
@@ -47833,6 +47902,15 @@ function extractExecutables(command) {
|
|
|
47833
47902
|
}
|
|
47834
47903
|
return out2;
|
|
47835
47904
|
}
|
|
47905
|
+
function commandToolNodeIds(command) {
|
|
47906
|
+
const out2 = [];
|
|
47907
|
+
for (const name2 of extractExecutables(command)) {
|
|
47908
|
+
if (!PUBLIC_TOOLS.has(name2)) continue;
|
|
47909
|
+
if (PLUMBING.has(name2)) continue;
|
|
47910
|
+
out2.push(toolNodeId(name2));
|
|
47911
|
+
}
|
|
47912
|
+
return out2;
|
|
47913
|
+
}
|
|
47836
47914
|
function observeCommandTools(store, command, ts) {
|
|
47837
47915
|
const result = { minted: [], reinforced: [], nodeIds: [] };
|
|
47838
47916
|
const osName = currentOsName();
|
|
@@ -51728,6 +51806,7 @@ function parseAssistantTurns(raw2, includeThinking) {
|
|
|
51728
51806
|
}
|
|
51729
51807
|
if (obj.type !== "assistant" || !Array.isArray(obj.message?.content)) continue;
|
|
51730
51808
|
const parts2 = [];
|
|
51809
|
+
const commands = [];
|
|
51731
51810
|
for (const b of obj.message.content) {
|
|
51732
51811
|
if (b["type"] === "text" && typeof b["text"] === "string") parts2.push(b["text"]);
|
|
51733
51812
|
else if (includeThinking && b["type"] === "thinking" && typeof b["thinking"] === "string")
|
|
@@ -51744,6 +51823,10 @@ function parseAssistantTurns(raw2, includeThinking) {
|
|
|
51744
51823
|
editedFileTurnSeq = turnSeq;
|
|
51745
51824
|
}
|
|
51746
51825
|
}
|
|
51826
|
+
} else if (b["type"] === "tool_use" && b["name"] === "Bash") {
|
|
51827
|
+
const input = b["input"];
|
|
51828
|
+
const cmd2 = input && typeof input === "object" ? input["command"] : void 0;
|
|
51829
|
+
if (typeof cmd2 === "string" && cmd2) commands.push(cmd2);
|
|
51747
51830
|
}
|
|
51748
51831
|
}
|
|
51749
51832
|
const provenance = lastFile ? lastFileTurnSeq === turnSeq ? lastFileIsWrite ? "edited" : "read" : "carried" : void 0;
|
|
@@ -51752,7 +51835,8 @@ function parseAssistantTurns(raw2, includeThinking) {
|
|
|
51752
51835
|
text: parts2.join("\n\n"),
|
|
51753
51836
|
...lastFile ? { workingFile: lastFile } : {},
|
|
51754
51837
|
...provenance ? { workingFileProvenance: provenance } : {},
|
|
51755
|
-
...editedFile && editedFileTurnSeq === turnSeq ? { editedFile } : {}
|
|
51838
|
+
...editedFile && editedFileTurnSeq === turnSeq ? { editedFile } : {},
|
|
51839
|
+
...commands.length > 0 ? { commands } : {}
|
|
51756
51840
|
});
|
|
51757
51841
|
}
|
|
51758
51842
|
return turns;
|
|
@@ -54151,6 +54235,7 @@ function createToolRunState() {
|
|
|
54151
54235
|
}
|
|
54152
54236
|
|
|
54153
54237
|
// src/engine.ts
|
|
54238
|
+
init_tool_index();
|
|
54154
54239
|
init_paths();
|
|
54155
54240
|
|
|
54156
54241
|
// src/profile.ts
|
|
@@ -54669,7 +54754,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
54669
54754
|
}
|
|
54670
54755
|
|
|
54671
54756
|
// src/engine.ts
|
|
54672
|
-
var DAEMON_VERSION = true ? "2.0.2-dev.
|
|
54757
|
+
var DAEMON_VERSION = true ? "2.0.2-dev.615" : "2.0.0-alpha.0";
|
|
54673
54758
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
54674
54759
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
54675
54760
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -55395,6 +55480,7 @@ function createWorkspaceEngine(opts) {
|
|
|
55395
55480
|
let corroboratedEdges = 0;
|
|
55396
55481
|
let touchedFileTurns = 0;
|
|
55397
55482
|
let touchedToolTurns = 0;
|
|
55483
|
+
let anchorHintsUpgraded = 0;
|
|
55398
55484
|
let linked = 0;
|
|
55399
55485
|
const t = Date.now();
|
|
55400
55486
|
let processedTurns = 0;
|
|
@@ -55418,6 +55504,12 @@ function createWorkspaceEngine(opts) {
|
|
|
55418
55504
|
if (processedTurns++ > 0) await yieldToLoop();
|
|
55419
55505
|
const turnFile = turn.workingFile ? toRel(turn.workingFile) : void 0;
|
|
55420
55506
|
const editedTurnFile = turn.editedFile ? toRel(turn.editedFile) : void 0;
|
|
55507
|
+
if (editedTurnFile) {
|
|
55508
|
+
try {
|
|
55509
|
+
anchorHintsUpgraded += upgradeAnchorHintsForFile(store, editedTurnFile, profile.id, t);
|
|
55510
|
+
} catch {
|
|
55511
|
+
}
|
|
55512
|
+
}
|
|
55421
55513
|
if (opts.sharedStore) {
|
|
55422
55514
|
try {
|
|
55423
55515
|
abstracted += harvestAbstractionFences(opts.sharedStore, turn.text, t).applied;
|
|
@@ -55501,6 +55593,10 @@ function createWorkspaceEngine(opts) {
|
|
|
55501
55593
|
}
|
|
55502
55594
|
try {
|
|
55503
55595
|
const touchedFileId = turnFile ? resolveFileId(turnFile) : void 0;
|
|
55596
|
+
if (turn.commands) {
|
|
55597
|
+
const ids = turn.commands.flatMap(commandToolNodeIds);
|
|
55598
|
+
if (ids.length > 0) toolRuns.record(sessionId, ids);
|
|
55599
|
+
}
|
|
55504
55600
|
const touched = new Set(toolRuns.get(sessionId));
|
|
55505
55601
|
if (touchedFileId) touched.add(touchedFileId);
|
|
55506
55602
|
for (const fence of parseIntentFences(turn.text)) {
|
|
@@ -55937,6 +56033,8 @@ function createWorkspaceEngine(opts) {
|
|
|
55937
56033
|
// The sum, so one liveness effectCounter sees an outcome regardless of
|
|
55938
56034
|
// which cell it landed in (WM-join).
|
|
55939
56035
|
exposureOutcomes: exposureShown + exposureEvicted + exposureUnshown,
|
|
56036
|
+
// AC-hint-upgrade (harvest seam): edited-this-turn hint promotions.
|
|
56037
|
+
anchorHintsUpgraded,
|
|
55940
56038
|
touchedFileTurns,
|
|
55941
56039
|
touchedToolTurns,
|
|
55942
56040
|
// Seam diagnostic: sessions holding tool-run records at harvest time.
|
|
@@ -56199,6 +56297,11 @@ function createWorkspaceEngine(opts) {
|
|
|
56199
56297
|
semanticMaintenance() {
|
|
56200
56298
|
const seqBefore = store.currentIngestSeq();
|
|
56201
56299
|
const report = runSemanticMaintenance(store);
|
|
56300
|
+
let hintUpgrade = { upgraded: 0, standing: 0 };
|
|
56301
|
+
try {
|
|
56302
|
+
hintUpgrade = upgradeAnchorHints(store, profile.id, Date.now());
|
|
56303
|
+
} catch {
|
|
56304
|
+
}
|
|
56202
56305
|
appendPassLedger(paths.configDir, "semantic-maintenance", report.durationMs, {
|
|
56203
56306
|
revisitsCleared: report.revisitsCleared,
|
|
56204
56307
|
revisitsStanding: report.revisitsStanding,
|
|
@@ -56209,7 +56312,9 @@ function createWorkspaceEngine(opts) {
|
|
|
56209
56312
|
fixCandidatesStanding: report.fixCandidates.standing,
|
|
56210
56313
|
designResolved: report.designResolved,
|
|
56211
56314
|
claimsEvaluated: report.claimsEvaluated,
|
|
56212
|
-
seqAdvanced: store.currentIngestSeq() - seqBefore
|
|
56315
|
+
seqAdvanced: store.currentIngestSeq() - seqBefore,
|
|
56316
|
+
anchorHintsUpgraded: hintUpgrade.upgraded,
|
|
56317
|
+
anchorHintsStanding: hintUpgrade.standing
|
|
56213
56318
|
});
|
|
56214
56319
|
if (report.revisitsCleared > 0 || report.fixCandidatesSettled > 0 || report.designResolved > 0) {
|
|
56215
56320
|
refreshContextNow();
|
package/package.json
CHANGED
package/pass-worker.mjs
CHANGED
|
@@ -25273,7 +25273,6 @@ function markBoth(store2, a, b, patch, ts) {
|
|
|
25273
25273
|
// ../../packages/local-graph/src/design-problem.ts
|
|
25274
25274
|
init_src();
|
|
25275
25275
|
init_src();
|
|
25276
|
-
init_src2();
|
|
25277
25276
|
|
|
25278
25277
|
// ../../packages/local-graph/src/problem-package-link.ts
|
|
25279
25278
|
init_src();
|
|
@@ -25458,6 +25457,9 @@ function backfillProblemContext(store2, ts) {
|
|
|
25458
25457
|
return report;
|
|
25459
25458
|
}
|
|
25460
25459
|
|
|
25460
|
+
// ../../packages/local-graph/src/design-problem.ts
|
|
25461
|
+
init_src2();
|
|
25462
|
+
|
|
25461
25463
|
// ../../packages/local-graph/src/problem-dedup.ts
|
|
25462
25464
|
init_src();
|
|
25463
25465
|
init_src();
|