@polycode-projects/the-mechanical-code-talker 5.0.20 → 5.0.22
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.
- package/README.md +4 -27
- package/package.json +1 -6
- package/src/adapters/toml-config.mjs +5 -0
- package/src/domain/domain.mjs +8 -0
- package/src/domain/interpret/normalize.mjs +86 -1
- package/src/domain/router/recognize.mjs +0 -0
- package/src/domain/world-snapshot.mjs +25 -0
- package/src/services/adventure-autoplay.mjs +1 -3
- package/src/services/adventure.mjs +17 -29
- package/src/services/chat.mjs +325 -13
- package/src/services/viz-boot.mjs +8 -8
- package/src/surfaces/web/memory-ask-browser.bundle.js +91 -91
- package/src/domain/code-explorer-hints.mjs +0 -180
- package/src/services/code-explorer-viz.mjs +0 -596
- package/src/surfaces/web/code-explorer-browser-entry.mjs +0 -253
package/README.md
CHANGED
|
@@ -116,7 +116,6 @@ derive by rule from both. Every answer is either grounded or an honest miss.
|
|
|
116
116
|
| `infra/` | the AWS CDK app that provisions the deployed site and its OIDC/deploy roles |
|
|
117
117
|
| `examples/` | runnable example scripts and fixture repos used by the README's own examples and the test suite |
|
|
118
118
|
| `demo/` | standalone demo scripts (e.g. the agentic-loop demo) |
|
|
119
|
-
| `electron/` | the Electron desktop app wrapper |
|
|
120
119
|
| `docs/` | reference docs: the adapter/repository-interface contracts, bibliography |
|
|
121
120
|
| `test/` | the unit, corpus, and estate-guard test suite (`npm test`) |
|
|
122
121
|
| `test-e2e/` | the end-to-end suite: real CLI/TUI spawns and Playwright browser journeys (`npm run test:e2e`) |
|
|
@@ -452,32 +451,6 @@ npx tmct chat --prompt 'disk-1 rests on disk-2. disk-2 rests on disk-3.
|
|
|
452
451
|
|
|
453
452
|
More on the game file and the planner under "Teach it a game" below.
|
|
454
453
|
|
|
455
|
-
### The code explorer (desktop)
|
|
456
|
-
|
|
457
|
-
The same ledger UI, refocused on a code graph, also runs as a desktop app. It
|
|
458
|
-
reads a `graph.json` (or a repo's `.tmct/` folder), shows every import, call and
|
|
459
|
-
`contains` edge as a plain sentence around a focus symbol, and docks a live chat
|
|
460
|
-
over the same graph. A hint rail suggests the next question from what the graph
|
|
461
|
-
actually holds: "what does X import", "which functions call Y", "list
|
|
462
|
-
functions". Every suggestion resolves to a real answer.
|
|
463
|
-
|
|
464
|
-
Electron is a dev-only dependency and never ships in the npm package. Because
|
|
465
|
-
`.npmrc` sets `ignore-scripts=true`, installing it does not fetch the runtime
|
|
466
|
-
binary; fetch it once, then build and launch:
|
|
467
|
-
|
|
468
|
-
```bash skip=network
|
|
469
|
-
npm i -D electron
|
|
470
|
-
node node_modules/electron/install.js # fetch the Electron binary (ignore-scripts skips this)
|
|
471
|
-
npm run build:electron # render electron/renderer/ from the demo graph
|
|
472
|
-
npm run electron # open the code explorer on the demo graph
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
Open a graph or a repo from the window's title bar to explore your own code.
|
|
476
|
-
The UI is channel-agnostic. Only the Electron shell (`electron/main.mjs` +
|
|
477
|
-
`electron/preload.cjs`) is desktop-specific. The same page stays servable as a
|
|
478
|
-
plain web page. `npm run test:electron` runs the shell smoke via Playwright and
|
|
479
|
-
skips cleanly when the binary is absent.
|
|
480
|
-
|
|
481
454
|
## How it interprets you
|
|
482
455
|
|
|
483
456
|
Every message runs through **multiple concurrent interpretation strategies**:
|
|
@@ -1320,6 +1293,10 @@ source = "wikipedia" # wikipedia | wikidata — where "research <topic>"
|
|
|
1320
1293
|
[discourse]
|
|
1321
1294
|
max_referents = 12 # how many referents stay resolvable across turns
|
|
1322
1295
|
|
|
1296
|
+
# Goal recognition (src/domain/router/recognize.mjs).
|
|
1297
|
+
[recognition]
|
|
1298
|
+
max_trace = 32 # how many observed steps a recognition reads back
|
|
1299
|
+
|
|
1323
1300
|
[telemetry]
|
|
1324
1301
|
enabled = false # local-only counters; never phones home
|
|
1325
1302
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polycode-projects/the-mechanical-code-talker",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.22",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The Mechanical Code Talker (tmct) — a tolerant, offline, $0 chat surface that guides you toward precision queries about a software repository. ELIZA/PARRY-style but domain-obsessed with code. No model calls; indexes a repo on request (tmct index) or reads any producer's graph.",
|
|
@@ -172,12 +172,8 @@
|
|
|
172
172
|
"build:ledger-bundle": "node scripts/build-ledger-bundle.mjs",
|
|
173
173
|
"build:ingest-bundle": "node scripts/build-ingest-bundle.mjs",
|
|
174
174
|
"build:research-bundle": "node scripts/build-research-bundle.mjs",
|
|
175
|
-
"build:code-explorer-bundle": "node scripts/build-code-explorer-bundle.mjs",
|
|
176
175
|
"build:mud-bundle": "node scripts/build-mud-bundle.mjs",
|
|
177
176
|
"build:mudiii-bundle": "node scripts/build-mudiii-bundle.mjs",
|
|
178
|
-
"build:electron": "node scripts/build-electron-app.mjs",
|
|
179
|
-
"electron": "electron electron/main.mjs",
|
|
180
|
-
"test:electron": "node --test electron/smoke.test.mjs",
|
|
181
177
|
"build:sprites-bundle": "node scripts/build-sprites-bundle.mjs",
|
|
182
178
|
"build:wink-vendor": "node scripts/build-wink-vendor.mjs",
|
|
183
179
|
"build:three-vendor": "node scripts/build-three-vendor.mjs",
|
|
@@ -201,7 +197,6 @@
|
|
|
201
197
|
"extract:facts": "node --disable-warning=ExperimentalWarning bin/tmct.mjs extract"
|
|
202
198
|
},
|
|
203
199
|
"devDependencies": {
|
|
204
|
-
"electron": "^43.2.0",
|
|
205
200
|
"esbuild": "0.28.1",
|
|
206
201
|
"ink-testing-library": "4.0.0",
|
|
207
202
|
"playwright": "1.61.1",
|
|
@@ -147,6 +147,11 @@ export async function normalizeConfig(raw, { configDir } = {}) {
|
|
|
147
147
|
// through; default-filling is resolveDiscourseConfig's job.
|
|
148
148
|
if (src.discourse !== undefined) cfg.discourse = src.discourse;
|
|
149
149
|
|
|
150
|
+
// Recognition knob (src/domain/router/recognize.mjs): sparse PASS-THROUGH,
|
|
151
|
+
// the raw `[recognition]` table (max_trace) rides through; default-filling
|
|
152
|
+
// is resolveRecognitionConfig's job.
|
|
153
|
+
if (src.recognition !== undefined) cfg.recognition = src.recognition;
|
|
154
|
+
|
|
150
155
|
const idx = src.index || {};
|
|
151
156
|
const index = {};
|
|
152
157
|
if (idx.languages !== undefined) index.languages = idx.languages;
|
package/src/domain/domain.mjs
CHANGED
|
@@ -197,6 +197,14 @@ const domainIndividuals = (domain) => {
|
|
|
197
197
|
return out;
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
+
/** `{ base, step }` for an @stepN-stamped subject, or null for a bare one —
|
|
201
|
+
* the one parser for the board's own snapshot grammar, so a caller outside
|
|
202
|
+
* this file never keeps a second copy of the regex. */
|
|
203
|
+
export function parseStepSubject(subject) {
|
|
204
|
+
const m = SNAPSHOT_RE.exec(String(subject || ""));
|
|
205
|
+
return m ? { base: m[1], step: Number(m[2]) } : null;
|
|
206
|
+
}
|
|
207
|
+
|
|
200
208
|
/** The current state as canonical sorted rows over the domain's dynamic
|
|
201
209
|
* predicates. Prefers the newest @stepN snapshot when one exists, so a
|
|
202
210
|
* re-plan after per-step execution never reads the stale step-0 board. */
|
|
@@ -173,6 +173,10 @@ const isListingRemainder = (rest) => {
|
|
|
173
173
|
return LISTING_TAIL_KINDS.has((words[words.length - 1] || "").toLowerCase());
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
+
// The punctuation set every delimiter-anchored preamble/filler frame in this
|
|
177
|
+
// file treats as a clause boundary.
|
|
178
|
+
const DELIM_SRC = "[,.;:!]|—|–|-";
|
|
179
|
+
|
|
176
180
|
/** Greeting lead-in with a delimiter (+ optional "quick question" bridge):
|
|
177
181
|
* "hey there, quick question - <Q>" -> "<Q>". Delimiter and non-empty
|
|
178
182
|
* remainder are both required, so a bare greeting stays small-talk. */
|
|
@@ -186,7 +190,14 @@ const THANKS_PREAMBLE_RE = /^(?:thanks|thank\s+you|many\s+thanks|thx|ty|cheers)(
|
|
|
186
190
|
* different wording — a throwaway counting aside before the real content,
|
|
187
191
|
* never part of the content itself ("ok, one more, teach me: no server is a
|
|
188
192
|
* client" must peel exactly as "ok cool, <Q>" already does). */
|
|
189
|
-
const
|
|
193
|
+
const ACK_WORDS_SRC = "ok(?:ay)?|aight|cool|alright|sure|right|fine|great|nice|got it|gotcha|sounds good|no worries|no problem|another\\s+one";
|
|
194
|
+
// The counting arm ("one more", "just one more") requires a trailing
|
|
195
|
+
// delimiter, unlike the ack words above — without it, "one more disk rests
|
|
196
|
+
// on peg-a" loses its own quantifier to this frame.
|
|
197
|
+
const ACK_COUNTING_SRC = "(?:just\\s+)?(?:one|another)\\s+more";
|
|
198
|
+
const ACK_PREAMBLE_RE = new RegExp(
|
|
199
|
+
`^(?:(?:${ACK_WORDS_SRC})[\\s,]+|(?:${ACK_COUNTING_SRC})\\s*(?:${DELIM_SRC})\\s*)+(.+)$`, "i",
|
|
200
|
+
);
|
|
190
201
|
/** Self-orientation lead-in with a delimiter — "just poking around, <Q>",
|
|
191
202
|
* "first time using this, <Q>". */
|
|
192
203
|
const BROWSING_PREAMBLE_RE = /^(?:just\s+(?:poking\s+around|looking\s+around|browsing|exploring|checking\s+(?:this|it)\s+out)|first\s+time\s+(?:trying\s+this\s+out|using\s+this|here)|i'?m\s+new\s+(?:here|around\s+here|to\s+(?:this|all\s+this)(?:\s+(?:repo|codebase|project|app|tool|thing))?))\s*[,.—–-]\s*(.+)$/i;
|
|
@@ -342,6 +353,80 @@ export function applyPreambleFrames(text) {
|
|
|
342
353
|
return q;
|
|
343
354
|
}
|
|
344
355
|
|
|
356
|
+
// ---- closed FILLER-CLAUSE prefixes: sentence-initial small talk ahead of a
|
|
357
|
+
// real question, distinct from the PREAMBLE frames above because family B
|
|
358
|
+
// (hesitation + pivot) needs no delimiter — an unconditional peel here would
|
|
359
|
+
// change what every existing normalizeQuery caller sees, so this is exposed
|
|
360
|
+
// as its own function and consumed only where a caller opts in explicitly.
|
|
361
|
+
|
|
362
|
+
const alt = (list) => [...list].sort((a, b) => b.length - a.length).map(escapeRegex).join("|");
|
|
363
|
+
|
|
364
|
+
// Family A — interjection + comment. A delimiter is required: a bare
|
|
365
|
+
// interjection followed by a noun ("oh water") is ordinary content.
|
|
366
|
+
const FILLER_INTERJECTIONS = Object.freeze([
|
|
367
|
+
"oh", "ah", "aha", "ooh", "ohh", "wow", "huh", "hm", "hmm", "mm", "mmm",
|
|
368
|
+
"heh", "ha", "yay", "ugh", "oof", "phew", "whoa", "oops", "yikes", "oi",
|
|
369
|
+
]);
|
|
370
|
+
const FILLER_COMMENT_WORDS = Object.freeze([
|
|
371
|
+
"nice", "cool", "great", "neat", "lovely", "interesting", "good", "ok", "okay",
|
|
372
|
+
"fair enough", "makes sense", "i see", "got it", "fine",
|
|
373
|
+
]);
|
|
374
|
+
|
|
375
|
+
// Family B — hesitation + pivot. Repeatable, delimiter optional. Deliberately
|
|
376
|
+
// excludes "like"/"so"/"now"/"then"/"right"/"ok": those either carry real
|
|
377
|
+
// content ("like what?") or already peel through LEADING_CONNECTIVE_RE /
|
|
378
|
+
// ACK_PREAMBLE_RE, and duplicating them here would give the same word two
|
|
379
|
+
// competing owners.
|
|
380
|
+
const FILLER_HESITATIONS = Object.freeze([
|
|
381
|
+
"um", "umm", "uhm", "uh", "uhh", "er", "err", "erm", "ehm", "eh",
|
|
382
|
+
"well", "anyway", "anyhow", "anyways", "regardless", "moving on",
|
|
383
|
+
]);
|
|
384
|
+
|
|
385
|
+
// Family C — meta-announcement: a self-describing announcement of the
|
|
386
|
+
// question about to come. Delimiter required.
|
|
387
|
+
const FILLER_ANNOUNCEMENTS = Object.freeze([
|
|
388
|
+
"quick question", "quick q", "one quick question", "just a quick question",
|
|
389
|
+
"random question", "random thing", "one more random thing", "another random thing",
|
|
390
|
+
"one more thing", "one last thing", "last thing", "one more question",
|
|
391
|
+
"side note", "side question", "sidebar", "off topic", "unrelated",
|
|
392
|
+
"on a different note", "different topic", "changing the subject", "new topic",
|
|
393
|
+
"just curious", "out of curiosity", "curious", "genuinely curious",
|
|
394
|
+
"while i'm here", "while i have you", "before i forget",
|
|
395
|
+
]);
|
|
396
|
+
|
|
397
|
+
const FILLER_A_SRC = `(?:${alt(FILLER_INTERJECTIONS)})(?:\\s+(?:${alt(FILLER_COMMENT_WORDS)}))?\\s*(?:${DELIM_SRC})\\s*`;
|
|
398
|
+
const FILLER_B_SRC = `(?:${alt(FILLER_HESITATIONS)})\\s*(?:(?:${DELIM_SRC})\\s*|\\s+)`;
|
|
399
|
+
const FILLER_C_SRC = `(?:${alt(FILLER_ANNOUNCEMENTS)})\\s*(?:${DELIM_SRC})\\s*`;
|
|
400
|
+
|
|
401
|
+
// An optional leading "sorry"/"sorry," ahead of any family, once.
|
|
402
|
+
const FILLER_CLAUSE_PREFIX_RE = new RegExp(
|
|
403
|
+
`^(?:sorry\\s*(?:${DELIM_SRC})?\\s*)?(?:${FILLER_A_SRC}|${FILLER_B_SRC}|${FILLER_C_SRC})+`, "i",
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
/** Peel a sentence-initial closed filler clause off `text`. Returns
|
|
407
|
+
* { prefix, remainder } or null when nothing in the closed inventory leads
|
|
408
|
+
* the line. Longest-alternative-first inside each family, so "one more
|
|
409
|
+
* random thing" wins over "one more thing". Pure; no graph, no store. */
|
|
410
|
+
export function fillerClausePrefix(text) {
|
|
411
|
+
const line = String(text || "").trim();
|
|
412
|
+
const m = line.match(FILLER_CLAUSE_PREFIX_RE);
|
|
413
|
+
if (!m || !m[0]) return null;
|
|
414
|
+
const remainder = line.slice(m[0].length).trim();
|
|
415
|
+
if (!remainder) return null; // a bare filler is small talk, not a peel
|
|
416
|
+
return { prefix: m[0].trim(), remainder };
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** QUESTION_LEAD_RE is anchored to the FIRST word, so a closed filler clause
|
|
420
|
+
* in front of a question moves the interrogative off word one and every
|
|
421
|
+
* write gate reads the line as a declarative. Peel once, then re-check the
|
|
422
|
+
* same question underneath. */
|
|
423
|
+
export function leadsInterrogative(text) {
|
|
424
|
+
const line = String(text || "").trim();
|
|
425
|
+
if (QUESTION_LEAD_RE.test(line)) return true;
|
|
426
|
+
const peel = fillerClausePrefix(line);
|
|
427
|
+
return Boolean(peel && QUESTION_LEAD_RE.test(peel.remainder));
|
|
428
|
+
}
|
|
429
|
+
|
|
345
430
|
/** Strippable leading framing clause: "since/[even] though/although/while/
|
|
346
431
|
* because/[even] if/whereas/given that/now that <clause>, <Q>" -> "<Q>".
|
|
347
432
|
* Comma-anchored and non-empty-remainder-required, same discipline as
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// domain/world-snapshot.mjs — the one grammar for a snapshot subject: bare
|
|
2
|
+
// `base@turnN` while a world stays on epoch 0, `base@epochE@turnN` once a
|
|
3
|
+
// recast has moved it on. Pure, no imports — every reader of this grammar
|
|
4
|
+
// (the adventure lane, autoplay, the recognizer) reads it from here instead
|
|
5
|
+
// of keeping its own copy.
|
|
6
|
+
|
|
7
|
+
const SNAPSHOT_RE = /^(.+?)@(?:epoch(\d+)@)?turn(\d+)$/;
|
|
8
|
+
|
|
9
|
+
/** The snapshot subject a turn writes: bare `base@turnN` while the world is
|
|
10
|
+
* on epoch 0, `base@epochE@turnN` once a recast has moved it on. */
|
|
11
|
+
export function snapshotSubject(base, turn, epoch = 0) {
|
|
12
|
+
return epoch > 0 ? `${base}@epoch${epoch}@turn${turn}` : `${base}@turn${turn}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Read a snapshot subject back: `{ base, epoch, turn }`, or null when the
|
|
16
|
+
* subject carries no snapshot stamp (a base row). Pure. */
|
|
17
|
+
export function parseSnapshotSubject(subject) {
|
|
18
|
+
const m = SNAPSHOT_RE.exec(String(subject || ""));
|
|
19
|
+
return m ? { base: m[1], epoch: m[2] ? Number(m[2]) : 0, turn: Number(m[3]) } : null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The base individual a subject names, snapshot-stamped or not. */
|
|
23
|
+
export function baseSubjectOf(subject) {
|
|
24
|
+
return parseSnapshotSubject(subject)?.base ?? subject;
|
|
25
|
+
}
|
|
@@ -26,11 +26,9 @@
|
|
|
26
26
|
// fact simply has nothing for this module to infer a goal toward.
|
|
27
27
|
import { findActionPath } from "../domain/planning.mjs";
|
|
28
28
|
import { loadMemory, readFactRows } from "../adapters/memory/core.mjs";
|
|
29
|
+
import { baseSubjectOf } from "../domain/world-snapshot.mjs";
|
|
29
30
|
import { foldWorldState, adventureTurn, worldActionRows } from "./adventure.mjs";
|
|
30
31
|
|
|
31
|
-
const SNAPSHOT_RE = /^(.+)@turn(\d+)$/;
|
|
32
|
-
const baseSubjectOf = (subject) => SNAPSHOT_RE.exec(subject)?.[1] ?? subject;
|
|
33
|
-
|
|
34
32
|
const isTypedRow = (rows, subject, type) =>
|
|
35
33
|
(rows || []).some((r) => r.subject === subject && r.predicate === "rdf:type" && r.object === type);
|
|
36
34
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// share the slot.
|
|
10
10
|
|
|
11
11
|
import { worldProvenanceTag } from "../domain/worlds-pack.mjs";
|
|
12
|
+
import { parseSnapshotSubject, snapshotSubject } from "../domain/world-snapshot.mjs";
|
|
12
13
|
import { parseImperative, OBJECT_PRONOUNS } from "../domain/grammar/ace.mjs";
|
|
13
14
|
import { loadLexicon, withProperNames, classify } from "../domain/grammar/lexicon.mjs";
|
|
14
15
|
import { register as registerReferent, bind as bindDiscourseForm } from "../domain/discourse.mjs";
|
|
@@ -177,11 +178,6 @@ async function resumedPosition(memoryDir) {
|
|
|
177
178
|
|
|
178
179
|
// ---- the world-state fold ----------------------------------------------------
|
|
179
180
|
|
|
180
|
-
// A snapshot subject is `base@turnN`, or `base@epochE@turnN` once a recast has
|
|
181
|
-
// moved the world past epoch 0 — the fold below reads both, and epoch-0 writes
|
|
182
|
-
// keep the bare form so an unrecast store never changes shape.
|
|
183
|
-
const SNAPSHOT_RE = /^(.+?)@(?:epoch(\d+)@)?turn(\d+)$/;
|
|
184
|
-
|
|
185
181
|
/** Which run of the world a store is on. Recasting a shared world (mud.html's
|
|
186
182
|
* RESET, a slider, the scenario dropdown) reopens the same deterministic
|
|
187
183
|
* instance ids over a fresh store while peers may still hold the old run's
|
|
@@ -199,21 +195,13 @@ export function worldEpochFact(epoch) {
|
|
|
199
195
|
return { subject: WORLD_EPOCH_SUBJECT, predicate: WORLD_EPOCH_PREDICATE, object: String(epoch) };
|
|
200
196
|
}
|
|
201
197
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return m ? { base: m[1], epoch: m[2] ? Number(m[2]) : 0, turn: Number(m[3]) } : null;
|
|
209
|
-
}
|
|
198
|
+
// The snapshot-subject grammar itself (`{ base, epoch, turn }` for a stamped
|
|
199
|
+
// subject, null for a base row) lives in domain/world-snapshot.mjs, the one
|
|
200
|
+
// place every reader — this lane, autoplay, the recognizer — parses it from.
|
|
201
|
+
// Re-exported here so every existing importer of snapshotSubject and
|
|
202
|
+
// parseSnapshotSubject keeps working.
|
|
203
|
+
export { snapshotSubject, parseSnapshotSubject };
|
|
210
204
|
|
|
211
|
-
/** The snapshot subject a turn writes: bare `@turnN` while the world is on
|
|
212
|
-
* epoch 0 (every store that has never been recast, and every fact written
|
|
213
|
-
* before epochs existed), the epoch-stamped form after. */
|
|
214
|
-
export function snapshotSubject(base, turn, epoch = 0) {
|
|
215
|
-
return epoch > 0 ? `${base}@epoch${epoch}@turn${turn}` : `${base}@turn${turn}`;
|
|
216
|
-
}
|
|
217
205
|
const PLACEMENT_PREDICATES = new Set([
|
|
218
206
|
"mgx:currently-in", "mgx:located-in", "mgx:fixed-in", "mgx:stands-locked-in", "mgx:hidden-in",
|
|
219
207
|
]);
|
|
@@ -303,7 +291,7 @@ export function isMudStatePredicate(predicate) {
|
|
|
303
291
|
export function worldIndividualNames(rows) {
|
|
304
292
|
const names = new Set();
|
|
305
293
|
for (const row of rows || []) {
|
|
306
|
-
if (
|
|
294
|
+
if (parseSnapshotSubject(row.subject)) continue;
|
|
307
295
|
if (row.predicate === "rdf:type" || PLACEMENT_PREDICATES.has(row.predicate)) names.add(row.subject);
|
|
308
296
|
if (EXIT_PREDICATE_RE.test(row.predicate)) { names.add(row.subject); names.add(row.object); }
|
|
309
297
|
}
|
|
@@ -332,8 +320,8 @@ export function foldWorldState(factRows) {
|
|
|
332
320
|
if (Number.isInteger(marked) && marked > epoch) epoch = marked;
|
|
333
321
|
continue;
|
|
334
322
|
}
|
|
335
|
-
const
|
|
336
|
-
if (
|
|
323
|
+
const snap = parseSnapshotSubject(row.subject);
|
|
324
|
+
if (snap && snap.epoch > epoch) epoch = snap.epoch;
|
|
337
325
|
}
|
|
338
326
|
const placements = new Map(); // subject -> { predicate, object, turn, epoch }
|
|
339
327
|
const positions = new Map(); // subject -> { predicate, object, turn, epoch }
|
|
@@ -345,11 +333,11 @@ export function foldWorldState(factRows) {
|
|
|
345
333
|
!prior || rowEpoch > prior.epoch || (rowEpoch === prior.epoch && turn >= prior.turn);
|
|
346
334
|
for (const row of rows) {
|
|
347
335
|
if (row.predicate === WORLD_EPOCH_PREDICATE) continue;
|
|
348
|
-
const
|
|
349
|
-
const base =
|
|
350
|
-
const rowEpoch =
|
|
351
|
-
const turn =
|
|
352
|
-
if (
|
|
336
|
+
const snap = parseSnapshotSubject(row.subject);
|
|
337
|
+
const base = snap ? snap.base : row.subject;
|
|
338
|
+
const rowEpoch = snap ? snap.epoch : epoch;
|
|
339
|
+
const turn = snap ? snap.turn : 0;
|
|
340
|
+
if (snap && rowEpoch === epoch) turnCount = Math.max(turnCount, turn);
|
|
353
341
|
if (PLACEMENT_PREDICATES.has(row.predicate)) {
|
|
354
342
|
if (outranks(rowEpoch, turn, placements.get(base))) placements.set(base, { predicate: row.predicate, object: row.object, turn, epoch: rowEpoch });
|
|
355
343
|
continue;
|
|
@@ -369,7 +357,7 @@ export function foldWorldState(factRows) {
|
|
|
369
357
|
continue;
|
|
370
358
|
}
|
|
371
359
|
const exit = EXIT_PREDICATE_RE.exec(row.predicate);
|
|
372
|
-
if (exit && !
|
|
360
|
+
if (exit && !snap) {
|
|
373
361
|
if (!exits.has(row.subject)) exits.set(row.subject, new Map());
|
|
374
362
|
exits.get(row.subject).set(exit[1], row.object);
|
|
375
363
|
}
|
|
@@ -946,7 +934,7 @@ export function worldDigestRows(rows, state, actingSubject = "player") {
|
|
|
946
934
|
.filter(([, place]) => OUT_OF_PLAY_PLACES.has(place.object))
|
|
947
935
|
.map(([subject]) => subject));
|
|
948
936
|
for (const row of rows || []) {
|
|
949
|
-
if (
|
|
937
|
+
if (parseSnapshotSubject(row.subject)) continue; // folded above
|
|
950
938
|
if (gone.has(row.subject)) continue; // out of the world entirely
|
|
951
939
|
// Room text comes from the world source only. A merged corpus overlaps a
|
|
952
940
|
// room's own vocabulary ("library rdfs:subClassOf literary study"), and
|