@polycode-projects/the-mechanical-code-talker 6.0.2 → 6.0.4

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.
@@ -17,7 +17,8 @@
17
17
  // never published — only the hosted demo site's public/ledger.html links to
18
18
  // it, as an optional sibling script the page degrades honestly without.
19
19
  import { vocabExampleHint } from "../../services/chat.mjs";
20
- import { createInMemoryStore, normFactTerm, applySeedPayload, loadMemory, readFactRows } from "../../adapters/memory/core.mjs";
20
+ import { createInMemoryStore, normFactTerm, applySeedPayload, loadMemory, readFactRows, wrapRowBackend } from "../../adapters/memory/core.mjs";
21
+ import { createHttpRowBackend, withOneRetryOnUnavailable } from "./http-row-backend.mjs";
21
22
  import { splitSentencesPreservingPaths } from "../../services/sentences.mjs";
22
23
  import { parseEntities } from "../../domain/codegraph.mjs";
23
24
  import { memoryFactGraphPayload } from "../../domain/memory-facts.mjs";
@@ -45,14 +46,35 @@ import { graphAsk, enginePlan } from "./engine-surface.mjs";
45
46
  * traverses those facts while a code-structure question still refuses honestly.
46
47
  *
47
48
  * ledger-viz.mjs's own inline script calls computeLedgerDataFromPayload
48
- * (re-exported below) on `memoryDir.payload` after a turn whose record shows
49
- * a successful write (`via: "assert"` or `via: "retract"`, `miss: false`) to
50
- * re-derive the page's rows/terms/edges/stats and re-mount the same view a
51
- * fresh page load would have rendered — a plain query never re-derives.
49
+ * (re-exported below) on the session's current payload after a turn whose
50
+ * record shows a successful write (`via: "assert"` or `via: "retract"`,
51
+ * `miss: false`) to re-derive the page's rows/terms/edges/stats and re-mount
52
+ * the same view a fresh page load would have rendered — a plain query never
53
+ * re-derives.
54
+ *
55
+ * `awsSessionKey` (optional): the page's AWS-mode backend choice, the same
56
+ * seam chat-browser-entry.mjs's own createChatSession takes — given, the
57
+ * session's memory binds to `createHttpRowBackend({apiBase: "/", sessionKey:
58
+ * awsSessionKey, fetchImpl})` wrapped with `seedPayload` as its read-only
59
+ * seed overlay; omitted, memory stays the plain in-memory store. `fetchImpl`
60
+ * (optional) overrides the ambient `fetch` the row backend calls through —
61
+ * a test points it at a running row-service double.
52
62
  */
53
- export function createLedgerSession({ seedPayload = null, vocabSeeded = false } = {}) {
54
- const memoryDir = createInMemoryStore();
55
- applySeedPayload(memoryDir, seedPayload);
63
+ export function createLedgerSession({
64
+ seedPayload = null, vocabSeeded = false, awsSessionKey = null,
65
+ fetchImpl = (...args) => globalThis.fetch(...args),
66
+ } = {}) {
67
+ // onOversizedRow: "drop" — see chat-browser-entry.mjs's own createChatSession
68
+ // for why: a real corpus seed's high-fan-out mgx:statedBy group is already
69
+ // over the row cap before this session teaches anything, and a session's
70
+ // own new fact adding one more edge to it can't fit one wire row either.
71
+ // The read side (core.mjs) always keeps every seed row regardless, so
72
+ // nothing about the seed itself is lossy — only that one property's
73
+ // cross-fact edge index stays as unwritable as the seed's own copy of it.
74
+ const memoryDir = awsSessionKey
75
+ ? wrapRowBackend(withOneRetryOnUnavailable(createHttpRowBackend({ apiBase: "/", sessionKey: awsSessionKey, fetchImpl })), { basePayload: seedPayload, onOversizedRow: "drop" })
76
+ : createInMemoryStore();
77
+ if (!awsSessionKey) applySeedPayload(memoryDir, seedPayload);
56
78
 
57
79
  const codeGraph = parseEntities({ individuals: [], objectProperties: [] });
58
80