@konneal/engine 0.2.116 → 0.2.117

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-YVNY4JWP.js";
3
+ } from "./chunk-ABHZUXZ5.js";
4
4
  import "./chunk-32UDKBA2.js";
5
- import "./chunk-PJ3ET5AY.js";
5
+ import "./chunk-KRSSSTMV.js";
6
6
  import "./chunk-TH5XGPD5.js";
7
7
  import "./chunk-DJ65EF5G.js";
8
8
  import "./chunk-A3QHHUN5.js";
@@ -60,7 +60,7 @@ import {
60
60
  tokenBudget,
61
61
  understandQuery,
62
62
  usageTotal
63
- } from "./chunk-PJ3ET5AY.js";
63
+ } from "./chunk-KRSSSTMV.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-PJ3ET5AY.js";
9
+ } from "./chunk-KRSSSTMV.js";
10
10
  import {
11
11
  portModelRunner
12
12
  } from "./chunk-TH5XGPD5.js";
@@ -22695,9 +22695,10 @@ var federate = {
22695
22695
 
22696
22696
  // workers/worker_public/src/stages/seal.ts
22697
22697
  async function familyChunks(env, familyNumber, query, keep) {
22698
+ const match2 = ftsMatchQuery(query) ?? `"${familyNumber}"`;
22698
22699
  const rows = await portStore(env).prepare(
22699
22700
  "SELECT id, doc_id, docidentifier, doctype, doc_number, edition, language, clause_anchor, clause_title, status, superseded_by, corpus, tier, text, unit_id, block, bm25(chunks_fts) AS rank FROM chunks_fts JOIN chunks c ON c.rowid = chunks_fts.rowid WHERE chunks_fts MATCH ?1 AND c.doc_number = ?2 ORDER BY rank LIMIT ?3"
22700
- ).bind(query.replace(/["'^]/g, " ").trim() || familyNumber, familyNumber, keep).all().catch(() => ({ results: [] }));
22701
+ ).bind(match2, familyNumber, keep * 4).all().catch(() => ({ results: [] }));
22701
22702
  return (rows.results ?? []).map((r) => ({
22702
22703
  id: String(r.id),
22703
22704
  score: 0,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  handleSearch
3
- } from "./chunk-XWT3T3T3.js";
4
- import "./chunk-PJ3ET5AY.js";
3
+ } from "./chunk-CTUT57OK.js";
4
+ import "./chunk-KRSSSTMV.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-YVNY4JWP.js";
7
+ } from "../../chunk-ABHZUXZ5.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-XWT3T3T3.js";
15
+ } from "../../chunk-CTUT57OK.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-PJ3ET5AY.js";
37
+ } from "../../chunk-KRSSSTMV.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-QDV37DDB.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-AXP7F365.js")).handleSearch(env, ctx, inner, tier, key);
1003
+ const res = name === "ask" ? await (await import("../../ask-2XVGJYUK.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-GGSBFGQ5.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.116",
30
+ "version": "0.2.117",
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",
@@ -4,6 +4,7 @@
4
4
  // inside it does.
5
5
  import { matchesDocScope } from "../context.ts";
6
6
  import { portStore } from "../env.ts";
7
+ import { ftsMatchQuery } from "../lexical.ts";
7
8
  import type { ChunkMeta, Hit } from "../../../shared/chunk";
8
9
  import type { Stage } from "./types.ts";
9
10
 
@@ -12,10 +13,16 @@ import type { Stage } from "./types.ts";
12
13
  * answer — a generic question's global ranking need not contain the
13
14
  * family at all, so an emptied pool pulls the family's own text. */
14
15
  async function familyChunks(env: any, familyNumber: string, query: string, keep: number): Promise<Hit[]> {
16
+ // ftsMatchQuery's OR shape: FTS5's implicit AND over a question's
17
+ // tokens matches nothing on standards prose (measured: 0 rows for
18
+ // the exact ask that needed this pull; the OR shape returns the
19
+ // family). Fetch wide — the edition filter downstream keeps only the
20
+ // declared edition, and the ranking then does its work.
21
+ const match = ftsMatchQuery(query) ?? `"${familyNumber}"`;
15
22
  const rows = await portStore(env).prepare(
16
23
  "SELECT id, doc_id, docidentifier, doctype, doc_number, edition, language, clause_anchor, clause_title, status, superseded_by, corpus, tier, text, unit_id, block, bm25(chunks_fts) AS rank FROM chunks_fts JOIN chunks c ON c.rowid = chunks_fts.rowid WHERE chunks_fts MATCH ?1 AND c.doc_number = ?2 ORDER BY rank LIMIT ?3",
17
24
  )
18
- .bind(query.replace(/["'^]/g, " ").trim() || familyNumber, familyNumber, keep)
25
+ .bind(match, familyNumber, keep * 4)
19
26
  .all()
20
27
  .catch(() => ({ results: [] }));
21
28
  return (rows.results ?? []).map((r: any) => ({