@polycode-projects/the-mechanical-code-talker 2.2.0 → 2.3.1

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 (137) hide show
  1. package/bin/tmct.mjs +4 -5
  2. package/corpus/LICENSES.json +19 -4
  3. package/corpus/README.md +48 -0
  4. package/corpus/generated/README.md +24 -9
  5. package/corpus/generated/ace-surface-variants.jsonl +4 -1
  6. package/corpus/generated/manifest.json +4 -4
  7. package/corpus/prose/manifest.json +512 -0
  8. package/corpus/prose/sqlite/LICENSE-NOTICE +53 -0
  9. package/corpus/prose/sqlite/arch.txt +213 -0
  10. package/corpus/prose/sqlite/atomiccommit.txt +1117 -0
  11. package/corpus/prose/sqlite/faq.txt +473 -0
  12. package/corpus/prose/sqlite/fileformat.txt +1589 -0
  13. package/corpus/prose/sqlite/lang_createtable.txt +1339 -0
  14. package/corpus/prose/sqlite/lang_insert.txt +580 -0
  15. package/corpus/prose/sqlite/lang_select.txt +3293 -0
  16. package/corpus/prose/sqlite/optoverview.txt +908 -0
  17. package/corpus/prose/sqlite/queryplanner.txt +447 -0
  18. package/corpus/prose/sqlite/transactional.txt +41 -0
  19. package/corpus/prose/sqlite/wal.txt +567 -0
  20. package/corpus/prose/sqlite/whentouse.txt +300 -0
  21. package/corpus/prose/wikipedia/Apple.txt +4 -0
  22. package/corpus/prose/wikipedia/Attempto_Controlled_English.txt +169 -0
  23. package/corpus/prose/wikipedia/Automated_planning_and_scheduling.txt +67 -0
  24. package/corpus/prose/wikipedia/Bee.txt +7 -0
  25. package/corpus/prose/wikipedia/Bird.txt +8 -0
  26. package/corpus/prose/wikipedia/Bone.txt +4 -0
  27. package/corpus/prose/wikipedia/Book.txt +7 -0
  28. package/corpus/prose/wikipedia/Bread.txt +6 -0
  29. package/corpus/prose/wikipedia/Butterfly.txt +6 -0
  30. package/corpus/prose/wikipedia/Car.txt +1 -0
  31. package/corpus/prose/wikipedia/Cat.txt +1 -0
  32. package/corpus/prose/wikipedia/Child.txt +3 -0
  33. package/corpus/prose/wikipedia/City.txt +2 -0
  34. package/corpus/prose/wikipedia/Clock.txt +2 -0
  35. package/corpus/prose/wikipedia/Cooking.txt +1 -0
  36. package/corpus/prose/wikipedia/Description_logic.txt +660 -0
  37. package/corpus/prose/wikipedia/Doctor.txt +6 -0
  38. package/corpus/prose/wikipedia/Dog.txt +4 -0
  39. package/corpus/prose/wikipedia/Eagle.txt +4 -0
  40. package/corpus/prose/wikipedia/Emotion.txt +9 -0
  41. package/corpus/prose/wikipedia/Eye.txt +5 -0
  42. package/corpus/prose/wikipedia/Family.txt +3 -0
  43. package/corpus/prose/wikipedia/Farm.txt +4 -0
  44. package/corpus/prose/wikipedia/Fear.txt +4 -0
  45. package/corpus/prose/wikipedia/First-order_logic.txt +1518 -0
  46. package/corpus/prose/wikipedia/Fish.txt +10 -0
  47. package/corpus/prose/wikipedia/Flower.txt +3 -0
  48. package/corpus/prose/wikipedia/Food.txt +10 -0
  49. package/corpus/prose/wikipedia/Grass.txt +9 -0
  50. package/corpus/prose/wikipedia/Hand.txt +2 -0
  51. package/corpus/prose/wikipedia/Happiness.txt +3 -0
  52. package/corpus/prose/wikipedia/Heart.txt +4 -0
  53. package/corpus/prose/wikipedia/Horse.txt +4 -0
  54. package/corpus/prose/wikipedia/House.txt +6 -0
  55. package/corpus/prose/wikipedia/Human.txt +4 -0
  56. package/corpus/prose/wikipedia/Insect.txt +6 -0
  57. package/corpus/prose/wikipedia/Interactive_fiction.txt +112 -0
  58. package/corpus/prose/wikipedia/Knowledge.txt +5 -0
  59. package/corpus/prose/wikipedia/Knowledge_representation_and_reasoning.txt +87 -0
  60. package/corpus/prose/wikipedia/LICENSE-NOTICE +94 -0
  61. package/corpus/prose/wikipedia/Language.txt +10 -0
  62. package/corpus/prose/wikipedia/Learning.txt +4 -0
  63. package/corpus/prose/wikipedia/Mammal.txt +3 -0
  64. package/corpus/prose/wikipedia/Memory.txt +5 -0
  65. package/corpus/prose/wikipedia/Milk.txt +1 -0
  66. package/corpus/prose/wikipedia/Mountain.txt +1 -0
  67. package/corpus/prose/wikipedia/Natural_language_processing.txt +211 -0
  68. package/corpus/prose/wikipedia/Ostrich.txt +2 -0
  69. package/corpus/prose/wikipedia/Owl.txt +2 -0
  70. package/corpus/prose/wikipedia/Penguin.txt +2 -0
  71. package/corpus/prose/wikipedia/Plant.txt +5 -0
  72. package/corpus/prose/wikipedia/Rain.txt +1 -0
  73. package/corpus/prose/wikipedia/Resource_Description_Framework.txt +184 -0
  74. package/corpus/prose/wikipedia/River.txt +1 -0
  75. package/corpus/prose/wikipedia/School.txt +8 -0
  76. package/corpus/prose/wikipedia/Sea.txt +1 -0
  77. package/corpus/prose/wikipedia/Semantic_Web.txt +114 -0
  78. package/corpus/prose/wikipedia/Semantic_reasoner.txt +29 -0
  79. package/corpus/prose/wikipedia/Snow.txt +5 -0
  80. package/corpus/prose/wikipedia/Sun.txt +5 -0
  81. package/corpus/prose/wikipedia/Teacher.txt +4 -0
  82. package/corpus/prose/wikipedia/Team.txt +3 -0
  83. package/corpus/prose/wikipedia/Text-based_game.txt +17 -0
  84. package/corpus/prose/wikipedia/Tool.txt +4 -0
  85. package/corpus/prose/wikipedia/Tree.txt +7 -0
  86. package/corpus/prose/wikipedia/Weather.txt +4 -0
  87. package/corpus/prose/wikipedia/Web_Ontology_Language.txt +133 -0
  88. package/corpus/prose/wikipedia/Wind.txt +8 -0
  89. package/corpus/prose/wikipedia/Writing.txt +5 -0
  90. package/corpus/wordnet/generate.mjs +6 -7
  91. package/package.json +31 -2
  92. package/src/adapters/corpus/conceptnet.mjs +1 -1
  93. package/src/adapters/graph-build.mjs +3 -3
  94. package/src/adapters/memory/blocks.mjs +2 -2
  95. package/src/adapters/memory/core.mjs +5 -5
  96. package/src/adapters/providers/bootstrap.mjs +1 -1
  97. package/src/adapters/providers/fixture.mjs +1 -1
  98. package/src/adapters/wink-model.mjs +1 -1
  99. package/src/adapters/wordnet-source.mjs +70 -0
  100. package/src/domain/answer-variants.json +1 -1
  101. package/src/domain/ask-vocab.mjs +2 -2
  102. package/src/domain/ask.mjs +4 -4
  103. package/src/domain/codegraph.mjs +3 -3
  104. package/src/domain/corpus-matrix.mjs +87 -0
  105. package/src/domain/grammar/ace.mjs +11 -11
  106. package/src/domain/grammar/lexicon.mjs +3 -3
  107. package/src/domain/inflect.mjs +67 -0
  108. package/src/domain/interpret/fuzzy.mjs +1 -1
  109. package/src/domain/interpret/merge.mjs +1 -1
  110. package/src/domain/interpret/normalize.mjs +1 -1
  111. package/src/domain/licences.mjs +68 -0
  112. package/src/domain/memory/capability.mjs +1 -1
  113. package/src/domain/memory/trust.mjs +2 -2
  114. package/src/domain/persona/codegen.mjs +123 -0
  115. package/src/domain/persona/examples.mjs +26 -0
  116. package/src/domain/persona/tiers.mjs +270 -0
  117. package/src/domain/publish-gate.mjs +41 -0
  118. package/src/domain/router/call-validator.mjs +1 -1
  119. package/src/domain/router/drive.mjs +3 -4
  120. package/src/domain/router/registry.mjs +12 -13
  121. package/src/domain/router/resolver.mjs +18 -5
  122. package/src/domain/router/results.mjs +3 -3
  123. package/src/domain/router/taught.mjs +4 -3
  124. package/src/domain/schemaorg/turtle.mjs +25 -0
  125. package/src/domain/semcor/parse.mjs +87 -0
  126. package/src/domain/syllogise.mjs +6 -6
  127. package/src/domain/version-stamp.mjs +36 -0
  128. package/src/domain/wordnet/yaml.mjs +133 -0
  129. package/src/services/chat-session.mjs +2 -2
  130. package/src/services/chat.mjs +2 -2
  131. package/src/services/cli-args.mjs +4 -4
  132. package/src/services/finish.mjs +1 -1
  133. package/src/services/ledger-viz.mjs +2 -3
  134. package/src/services/sessions.mjs +4 -4
  135. package/src/services/viz-theme.mjs +3 -4
  136. package/src/surfaces/web/memory-ask-browser.bundle.js +1 -18
  137. package/src/domain/router/guardrail.mjs +0 -116
@@ -1,116 +0,0 @@
1
- // src/domain/router/guardrail.mjs — the guardrail. Validate an
2
- // EXTERNALLY-proposed `tool_use` against the registry's declared preconditions.
3
- //
4
- // Proves RESOLVABILITY (the tool is registered/declared, args are well-formed, every
5
- // `resolves(param, as)` precondition binds to a real graph entity) — NOT antecedent
6
- // correctness: a cross-turn mis-binding ("it" -> the wrong Commit) still resolves to a
7
- // real entity and passes. "This symbol denotes something real and the call is
8
- // well-formed", never "this is the right something".
9
- //
10
- // Pure over its inputs + ctx.resolve (the binding oracle). No network, no Date.now.
11
-
12
- import { capabilityByName, preconditionsOf, PRECOND } from "./registry.mjs";
13
- import { hallucinationsIn } from "./call-validator.mjs";
14
-
15
- /** The same read-only breadth-first enrichment as resolver.mjs's `dispatchEachCandidate`:
16
- * dispatching the SAME tool once per tied candidate is safe for `readOnly` capabilities
17
- * (dispatch performs no writes). Returns `[{candidate, result}, ...]`, or
18
- * undefined when there is no dispatcher to run it with. */
19
- async function dispatchEachCandidate(pool, capName, arg, ctx) {
20
- if (!ctx.dispatch) return undefined;
21
- // Only readOnly capabilities may be dispatched here: the enrichment runs the
22
- // SAME tool once per tied candidate, which is only safe when dispatch
23
- // performs no writes. A registered world-mutating capability is planned
24
- // over, never dispatched.
25
- if (capabilityByName(capName)?.readOnly !== true) return undefined;
26
- const results = [];
27
- for (const c of pool) {
28
- const res = await ctx.dispatch(capName, { [arg]: c.label });
29
- results.push({ candidate: c.label, result: res });
30
- }
31
- return results;
32
- }
33
-
34
- /** Validate a proposed tool_use. Returns a glass-box verdict:
35
- * { ok, tool, denied:[{reason,detail}], steps:[{pred,ok,...}], provenance, candidateResults? }
36
- * ok=false with a default-deny/undeclared/unknown-arg/missing-arg denial is structural (no
37
- * graph needed); an `unresolved` step is a binding rejection, and an ambiguous `resolves`
38
- * term additionally carries `candidateResults` (the tool dispatched once per tied candidate)
39
- * when `ctx.dispatch` is wired. `declaredNames=null` skips the declared-set check.
40
- * `ctx.resolve(term)` is the resolveObject oracle; omit it for structural-only validation. */
41
- export async function guard(toolUse, declaredNames = null, ctx = {}) {
42
- const name = toolUse?.name;
43
- const input = toolUse && typeof toolUse.input === "object" && toolUse.input ? toolUse.input : {};
44
- const denied = [];
45
- const steps = [];
46
-
47
- // Default-deny: unknown/unregistered tool is an automatic reject.
48
- const declaredList = declaredNames ? [...declaredNames] : null;
49
- const cap = capabilityByName(name);
50
- if (!cap) {
51
- denied.push({ reason: "default-deny", detail: `"${name ?? "(none)"}" is not a registered capability` });
52
- return { ok: false, tool: name ?? null, denied, steps, provenance: "registry default-deny" };
53
- }
54
- const structural = hallucinationsIn({ name, input }, declaredList ?? [name]);
55
- for (const p of structural) {
56
- // no declared set supplied => "undeclared" isn't a real denial (we synthesised [name]).
57
- if (!declaredList && p.reason === "undeclared") continue;
58
- denied.push(p);
59
- }
60
-
61
- // Precondition check — the STRIPS safety gate, step by step.
62
- let candidateResults;
63
- for (const pre of preconditionsOf(name)) {
64
- if (pre.pred === PRECOND.graphLoaded) {
65
- steps.push({ step: "precondition", pred: pre.pred, ok: true });
66
- } else if (pre.pred === PRECOND.anyPresent) {
67
- const ok = pre.params.some((k) => input[k] !== undefined && input[k] !== null && String(input[k]).trim() !== "");
68
- steps.push({ step: "precondition", pred: pre.pred, params: pre.params, ok });
69
- if (!ok) denied.push({ reason: "missing-arg", detail: `${name} needs one of ${pre.params.join("|")}` });
70
- } else if (pre.pred === PRECOND.resolves) {
71
- const term = input[pre.param];
72
- const present = term !== undefined && term !== null && String(term).trim() !== "";
73
- if (!present) {
74
- steps.push({ step: "precondition", pred: pre.pred, param: pre.param, value: null, ok: false });
75
- continue;
76
- }
77
- // No oracle wired: assert the arg is PRESENT only, not that it binds.
78
- if (!ctx.resolve) {
79
- steps.push({ step: "precondition", pred: pre.pred, param: pre.param, value: term, ok: true, note: "structural-only (no resolver wired)" });
80
- continue;
81
- }
82
- const r = ctx.resolve(String(term));
83
- const resolvedOk = Boolean(r && r.match && !r.ambiguous);
84
- steps.push({
85
- step: "precondition", pred: pre.pred, param: pre.param, value: term,
86
- ok: resolvedOk,
87
- ...(r && r.match ? { boundTo: r.match.label, boundClass: r.match.class ?? null, tier: r.tier ?? null } : {}),
88
- ...(r && r.ambiguous ? { ambiguous: true } : {}),
89
- });
90
- if (!resolvedOk) {
91
- denied.push({
92
- reason: "unresolved",
93
- detail: r && r.ambiguous
94
- ? `${name}.${pre.param}="${term}" is ambiguous (narrow it)`
95
- : `${name}.${pre.param}="${term}" resolves to no graph entity`,
96
- });
97
- if (r && r.ambiguous) {
98
- const pool = [r.match, ...(r.candidates || [])].slice(0, 4);
99
- const dispatched = await dispatchEachCandidate(pool, name, pre.param, ctx);
100
- if (dispatched) candidateResults = dispatched;
101
- }
102
- }
103
- }
104
- }
105
-
106
- const ok = denied.length === 0;
107
- return {
108
- ok, tool: name, denied, steps, provenance: ok ? "resolvable (NOT proven antecedent-correct)" : "denied",
109
- ...(candidateResults ? { candidateResults } : {}),
110
- };
111
- }
112
-
113
- /** Convenience boolean: does a proposed tool_use PASS the guardrail? */
114
- export async function admits(toolUse, declaredNames = null, ctx = {}) {
115
- return (await guard(toolUse, declaredNames, ctx)).ok;
116
- }