@konneal/engine 0.2.113 → 0.2.115

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.
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  handleAsk
3
- } from "./chunk-PSI5SR2A.js";
3
+ } from "./chunk-MUAY4BXY.js";
4
4
  import "./chunk-32UDKBA2.js";
5
- import "./chunk-NO4WHD3K.js";
5
+ import "./chunk-A6YQYN3O.js";
6
6
  import "./chunk-TH5XGPD5.js";
7
7
  import "./chunk-DJ65EF5G.js";
8
8
  import "./chunk-A3QHHUN5.js";
@@ -22158,11 +22158,11 @@ var dense = {
22158
22158
  const allMatches = (await env.VECTORIZE.query(vector, q)).matches ?? [];
22159
22159
  let matches = allMatches;
22160
22160
  const before = matches.length;
22161
- matches = matches.filter((m) => String(m.metadata?.doc_number ?? "") === filters.doc_number);
22161
+ matches = matches.filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number));
22162
22162
  if (filters.edition) matches = matches.filter((m) => !m.metadata?.edition || String(m.metadata.edition) === filters.edition);
22163
22163
  console.log("dense scope (in code):", before, "\u2192", matches.length, "in doc", filters.doc_number, filters.edition ? `@${filters.edition}` : "");
22164
22164
  if (filters && filters.edition && matches.length < 3) {
22165
- const docOnly = allMatches.filter((m) => String(m.metadata?.doc_number ?? "") === filters.doc_number);
22165
+ const docOnly = allMatches.filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number));
22166
22166
  if (docOnly.length > matches.length) {
22167
22167
  console.log("edition pin dropped:", filters.doc_number, "@", filters.edition, "\u2192", docOnly.length, "doc-scoped hits (edition not in corpus)");
22168
22168
  matches = docOnly;
@@ -23474,7 +23474,7 @@ async function retrieve(env, query, opts = {}) {
23474
23474
  const filter = filters ? toVectorizeFilter(filters) : null;
23475
23475
  const folded = retrievalQuery(query, opts.prev);
23476
23476
  let rq = opts.queryOverride?.trim() || u?.standalone_query?.trim() || folded;
23477
- if (u?.process_intent) rq += processExpansion();
23477
+ if (u?.process_intent && !opts.sealScope) rq += processExpansion();
23478
23478
  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);
23479
23479
  const lexicalP = lexicalPrefilter(env, opts.lexicalBoost ? `${rq} ${opts.lexicalBoost}` : rq).catch(() => []);
23480
23480
  const [vector, lexicalHits0] = await Promise.all([vectorP, lexicalP]);
@@ -60,7 +60,7 @@ import {
60
60
  tokenBudget,
61
61
  understandQuery,
62
62
  usageTotal
63
- } from "./chunk-NO4WHD3K.js";
63
+ } from "./chunk-A6YQYN3O.js";
64
64
  import {
65
65
  embed,
66
66
  generateOnce,
@@ -6,7 +6,7 @@ import {
6
6
  sessionFrom,
7
7
  telemetry,
8
8
  understandQuery
9
- } from "./chunk-NO4WHD3K.js";
9
+ } from "./chunk-A6YQYN3O.js";
10
10
  import {
11
11
  portModelRunner
12
12
  } from "./chunk-TH5XGPD5.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  handleSearch
3
- } from "./chunk-WUD4XR7Y.js";
4
- import "./chunk-NO4WHD3K.js";
3
+ } from "./chunk-ZD7SNNGW.js";
4
+ import "./chunk-A6YQYN3O.js";
5
5
  import "./chunk-TH5XGPD5.js";
6
6
  import "./chunk-DJ65EF5G.js";
7
7
  import "./chunk-A3QHHUN5.js";
@@ -4,7 +4,7 @@ import {
4
4
  handleMemories,
5
5
  scoreFaithfulness,
6
6
  scoreJudge
7
- } from "../../chunk-PSI5SR2A.js";
7
+ } from "../../chunk-MUAY4BXY.js";
8
8
  import {
9
9
  TOOLS_REGISTRY,
10
10
  bindModelNode,
@@ -12,7 +12,7 @@ import {
12
12
  } from "../../chunk-32UDKBA2.js";
13
13
  import {
14
14
  handleSearch
15
- } from "../../chunk-WUD4XR7Y.js";
15
+ } from "../../chunk-ZD7SNNGW.js";
16
16
  import {
17
17
  buildMessages,
18
18
  citations,
@@ -34,7 +34,7 @@ import {
34
34
  sessionFrom,
35
35
  telemetry,
36
36
  understandQuery
37
- } from "../../chunk-NO4WHD3K.js";
37
+ } from "../../chunk-A6YQYN3O.js";
38
38
  import {
39
39
  cfBlobs,
40
40
  embed,
@@ -1000,7 +1000,7 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
1000
1000
  const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
1001
1001
  payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
1002
1002
  } else {
1003
- const res = name === "ask" ? await (await import("../../ask-645ZWTEQ.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-6J5FUJOC.js")).handleSearch(env, ctx, inner, tier, key);
1003
+ const res = name === "ask" ? await (await import("../../ask-RLMNWTHA.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-AH4A4SFJ.js")).handleSearch(env, ctx, inner, tier, key);
1004
1004
  payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
1005
1005
  }
1006
1006
  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/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.113",
30
+ "version": "0.2.115",
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",
@@ -109,7 +109,11 @@ export async function retrieve(
109
109
  const filter = filters ? toVectorizeFilter(filters) : null;
110
110
  const folded = retrievalQuery(query, opts.prev);
111
111
  let rq = opts.queryOverride?.trim() || u?.standalone_query?.trim() || folded;
112
- if (u?.process_intent) rq += processExpansion();
112
+ // the process expansion widens an UNSCOPED question toward the
113
+ // certification corpus; under a declared seal it poisons the query
114
+ // against the sealed family instead (the pool empties, the refusal
115
+ // follows) — the chip's context note already scopes the ANSWER
116
+ if (u?.process_intent && !opts.sealScope) rq += processExpansion();
113
117
  // Dense embed + full-corpus BM25 prefilter in parallel (G-ETSI-1 /
114
118
  // arXiv:2604.09868 §II-B5). Lexical must scan the whole corpus — the
115
119
  // old keywordRank only re-ordered dense hits and could not recover
@@ -4,6 +4,7 @@
4
4
  // saved), the doc/edition-filtered query with its guessed-pin drop and
5
5
  // sparse-filter widen, and the plain unfiltered query.
6
6
  import { LIMITS } from "../config.ts";
7
+ import { matchesDocScope } from "../context.ts";
7
8
  import type { Stage } from "./types.ts";
8
9
 
9
10
  export const dense: Stage = {
@@ -37,7 +38,7 @@ export const dense: Stage = {
37
38
  const allMatches: any[] = (await env.VECTORIZE.query(vector, q)).matches ?? [];
38
39
  let matches: any[] = allMatches;
39
40
  const before = matches.length;
40
- matches = matches.filter((m) => String(m.metadata?.doc_number ?? "") === filters.doc_number);
41
+ matches = matches.filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number!));
41
42
  if (filters.edition) matches = matches.filter((m) => !m.metadata?.edition || String(m.metadata.edition) === filters.edition);
42
43
  console.log("dense scope (in code):", before, "→", matches.length, "in doc", filters.doc_number, filters.edition ? `@${filters.edition}` : "");
43
44
  // an edition pin corroborated by (almost) nothing means the pin
@@ -52,7 +53,7 @@ export const dense: Stage = {
52
53
  // the same guess-drop, in code: a pinned edition that starved the
53
54
  // scoped set drops to the doc-only scope
54
55
  if (filters && filters.edition && matches.length < 3) {
55
- const docOnly = allMatches.filter((m) => String(m.metadata?.doc_number ?? "") === filters.doc_number);
56
+ const docOnly = allMatches.filter((m) => matchesDocScope(m.metadata ?? {}, filters.doc_number!));
56
57
  if (docOnly.length > matches.length) {
57
58
  console.log("edition pin dropped:", filters.doc_number, "@", filters.edition, "→", docOnly.length, "doc-scoped hits (edition not in corpus)");
58
59
  matches = docOnly;