@konneal/engine 0.2.97 → 0.2.98

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.
@@ -0,0 +1,15 @@
1
+ import {
2
+ handleAsk
3
+ } from "./chunk-BIX3SMC7.js";
4
+ import "./chunk-A3ELAHKF.js";
5
+ import "./chunk-TXPWLKCI.js";
6
+ import "./chunk-KNCRYAX3.js";
7
+ import "./chunk-DTW4UW2E.js";
8
+ import "./chunk-A3QHHUN5.js";
9
+ import "./chunk-U4ERFUOK.js";
10
+ import "./chunk-BOAITSVV.js";
11
+ import "./chunk-JZFXSTYX.js";
12
+ import "./chunk-3FYJM7LH.js";
13
+ export {
14
+ handleAsk
15
+ };
@@ -3,13 +3,13 @@ import {
3
3
  hasLane,
4
4
  portIndex,
5
5
  portModelRunner
6
- } from "./chunk-LOBYXEVD.js";
6
+ } from "./chunk-KNCRYAX3.js";
7
7
  import {
8
8
  standardKeysFrom
9
- } from "./chunk-LVZTWUVJ.js";
9
+ } from "./chunk-U4ERFUOK.js";
10
10
  import {
11
11
  THRESHOLDS
12
- } from "./chunk-2PCUAJJO.js";
12
+ } from "./chunk-BOAITSVV.js";
13
13
  import {
14
14
  P
15
15
  } from "./chunk-3FYJM7LH.js";
@@ -18,7 +18,7 @@ import {
18
18
  tableRetyped,
19
19
  toolNote,
20
20
  verdictNote
21
- } from "./chunk-AJU6LMY3.js";
21
+ } from "./chunk-A3ELAHKF.js";
22
22
  import {
23
23
  NO_CONTEXT,
24
24
  answerQuality,
@@ -56,20 +56,20 @@ import {
56
56
  tokenBudget,
57
57
  understandQuery,
58
58
  usageTotal
59
- } from "./chunk-PTCDEFI3.js";
59
+ } from "./chunk-TXPWLKCI.js";
60
60
  import {
61
61
  embed,
62
62
  generateOnce,
63
63
  portModelRunner,
64
64
  portStore
65
- } from "./chunk-LOBYXEVD.js";
65
+ } from "./chunk-KNCRYAX3.js";
66
66
  import {
67
67
  corsHeaders,
68
68
  err,
69
69
  json,
70
70
  readJson,
71
71
  validateQuery
72
- } from "./chunk-SPKPH54J.js";
72
+ } from "./chunk-DTW4UW2E.js";
73
73
  import {
74
74
  canonicalRefusal,
75
75
  refusalAnswer
@@ -79,7 +79,7 @@ import {
79
79
  requestSalt,
80
80
  resolveRequestScope,
81
81
  standardKeysFrom
82
- } from "./chunk-LVZTWUVJ.js";
82
+ } from "./chunk-U4ERFUOK.js";
83
83
  import {
84
84
  LIMITS,
85
85
  MODELS,
@@ -90,7 +90,7 @@ import {
90
90
  requestEffort,
91
91
  roleModel,
92
92
  sha256Hex
93
- } from "./chunk-2PCUAJJO.js";
93
+ } from "./chunk-BOAITSVV.js";
94
94
  import {
95
95
  certificateLinks,
96
96
  registerNote,
@@ -65,6 +65,7 @@ var THRESHOLDS = {
65
65
  * pool below the primary dense lane; they must earn their window
66
66
  * slot under the cross-encoder, not by graph membership alone. */
67
67
  graphLaneDiscount: 0.75,
68
+ licensedLaneScore: 0.5,
68
69
  /** The entailment gate (TODO.new-era/10): the faithfulness scorer
69
70
  * promoted from eval-only onto the serving path. The confidence line
70
71
  * then states a measurement — claim support in the cited passages —
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LIMITS,
3
3
  sha256Hex
4
- } from "./chunk-2PCUAJJO.js";
4
+ } from "./chunk-BOAITSVV.js";
5
5
  import {
6
6
  P
7
7
  } from "./chunk-3FYJM7LH.js";
@@ -6,27 +6,27 @@ import {
6
6
  sessionFrom,
7
7
  telemetry,
8
8
  understandQuery
9
- } from "./chunk-PTCDEFI3.js";
9
+ } from "./chunk-TXPWLKCI.js";
10
10
  import {
11
11
  portModelRunner
12
- } from "./chunk-LOBYXEVD.js";
12
+ } from "./chunk-KNCRYAX3.js";
13
13
  import {
14
14
  corsHeaders,
15
15
  err,
16
16
  json,
17
17
  readJson,
18
18
  validateQuery
19
- } from "./chunk-SPKPH54J.js";
19
+ } from "./chunk-DTW4UW2E.js";
20
20
  import {
21
21
  entitlementScope,
22
22
  standardKeysFrom
23
- } from "./chunk-LVZTWUVJ.js";
23
+ } from "./chunk-U4ERFUOK.js";
24
24
  import {
25
25
  LIMITS,
26
26
  MODELS,
27
27
  num,
28
28
  sha256Hex
29
- } from "./chunk-2PCUAJJO.js";
29
+ } from "./chunk-BOAITSVV.js";
30
30
 
31
31
  // workers/worker_public/src/search.ts
32
32
  async function handleSearch(env, ctx, req, tier, key) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  answerEffort,
3
3
  effortBudget
4
- } from "./chunk-2PCUAJJO.js";
4
+ } from "./chunk-BOAITSVV.js";
5
5
 
6
6
  // workers/worker_public/src/ai.ts
7
7
  var delay = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -3,12 +3,13 @@ import {
3
3
  hasLane,
4
4
  portIndex,
5
5
  portModelRunner,
6
+ portStore,
6
7
  rerank
7
- } from "./chunk-LOBYXEVD.js";
8
+ } from "./chunk-KNCRYAX3.js";
8
9
  import {
9
10
  bubbleConfirmPage,
10
11
  isAllowedBubbleOrigin
11
- } from "./chunk-SPKPH54J.js";
12
+ } from "./chunk-DTW4UW2E.js";
12
13
  import {
13
14
  DATASETS,
14
15
  LIMITS,
@@ -18,7 +19,7 @@ import {
18
19
  processExpansion,
19
20
  sha256Hex,
20
21
  today
21
- } from "./chunk-2PCUAJJO.js";
22
+ } from "./chunk-BOAITSVV.js";
22
23
  import {
23
24
  P
24
25
  } from "./chunk-3FYJM7LH.js";
@@ -22523,29 +22524,35 @@ var graphLane = {
22523
22524
  };
22524
22525
 
22525
22526
  // workers/worker_public/src/stages/licensedLane.ts
22527
+ var sha1Hex = async (s8) => {
22528
+ const digest = await crypto.subtle.digest("SHA-1", new TextEncoder().encode(s8));
22529
+ return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
22530
+ };
22526
22531
  var licensedLane = {
22527
22532
  name: "licensed-lane",
22528
22533
  failure: "additive",
22529
- when: (c) => !!c.opts.licensedDocNumbers?.length && c.vector.length > 0,
22530
- prefetch: (c) => {
22531
- c.lane["licensed-lane"] = portIndex(c.env, "public").query({
22532
- vector: c.vector,
22533
- topK: 12,
22534
- filter: { standard: { $in: c.opts.licensedDocNumbers } }
22535
- });
22536
- },
22534
+ when: (c) => !!c.opts.licensedDocNumbers?.length,
22537
22535
  run: async (c) => {
22538
- const g = await c.lane["licensed-lane"];
22536
+ const standards = c.opts.licensedDocNumbers;
22537
+ const placeholders = standards.map((_, i) => `?${i + 1}`).join(",");
22538
+ const rows = await portStore(c.env).prepare(`SELECT standard, node_id FROM model_nodes WHERE standard IN (${placeholders}) LIMIT 40`).bind(...standards).all().catch(() => ({ results: [] }));
22539
+ const ids = await Promise.all(
22540
+ (rows.results ?? []).map(
22541
+ async (r) => "m" + (await sha1Hex(`${r.standard}|${r.node_id}`)).slice(0, 16)
22542
+ )
22543
+ );
22544
+ if (!ids.length) return;
22545
+ const matches = await portIndex(c.env, "public").getByIds(ids);
22539
22546
  const seenIds = new Set(c.matches.map((m) => m.id));
22540
22547
  let merged = 0;
22541
- for (const m of (g ?? []).slice(0, 10)) {
22542
- if (!seenIds.has(m.id)) {
22543
- c.matches.push({ id: m.id, score: m.score * THRESHOLDS.graphLaneDiscount, metadata: m.metadata });
22548
+ for (const m of matches) {
22549
+ if (m.metadata && !seenIds.has(m.id)) {
22550
+ c.matches.push({ id: m.id, score: THRESHOLDS.licensedLaneScore, metadata: m.metadata });
22544
22551
  seenIds.add(m.id);
22545
22552
  merged++;
22546
22553
  }
22547
22554
  }
22548
- console.log("licensed lane:", g?.length ?? 0, "hits,", merged, "merged");
22555
+ console.log("licensed lane:", ids.length, "units,", matches.length, "vectors,", merged, "merged");
22549
22556
  }
22550
22557
  };
22551
22558
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DATASETS,
3
3
  datasetAllowed
4
- } from "./chunk-2PCUAJJO.js";
4
+ } from "./chunk-BOAITSVV.js";
5
5
  import {
6
6
  P
7
7
  } from "./chunk-3FYJM7LH.js";
package/dist/config.d.ts CHANGED
@@ -37,6 +37,7 @@ export declare const THRESHOLDS: {
37
37
  * pool below the primary dense lane; they must earn their window
38
38
  * slot under the cross-encoder, not by graph membership alone. */
39
39
  readonly graphLaneDiscount: 0.75;
40
+ readonly licensedLaneScore: 0.5;
40
41
  /** The entailment gate (TODO.new-era/10): the faithfulness scorer
41
42
  * promoted from eval-only onto the serving path. The confidence line
42
43
  * then states a measurement — claim support in the cited passages —
@@ -0,0 +1,13 @@
1
+ import {
2
+ handleSearch
3
+ } from "./chunk-GY33RTEO.js";
4
+ import "./chunk-TXPWLKCI.js";
5
+ import "./chunk-KNCRYAX3.js";
6
+ import "./chunk-DTW4UW2E.js";
7
+ import "./chunk-A3QHHUN5.js";
8
+ import "./chunk-U4ERFUOK.js";
9
+ import "./chunk-BOAITSVV.js";
10
+ import "./chunk-3FYJM7LH.js";
11
+ export {
12
+ handleSearch
13
+ };
@@ -4,10 +4,10 @@ import {
4
4
  parseToolCall,
5
5
  runTool,
6
6
  toolNote
7
- } from "./chunk-AJU6LMY3.js";
8
- import "./chunk-LOBYXEVD.js";
9
- import "./chunk-LVZTWUVJ.js";
10
- import "./chunk-2PCUAJJO.js";
7
+ } from "./chunk-A3ELAHKF.js";
8
+ import "./chunk-KNCRYAX3.js";
9
+ import "./chunk-U4ERFUOK.js";
10
+ import "./chunk-BOAITSVV.js";
11
11
  import "./chunk-3FYJM7LH.js";
12
12
  export {
13
13
  TOOLS_REGISTRY,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  authenticate
3
- } from "../../chunk-SPKPH54J.js";
4
- import "../../chunk-2PCUAJJO.js";
3
+ } from "../../chunk-DTW4UW2E.js";
4
+ import "../../chunk-BOAITSVV.js";
5
5
  import {
6
6
  P,
7
7
  setProfile
@@ -16,7 +16,7 @@ import {
16
16
  roleModel,
17
17
  sha256Hex,
18
18
  today
19
- } from "../../chunk-2PCUAJJO.js";
19
+ } from "../../chunk-BOAITSVV.js";
20
20
  import "../../chunk-3FYJM7LH.js";
21
21
  export {
22
22
  DATASETS,
@@ -4,15 +4,15 @@ import {
4
4
  handleMemories,
5
5
  scoreFaithfulness,
6
6
  scoreJudge
7
- } from "../../chunk-CX3OVN3V.js";
7
+ } from "../../chunk-BIX3SMC7.js";
8
8
  import {
9
9
  TOOLS_REGISTRY,
10
10
  bindModelNode,
11
11
  modelGroundingBlock
12
- } from "../../chunk-AJU6LMY3.js";
12
+ } from "../../chunk-A3ELAHKF.js";
13
13
  import {
14
14
  handleSearch
15
- } from "../../chunk-ZLQMRQOV.js";
15
+ } from "../../chunk-GY33RTEO.js";
16
16
  import {
17
17
  buildMessages,
18
18
  citations,
@@ -34,13 +34,13 @@ import {
34
34
  sessionFrom,
35
35
  telemetry,
36
36
  understandQuery
37
- } from "../../chunk-PTCDEFI3.js";
37
+ } from "../../chunk-TXPWLKCI.js";
38
38
  import {
39
39
  cfBlobs,
40
40
  embed,
41
41
  generateOnce,
42
42
  portModelRunner
43
- } from "../../chunk-LOBYXEVD.js";
43
+ } from "../../chunk-KNCRYAX3.js";
44
44
  import {
45
45
  authenticate,
46
46
  corsHeaders,
@@ -49,14 +49,14 @@ import {
49
49
  readJson,
50
50
  validateQuery,
51
51
  withCors
52
- } from "../../chunk-SPKPH54J.js";
52
+ } from "../../chunk-DTW4UW2E.js";
53
53
  import {
54
54
  canonicalRefusal
55
55
  } from "../../chunk-A3QHHUN5.js";
56
56
  import {
57
57
  entitlementScope,
58
58
  standardKeysFrom
59
- } from "../../chunk-LVZTWUVJ.js";
59
+ } from "../../chunk-U4ERFUOK.js";
60
60
  import {
61
61
  LIMITS,
62
62
  MODELS,
@@ -67,7 +67,7 @@ import {
67
67
  roleModel,
68
68
  sha256Hex,
69
69
  today
70
- } from "../../chunk-2PCUAJJO.js";
70
+ } from "../../chunk-BOAITSVV.js";
71
71
  import "../../chunk-JZFXSTYX.js";
72
72
  import {
73
73
  P,
@@ -990,13 +990,13 @@ async function callToolOnce(env, ctx, _req, tier, key, name, args, t0) {
990
990
  // stream:false forces the JSON lane (anon defaults to SSE)
991
991
  body: JSON.stringify({ ...args, stream: false })
992
992
  });
993
- const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-Z4HQH3QU.js");
993
+ const { runTool, TOOLS_REGISTRY: TOOLS_REGISTRY2 } = await import("../../tools-YHEXFX6V.js");
994
994
  let payload;
995
995
  if (TOOLS_REGISTRY2.some((t) => t.name === name && t.audiences.includes("mcp"))) {
996
996
  const r = await runTool({ ...env, DB: env.DB }, { name, args }, "mcp");
997
997
  payload = r ? { tool: r.name, query: r.query, result: r.output } : { error: { message: `tool ${name} returned nothing for the given arguments` } };
998
998
  } else {
999
- const res = name === "ask" ? await (await import("../../ask-KKOQH7HK.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-CGQFGYTR.js")).handleSearch(env, ctx, inner, tier, key);
999
+ const res = name === "ask" ? await (await import("../../ask-4G24T25V.js")).handleAsk(env, ctx, inner, tier, key) : await (await import("../../search-EQAOPFCC.js")).handleSearch(env, ctx, inner, tier, key);
1000
1000
  payload = await res.json().catch(() => ({ error: { message: "tool transport failed", status: res.status } }));
1001
1001
  }
1002
1002
  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 });
@@ -4,8 +4,8 @@ import {
4
4
  requestSalt,
5
5
  resolveRequestScope,
6
6
  standardKeysFrom
7
- } from "../../chunk-LVZTWUVJ.js";
8
- import "../../chunk-2PCUAJJO.js";
7
+ } from "../../chunk-U4ERFUOK.js";
8
+ import "../../chunk-BOAITSVV.js";
9
9
  import "../../chunk-3FYJM7LH.js";
10
10
  export {
11
11
  entitlementScope,
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.97",
30
+ "version": "0.2.98",
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",
@@ -62,6 +62,7 @@ export const THRESHOLDS = {
62
62
  * pool below the primary dense lane; they must earn their window
63
63
  * slot under the cross-encoder, not by graph membership alone. */
64
64
  graphLaneDiscount: 0.75,
65
+ licensedLaneScore: 0.5,
65
66
  /** The entailment gate (TODO.new-era/10): the faithfulness scorer
66
67
  * promoted from eval-only onto the serving path. The confidence line
67
68
  * then states a measurement — claim support in the cited passages —
@@ -1,38 +1,56 @@
1
1
  // Licensed lane (additive): an entitled caller whose question is
2
2
  // topically about a licensed standard gets that standard's typed units
3
- // merged into the pool at the graph lane's discount — the public
4
- // restatements (the Recommendations' own annexes citing the standard)
5
- // stop out-ranking the licensed package's own units, the rank-order
6
- // gap the quality ledger has documented on every damp-heat run since
7
- // the eleven-standard wave. Unentitled callers never see this lane
8
- // (license-scope would strip the units anyway — the lane simply does
9
- // not fire).
3
+ // merged into the pool before rerank — the public restatements stop
4
+ // out-ranking the licensed package's own machinery (the rank-order gap
5
+ // the quality ledger has documented on every damp-heat run since the
6
+ // eleven-standard wave).
7
+ //
8
+ // Identity, not similarity: the units are resolved from the model
9
+ // plane's own registry (D1 model_nodes by standard) and turned into
10
+ // index ids with the exporter's hash — `m` + sha1(standard|node_id)
11
+ // truncated to 16 — then fetched by id. Vectorize metadata filtering
12
+ // plays no part (measured: REST and binding filters on this index
13
+ // return empty even for values proven present), and no similarity
14
+ // search is needed — the package's units are the package's units, and
15
+ // the pool's cross-encoder ranks them against the question like every
16
+ // other candidate.
10
17
  import { THRESHOLDS } from "../config.ts";
11
- import { portIndex } from "../env.ts";
18
+ import { portIndex, portStore } from "../env.ts";
12
19
  import type { Stage } from "./types.ts";
13
20
 
21
+ const sha1Hex = async (s: string) => {
22
+ const digest = await crypto.subtle.digest("SHA-1", new TextEncoder().encode(s));
23
+ return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
24
+ };
25
+
14
26
  export const licensedLane: Stage = {
15
27
  name: "licensed-lane",
16
28
  failure: "additive",
17
- when: (c) => !!c.opts.licensedDocNumbers?.length && c.vector.length > 0,
18
- prefetch: (c) => {
19
- c.lane["licensed-lane"] = portIndex(c.env, "public").query({
20
- vector: c.vector,
21
- topK: 12,
22
- filter: { standard: { $in: c.opts.licensedDocNumbers } },
23
- });
24
- },
29
+ when: (c) => !!c.opts.licensedDocNumbers?.length,
25
30
  run: async (c) => {
26
- const g = (await c.lane["licensed-lane"]!) as any;
31
+ const standards = c.opts.licensedDocNumbers!;
32
+ const placeholders = standards.map((_, i) => `?${i + 1}`).join(",");
33
+ const rows = await portStore(c.env)
34
+ .prepare(`SELECT standard, node_id FROM model_nodes WHERE standard IN (${placeholders}) LIMIT 40`)
35
+ .bind(...standards)
36
+ .all()
37
+ .catch(() => ({ results: [] }));
38
+ const ids = await Promise.all(
39
+ ((rows.results ?? []) as { standard: string; node_id: string }[]).map(async (r) =>
40
+ "m" + (await sha1Hex(`${r.standard}|${r.node_id}`)).slice(0, 16),
41
+ ),
42
+ );
43
+ if (!ids.length) return;
44
+ const matches = await portIndex(c.env, "public").getByIds(ids);
27
45
  const seenIds = new Set(c.matches.map((m: any) => m.id));
28
46
  let merged = 0;
29
- for (const m of (g ?? []).slice(0, 10)) {
30
- if (!seenIds.has(m.id)) {
31
- c.matches.push({ id: m.id, score: m.score * THRESHOLDS.graphLaneDiscount, metadata: m.metadata });
47
+ for (const m of matches) {
48
+ if (m.metadata && !seenIds.has(m.id)) {
49
+ c.matches.push({ id: m.id, score: THRESHOLDS.licensedLaneScore, metadata: m.metadata });
32
50
  seenIds.add(m.id);
33
51
  merged++;
34
52
  }
35
53
  }
36
- console.log("licensed lane:", g?.length ?? 0, "hits,", merged, "merged");
54
+ console.log("licensed lane:", ids.length, "units,", matches.length, "vectors,", merged, "merged");
37
55
  },
38
56
  };
@@ -1,15 +0,0 @@
1
- import {
2
- handleAsk
3
- } from "./chunk-CX3OVN3V.js";
4
- import "./chunk-AJU6LMY3.js";
5
- import "./chunk-PTCDEFI3.js";
6
- import "./chunk-LOBYXEVD.js";
7
- import "./chunk-SPKPH54J.js";
8
- import "./chunk-A3QHHUN5.js";
9
- import "./chunk-LVZTWUVJ.js";
10
- import "./chunk-2PCUAJJO.js";
11
- import "./chunk-JZFXSTYX.js";
12
- import "./chunk-3FYJM7LH.js";
13
- export {
14
- handleAsk
15
- };
@@ -1,13 +0,0 @@
1
- import {
2
- handleSearch
3
- } from "./chunk-ZLQMRQOV.js";
4
- import "./chunk-PTCDEFI3.js";
5
- import "./chunk-LOBYXEVD.js";
6
- import "./chunk-SPKPH54J.js";
7
- import "./chunk-A3QHHUN5.js";
8
- import "./chunk-LVZTWUVJ.js";
9
- import "./chunk-2PCUAJJO.js";
10
- import "./chunk-3FYJM7LH.js";
11
- export {
12
- handleSearch
13
- };