@polycode-projects/the-mechanical-code-talker 5.0.32 → 5.0.34

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.
@@ -165,9 +165,10 @@ export function routeBetweenCells(factRows, fromCell, toCell) {
165
165
  * `outlook`/`applyEdit`/`applyAgentEdit` for it, the same way it does for a
166
166
  * square; `tick`, `driveAgent`, `recast` and `board` never get anything real
167
167
  * to do without a layout, so they answer with the same "nothing moved" shape
168
- * a resting board would rather than throwing — the page simply never wires
169
- * its play/step/drive controls to a puzzle scenario (see mudiii-viz.mjs's
170
- * `puzzle` flag). */
168
+ * a resting board would rather than throwing. A puzzle page's own play and
169
+ * step controls never reach them either: they walk the crossing `outlook`
170
+ * already found, one position at a time (see mudiii-viz.mjs's `puzzle`
171
+ * flag). */
171
172
  export async function createMudiiiSession(
172
173
  worldPayload, { agents = [], epoch = 0, getTeachEnabled = () => false } = {},
173
174
  ) {
@@ -32,7 +32,8 @@
32
32
  import { createInMemoryStore, applySeedPayload, loadMemory, readFactRows, appendFacts, removeFacts, normFactTerm, normFactPredicate } from "../../adapters/memory/core.mjs";
33
33
  import { factIdFor } from "../../domain/hash.mjs";
34
34
  import { loadLexicon } from "../../domain/grammar/lexicon.mjs";
35
- import { ingestText } from "../../services/extract-facts.mjs";
35
+ import { ingestText, setIngestYield } from "../../services/extract-facts.mjs";
36
+ import { isNewsProvenance } from "../../domain/news-feed.mjs";
36
37
  import {
37
38
  resolveNewsConfig, createNewsState, pollNewsSources, enrichTopTerms, buildFeed,
38
39
  ingestUploadedFactRows, isVocabGroundedTerm,
@@ -125,14 +126,22 @@ function fixtureRawItems(format, body) {
125
126
  * own one-off preflight rather than the poll cycle's consent.
126
127
  *
127
128
  * Returns `{ memoryDir, phase, consented, metrics, nextPollAt, config,
128
- * requestLog, health, start, poll, enrich, buildFeed, rank, addSource,
129
+ * requestLog, health, start, poll, enrich, buildFeed, stats, rank, addSource,
129
130
  * setInterval, ingestText, ingestFile, replayFixture, revokeConsent,
130
131
  * destroy }`.
131
132
  */
132
133
  export function createNewsSession({
133
134
  seedPayload = null, vocabSeeded = false, fetchImpl = null, now = isoNow,
134
- prefs = null, prefKey = NEWS_START_PREF_KEY,
135
+ prefs = null, prefKey = NEWS_START_PREF_KEY, yieldToHost,
135
136
  } = {}) {
137
+ // Grounding one article is seconds of straight-line work, and the page has
138
+ // only the one thread. A macrotask between candidates lets it paint, answer
139
+ // a click and keep the "polling…" affordance honest instead of going
140
+ // unresponsive mid-poll. A Node caller gets no yield and pays nothing.
141
+ setIngestYield(yieldToHost === undefined
142
+ ? (typeof document === "undefined" ? null : () => new Promise((resolve) => setTimeout(resolve, 0)))
143
+ : yieldToHost);
144
+
136
145
  const memoryDir = createInMemoryStore();
137
146
  applySeedPayload(memoryDir, seedPayload);
138
147
 
@@ -272,6 +281,18 @@ export function createNewsSession({
272
281
 
273
282
  async buildFeed() { return buildFeed(ctx()); },
274
283
 
284
+ /** The two whole-graph counts the dashboard shows: every fact the store
285
+ * holds, and the subset a news, fixture-replay or research ingest
286
+ * contributed. Read off the same provenance rule the feed window uses,
287
+ * so a tile and the feed can never disagree about what came from news. */
288
+ async stats() {
289
+ const memory = await store.loadMemory(memoryDir);
290
+ const rows = store.readFactRows(memory);
291
+ let fromNews = 0;
292
+ for (const row of rows) if (isNewsProvenance(row.provenance)) fromNews += 1;
293
+ return { graphSize: rows.length, factsFromNews: fromNews };
294
+ },
295
+
275
296
  /** The fact rows behind a set of ids — a feed item's own `factIds`,
276
297
  * expanded so the page's `<details>` fact list can show each one as a
277
298
  * sentence and, nested under it, the raw triple record. */