@konneal/engine 0.2.44 → 0.2.45

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,6 +1,6 @@
1
1
  import {
2
2
  handleAsk
3
- } from "./chunk-HDUSO5S5.js";
3
+ } from "./chunk-BCNSMJ7Q.js";
4
4
  import "./chunk-N2UOENDY.js";
5
5
  import "./chunk-R2V3X6SQ.js";
6
6
  import "./chunk-A3QHHUN5.js";
@@ -15,6 +15,10 @@ export declare function isRegisterShaped(query: string): boolean;
15
15
  * 2+ characters that are not register question words, plus bare model
16
16
  * numbers ("190", "HM14H1"). Upper-cased tokens match case-insensitively
17
17
  * in SQL LIKE. */
18
+ /** The family the question names ("R 60", "R60", "D 31") — the register
19
+ * search filters to it, so a question about R 60 never presents R 76
20
+ * rows. */
21
+ export declare function queryFamily(query: string): string | null;
18
22
  export declare function registerTokens(query: string): string[];
19
23
  /** The register query for a token set. Numeric tokens (a model number
20
24
  * like "190") must match as a STANDALONE value — `LIKE '%190%'` also
@@ -1751,6 +1751,10 @@ function semanticCacheKey(indexVersion, gen, signature) {
1751
1751
  function isRegisterShaped(query) {
1752
1752
  return /\bcertif(ied|icates?|ication)s?\b/i.test(query) && /\b(is|are|still|currently|valid|status|suspended|revoked|was|were)\b/i.test(query);
1753
1753
  }
1754
+ function queryFamily(query) {
1755
+ const m = /\b([RDMB])\s?-?(\d{2,3})\b/i.exec(query);
1756
+ return m ? `${m[1].toUpperCase()}${m[2].padStart(2, "0")}` : null;
1757
+ }
1754
1758
  function registerTokens(query) {
1755
1759
  const stop = /* @__PURE__ */ new Set([
1756
1760
  "the",
@@ -1833,7 +1837,13 @@ async function searchRegister(db, query) {
1833
1837
  if (!isRegisterShaped(query)) return null;
1834
1838
  const tokens2 = registerTokens(query);
1835
1839
  if (!tokens2.length) return null;
1836
- const { sql, params } = buildRegisterQuery(tokens2);
1840
+ const built = buildRegisterQuery(tokens2);
1841
+ let { sql, params } = built;
1842
+ const family = queryFamily(query);
1843
+ if (family) {
1844
+ sql = sql.replace(" WHERE ", " WHERE family = ?0 AND ");
1845
+ params.unshift(family);
1846
+ }
1837
1847
  try {
1838
1848
  const res = await db.prepare(sql).bind(...params).all();
1839
1849
  return { rows: res.results ?? [], tokens: tokens2 };
@@ -2183,6 +2193,7 @@ async function handleAsk(env, ctx, req, tier, key) {
2183
2193
  const graphDocNumbers = await graphExpand(env, understanding);
2184
2194
  const eNote = await editionNote(env, understanding);
2185
2195
  const register = await searchRegister(env.DB, q.query);
2196
+ console.log("register-search:", JSON.stringify({ shaped: !!register, tokens: register?.tokens ?? null, rows: register?.rows?.length ?? null, first: register?.rows?.[0]?.num ?? null }));
2186
2197
  const regNote = register ? registerNote(register.rows) : void 0;
2187
2198
  if (understanding?.intent !== "conversational" && !nodeScoped && !contextual && !declaredCtx && !draftAct && !apiCallIntent && !userImage && !fresh) {
2188
2199
  const warmVec = await warmEmbed ?? null;
@@ -9,7 +9,7 @@ import {
9
9
  modelGroundingBlock,
10
10
  scoreJudge,
11
11
  standardForDocNumber
12
- } from "../../chunk-HDUSO5S5.js";
12
+ } from "../../chunk-BCNSMJ7Q.js";
13
13
  import {
14
14
  buildMessages,
15
15
  citations,
@@ -999,7 +999,7 @@ async function handleMcp(env, ctx, req, tier, key) {
999
999
  // stream:false forces the JSON lane (anon defaults to SSE)
1000
1000
  body: JSON.stringify({ ...args, stream: false })
1001
1001
  });
1002
- const res = name === "ask" ? await (await import("../../ask-JOX2D7KH.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-QZDQVB57.js")).handleSearch(env, ctx, inner, tier, key);
1002
+ const res = name === "ask" ? await (await import("../../ask-OOIREJML.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-QZDQVB57.js")).handleSearch(env, ctx, inner, tier, key);
1003
1003
  return res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
1004
1004
  });
1005
1005
  if (out.ok && "accepted" in out) return new Response(null, { status: 202 });
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.44",
30
+ "version": "0.2.45",
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",
@@ -583,6 +583,7 @@ async function handleAsk(
583
583
  // join the prompt as an authoritative note — exact matches, never a
584
584
  // similarity guess about certification standing
585
585
  const register = await searchRegister(env.DB, q.query);
586
+ console.log("register-search:", JSON.stringify({ shaped: !!register, tokens: register?.tokens ?? null, rows: register?.rows?.length ?? null, first: register?.rows?.[0]?.num ?? null }));
586
587
  const regNote = register ? registerNote(register.rows) : undefined;
587
588
 
588
589
  // semantic cache: near-duplicate of a recently answered question —
@@ -29,6 +29,14 @@ export function isRegisterShaped(query: string): boolean {
29
29
  * 2+ characters that are not register question words, plus bare model
30
30
  * numbers ("190", "HM14H1"). Upper-cased tokens match case-insensitively
31
31
  * in SQL LIKE. */
32
+ /** The family the question names ("R 60", "R60", "D 31") — the register
33
+ * search filters to it, so a question about R 60 never presents R 76
34
+ * rows. */
35
+ export function queryFamily(query: string): string | null {
36
+ const m = /\b([RDMB])\s?-?(\d{2,3})\b/i.exec(query);
37
+ return m ? `${m[1].toUpperCase()}${m[2].padStart(2, "0")}` : null;
38
+ }
39
+
32
40
  export function registerTokens(query: string): string[] {
33
41
  const stop = new Set([
34
42
  "the", "a", "an", "is", "are", "was", "were", "still", "currently", "in", "on", "for", "of", "and", "or",
@@ -84,7 +92,13 @@ export async function searchRegister(db: any, query: string): Promise<{ rows: Re
84
92
  if (!isRegisterShaped(query)) return null;
85
93
  const tokens = registerTokens(query);
86
94
  if (!tokens.length) return null;
87
- const { sql, params } = buildRegisterQuery(tokens);
95
+ const built = buildRegisterQuery(tokens);
96
+ let { sql, params } = built;
97
+ const family = queryFamily(query);
98
+ if (family) {
99
+ sql = sql.replace(" WHERE ", " WHERE family = ?0 AND ");
100
+ params.unshift(family);
101
+ }
88
102
  try {
89
103
  const res = await db.prepare(sql).bind(...params).all();
90
104
  return { rows: (res.results ?? []) as RegisterRow[], tokens };