@codemem/core 0.50.0-beta.1 → 0.50.0-beta.2

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.
Files changed (68) hide show
  1. package/dist/coordinator-actions.d.ts +2 -0
  2. package/dist/coordinator-actions.d.ts.map +1 -1
  3. package/dist/coordinator-device-removal-list.d.ts +3 -1
  4. package/dist/coordinator-device-removal-list.d.ts.map +1 -1
  5. package/dist/{coordinator-runtime-ynLTJI6d.js → coordinator-runtime-ChgCIqfx.js} +400 -396
  6. package/dist/coordinator-runtime-ChgCIqfx.js.map +1 -0
  7. package/dist/device-identity-inventory.d.ts.map +1 -1
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +10146 -9920
  11. package/dist/index.js.map +1 -1
  12. package/dist/ingest-events.d.ts.map +1 -1
  13. package/dist/internal/cloudflare-coordinator.js +2 -2
  14. package/dist/internal/relay-runtime.js +10 -10
  15. package/dist/legacy-team-setup-completion-manifest.d.ts +41 -0
  16. package/dist/legacy-team-setup-completion-manifest.d.ts.map +1 -1
  17. package/dist/legacy-team-setup-errors.d.ts +1 -1
  18. package/dist/legacy-team-setup-errors.d.ts.map +1 -1
  19. package/dist/{owner-enrollment-start-D8QzF1Ar.js → owner-enrollment-start-CD7R8wy3.js} +2 -2
  20. package/dist/{owner-enrollment-start-D8QzF1Ar.js.map → owner-enrollment-start-CD7R8wy3.js.map} +1 -1
  21. package/dist/pairing-removal.d.ts +2 -1
  22. package/dist/pairing-removal.d.ts.map +1 -1
  23. package/dist/pi-hooks.d.ts +1 -5
  24. package/dist/pi-hooks.d.ts.map +1 -1
  25. package/dist/project-scope-settings.d.ts +14 -1
  26. package/dist/project-scope-settings.d.ts.map +1 -1
  27. package/dist/raw-event-flush.d.ts.map +1 -1
  28. package/dist/{relay-peer-client-w7WdS1AP.js → relay-peer-client-CrFrhN_q.js} +1953 -1949
  29. package/dist/relay-peer-client-CrFrhN_q.js.map +1 -0
  30. package/dist/removed-device-local-ids.d.ts +16 -0
  31. package/dist/removed-device-local-ids.d.ts.map +1 -0
  32. package/dist/scope-membership-cache-read.d.ts +28 -1
  33. package/dist/scope-membership-cache-read.d.ts.map +1 -1
  34. package/dist/scope-membership-cache-test-fixtures.d.ts +1 -0
  35. package/dist/scope-membership-cache-test-fixtures.d.ts.map +1 -1
  36. package/dist/scope-membership-cache.d.ts +1 -1
  37. package/dist/scope-membership-cache.d.ts.map +1 -1
  38. package/dist/scope-membership-evidence.d.ts +17 -1
  39. package/dist/scope-membership-evidence.d.ts.map +1 -1
  40. package/dist/{scope-resolution-B7FK15hx.js → scope-resolution-DXzf4k16.js} +1353 -1313
  41. package/dist/{scope-resolution-B7FK15hx.js.map → scope-resolution-DXzf4k16.js.map} +1 -1
  42. package/dist/semantic-worker-entry.js +1 -1
  43. package/dist/{semantic-worker-job-BjujlM4-.js → semantic-worker-job-DjfAtX64.js} +3 -3
  44. package/dist/{semantic-worker-job-BjujlM4-.js.map → semantic-worker-job-DjfAtX64.js.map} +1 -1
  45. package/dist/{semantic-worker-ranking-WaUCapnY.js → semantic-worker-ranking-CZCemeb4.js} +26 -26
  46. package/dist/{semantic-worker-ranking-WaUCapnY.js.map → semantic-worker-ranking-CZCemeb4.js.map} +1 -1
  47. package/dist/{sync-auth-constants-DNUSV-Tn.js → sync-auth-constants-CifCg69d.js} +16 -14
  48. package/dist/{sync-auth-constants-DNUSV-Tn.js.map → sync-auth-constants-CifCg69d.js.map} +1 -1
  49. package/dist/sync-channel-pass.d.ts.map +1 -1
  50. package/dist/sync-pass.d.ts +2 -0
  51. package/dist/sync-pass.d.ts.map +1 -1
  52. package/dist/sync-reachability-pass-BFTEIkZH.js +2 -0
  53. package/dist/{sync-reachability-pass-DKEORTbs.js → sync-reachability-pass-vOvswNNG.js} +2738 -2591
  54. package/dist/sync-reachability-pass-vOvswNNG.js.map +1 -0
  55. package/dist/sync-replication.d.ts +5 -0
  56. package/dist/sync-replication.d.ts.map +1 -1
  57. package/dist/sync-status-test-fixtures.d.ts +1 -1
  58. package/dist/sync-status-test-fixtures.d.ts.map +1 -1
  59. package/dist/test-utils.d.ts +4 -1
  60. package/dist/test-utils.d.ts.map +1 -1
  61. package/dist/{validated-vector-index-audit-BtUovYuM.js → validated-vector-index-audit-CFSIbYIn.js} +33 -33
  62. package/dist/{validated-vector-index-audit-BtUovYuM.js.map → validated-vector-index-audit-CFSIbYIn.js.map} +1 -1
  63. package/dist/viewer-device-removal-commit.d.ts.map +1 -1
  64. package/package.json +3 -3
  65. package/dist/coordinator-runtime-ynLTJI6d.js.map +0 -1
  66. package/dist/relay-peer-client-w7WdS1AP.js.map +0 -1
  67. package/dist/sync-reachability-pass-BpTtRqcV.js +0 -2
  68. package/dist/sync-reachability-pass-DKEORTbs.js.map +0 -1
@@ -8,7 +8,7 @@ if (import.meta.url.endsWith(".ts")) {
8
8
  return t.parentURL?.startsWith(i) && e.startsWith(".") && e.endsWith(".js") ? n(`${e.slice(0, -3)}.ts`, t) : n(e, t);
9
9
  } });
10
10
  }
11
- await import("./semantic-worker-job-BjujlM4-.js");
11
+ await import("./semantic-worker-job-DjfAtX64.js");
12
12
  //#endregion
13
13
 
14
14
  //# sourceMappingURL=semantic-worker-entry.js.map
@@ -1,5 +1,5 @@
1
- import { lt as e } from "./scope-resolution-B7FK15hx.js";
2
- import { n as t } from "./semantic-worker-ranking-WaUCapnY.js";
1
+ import { mt as e } from "./scope-resolution-DXzf4k16.js";
2
+ import { n as t } from "./semantic-worker-ranking-CZCemeb4.js";
3
3
  import { statSync as n } from "node:fs";
4
4
  import { load as r } from "sqlite-vec";
5
5
  import { parentPort as i, workerData as a } from "node:worker_threads";
@@ -47,4 +47,4 @@ o.on("message", (e) => {
47
47
  }), o.postMessage({ type: "ready" });
48
48
  //#endregion
49
49
 
50
- //# sourceMappingURL=semantic-worker-job-BjujlM4-.js.map
50
+ //# sourceMappingURL=semantic-worker-job-DjfAtX64.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-worker-job-BjujlM4-.js","names":[],"sources":["../src/semantic/semantic-worker-job.ts"],"sourcesContent":["import { statSync } from \"node:fs\";\nimport { parentPort, workerData } from \"node:worker_threads\";\nimport { load } from \"sqlite-vec\";\nimport { connectReadOnly } from \"../db.js\";\nimport type { RankInput, WorkerRequest } from \"./semantic-worker-protocol.js\";\nimport { rankWorkerInput } from \"./semantic-worker-ranking.js\";\n\nif (!parentPort) throw new Error(\"semantic_worker_parent_required\");\nconst port = parentPort;\nconst { dbPath, fileIdentity } = workerData as { dbPath: string; fileIdentity: string };\nconst stat = statSync(dbPath);\nif (`${stat.dev}:${stat.ino}` !== fileIdentity) throw new Error(\"semantic_worker_file_changed\");\nconst db = connectReadOnly(dbPath);\ntry {\n\tload(db);\n\tdb.pragma(\"query_only = ON\");\n\tdb.prepare(\"SELECT vec_version()\").get();\n} catch (error) {\n\tdb.close();\n\tthrow error;\n}\n\nfunction validateInput(input: RankInput): void {\n\tif (\n\t\ttypeof input.generationId !== \"string\" ||\n\t\t!input.generationId.trim() ||\n\t\tinput.generationId.length > 256 ||\n\t\t!(input.embedding instanceof Float32Array) ||\n\t\tinput.embedding.length !== 384 ||\n\t\t!input.embedding.every(Number.isFinite) ||\n\t\t!input.proof.actorId.trim() ||\n\t\t!input.proof.deviceId.trim() ||\n\t\t!input.embeddingIdentity ||\n\t\tinput.embeddingIdentity.length > 2048 ||\n\t\t!Number.isFinite(input.limit) ||\n\t\tJSON.stringify(input.filters).length > 32_768\n\t)\n\t\tthrow new Error(\"invalid_semantic_worker_input\");\n}\n\nport.on(\"message\", (request: WorkerRequest) => {\n\tif (request?.type === \"close\") {\n\t\tdb.close();\n\t\tport.close();\n\t\treturn;\n\t}\n\tif (\n\t\trequest?.type !== \"rank\" ||\n\t\t!Number.isSafeInteger(request.id) ||\n\t\t!Number.isFinite(request.deadlineAt)\n\t) {\n\t\tthrow new Error(\"invalid_semantic_worker_message\");\n\t}\n\ttry {\n\t\tvalidateInput(request.input);\n\t\tif (Date.now() >= request.deadlineAt) {\n\t\t\tport.postMessage({ type: \"error\", id: request.id, code: \"expired\" });\n\t\t\treturn;\n\t\t}\n\t\tconst output = rankWorkerInput(db, request.input);\n\t\tport.postMessage({ type: \"result\", id: request.id, output });\n\t} catch {\n\t\tport.postMessage({ type: \"error\", id: request.id, code: \"ranking_failed\" });\n\t}\n});\nport.postMessage({ type: \"ready\" });\n"],"mappings":";;;;;;AAOA,IAAI,CAAC,GAAY,MAAU,MAAM,iCAAiC;AAClE,IAAM,IAAO,GACP,EAAE,WAAQ,oBAAiB,GAC3B,IAAO,EAAS,CAAM;AAC5B,IAAI,GAAG,EAAK,IAAI,GAAG,EAAK,UAAU,GAAc,MAAU,MAAM,8BAA8B;AAC9F,IAAM,IAAK,EAAgB,CAAM;AACjC,IAAI;CAGH,AAFA,EAAK,CAAE,GACP,EAAG,OAAO,iBAAiB,GAC3B,EAAG,QAAQ,sBAAsB,CAAC,CAAC,IAAI;AACxC,SAAS,GAAO;CAEf,MADA,EAAG,MAAM,GACH;AACP;AAEA,SAAS,EAAc,GAAwB;CAC9C,IACC,OAAO,EAAM,gBAAiB,YAC9B,CAAC,EAAM,aAAa,KAAK,KACzB,EAAM,aAAa,SAAS,OAC5B,EAAE,EAAM,qBAAqB,iBAC7B,EAAM,UAAU,WAAW,OAC3B,CAAC,EAAM,UAAU,MAAM,OAAO,QAAQ,KACtC,CAAC,EAAM,MAAM,QAAQ,KAAK,KAC1B,CAAC,EAAM,MAAM,SAAS,KAAK,KAC3B,CAAC,EAAM,qBACP,EAAM,kBAAkB,SAAS,QACjC,CAAC,OAAO,SAAS,EAAM,KAAK,KAC5B,KAAK,UAAU,EAAM,OAAO,CAAC,CAAC,SAAS,OAEvC,MAAU,MAAM,+BAA+B;AACjD;AAEA,EAAK,GAAG,YAAY,MAA2B;CAC9C,IAAI,GAAS,SAAS,SAAS;EAE9B,AADA,EAAG,MAAM,GACT,EAAK,MAAM;EACX;CACD;CACA,IACC,GAAS,SAAS,UAClB,CAAC,OAAO,cAAc,EAAQ,EAAE,KAChC,CAAC,OAAO,SAAS,EAAQ,UAAU,GAEnC,MAAU,MAAM,iCAAiC;CAElD,IAAI;EAEH,IADA,EAAc,EAAQ,KAAK,GACvB,KAAK,IAAI,KAAK,EAAQ,YAAY;GACrC,EAAK,YAAY;IAAE,MAAM;IAAS,IAAI,EAAQ;IAAI,MAAM;GAAU,CAAC;GACnE;EACD;EACA,IAAM,IAAS,EAAgB,GAAI,EAAQ,KAAK;EAChD,EAAK,YAAY;GAAE,MAAM;GAAU,IAAI,EAAQ;GAAI;EAAO,CAAC;CAC5D,QAAQ;EACP,EAAK,YAAY;GAAE,MAAM;GAAS,IAAI,EAAQ;GAAI,MAAM;EAAiB,CAAC;CAC3E;AACD,CAAC,GACD,EAAK,YAAY,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"semantic-worker-job-DjfAtX64.js","names":[],"sources":["../src/semantic/semantic-worker-job.ts"],"sourcesContent":["import { statSync } from \"node:fs\";\nimport { parentPort, workerData } from \"node:worker_threads\";\nimport { load } from \"sqlite-vec\";\nimport { connectReadOnly } from \"../db.js\";\nimport type { RankInput, WorkerRequest } from \"./semantic-worker-protocol.js\";\nimport { rankWorkerInput } from \"./semantic-worker-ranking.js\";\n\nif (!parentPort) throw new Error(\"semantic_worker_parent_required\");\nconst port = parentPort;\nconst { dbPath, fileIdentity } = workerData as { dbPath: string; fileIdentity: string };\nconst stat = statSync(dbPath);\nif (`${stat.dev}:${stat.ino}` !== fileIdentity) throw new Error(\"semantic_worker_file_changed\");\nconst db = connectReadOnly(dbPath);\ntry {\n\tload(db);\n\tdb.pragma(\"query_only = ON\");\n\tdb.prepare(\"SELECT vec_version()\").get();\n} catch (error) {\n\tdb.close();\n\tthrow error;\n}\n\nfunction validateInput(input: RankInput): void {\n\tif (\n\t\ttypeof input.generationId !== \"string\" ||\n\t\t!input.generationId.trim() ||\n\t\tinput.generationId.length > 256 ||\n\t\t!(input.embedding instanceof Float32Array) ||\n\t\tinput.embedding.length !== 384 ||\n\t\t!input.embedding.every(Number.isFinite) ||\n\t\t!input.proof.actorId.trim() ||\n\t\t!input.proof.deviceId.trim() ||\n\t\t!input.embeddingIdentity ||\n\t\tinput.embeddingIdentity.length > 2048 ||\n\t\t!Number.isFinite(input.limit) ||\n\t\tJSON.stringify(input.filters).length > 32_768\n\t)\n\t\tthrow new Error(\"invalid_semantic_worker_input\");\n}\n\nport.on(\"message\", (request: WorkerRequest) => {\n\tif (request?.type === \"close\") {\n\t\tdb.close();\n\t\tport.close();\n\t\treturn;\n\t}\n\tif (\n\t\trequest?.type !== \"rank\" ||\n\t\t!Number.isSafeInteger(request.id) ||\n\t\t!Number.isFinite(request.deadlineAt)\n\t) {\n\t\tthrow new Error(\"invalid_semantic_worker_message\");\n\t}\n\ttry {\n\t\tvalidateInput(request.input);\n\t\tif (Date.now() >= request.deadlineAt) {\n\t\t\tport.postMessage({ type: \"error\", id: request.id, code: \"expired\" });\n\t\t\treturn;\n\t\t}\n\t\tconst output = rankWorkerInput(db, request.input);\n\t\tport.postMessage({ type: \"result\", id: request.id, output });\n\t} catch {\n\t\tport.postMessage({ type: \"error\", id: request.id, code: \"ranking_failed\" });\n\t}\n});\nport.postMessage({ type: \"ready\" });\n"],"mappings":";;;;;;AAOA,IAAI,CAAC,GAAY,MAAU,MAAM,iCAAiC;AAClE,IAAM,IAAO,GACP,EAAE,WAAQ,oBAAiB,GAC3B,IAAO,EAAS,CAAM;AAC5B,IAAI,GAAG,EAAK,IAAI,GAAG,EAAK,UAAU,GAAc,MAAU,MAAM,8BAA8B;AAC9F,IAAM,IAAK,EAAgB,CAAM;AACjC,IAAI;CAGH,AAFA,EAAK,CAAE,GACP,EAAG,OAAO,iBAAiB,GAC3B,EAAG,QAAQ,sBAAsB,CAAC,CAAC,IAAI;AACxC,SAAS,GAAO;CAEf,MADA,EAAG,MAAM,GACH;AACP;AAEA,SAAS,EAAc,GAAwB;CAC9C,IACC,OAAO,EAAM,gBAAiB,YAC9B,CAAC,EAAM,aAAa,KAAK,KACzB,EAAM,aAAa,SAAS,OAC5B,EAAE,EAAM,qBAAqB,iBAC7B,EAAM,UAAU,WAAW,OAC3B,CAAC,EAAM,UAAU,MAAM,OAAO,QAAQ,KACtC,CAAC,EAAM,MAAM,QAAQ,KAAK,KAC1B,CAAC,EAAM,MAAM,SAAS,KAAK,KAC3B,CAAC,EAAM,qBACP,EAAM,kBAAkB,SAAS,QACjC,CAAC,OAAO,SAAS,EAAM,KAAK,KAC5B,KAAK,UAAU,EAAM,OAAO,CAAC,CAAC,SAAS,OAEvC,MAAU,MAAM,+BAA+B;AACjD;AAEA,EAAK,GAAG,YAAY,MAA2B;CAC9C,IAAI,GAAS,SAAS,SAAS;EAE9B,AADA,EAAG,MAAM,GACT,EAAK,MAAM;EACX;CACD;CACA,IACC,GAAS,SAAS,UAClB,CAAC,OAAO,cAAc,EAAQ,EAAE,KAChC,CAAC,OAAO,SAAS,EAAQ,UAAU,GAEnC,MAAU,MAAM,iCAAiC;CAElD,IAAI;EAEH,IADA,EAAc,EAAQ,KAAK,GACvB,KAAK,IAAI,KAAK,EAAQ,YAAY;GACrC,EAAK,YAAY;IAAE,MAAM;IAAS,IAAI,EAAQ;IAAI,MAAM;GAAU,CAAC;GACnE;EACD;EACA,IAAM,IAAS,EAAgB,GAAI,EAAQ,KAAK;EAChD,EAAK,YAAY;GAAE,MAAM;GAAU,IAAI,EAAQ;GAAI;EAAO,CAAC;CAC5D,QAAQ;EACP,EAAK,YAAY;GAAE,MAAM;GAAS,IAAI,EAAQ;GAAI,MAAM;EAAiB,CAAC;CAC3E;AACD,CAAC,GACD,EAAK,YAAY,EAAE,MAAM,QAAQ,CAAC"}
@@ -1,22 +1,22 @@
1
- import { It as e, U as t, Z as n, b as r, bt as i, st as a } from "./scope-resolution-B7FK15hx.js";
1
+ import { J as e, T as t, Tt as n, Vt as r, ft as i, nt as a } from "./scope-resolution-DXzf4k16.js";
2
2
  import { h as o } from "./workspace-identity-C7EPmSZe.js";
3
- import { b as s, d as c, f as l, m as u, p as d, v as f, x as p } from "./validated-vector-index-audit-BtUovYuM.js";
3
+ import { b as s, d as c, f as l, m as u, p as d, v as f, x as p } from "./validated-vector-index-audit-CFSIbYIn.js";
4
4
  import { createHash as m } from "node:crypto";
5
5
  import { drizzle as h } from "drizzle-orm/better-sqlite3";
6
6
  import { eq as g, or as _ } from "drizzle-orm";
7
7
  //#region src/automatic-continuity.ts
8
- function v(t, n, i) {
8
+ function v(e, n, i) {
9
9
  if (n === void 0) return;
10
10
  if (n === null) return null;
11
11
  let a = n.source.trim().toLowerCase(), o = n.hostSessionId.trim();
12
12
  if (!a || !o || o.toLowerCase() === "unknown") return null;
13
- let s = r("s.project", i ?? ""), c = t.prepare(`
13
+ let s = t("s.project", i ?? ""), c = e.prepare(`
14
14
  SELECT os.session_id FROM opencode_sessions os JOIN sessions s ON s.id = os.session_id
15
15
  WHERE os.source = ? AND os.opencode_session_id = ?
16
16
  ${s.clause ? `AND ${s.clause}` : ""}
17
17
  ORDER BY (SELECT MAX(memory_items.created_at) FROM memory_items
18
18
  WHERE memory_items.session_id = os.session_id AND memory_items.active = 1
19
- AND ${e()}) DESC, s.started_at DESC, s.id DESC LIMIT 2
19
+ AND ${r()}) DESC, s.started_at DESC, s.id DESC LIMIT 2
20
20
  `).all(a, o, ...s.params);
21
21
  return !s.clause && c.length > 1 ? null : c[0]?.session_id ?? null;
22
22
  }
@@ -24,7 +24,7 @@ function v(t, n, i) {
24
24
  //#region src/legacy-pairing-assignment-state.ts
25
25
  var y = "legacy_pairing_assignment_conversion";
26
26
  function b(e) {
27
- return i(e, "maintenance_jobs") ? e.prepare("SELECT 1 FROM maintenance_jobs WHERE kind = ? AND status = 'completed'").get(y) !== void 0 : !1;
27
+ return n(e, "maintenance_jobs") ? e.prepare("SELECT 1 FROM maintenance_jobs WHERE kind = ? AND status = 'completed'").get(y) !== void 0 : !1;
28
28
  }
29
29
  //#endregion
30
30
  //#region src/same-actor-peers.ts
@@ -35,51 +35,51 @@ var x = /* @__PURE__ */ new Set([
35
35
  "exact_project_invite",
36
36
  "review_resolution"
37
37
  ]);
38
- function S(e, r) {
39
- let o = w(e, r);
38
+ function S(t, r) {
39
+ let o = w(t, r);
40
40
  if (!o) return [];
41
- if (!i(e, "sync_peers")) return [...o.deviceIds].sort();
41
+ if (!n(t, "sync_peers")) return [...o.deviceIds].sort();
42
42
  let s = [
43
43
  "peer_device_id",
44
44
  "public_key",
45
45
  "pinned_fingerprint"
46
- ].every((t) => a(e, "sync_peers", t));
47
- if (o.boundDeviceIds.size > 0 && !s || (o.boundDeviceIds.size > 0 && D(e, o), b(e))) return [...o.deviceIds].sort();
48
- let c = h(e, { schema: t }).select({ peer_device_id: n.peer_device_id }).from(n).where(_(g(n.claimed_local_actor, 1), g(n.actor_id, r))).all();
46
+ ].every((e) => i(t, "sync_peers", e));
47
+ if (o.boundDeviceIds.size > 0 && !s || (o.boundDeviceIds.size > 0 && D(t, o), b(t))) return [...o.deviceIds].sort();
48
+ let c = h(t, { schema: e }).select({ peer_device_id: a.peer_device_id }).from(a).where(_(g(a.claimed_local_actor, 1), g(a.actor_id, r))).all();
49
49
  for (let e of c) {
50
50
  let t = String(e.peer_device_id ?? "").trim();
51
51
  t && !o.boundDeviceIds.has(t) && o.deviceIds.add(t);
52
52
  }
53
53
  return [...o.deviceIds].sort();
54
54
  }
55
- function C(e, t, n) {
56
- if (n === 0 || !i(e, "actors") || ![
55
+ function C(e, t, r) {
56
+ if (r === 0 || !n(e, "actors") || ![
57
57
  "actor_id",
58
58
  "status",
59
59
  "merged_into_actor_id"
60
- ].every((t) => a(e, "actors", t))) return !1;
61
- let r = e.prepare("SELECT status, merged_into_actor_id FROM actors WHERE actor_id = ?").get(t);
62
- return r?.status === "active" && !r.merged_into_actor_id;
60
+ ].every((t) => i(e, "actors", t))) return !1;
61
+ let a = e.prepare("SELECT status, merged_into_actor_id FROM actors WHERE actor_id = ?").get(t);
62
+ return a?.status === "active" && !a.merged_into_actor_id;
63
63
  }
64
64
  function w(e, t) {
65
- let n = {
65
+ let r = {
66
66
  deviceIds: /* @__PURE__ */ new Set(),
67
67
  boundDeviceIds: /* @__PURE__ */ new Set(),
68
68
  locallyBoundDeviceIds: /* @__PURE__ */ new Set()
69
- }, r = i(e, "identity_devices") && [
69
+ }, a = n(e, "identity_devices") && [
70
70
  "device_id",
71
71
  "identity_id",
72
72
  "status",
73
73
  "provenance"
74
- ].every((t) => a(e, "identity_devices", t));
75
- if (i(e, "identity_devices") && !r) return null;
76
- if (!r) return n;
74
+ ].every((t) => i(e, "identity_devices", t));
75
+ if (n(e, "identity_devices") && !a) return null;
76
+ if (!a) return r;
77
77
  let o = e.prepare("SELECT device_id, identity_id, status, provenance FROM identity_devices").all(), s = C(e, t, o.length);
78
78
  for (let e of o) {
79
- let r = String(e.device_id ?? "").trim();
80
- !r || e.status === "removed" || (n.boundDeviceIds.add(r), s && String(e.identity_id ?? "").trim() === t && e.status === "active" && x.has(e.provenance) && (n.deviceIds.add(r), n.locallyBoundDeviceIds.add(r)));
79
+ let n = String(e.device_id ?? "").trim();
80
+ !n || e.status === "removed" || (r.boundDeviceIds.add(n), s && String(e.identity_id ?? "").trim() === t && e.status === "active" && x.has(e.provenance) && (r.deviceIds.add(n), r.locallyBoundDeviceIds.add(n)));
81
81
  }
82
- return n;
82
+ return r;
83
83
  }
84
84
  function T(e) {
85
85
  let t = String(e.public_key ?? "").trim(), n = String(e.pinned_fingerprint ?? "").trim();
@@ -182,4 +182,4 @@ function M(e, t) {
182
182
  //#endregion
183
183
  export { y as a, S as i, M as n, b as o, j as r, v as s, A as t };
184
184
 
185
- //# sourceMappingURL=semantic-worker-ranking-WaUCapnY.js.map
185
+ //# sourceMappingURL=semantic-worker-ranking-CZCemeb4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-worker-ranking-WaUCapnY.js","names":[],"sources":["../src/automatic-continuity.ts","../src/legacy-pairing-assignment-state.ts","../src/same-actor-peers.ts","../src/semantic/validated-vector-index.ts","../src/semantic/semantic-worker-ranking.ts"],"sourcesContent":["import type { Database } from \"./db.js\";\nimport { projectColumnClause } from \"./project.js\";\nimport { summaryLikeSqlPredicate } from \"./summary-memory.js\";\nimport type { AutomaticContext } from \"./types.js\";\n\n/** Select continuity within the current project when a host session has moved. */\nexport function automaticSummarySession(\n\tdb: Database,\n\tcontext: AutomaticContext | null | undefined,\n\tproject?: string | null,\n): number | null | undefined {\n\tif (context === undefined) return undefined;\n\tif (context === null) return null;\n\tconst source = context.source.trim().toLowerCase();\n\tconst hostId = context.hostSessionId.trim();\n\tif (!source || !hostId || hostId.toLowerCase() === \"unknown\") return null;\n\tconst filter = projectColumnClause(\"s.project\", project ?? \"\");\n\tconst rows = db\n\t\t.prepare(`\n\t\tSELECT os.session_id FROM opencode_sessions os JOIN sessions s ON s.id = os.session_id\n\t\tWHERE os.source = ? AND os.opencode_session_id = ?\n\t\t${filter.clause ? `AND ${filter.clause}` : \"\"}\n\t\tORDER BY (SELECT MAX(memory_items.created_at) FROM memory_items\n\t\t\tWHERE memory_items.session_id = os.session_id AND memory_items.active = 1\n\t\t\tAND ${summaryLikeSqlPredicate()}) DESC, s.started_at DESC, s.id DESC LIMIT 2\n\t`)\n\t\t.all(source, hostId, ...filter.params) as Array<{ session_id: number }>;\n\tif (!filter.clause && rows.length > 1) return null;\n\treturn rows[0]?.session_id ?? null;\n}\n","import { type Database, tableExists } from \"./db.js\";\n\n/** Maintenance job whose completion marks the one-time conversion as done. */\nexport const LEGACY_PAIRING_ASSIGNMENT_JOB = \"legacy_pairing_assignment_conversion\";\n\n/**\n * Whether the person assigned on pairings (`sync_peers.actor_id` and\n * `claimed_local_actor`) has been converted into Identity bindings. Before that\n * the older columns still decide which devices are this person's own. Afterward\n * only bindings do. Read-only, so it is safe on every query path.\n */\nexport function legacyPairingAssignmentsConverted(db: Database): boolean {\n\tif (!tableExists(db, \"maintenance_jobs\")) return false;\n\treturn (\n\t\tdb\n\t\t\t.prepare(\"SELECT 1 FROM maintenance_jobs WHERE kind = ? AND status = 'completed'\")\n\t\t\t.get(LEGACY_PAIRING_ASSIGNMENT_JOB) !== undefined\n\t);\n}\n","import { eq, or } from \"drizzle-orm\";\nimport { drizzle } from \"drizzle-orm/better-sqlite3\";\nimport { columnExists, type Database, tableExists } from \"./db.js\";\nimport { legacyPairingAssignmentsConverted } from \"./legacy-pairing-assignment-state.js\";\nimport * as schema from \"./schema.js\";\nimport { fingerprintPublicKey } from \"./sync-fingerprint.js\";\n\nconst SAME_PERSON_BINDING_PROVENANCE = new Set([\n\t\"user_confirmed_identity_setup\",\n\t// A person once marked the pairing as their own device; the conversion kept that decision.\n\t\"legacy_pairing_assignment\",\n\t\"recipient_invite\",\n\t\"exact_project_invite\",\n\t\"review_resolution\",\n]);\n\n/**\n * Shared read-only resolver. Bindings decide which devices are this person's own.\n * The person assigned on a pairing still counts for a device with no binding until\n * the one-time conversion of those assignments has run on this database.\n */\nexport function resolveSameActorPeerIds(db: Database, actorId: string): string[] {\n\tconst sets = resolveBindings(db, actorId);\n\tif (!sets) return [];\n\tif (!tableExists(db, \"sync_peers\")) return [...sets.deviceIds].sort();\n\tconst hasAliasEvidence = [\"peer_device_id\", \"public_key\", \"pinned_fingerprint\"].every((column) =>\n\t\tcolumnExists(db, \"sync_peers\", column),\n\t);\n\tif (sets.boundDeviceIds.size > 0 && !hasAliasEvidence) return [...sets.deviceIds].sort();\n\tif (sets.boundDeviceIds.size > 0) resolveAliases(db, sets);\n\tif (legacyPairingAssignmentsConverted(db)) return [...sets.deviceIds].sort();\n\tconst legacyRows = drizzle(db, { schema })\n\t\t.select({ peer_device_id: schema.syncPeers.peer_device_id })\n\t\t.from(schema.syncPeers)\n\t\t.where(or(eq(schema.syncPeers.claimed_local_actor, 1), eq(schema.syncPeers.actor_id, actorId)))\n\t\t.all();\n\tfor (const row of legacyRows) {\n\t\tconst deviceId = String(row.peer_device_id ?? \"\").trim();\n\t\tif (deviceId && !sets.boundDeviceIds.has(deviceId)) sets.deviceIds.add(deviceId);\n\t}\n\treturn [...sets.deviceIds].sort();\n}\n\ntype BindingSets = {\n\tdeviceIds: Set<string>;\n\tboundDeviceIds: Set<string>;\n\tlocallyBoundDeviceIds: Set<string>;\n};\n\nfunction activeActor(db: Database, actorId: string, bindingCount: number): boolean {\n\tif (bindingCount === 0 || !tableExists(db, \"actors\")) return false;\n\tif (\n\t\t![\"actor_id\", \"status\", \"merged_into_actor_id\"].every((column) =>\n\t\t\tcolumnExists(db, \"actors\", column),\n\t\t)\n\t)\n\t\treturn false;\n\tconst actor = db\n\t\t.prepare(\"SELECT status, merged_into_actor_id FROM actors WHERE actor_id = ?\")\n\t\t.get(actorId) as { status: string; merged_into_actor_id: string | null } | undefined;\n\treturn actor?.status === \"active\" && !actor.merged_into_actor_id;\n}\n\nfunction resolveBindings(db: Database, actorId: string): BindingSets | null {\n\tconst sets: BindingSets = {\n\t\tdeviceIds: new Set(),\n\t\tboundDeviceIds: new Set(),\n\t\tlocallyBoundDeviceIds: new Set(),\n\t};\n\tconst hasIdentityBindings =\n\t\ttableExists(db, \"identity_devices\") &&\n\t\t[\"device_id\", \"identity_id\", \"status\", \"provenance\"].every((column) =>\n\t\t\tcolumnExists(db, \"identity_devices\", column),\n\t\t);\n\tif (tableExists(db, \"identity_devices\") && !hasIdentityBindings) return null;\n\tif (!hasIdentityBindings) return sets;\n\tconst bindings = db\n\t\t.prepare(\"SELECT device_id, identity_id, status, provenance FROM identity_devices\")\n\t\t.all() as Array<{\n\t\tdevice_id: string;\n\t\tidentity_id: string;\n\t\tstatus: string;\n\t\tprovenance: string;\n\t}>;\n\tconst localActorIsActive = activeActor(db, actorId, bindings.length);\n\tfor (const binding of bindings) {\n\t\tconst deviceId = String(binding.device_id ?? \"\").trim();\n\t\t// A binding that device removal ended counts as no binding at all.\n\t\tif (!deviceId || binding.status === \"removed\") continue;\n\t\tsets.boundDeviceIds.add(deviceId);\n\t\tif (\n\t\t\tlocalActorIsActive &&\n\t\t\tString(binding.identity_id ?? \"\").trim() === actorId &&\n\t\t\tbinding.status === \"active\" &&\n\t\t\tSAME_PERSON_BINDING_PROVENANCE.has(binding.provenance)\n\t\t) {\n\t\t\tsets.deviceIds.add(deviceId);\n\t\t\tsets.locallyBoundDeviceIds.add(deviceId);\n\t\t}\n\t}\n\treturn sets;\n}\n\ntype PeerEvidence = {\n\tpeer_device_id: string;\n\tpublic_key: string | null;\n\tpinned_fingerprint: string | null;\n};\n\nfunction validatedFingerprint(row: PeerEvidence): string | null {\n\tconst publicKey = String(row.public_key ?? \"\").trim();\n\tconst pinned = String(row.pinned_fingerprint ?? \"\").trim();\n\tif (!publicKey) return pinned || null;\n\tconst derived = fingerprintPublicKey(publicKey);\n\treturn pinned && pinned !== derived ? null : pinned || derived;\n}\n\nfunction provenFingerprint(row: PeerEvidence): string | null {\n\treturn String(row.public_key ?? \"\").trim() ? validatedFingerprint(row) : null;\n}\n\nfunction resolveAliases(db: Database, sets: BindingSets): void {\n\tconst { deviceIds, boundDeviceIds } = sets;\n\tconst peerEvidence = db\n\t\t.prepare(\"SELECT peer_device_id, public_key, pinned_fingerprint FROM sync_peers\")\n\t\t.all() as PeerEvidence[];\n\tconst { boundFingerprints, locallyBoundFingerprints } = resolveBoundFingerprints(\n\t\tpeerEvidence,\n\t\tsets,\n\t);\n\tfor (const row of peerEvidence) {\n\t\tconst deviceId = String(row.peer_device_id ?? \"\").trim();\n\t\tconst fingerprint = validatedFingerprint(row);\n\t\tif (!deviceId || !fingerprint || !boundFingerprints.has(fingerprint)) continue;\n\t\tconst hasAuthoritativeBinding = boundDeviceIds.has(deviceId);\n\t\tboundDeviceIds.add(deviceId);\n\t\tif (\n\t\t\t!hasAuthoritativeBinding &&\n\t\t\tlocallyBoundFingerprints.has(fingerprint) &&\n\t\t\tprovenFingerprint(row)\n\t\t) {\n\t\t\tdeviceIds.add(deviceId);\n\t\t}\n\t}\n}\n\nfunction resolveBoundFingerprints(peerEvidence: PeerEvidence[], sets: BindingSets) {\n\tconst { boundDeviceIds, locallyBoundDeviceIds } = sets;\n\tconst boundFingerprints = new Set<string>();\n\tconst locallyBoundFingerprints = new Set<string>();\n\tconst conflictingBoundFingerprints = new Set<string>();\n\tfor (const row of peerEvidence) {\n\t\tconst deviceId = String(row.peer_device_id ?? \"\").trim();\n\t\tconst fingerprint = validatedFingerprint(row);\n\t\tif (!deviceId || !fingerprint || !boundDeviceIds.has(deviceId)) continue;\n\t\tboundFingerprints.add(fingerprint);\n\t\tif (locallyBoundDeviceIds.has(deviceId)) {\n\t\t\tif (provenFingerprint(row)) locallyBoundFingerprints.add(fingerprint);\n\t\t} else {\n\t\t\tconflictingBoundFingerprints.add(fingerprint);\n\t\t}\n\t}\n\tfor (const fingerprint of conflictingBoundFingerprints)\n\t\tlocallyBoundFingerprints.delete(fingerprint);\n\treturn { boundFingerprints, locallyBoundFingerprints };\n}\n","/** Persisted vector writer contract and readiness-gated semantic ranking. */\nimport type { Database } from \"../db.js\";\nimport {\n\ttype RankingRequest,\n\ttype RankingResult,\n\trankPrevalidatedSnapshot,\n\tresolveCatalogModels,\n} from \"./semantic-ranking.js\";\nimport {\n\ttype CandidateVersion,\n\tisSearchableVectorCatalog,\n\treadCandidateVersions,\n\treadCatalog,\n\treadSearchableModelLabels,\n\tsnapshot,\n} from \"./validated-vector-index-state.js\";\n\nexport { auditBatch, startAudit } from \"./validated-vector-index-audit.js\";\nexport {\n\tdeleteValidatedVectors,\n\ttype ValidatedBatch,\n\twriteValidatedBatch,\n} from \"./validated-vector-index-mutations.js\";\nexport {\n\ttype AuditProgress,\n\ttype CandidateVersion,\n\tinitializeValidatedIndex,\n\tinvalidateValidatedIndex,\n\tisSearchableVectorCatalog,\n\treadCandidateVersions,\n\treadCatalog,\n\treadSearchableModelLabels,\n\ttype VectorCatalog,\n} from \"./validated-vector-index-state.js\";\n\nexport interface IndexedRanking extends RankingResult {\n\tgenerationId: string;\n\trevision: number;\n\tmodels: string[];\n\tcandidateVersions: CandidateVersion[];\n}\n\n/** Reuses a caller-owned read transaction; no DDL, audit, BLOB hashes or model-catalog vec0 scan. */\nexport function rankValidatedIndex(db: Database, request: RankingRequest): IndexedRanking | null {\n\treturn snapshot(db, () => {\n\t\tconst catalog = readCatalog(db);\n\t\tif (!isSearchableVectorCatalog(db, catalog)) return null;\n\t\tconst models = resolveCatalogModels(\n\t\t\trequest.query.model,\n\t\t\treadSearchableModelLabels(db, catalog),\n\t\t\tcatalog.migration,\n\t\t);\n\t\tif (!models.length) return null;\n\t\tconst ranked = rankPrevalidatedSnapshot(db, request, {\n\t\t\tmodels,\n\t\t\tacceptedIds: null,\n\t\t\tindexedRows: true,\n\t\t});\n\t\tconst candidateVersions = readCandidateVersions(db, {\n\t\t\tmemoryIds: ranked.results.map((row) => row.id),\n\t\t\tmodels,\n\t\t});\n\t\treturn {\n\t\t\t...ranked,\n\t\t\tgenerationId: catalog.generationId,\n\t\t\trevision: catalog.revision,\n\t\t\tmodels,\n\t\t\tcandidateVersions,\n\t\t};\n\t});\n}\n","import { createHash } from \"node:crypto\";\nimport { automaticSummarySession } from \"../automatic-continuity.js\";\nimport type { Database } from \"../db.js\";\nimport { resolveSameActorPeerIds } from \"../same-actor-peers.js\";\nimport type { AutomaticContext } from \"../types.js\";\nimport type { RankInput, RankOutput } from \"./semantic-worker-protocol.js\";\nimport {\n\tisSearchableVectorCatalog,\n\trankValidatedIndex,\n\treadCatalog,\n} from \"./validated-vector-index.js\";\n\nexport function contentIdentity(row: Record<string, unknown>): string {\n\treturn createHash(\"sha256\").update(JSON.stringify(row)).digest(\"hex\");\n}\n\nexport function summarySessionId(\n\tdb: Database,\n\tcontext: AutomaticContext | null | undefined,\n\tproject?: string | null,\n): number | null | undefined {\n\treturn automaticSummarySession(db, context, project);\n}\n\n/** Authorization, continuity, model selection, ranking and identities share one short read snapshot. */\nexport function rankWorkerInput(db: Database, input: RankInput): RankOutput | null {\n\treturn db.transaction(() => {\n\t\tconst catalog = readCatalog(db);\n\t\tif (!isSearchableVectorCatalog(db, catalog) || catalog.generationId !== input.generationId)\n\t\t\treturn null;\n\t\tconst claimedDeviceIds = resolveSameActorPeerIds(db, input.proof.actorId);\n\t\tconst ranked = rankValidatedIndex(db, {\n\t\t\tquery: { model: input.embeddingIdentity, vectors: [input.embedding] },\n\t\t\tlimit: input.limit,\n\t\t\tfilters: input.filters,\n\t\t\tcontext: {\n\t\t\t\t...input.proof,\n\t\t\t\tclaimedDeviceIds,\n\t\t\t\tlegacyActorIds: claimedDeviceIds.map((id) => `legacy-sync:${id}`),\n\t\t\t\tscopeVisibilityDb: db,\n\t\t\t},\n\t\t\tsummarySessionId: summarySessionId(db, input.automaticContext, input.filters?.project),\n\t\t});\n\t\tif (!ranked || ranked.generationId !== input.generationId) return null;\n\t\treturn {\n\t\t\tgenerationId: ranked.generationId,\n\t\t\trevision: ranked.revision,\n\t\t\tmodels: ranked.models,\n\t\t\tcandidateVersions: ranked.candidateVersions,\n\t\t\tcandidates: ranked.results.map((row) => {\n\t\t\t\tconst raw = db.prepare(\"SELECT * FROM memory_items WHERE id = ?\").get(row.id) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\treturn {\n\t\t\t\t\tid: row.id,\n\t\t\t\t\tdistance: row.distance,\n\t\t\t\t\tcontentIdentity: contentIdentity(raw),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t})();\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,EACf,GACA,GACA,GAC4B;CAC5B,IAAI,MAAY,KAAA,GAAW;CAC3B,IAAI,MAAY,MAAM,OAAO;CAC7B,IAAM,IAAS,EAAQ,OAAO,KAAK,CAAC,CAAC,YAAY,GAC3C,IAAS,EAAQ,cAAc,KAAK;CAC1C,IAAI,CAAC,KAAU,CAAC,KAAU,EAAO,YAAY,MAAM,WAAW,OAAO;CACrE,IAAM,IAAS,EAAoB,aAAa,KAAW,EAAE,GACvD,IAAO,EAC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AAE,OAAO,EAAM;IAAmB,SAAS,CAAC,EAAM,SAAS;GAAE;GACpE,OAAO,EAAM;GACb,SAAS,EAAM;GACf,SAAS;IACR,GAAG,EAAM;IACT;IACA,gBAAgB,EAAiB,KAAK,MAAO,eAAe,GAAI;IAChE,mBAAmB;GACpB;GACA,kBAAkB,EAAiB,GAAI,EAAM,kBAAkB,EAAM,SAAS,OAAO;EACtF,CAAC;EAED,OADI,CAAC,KAAU,EAAO,iBAAiB,EAAM,eAAqB,OAC3D;GACN,cAAc,EAAO;GACrB,UAAU,EAAO;GACjB,QAAQ,EAAO;GACf,mBAAmB,EAAO;GAC1B,YAAY,EAAO,QAAQ,KAAK,MAAQ;IACvC,IAAM,IAAM,EAAG,QAAQ,yCAAyC,CAAC,CAAC,IAAI,EAAI,EAAE;IAI5E,OAAO;KACN,IAAI,EAAI;KACR,UAAU,EAAI;KACd,iBAAiB,EAAgB,CAAG;IACrC;GACD,CAAC;EACF;CACD,CAAC,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"semantic-worker-ranking-CZCemeb4.js","names":[],"sources":["../src/automatic-continuity.ts","../src/legacy-pairing-assignment-state.ts","../src/same-actor-peers.ts","../src/semantic/validated-vector-index.ts","../src/semantic/semantic-worker-ranking.ts"],"sourcesContent":["import type { Database } from \"./db.js\";\nimport { projectColumnClause } from \"./project.js\";\nimport { summaryLikeSqlPredicate } from \"./summary-memory.js\";\nimport type { AutomaticContext } from \"./types.js\";\n\n/** Select continuity within the current project when a host session has moved. */\nexport function automaticSummarySession(\n\tdb: Database,\n\tcontext: AutomaticContext | null | undefined,\n\tproject?: string | null,\n): number | null | undefined {\n\tif (context === undefined) return undefined;\n\tif (context === null) return null;\n\tconst source = context.source.trim().toLowerCase();\n\tconst hostId = context.hostSessionId.trim();\n\tif (!source || !hostId || hostId.toLowerCase() === \"unknown\") return null;\n\tconst filter = projectColumnClause(\"s.project\", project ?? \"\");\n\tconst rows = db\n\t\t.prepare(`\n\t\tSELECT os.session_id FROM opencode_sessions os JOIN sessions s ON s.id = os.session_id\n\t\tWHERE os.source = ? AND os.opencode_session_id = ?\n\t\t${filter.clause ? `AND ${filter.clause}` : \"\"}\n\t\tORDER BY (SELECT MAX(memory_items.created_at) FROM memory_items\n\t\t\tWHERE memory_items.session_id = os.session_id AND memory_items.active = 1\n\t\t\tAND ${summaryLikeSqlPredicate()}) DESC, s.started_at DESC, s.id DESC LIMIT 2\n\t`)\n\t\t.all(source, hostId, ...filter.params) as Array<{ session_id: number }>;\n\tif (!filter.clause && rows.length > 1) return null;\n\treturn rows[0]?.session_id ?? null;\n}\n","import { type Database, tableExists } from \"./db.js\";\n\n/** Maintenance job whose completion marks the one-time conversion as done. */\nexport const LEGACY_PAIRING_ASSIGNMENT_JOB = \"legacy_pairing_assignment_conversion\";\n\n/**\n * Whether the person assigned on pairings (`sync_peers.actor_id` and\n * `claimed_local_actor`) has been converted into Identity bindings. Before that\n * the older columns still decide which devices are this person's own. Afterward\n * only bindings do. Read-only, so it is safe on every query path.\n */\nexport function legacyPairingAssignmentsConverted(db: Database): boolean {\n\tif (!tableExists(db, \"maintenance_jobs\")) return false;\n\treturn (\n\t\tdb\n\t\t\t.prepare(\"SELECT 1 FROM maintenance_jobs WHERE kind = ? AND status = 'completed'\")\n\t\t\t.get(LEGACY_PAIRING_ASSIGNMENT_JOB) !== undefined\n\t);\n}\n","import { eq, or } from \"drizzle-orm\";\nimport { drizzle } from \"drizzle-orm/better-sqlite3\";\nimport { columnExists, type Database, tableExists } from \"./db.js\";\nimport { legacyPairingAssignmentsConverted } from \"./legacy-pairing-assignment-state.js\";\nimport * as schema from \"./schema.js\";\nimport { fingerprintPublicKey } from \"./sync-fingerprint.js\";\n\nconst SAME_PERSON_BINDING_PROVENANCE = new Set([\n\t\"user_confirmed_identity_setup\",\n\t// A person once marked the pairing as their own device; the conversion kept that decision.\n\t\"legacy_pairing_assignment\",\n\t\"recipient_invite\",\n\t\"exact_project_invite\",\n\t\"review_resolution\",\n]);\n\n/**\n * Shared read-only resolver. Bindings decide which devices are this person's own.\n * The person assigned on a pairing still counts for a device with no binding until\n * the one-time conversion of those assignments has run on this database.\n */\nexport function resolveSameActorPeerIds(db: Database, actorId: string): string[] {\n\tconst sets = resolveBindings(db, actorId);\n\tif (!sets) return [];\n\tif (!tableExists(db, \"sync_peers\")) return [...sets.deviceIds].sort();\n\tconst hasAliasEvidence = [\"peer_device_id\", \"public_key\", \"pinned_fingerprint\"].every((column) =>\n\t\tcolumnExists(db, \"sync_peers\", column),\n\t);\n\tif (sets.boundDeviceIds.size > 0 && !hasAliasEvidence) return [...sets.deviceIds].sort();\n\tif (sets.boundDeviceIds.size > 0) resolveAliases(db, sets);\n\tif (legacyPairingAssignmentsConverted(db)) return [...sets.deviceIds].sort();\n\tconst legacyRows = drizzle(db, { schema })\n\t\t.select({ peer_device_id: schema.syncPeers.peer_device_id })\n\t\t.from(schema.syncPeers)\n\t\t.where(or(eq(schema.syncPeers.claimed_local_actor, 1), eq(schema.syncPeers.actor_id, actorId)))\n\t\t.all();\n\tfor (const row of legacyRows) {\n\t\tconst deviceId = String(row.peer_device_id ?? \"\").trim();\n\t\tif (deviceId && !sets.boundDeviceIds.has(deviceId)) sets.deviceIds.add(deviceId);\n\t}\n\treturn [...sets.deviceIds].sort();\n}\n\ntype BindingSets = {\n\tdeviceIds: Set<string>;\n\tboundDeviceIds: Set<string>;\n\tlocallyBoundDeviceIds: Set<string>;\n};\n\nfunction activeActor(db: Database, actorId: string, bindingCount: number): boolean {\n\tif (bindingCount === 0 || !tableExists(db, \"actors\")) return false;\n\tif (\n\t\t![\"actor_id\", \"status\", \"merged_into_actor_id\"].every((column) =>\n\t\t\tcolumnExists(db, \"actors\", column),\n\t\t)\n\t)\n\t\treturn false;\n\tconst actor = db\n\t\t.prepare(\"SELECT status, merged_into_actor_id FROM actors WHERE actor_id = ?\")\n\t\t.get(actorId) as { status: string; merged_into_actor_id: string | null } | undefined;\n\treturn actor?.status === \"active\" && !actor.merged_into_actor_id;\n}\n\nfunction resolveBindings(db: Database, actorId: string): BindingSets | null {\n\tconst sets: BindingSets = {\n\t\tdeviceIds: new Set(),\n\t\tboundDeviceIds: new Set(),\n\t\tlocallyBoundDeviceIds: new Set(),\n\t};\n\tconst hasIdentityBindings =\n\t\ttableExists(db, \"identity_devices\") &&\n\t\t[\"device_id\", \"identity_id\", \"status\", \"provenance\"].every((column) =>\n\t\t\tcolumnExists(db, \"identity_devices\", column),\n\t\t);\n\tif (tableExists(db, \"identity_devices\") && !hasIdentityBindings) return null;\n\tif (!hasIdentityBindings) return sets;\n\tconst bindings = db\n\t\t.prepare(\"SELECT device_id, identity_id, status, provenance FROM identity_devices\")\n\t\t.all() as Array<{\n\t\tdevice_id: string;\n\t\tidentity_id: string;\n\t\tstatus: string;\n\t\tprovenance: string;\n\t}>;\n\tconst localActorIsActive = activeActor(db, actorId, bindings.length);\n\tfor (const binding of bindings) {\n\t\tconst deviceId = String(binding.device_id ?? \"\").trim();\n\t\t// A binding that device removal ended counts as no binding at all.\n\t\tif (!deviceId || binding.status === \"removed\") continue;\n\t\tsets.boundDeviceIds.add(deviceId);\n\t\tif (\n\t\t\tlocalActorIsActive &&\n\t\t\tString(binding.identity_id ?? \"\").trim() === actorId &&\n\t\t\tbinding.status === \"active\" &&\n\t\t\tSAME_PERSON_BINDING_PROVENANCE.has(binding.provenance)\n\t\t) {\n\t\t\tsets.deviceIds.add(deviceId);\n\t\t\tsets.locallyBoundDeviceIds.add(deviceId);\n\t\t}\n\t}\n\treturn sets;\n}\n\ntype PeerEvidence = {\n\tpeer_device_id: string;\n\tpublic_key: string | null;\n\tpinned_fingerprint: string | null;\n};\n\nfunction validatedFingerprint(row: PeerEvidence): string | null {\n\tconst publicKey = String(row.public_key ?? \"\").trim();\n\tconst pinned = String(row.pinned_fingerprint ?? \"\").trim();\n\tif (!publicKey) return pinned || null;\n\tconst derived = fingerprintPublicKey(publicKey);\n\treturn pinned && pinned !== derived ? null : pinned || derived;\n}\n\nfunction provenFingerprint(row: PeerEvidence): string | null {\n\treturn String(row.public_key ?? \"\").trim() ? validatedFingerprint(row) : null;\n}\n\nfunction resolveAliases(db: Database, sets: BindingSets): void {\n\tconst { deviceIds, boundDeviceIds } = sets;\n\tconst peerEvidence = db\n\t\t.prepare(\"SELECT peer_device_id, public_key, pinned_fingerprint FROM sync_peers\")\n\t\t.all() as PeerEvidence[];\n\tconst { boundFingerprints, locallyBoundFingerprints } = resolveBoundFingerprints(\n\t\tpeerEvidence,\n\t\tsets,\n\t);\n\tfor (const row of peerEvidence) {\n\t\tconst deviceId = String(row.peer_device_id ?? \"\").trim();\n\t\tconst fingerprint = validatedFingerprint(row);\n\t\tif (!deviceId || !fingerprint || !boundFingerprints.has(fingerprint)) continue;\n\t\tconst hasAuthoritativeBinding = boundDeviceIds.has(deviceId);\n\t\tboundDeviceIds.add(deviceId);\n\t\tif (\n\t\t\t!hasAuthoritativeBinding &&\n\t\t\tlocallyBoundFingerprints.has(fingerprint) &&\n\t\t\tprovenFingerprint(row)\n\t\t) {\n\t\t\tdeviceIds.add(deviceId);\n\t\t}\n\t}\n}\n\nfunction resolveBoundFingerprints(peerEvidence: PeerEvidence[], sets: BindingSets) {\n\tconst { boundDeviceIds, locallyBoundDeviceIds } = sets;\n\tconst boundFingerprints = new Set<string>();\n\tconst locallyBoundFingerprints = new Set<string>();\n\tconst conflictingBoundFingerprints = new Set<string>();\n\tfor (const row of peerEvidence) {\n\t\tconst deviceId = String(row.peer_device_id ?? \"\").trim();\n\t\tconst fingerprint = validatedFingerprint(row);\n\t\tif (!deviceId || !fingerprint || !boundDeviceIds.has(deviceId)) continue;\n\t\tboundFingerprints.add(fingerprint);\n\t\tif (locallyBoundDeviceIds.has(deviceId)) {\n\t\t\tif (provenFingerprint(row)) locallyBoundFingerprints.add(fingerprint);\n\t\t} else {\n\t\t\tconflictingBoundFingerprints.add(fingerprint);\n\t\t}\n\t}\n\tfor (const fingerprint of conflictingBoundFingerprints)\n\t\tlocallyBoundFingerprints.delete(fingerprint);\n\treturn { boundFingerprints, locallyBoundFingerprints };\n}\n","/** Persisted vector writer contract and readiness-gated semantic ranking. */\nimport type { Database } from \"../db.js\";\nimport {\n\ttype RankingRequest,\n\ttype RankingResult,\n\trankPrevalidatedSnapshot,\n\tresolveCatalogModels,\n} from \"./semantic-ranking.js\";\nimport {\n\ttype CandidateVersion,\n\tisSearchableVectorCatalog,\n\treadCandidateVersions,\n\treadCatalog,\n\treadSearchableModelLabels,\n\tsnapshot,\n} from \"./validated-vector-index-state.js\";\n\nexport { auditBatch, startAudit } from \"./validated-vector-index-audit.js\";\nexport {\n\tdeleteValidatedVectors,\n\ttype ValidatedBatch,\n\twriteValidatedBatch,\n} from \"./validated-vector-index-mutations.js\";\nexport {\n\ttype AuditProgress,\n\ttype CandidateVersion,\n\tinitializeValidatedIndex,\n\tinvalidateValidatedIndex,\n\tisSearchableVectorCatalog,\n\treadCandidateVersions,\n\treadCatalog,\n\treadSearchableModelLabels,\n\ttype VectorCatalog,\n} from \"./validated-vector-index-state.js\";\n\nexport interface IndexedRanking extends RankingResult {\n\tgenerationId: string;\n\trevision: number;\n\tmodels: string[];\n\tcandidateVersions: CandidateVersion[];\n}\n\n/** Reuses a caller-owned read transaction; no DDL, audit, BLOB hashes or model-catalog vec0 scan. */\nexport function rankValidatedIndex(db: Database, request: RankingRequest): IndexedRanking | null {\n\treturn snapshot(db, () => {\n\t\tconst catalog = readCatalog(db);\n\t\tif (!isSearchableVectorCatalog(db, catalog)) return null;\n\t\tconst models = resolveCatalogModels(\n\t\t\trequest.query.model,\n\t\t\treadSearchableModelLabels(db, catalog),\n\t\t\tcatalog.migration,\n\t\t);\n\t\tif (!models.length) return null;\n\t\tconst ranked = rankPrevalidatedSnapshot(db, request, {\n\t\t\tmodels,\n\t\t\tacceptedIds: null,\n\t\t\tindexedRows: true,\n\t\t});\n\t\tconst candidateVersions = readCandidateVersions(db, {\n\t\t\tmemoryIds: ranked.results.map((row) => row.id),\n\t\t\tmodels,\n\t\t});\n\t\treturn {\n\t\t\t...ranked,\n\t\t\tgenerationId: catalog.generationId,\n\t\t\trevision: catalog.revision,\n\t\t\tmodels,\n\t\t\tcandidateVersions,\n\t\t};\n\t});\n}\n","import { createHash } from \"node:crypto\";\nimport { automaticSummarySession } from \"../automatic-continuity.js\";\nimport type { Database } from \"../db.js\";\nimport { resolveSameActorPeerIds } from \"../same-actor-peers.js\";\nimport type { AutomaticContext } from \"../types.js\";\nimport type { RankInput, RankOutput } from \"./semantic-worker-protocol.js\";\nimport {\n\tisSearchableVectorCatalog,\n\trankValidatedIndex,\n\treadCatalog,\n} from \"./validated-vector-index.js\";\n\nexport function contentIdentity(row: Record<string, unknown>): string {\n\treturn createHash(\"sha256\").update(JSON.stringify(row)).digest(\"hex\");\n}\n\nexport function summarySessionId(\n\tdb: Database,\n\tcontext: AutomaticContext | null | undefined,\n\tproject?: string | null,\n): number | null | undefined {\n\treturn automaticSummarySession(db, context, project);\n}\n\n/** Authorization, continuity, model selection, ranking and identities share one short read snapshot. */\nexport function rankWorkerInput(db: Database, input: RankInput): RankOutput | null {\n\treturn db.transaction(() => {\n\t\tconst catalog = readCatalog(db);\n\t\tif (!isSearchableVectorCatalog(db, catalog) || catalog.generationId !== input.generationId)\n\t\t\treturn null;\n\t\tconst claimedDeviceIds = resolveSameActorPeerIds(db, input.proof.actorId);\n\t\tconst ranked = rankValidatedIndex(db, {\n\t\t\tquery: { model: input.embeddingIdentity, vectors: [input.embedding] },\n\t\t\tlimit: input.limit,\n\t\t\tfilters: input.filters,\n\t\t\tcontext: {\n\t\t\t\t...input.proof,\n\t\t\t\tclaimedDeviceIds,\n\t\t\t\tlegacyActorIds: claimedDeviceIds.map((id) => `legacy-sync:${id}`),\n\t\t\t\tscopeVisibilityDb: db,\n\t\t\t},\n\t\t\tsummarySessionId: summarySessionId(db, input.automaticContext, input.filters?.project),\n\t\t});\n\t\tif (!ranked || ranked.generationId !== input.generationId) return null;\n\t\treturn {\n\t\t\tgenerationId: ranked.generationId,\n\t\t\trevision: ranked.revision,\n\t\t\tmodels: ranked.models,\n\t\t\tcandidateVersions: ranked.candidateVersions,\n\t\t\tcandidates: ranked.results.map((row) => {\n\t\t\t\tconst raw = db.prepare(\"SELECT * FROM memory_items WHERE id = ?\").get(row.id) as Record<\n\t\t\t\t\tstring,\n\t\t\t\t\tunknown\n\t\t\t\t>;\n\t\t\t\treturn {\n\t\t\t\t\tid: row.id,\n\t\t\t\t\tdistance: row.distance,\n\t\t\t\t\tcontentIdentity: contentIdentity(raw),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t})();\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,EACf,GACA,GACA,GAC4B;CAC5B,IAAI,MAAY,KAAA,GAAW;CAC3B,IAAI,MAAY,MAAM,OAAO;CAC7B,IAAM,IAAS,EAAQ,OAAO,KAAK,CAAC,CAAC,YAAY,GAC3C,IAAS,EAAQ,cAAc,KAAK;CAC1C,IAAI,CAAC,KAAU,CAAC,KAAU,EAAO,YAAY,MAAM,WAAW,OAAO;CACrE,IAAM,IAAS,EAAoB,aAAa,KAAW,EAAE,GACvD,IAAO,EACX,QAAQ;;;IAGP,EAAO,SAAS,OAAO,EAAO,WAAW,GAAG;;;SAGvC,EAAwB,EAAE;EACjC,CAAC,CACA,IAAI,GAAQ,GAAQ,GAAG,EAAO,MAAM;CAEtC,OADI,CAAC,EAAO,UAAU,EAAK,SAAS,IAAU,OACvC,EAAK,EAAE,EAAE,cAAc;AAC/B;;;AC1BA,IAAa,IAAgC;AAQ7C,SAAgB,EAAkC,GAAuB;CAExE,OADK,EAAY,GAAI,kBAAkB,IAEtC,EACE,QAAQ,wEAAwE,CAAC,CACjF,IAAI,CAA6B,MAAM,KAAA,IAJO;AAMlD;;;ACXA,IAAM,oBAAiC,IAAI,IAAI;CAC9C;CAEA;CACA;CACA;CACA;AACD,CAAC;AAOD,SAAgB,EAAwB,GAAc,GAA2B;CAChF,IAAM,IAAO,EAAgB,GAAI,CAAO;C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;KACR,UAAU,EAAI;KACd,iBAAiB,EAAgB,CAAG;IACrC;GACD,CAAC;EACF;CACD,CAAC,CAAC,CAAC;AACJ"}
@@ -9122,22 +9122,24 @@ function Eh(e) {
9122
9122
  revoked: !0
9123
9123
  } : u;
9124
9124
  }
9125
- function Dh(e, t) {
9126
- let n = () => /* @__PURE__ */ Error("coordinator_removal_list_malformed");
9127
- if (e?.version !== 1 || !Array.isArray(e.items) || e.items.length > 500) throw n();
9128
- let r = t ?? Infinity, i = e.items.map((e) => {
9129
- if (!e || typeof e != "object" || Array.isArray(e) || "revoked" in e) throw n();
9130
- let t = {
9125
+ function Dh(e, t, n = {}) {
9126
+ let r = () => /* @__PURE__ */ Error("coordinator_removal_list_malformed");
9127
+ if (e?.version !== 1 || !Array.isArray(e.items) || e.items.length > 500) throw r();
9128
+ let i = t ?? Infinity, a = e.items.map((e) => {
9129
+ if (!e || typeof e != "object" || Array.isArray(e)) throw r();
9130
+ let t = "revoked" in e;
9131
+ if (t && (!n.includeBlocked || e.revoked !== !0)) throw r();
9132
+ let a = {
9131
9133
  ...e,
9132
- revoked: 0
9134
+ revoked: +!!t
9133
9135
  };
9134
- if (!Th(t) || t.removal_seq >= r) throw n();
9135
- return r = t.removal_seq, Eh(t);
9136
- }), a = e.next_before_seq;
9137
- if (a !== null && (typeof a != "number" || a !== i.at(-1)?.removal_seq)) throw n();
9136
+ if (!Th(a) || a.removal_seq >= i) throw r();
9137
+ return i = a.removal_seq, Eh(a);
9138
+ }), o = e.next_before_seq;
9139
+ if (o !== null && (typeof o != "number" || o !== a.at(-1)?.removal_seq)) throw r();
9138
9140
  return {
9139
- items: i,
9140
- next_before_seq: a
9141
+ items: a,
9142
+ next_before_seq: o
9141
9143
  };
9142
9144
  }
9143
9145
  function Oh(e, t) {
@@ -12847,4 +12849,4 @@ var $x = 300;
12847
12849
  //#endregion
12848
12850
  export { tb as $, Re as $a, tr as $i, tp as $n, ps as $r, Pg as $t, ax as A, Tt as Aa, ea as Ai, Dm as An, Ju as Ar, D_ as At, Bb as B, Se as Ba, gi as Bi, Kp as Bn, pl as Br, Kg as Bt, Ox as C, At as Ca, Qi as Ci, Fm as Cn, yd as Cr, j_ as Ct, Vb as D, Ft as Da, yi as Di, km as Dn, vd as Dr, S_ as Dt, Cx as E, Ot as Ea, Ni as Ei, Tm as En, gd as Er, C_ as Et, Fb as F, We as Fa, di as Fi, wm as Fn, Iu as Fr, g_ as Ft, wb as G, _e as Ga, Tr as Gi, Hp as Gn, xs as Gr, Yg as Gt, Tb as H, xe as Ha, ni as Hi, qp as Hn, tc as Hr, Xg as Ht, Lb as I, rt as Ia, hi as Ii, em as In, Eu as Ir, __ as It, ub as J, ze as Ja, jr as Ji, Bp as Jn, bs as Jr, Vg as Jt, bb as K, he as Ka, Ar as Ki, Lp as Kn, ys as Kr, Bg as Kt, Rb as L, nt as La, fi as Li, cm as Ln, $l as Lr, x_ as Lt, cx as M, _t as Ma, ia as Mi, Zp as Mn, Ku as Mr, y_ as Mt, lx as N, g as Na, Yi as Ni, Xp as Nn, ed as Nr, b_ as Nt, Hb as O, wt as Oa, Xi as Oi, Pm as On, bd as Or, e_ as Ot, zb as P, Et as Pa, na as Pi, Qp as Pn, Yu as Pr, v_ as Pt, $y as Q, Pe as Qa, pr as Qi, kp as Qn, ls as Qr, Ag as Qt, Ib as R, ut as Ra, mi as Ri, Wp as Rn, j as Rr, n_ as Rt, wx as S, Mt as Sa, qi as Si, Im as Sn, Jd as Sr, A_ as St, Dx as T, Dt as Ta, ki as Ti, Rm as Tn, nd as Tr, T_ as Tt, Cb as U, ve as Ua, ti as Ui, Mp as Un, Ls as Ur, qg as Ut, Eb as V, ye as Va, li as Vi, Yp as Vn, Lc as Vr, Zg as Vt, xb as W, ge as Wa, si as Wi, Vp as Wn, Es as Wr, Qg as Wt, cb as X, we as Xa, Pr as Xi, fp as Xn, cs as Xr, Fg as Xt, lb as Y, Ce as Ya, wr as Yi, Ip as Yn, _s as Yr, Ug as Yt, ib as Z, Fe as Za, C as Zi, K as Zn, D as Zr, Rg as Zt, Sx as _, zt as _a, pa as _i, ig as _n, l as _o, Ud as _r, H_ as _t, Fx as a, Zn as aa, uo as ai, Rh as an, u as ao, qf as ar, Wv as at, hx as b, Nt as ba, oa as bi, lh as bn, Kd as br, k_ as bt, Ix as c, v as ca, io as ci, cg as cn, ee as co, hf as cr, Kv as ct, Gx as d, un as da, Da as di, ng as dn, de as do, V as dr, qv as dt, S as ea, fs as ei, Og as en, Ve as eo, ep as er, eb as et, Wx as f, _ as fa, ja as fi, sg as fn, fe as fo, Bd as fr, Bv as ft, $ as g, Bt as ga, va as gi, og as gn, s as go, Hd as gr, B_ as gt, Bx as h, Ut as ha, Aa as hi, ag as hn, oe as ho, Yd as hr, L_ as ht, Lx as i, Qn as ia, lo as ii, Vh as in, ae as io, up as ir, Xv as it, ux as j, xt as ja, ta as ji, tm as jn, qu as jr, E_ as jt, sx as k, dt as ka, Ki as ki, Nm as kn, Lu as kr, O_ as kt, Px as l, _n as la, ao as li, eg as ln, se as lo, xd as lr, Yv as lt, Rx as m, Wt as ma, Ma as mi, Hh as mn, me as mo, Fd as mr, z_ as mt, Qx as n, wn as na, wo as ni, zh as nn, Be as no, sp as nr, Hy as nt, Mx as o, y as oa, to as oi, Dg as on, pe as oo, Kf as or, Hv as ot, zx as p, Gt as pa, Oa as pi, Gh as pn, ue as po, Rd as pr, Vv as pt, hb as q, Te as qa, kr as qi, Fp as qn, vs as qr, Hg as qt, Vx as r, Xn as ra, Bo as ri, Bh as rn, ce as ro, dp as rr, Qy as rt, Nx as s, b as sa, eo as si, ug as sn, p as so, xf as sr, Jv as st, $x as t, Ln as ta, ss as ti, kg as tn, He as to, $f as tr, nb as tt, Ux as u, bn as ua, no as ui, $h as un, le as uo, Vd as ur, Gv as ut, px as v, Vt as va, w as vi, rg as vn, c as vo, qd as vr, P_ as vt, xx as w, It as wa, _i as wi, Lm as wn, ud as wr, t_ as wt, mx as x, Pt as xa, Zi as xi, eh as xn, Gd as xr, M_ as xt, jx as y, Lt as ya, aa as yi, Dh as yn, o as yo, Wd as yr, R_ as yt, Pb as z, Qe as za, ui as zi, Up as zn, ml as zr, $g as zt };
12849
12851
 
12850
- //# sourceMappingURL=sync-auth-constants-DNUSV-Tn.js.map
12852
+ //# sourceMappingURL=sync-auth-constants-CifCg69d.js.map