@verax-ai/proxy 0.4.5 → 0.4.6

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 (2) hide show
  1. package/dist/reconcile.js +19 -3
  2. package/package.json +1 -1
package/dist/reconcile.js CHANGED
@@ -363,10 +363,26 @@ export function reconcile(channelRows, effects, opts) {
363
363
  const rowTol = rowToleranceMs(row, toleranceMs);
364
364
  const marked = { ...row, toleranceMs: rowTol };
365
365
  if (typeof row.ref === "string" && row.ref !== "") {
366
- const idx = effects.findIndex((e, i) => !used.has(i) &&
366
+ const findFor = (ref) => effects.findIndex((e, i) => !used.has(i) &&
367
367
  decided(e) &&
368
- (e.row.ref === row.ref ||
369
- opts?.approvals?.some((a) => a.ref === row.ref && a.allowRef === e.row.ref)));
368
+ (e.row.ref === ref || opts?.approvals?.some((a) => a.ref === ref && a.allowRef === e.row.ref)));
369
+ let idx = findFor(row.ref);
370
+ if (idx === -1) {
371
+ // The brain is answered with its own `_ref`, so the statement may carry the raw
372
+ // ref of a scoped defer `<tenantKey>:<raw>`. Taken only when one tenant has it.
373
+ const scoped = [
374
+ ...new Set((opts?.approvals ?? [])
375
+ .filter((a) => a.ref.endsWith(`:${row.ref}`))
376
+ .map((a) => a.ref)
377
+ .filter((ref) => findFor(ref) !== -1)),
378
+ ];
379
+ if (scoped.length > 1) {
380
+ ghost.push(asGhost(marked, effects, "ref-ambiguous"));
381
+ continue;
382
+ }
383
+ if (scoped.length === 1)
384
+ idx = findFor(scoped[0]);
385
+ }
370
386
  if (idx === -1) {
371
387
  ghost.push(asGhost(marked, effects));
372
388
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verax-ai/proxy",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {