@konneal/engine 0.2.166 → 0.2.168
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-RUMLIO35.js +16 -0
- package/dist/{chunk-FQYHT4VC.js → chunk-4FZNJR5Q.js} +1 -1
- package/dist/{chunk-2FME6R6J.js → chunk-AGL4NGXY.js} +6 -6
- package/dist/{chunk-SIT4XSD5.js → chunk-BFOCWZ7U.js} +4 -4
- package/dist/{chunk-5AME76UW.js → chunk-LIZJLRXZ.js} +64 -6
- package/dist/{chunk-5V2A3CAH.js → chunk-LU7VIMD7.js} +1 -1
- package/dist/{chunk-AP73VIHB.js → chunk-PTY2OSC4.js} +3 -3
- package/dist/{chunk-TTEJQ5XA.js → chunk-QY556RJM.js} +1 -1
- package/dist/{chunk-OLO45N6D.js → chunk-Y7LWT24U.js} +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/search-Y4Y46Y57.js +14 -0
- package/dist/{tools-PR7PFAV6.js → tools-3RP7DHGI.js} +4 -4
- package/dist/worker_mcp/src/index.js +2 -2
- package/dist/worker_public/src/config.js +1 -1
- package/dist/worker_public/src/index.js +10 -10
- package/dist/worker_public/src/requestScope.js +2 -2
- package/package.json +1 -1
- package/workers/worker_public/src/config.ts +1 -1
- package/workers/worker_public/src/stages/dense.ts +10 -3
- package/workers/worker_public/src/stages/figureSeat.ts +69 -0
- package/workers/worker_public/src/stages/index.ts +2 -0
- package/dist/ask-XJOOMAXU.js +0 -16
- package/dist/search-6KM4P2E5.js +0 -14
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleAsk
|
|
3
|
+
} from "./chunk-AGL4NGXY.js";
|
|
4
|
+
import "./chunk-ECOYO7EX.js";
|
|
5
|
+
import "./chunk-PTY2OSC4.js";
|
|
6
|
+
import "./chunk-LIZJLRXZ.js";
|
|
7
|
+
import "./chunk-LU7VIMD7.js";
|
|
8
|
+
import "./chunk-QY556RJM.js";
|
|
9
|
+
import "./chunk-ETLSWSZ7.js";
|
|
10
|
+
import "./chunk-Y7LWT24U.js";
|
|
11
|
+
import "./chunk-4FZNJR5Q.js";
|
|
12
|
+
import "./chunk-3FYJM7LH.js";
|
|
13
|
+
import "./chunk-LSZTJI7V.js";
|
|
14
|
+
export {
|
|
15
|
+
handleAsk
|
|
16
|
+
};
|
|
@@ -92,7 +92,7 @@ var THRESHOLDS = {
|
|
|
92
92
|
// when the in-code doc scope cuts the vector-level top-K to zero, the
|
|
93
93
|
// re-query runs at this depth and scopes in code (the native filter is
|
|
94
94
|
// dead — measured 2026-10-05)
|
|
95
|
-
denseStarveK:
|
|
95
|
+
denseStarveK: 100,
|
|
96
96
|
entailmentGate: true,
|
|
97
97
|
entailmentBudgetMs: 6e3,
|
|
98
98
|
entailmentSupportedFloor: 0.9,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
tableRetyped,
|
|
33
33
|
toolNote,
|
|
34
34
|
verdictNote
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-PTY2OSC4.js";
|
|
36
36
|
import {
|
|
37
37
|
NO_CONTEXT,
|
|
38
38
|
STAGE_NAMES,
|
|
@@ -75,18 +75,18 @@ import {
|
|
|
75
75
|
tokenBudget,
|
|
76
76
|
understandQuery,
|
|
77
77
|
usageTotal
|
|
78
|
-
} from "./chunk-
|
|
78
|
+
} from "./chunk-LIZJLRXZ.js";
|
|
79
79
|
import {
|
|
80
80
|
embed,
|
|
81
81
|
generateOnce
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-LU7VIMD7.js";
|
|
83
83
|
import {
|
|
84
84
|
corsHeaders,
|
|
85
85
|
err,
|
|
86
86
|
json,
|
|
87
87
|
readJson,
|
|
88
88
|
validateQuery
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-QY556RJM.js";
|
|
90
90
|
import {
|
|
91
91
|
cacheableAnswer,
|
|
92
92
|
canonicalRefusal,
|
|
@@ -99,7 +99,7 @@ import {
|
|
|
99
99
|
requestSalt,
|
|
100
100
|
resolveRequestScope,
|
|
101
101
|
standardKeysFrom
|
|
102
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-Y7LWT24U.js";
|
|
103
103
|
import {
|
|
104
104
|
LIMITS,
|
|
105
105
|
MODELS,
|
|
@@ -110,7 +110,7 @@ import {
|
|
|
110
110
|
requestEffort,
|
|
111
111
|
roleModel,
|
|
112
112
|
sha256Hex
|
|
113
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-4FZNJR5Q.js";
|
|
114
114
|
import {
|
|
115
115
|
P
|
|
116
116
|
} from "./chunk-3FYJM7LH.js";
|
|
@@ -6,24 +6,24 @@ import {
|
|
|
6
6
|
sessionFrom,
|
|
7
7
|
telemetry,
|
|
8
8
|
understandQuery
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LIZJLRXZ.js";
|
|
10
10
|
import {
|
|
11
11
|
corsHeaders,
|
|
12
12
|
err,
|
|
13
13
|
json,
|
|
14
14
|
readJson,
|
|
15
15
|
validateQuery
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-QY556RJM.js";
|
|
17
17
|
import {
|
|
18
18
|
entitlementScope,
|
|
19
19
|
standardKeysFrom
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-Y7LWT24U.js";
|
|
21
21
|
import {
|
|
22
22
|
LIMITS,
|
|
23
23
|
MODELS,
|
|
24
24
|
num,
|
|
25
25
|
sha256Hex
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4FZNJR5Q.js";
|
|
27
27
|
import {
|
|
28
28
|
portModelRunner
|
|
29
29
|
} from "./chunk-LSZTJI7V.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
embed,
|
|
3
3
|
rerank
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LU7VIMD7.js";
|
|
5
5
|
import {
|
|
6
6
|
bubbleConfirmPage,
|
|
7
7
|
isAllowedBubbleOrigin
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QY556RJM.js";
|
|
9
9
|
import {
|
|
10
10
|
DATASETS,
|
|
11
11
|
LIMITS,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
processExpansion,
|
|
16
16
|
sha256Hex,
|
|
17
17
|
today
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4FZNJR5Q.js";
|
|
19
19
|
import {
|
|
20
20
|
P
|
|
21
21
|
} from "./chunk-3FYJM7LH.js";
|
|
@@ -22165,9 +22165,13 @@ var dense = {
|
|
|
22165
22165
|
if (filters.edition) matches = matches.filter((m) => !m.metadata?.edition || String(m.metadata.edition) === filters.edition);
|
|
22166
22166
|
console.log("dense scope (in code):", before, "\u2192", matches.length, "in doc", filters.doc_number, filters.edition ? `@${filters.edition}` : "");
|
|
22167
22167
|
if (!matches.length) {
|
|
22168
|
-
|
|
22169
|
-
|
|
22170
|
-
|
|
22168
|
+
try {
|
|
22169
|
+
const wide = await env.VECTORIZE.query(vector, { ...q, topK: THRESHOLDS.denseStarveK });
|
|
22170
|
+
matches = (wide.matches ?? []).filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number));
|
|
22171
|
+
console.log("dense scope starvation \u2192 deep re-query:", matches.length, "doc members in the top", THRESHOLDS.denseStarveK);
|
|
22172
|
+
} catch (e) {
|
|
22173
|
+
console.log("dense scope starvation re-query failed:", String(e).slice(0, 120));
|
|
22174
|
+
}
|
|
22171
22175
|
}
|
|
22172
22176
|
if (filters && filters.edition && matches.length < 3) {
|
|
22173
22177
|
const docOnly = allMatches.filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number));
|
|
@@ -22990,6 +22994,59 @@ Which of these figures best answers the question? Reply with ONLY: {"pick": N} u
|
|
|
22990
22994
|
}
|
|
22991
22995
|
};
|
|
22992
22996
|
|
|
22997
|
+
// workers/worker_public/src/stages/figureSeat.ts
|
|
22998
|
+
var figureSeat = {
|
|
22999
|
+
name: "figure-seat",
|
|
23000
|
+
failure: "additive",
|
|
23001
|
+
when: (c) => FIGURE_Q.test(c.query),
|
|
23002
|
+
run: async (c) => {
|
|
23003
|
+
try {
|
|
23004
|
+
const counts = /* @__PURE__ */ new Map();
|
|
23005
|
+
for (const h of c.finalHits.slice(0, 5)) {
|
|
23006
|
+
const dn = String(h.metadata.doc_number ?? "");
|
|
23007
|
+
if (dn) counts.set(dn, (counts.get(dn) ?? 0) + 1);
|
|
23008
|
+
}
|
|
23009
|
+
const docNumber = c.u?.doc_number ?? [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
23010
|
+
if (!docNumber) return;
|
|
23011
|
+
const seated = new Set(
|
|
23012
|
+
c.finalHits.filter((h) => h.metadata.block === "figure").map((h) => String(h.metadata.unit_id ?? h.id))
|
|
23013
|
+
);
|
|
23014
|
+
const rows = await portStore(c.env).prepare(
|
|
23015
|
+
`SELECT id, doc_id, docidentifier, clause_anchor, clause_title, doc_number, edition, language, status, corpus, tier, text, unit_id
|
|
23016
|
+
FROM chunks WHERE doc_number = ?1 AND block = 'figure' AND unit_id IS NOT NULL LIMIT 3`
|
|
23017
|
+
).bind(String(docNumber)).all();
|
|
23018
|
+
const fresh = [];
|
|
23019
|
+
for (const r of rows.results ?? []) {
|
|
23020
|
+
if (seated.has(String(r.unit_id))) continue;
|
|
23021
|
+
fresh.push({
|
|
23022
|
+
id: String(r.id),
|
|
23023
|
+
score: 0,
|
|
23024
|
+
rerank_score: 0,
|
|
23025
|
+
text: String(r.text ?? ""),
|
|
23026
|
+
metadata: {
|
|
23027
|
+
doc_id: String(r.doc_id ?? ""),
|
|
23028
|
+
docidentifier: String(r.docidentifier ?? ""),
|
|
23029
|
+
doc_number: String(r.doc_number ?? docNumber),
|
|
23030
|
+
clause_anchor: r.clause_anchor ? String(r.clause_anchor) : void 0,
|
|
23031
|
+
clause_title: r.clause_title ? String(r.clause_title) : void 0,
|
|
23032
|
+
edition: r.edition ? String(r.edition) : void 0,
|
|
23033
|
+
language: r.language ? String(r.language) : void 0,
|
|
23034
|
+
status: r.status ? String(r.status) : void 0,
|
|
23035
|
+
corpus: r.corpus ? String(r.corpus) : void 0,
|
|
23036
|
+
tier: r.tier ? String(r.tier) : void 0,
|
|
23037
|
+
block: "figure",
|
|
23038
|
+
unit_id: String(r.unit_id)
|
|
23039
|
+
}
|
|
23040
|
+
});
|
|
23041
|
+
}
|
|
23042
|
+
if (!fresh.length) return;
|
|
23043
|
+
c.finalHits = [...fresh, ...c.finalHits];
|
|
23044
|
+
console.log("figure-seat: seated", fresh.length, "figure chunk(s) of doc", docNumber);
|
|
23045
|
+
} catch {
|
|
23046
|
+
}
|
|
23047
|
+
}
|
|
23048
|
+
};
|
|
23049
|
+
|
|
22993
23050
|
// workers/worker_public/src/stages/termNudge.ts
|
|
22994
23051
|
var termNudge = {
|
|
22995
23052
|
name: "term-nudge",
|
|
@@ -23488,6 +23545,7 @@ var STAGES = [
|
|
|
23488
23545
|
typedPin,
|
|
23489
23546
|
sectionDescent,
|
|
23490
23547
|
dedup,
|
|
23548
|
+
figureSeat,
|
|
23491
23549
|
vlmFigureRerank,
|
|
23492
23550
|
windowFloor
|
|
23493
23551
|
];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
embed
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LU7VIMD7.js";
|
|
4
4
|
import {
|
|
5
5
|
standardKeysFrom
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-Y7LWT24U.js";
|
|
7
7
|
import {
|
|
8
8
|
THRESHOLDS
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4FZNJR5Q.js";
|
|
10
10
|
import {
|
|
11
11
|
P
|
|
12
12
|
} from "./chunk-3FYJM7LH.js";
|
package/dist/config.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare const THRESHOLDS: {
|
|
|
51
51
|
* not only the source rung. Fails open (a slow or unparseable check
|
|
52
52
|
* leaves the source-rung note unchanged). */
|
|
53
53
|
readonly compressShare: 0.6;
|
|
54
|
-
readonly denseStarveK:
|
|
54
|
+
readonly denseStarveK: 100;
|
|
55
55
|
readonly entailmentGate: true;
|
|
56
56
|
readonly entailmentBudgetMs: 6000;
|
|
57
57
|
readonly entailmentSupportedFloor: 0.9;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
handleSearch
|
|
3
|
+
} from "./chunk-BFOCWZ7U.js";
|
|
4
|
+
import "./chunk-LIZJLRXZ.js";
|
|
5
|
+
import "./chunk-LU7VIMD7.js";
|
|
6
|
+
import "./chunk-QY556RJM.js";
|
|
7
|
+
import "./chunk-ETLSWSZ7.js";
|
|
8
|
+
import "./chunk-Y7LWT24U.js";
|
|
9
|
+
import "./chunk-4FZNJR5Q.js";
|
|
10
|
+
import "./chunk-3FYJM7LH.js";
|
|
11
|
+
import "./chunk-LSZTJI7V.js";
|
|
12
|
+
export {
|
|
13
|
+
handleSearch
|
|
14
|
+
};
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
parseToolCall,
|
|
5
5
|
runTool,
|
|
6
6
|
toolNote
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-PTY2OSC4.js";
|
|
8
|
+
import "./chunk-LU7VIMD7.js";
|
|
9
|
+
import "./chunk-Y7LWT24U.js";
|
|
10
|
+
import "./chunk-4FZNJR5Q.js";
|
|
11
11
|
import "./chunk-3FYJM7LH.js";
|
|
12
12
|
import "./chunk-LSZTJI7V.js";
|
|
13
13
|
export {
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
handleMemories,
|
|
5
5
|
scoreFaithfulness,
|
|
6
6
|
scoreJudge
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-AGL4NGXY.js";
|
|
8
8
|
import "../../chunk-ECOYO7EX.js";
|
|
9
9
|
import {
|
|
10
10
|
TOOLS_REGISTRY,
|
|
11
11
|
bindModelNode,
|
|
12
12
|
modelGroundingBlock
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-PTY2OSC4.js";
|
|
14
14
|
import {
|
|
15
15
|
handleSearch
|
|
16
|
-
} from "../../chunk-
|
|
16
|
+
} from "../../chunk-BFOCWZ7U.js";
|
|
17
17
|
import {
|
|
18
18
|
buildMessages,
|
|
19
19
|
citations,
|
|
@@ -38,11 +38,11 @@ import {
|
|
|
38
38
|
sessionFrom,
|
|
39
39
|
telemetry,
|
|
40
40
|
understandQuery
|
|
41
|
-
} from "../../chunk-
|
|
41
|
+
} from "../../chunk-LIZJLRXZ.js";
|
|
42
42
|
import {
|
|
43
43
|
embed,
|
|
44
44
|
generateOnce
|
|
45
|
-
} from "../../chunk-
|
|
45
|
+
} from "../../chunk-LU7VIMD7.js";
|
|
46
46
|
import {
|
|
47
47
|
authenticate,
|
|
48
48
|
corsHeaders,
|
|
@@ -51,14 +51,14 @@ import {
|
|
|
51
51
|
readJson,
|
|
52
52
|
validateQuery,
|
|
53
53
|
withCors
|
|
54
|
-
} from "../../chunk-
|
|
54
|
+
} from "../../chunk-QY556RJM.js";
|
|
55
55
|
import {
|
|
56
56
|
canonicalRefusal
|
|
57
57
|
} from "../../chunk-ETLSWSZ7.js";
|
|
58
58
|
import {
|
|
59
59
|
entitlementScope,
|
|
60
60
|
standardKeysFrom
|
|
61
|
-
} from "../../chunk-
|
|
61
|
+
} from "../../chunk-Y7LWT24U.js";
|
|
62
62
|
import {
|
|
63
63
|
LIMITS,
|
|
64
64
|
MODELS,
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
roleModel,
|
|
70
70
|
sha256Hex,
|
|
71
71
|
today
|
|
72
|
-
} from "../../chunk-
|
|
72
|
+
} from "../../chunk-4FZNJR5Q.js";
|
|
73
73
|
import {
|
|
74
74
|
P,
|
|
75
75
|
setProfile
|
|
@@ -1119,13 +1119,13 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
|
|
|
1119
1119
|
// stream:false forces the JSON lane (anon defaults to SSE)
|
|
1120
1120
|
body: JSON.stringify({ ...args, stream: false })
|
|
1121
1121
|
});
|
|
1122
|
-
const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-
|
|
1122
|
+
const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-3RP7DHGI.js");
|
|
1123
1123
|
let payload;
|
|
1124
1124
|
if (TOOLS_REGISTRY2.some((t) => t.name === name && t.audiences.includes("mcp"))) {
|
|
1125
1125
|
const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
|
|
1126
1126
|
payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
|
|
1127
1127
|
} else {
|
|
1128
|
-
const res = name === "ask" ? await (await import("../../ask-
|
|
1128
|
+
const res = name === "ask" ? await (await import("../../ask-RUMLIO35.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-Y4Y46Y57.js")).handleSearch(env, ctx, inner, tier, key);
|
|
1129
1129
|
payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
|
|
1130
1130
|
}
|
|
1131
1131
|
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 });
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
requestSalt,
|
|
5
5
|
resolveRequestScope,
|
|
6
6
|
standardKeysFrom
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-Y7LWT24U.js";
|
|
8
|
+
import "../../chunk-4FZNJR5Q.js";
|
|
9
9
|
import "../../chunk-3FYJM7LH.js";
|
|
10
10
|
export {
|
|
11
11
|
entitlementScope,
|
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.168",
|
|
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",
|
|
@@ -89,7 +89,7 @@ export const THRESHOLDS = {
|
|
|
89
89
|
// when the in-code doc scope cuts the vector-level top-K to zero, the
|
|
90
90
|
// re-query runs at this depth and scopes in code (the native filter is
|
|
91
91
|
// dead — measured 2026-10-05)
|
|
92
|
-
denseStarveK:
|
|
92
|
+
denseStarveK: 100,
|
|
93
93
|
entailmentGate: true,
|
|
94
94
|
entailmentBudgetMs: 6000,
|
|
95
95
|
entailmentSupportedFloor: 0.9,
|
|
@@ -51,9 +51,16 @@ export const dense: Stage = {
|
|
|
51
51
|
// reachable only through a wider net. Fires only when the scope
|
|
52
52
|
// starves to zero — zero behavior when the scope matches.
|
|
53
53
|
if (!matches.length) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
try {
|
|
55
|
+
const wide: any = await env.VECTORIZE.query(vector, { ...q, topK: THRESHOLDS.denseStarveK });
|
|
56
|
+
matches = (wide.matches ?? []).filter((m: any) => matchesDocScope(m.metadata ?? {}, filters.doc_number!));
|
|
57
|
+
console.log("dense scope starvation → deep re-query:", matches.length, "doc members in the top", THRESHOLDS.denseStarveK);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
// the deep net must never break the ask: a rejected re-query
|
|
60
|
+
// (topK above the platform cap, a transient index error)
|
|
61
|
+
// degrades to the pre-fallback state — other lanes' leftovers
|
|
62
|
+
console.log("dense scope starvation re-query failed:", String(e).slice(0, 120));
|
|
63
|
+
}
|
|
57
64
|
}
|
|
58
65
|
// an edition pin corroborated by (almost) nothing means the pin
|
|
59
66
|
// was a guess — understanding emits editions for families it
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// The figure seat (TODO.sota/18.3's completion — the guaranteed place):
|
|
2
|
+
// a figure-SEEKING question deterministically seats the asked document's
|
|
3
|
+
// own figure chunks in the window. No embedding contest, no variance —
|
|
4
|
+
// the question names a figure; the document's figures get their places;
|
|
5
|
+
// the VLM rerank then orders them by image and the seeking completion
|
|
6
|
+
// attaches the block from the producer's payload. The D1 read is one
|
|
7
|
+
// bounded query (doc_number + block, LIMIT 3), additive, ablatable like
|
|
8
|
+
// any stage. Positioned BEFORE the VLM rerank so the rerank sees the
|
|
9
|
+
// seated figures and can order them by image.
|
|
10
|
+
import { FIGURE_Q } from "./vlmFigureRerank.ts";
|
|
11
|
+
import { portStore } from "../env.ts";
|
|
12
|
+
import type { Stage } from "./types.ts";
|
|
13
|
+
import type { Hit } from "../../../shared/chunk";
|
|
14
|
+
|
|
15
|
+
export const figureSeat: Stage = {
|
|
16
|
+
name: "figure-seat",
|
|
17
|
+
failure: "additive",
|
|
18
|
+
when: (c) => FIGURE_Q.test(c.query),
|
|
19
|
+
run: async (c) => {
|
|
20
|
+
try {
|
|
21
|
+
const counts = new Map<string, number>();
|
|
22
|
+
for (const h of c.finalHits.slice(0, 5)) {
|
|
23
|
+
const dn = String((h.metadata as any).doc_number ?? "");
|
|
24
|
+
if (dn) counts.set(dn, (counts.get(dn) ?? 0) + 1);
|
|
25
|
+
}
|
|
26
|
+
const docNumber = (c.u as any)?.doc_number ?? [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
27
|
+
if (!docNumber) return;
|
|
28
|
+
const seated = new Set(
|
|
29
|
+
c.finalHits.filter((h: Hit) => (h.metadata as any).block === "figure").map((h: Hit) => String((h.metadata as any).unit_id ?? h.id)),
|
|
30
|
+
);
|
|
31
|
+
const rows = await portStore(c.env)
|
|
32
|
+
.prepare(
|
|
33
|
+
`SELECT id, doc_id, docidentifier, clause_anchor, clause_title, doc_number, edition, language, status, corpus, tier, text, unit_id
|
|
34
|
+
FROM chunks WHERE doc_number = ?1 AND block = 'figure' AND unit_id IS NOT NULL LIMIT 3`,
|
|
35
|
+
)
|
|
36
|
+
.bind(String(docNumber))
|
|
37
|
+
.all();
|
|
38
|
+
const fresh: Hit[] = [];
|
|
39
|
+
for (const r of (rows.results ?? []) as any[]) {
|
|
40
|
+
if (seated.has(String(r.unit_id))) continue;
|
|
41
|
+
fresh.push({
|
|
42
|
+
id: String(r.id),
|
|
43
|
+
score: 0,
|
|
44
|
+
rerank_score: 0,
|
|
45
|
+
text: String(r.text ?? ""),
|
|
46
|
+
metadata: {
|
|
47
|
+
doc_id: String(r.doc_id ?? ""),
|
|
48
|
+
docidentifier: String(r.docidentifier ?? ""),
|
|
49
|
+
doc_number: String(r.doc_number ?? docNumber),
|
|
50
|
+
clause_anchor: r.clause_anchor ? String(r.clause_anchor) : undefined,
|
|
51
|
+
clause_title: r.clause_title ? String(r.clause_title) : undefined,
|
|
52
|
+
edition: r.edition ? String(r.edition) : undefined,
|
|
53
|
+
language: r.language ? String(r.language) : undefined,
|
|
54
|
+
status: r.status ? String(r.status) : undefined,
|
|
55
|
+
corpus: r.corpus ? String(r.corpus) : undefined,
|
|
56
|
+
tier: r.tier ? String(r.tier) : undefined,
|
|
57
|
+
block: "figure",
|
|
58
|
+
unit_id: String(r.unit_id),
|
|
59
|
+
} as any,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (!fresh.length) return;
|
|
63
|
+
c.finalHits = [...fresh, ...c.finalHits];
|
|
64
|
+
console.log("figure-seat: seated", fresh.length, "figure chunk(s) of doc", docNumber);
|
|
65
|
+
} catch {
|
|
66
|
+
// additive — the text ranking stands
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -34,6 +34,7 @@ import { overviewDemote } from "./overviewDemote.ts";
|
|
|
34
34
|
import { familyBoost } from "./familyBoost.ts";
|
|
35
35
|
import { rerankStage, lexicalRrf } from "./rerank.ts";
|
|
36
36
|
import { vlmFigureRerank } from "./vlmFigureRerank.ts";
|
|
37
|
+
import { figureSeat } from "./figureSeat.ts";
|
|
37
38
|
import { termNudge } from "./termNudge.ts";
|
|
38
39
|
import { conceptSteer } from "./conceptSteer.ts";
|
|
39
40
|
import { editionSteer } from "./editionSteer.ts";
|
|
@@ -76,6 +77,7 @@ export const STAGES: Stage[] = [
|
|
|
76
77
|
typedPin,
|
|
77
78
|
sectionDescent,
|
|
78
79
|
dedup,
|
|
80
|
+
figureSeat,
|
|
79
81
|
vlmFigureRerank,
|
|
80
82
|
windowFloor,
|
|
81
83
|
];
|
package/dist/ask-XJOOMAXU.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
handleAsk
|
|
3
|
-
} from "./chunk-2FME6R6J.js";
|
|
4
|
-
import "./chunk-ECOYO7EX.js";
|
|
5
|
-
import "./chunk-AP73VIHB.js";
|
|
6
|
-
import "./chunk-5AME76UW.js";
|
|
7
|
-
import "./chunk-5V2A3CAH.js";
|
|
8
|
-
import "./chunk-TTEJQ5XA.js";
|
|
9
|
-
import "./chunk-ETLSWSZ7.js";
|
|
10
|
-
import "./chunk-OLO45N6D.js";
|
|
11
|
-
import "./chunk-FQYHT4VC.js";
|
|
12
|
-
import "./chunk-3FYJM7LH.js";
|
|
13
|
-
import "./chunk-LSZTJI7V.js";
|
|
14
|
-
export {
|
|
15
|
-
handleAsk
|
|
16
|
-
};
|
package/dist/search-6KM4P2E5.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
handleSearch
|
|
3
|
-
} from "./chunk-SIT4XSD5.js";
|
|
4
|
-
import "./chunk-5AME76UW.js";
|
|
5
|
-
import "./chunk-5V2A3CAH.js";
|
|
6
|
-
import "./chunk-TTEJQ5XA.js";
|
|
7
|
-
import "./chunk-ETLSWSZ7.js";
|
|
8
|
-
import "./chunk-OLO45N6D.js";
|
|
9
|
-
import "./chunk-FQYHT4VC.js";
|
|
10
|
-
import "./chunk-3FYJM7LH.js";
|
|
11
|
-
import "./chunk-LSZTJI7V.js";
|
|
12
|
-
export {
|
|
13
|
-
handleSearch
|
|
14
|
-
};
|