@konneal/engine 0.2.195 → 0.2.197
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/{ask-CDJCSFI4.js → ask-64WZ7GK3.js} +2 -2
- package/dist/{chunk-GJHB3LY4.js → chunk-EHXWBBWS.js} +9 -6
- package/dist/{chunk-JEPZ7SNP.js → chunk-TMIVKBN2.js} +44 -26
- package/dist/{chunk-6HW7R5SI.js → chunk-W2MBNLDL.js} +1 -1
- package/dist/completion.d.ts +1 -1
- package/dist/context.d.ts +29 -0
- package/dist/{search-3V6EFKFX.js → search-KDB6QHHQ.js} +2 -2
- package/dist/worker_public/src/index.js +4 -4
- package/docs/spec-pipeline.md +14 -8
- package/package.json +1 -1
- package/workers/worker_public/src/ask.ts +2 -2
- package/workers/worker_public/src/completion.ts +12 -3
- package/workers/worker_public/src/context.ts +37 -0
- package/workers/worker_public/src/pipeline.ts +16 -17
- package/workers/worker_public/src/stages/editionCover.ts +8 -0
- package/workers/worker_public/src/stages/figureSeat.ts +25 -11
- package/workers/worker_public/src/stages/types.ts +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handleAsk
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EHXWBBWS.js";
|
|
4
4
|
import "./chunk-IRCDOFP4.js";
|
|
5
5
|
import "./chunk-2DBXRO4E.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-TMIVKBN2.js";
|
|
7
7
|
import "./chunk-5OSQMWRV.js";
|
|
8
8
|
import "./chunk-M4OCMIWU.js";
|
|
9
9
|
import "./chunk-ETLSWSZ7.js";
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
tokenBudget,
|
|
78
78
|
understandQuery,
|
|
79
79
|
usageTotal
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-TMIVKBN2.js";
|
|
81
81
|
import {
|
|
82
82
|
CAPACITY_PAUSE_MS,
|
|
83
83
|
embed,
|
|
@@ -519,17 +519,20 @@ async function completeTables(db, answer, used) {
|
|
|
519
519
|
}
|
|
520
520
|
return blocks;
|
|
521
521
|
}
|
|
522
|
-
async function completeFigures(db, answer, alreadyAttached, used = [], query) {
|
|
522
|
+
async function completeFigures(db, answer, alreadyAttached, used = [], query, namedDoc = null) {
|
|
523
523
|
const unitForm = (answer.match(/u:fig[\w.-]*/g) ?? []).map((x) => x.replace(/[.,;:)]+$/, ""));
|
|
524
524
|
const bareForm = (answer.match(/\bfig-[\w.-]+\b/g) ?? []).map((x) => x.replace(/[.,;:)]+$/, ""));
|
|
525
525
|
let mentioned = [.../* @__PURE__ */ new Set([...unitForm, ...bareForm.map((x) => x.startsWith("u:") ? x : "u:" + x)])].slice(0, 6);
|
|
526
|
+
const namedLabel = namedDoc ? namedDoc.split(":")[0].trim().toUpperCase() : "";
|
|
527
|
+
const namedPart = namedLabel && /-\d|-[A-Z]\b/.test(namedLabel) ? namedLabel : "";
|
|
528
|
+
const ofNamedPart = (h) => !namedPart || String(h.metadata.docidentifier ?? "").toUpperCase().startsWith(namedPart);
|
|
526
529
|
const docOf = /* @__PURE__ */ new Map();
|
|
527
530
|
const proseNums = new Set(
|
|
528
531
|
(answer.match(/\bFig(?:ure|\.)s?\s*([0-9]{1,2}[a-z]?)/g) ?? []).map((x) => x.replace(/\bFig(?:ure|\.)s?\s*/i, "").toLowerCase())
|
|
529
532
|
);
|
|
530
533
|
if (query && /\bfig(ure|s)?\b/i.test(query)) {
|
|
531
534
|
for (const h of used.slice(0, 12)) {
|
|
532
|
-
if (h.metadata.unit_id && h.metadata.block === "figure") {
|
|
535
|
+
if (h.metadata.unit_id && h.metadata.block === "figure" && ofNamedPart(h)) {
|
|
533
536
|
mentioned.push(h.metadata.unit_id);
|
|
534
537
|
if (!docOf.has(h.metadata.unit_id)) docOf.set(h.metadata.unit_id, { unit_id: h.metadata.unit_id, doc_id: h.metadata.doc_id, docidentifier: h.metadata.docidentifier });
|
|
535
538
|
}
|
|
@@ -537,7 +540,7 @@ async function completeFigures(db, answer, alreadyAttached, used = [], query) {
|
|
|
537
540
|
mentioned = [...new Set(mentioned)].slice(0, 6);
|
|
538
541
|
}
|
|
539
542
|
if (proseNums.size) {
|
|
540
|
-
const fams = [...new Set(used.map((h) => h.metadata.docidentifier).filter(Boolean))].slice(0, 3);
|
|
543
|
+
const fams = [...new Set([namedPart, ...used.map((h) => h.metadata.docidentifier).filter(Boolean)].filter(Boolean))].slice(0, 3);
|
|
541
544
|
for (const fam of fams) {
|
|
542
545
|
const base = String(fam).replace(/\s*\([A-Z]\)\s*$/, "").split(":")[0].trim();
|
|
543
546
|
const rows = await publicationUnitRows(db, "figure", `%${base}%`, 24);
|
|
@@ -3451,7 +3454,7 @@ ${doc.text}` }
|
|
|
3451
3454
|
if (!canonical0.includes(refusalAnswer())) {
|
|
3452
3455
|
try {
|
|
3453
3456
|
streamedCompletionBlocks = await completeTables(env.DB, canonical0, usedHits);
|
|
3454
|
-
streamedCompletionBlocks.push(...await completeFigures(env.DB, canonical0, [...c2.blocks, ...streamedCompletionBlocks], usedHits, q2.query));
|
|
3457
|
+
streamedCompletionBlocks.push(...await completeFigures(env.DB, canonical0, [...c2.blocks, ...streamedCompletionBlocks], usedHits, q2.query, understanding?.docidentifier ?? null));
|
|
3455
3458
|
if (streamedCompletionBlocks.length) console.log("streamed completion:", streamedCompletionBlocks.length, "block(s) attached");
|
|
3456
3459
|
} catch {
|
|
3457
3460
|
}
|
|
@@ -3684,7 +3687,7 @@ ${doc.text}` }
|
|
|
3684
3687
|
completionBlocks = await completeTables(env.DB, answer, used);
|
|
3685
3688
|
if (completionBlocks.length) console.log("contract completion:", completionBlocks.length, "table block(s) attached server-side");
|
|
3686
3689
|
}
|
|
3687
|
-
completionBlocks.push(...await completeFigures(env.DB, answer, [...c2ns.blocks, ...completionBlocks], used, q2.query));
|
|
3690
|
+
completionBlocks.push(...await completeFigures(env.DB, answer, [...c2ns.blocks, ...completionBlocks], used, q2.query, understanding?.docidentifier ?? null));
|
|
3688
3691
|
if (register?.rows?.length && answer.includes(refusalAnswer())) {
|
|
3689
3692
|
console.log("blind-answer: the register note carried rows but the answer refused \u2014 regenerating once");
|
|
3690
3693
|
mark("Re-answering from the register results");
|
|
@@ -21820,6 +21820,21 @@ function refCodec() {
|
|
|
21820
21820
|
return REGISTRY[P().publisher.codec] ?? plainSlug;
|
|
21821
21821
|
}
|
|
21822
21822
|
|
|
21823
|
+
// workers/worker_public/src/selfquery.ts
|
|
21824
|
+
function toVectorizeFilter(f) {
|
|
21825
|
+
if (f.doc_number) {
|
|
21826
|
+
const out = { doc_number: f.doc_number };
|
|
21827
|
+
if (f.edition) out.edition = f.edition;
|
|
21828
|
+
return out;
|
|
21829
|
+
}
|
|
21830
|
+
return void 0;
|
|
21831
|
+
}
|
|
21832
|
+
function standardKeyAllowed(meta, keys) {
|
|
21833
|
+
if (!keys) return true;
|
|
21834
|
+
const k = meta.standard_key;
|
|
21835
|
+
return !k || keys.has(k);
|
|
21836
|
+
}
|
|
21837
|
+
|
|
21823
21838
|
// workers/worker_public/src/context.ts
|
|
21824
21839
|
var NO_CONTEXT = { kind: "none", scoped_to: null };
|
|
21825
21840
|
var MACHINE_STATE_MAX = 60;
|
|
@@ -21872,6 +21887,13 @@ function docScopeFilter(scopeDocNumber) {
|
|
|
21872
21887
|
const base = scopeDocNumber.split("-")[0];
|
|
21873
21888
|
return { doc_number: { $in: base === scopeDocNumber ? [scopeDocNumber] : [scopeDocNumber, base] } };
|
|
21874
21889
|
}
|
|
21890
|
+
function bindLexicalLane(hits, scopes) {
|
|
21891
|
+
const { doc, seal: seal2, standardKeys } = scopes;
|
|
21892
|
+
if (!doc && !seal2 && !standardKeys) return hits;
|
|
21893
|
+
return hits.filter(
|
|
21894
|
+
(h) => (!doc || matchesDocScope(h.metadata, doc)) && (!seal2 || matchesDocScope(h.metadata, seal2.doc_number) && (!seal2.edition || h.metadata.edition === seal2.edition)) && standardKeyAllowed(h.metadata, standardKeys)
|
|
21895
|
+
);
|
|
21896
|
+
}
|
|
21875
21897
|
async function resolveDocScope(env, ctx) {
|
|
21876
21898
|
if (!ctx.doc) return null;
|
|
21877
21899
|
const parsed = parseDocRef(ctx.doc, ctx.edition);
|
|
@@ -22203,21 +22225,6 @@ var dense = {
|
|
|
22203
22225
|
}
|
|
22204
22226
|
};
|
|
22205
22227
|
|
|
22206
|
-
// workers/worker_public/src/selfquery.ts
|
|
22207
|
-
function toVectorizeFilter(f) {
|
|
22208
|
-
if (f.doc_number) {
|
|
22209
|
-
const out = { doc_number: f.doc_number };
|
|
22210
|
-
if (f.edition) out.edition = f.edition;
|
|
22211
|
-
return out;
|
|
22212
|
-
}
|
|
22213
|
-
return void 0;
|
|
22214
|
-
}
|
|
22215
|
-
function standardKeyAllowed(meta, keys) {
|
|
22216
|
-
if (!keys) return true;
|
|
22217
|
-
const k = meta.standard_key;
|
|
22218
|
-
return !k || keys.has(k);
|
|
22219
|
-
}
|
|
22220
|
-
|
|
22221
22228
|
// workers/worker_public/src/stages/citationProbe.ts
|
|
22222
22229
|
var CITE_PATTERN = /\b(?:cite[sd]?|citing|referenc(?:e|es|ed|ing)|list[s]?|quote[sd]?)\b/i;
|
|
22223
22230
|
var REFS_PATTERN = /\b(?:standard|publication|document|normative|bibliograph)/i;
|
|
@@ -22822,8 +22829,10 @@ var editionCover = {
|
|
|
22822
22829
|
failure: "additive",
|
|
22823
22830
|
when: (c) => !c.filters?.edition && c.hits.length > 1,
|
|
22824
22831
|
run: async (c) => {
|
|
22832
|
+
const scope = c.filters?.doc_number;
|
|
22825
22833
|
const poolDocs = /* @__PURE__ */ new Map();
|
|
22826
22834
|
for (const h of c.hits) {
|
|
22835
|
+
if (scope && !matchesDocScope(h.metadata, scope)) continue;
|
|
22827
22836
|
const di = h.metadata.docidentifier;
|
|
22828
22837
|
const ed = h.metadata.edition;
|
|
22829
22838
|
if (!di || !ed) continue;
|
|
@@ -23043,15 +23052,20 @@ var figureSeat = {
|
|
|
23043
23052
|
const dn = String(h.metadata.doc_number ?? "");
|
|
23044
23053
|
if (dn) counts.set(dn, (counts.get(dn) ?? 0) + 1);
|
|
23045
23054
|
}
|
|
23046
|
-
const
|
|
23047
|
-
|
|
23055
|
+
const namedDoc = String(c.u?.docidentifier ?? "").trim();
|
|
23056
|
+
const number = String(c.u?.doc_number ?? "");
|
|
23057
|
+
const byIdentifier = /-\d|-[A-Z]\b/.test(namedDoc.replace(/:\d{4}.*$/, ""));
|
|
23058
|
+
const scope = byIdentifier ? namedDoc : number || [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
23059
|
+
if (!scope) return;
|
|
23048
23060
|
const seated = new Set(
|
|
23049
23061
|
c.finalHits.filter((h) => h.metadata.block === "figure").map((h) => String(h.metadata.unit_id ?? h.id))
|
|
23050
23062
|
);
|
|
23051
|
-
const
|
|
23052
|
-
|
|
23053
|
-
|
|
23054
|
-
|
|
23063
|
+
const cols = "id, doc_id, docidentifier, clause_anchor, clause_title, doc_number, edition, language, status, corpus, tier, text, unit_id";
|
|
23064
|
+
const store = portStore(c.env);
|
|
23065
|
+
let rows = byIdentifier ? await store.prepare(`SELECT ${cols} FROM chunks WHERE docidentifier LIKE ?1 AND block = 'figure' AND unit_id IS NOT NULL ORDER BY clause_anchor LIMIT 3`).bind(`%${namedDoc}`).all() : await store.prepare(`SELECT ${cols} FROM chunks WHERE doc_number = ?1 AND block = 'figure' AND unit_id IS NOT NULL LIMIT 3`).bind(String(scope)).all();
|
|
23066
|
+
if (byIdentifier && !(rows.results ?? []).length && number) {
|
|
23067
|
+
rows = await store.prepare(`SELECT ${cols} FROM chunks WHERE doc_number = ?1 AND block = 'figure' AND unit_id IS NOT NULL LIMIT 3`).bind(number).all();
|
|
23068
|
+
}
|
|
23055
23069
|
const fresh = [];
|
|
23056
23070
|
for (const r of rows.results ?? []) {
|
|
23057
23071
|
if (seated.has(String(r.unit_id))) continue;
|
|
@@ -23063,7 +23077,7 @@ var figureSeat = {
|
|
|
23063
23077
|
metadata: {
|
|
23064
23078
|
doc_id: String(r.doc_id ?? ""),
|
|
23065
23079
|
docidentifier: String(r.docidentifier ?? ""),
|
|
23066
|
-
doc_number: String(r.doc_number ??
|
|
23080
|
+
doc_number: String(r.doc_number ?? number ?? scope),
|
|
23067
23081
|
clause_anchor: r.clause_anchor ? String(r.clause_anchor) : void 0,
|
|
23068
23082
|
clause_title: r.clause_title ? String(r.clause_title) : void 0,
|
|
23069
23083
|
edition: r.edition ? String(r.edition) : void 0,
|
|
@@ -23078,7 +23092,7 @@ var figureSeat = {
|
|
|
23078
23092
|
}
|
|
23079
23093
|
if (!fresh.length) return;
|
|
23080
23094
|
c.finalHits = [...fresh, ...c.finalHits];
|
|
23081
|
-
console.log("figure-seat: seated", fresh.length, "figure chunk(s) of doc",
|
|
23095
|
+
console.log("figure-seat: seated", fresh.length, "figure chunk(s) of", byIdentifier ? namedDoc : "doc " + scope, byIdentifier ? "(named)" : "");
|
|
23082
23096
|
} catch {
|
|
23083
23097
|
}
|
|
23084
23098
|
}
|
|
@@ -23810,10 +23824,14 @@ async function retrieve(env, query, opts = {}) {
|
|
|
23810
23824
|
const vectorP = rq === folded && opts.optimisticVec ? Promise.resolve(opts.optimisticVec) : rq === folded && opts.warmEmbed ? opts.warmEmbed.then((w) => w ?? embed(portModelRunner(env), MODELS.embed, rq)) : embed(portModelRunner(env), MODELS.embed, rq);
|
|
23811
23825
|
const lexicalP = lexicalPrefilter(env, opts.lexicalBoost ? `${rq} ${opts.lexicalBoost}` : rq).catch(() => []);
|
|
23812
23826
|
const [vector, lexicalHits0] = await Promise.all([vectorP, lexicalP]);
|
|
23813
|
-
const lexicalHits =
|
|
23814
|
-
|
|
23815
|
-
|
|
23827
|
+
const lexicalHits = bindLexicalLane(lexicalHits0, {
|
|
23828
|
+
doc: scope?.doc_number ?? null,
|
|
23829
|
+
seal: opts.sealScope ?? null,
|
|
23830
|
+
standardKeys: opts.standardKeys ?? null
|
|
23831
|
+
});
|
|
23816
23832
|
if (lexicalHits.length) console.log("lexical prefilter:", lexicalHits.length, "hits");
|
|
23833
|
+
if (scope?.doc_number && lexicalHits.length !== lexicalHits0.length)
|
|
23834
|
+
console.log("lexical scope:", lexicalHits0.length, "\u2192", lexicalHits.length, "in doc", scope.doc_number);
|
|
23817
23835
|
const ctx = {
|
|
23818
23836
|
env,
|
|
23819
23837
|
query,
|
package/dist/completion.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import type { StoreQuery } from "./ports/store.ts";
|
|
|
2
2
|
import { type ResolvedBlock } from "./refs.ts";
|
|
3
3
|
import type { Hit } from "./pipeline.ts";
|
|
4
4
|
export declare function completeTables(db: StoreQuery, answer: string, used: Hit[]): Promise<ResolvedBlock[]>;
|
|
5
|
-
export declare function completeFigures(db: StoreQuery, answer: string, alreadyAttached: ResolvedBlock[], used?: Hit[], query?: string): Promise<ResolvedBlock[]>;
|
|
5
|
+
export declare function completeFigures(db: StoreQuery, answer: string, alreadyAttached: ResolvedBlock[], used?: Hit[], query?: string, namedDoc?: string | null): Promise<ResolvedBlock[]>;
|
package/dist/context.d.ts
CHANGED
|
@@ -136,6 +136,35 @@ export declare function docScopeFilter(scopeDocNumber: string): {
|
|
|
136
136
|
$in: string[];
|
|
137
137
|
};
|
|
138
138
|
};
|
|
139
|
+
/** The scopes that bind the lexical lane at its SOURCE. The lane ranks
|
|
140
|
+
* the whole corpus and enters the pool twice — the union before the
|
|
141
|
+
* rerank and the RRF after it — so no pool-level cut can hold it: every
|
|
142
|
+
* hard scope filters the list here, once, for both entries. The
|
|
143
|
+
* document scope is the dense lane's own (the same grain rule): the
|
|
144
|
+
* cross-encoder re-scores whatever it is handed, so an unscoped union
|
|
145
|
+
* put 23–40 off-document candidates beside the scoped ones and let
|
|
146
|
+
* another publication's overview into a part-scoped window (measured
|
|
147
|
+
* 2026-12-05). Off-document breadth stays the dense lane's widening. */
|
|
148
|
+
export interface LexicalScopes {
|
|
149
|
+
/** the understood document — absent or null means unscoped */
|
|
150
|
+
doc?: string | null;
|
|
151
|
+
/** a declared context's seal: the family, optionally the edition */
|
|
152
|
+
seal?: {
|
|
153
|
+
doc_number: string;
|
|
154
|
+
edition?: string;
|
|
155
|
+
} | null;
|
|
156
|
+
/** the license entitlement set — absent or null means inert */
|
|
157
|
+
standardKeys?: ReadonlySet<string> | null;
|
|
158
|
+
}
|
|
159
|
+
export declare function bindLexicalLane<T extends {
|
|
160
|
+
metadata: LexicalMeta;
|
|
161
|
+
}>(hits: T[], scopes: LexicalScopes): T[];
|
|
162
|
+
interface LexicalMeta {
|
|
163
|
+
doc_number?: string;
|
|
164
|
+
docidentifier?: string;
|
|
165
|
+
edition?: string;
|
|
166
|
+
standard_key?: string;
|
|
167
|
+
}
|
|
139
168
|
export declare function resolveDocScope(env: any, ctx: DeclaredContext): Promise<DocScope | null>;
|
|
140
169
|
export declare function appliedContext(declared: DeclaredContext | null, scope: DocScope | null, note?: AppliedContext["note"], live?: LiveEcho): AppliedContext;
|
|
141
170
|
/** Validate a context_applied object arriving from a client (the
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
listUserDocuments,
|
|
10
10
|
scoreFaithfulness,
|
|
11
11
|
scoreJudge
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-EHXWBBWS.js";
|
|
13
13
|
import "../../chunk-IRCDOFP4.js";
|
|
14
14
|
import {
|
|
15
15
|
TOOLS_REGISTRY,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "../../chunk-2DBXRO4E.js";
|
|
19
19
|
import {
|
|
20
20
|
handleSearch
|
|
21
|
-
} from "../../chunk-
|
|
21
|
+
} from "../../chunk-W2MBNLDL.js";
|
|
22
22
|
import {
|
|
23
23
|
buildMessages,
|
|
24
24
|
citations,
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
sessionFrom,
|
|
44
44
|
telemetry,
|
|
45
45
|
understandQuery
|
|
46
|
-
} from "../../chunk-
|
|
46
|
+
} from "../../chunk-TMIVKBN2.js";
|
|
47
47
|
import {
|
|
48
48
|
embed,
|
|
49
49
|
generateOnce,
|
|
@@ -1265,7 +1265,7 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
|
|
|
1265
1265
|
const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
|
|
1266
1266
|
payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
|
|
1267
1267
|
} else {
|
|
1268
|
-
const res = name === "ask" ? await (await import("../../ask-
|
|
1268
|
+
const res = name === "ask" ? await (await import("../../ask-64WZ7GK3.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-KDB6QHHQ.js")).handleSearch(env, ctx, inner, tier, key);
|
|
1269
1269
|
payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
|
|
1270
1270
|
}
|
|
1271
1271
|
telemetry(env, ctx, tier, `mcp:${name}`, null, !payload?.error, JSON.stringify(payload).length, await sha256Hex(`${name}:${JSON.stringify(args ?? {})}`), void 0, void 0, { durationMs: Date.now() - t0 });
|
package/docs/spec-pipeline.md
CHANGED
|
@@ -12,7 +12,9 @@ result.
|
|
|
12
12
|
- **Context** (`PipelineContext`) — the mutable state every stage reads
|
|
13
13
|
and writes: `env`, `query` (the user's original wording), `rq` (the
|
|
14
14
|
retrieval query), `u` (query understanding, nullable), `filters` /
|
|
15
|
-
`filter` (the
|
|
15
|
+
`filter` (the document/edition scope — the dense lane's filter and,
|
|
16
|
+
through the prelude's `bindLexicalLane`, the lexical lane's too),
|
|
17
|
+
`vector`, `lexicalHits`,
|
|
16
18
|
`matches` (the candidate pool, Vectorize-match shape), `hits` (the
|
|
17
19
|
ranked pool), `finalHits` (the answer window), `glossary`, `opts`.
|
|
18
20
|
- **Guard** (`when`) — a pure read of the context; absent = always runs.
|
|
@@ -55,7 +57,7 @@ candidate lanes → pool open → pool-level merges → refinement → window as
|
|
|
55
57
|
| 6 | `multi-query` | `u.query_variants` | blocking (per-variant catches inside) | REPLACES `matches` | RRF-fuses the primary ranking with each variant's (k=60, top `retrieveK`). |
|
|
56
58
|
| 7 | `sub-query` | `u.complexity === "complex" && u.sub_queries` | blocking (per-sub catches inside) | appends `matches` | Complementary-perspective union at `subQueryDiscount` (no RRF). |
|
|
57
59
|
| 8 | `pool-open` | — | blocking | `hits` | Converts the candidate pool to the `Hit` shape. Last writer of `matches`; every later stage operates on `hits`. |
|
|
58
|
-
| 9 | `lexical-union` | `lexicalHits.length` | blocking | appends `hits` | Full-corpus BM25 hits dense missed (dense metadata wins on id collision). |
|
|
60
|
+
| 9 | `lexical-union` | `lexicalHits.length` | blocking | appends `hits` | Full-corpus BM25 hits dense missed (dense metadata wins on id collision). The list arrives already bound to every hard scope at the source (the prelude) — under a document scope the union adds the scoped document's hits only. |
|
|
59
61
|
| 10 | `federate` | `opts.federate` | additive (callback catches transport) | appends `hits` | Internal ISO/IEC passages at `federateDiscount`. |
|
|
60
62
|
| 11 | `seal` | `opts.sealScope` | blocking | filters `hits` | The declared context's hard cut: nothing outside the declared family reaches rerank. (The lexical lane is sealed at the SOURCE, in the prelude — not here.) |
|
|
61
63
|
| 11b | `license-scope` | `opts.standardKeys` | blocking | filters `hits` | The license entitlement hard cut (TODO.external-refs/08): a chunk carrying a `standard_key` outside the caller's set never reaches rerank; public chunks (no key) always pass. (The lexical lane is bound at the SOURCE, in the prelude — the lexical union AND the post-rerank lexical-rrf consume the bound list. The post-scope single-document fetches — section-descent, typed-pin parent, edition-cover — are doc-scoped, and a document's key is a per-document constant, so they cannot re-admit a dropped key; citation-probe filters its bibliography push by the same predicate.) |
|
|
@@ -65,7 +67,7 @@ candidate lanes → pool open → pool-level merges → refinement → window as
|
|
|
65
67
|
| 15 | `lexical-rrf` | `hits.length > 1 && lexicalHits.length` | blocking | REPLACES `hits` order | RRF fusion with the full-corpus lexical ranking. Runs even when rerank failed (additive semantics preserve this). |
|
|
66
68
|
| 16 | `citation-probe` | citation-question shape + a document named in the TEXT | additive | appends `hits`, appends `notes` | GraphRAG: bibliography-shaped questions get (a) the family's bibliography sections as passages — FTS over the chunk store, deterministic, text fetched from D1 (getByIds returns no text), pushed to `hits` at score 10 — and (b) the graph's `cites` edges for the family as an authoritative per-edition note on the `notes` channel, identifiers codec-normalized. The graph answers the STRUCTURE; the passages ground it verbatim. |
|
|
67
69
|
| 17 | `corpus-scope` | `opts.datasetScope` | blocking | filters `hits` | Dataset scope (the sidebar toggles): drops hits whose corpus the request excludes. LAST of the pool-assembly stages — the lexical union above refills the pool after rerank, so filtering earlier let excluded corpora back in. Corpora the toggle model doesn't name pass untouched. |
|
|
68
|
-
| 18 | `edition-cover` | `!filters.edition && hits.length > 1` | additive | appends `hits` | Registry-driven cover: when a pool holds only stale editions of a document whose ACTIVE edition the documents registry knows, fetch the current edition's chunks and add at `editionCoverDiscount` — steering needs the successor present to demote. |
|
|
70
|
+
| 18 | `edition-cover` | `!filters.edition && hits.length > 1` | additive | appends `hits` | Registry-driven cover: when a pool holds only stale editions of a document whose ACTIVE edition the documents registry knows, fetch the current edition's chunks and add at `editionCoverDiscount` — steering needs the successor present to demote. Under a document scope the pooled documents are the scope's own (`matchesDocScope`): an off-document passage a cross-document lane merged never gets its publication covered. |
|
|
69
71
|
| 19 | `std-ref-nudge` | query names ISO/IEC/ASTM/EN | blocking | `hits[].rerank_score`, sorts | Standard-reference nudge: chunks CARRYING such a citation get `stdRefNudgeSpread × spread` — the citing clause is the answer to "which standard does X invoke", and generic family prose otherwise fills the window (l5a measured). |
|
|
70
72
|
| 20 | `term-nudge` | `u.term` | blocking | `hits[].rerank_score`, sorts | Clause whose head IS the asked term gets `termNudgeSpread × spread` (decisive). |
|
|
71
73
|
| 21 | `concept-steer` | `glossary.length && hits.length > 1` | blocking | `hits[].rerank_score`, sorts | Vocabulary-link families boosted (`conceptSteerSpread`). |
|
|
@@ -131,11 +133,15 @@ The invariants:
|
|
|
131
133
|
## The prelude (not stages, deliberately)
|
|
132
134
|
|
|
133
135
|
`retrieve()` resolves the query fold, runs the dense embed and the
|
|
134
|
-
full-corpus lexical prefilter **in parallel**, and
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
full-corpus lexical prefilter **in parallel**, and binds the lexical
|
|
137
|
+
lane at the source to every hard scope (`bindLexicalLane`: the declared
|
|
138
|
+
context's seal, the license entitlement set, and the understood
|
|
139
|
+
document — the dense lane's own scope, the same grain rule). The lane
|
|
140
|
+
re-enters the pool twice (union before the rerank, RRF after it), so
|
|
141
|
+
the binding must precede both. This parallelism is load-bearing (Option
|
|
142
|
+
C: the optimistic vector may already be resolved; embed and lexical
|
|
143
|
+
must not serialize) — it stays in the composition layer, not in stages,
|
|
144
|
+
so no stage boundary can introduce a serial round-trip on the hot path.
|
|
139
145
|
|
|
140
146
|
## Verification
|
|
141
147
|
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"playwright": "^1.62.1",
|
|
28
28
|
"yaml": "^2.9.1"
|
|
29
29
|
},
|
|
30
|
-
"version": "0.2.
|
|
30
|
+
"version": "0.2.197",
|
|
31
31
|
"description": "The Konneal engine: the publisher-agnostic build pipeline and API plane for standards intelligence (retrieval, answer contract, verdicts, evaluation).",
|
|
32
32
|
"license": "BSD-3-Clause",
|
|
33
33
|
"type": "module",
|
|
@@ -1959,7 +1959,7 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
|
|
|
1959
1959
|
if (!canonical0.includes(refusalAnswer())) {
|
|
1960
1960
|
try {
|
|
1961
1961
|
streamedCompletionBlocks = await completeTables(env.DB, canonical0, usedHits);
|
|
1962
|
-
streamedCompletionBlocks.push(...(await completeFigures(env.DB, canonical0, [...c2.blocks, ...streamedCompletionBlocks], usedHits, q.query)));
|
|
1962
|
+
streamedCompletionBlocks.push(...(await completeFigures(env.DB, canonical0, [...c2.blocks, ...streamedCompletionBlocks], usedHits, q.query, understanding?.docidentifier ?? null)));
|
|
1963
1963
|
if (streamedCompletionBlocks.length) console.log("streamed completion:", streamedCompletionBlocks.length, "block(s) attached");
|
|
1964
1964
|
} catch { /* additive — the answer stands without the blocks */ }
|
|
1965
1965
|
}
|
|
@@ -2283,7 +2283,7 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
|
|
|
2283
2283
|
}
|
|
2284
2284
|
|
|
2285
2285
|
// figure completion (#172) — see ./completion for the rationale
|
|
2286
|
-
completionBlocks.push(...(await completeFigures(env.DB, answer!, [...c2ns.blocks, ...completionBlocks], used, q.query)));
|
|
2286
|
+
completionBlocks.push(...(await completeFigures(env.DB, answer!, [...c2ns.blocks, ...completionBlocks], used, q.query, understanding?.docidentifier ?? null)));
|
|
2287
2287
|
|
|
2288
2288
|
// the blind-answer regeneration (2026-10-03, live on the photo case):
|
|
2289
2289
|
// the multimodal call can answer AROUND an attached image — a 200 whose
|
|
@@ -59,6 +59,7 @@ export async function completeFigures(
|
|
|
59
59
|
alreadyAttached: ResolvedBlock[],
|
|
60
60
|
used: Hit[] = [],
|
|
61
61
|
query?: string,
|
|
62
|
+
namedDoc: string | null = null,
|
|
62
63
|
): Promise<ResolvedBlock[]> {
|
|
63
64
|
// the model names figures BOTH ways: unit ids (u:fig-3) and bare
|
|
64
65
|
// producer anchors (fig-2a of D 36) — collect both forms; bare
|
|
@@ -67,7 +68,15 @@ export async function completeFigures(
|
|
|
67
68
|
const unitForm = (answer.match(/u:fig[\w.-]*/g) ?? []).map((x) => x.replace(/[.,;:)]+$/, ""));
|
|
68
69
|
const bareForm = (answer.match(/\bfig-[\w.-]+\b/g) ?? []).map((x) => x.replace(/[.,;:)]+$/, ""));
|
|
69
70
|
let mentioned = [...new Set([...unitForm, ...bareForm.map((x) => (x.startsWith("u:") ? x : "u:" + x))])].slice(0, 6);
|
|
70
|
-
// the
|
|
71
|
+
// the part the question names ("Figure 2 in OIML R 60-2"): every part of
|
|
72
|
+
// a family carries the family's number, so without this the completion
|
|
73
|
+
// attached the sibling part's figures — R 60-1's under a question about
|
|
74
|
+
// R 60-2 (measured 2026-12-05). The part comes from the understanding's
|
|
75
|
+
// normalized reference (the text scan keeps only the family); a
|
|
76
|
+
// family-level or absent reference changes nothing.
|
|
77
|
+
const namedLabel = namedDoc ? namedDoc.split(":")[0].trim().toUpperCase() : "";
|
|
78
|
+
const namedPart = namedLabel && /-\d|-[A-Z]\b/.test(namedLabel) ? namedLabel : "";
|
|
79
|
+
const ofNamedPart = (h: Hit) => !namedPart || String(h.metadata.docidentifier ?? "").toUpperCase().startsWith(namedPart);
|
|
71
80
|
const docOf = new Map<string, UnitKey>();
|
|
72
81
|
// natural prose names figures without any identifier at all — "Figure 3
|
|
73
82
|
// of R 60-2 shows…" (the #172 residual): resolve those by number within
|
|
@@ -84,7 +93,7 @@ export async function completeFigures(
|
|
|
84
93
|
// a hope that the model names an unnameable id
|
|
85
94
|
if (query && /\bfig(ure|s)?\b/i.test(query)) {
|
|
86
95
|
for (const h of used.slice(0, 12)) {
|
|
87
|
-
if (h.metadata.unit_id && h.metadata.block === "figure") {
|
|
96
|
+
if (h.metadata.unit_id && h.metadata.block === "figure" && ofNamedPart(h)) {
|
|
88
97
|
mentioned.push(h.metadata.unit_id);
|
|
89
98
|
if (!docOf.has(h.metadata.unit_id)) docOf.set(h.metadata.unit_id, { unit_id: h.metadata.unit_id, doc_id: h.metadata.doc_id, docidentifier: h.metadata.docidentifier });
|
|
90
99
|
}
|
|
@@ -92,7 +101,7 @@ export async function completeFigures(
|
|
|
92
101
|
mentioned = [...new Set(mentioned)].slice(0, 6);
|
|
93
102
|
}
|
|
94
103
|
if (proseNums.size) {
|
|
95
|
-
const fams = [...new Set(used.map((h) => h.metadata.docidentifier).filter(Boolean))].slice(0, 3);
|
|
104
|
+
const fams = [...new Set([namedPart, ...used.map((h) => h.metadata.docidentifier).filter(Boolean)].filter(Boolean))].slice(0, 3);
|
|
96
105
|
for (const fam of fams) {
|
|
97
106
|
const base = String(fam).replace(/\s*\([A-Z]\)\s*$/, "").split(":")[0].trim();
|
|
98
107
|
const rows = await publicationUnitRows(db, "figure", `%${base}%`, 24);
|
|
@@ -140,6 +140,7 @@ export function parseContext(body: any): DeclaredContext | null {
|
|
|
140
140
|
|
|
141
141
|
import { refCodec, type DocScope } from "./codecs.ts";
|
|
142
142
|
import { P } from "./profile.ts";
|
|
143
|
+
import { standardKeyAllowed } from "./selfquery.ts";
|
|
143
144
|
export type { DocScope };
|
|
144
145
|
|
|
145
146
|
/** Parse the two reference forms the estate speaks: the URN the SMART
|
|
@@ -203,6 +204,42 @@ export function docScopeFilter(scopeDocNumber: string): { doc_number: { $in: str
|
|
|
203
204
|
return { doc_number: { $in: base === scopeDocNumber ? [scopeDocNumber] : [scopeDocNumber, base] } };
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
/** The scopes that bind the lexical lane at its SOURCE. The lane ranks
|
|
208
|
+
* the whole corpus and enters the pool twice — the union before the
|
|
209
|
+
* rerank and the RRF after it — so no pool-level cut can hold it: every
|
|
210
|
+
* hard scope filters the list here, once, for both entries. The
|
|
211
|
+
* document scope is the dense lane's own (the same grain rule): the
|
|
212
|
+
* cross-encoder re-scores whatever it is handed, so an unscoped union
|
|
213
|
+
* put 23–40 off-document candidates beside the scoped ones and let
|
|
214
|
+
* another publication's overview into a part-scoped window (measured
|
|
215
|
+
* 2026-12-05). Off-document breadth stays the dense lane's widening. */
|
|
216
|
+
export interface LexicalScopes {
|
|
217
|
+
/** the understood document — absent or null means unscoped */
|
|
218
|
+
doc?: string | null;
|
|
219
|
+
/** a declared context's seal: the family, optionally the edition */
|
|
220
|
+
seal?: { doc_number: string; edition?: string } | null;
|
|
221
|
+
/** the license entitlement set — absent or null means inert */
|
|
222
|
+
standardKeys?: ReadonlySet<string> | null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function bindLexicalLane<T extends { metadata: LexicalMeta }>(hits: T[], scopes: LexicalScopes): T[] {
|
|
226
|
+
const { doc, seal, standardKeys } = scopes;
|
|
227
|
+
if (!doc && !seal && !standardKeys) return hits;
|
|
228
|
+
return hits.filter(
|
|
229
|
+
(h) =>
|
|
230
|
+
(!doc || matchesDocScope(h.metadata, doc)) &&
|
|
231
|
+
(!seal || (matchesDocScope(h.metadata, seal.doc_number) && (!seal.edition || h.metadata.edition === seal.edition))) &&
|
|
232
|
+
standardKeyAllowed(h.metadata, standardKeys),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface LexicalMeta {
|
|
237
|
+
doc_number?: string;
|
|
238
|
+
docidentifier?: string;
|
|
239
|
+
edition?: string;
|
|
240
|
+
standard_key?: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
206
243
|
export async function resolveDocScope(env: any, ctx: DeclaredContext): Promise<DocScope | null> {
|
|
207
244
|
if (!ctx.doc) return null;
|
|
208
245
|
const parsed = parseDocRef(ctx.doc, ctx.edition);
|
|
@@ -33,8 +33,8 @@ export function promptVars(extra: Record<string, string> = {}): Record<string, s
|
|
|
33
33
|
export function fill(template: string, vars: Record<string, string>): string {
|
|
34
34
|
return template.replace(/\{\{(\w+)\}\}/g, (_m, k: string) => (k in vars ? vars[k] : ""));
|
|
35
35
|
}
|
|
36
|
-
import { QueryFilters, toVectorizeFilter
|
|
37
|
-
import {
|
|
36
|
+
import { QueryFilters, toVectorizeFilter } from "./selfquery";
|
|
37
|
+
import { bindLexicalLane } from "./context";
|
|
38
38
|
import { hitQuality } from "./quality";
|
|
39
39
|
import { lexicalPrefilter } from "./lexical";
|
|
40
40
|
import { positionOrder } from "./structural";
|
|
@@ -129,22 +129,21 @@ export async function retrieve(
|
|
|
129
129
|
: embed(portModelRunner(env), MODELS.embed, rq);
|
|
130
130
|
const lexicalP = lexicalPrefilter(env, opts.lexicalBoost ? `${rq} ${opts.lexicalBoost}` : rq).catch(() => [] as Hit[]);
|
|
131
131
|
const [vector, lexicalHits0] = await Promise.all([vectorP, lexicalP]);
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
standardKeyAllowed(h.metadata, opts.standardKeys),
|
|
145
|
-
)
|
|
146
|
-
: lexicalHits0);
|
|
132
|
+
// Every hard scope binds the lexical lane at the SOURCE: the lane
|
|
133
|
+
// re-enters the pool twice (lexical-union pre-rerank and lexical-rrf
|
|
134
|
+
// post-rerank — both consume this list), so the RRF fusion mixes the
|
|
135
|
+
// full-corpus lexical ranking into the final hits past any pool-level
|
|
136
|
+
// cut. Under a seal the lane is the FAMILY's hits only; the license
|
|
137
|
+
// entitlement scope binds it the same way; and the understood document
|
|
138
|
+
// scopes it exactly as it scopes the dense lane (bindLexicalLane).
|
|
139
|
+
const lexicalHits = bindLexicalLane(lexicalHits0, {
|
|
140
|
+
doc: scope?.doc_number ?? null,
|
|
141
|
+
seal: opts.sealScope ?? null,
|
|
142
|
+
standardKeys: opts.standardKeys ?? null,
|
|
143
|
+
});
|
|
147
144
|
if (lexicalHits.length) console.log("lexical prefilter:", lexicalHits.length, "hits");
|
|
145
|
+
if (scope?.doc_number && lexicalHits.length !== lexicalHits0.length)
|
|
146
|
+
console.log("lexical scope:", lexicalHits0.length, "→", lexicalHits.length, "in doc", scope.doc_number);
|
|
148
147
|
|
|
149
148
|
const ctx: PipelineContext = {
|
|
150
149
|
env, query, rq, folded, u, filters, filter, vector, lexicalHits,
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// left every 2021 chunk out). One registry read per query; at most
|
|
8
8
|
// `maxDocs` documents covered; additive — any failure skips.
|
|
9
9
|
import { THRESHOLDS } from "../config.ts";
|
|
10
|
+
import { matchesDocScope } from "../context.ts";
|
|
10
11
|
import type { Stage } from "./types.ts";
|
|
11
12
|
import { rowsToHits } from "../lexical.ts";
|
|
12
13
|
|
|
@@ -20,8 +21,15 @@ export const editionCover: Stage = {
|
|
|
20
21
|
failure: "additive",
|
|
21
22
|
when: (c) => !c.filters?.edition && c.hits.length > 1,
|
|
22
23
|
run: async (c) => {
|
|
24
|
+
const scope = c.filters?.doc_number;
|
|
23
25
|
const poolDocs = new Map<string, Set<string>>();
|
|
24
26
|
for (const h of c.hits) {
|
|
27
|
+
// a document scope binds the cover at the scope's grain: the pool
|
|
28
|
+
// may still hold an off-document passage a cross-document lane
|
|
29
|
+
// merged, and covering THAT publication seated three of its cover
|
|
30
|
+
// chunks at one score right beside the top passage (measured
|
|
31
|
+
// 2026-12-05: a part-scoped figure window led with them)
|
|
32
|
+
if (scope && !matchesDocScope(h.metadata, scope)) continue;
|
|
25
33
|
const di = h.metadata.docidentifier;
|
|
26
34
|
const ed = h.metadata.edition;
|
|
27
35
|
if (!di || !ed) continue;
|
|
@@ -23,18 +23,32 @@ export const figureSeat: Stage = {
|
|
|
23
23
|
const dn = String((h.metadata as any).doc_number ?? "");
|
|
24
24
|
if (dn) counts.set(dn, (counts.get(dn) ?? 0) + 1);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// The asked publication at its own grain: every part of a family
|
|
27
|
+
// carries the family's doc_number (R 60-1, R 60-2 and R 60-A all say
|
|
28
|
+
// "60"), so a seat by number returned three of the family's eight
|
|
29
|
+
// figures regardless of the part the question named — "Figure 2 in
|
|
30
|
+
// OIML R 60-2" seated R 60-1's figures (measured 2026-12-05). A part
|
|
31
|
+
// reference is seated by its own identifier; a family reference keeps
|
|
32
|
+
// the number.
|
|
33
|
+
const namedDoc = String((c.u as any)?.docidentifier ?? "").trim();
|
|
34
|
+
const number = String((c.u as any)?.doc_number ?? "");
|
|
35
|
+
const byIdentifier = /-\d|-[A-Z]\b/.test(namedDoc.replace(/:\d{4}.*$/, ""));
|
|
36
|
+
const scope = byIdentifier ? namedDoc : number || [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
37
|
+
if (!scope) return;
|
|
28
38
|
const seated = new Set(
|
|
29
39
|
c.finalHits.filter((h: Hit) => (h.metadata as any).block === "figure").map((h: Hit) => String((h.metadata as any).unit_id ?? h.id)),
|
|
30
40
|
);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
.bind(String(
|
|
37
|
-
|
|
41
|
+
const cols =
|
|
42
|
+
"id, doc_id, docidentifier, clause_anchor, clause_title, doc_number, edition, language, status, corpus, tier, text, unit_id";
|
|
43
|
+
const store = portStore(c.env);
|
|
44
|
+
let rows = byIdentifier
|
|
45
|
+
? await store.prepare(`SELECT ${cols} FROM chunks WHERE docidentifier LIKE ?1 AND block = 'figure' AND unit_id IS NOT NULL ORDER BY clause_anchor LIMIT 3`).bind(`%${namedDoc}`).all()
|
|
46
|
+
: await store.prepare(`SELECT ${cols} FROM chunks WHERE doc_number = ?1 AND block = 'figure' AND unit_id IS NOT NULL LIMIT 3`).bind(String(scope)).all();
|
|
47
|
+
if (byIdentifier && !(rows.results ?? []).length && number) {
|
|
48
|
+
// an identifier spelling the chunks do not carry — the family's
|
|
49
|
+
// figures stand in rather than none
|
|
50
|
+
rows = await store.prepare(`SELECT ${cols} FROM chunks WHERE doc_number = ?1 AND block = 'figure' AND unit_id IS NOT NULL LIMIT 3`).bind(number).all();
|
|
51
|
+
}
|
|
38
52
|
const fresh: Hit[] = [];
|
|
39
53
|
for (const r of (rows.results ?? []) as any[]) {
|
|
40
54
|
if (seated.has(String(r.unit_id))) continue;
|
|
@@ -46,7 +60,7 @@ export const figureSeat: Stage = {
|
|
|
46
60
|
metadata: {
|
|
47
61
|
doc_id: String(r.doc_id ?? ""),
|
|
48
62
|
docidentifier: String(r.docidentifier ?? ""),
|
|
49
|
-
doc_number: String(r.doc_number ??
|
|
63
|
+
doc_number: String(r.doc_number ?? number ?? scope),
|
|
50
64
|
clause_anchor: r.clause_anchor ? String(r.clause_anchor) : undefined,
|
|
51
65
|
clause_title: r.clause_title ? String(r.clause_title) : undefined,
|
|
52
66
|
edition: r.edition ? String(r.edition) : undefined,
|
|
@@ -61,7 +75,7 @@ export const figureSeat: Stage = {
|
|
|
61
75
|
}
|
|
62
76
|
if (!fresh.length) return;
|
|
63
77
|
c.finalHits = [...fresh, ...c.finalHits];
|
|
64
|
-
console.log("figure-seat: seated", fresh.length, "figure chunk(s) of doc",
|
|
78
|
+
console.log("figure-seat: seated", fresh.length, "figure chunk(s) of", byIdentifier ? namedDoc : "doc " + scope, byIdentifier ? "(named)" : "");
|
|
65
79
|
} catch {
|
|
66
80
|
// additive — the text ranking stands
|
|
67
81
|
}
|
|
@@ -99,7 +99,7 @@ export interface PipelineContext {
|
|
|
99
99
|
filters: QueryFilters | null; // dense-stage may drop a guessed edition pin
|
|
100
100
|
filter: Record<string, string> | null | undefined; // toVectorizeFilter's output
|
|
101
101
|
vector: number[]; // embedding of rq
|
|
102
|
-
lexicalHits: Hit[]; // full-corpus BM25 ranking (
|
|
102
|
+
lexicalHits: Hit[]; // full-corpus BM25 ranking (bound at the source to every hard scope: seal, license, document)
|
|
103
103
|
matches: any[]; // the candidate pool (Vectorize match shape, pre-Hit)
|
|
104
104
|
hits: Hit[]; // the ranked pool from poolOpen onward
|
|
105
105
|
finalHits: Hit[]; // the answer window
|