@konneal/engine 0.2.29 → 0.2.30
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-UAJHC6U7.js → ask-43C2WZZO.js} +2 -2
- package/dist/{chunk-BHWG556Q.js → chunk-F66NYFUK.js} +8 -1
- package/dist/{chunk-RI2SRLZY.js → chunk-S7NLWPNX.js} +1 -1
- package/dist/{chunk-ODHIVW3M.js → chunk-TDKNQPA2.js} +1 -1
- package/dist/{search-ICNVGXUY.js → search-NHTT5DDI.js} +2 -2
- package/dist/worker_public/src/index.js +7 -7
- package/package.json +1 -1
- package/workers/worker_public/src/index.ts +3 -3
- package/workers/worker_public/src/stages/seal.ts +8 -1
- package/workers/worker_public/src/stages/types.ts +6 -0
|
@@ -22747,7 +22747,7 @@ var federate = {
|
|
|
22747
22747
|
// workers/worker_public/src/stages/seal.ts
|
|
22748
22748
|
var seal = {
|
|
22749
22749
|
name: "seal",
|
|
22750
|
-
when: (c) => !!c.opts.sealScope || !!c.opts.editionSteer,
|
|
22750
|
+
when: (c) => !!c.opts.sealScope || !!c.opts.editionSteer || !!c.opts.editionExclude,
|
|
22751
22751
|
run: (c) => {
|
|
22752
22752
|
const before = c.hits.length;
|
|
22753
22753
|
const scope = c.opts.sealScope;
|
|
@@ -22756,6 +22756,13 @@ var seal = {
|
|
|
22756
22756
|
console.log("context seal:", before, "\u2192", c.hits.length, "candidates within", `doc#${scope.doc_number}${scope.edition ? "@" + scope.edition : ""}`);
|
|
22757
22757
|
return;
|
|
22758
22758
|
}
|
|
22759
|
+
const exclude = c.opts.editionExclude;
|
|
22760
|
+
if (exclude) {
|
|
22761
|
+
const before2 = c.hits.length;
|
|
22762
|
+
c.hits = c.hits.filter((h) => !(h.metadata.doc_number === exclude.doc_number && h.metadata.edition !== exclude.edition));
|
|
22763
|
+
console.log("edition exclude:", before2, "\u2192", c.hits.length, "after dropping superseded candidates of", `doc#${exclude.doc_number}@${exclude.edition}`);
|
|
22764
|
+
return;
|
|
22765
|
+
}
|
|
22759
22766
|
const steer = c.opts.editionSteer;
|
|
22760
22767
|
const current = [];
|
|
22761
22768
|
const superseded = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handleSearch
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-S7NLWPNX.js";
|
|
4
4
|
import {
|
|
5
5
|
bindModelNode,
|
|
6
6
|
checkQuoteAnchors,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
modelGroundingBlock,
|
|
10
10
|
scoreJudge,
|
|
11
11
|
standardForDocNumber
|
|
12
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-TDKNQPA2.js";
|
|
13
13
|
import {
|
|
14
14
|
buildMessages,
|
|
15
15
|
citations,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
sessionFrom,
|
|
33
33
|
telemetry,
|
|
34
34
|
understandQuery
|
|
35
|
-
} from "../../chunk-
|
|
35
|
+
} from "../../chunk-F66NYFUK.js";
|
|
36
36
|
import {
|
|
37
37
|
authenticate,
|
|
38
38
|
corsHeaders,
|
|
@@ -996,7 +996,7 @@ async function handleMcp(env, ctx, req, tier, key) {
|
|
|
996
996
|
// stream:false forces the JSON lane (anon defaults to SSE)
|
|
997
997
|
body: JSON.stringify({ ...args, stream: false })
|
|
998
998
|
});
|
|
999
|
-
const res = name === "ask" ? await (await import("../../ask-
|
|
999
|
+
const res = name === "ask" ? await (await import("../../ask-43C2WZZO.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-NHTT5DDI.js")).handleSearch(env, ctx, inner, tier, key);
|
|
1000
1000
|
return res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
|
|
1001
1001
|
});
|
|
1002
1002
|
if (out.ok && "accepted" in out) return new Response(null, { status: 202 });
|
|
@@ -1456,21 +1456,21 @@ async function verifyRoute(c) {
|
|
|
1456
1456
|
try {
|
|
1457
1457
|
const u = await understandQuery(env.AI, roleModel(env, "understand"), query, [], []);
|
|
1458
1458
|
let lexicalBoost;
|
|
1459
|
-
let
|
|
1459
|
+
let editionExclude = null;
|
|
1460
1460
|
try {
|
|
1461
1461
|
const fam = u?.doc_number ? refCodec().familyOf(u.doc_number) : null;
|
|
1462
1462
|
if (fam) {
|
|
1463
1463
|
const row = await env.DB.prepare("SELECT edition FROM documents WHERE family = ?1 AND active = 1 ORDER BY edition DESC LIMIT 1").bind(fam).first().catch(() => null);
|
|
1464
1464
|
if (row?.edition) {
|
|
1465
1465
|
lexicalBoost = String(row.edition);
|
|
1466
|
-
|
|
1466
|
+
editionExclude = { doc_number: fam.split("-").pop() ?? "", edition: String(row.edition) };
|
|
1467
1467
|
}
|
|
1468
1468
|
}
|
|
1469
1469
|
} catch {
|
|
1470
1470
|
}
|
|
1471
1471
|
const bound = await bindModelNode(env, { query, standardKeys: entitlementScope(standardKeysFrom(body)) });
|
|
1472
1472
|
const modelGrounding = bound && !bound.gated ? modelGroundingBlock(bound) : null;
|
|
1473
|
-
const retrieved = await retrieve(env, query, { understanding: u, standardKeys: entitlementScope(standardKeysFrom(body)), lexicalBoost,
|
|
1473
|
+
const retrieved = await retrieve(env, query, { understanding: u, standardKeys: entitlementScope(standardKeysFrom(body)), lexicalBoost, editionExclude });
|
|
1474
1474
|
const passages = retrieved.hits.map((h) => h.text);
|
|
1475
1475
|
const anchors = checkQuoteAnchors(answer, passages);
|
|
1476
1476
|
const refs = [...answer.matchAll(/\[\[u:([^\]]+)\]\]/g)].map((m) => m[1]);
|
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.30",
|
|
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",
|
|
@@ -234,7 +234,7 @@ async function verifyRoute(c: RouteContext): Promise<Response> {
|
|
|
234
234
|
// grounding — a verify that grounds against different passages than
|
|
235
235
|
// the answer used judges a different answer
|
|
236
236
|
let lexicalBoost: string | undefined;
|
|
237
|
-
let
|
|
237
|
+
let editionExclude: { doc_number: string; edition: string } | null = null;
|
|
238
238
|
try {
|
|
239
239
|
const fam = u?.doc_number ? refCodec().familyOf(u.doc_number) : null;
|
|
240
240
|
if (fam) {
|
|
@@ -242,7 +242,7 @@ async function verifyRoute(c: RouteContext): Promise<Response> {
|
|
|
242
242
|
.bind(fam).first().catch(() => null);
|
|
243
243
|
if (row?.edition) {
|
|
244
244
|
lexicalBoost = String(row.edition);
|
|
245
|
-
|
|
245
|
+
editionExclude = { doc_number: fam.split("-").pop() ?? "", edition: String(row.edition) };
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
} catch {
|
|
@@ -250,7 +250,7 @@ async function verifyRoute(c: RouteContext): Promise<Response> {
|
|
|
250
250
|
}
|
|
251
251
|
const bound = await bindModelNode(env, { query, standardKeys: entitlementScope(standardKeysFrom(body)) });
|
|
252
252
|
const modelGrounding = bound && !bound.gated ? modelGroundingBlock(bound) : null;
|
|
253
|
-
const retrieved = await retrieve(env, query, { understanding: u, standardKeys: entitlementScope(standardKeysFrom(body)), lexicalBoost,
|
|
253
|
+
const retrieved = await retrieve(env, query, { understanding: u, standardKeys: entitlementScope(standardKeysFrom(body)), lexicalBoost, editionExclude });
|
|
254
254
|
const passages = retrieved.hits.map((h: Hit) => h.text);
|
|
255
255
|
const anchors = checkQuoteAnchors(answer, passages);
|
|
256
256
|
const refs = [...answer.matchAll(/\[\[u:([^\]]+)\]\]/g)].map((m) => m[1]);
|
|
@@ -6,7 +6,7 @@ import type { Stage } from "./types.ts";
|
|
|
6
6
|
|
|
7
7
|
export const seal: Stage = {
|
|
8
8
|
name: "seal",
|
|
9
|
-
when: (c) => !!c.opts.sealScope || !!c.opts.editionSteer,
|
|
9
|
+
when: (c) => !!c.opts.sealScope || !!c.opts.editionSteer || !!c.opts.editionExclude,
|
|
10
10
|
run: (c) => {
|
|
11
11
|
const before = c.hits.length;
|
|
12
12
|
const scope = c.opts.sealScope!;
|
|
@@ -15,6 +15,13 @@ export const seal: Stage = {
|
|
|
15
15
|
console.log("context seal:", before, "→", c.hits.length, "candidates within", `doc#${scope.doc_number}${scope.edition ? "@" + scope.edition : ""}`);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
+
const exclude = c.opts.editionExclude!;
|
|
19
|
+
if (exclude) {
|
|
20
|
+
const before = c.hits.length;
|
|
21
|
+
c.hits = c.hits.filter((h) => !(h.metadata.doc_number === exclude.doc_number && h.metadata.edition !== exclude.edition));
|
|
22
|
+
console.log("edition exclude:", before, "→", c.hits.length, "after dropping superseded candidates of", `doc#${exclude.doc_number}@${exclude.edition}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
18
25
|
const steer = c.opts.editionSteer!;
|
|
19
26
|
const current: typeof c.hits = [];
|
|
20
27
|
const superseded: typeof c.hits = [];
|
|
@@ -34,6 +34,12 @@ export interface RetrieveOptions {
|
|
|
34
34
|
* of the candidate pool — superseded passages stay servable but stop
|
|
35
35
|
* competing for the window against the current edition. */
|
|
36
36
|
editionSteer?: { doc_number: string; edition: string } | null;
|
|
37
|
+
/** Verify's grounding cut: hits of the named document whose edition
|
|
38
|
+
* differs from the active one are REMOVED — a grounding endpoint
|
|
39
|
+
* judges against the current edition; a superseded passage cannot
|
|
40
|
+
* ground a current-edition claim. Everything else (other documents,
|
|
41
|
+
* undated vocabulary) survives. */
|
|
42
|
+
editionExclude?: { doc_number: string; edition: string } | null;
|
|
37
43
|
/** Option C: dense-lane results computed concurrently with
|
|
38
44
|
* understanding (same folded-query vector, retrieve's exact query
|
|
39
45
|
* parameters). With no filter they REPLACE the primary dense query;
|