@konneal/engine 0.2.123 → 0.2.126

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,14 +1,14 @@
1
1
  import {
2
2
  handleAsk
3
- } from "./chunk-U6FXEUZP.js";
4
- import "./chunk-3L6TJAS6.js";
3
+ } from "./chunk-ZHHORWM6.js";
4
+ import "./chunk-J6LBR6GI.js";
5
5
  import "./chunk-2JUWER2A.js";
6
6
  import "./chunk-TH5XGPD5.js";
7
7
  import "./chunk-DJ65EF5G.js";
8
8
  import "./chunk-A4A26BCV.js";
9
9
  import "./chunk-4NXH5ZI6.js";
10
10
  import "./chunk-VT7DR6NQ.js";
11
- import "./chunk-IOT75KLU.js";
11
+ import "./chunk-GBGRHXRU.js";
12
12
  import "./chunk-3FYJM7LH.js";
13
13
  export {
14
14
  handleAsk
@@ -11,7 +11,7 @@ import {
11
11
  registerNote,
12
12
  registerTokens,
13
13
  searchRegister
14
- } from "./chunk-IOT75KLU.js";
14
+ } from "./chunk-GBGRHXRU.js";
15
15
  import "./chunk-3FYJM7LH.js";
16
16
  export {
17
17
  aggregateBlock,
@@ -35,9 +35,10 @@ function aggregateNote(agg) {
35
35
  const latest = agg.latest ? `The latest certificate in the snapshot is ${agg.latest.num} (holder ${agg.latest.holder}, model "${agg.latest.model}"${agg.latest.year ? `, issued ${agg.latest.year}` : ""}, status ${agg.latest.status}).` : "No certificate rows are present in the snapshot.";
36
36
  const link = agg.latest?.pdf_key ? ` Its document: https://www.oimlsmart.org/cert-pdf/${agg.latest.pdf_key}` : "";
37
37
  return [
38
- `Certificate register (authoritative computation over the snapshot): the ${agg.family} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}).`,
38
+ `CERTIFICATE REGISTER \u2014 THIS NOTE ANSWERS THE QUESTION. Answer from THIS note; do not refuse for want of passages (the retrieval passages are irrelevant for register questions).`,
39
+ `The ${agg.family} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}) \u2014 computed over the register snapshot; state these numbers verbatim.`,
39
40
  latest + link,
40
- "Certificates are issued per RECOMMENDATION FAMILY \u2014 the register carries no edition dimension, so an edition named in the question (e.g. 2021) does not narrow it. State the family total, qualify that the register is a snapshot, and cite these numbers verbatim."
41
+ "Certificates are issued per RECOMMENDATION FAMILY \u2014 the register carries no edition dimension, so an edition named in the question (e.g. 2021) does not narrow it; say so when the question names an edition. Qualify that the register is a snapshot, and cite the register."
41
42
  ].join("\n");
42
43
  }
43
44
  function aggregateBlock(agg) {
@@ -1181,7 +1181,7 @@ var certificatesSearch = {
1181
1181
  handler: async (env, args) => {
1182
1182
  const query = String(args?.query ?? "").trim().slice(0, 160);
1183
1183
  if (!query) return null;
1184
- const { searchRegister, registerNote, certificateLinks } = await import("./certificates-TDPN7SA2.js");
1184
+ const { searchRegister, registerNote, certificateLinks } = await import("./certificates-TMYS7XLD.js");
1185
1185
  const reg = await searchRegister(env.DB, query, true);
1186
1186
  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.`;
1187
1187
  return { name: "certificates.search", query, output };
@@ -22,7 +22,7 @@ import {
22
22
  tableRetyped,
23
23
  toolNote,
24
24
  verdictNote
25
- } from "./chunk-3L6TJAS6.js";
25
+ } from "./chunk-J6LBR6GI.js";
26
26
  import {
27
27
  NO_CONTEXT,
28
28
  STAGE_NAMES,
@@ -108,7 +108,7 @@ import {
108
108
  registerAggregateIntent,
109
109
  registerNote,
110
110
  searchRegister
111
- } from "./chunk-IOT75KLU.js";
111
+ } from "./chunk-GBGRHXRU.js";
112
112
  import {
113
113
  P
114
114
  } from "./chunk-3FYJM7LH.js";
@@ -2082,9 +2082,33 @@ async function handleAsk(env, ctx, req, tier, key) {
2082
2082
  if (fam) {
2083
2083
  const agg = await registerAggregate(env.DB, fam);
2084
2084
  if (agg) {
2085
+ const latestLine = agg.latest ? `The latest certificate in the snapshot is ${agg.latest.num} \u2014 holder ${agg.latest.holder}, model "${agg.latest.model}"${agg.latest.year ? `, issued ${agg.latest.year}` : ""}, status ${agg.latest.status}.` : "No certificate rows are present in the snapshot.";
2086
+ const linkLine = agg.latest?.pdf_key ? `
2087
+
2088
+ [The latest certificate's document](${`/cert-pdf/${agg.latest.pdf_key}`}) is on file.` : "";
2089
+ const answer2 = aggIntent === "count" ? `The ${P().publisher.name} ${agg.family} family holds **${agg.count} certificate${agg.count === 1 ? "" : "s"}** in the ${P().publisher.name}-CS register snapshot (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}).
2090
+
2091
+ Certificates are issued per recommendation family \u2014 the register carries no edition dimension, so the 2021 you named does not narrow the count. The register is a snapshot rather than live certification status.` : `${latestLine}${linkLine}
2092
+
2093
+ Certificates are issued per recommendation family \u2014 the register carries no edition dimension. The register is a snapshot rather than live certification status.`;
2094
+ const block = aggregateBlock(agg);
2095
+ registerBlock = block;
2085
2096
  aggregateNoteText = aggregateNote(agg);
2086
- registerBlock = aggregateBlock(agg);
2087
- console.log("register aggregate:", agg.family, "count", agg.count, "latest", agg.latest?.num ?? "none");
2097
+ const queryHash2 = await sha256Hex(q.query);
2098
+ telemetry(env, ctx, tier, "ask", MODELS.member, true, answer2.length, queryHash2, q.lang, void 0, telemetryMeta());
2099
+ const tq2 = await chargeAnswerTokens(env, bucketId, void 0, q.query.length, answer2.length);
2100
+ return json({
2101
+ answer: answer2,
2102
+ citations: [{ docidentifier: `${P().publisher.name}-CS certificate register (family ${agg.family})`, corpus: "register" }],
2103
+ model: MODELS.member,
2104
+ query_hash: queryHash2,
2105
+ follow_ups: [],
2106
+ blocks: [block],
2107
+ context_applied: NO_CONTEXT,
2108
+ read: readAs(),
2109
+ ...ablate ? { ablate } : {},
2110
+ quota: { ...quota, ...tq2 }
2111
+ });
2088
2112
  }
2089
2113
  }
2090
2114
  }
@@ -4,7 +4,7 @@ import {
4
4
  parseToolCall,
5
5
  runTool,
6
6
  toolNote
7
- } from "./chunk-3L6TJAS6.js";
7
+ } from "./chunk-J6LBR6GI.js";
8
8
  import "./chunk-TH5XGPD5.js";
9
9
  import "./chunk-4NXH5ZI6.js";
10
10
  import "./chunk-VT7DR6NQ.js";
@@ -4,12 +4,12 @@ import {
4
4
  handleMemories,
5
5
  scoreFaithfulness,
6
6
  scoreJudge
7
- } from "../../chunk-U6FXEUZP.js";
7
+ } from "../../chunk-ZHHORWM6.js";
8
8
  import {
9
9
  TOOLS_REGISTRY,
10
10
  bindModelNode,
11
11
  modelGroundingBlock
12
- } from "../../chunk-3L6TJAS6.js";
12
+ } from "../../chunk-J6LBR6GI.js";
13
13
  import {
14
14
  handleSearch
15
15
  } from "../../chunk-P6IRYZLL.js";
@@ -68,7 +68,7 @@ import {
68
68
  sha256Hex,
69
69
  today
70
70
  } from "../../chunk-VT7DR6NQ.js";
71
- import "../../chunk-IOT75KLU.js";
71
+ import "../../chunk-GBGRHXRU.js";
72
72
  import {
73
73
  P,
74
74
  setProfile
@@ -1043,13 +1043,13 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
1043
1043
  // stream:false forces the JSON lane (anon defaults to SSE)
1044
1044
  body: JSON.stringify({ ...args, stream: false })
1045
1045
  });
1046
- const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-EI6M4AY2.js");
1046
+ const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-O4JYGVSR.js");
1047
1047
  let payload;
1048
1048
  if (TOOLS_REGISTRY2.some((t) => t.name === name && t.audiences.includes("mcp"))) {
1049
1049
  const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
1050
1050
  payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
1051
1051
  } else {
1052
- const res = name === "ask" ? await (await import("../../ask-2BYMHPT3.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-OVUHVV35.js")).handleSearch(env, ctx, inner, tier, key);
1052
+ const res = name === "ask" ? await (await import("../../ask-RAQHKSPN.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-OVUHVV35.js")).handleSearch(env, ctx, inner, tier, key);
1053
1053
  payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
1054
1054
  }
1055
1055
  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.123",
30
+ "version": "0.2.126",
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",
@@ -770,9 +770,38 @@ let convEntities: Array<{ entity: string; kind: string }> = [];
770
770
  if (fam) {
771
771
  const agg = await registerAggregate(env.DB, fam);
772
772
  if (agg) {
773
+ // DETERMINISTIC ANSWER (the verdict engine's law applied to the
774
+ // register): a count/latest question is computed data — the
775
+ // model never enters the loop, so its scope training can never
776
+ // refuse a computed fact. The prose mirrors the note; the block
777
+ // carries the same numbers for the UI.
778
+ const latestLine = agg.latest
779
+ ? `The latest certificate in the snapshot is ${agg.latest.num} — holder ${agg.latest.holder}, model "${agg.latest.model}"${agg.latest.year ? `, issued ${agg.latest.year}` : ""}, status ${agg.latest.status}.`
780
+ : "No certificate rows are present in the snapshot.";
781
+ const linkLine = agg.latest?.pdf_key
782
+ ? `\n\n[The latest certificate's document](${`/cert-pdf/${agg.latest.pdf_key}`}) is on file.`
783
+ : "";
784
+ const answer = aggIntent === "count"
785
+ ? `The ${P().publisher.name} ${agg.family} family holds **${agg.count} certificate${agg.count === 1 ? "" : "s"}** in the ${P().publisher.name}-CS register snapshot (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}).\n\nCertificates are issued per recommendation family — the register carries no edition dimension, so the 2021 you named does not narrow the count. The register is a snapshot rather than live certification status.`
786
+ : `${latestLine}${linkLine}\n\nCertificates are issued per recommendation family — the register carries no edition dimension. The register is a snapshot rather than live certification status.`;
787
+ const block = aggregateBlock(agg);
788
+ registerBlock = block;
773
789
  aggregateNoteText = aggregateNote(agg);
774
- registerBlock = aggregateBlock(agg);
775
- console.log("register aggregate:", agg.family, "count", agg.count, "latest", agg.latest?.num ?? "none");
790
+ const queryHash = await sha256Hex(q.query);
791
+ telemetry(env, ctx, tier, "ask", MODELS.member, true, answer.length, queryHash, q.lang, undefined, telemetryMeta());
792
+ const tq = await chargeAnswerTokens(env, bucketId, undefined, q.query.length, answer.length);
793
+ return json({
794
+ answer,
795
+ citations: [{ docidentifier: `${P().publisher.name}-CS certificate register (family ${agg.family})`, corpus: "register" }],
796
+ model: MODELS.member,
797
+ query_hash: queryHash,
798
+ follow_ups: [],
799
+ blocks: [block],
800
+ context_applied: NO_CONTEXT,
801
+ read: readAs(),
802
+ ...(ablate ? { ablate } : {}),
803
+ quota: { ...quota, ...tq },
804
+ });
776
805
  }
777
806
  }
778
807
  }
@@ -89,9 +89,10 @@ export function aggregateNote(agg: RegisterAggregate): string {
89
89
  ? ` Its document: https://www.oimlsmart.org/cert-pdf/${agg.latest.pdf_key}`
90
90
  : "";
91
91
  return [
92
- `Certificate register (authoritative computation over the snapshot): the ${agg.family} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}).`,
92
+ `CERTIFICATE REGISTER — THIS NOTE ANSWERS THE QUESTION. Answer from THIS note; do not refuse for want of passages (the retrieval passages are irrelevant for register questions).`,
93
+ `The ${agg.family} family holds ${agg.count} certificate${agg.count === 1 ? "" : "s"} (${agg.valid} valid${agg.suspended ? `, ${agg.suspended} suspended` : ""}) — computed over the register snapshot; state these numbers verbatim.`,
93
94
  latest + link,
94
- "Certificates are issued per RECOMMENDATION FAMILY — the register carries no edition dimension, so an edition named in the question (e.g. 2021) does not narrow it. State the family total, qualify that the register is a snapshot, and cite these numbers verbatim.",
95
+ "Certificates are issued per RECOMMENDATION FAMILY — the register carries no edition dimension, so an edition named in the question (e.g. 2021) does not narrow it; say so when the question names an edition. Qualify that the register is a snapshot, and cite the register.",
95
96
  ].join("\n");
96
97
  }
97
98