@konneal/engine 0.2.177 → 0.2.179

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-K4IEKILQ.js";
4
- import "./chunk-JKBU2IPM.js";
5
- import "./chunk-RO5LNSPH.js";
3
+ } from "./chunk-LDSGL62W.js";
4
+ import "./chunk-IRCDOFP4.js";
5
+ import "./chunk-ROXOL4GF.js";
6
6
  import "./chunk-CLDMP5YH.js";
7
7
  import "./chunk-ZHT4456M.js";
8
8
  import "./chunk-D7MO4RVQ.js";
@@ -13,7 +13,7 @@ import {
13
13
  registerNote,
14
14
  registerTokens,
15
15
  searchRegister
16
- } from "./chunk-JKBU2IPM.js";
16
+ } from "./chunk-IRCDOFP4.js";
17
17
  import "./chunk-3FYJM7LH.js";
18
18
  export {
19
19
  aggregateBlock,
@@ -142,7 +142,7 @@ function registerTokens(query) {
142
142
  if (/^\d+$/.test(w) && w.length < 2) continue;
143
143
  if (!tokens.includes(w)) tokens.push(w);
144
144
  }
145
- return tokens.slice(0, 6);
145
+ return tokens.slice(0, 12);
146
146
  }
147
147
  function buildRegisterQuery(tokens) {
148
148
  const params = [];
@@ -8,7 +8,7 @@ import {
8
8
  registerBypassesCache,
9
9
  registerNote,
10
10
  searchRegister
11
- } from "./chunk-JKBU2IPM.js";
11
+ } from "./chunk-IRCDOFP4.js";
12
12
  import {
13
13
  TOOL_DECLARATION,
14
14
  bindConstraintByQuantities,
@@ -33,7 +33,7 @@ import {
33
33
  tableRetyped,
34
34
  toolNote,
35
35
  verdictNote
36
- } from "./chunk-RO5LNSPH.js";
36
+ } from "./chunk-ROXOL4GF.js";
37
37
  import {
38
38
  NO_CONTEXT,
39
39
  STAGE_NAMES,
@@ -2435,6 +2435,8 @@ Certificates are issued per recommendation family \u2014 the register carries no
2435
2435
  }
2436
2436
  const regNote = aggregateNoteText ?? (register ? [registerNote(register.rows), certificateLinks(register.rows)].filter(Boolean).join("\n") : void 0);
2437
2437
  const ops = await operationsLane(env.DB, q2.query);
2438
+ const registerOwns = !!register?.rows?.length;
2439
+ const registerCitation = registerOwns ? [{ docidentifier: `${P().publisher.name}-CS certificate register`, corpus: "register" }] : [];
2438
2440
  if (understanding?.intent === "conversational") {
2439
2441
  const queryHash2 = await sha256Hex(q2.query);
2440
2442
  const messages2 = [
@@ -2831,9 +2833,10 @@ Answer account questions from these records ONLY: name the record when you use i
2831
2833
  },
2832
2834
  text: `${m.anchor} \u2014 ${m.text}`
2833
2835
  }));
2836
+ const passagePool = registerOwns ? [...opsHits, ...hits].filter((h) => !!h.metadata.cert_holder) : [...opsHits, ...hits];
2834
2837
  const { messages, usedHits } = buildMessages(
2835
2838
  q2.query,
2836
- [...opsHits, ...hits],
2839
+ passagePool,
2837
2840
  q2.lang,
2838
2841
  keptHistory,
2839
2842
  // stage-extracted graph facts (GraphRAG) ride the same note channel
@@ -2902,7 +2905,7 @@ Answer account questions from these records ONLY: name the record when you use i
2902
2905
  console.log("user image attached to generation");
2903
2906
  }
2904
2907
  const queryHash = await sha256Hex(q2.query);
2905
- const cites = boundModel ? [modelCitation(boundModel), ...citations(usedHits)] : citations(usedHits);
2908
+ const cites = [...registerCitation, ...boundModel ? [modelCitation(boundModel), ...citations(usedHits)] : citations(usedHits)];
2906
2909
  if (live2) {
2907
2910
  const stream = await generateStream(env, model, messages, routeEffort(routed.route));
2908
2911
  if (stream) {
@@ -3191,7 +3194,7 @@ Answer account questions from these records ONLY: name the record when you use i
3191
3194
  telemetry(env, ctx, tier, "ask", model, false, 0, queryHash, q2.lang, void 0, telemetryMeta());
3192
3195
  return err(502, "generation_failed", "The generation model is unavailable; please retry.");
3193
3196
  }
3194
- const finalCites = boundModel ? [modelCitation(boundModel), ...citations(used)] : citations(used);
3197
+ const finalCites = [...registerCitation, ...boundModel ? [modelCitation(boundModel), ...citations(used)] : citations(used)];
3195
3198
  const c2ns = answer.includes(refusalAnswer()) ? { text: answer, blocks: [], dropped: [] } : await contractV2(env.DB, answer, used);
3196
3199
  answer = c2ns.text;
3197
3200
  const finalAnchors = answer.includes(refusalAnswer()) ? { total: 0, violations: [] } : checkQuoteAnchors(answer, used.map((h) => h.text));
@@ -1565,7 +1565,7 @@ var certificatesSearch = {
1565
1565
  handler: async (env, args) => {
1566
1566
  const query = String(args?.query ?? "").trim().slice(0, 160);
1567
1567
  if (!query) return null;
1568
- const { searchRegister, registerNote, certificateLinks } = await import("./certificates-QHFH2KLH.js");
1568
+ const { searchRegister, registerNote, certificateLinks } = await import("./certificates-V6KO2L6P.js");
1569
1569
  const reg = await searchRegister(env.DB, query, true);
1570
1570
  const output = reg?.rows?.length ? [registerNote(reg.rows), certificateLinks(reg.rows)].filter(Boolean).join("\n") : `No certificate was found for "${query}" in the certificates database (the register snapshot). State this as the search's result, with the searched string visible.`;
1571
1571
  return { name: "certificates.search", query, output };
@@ -4,7 +4,7 @@ import {
4
4
  parseToolCall,
5
5
  runTool,
6
6
  toolNote
7
- } from "./chunk-RO5LNSPH.js";
7
+ } from "./chunk-ROXOL4GF.js";
8
8
  import "./chunk-ZHT4456M.js";
9
9
  import "./chunk-FNQ7UOEB.js";
10
10
  import "./chunk-HWWJAJWM.js";
@@ -4,13 +4,13 @@ import {
4
4
  handleMemories,
5
5
  scoreFaithfulness,
6
6
  scoreJudge
7
- } from "../../chunk-K4IEKILQ.js";
8
- import "../../chunk-JKBU2IPM.js";
7
+ } from "../../chunk-LDSGL62W.js";
8
+ import "../../chunk-IRCDOFP4.js";
9
9
  import {
10
10
  TOOLS_REGISTRY,
11
11
  bindModelNode,
12
12
  modelGroundingBlock
13
- } from "../../chunk-RO5LNSPH.js";
13
+ } from "../../chunk-ROXOL4GF.js";
14
14
  import {
15
15
  handleSearch
16
16
  } from "../../chunk-MUWO2EV6.js";
@@ -1175,13 +1175,13 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
1175
1175
  // stream:false forces the JSON lane (anon defaults to SSE)
1176
1176
  body: JSON.stringify({ ...args, stream: false })
1177
1177
  });
1178
- const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-DKQZGSWK.js");
1178
+ const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-UCUNOJR4.js");
1179
1179
  let payload;
1180
1180
  if (TOOLS_REGISTRY2.some((t) => t.name === name && t.audiences.includes("mcp"))) {
1181
1181
  const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
1182
1182
  payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
1183
1183
  } else {
1184
- const res = name === "ask" ? await (await import("../../ask-2UHDJPEU.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-KNPPTHMG.js")).handleSearch(env, ctx, inner, tier, key);
1184
+ const res = name === "ask" ? await (await import("../../ask-PWT4B6YE.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-KNPPTHMG.js")).handleSearch(env, ctx, inner, tier, key);
1185
1185
  payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
1186
1186
  }
1187
1187
  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.177",
30
+ "version": "0.2.179",
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",
@@ -914,6 +914,21 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
914
914
  const regNote = aggregateNoteText
915
915
  ?? (register ? [registerNote(register.rows), certificateLinks(register.rows)].filter(Boolean).join("\n") : undefined);
916
916
  const ops = await operationsLane(env.DB, q.query);
917
+ // The register lane owns the answer surface when it holds rows — the
918
+ // aggregate path's philosophy (the note answers the structure, the
919
+ // model narrates) extended to the standing lane. Measured 2026-10-28:
920
+ // one note among fifteen system notes loses to the retrieval volume —
921
+ // 11/14 standing probes answered the corpus-refusal template WITH the
922
+ // note in the prompt (the photo path already knew this: its
923
+ // refusal-rescue at the answer gates exists for exactly this shape).
924
+ // The passage pool narrows to the certificate plane's own chunks (the
925
+ // register's digitalized documents, metadata cert_holder); when the
926
+ // dense lane missed them the note alone carries the answer — it says
927
+ // so itself.
928
+ const registerOwns = !!register?.rows?.length;
929
+ const registerCitation = registerOwns
930
+ ? [{ docidentifier: `${P().publisher.name}-CS certificate register`, corpus: "register" }]
931
+ : [];
917
932
 
918
933
  // Conversational route, decided by query UNDERSTANDING (any language, any
919
934
  // phrasing) — not string matching. No retrieval: nothing in the corpus
@@ -1499,9 +1514,23 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
1499
1514
  },
1500
1515
  text: `${m.anchor} — ${m.text}`,
1501
1516
  }));
1517
+ // The register lane owns the answer surface when it holds rows — the
1518
+ // aggregate path's philosophy (the note answers the structure, the
1519
+ // model narrates) extended to the standing lane. Measured 2026-10-28:
1520
+ // one note among fifteen system notes loses to the retrieval volume —
1521
+ // 11/14 standing probes answered the corpus-refusal template WITH the
1522
+ // note in the prompt (the photo path already knew this: its
1523
+ // refusal-rescue at the answer gates exists for exactly this shape).
1524
+ // The passage pool narrows to the certificate plane's own chunks (the
1525
+ // register's digitalized documents, metadata cert_holder); when the
1526
+ // dense lane missed them the note alone carries the answer — it says
1527
+ // so itself.
1528
+ const passagePool = registerOwns
1529
+ ? [...opsHits, ...hits].filter((h) => !!(h.metadata as any).cert_holder)
1530
+ : [...opsHits, ...hits];
1502
1531
  const { messages, usedHits } = buildMessages(
1503
1532
  q.query,
1504
- [...opsHits, ...hits],
1533
+ passagePool,
1505
1534
  q.lang,
1506
1535
  keptHistory,
1507
1536
  // stage-extracted graph facts (GraphRAG) ride the same note channel
@@ -1623,8 +1652,10 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
1623
1652
  const queryHash = await sha256Hex(q.query);
1624
1653
  // The bound model node leads the citations (TODO.ai-platform/05): the
1625
1654
  // panel's first citation card IS the model node — its constraint, its
1626
- // provenance — ahead of the prose passages.
1627
- const cites = boundModel ? [modelCitation(boundModel), ...citations(usedHits)] : citations(usedHits);
1655
+ // provenance — ahead of the prose passages. The register rides first
1656
+ // when it owns the answer (the standing citation the aggregate path
1657
+ // has always attached).
1658
+ const cites = [...registerCitation, ...(boundModel ? [modelCitation(boundModel), ...citations(usedHits)] : citations(usedHits))];
1628
1659
 
1629
1660
  if (live) {
1630
1661
  const stream = await generateStream(env, model, messages, routeEffort(routed.route));
@@ -2021,7 +2052,7 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
2021
2052
  telemetry(env, ctx, tier, "ask", model, false, 0, queryHash, q.lang, undefined, telemetryMeta());
2022
2053
  return err(502, "generation_failed", "The generation model is unavailable; please retry.");
2023
2054
  }
2024
- const finalCites = boundModel ? [modelCitation(boundModel!), ...citations(used)] : citations(used);
2055
+ const finalCites = [...registerCitation, ...(boundModel ? [modelCitation(boundModel!), ...citations(used)] : citations(used))];
2025
2056
  const c2ns = answer!.includes(refusalAnswer())
2026
2057
  ? { text: answer, blocks: [] as Awaited<ReturnType<typeof contractV2>>["blocks"], dropped: [] as string[] }
2027
2058
  : await contractV2(env.DB, answer!, used);
@@ -189,7 +189,13 @@ export function registerTokens(query: string): string[] {
189
189
  if (/^\d+$/.test(w) && w.length < 2) continue;
190
190
  if (!tokens.includes(w)) tokens.push(w);
191
191
  }
192
- return tokens.slice(0, 6);
192
+ // the budget is 12, not 6: a long holder name consumed the six slots
193
+ // before the distinctive model token was ever consulted (the live
194
+ // probe: "Endress + Hauser GmbH + Co., KG Automatic level gauge -
195
+ // Type: NMR81 and NMR84" cut "NMR84" — the question's WHOLE POINT —
196
+ // at position 7). rankRegisterRows discounts holder-only rows, so the
197
+ // wider OR net costs nothing in note quality.
198
+ return tokens.slice(0, 12);
193
199
  }
194
200
 
195
201
  /** The register query for a token set. Numeric tokens (a model number