@polycode-projects/the-mechanical-code-talker 0.8.1 → 0.8.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.
@@ -44,7 +44,7 @@ import { selectTool } from "../server-http.mjs";
44
44
  import {
45
45
  capabilities, capabilityByName, preconditionsOf, effectsOf, PRECOND,
46
46
  } from "./registry.mjs";
47
- import { hallucinationsIn } from "../../agentbench/grade.mjs";
47
+ import { hallucinationsIn } from "./call-validator.mjs";
48
48
 
49
49
  // ---- the ask-kind -> epistemic-topic MAPPING (the Stage-1 core) --------------
50
50
  // Keyed `${shape}:${kind}` off parseQuery's simple-clause output. The VALUE is
@@ -0,0 +1,31 @@
1
+ // src/router/set-algebra.mjs — the COMPOSITION OPERATORS: pure set-algebra a
2
+ // multi-step plan needs to fold its threaded step result-sets into ONE composed
3
+ // answer. Shared by the product router (goal-reasoner's relative-filter fold)
4
+ // and the bench result-execution layer (agentbench/results.mjs re-exports
5
+ // these) — the bench imports the product, never the other way round. The
6
+ // resolver DRIVER picks the operator from the router's OWN HTN method
7
+ // (relative-filter -> intersect; conditional -> fallback/guard) and applies it;
8
+ // grade.mjs never imports these (it only value-compares the driver's composed
9
+ // answer to the STATIC expect.result literal — no circular re-derivation).
10
+ // No I/O, no Date.now, no LLM.
11
+
12
+ /** Dedupe + locale-stable sort — the canonical label-set normal form. */
13
+ export const uniqSort = (xs) => [...new Set(xs)].sort((a, b) => String(a).localeCompare(String(b)));
14
+
15
+ /** a ∩ b — the relative-filter fold ("of the <set>, which are <Y>"). */
16
+ export function intersect(a = [], b = []) {
17
+ const bs = new Set(b);
18
+ return uniqSort([...new Set(a)].filter((x) => bs.has(x)));
19
+ }
20
+
21
+ /** if a is empty -> b, else a — the conditional "… <action> instead" recipe
22
+ * ("if X has no tests, list what covers Y instead"). */
23
+ export function fallbackIfEmpty(a = [], b = []) {
24
+ return uniqSort(a.length ? a : b);
25
+ }
26
+
27
+ /** if a is empty -> b, else ∅ — the guarded conditional ("if X is untested,
28
+ * <action> it"): the action's result fires ONLY when the guard set is empty. */
29
+ export function guardIfEmpty(a = [], b = []) {
30
+ return uniqSort(a.length ? [] : b);
31
+ }