@polycode-projects/the-mechanical-code-talker 5.0.27 → 5.0.28
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/corpus/worlds/index.json.gz +0 -0
- package/corpus/worlds/manifest.json +27 -17
- package/corpus/worlds/shards/river-crossing.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square-chapel.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square-market.jsonl.gz +0 -0
- package/corpus/worlds/shards/town-square.jsonl.gz +0 -0
- package/corpus/worlds/src/river-crossing.jsonl +29 -0
- package/corpus/worlds/src/town-square-chapel.jsonl +12 -8
- package/corpus/worlds/src/town-square-market.jsonl +12 -8
- package/corpus/worlds/src/town-square.jsonl +12 -8
- package/package.json +1 -1
- package/src/adapters/memory/inspect.mjs +37 -0
- package/src/domain/agent-traits.mjs +282 -0
- package/src/domain/choice-question.mjs +135 -6
- package/src/domain/el-classify.mjs +39 -7
- package/src/domain/fact-phrase.mjs +7 -4
- package/src/domain/interpret/normalize.mjs +58 -2
- package/src/domain/town-square-world.mjs +44 -19
- package/src/services/adventure.mjs +5 -16
- package/src/services/agent-editor.mjs +216 -0
- package/src/services/chat-session.mjs +26 -5
- package/src/services/chat.mjs +118 -58
- package/src/services/mudiii-scene.mjs +32 -5
- package/src/services/mudiii-turn.mjs +7 -3
- package/src/services/mudiii-viz.mjs +215 -1
- package/src/services/predator-prey.mjs +157 -24
- package/src/surfaces/web/chat-browser-entry.mjs +69 -3
- package/src/surfaces/web/memory-ask-browser.bundle.js +155 -155
- package/src/surfaces/web/mudiii-browser-entry.mjs +35 -0
- package/src/surfaces/web/turn-session.mjs +13 -9
|
Binary file
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 1,
|
|
3
3
|
"generated": "by scripts/build-worlds-pack.mjs from corpus/worlds/src/",
|
|
4
4
|
"counts": {
|
|
5
|
-
"worlds":
|
|
6
|
-
"facts":
|
|
7
|
-
"rules":
|
|
5
|
+
"worlds": 11,
|
|
6
|
+
"facts": 3074,
|
|
7
|
+
"rules": 126
|
|
8
8
|
},
|
|
9
9
|
"budgets": {
|
|
10
10
|
"sourceBytesPerWorld": 131072,
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
"bytes": 14345,
|
|
43
43
|
"sha256": "338f8c63ae94e62f9c4fa06e090569b248c3afdd404d3034fc43c8e0dc9d9e39"
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
"file": "src/river-crossing.jsonl",
|
|
47
|
+
"bytes": 3372,
|
|
48
|
+
"sha256": "18ead49c79ff3bc71901bcd00356eaf34aba8a0e36a49df00a4aefd0fa3ca591"
|
|
49
|
+
},
|
|
45
50
|
{
|
|
46
51
|
"file": "src/spider-fly.jsonl",
|
|
47
52
|
"bytes": 53690,
|
|
@@ -49,25 +54,25 @@
|
|
|
49
54
|
},
|
|
50
55
|
{
|
|
51
56
|
"file": "src/town-square-chapel.jsonl",
|
|
52
|
-
"bytes":
|
|
53
|
-
"sha256": "
|
|
57
|
+
"bytes": 108706,
|
|
58
|
+
"sha256": "2c65f103a617c05eb16646ed684632c82b7c525f4ec0589289637b18d7f7b94e"
|
|
54
59
|
},
|
|
55
60
|
{
|
|
56
61
|
"file": "src/town-square-market.jsonl",
|
|
57
|
-
"bytes":
|
|
58
|
-
"sha256": "
|
|
62
|
+
"bytes": 52609,
|
|
63
|
+
"sha256": "791221ace6d03a1cad15c484f6044591716ceabcfbf1936119a2a1aa6297dff8"
|
|
59
64
|
},
|
|
60
65
|
{
|
|
61
66
|
"file": "src/town-square.jsonl",
|
|
62
|
-
"bytes":
|
|
63
|
-
"sha256": "
|
|
67
|
+
"bytes": 75521,
|
|
68
|
+
"sha256": "7a7f87386495285fc0e39f14f10253044f4c5181f7b4fa501a1c88810184950d"
|
|
64
69
|
}
|
|
65
70
|
],
|
|
66
71
|
"files": [
|
|
67
72
|
{
|
|
68
73
|
"file": "index.json.gz",
|
|
69
|
-
"bytes":
|
|
70
|
-
"sha256": "
|
|
74
|
+
"bytes": 173,
|
|
75
|
+
"sha256": "75197e925a6689be361143c3e26523645898b4fcea37c48a3e628f0bc1968ecb"
|
|
71
76
|
},
|
|
72
77
|
{
|
|
73
78
|
"file": "shards/ashcombe-hall.jsonl.gz",
|
|
@@ -99,6 +104,11 @@
|
|
|
99
104
|
"bytes": 1421,
|
|
100
105
|
"sha256": "548d4393a2f73a0202935db7a8d3e4e292406deadff791d0dc111bf3ce591aaa"
|
|
101
106
|
},
|
|
107
|
+
{
|
|
108
|
+
"file": "shards/river-crossing.jsonl.gz",
|
|
109
|
+
"bytes": 496,
|
|
110
|
+
"sha256": "2899d7ad90cb806ad4392be053ed22cf8a5c7eb69d93d947f8d63806abfe5e7d"
|
|
111
|
+
},
|
|
102
112
|
{
|
|
103
113
|
"file": "shards/spider-fly.jsonl.gz",
|
|
104
114
|
"bytes": 3148,
|
|
@@ -106,18 +116,18 @@
|
|
|
106
116
|
},
|
|
107
117
|
{
|
|
108
118
|
"file": "shards/town-square-chapel.jsonl.gz",
|
|
109
|
-
"bytes":
|
|
110
|
-
"sha256": "
|
|
119
|
+
"bytes": 5580,
|
|
120
|
+
"sha256": "46fd19d56e6d6fb64d8b37753b102f7f1dcab41c8729252c8b31cf9df0dc9007"
|
|
111
121
|
},
|
|
112
122
|
{
|
|
113
123
|
"file": "shards/town-square-market.jsonl.gz",
|
|
114
|
-
"bytes":
|
|
115
|
-
"sha256": "
|
|
124
|
+
"bytes": 3154,
|
|
125
|
+
"sha256": "80210037ca9efa40819ee7f76d5c372e60c02bb9a6775fa96eec49391385c80c"
|
|
116
126
|
},
|
|
117
127
|
{
|
|
118
128
|
"file": "shards/town-square.jsonl.gz",
|
|
119
|
-
"bytes":
|
|
120
|
-
"sha256": "
|
|
129
|
+
"bytes": 4319,
|
|
130
|
+
"sha256": "7512ee0418af4bd46d4c005bd8447f56784dc277c9f46b9fe149e967f3eb39c0"
|
|
121
131
|
}
|
|
122
132
|
]
|
|
123
133
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{"world":"river-crossing","kind":"meta","opening":"a farmer stands on the east bank with a fox, a goat and a cabbage. Ferry them all to the west bank — never leave the fox alone with the goat, or the goat alone with the cabbage."}
|
|
2
|
+
{"world":"river-crossing","kind":"fact","subject":"bank-east","predicate":"rdf:type","object":"bank"}
|
|
3
|
+
{"world":"river-crossing","kind":"fact","subject":"bank-west","predicate":"rdf:type","object":"bank"}
|
|
4
|
+
{"world":"river-crossing","kind":"fact","subject":"fox","predicate":"mgx:display-name","object":"fox"}
|
|
5
|
+
{"world":"river-crossing","kind":"fact","subject":"fox","predicate":"mgx:model","object":"fox"}
|
|
6
|
+
{"world":"river-crossing","kind":"fact","subject":"fox","predicate":"mgx:consumes","object":"goat"}
|
|
7
|
+
{"world":"river-crossing","kind":"fact","subject":"goat","predicate":"mgx:display-name","object":"goat"}
|
|
8
|
+
{"world":"river-crossing","kind":"fact","subject":"goat","predicate":"mgx:consumes","object":"cabbage"}
|
|
9
|
+
{"world":"river-crossing","kind":"fact","subject":"goat","predicate":"mgx:evades","object":"fox"}
|
|
10
|
+
{"world":"river-crossing","kind":"fact","subject":"cabbage","predicate":"mgx:display-name","object":"cabbage"}
|
|
11
|
+
{"world":"river-crossing","kind":"fact","subject":"cabbage","predicate":"mgx:evades","object":"goat"}
|
|
12
|
+
{"world":"river-crossing","kind":"fact","subject":"farmer","predicate":"mgx:display-name","object":"farmer"}
|
|
13
|
+
{"world":"river-crossing","kind":"fact","subject":"farmer","predicate":"mgx:guards","object":"fox"}
|
|
14
|
+
{"world":"river-crossing","kind":"fact","subject":"farmer","predicate":"mgx:guards","object":"goat"}
|
|
15
|
+
{"world":"river-crossing","kind":"fact","subject":"fox-1","predicate":"rdf:type","object":"fox"}
|
|
16
|
+
{"world":"river-crossing","kind":"fact","subject":"fox-1","predicate":"rdf:type","object":"passenger"}
|
|
17
|
+
{"world":"river-crossing","kind":"fact","subject":"fox-1","predicate":"mgx:currently-in","object":"bank-east"}
|
|
18
|
+
{"world":"river-crossing","kind":"fact","subject":"goat-1","predicate":"rdf:type","object":"goat"}
|
|
19
|
+
{"world":"river-crossing","kind":"fact","subject":"goat-1","predicate":"rdf:type","object":"passenger"}
|
|
20
|
+
{"world":"river-crossing","kind":"fact","subject":"goat-1","predicate":"mgx:currently-in","object":"bank-east"}
|
|
21
|
+
{"world":"river-crossing","kind":"fact","subject":"cabbage-1","predicate":"rdf:type","object":"cabbage"}
|
|
22
|
+
{"world":"river-crossing","kind":"fact","subject":"cabbage-1","predicate":"rdf:type","object":"passenger"}
|
|
23
|
+
{"world":"river-crossing","kind":"fact","subject":"cabbage-1","predicate":"mgx:currently-in","object":"bank-east"}
|
|
24
|
+
{"world":"river-crossing","kind":"fact","subject":"farmer-1","predicate":"rdf:type","object":"farmer"}
|
|
25
|
+
{"world":"river-crossing","kind":"fact","subject":"farmer-1","predicate":"mgx:currently-in","object":"bank-east"}
|
|
26
|
+
{"world":"river-crossing","kind":"rule","name":"ferry onto","ruleKind":"action-signature","slots":{"subjectClass":"passenger","targetClass":"bank"}}
|
|
27
|
+
{"world":"river-crossing","kind":"rule","name":"ferry onto","ruleKind":"action-signature","slots":{"subjectClass":"farmer","targetClass":"bank"}}
|
|
28
|
+
{"world":"river-crossing","kind":"rule","name":"ferry onto","ruleKind":"action-effect","slots":{"predicate":"currently-in","subjectRole":"subject","objectRole":"target"}}
|
|
29
|
+
{"world":"river-crossing","kind":"rule","name":"ferry onto","ruleKind":"action-effect","slots":{"predicate":"currently-in","subjectRole":"farmer","objectRole":"target"}}
|
|
@@ -912,18 +912,22 @@
|
|
|
912
912
|
{"world":"town-square-chapel","kind":"fact","subject":"square","predicate":"mgx:start-with","object":"2 foxs and 2 goblins by default"}
|
|
913
913
|
{"world":"town-square-chapel","kind":"fact","subject":"square","predicate":"mgx:hasA","object":"limit of 6 goblins and 8 food items at once by default"}
|
|
914
914
|
{"world":"town-square-chapel","kind":"fact","subject":"prop","predicate":"mgx:cover","object":"one cell each, which nothing can walk into"}
|
|
915
|
-
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:
|
|
916
|
-
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:
|
|
917
|
-
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:
|
|
918
|
-
{"world":"town-square-chapel","kind":"fact","subject":"
|
|
919
|
-
{"world":"town-square-chapel","kind":"fact","subject":"
|
|
920
|
-
{"world":"town-square-chapel","kind":"fact","subject":"goblin","predicate":"mgx:
|
|
915
|
+
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:vision-radius","object":"4"}
|
|
916
|
+
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:hasMass","object":"20"}
|
|
917
|
+
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:mass-drain-per-turn","object":"0.08"}
|
|
918
|
+
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:pursues","object":"goblin"}
|
|
919
|
+
{"world":"town-square-chapel","kind":"fact","subject":"fox","predicate":"mgx:consumes","object":"goblin"}
|
|
920
|
+
{"world":"town-square-chapel","kind":"fact","subject":"goblin","predicate":"mgx:vision-radius","object":"3"}
|
|
921
|
+
{"world":"town-square-chapel","kind":"fact","subject":"goblin","predicate":"mgx:hasMass","object":"8"}
|
|
922
|
+
{"world":"town-square-chapel","kind":"fact","subject":"goblin","predicate":"mgx:mass-drain-per-turn","object":"0.06"}
|
|
923
|
+
{"world":"town-square-chapel","kind":"fact","subject":"goblin","predicate":"mgx:consumes","object":"crumb"}
|
|
924
|
+
{"world":"town-square-chapel","kind":"fact","subject":"goblin","predicate":"mgx:consumes","object":"morsel"}
|
|
921
925
|
{"world":"town-square-chapel","kind":"fact","subject":"goblin","predicate":"mgx:arrive","object":"every 5 turns at the edge of the board by default"}
|
|
922
926
|
{"world":"town-square-chapel","kind":"fact","subject":"crumb","predicate":"mgx:arrive","object":"every 3 turns on any open cell by default"}
|
|
923
927
|
{"world":"town-square-chapel","kind":"fact","subject":"crumb","predicate":"mgx:start-with","object":"mass 2 by default"}
|
|
924
928
|
{"world":"town-square-chapel","kind":"fact","subject":"morsel","predicate":"mgx:start-with","object":"mass 2 by default"}
|
|
925
929
|
{"world":"town-square-chapel","kind":"fact","subject":"morsel","predicate":"mgx:arrive","object":"where the player puts it"}
|
|
926
|
-
{"world":"town-square-chapel","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"4 cells for the fox
|
|
927
|
-
{"world":"town-square-chapel","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"3 cells for the goblin
|
|
930
|
+
{"world":"town-square-chapel","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"4 cells for the fox"}
|
|
931
|
+
{"world":"town-square-chapel","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"3 cells for the goblin"}
|
|
928
932
|
{"world":"town-square-chapel","kind":"rule","name":"go","ruleKind":"action-signature","slots":{"subjectClass":"animal","targetClass":"cell"}}
|
|
929
933
|
{"world":"town-square-chapel","kind":"rule","name":"go","ruleKind":"action-effect","slots":{"predicate":"currently-in","subjectRole":"subject","objectRole":"target"}}
|
|
@@ -438,18 +438,22 @@
|
|
|
438
438
|
{"world":"town-square-market","kind":"fact","subject":"square","predicate":"mgx:start-with","object":"1 fox and 4 goblins by default"}
|
|
439
439
|
{"world":"town-square-market","kind":"fact","subject":"square","predicate":"mgx:hasA","object":"limit of 6 goblins and 8 food items at once by default"}
|
|
440
440
|
{"world":"town-square-market","kind":"fact","subject":"prop","predicate":"mgx:cover","object":"one cell each, which nothing can walk into"}
|
|
441
|
-
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:
|
|
442
|
-
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:
|
|
443
|
-
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:
|
|
444
|
-
{"world":"town-square-market","kind":"fact","subject":"
|
|
445
|
-
{"world":"town-square-market","kind":"fact","subject":"
|
|
446
|
-
{"world":"town-square-market","kind":"fact","subject":"goblin","predicate":"mgx:
|
|
441
|
+
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:vision-radius","object":"4"}
|
|
442
|
+
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:hasMass","object":"20"}
|
|
443
|
+
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:mass-drain-per-turn","object":"0.08"}
|
|
444
|
+
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:pursues","object":"goblin"}
|
|
445
|
+
{"world":"town-square-market","kind":"fact","subject":"fox","predicate":"mgx:consumes","object":"goblin"}
|
|
446
|
+
{"world":"town-square-market","kind":"fact","subject":"goblin","predicate":"mgx:vision-radius","object":"3"}
|
|
447
|
+
{"world":"town-square-market","kind":"fact","subject":"goblin","predicate":"mgx:hasMass","object":"8"}
|
|
448
|
+
{"world":"town-square-market","kind":"fact","subject":"goblin","predicate":"mgx:mass-drain-per-turn","object":"0.06"}
|
|
449
|
+
{"world":"town-square-market","kind":"fact","subject":"goblin","predicate":"mgx:consumes","object":"crumb"}
|
|
450
|
+
{"world":"town-square-market","kind":"fact","subject":"goblin","predicate":"mgx:consumes","object":"morsel"}
|
|
447
451
|
{"world":"town-square-market","kind":"fact","subject":"goblin","predicate":"mgx:arrive","object":"every 5 turns at the edge of the board by default"}
|
|
448
452
|
{"world":"town-square-market","kind":"fact","subject":"crumb","predicate":"mgx:arrive","object":"every 3 turns on any open cell by default"}
|
|
449
453
|
{"world":"town-square-market","kind":"fact","subject":"crumb","predicate":"mgx:start-with","object":"mass 2 by default"}
|
|
450
454
|
{"world":"town-square-market","kind":"fact","subject":"morsel","predicate":"mgx:start-with","object":"mass 2 by default"}
|
|
451
455
|
{"world":"town-square-market","kind":"fact","subject":"morsel","predicate":"mgx:arrive","object":"where the player puts it"}
|
|
452
|
-
{"world":"town-square-market","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"4 cells for the fox
|
|
453
|
-
{"world":"town-square-market","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"3 cells for the goblin
|
|
456
|
+
{"world":"town-square-market","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"4 cells for the fox"}
|
|
457
|
+
{"world":"town-square-market","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"3 cells for the goblin"}
|
|
454
458
|
{"world":"town-square-market","kind":"rule","name":"go","ruleKind":"action-signature","slots":{"subjectClass":"animal","targetClass":"cell"}}
|
|
455
459
|
{"world":"town-square-market","kind":"rule","name":"go","ruleKind":"action-effect","slots":{"predicate":"currently-in","subjectRole":"subject","objectRole":"target"}}
|
|
@@ -670,18 +670,22 @@
|
|
|
670
670
|
{"world":"town-square","kind":"fact","subject":"square","predicate":"mgx:start-with","object":"1 fox and 3 goblins by default"}
|
|
671
671
|
{"world":"town-square","kind":"fact","subject":"square","predicate":"mgx:hasA","object":"limit of 6 goblins and 8 food items at once by default"}
|
|
672
672
|
{"world":"town-square","kind":"fact","subject":"prop","predicate":"mgx:cover","object":"one cell each, which nothing can walk into"}
|
|
673
|
-
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:
|
|
674
|
-
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:
|
|
675
|
-
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:
|
|
676
|
-
{"world":"town-square","kind":"fact","subject":"
|
|
677
|
-
{"world":"town-square","kind":"fact","subject":"
|
|
678
|
-
{"world":"town-square","kind":"fact","subject":"goblin","predicate":"mgx:
|
|
673
|
+
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:vision-radius","object":"4"}
|
|
674
|
+
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:hasMass","object":"20"}
|
|
675
|
+
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:mass-drain-per-turn","object":"0.08"}
|
|
676
|
+
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:pursues","object":"goblin"}
|
|
677
|
+
{"world":"town-square","kind":"fact","subject":"fox","predicate":"mgx:consumes","object":"goblin"}
|
|
678
|
+
{"world":"town-square","kind":"fact","subject":"goblin","predicate":"mgx:vision-radius","object":"3"}
|
|
679
|
+
{"world":"town-square","kind":"fact","subject":"goblin","predicate":"mgx:hasMass","object":"8"}
|
|
680
|
+
{"world":"town-square","kind":"fact","subject":"goblin","predicate":"mgx:mass-drain-per-turn","object":"0.06"}
|
|
681
|
+
{"world":"town-square","kind":"fact","subject":"goblin","predicate":"mgx:consumes","object":"crumb"}
|
|
682
|
+
{"world":"town-square","kind":"fact","subject":"goblin","predicate":"mgx:consumes","object":"morsel"}
|
|
679
683
|
{"world":"town-square","kind":"fact","subject":"goblin","predicate":"mgx:arrive","object":"every 5 turns at the edge of the board by default"}
|
|
680
684
|
{"world":"town-square","kind":"fact","subject":"crumb","predicate":"mgx:arrive","object":"every 3 turns on any open cell by default"}
|
|
681
685
|
{"world":"town-square","kind":"fact","subject":"crumb","predicate":"mgx:start-with","object":"mass 2 by default"}
|
|
682
686
|
{"world":"town-square","kind":"fact","subject":"morsel","predicate":"mgx:start-with","object":"mass 2 by default"}
|
|
683
687
|
{"world":"town-square","kind":"fact","subject":"morsel","predicate":"mgx:arrive","object":"where the player puts it"}
|
|
684
|
-
{"world":"town-square","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"4 cells for the fox
|
|
685
|
-
{"world":"town-square","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"3 cells for the goblin
|
|
688
|
+
{"world":"town-square","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"4 cells for the fox"}
|
|
689
|
+
{"world":"town-square","kind":"fact","subject":"vision radius","predicate":"mgx:hasProperty","object":"3 cells for the goblin"}
|
|
686
690
|
{"world":"town-square","kind":"rule","name":"go","ruleKind":"action-signature","slots":{"subjectClass":"animal","targetClass":"cell"}}
|
|
687
691
|
{"world":"town-square","kind":"rule","name":"go","ruleKind":"action-effect","slots":{"predicate":"currently-in","subjectRole":"subject","objectRole":"target"}}
|
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.28",
|
|
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.",
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import { loadMemory, UTTERANCE_CLASS, IN_REPLY_TO_PROP, readFactRows, findContradictions } from "./core.mjs";
|
|
7
7
|
import { loadBlockIndex } from "./blocks.mjs";
|
|
8
|
+
import { buildTableauKb, findTableauViolations } from "../../domain/tableau.mjs";
|
|
9
|
+
import { elUnsatisfiableClasses } from "../../domain/el-classify.mjs";
|
|
10
|
+
|
|
11
|
+
// A store-wide audit checks every individual/class the store names, so its
|
|
12
|
+
// budgets stay well under /prove's own per-question defaults (tableau.mjs's
|
|
13
|
+
// DEFAULT_PROVE_STEPS etc.) — the cost here is per-subject, not per-turn.
|
|
14
|
+
const CONSISTENCY_TABLEAU_OPTS = { maxSteps: 200, maxBranches: 16, maxNodes: 32 };
|
|
15
|
+
const CONSISTENCY_EL_OPTS = { budget: 500, rounds: 16 };
|
|
8
16
|
|
|
9
17
|
/** Log-scaled sample count for a class of `n` individuals: 2·log10(n), floored
|
|
10
18
|
* at 3, never more than n (10,000 → 8; 500 → 5; 3 → 3; 1 → 1). Verbose doubles. */
|
|
@@ -94,6 +102,35 @@ export function renderMemory({ memory, blocks }, { verbose = false } = {}) {
|
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
|
|
105
|
+
// ---- wider consistency findings: a DL tableau clash (a cardinality
|
|
106
|
+
// clash, E5's own flagship, or any other clash the ALC-through-
|
|
107
|
+
// SHOIQ tableau derives) and an EL-saturation-proved unsatisfiable
|
|
108
|
+
// class, surfaced BESIDE the contradictions above rather than
|
|
109
|
+
// folded into them — findConsistencyViolations only reads type,
|
|
110
|
+
// subclass and disjointness edges, so neither shape sits inside
|
|
111
|
+
// its own check. Both read-only; a budget-exhausted subject is
|
|
112
|
+
// simply absent rather than counted as a clean bill. ----
|
|
113
|
+
const consistencyRows = readFactRows(memory);
|
|
114
|
+
const consistencyKb = buildTableauKb(consistencyRows);
|
|
115
|
+
const tableauFindings = findTableauViolations(consistencyKb, null, CONSISTENCY_TABLEAU_OPTS);
|
|
116
|
+
const elFindings = elUnsatisfiableClasses(consistencyRows, CONSISTENCY_EL_OPTS);
|
|
117
|
+
const consistencyById = new Map(consistencyRows.map((r) => [r.id, r]));
|
|
118
|
+
const renderPremises = (ids) => (ids || [])
|
|
119
|
+
.map((id) => consistencyById.get(id))
|
|
120
|
+
.filter(Boolean)
|
|
121
|
+
.map((r) => truncate(`${r.subject} ${r.predicate} ${r.object}`, textCap))
|
|
122
|
+
.join("; ");
|
|
123
|
+
if (tableauFindings.length || elFindings.unsatisfiable.length) {
|
|
124
|
+
const total = tableauFindings.length + elFindings.unsatisfiable.length;
|
|
125
|
+
lines.push("", `consistency findings (${total} — a DL/EL check beside the contradictions above):`);
|
|
126
|
+
for (const f of tableauFindings.slice(0, verbose ? 8 : 3)) {
|
|
127
|
+
lines.push(` ${f.subject} is inconsistent: ${renderPremises(f.premises)}`);
|
|
128
|
+
}
|
|
129
|
+
for (const cls of elFindings.unsatisfiable.slice(0, verbose ? 8 : 3)) {
|
|
130
|
+
lines.push(` ${cls} can never have any members: ${renderPremises(elFindings.premisesOf(cls))}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
97
134
|
// ---- recent Q→A pairs (off the inReplyTo edges) ----
|
|
98
135
|
const byId = new Map(individuals.map((i) => [i.id, i]));
|
|
99
136
|
const replyGroup = (memory.objectProperties || []).find((g) => g?.prop === IN_REPLY_TO_PROP);
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// agent-traits.mjs — what drives an agent class or instance, read from rows
|
|
2
|
+
// alone: display name, avatar, mass, drain per turn, vision radius, whether
|
|
3
|
+
// it is marked a predator, and the classes it pursues, evades, consumes and
|
|
4
|
+
// guards. One instance's own rows override its class; a class with nothing
|
|
5
|
+
// stated has no drive, never a JS-invented default.
|
|
6
|
+
//
|
|
7
|
+
// The chain walk itself (classChainOf) is the same breadth-first walk
|
|
8
|
+
// src/services/adventure.mjs's objectClassChain already performs over
|
|
9
|
+
// rdf:type/rdfs:subClassOf, lifted here so the two callers — the adventure
|
|
10
|
+
// lane's mass-drain read and this module's trait resolver — share one walk
|
|
11
|
+
// instead of drifting apart. adventure.mjs imports it back down (services
|
|
12
|
+
// may import domain) and applies its own world-row filter before calling it;
|
|
13
|
+
// this module makes no such filter, since a domain module reads whatever
|
|
14
|
+
// rows it is given.
|
|
15
|
+
//
|
|
16
|
+
// Every list this module returns is sorted in codepoint order before it is
|
|
17
|
+
// returned, and every resolver here is a pure function of the row SET, never
|
|
18
|
+
// of the order the rows arrived in — the same rule p2p-room.mjs's
|
|
19
|
+
// sortFactIndividualsById holds for a merged fact store, so two callers who
|
|
20
|
+
// built the same rows in different orders never read a different answer.
|
|
21
|
+
|
|
22
|
+
/** Every predicate a spawn copies from a class onto an instance, and that the
|
|
23
|
+
* resolver reads back off the class chain. Sorted, frozen, closed: a
|
|
24
|
+
* predicate not on this list is world state, not an imperative, and a spawn
|
|
25
|
+
* leaves it alone. */
|
|
26
|
+
export const AGENT_TRAIT_PREDICATES = Object.freeze([
|
|
27
|
+
"mgx:consumes",
|
|
28
|
+
"mgx:display-name",
|
|
29
|
+
"mgx:evades",
|
|
30
|
+
"mgx:guards",
|
|
31
|
+
"mgx:hasMass",
|
|
32
|
+
"mgx:is-predator",
|
|
33
|
+
"mgx:mass-drain-per-turn",
|
|
34
|
+
"mgx:model",
|
|
35
|
+
"mgx:pursues",
|
|
36
|
+
"mgx:vision-radius",
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
/** The subset of AGENT_TRAIT_PREDICATES that read as a set of rows rather
|
|
40
|
+
* than a single value: every row on the nearest chain link that declares
|
|
41
|
+
* any, not just the first. */
|
|
42
|
+
export const AGENT_TRAIT_MULTI = Object.freeze(new Set([
|
|
43
|
+
"mgx:consumes",
|
|
44
|
+
"mgx:evades",
|
|
45
|
+
"mgx:guards",
|
|
46
|
+
"mgx:pursues",
|
|
47
|
+
]));
|
|
48
|
+
|
|
49
|
+
const objectsOf = (rows, subject, predicate) =>
|
|
50
|
+
(rows || []).filter((r) => r.subject === subject && r.predicate === predicate).map((r) => r.object);
|
|
51
|
+
|
|
52
|
+
const sortedUnique = (values) => [...new Set(values)].sort();
|
|
53
|
+
|
|
54
|
+
/** `subject`'s own class chain, nearest first, starting with `subject`
|
|
55
|
+
* itself: a breadth-first walk over its rdf:type and rdfs:subClassOf rows.
|
|
56
|
+
* A cycle stops the walk rather than looping. Pure — reads exactly the rows
|
|
57
|
+
* it is given, with no provenance filter of its own. */
|
|
58
|
+
export function classChainOf(rows, subject) {
|
|
59
|
+
const parentsOf = (node) => (rows || [])
|
|
60
|
+
.filter((r) => r.subject === node && (r.predicate === "rdf:type" || r.predicate === "rdfs:subClassOf"))
|
|
61
|
+
.map((r) => r.object);
|
|
62
|
+
const seen = new Set([subject]);
|
|
63
|
+
const chain = [subject];
|
|
64
|
+
const queue = [...parentsOf(subject)];
|
|
65
|
+
while (queue.length) {
|
|
66
|
+
const node = queue.shift();
|
|
67
|
+
if (seen.has(node)) continue;
|
|
68
|
+
seen.add(node);
|
|
69
|
+
chain.push(node);
|
|
70
|
+
queue.push(...parentsOf(node));
|
|
71
|
+
}
|
|
72
|
+
return chain;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The single declared value of `predicate` on `subject`'s own class chain,
|
|
76
|
+
* nearest first — an instance's own row wins over its class's. Null when no
|
|
77
|
+
* chain link declares one, which reads as "nobody has said anything about
|
|
78
|
+
* this yet", never as an invented default. When a single node writes more
|
|
79
|
+
* than one value for the same predicate (an ill-formed world), the choice
|
|
80
|
+
* is the sorted-first value, so the answer never depends on which order the
|
|
81
|
+
* rows arrived in. Pure. */
|
|
82
|
+
export function traitValueOf(rows, subject, predicate) {
|
|
83
|
+
for (const node of classChainOf(rows, subject)) {
|
|
84
|
+
const values = objectsOf(rows, node, predicate);
|
|
85
|
+
if (values.length) return sortedUnique(values)[0];
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Every declared value of `predicate` on the FIRST chain link (nearest
|
|
91
|
+
* first) that declares any, sorted and deduped — so an instance's own
|
|
92
|
+
* `mgx:evades` row replaces its class's set rather than adding to it. Empty
|
|
93
|
+
* when no chain link declares one. Pure. */
|
|
94
|
+
export function traitValuesOf(rows, subject, predicate) {
|
|
95
|
+
for (const node of classChainOf(rows, subject)) {
|
|
96
|
+
const values = objectsOf(rows, node, predicate);
|
|
97
|
+
if (values.length) return sortedUnique(values);
|
|
98
|
+
}
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Which chain link answered `traitValueOf`/`traitValuesOf` for this
|
|
103
|
+
* predicate: `"instance"` when `subject` itself declares it, the class name
|
|
104
|
+
* that declares it otherwise, or `null` when no chain link does. Pure. */
|
|
105
|
+
export function traitOriginOf(rows, subject, predicate) {
|
|
106
|
+
const chain = classChainOf(rows, subject);
|
|
107
|
+
for (const node of chain) {
|
|
108
|
+
if (objectsOf(rows, node, predicate).length) return node === subject ? "instance" : node;
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const numberOrNull = (value) => {
|
|
114
|
+
if (value === null) return null;
|
|
115
|
+
const n = Number(value);
|
|
116
|
+
return Number.isFinite(n) ? n : null;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** Every trait `subject` reads off its own class chain, flat and fully
|
|
120
|
+
* populated so no caller has to remember which key is a list. `classes` is
|
|
121
|
+
* the chain of ancestor class names, nearest first, excluding `subject`
|
|
122
|
+
* itself. A trait nobody declared reads as `null` (single-valued) or `[]`
|
|
123
|
+
* (multi-valued), never as a JS-side default. Pure. */
|
|
124
|
+
export function agentTraitsOf(rows, subject) {
|
|
125
|
+
return {
|
|
126
|
+
subject,
|
|
127
|
+
classes: classChainOf(rows, subject).slice(1),
|
|
128
|
+
displayName: traitValueOf(rows, subject, "mgx:display-name"),
|
|
129
|
+
model: traitValueOf(rows, subject, "mgx:model"),
|
|
130
|
+
mass: numberOrNull(traitValueOf(rows, subject, "mgx:hasMass")),
|
|
131
|
+
massDrainPerTurn: numberOrNull(traitValueOf(rows, subject, "mgx:mass-drain-per-turn")),
|
|
132
|
+
visionRadius: numberOrNull(traitValueOf(rows, subject, "mgx:vision-radius")),
|
|
133
|
+
isPredator: traitValueOf(rows, subject, "mgx:is-predator") === "true",
|
|
134
|
+
pursues: traitValuesOf(rows, subject, "mgx:pursues"),
|
|
135
|
+
evades: traitValuesOf(rows, subject, "mgx:evades"),
|
|
136
|
+
consumes: traitValuesOf(rows, subject, "mgx:consumes"),
|
|
137
|
+
guards: traitValuesOf(rows, subject, "mgx:guards"),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** `className`'s own trait rows — the rows a class-tab editor renders for
|
|
142
|
+
* that class alone, never an ancestor's. Sorted by (predicate, object).
|
|
143
|
+
* Pure. */
|
|
144
|
+
export function classFactRowsFor(rows, className) {
|
|
145
|
+
return (rows || [])
|
|
146
|
+
.filter((r) => r.subject === className && AGENT_TRAIT_PREDICATES.includes(r.predicate))
|
|
147
|
+
.map((r) => ({ subject: r.subject, predicate: r.predicate, object: r.object }))
|
|
148
|
+
.sort(compareRows);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function compareRows(a, b) {
|
|
152
|
+
if (a.predicate !== b.predicate) return a.predicate < b.predicate ? -1 : 1;
|
|
153
|
+
if (a.object !== b.object) return a.object < b.object ? -1 : 1;
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const DRIVE_PREDICATES = Object.freeze(["mgx:consumes", "mgx:evades", "mgx:pursues"]);
|
|
158
|
+
|
|
159
|
+
/** Whether any row states a drive (`mgx:pursues`, `mgx:evades` or
|
|
160
|
+
* `mgx:consumes`). A world that states none is a world whose cast is still
|
|
161
|
+
* driven by its injected roles object and config numbers alone. Pure. */
|
|
162
|
+
export function rowsDeclareDrives(rows) {
|
|
163
|
+
return (rows || []).some((r) => DRIVE_PREDICATES.includes(r.predicate));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The class an appetite belongs to: the consuming subject's own bare
|
|
167
|
+
* `rdf:type` class when it is an instance, otherwise the subject itself. */
|
|
168
|
+
function consumerClassOf(rows, subject) {
|
|
169
|
+
const typed = (rows || []).find((r) => r.subject === subject && r.predicate === "rdf:type");
|
|
170
|
+
return typed ? typed.object : subject;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The class names `subject` moves away from: its own chain's `mgx:evades`
|
|
174
|
+
* rows when any are declared, otherwise the inverse of `mgx:consumes` —
|
|
175
|
+
* every class whose members declare an appetite for a class on `subject`'s
|
|
176
|
+
* own chain. The inverse is what keeps a prey fleeing its eater without the
|
|
177
|
+
* world stating the fear twice; a declared `mgx:evades` set replaces it
|
|
178
|
+
* entirely, so one instance can be taught a different fear (or a fear of
|
|
179
|
+
* something absent) without inheriting the derived one back. Sorted. Pure. */
|
|
180
|
+
export function fearedClassesOf(rows, subject) {
|
|
181
|
+
const declared = traitValuesOf(rows, subject, "mgx:evades");
|
|
182
|
+
if (declared.length) return declared;
|
|
183
|
+
const chain = new Set(classChainOf(rows, subject));
|
|
184
|
+
const consumers = new Set();
|
|
185
|
+
for (const row of rows || []) {
|
|
186
|
+
if (row.predicate !== "mgx:consumes" || !chain.has(row.object)) continue;
|
|
187
|
+
consumers.add(consumerClassOf(rows, row.subject));
|
|
188
|
+
}
|
|
189
|
+
return [...consumers].sort();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** The cast a world's own rows state, in the `{ predator, prey, food }` shape
|
|
193
|
+
* the town-square engine's `roles` parameter already takes. A predator class
|
|
194
|
+
* is one whose declared `mgx:pursues`/`mgx:consumes` names another class that
|
|
195
|
+
* itself declares a drive; the prey class is the one it names. `fallback`
|
|
196
|
+
* fills whatever the rows say nothing about — the food kinds always come
|
|
197
|
+
* from it, since a spawned and a placed food differ by who put them there,
|
|
198
|
+
* which no trait row states. Null when the rows state no cast at all and no
|
|
199
|
+
* fallback was given. Sorted-first on ties, so two row orders build the same
|
|
200
|
+
* cast. Pure. */
|
|
201
|
+
export function castFromFacts(rows, { fallback = null } = {}) {
|
|
202
|
+
const driveSubjects = new Set(
|
|
203
|
+
(rows || []).filter((r) => DRIVE_PREDICATES.includes(r.predicate)).map((r) => r.subject),
|
|
204
|
+
);
|
|
205
|
+
const driveClasses = new Set([...driveSubjects].map((s) => consumerClassOf(rows, s)));
|
|
206
|
+
let predatorKind = null;
|
|
207
|
+
let preyKind = null;
|
|
208
|
+
for (const kind of [...driveClasses].sort()) {
|
|
209
|
+
const targets = [...traitValuesOf(rows, kind, "mgx:pursues"), ...traitValuesOf(rows, kind, "mgx:consumes")]
|
|
210
|
+
.filter((target) => target !== kind && driveClasses.has(target))
|
|
211
|
+
.sort();
|
|
212
|
+
if (targets.length) { predatorKind = kind; preyKind = targets[0]; break; }
|
|
213
|
+
}
|
|
214
|
+
if (!predatorKind) return fallback;
|
|
215
|
+
return {
|
|
216
|
+
predator: { role: "predator", kind: predatorKind, idPrefix: predatorKind, hunts: preyKind ? "prey" : null },
|
|
217
|
+
prey: preyKind
|
|
218
|
+
? { role: "prey", kind: preyKind, idPrefix: preyKind, hunts: null }
|
|
219
|
+
: (fallback?.prey ?? null),
|
|
220
|
+
food: fallback?.food ?? null,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const compareConstraints = (a, b) => {
|
|
225
|
+
if (a.left !== b.left) return a.left < b.left ? -1 : 1;
|
|
226
|
+
if (a.right !== b.right) return a.right < b.right ? -1 : 1;
|
|
227
|
+
if (a.guard !== b.guard) return a.guard < b.guard ? -1 : 1;
|
|
228
|
+
return 0;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/** The action-constraint slot sets a world's own drive facts imply, in the
|
|
232
|
+
* `{ left, right, guard }` shape src/domain/domain.mjs compiles: for every
|
|
233
|
+
* `X mgx:consumes Y` row, every `Z mgx:guards X` row yields a constraint
|
|
234
|
+
* saying X and Y may not share a place unless Z is there too — the farmer
|
|
235
|
+
* guarding the wolf's own appetite, not the goat it threatens. A consumes
|
|
236
|
+
* pair with no guard row yields no constraint, which is why the town
|
|
237
|
+
* square (the fox eats goblins and nobody guards anything) states none.
|
|
238
|
+
* Sorted by (left, right, guard) and deduped, so a fact set that states
|
|
239
|
+
* the same guard twice, or in either row order, yields one constraint
|
|
240
|
+
* list. Pure. */
|
|
241
|
+
export function constraintsFromDrives(rows) {
|
|
242
|
+
const guardsOfConsumer = new Map();
|
|
243
|
+
for (const row of rows || []) {
|
|
244
|
+
if (row.predicate !== "mgx:guards") continue;
|
|
245
|
+
if (!guardsOfConsumer.has(row.object)) guardsOfConsumer.set(row.object, new Set());
|
|
246
|
+
guardsOfConsumer.get(row.object).add(row.subject);
|
|
247
|
+
}
|
|
248
|
+
const seen = new Set();
|
|
249
|
+
const out = [];
|
|
250
|
+
for (const row of rows || []) {
|
|
251
|
+
if (row.predicate !== "mgx:consumes") continue;
|
|
252
|
+
for (const guard of guardsOfConsumer.get(row.subject) || []) {
|
|
253
|
+
const key = `${row.subject}\0${row.object}\0${guard}`;
|
|
254
|
+
if (seen.has(key)) continue;
|
|
255
|
+
seen.add(key);
|
|
256
|
+
out.push({ left: row.subject, right: row.object, guard });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return out.sort(compareConstraints);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** The instance's own rows for a fresh spawn of `className`: one row per
|
|
263
|
+
* trait `className`'s own class chain declares, subject rewritten to
|
|
264
|
+
* `instanceId`, plus the `rdf:type` row. Sorted by (predicate, object) so
|
|
265
|
+
* two callers building the same spawn build the same list. Returns rows, it
|
|
266
|
+
* does not write them — the caller appends them through `appendFacts`,
|
|
267
|
+
* whose content-addressed ids make a second spawn of the same instance a
|
|
268
|
+
* no-op rather than a duplicate. Pure. */
|
|
269
|
+
export function instanceFactsFrom(rows, className, instanceId) {
|
|
270
|
+
const out = [{ subject: instanceId, predicate: "rdf:type", object: className }];
|
|
271
|
+
for (const predicate of AGENT_TRAIT_PREDICATES) {
|
|
272
|
+
if (AGENT_TRAIT_MULTI.has(predicate)) {
|
|
273
|
+
for (const object of traitValuesOf(rows, className, predicate)) {
|
|
274
|
+
out.push({ subject: instanceId, predicate, object });
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
const value = traitValueOf(rows, className, predicate);
|
|
278
|
+
if (value !== null) out.push({ subject: instanceId, predicate, object: value });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return out.sort(compareRows);
|
|
282
|
+
}
|