@myclaw163/clawclaw-cli 0.7.16 → 0.8.2
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/QUICKSTART_HERMES.md +1 -1
- package/QUICKSTART_OPENCLAW.md +3 -11
- package/QUICKSTART_OTHER.md +8 -8
- package/README.md +18 -9
- package/bin/clawclaw-channel.mjs +13 -0
- package/docs/configuration.md +86 -33
- package/docs/custom-modules/README.md +148 -0
- package/docs/custom-modules/api-reference.md +767 -0
- package/docs/custom-modules/behavior.md +318 -0
- package/docs/custom-modules/perception.md +305 -0
- package/docs/custom-modules/trigger.md +292 -0
- package/docs/desktop-event-push.md +6 -4
- package/docs/runtime/README.md +28 -10
- package/docs/runtime/agent-notifications.md +48 -29
- package/docs/runtime/behavior-runtime.md +139 -0
- package/docs/runtime/components-and-boundaries.md +89 -173
- package/docs/runtime/events-and-state.md +55 -66
- package/docs/runtime/official-perception-modules.md +17 -9
- package/docs/runtime/owner-lifecycle-and-observability.md +62 -39
- package/docs/runtime/perception-replay.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +35 -37
- package/package.json +10 -7
- package/scripts/check-skill-command-surface.mjs +54 -10
- package/scripts/compare-perception-replays.test.ts +10 -10
- package/scripts/compare-perception-replays.ts +14 -10
- package/scripts/replay-perception.ts +3 -3
- package/scripts/watch-perception-events.test.ts +1 -1
- package/skills/clawclaw/SKILL.md +97 -59
- package/skills/clawclaw/references/BEHAVIORS.md +154 -0
- package/skills/clawclaw/references/CHANNELS.md +115 -0
- package/skills/clawclaw/references/CHATTERBOX.md +3 -2
- package/skills/clawclaw/references/COMMANDS.md +108 -58
- package/skills/clawclaw/references/GAME-MECHANICS.md +4 -3
- package/skills/clawclaw/references/HUB.md +27 -23
- package/skills/clawclaw/references/STREAM.md +18 -14
- package/skills/clawclaw/references/TACTICS.md +2 -2
- package/src/behaviors/official-finite/do-task.ts +141 -0
- package/src/behaviors/official-finite/evade.ts +78 -0
- package/src/behaviors/official-finite/find-player.ts +50 -0
- package/src/behaviors/official-finite/follow-player.ts +70 -0
- package/src/behaviors/official-finite/go-to.ts +69 -0
- package/src/behaviors/official-finite/hide-temporarily.ts +77 -0
- package/src/behaviors/official-finite/hold-position.ts +48 -0
- package/src/behaviors/official-finite/hunt-player.ts +47 -0
- package/src/behaviors/official-finite/index.test.ts +202 -0
- package/src/behaviors/official-finite/index.ts +47 -0
- package/src/behaviors/official-finite/inspect-corpse.ts +64 -0
- package/src/behaviors/official-finite/patrol-area.ts +80 -0
- package/src/behaviors/official-finite/report-corpse.ts +73 -0
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +152 -0
- package/src/behaviors/official-finite/shared.ts +27 -0
- package/src/behaviors/official-finite/trigger-alarm.ts +53 -0
- package/src/channel/claude-channel-ipc-server.ts +295 -0
- package/src/channel/claude-channel-ipc.ts +152 -0
- package/src/channel/claude-channel-server.test.ts +202 -0
- package/src/channel/claude-channel-server.ts +221 -0
- package/src/cli.ts +4 -2
- package/src/commands/account.test.ts +17 -17
- package/src/commands/behavior.test.ts +158 -0
- package/src/commands/behavior.ts +443 -0
- package/src/commands/communication.test.ts +12 -0
- package/src/commands/communication.ts +6 -3
- package/src/commands/data.test.ts +1 -1
- package/src/commands/data.ts +1 -1
- package/src/commands/events-canonical-state.test.ts +221 -2
- package/src/commands/events.ts +205 -12
- package/src/commands/game/index.test.ts +172 -3
- package/src/commands/game/index.ts +69 -32
- package/src/commands/hub.test.ts +25 -14
- package/src/commands/hub.ts +15 -19
- package/src/commands/load.test.ts +228 -6
- package/src/commands/load.ts +102 -18
- package/src/commands/memory.ts +1 -1
- package/src/commands/peek.ts +1 -1
- package/src/commands/perception.test.ts +30 -1
- package/src/commands/perception.ts +15 -17
- package/src/commands/trigger.test.ts +140 -0
- package/src/commands/trigger.ts +314 -0
- package/src/lib/account-guidance.test.ts +4 -0
- package/src/lib/account-guidance.ts +1 -1
- package/src/lib/behavior-export.test.ts +282 -0
- package/src/lib/behavior-export.ts +514 -0
- package/src/lib/game-client.test.ts +4 -17
- package/src/lib/game-client.ts +1 -0
- package/src/lib/gameplay-config.test.ts +258 -37
- package/src/lib/gameplay-config.ts +175 -35
- package/src/lib/hub-install.test.ts +19 -41
- package/src/lib/hub-install.ts +10 -38
- package/src/lib/hub-reminder.ts +7 -9
- package/src/lib/init-command.ts +1 -1
- package/src/lib/official-resource-sync.test.ts +199 -0
- package/src/lib/official-resource-sync.ts +221 -0
- package/src/lib/perception-config.test.ts +9 -4
- package/src/lib/perception-config.ts +10 -13
- package/src/lib/perception-export.test.ts +145 -0
- package/src/lib/perception-export.ts +178 -0
- package/src/lib/trigger-config.test.ts +102 -0
- package/src/lib/trigger-config.ts +217 -0
- package/src/lib/user-data.test.ts +23 -6
- package/src/lib/user-data.ts +15 -123
- package/src/pipeline/canonical-event-presentation.test.ts +5 -5
- package/src/pipeline/canonical-event-presentation.ts +13 -5
- package/src/pipeline/event-format.test.ts +106 -3
- package/src/pipeline/event-format.ts +172 -4
- package/src/pipeline/event-hints.test.ts +57 -4
- package/src/pipeline/event-hints.ts +34 -8
- package/src/runtime/canonical-monitor.test.ts +2 -0
- package/src/runtime/canonical-monitor.ts +6 -2
- package/src/runtime/clawclaw/agent-event-policy.test.ts +23 -2
- package/src/runtime/clawclaw/agent-event-policy.ts +12 -5
- package/src/runtime/clawclaw/behavior-decision.test.ts +29 -0
- package/src/runtime/clawclaw/behavior-decision.ts +82 -0
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +175 -0
- package/src/runtime/clawclaw/behavior-input-fields.ts +270 -0
- package/src/runtime/clawclaw/behavior-input.test.ts +151 -0
- package/src/runtime/clawclaw/behavior-input.ts +70 -0
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +59 -0
- package/src/runtime/clawclaw/behavior-observation-memory.ts +142 -0
- package/src/runtime/clawclaw/behavior-read-api.test.ts +123 -0
- package/src/runtime/clawclaw/behavior-read-api.ts +158 -0
- package/src/runtime/clawclaw/{plugins/perception/visual-state-projector.ts → observation-frame-projector.ts} +44 -25
- package/src/runtime/clawclaw/owner.test.ts +187 -0
- package/src/runtime/clawclaw/owner.ts +431 -69
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +304 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +285 -41
- package/src/runtime/clawclaw/plugins/action/automated-action-normalization.ts +82 -0
- package/src/runtime/clawclaw/plugins/assembly.test.ts +135 -29
- package/src/runtime/clawclaw/plugins/assembly.ts +54 -28
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +468 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +40 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.ts +30 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +152 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +156 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +104 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-manifest.ts +173 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +182 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.ts +223 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +157 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +848 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +1347 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +212 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +174 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +621 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +195 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +180 -0
- package/src/runtime/clawclaw/plugins/behavior/index.ts +11 -0
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +766 -0
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +283 -0
- package/src/runtime/clawclaw/plugins/{strategy/thread-strategy-executor.ts → behavior/thread-behavior-executor.ts} +109 -121
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +80 -0
- package/src/runtime/clawclaw/plugins/behavior-input-source.ts +247 -0
- package/src/runtime/clawclaw/plugins/{strategy → game-query}/context-capabilities.ts +1 -1
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +13 -10
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +26 -14
- package/src/runtime/clawclaw/plugins/game-query/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/index.ts +3 -1
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +239 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +100 -0
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +346 -0
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +230 -12
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +118 -90
- package/src/runtime/clawclaw/plugins/mailbox/consumer-ids.ts +5 -0
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +3 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +1 -1
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +4 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +87 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +70 -12
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +94 -11
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +1229 -345
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +479 -35
- package/src/runtime/clawclaw/plugins/perception/contracts.ts +4 -3
- package/src/runtime/clawclaw/plugins/perception/index.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +23 -13
- package/src/runtime/clawclaw/plugins/perception/module-runner.ts +11 -9
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +39 -38
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +92 -0
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +248 -0
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +39 -37
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +22 -21
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +15 -9
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +3 -3
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +33 -18
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +22 -16
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +6 -7
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +18 -12
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +14 -10
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +20 -14
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +5 -6
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +49 -34
- package/src/runtime/clawclaw/plugins/perception/official-module-ids.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +126 -20
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +24 -3
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +59 -46
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +27 -5
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +381 -49
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +267 -245
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +98 -0
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +89 -16
- package/src/runtime/clawclaw/plugins/perception/perception-test-fixtures.ts +34 -0
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +27 -15
- package/src/runtime/clawclaw/plugins/perception/replay.ts +10 -5
- package/src/runtime/clawclaw/plugins/perception/shared/math.ts +1 -107
- package/src/runtime/clawclaw/plugins/perception/spatial-facts.ts +7 -10
- package/src/runtime/clawclaw/plugins/plugin-api-version.ts +112 -0
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +388 -559
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +56 -5
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.ts +135 -26
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +249 -16
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +99 -2
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +212 -0
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.ts +259 -0
- package/src/runtime/clawclaw/plugins/trigger/contracts.ts +97 -0
- package/src/runtime/clawclaw/plugins/trigger/index.ts +4 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +118 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +548 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +655 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +169 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.ts +457 -0
- package/src/runtime/clawclaw/runtime.ts +8 -0
- package/src/runtime/clawclaw/spatial-api.ts +76 -0
- package/src/runtime/clawclaw-event-catalog.test.ts +46 -1
- package/src/runtime/clawclaw-event-catalog.ts +40 -3
- package/src/runtime/framework/capability-registry.test.ts +196 -55
- package/src/runtime/framework/capability-registry.ts +99 -17
- package/src/runtime/framework/contracts.ts +30 -4
- package/src/runtime/framework/control/control-scheduler.ts +13 -5
- package/src/runtime/framework/control/types.ts +11 -4
- package/src/runtime/framework/control-coordinator.test.ts +95 -80
- package/src/runtime/framework/events/event-delivery-service.ts +4 -2
- package/src/runtime/framework/events/event-ingress.test.ts +25 -0
- package/src/runtime/framework/events/event-ingress.ts +2 -1
- package/src/runtime/framework/events/event-repository.ts +24 -2
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +124 -8
- package/src/runtime/framework/events/memory-event-repository.ts +92 -28
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +604 -2
- package/src/runtime/framework/events/sqlite-event-repository.ts +531 -21
- package/src/runtime/framework/events/types.ts +24 -8
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +38 -1
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +233 -7
- package/src/runtime/framework/modules/runtime-module-loader.ts +69 -4
- package/src/runtime/framework/plugins/contracts.ts +12 -18
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +81 -71
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +38 -20
- package/src/runtime/framework/runtime.ts +20 -23
- package/src/runtime/host-monitor-rate-gate.test.ts +73 -0
- package/src/runtime/host-monitor-rate-gate.ts +123 -0
- package/src/runtime/mailbox-host-relay.test.ts +45 -0
- package/src/runtime/mailbox-host-relay.ts +25 -0
- package/src/runtime/observability/factory.ts +4 -4
- package/src/runtime/observability/observability.test.ts +25 -3
- package/src/runtime/observability/reporter.ts +1 -1
- package/src/runtime/observability/types.ts +2 -2
- package/src/runtime/owner-control.ts +10 -2
- package/src/runtime/runtime-logger.test.ts +1 -1
- package/src/runtime/runtime-logger.ts +4 -6
- package/src/runtime/runtime.test.ts +88 -22
- package/src/sdk/action.ts +2 -2
- package/src/sdk/behavior-plugin/index.test.ts +74 -0
- package/src/sdk/behavior-plugin/index.ts +335 -0
- package/src/sdk/behavior-toolkit/corpse-search.ts +87 -0
- package/src/sdk/behavior-toolkit/escape.ts +40 -0
- package/src/sdk/behavior-toolkit/index.ts +7 -0
- package/src/sdk/behavior-toolkit/kill-flow.ts +299 -0
- package/src/sdk/behavior-toolkit/model.ts +263 -0
- package/src/sdk/behavior-toolkit/move-gate.ts +52 -0
- package/src/sdk/behavior-toolkit/patrol.ts +53 -0
- package/src/sdk/behavior-toolkit/search.ts +102 -0
- package/src/sdk/index.test.ts +45 -0
- package/src/sdk/index.ts +67 -73
- package/src/sdk/module-input/index.test.ts +49 -0
- package/src/sdk/module-input/index.ts +229 -0
- package/src/sdk/perception-plugin/index.test.ts +2 -2
- package/src/sdk/perception-plugin/index.ts +51 -142
- package/src/sdk/perception-plugin/math.ts +107 -0
- package/src/sdk/trigger-plugin/index.test.ts +41 -0
- package/src/sdk/trigger-plugin/index.ts +128 -0
- package/src/strategies/avoid-lone.ts +21 -10
- package/src/strategies/avoid-players.ts +26 -16
- package/src/strategies/corpse-patrol.ts +25 -14
- package/src/strategies/crab-sabotage.ts +20 -9
- package/src/strategies/find-player.ts +33 -21
- package/src/strategies/game-utils.ts +1 -1
- package/src/strategies/goals/crab-sabotage-top.test.ts +145 -0
- package/src/strategies/goals/crab-sabotage-top.ts +32 -69
- package/src/strategies/hide.ts +25 -15
- package/src/strategies/kill-frenzy.ts +21 -10
- package/src/strategies/kill-lone.ts +27 -17
- package/src/strategies/kill-target.ts +33 -22
- package/src/strategies/lone-kill-task.ts +20 -9
- package/src/strategies/move-room.ts +29 -18
- package/src/strategies/official-long-behavior.test.ts +89 -0
- package/src/strategies/paradise-fish.ts +29 -18
- package/src/strategies/pathfind/astar-path.test.ts +127 -2
- package/src/strategies/pathfind/astar-path.ts +136 -26
- package/src/strategies/patrol.ts +21 -10
- package/src/strategies/player-targets.test.ts +10 -0
- package/src/strategies/player-targets.ts +13 -0
- package/src/strategies/report-patrol.ts +21 -10
- package/src/strategies/shrimp-memory.ts +30 -19
- package/src/strategies/social-task.ts +34 -23
- package/src/strategies/task-kill-report.ts +33 -22
- package/src/strategies/task-only.test.ts +99 -85
- package/src/strategies/task-only.ts +23 -12
- package/src/strategies/task-report.ts +25 -14
- package/src/strategies/types.ts +8 -8
- package/src/strategies/warrior-memory.ts +29 -19
- package/docs/runtime/strategy-runtime.md +0 -111
- package/docs//350/207/252/345/256/232/344/271/211/346/204/237/347/237/245.md +0 -502
- package/docs//350/207/252/345/256/232/344/271/211/347/255/226/347/225/245.md +0 -395
- package/skills/clawclaw/references/STRATEGIES.md +0 -76
- package/src/commands/strategy.test.ts +0 -209
- package/src/commands/strategy.ts +0 -242
- package/src/lib/strategy-export.test.ts +0 -406
- package/src/lib/strategy-export.ts +0 -381
- package/src/runtime/clawclaw/plugins/perception/official-modules.ts +0 -31
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.test.ts +0 -177
- package/src/runtime/clawclaw/plugins/strategy/examples/task-only-strategy.ts +0 -191
- package/src/runtime/clawclaw/plugins/strategy/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/strategy/local-strategy-executor.ts +0 -412
- package/src/runtime/clawclaw/plugins/strategy/strategy-action.ts +0 -80
- package/src/runtime/clawclaw/plugins/strategy/strategy-analysis-thread-host.ts +0 -183
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor-types.ts +0 -29
- package/src/runtime/clawclaw/plugins/strategy/strategy-executor.test.ts +0 -693
- package/src/runtime/clawclaw/plugins/strategy/strategy-game-api.ts +0 -57
- package/src/runtime/clawclaw/plugins/strategy/strategy-module-loader.ts +0 -168
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.test.ts +0 -2175
- package/src/runtime/clawclaw/plugins/strategy/strategy-plugin.ts +0 -1774
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.test.ts +0 -153
- package/src/runtime/clawclaw/plugins/strategy/strategy-source.ts +0 -443
- package/src/sdk/strategy-plugin/index.test.ts +0 -958
- package/src/sdk/strategy-plugin/index.ts +0 -1350
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { syncOfficialPerceptions } from '../../../../lib/perception-export.js';
|
|
5
6
|
import { createClawclawEventCatalog } from '../../../clawclaw-event-catalog.js';
|
|
6
7
|
import { MemoryEventRepository } from '../../../framework/events/index.js';
|
|
7
8
|
import type {
|
|
@@ -15,8 +16,8 @@ import {
|
|
|
15
16
|
CLAWCLAW_PERCEPTION_PLUGIN_ID,
|
|
16
17
|
ClawclawPerceptionPlugin,
|
|
17
18
|
} from './perception-plugin.js';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
19
|
+
import { ImportedLocalPerceptionModuleRunner } from './module-runner.js';
|
|
20
|
+
import { ObservationFrameProjector } from '../../observation-frame-projector.js';
|
|
20
21
|
|
|
21
22
|
function stored(
|
|
22
23
|
frameSeq: number,
|
|
@@ -68,6 +69,16 @@ function stateAt(tick: number, sevenX: number, nineX?: number) {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
const replayPlugins = new Set<ClawclawPerceptionPlugin>();
|
|
72
|
+
const officialWorkspace = mkdtempSync(join(tmpdir(), 'ccl-perception-official-'));
|
|
73
|
+
|
|
74
|
+
beforeAll(async () => {
|
|
75
|
+
await syncOfficialPerceptions({ workspaceDir: officialWorkspace });
|
|
76
|
+
vi.stubEnv('CLAWCLAW_WORKSPACE_DIR', officialWorkspace);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
afterAll(() => {
|
|
80
|
+
rmSync(officialWorkspace, { recursive: true, force: true });
|
|
81
|
+
});
|
|
71
82
|
|
|
72
83
|
function pluginFor(id: string) {
|
|
73
84
|
const plugin = new ClawclawPerceptionPlugin({ modules: [id] });
|
|
@@ -78,6 +89,7 @@ function pluginFor(id: string) {
|
|
|
78
89
|
afterEach(async () => {
|
|
79
90
|
await Promise.allSettled([...replayPlugins].map((plugin) => plugin.stopForReplay()));
|
|
80
91
|
replayPlugins.clear();
|
|
92
|
+
vi.stubEnv('CLAWCLAW_WORKSPACE_DIR', officialWorkspace);
|
|
81
93
|
});
|
|
82
94
|
|
|
83
95
|
const journals = new WeakMap<
|
|
@@ -114,7 +126,6 @@ function pluginContext(
|
|
|
114
126
|
provideAction: () => { throw new Error('unused'); },
|
|
115
127
|
queryObservation: () => Promise.reject(new Error('unused')),
|
|
116
128
|
performAction: () => Promise.reject(new Error('unused')),
|
|
117
|
-
releaseActionCaller: () => {},
|
|
118
129
|
},
|
|
119
130
|
diagnostic,
|
|
120
131
|
signal: new AbortController().signal,
|
|
@@ -201,6 +212,195 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
201
212
|
});
|
|
202
213
|
});
|
|
203
214
|
|
|
215
|
+
it('isolates attributed and unattributed Worker startup failures while healthy modules stay active', async () => {
|
|
216
|
+
const root = mkdtempSync(join(tmpdir(), 'ccl-perception-start-isolation-'));
|
|
217
|
+
const perceptions = join(root, 'user-data', 'perceptions');
|
|
218
|
+
mkdirSync(perceptions, { recursive: true });
|
|
219
|
+
writeFileSync(join(perceptions, 'bad-start.ts'), `
|
|
220
|
+
import { ClawclawPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
221
|
+
throw new Error('expected_runner_start_failure');
|
|
222
|
+
export default class BadStart extends ClawclawPerception {
|
|
223
|
+
static manifest = {
|
|
224
|
+
apiVersion: 2,
|
|
225
|
+
id: 'visual.bad_start', name: 'Bad start', description: 'Fails during direct import.',
|
|
226
|
+
subjectScope: 'others', produces: ['visual.bad_start'],
|
|
227
|
+
};
|
|
228
|
+
update() { return []; }
|
|
229
|
+
}
|
|
230
|
+
`, 'utf8');
|
|
231
|
+
writeFileSync(join(perceptions, 'worker-bad-start.ts'), `
|
|
232
|
+
import { isMainThread } from 'node:worker_threads';
|
|
233
|
+
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
234
|
+
if (!isMainThread) throw new Error('expected_worker_start_failure');
|
|
235
|
+
export default class WorkerBadStart extends ClawclawParallelPerception {
|
|
236
|
+
static manifest = {
|
|
237
|
+
apiVersion: 2,
|
|
238
|
+
id: 'visual.worker_bad_start', name: 'Worker bad start',
|
|
239
|
+
description: 'Loads on the owner thread but fails in a Worker.',
|
|
240
|
+
subjectScope: 'others', produces: ['visual.worker_bad_start'],
|
|
241
|
+
execution: 'parallel_analysis',
|
|
242
|
+
};
|
|
243
|
+
analyze(input) { return { frame_seq: input.frame.frameSeq }; }
|
|
244
|
+
commit() { return []; }
|
|
245
|
+
}
|
|
246
|
+
`, 'utf8');
|
|
247
|
+
writeFileSync(join(perceptions, 'worker-exit-start.ts'), `
|
|
248
|
+
import { isMainThread } from 'node:worker_threads';
|
|
249
|
+
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
250
|
+
if (!isMainThread) process.exit(23);
|
|
251
|
+
export default class WorkerExitStart extends ClawclawParallelPerception {
|
|
252
|
+
static manifest = {
|
|
253
|
+
apiVersion: 2,
|
|
254
|
+
id: 'visual.worker_exit_start', name: 'Worker exit start',
|
|
255
|
+
description: 'Exits before the Worker can attribute its startup failure.',
|
|
256
|
+
subjectScope: 'others', produces: ['visual.worker_exit_start'],
|
|
257
|
+
execution: 'parallel_analysis',
|
|
258
|
+
};
|
|
259
|
+
analyze(input) { return { frame_seq: input.frame.frameSeq }; }
|
|
260
|
+
commit() { return []; }
|
|
261
|
+
}
|
|
262
|
+
`, 'utf8');
|
|
263
|
+
writeFileSync(join(perceptions, 'healthy-start.ts'), `
|
|
264
|
+
import { ClawclawPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
265
|
+
export default class HealthyStart extends ClawclawPerception {
|
|
266
|
+
static manifest = {
|
|
267
|
+
apiVersion: 2,
|
|
268
|
+
id: 'visual.healthy_start', name: 'Healthy start',
|
|
269
|
+
description: 'Keeps ordered perception alive when peers fail.',
|
|
270
|
+
subjectScope: 'others', produces: ['visual.healthy_start'],
|
|
271
|
+
};
|
|
272
|
+
updates = 0;
|
|
273
|
+
update(frame) {
|
|
274
|
+
this.updates += 1;
|
|
275
|
+
return [{
|
|
276
|
+
type: 'visual.healthy_start', dedupeKey: 'healthy-start:' + frame.frameSeq,
|
|
277
|
+
payload: { frame_seq: frame.frameSeq, updates: this.updates },
|
|
278
|
+
}];
|
|
279
|
+
}
|
|
280
|
+
debugSnapshot() { return { updates: this.updates }; }
|
|
281
|
+
}
|
|
282
|
+
`, 'utf8');
|
|
283
|
+
await syncOfficialPerceptions({ workspaceDir: root });
|
|
284
|
+
const plugin = new ClawclawPerceptionPlugin({
|
|
285
|
+
modules: [
|
|
286
|
+
'visual.bad_start',
|
|
287
|
+
'visual.worker_bad_start',
|
|
288
|
+
'visual.worker_exit_start',
|
|
289
|
+
'visual.healthy_start',
|
|
290
|
+
'visual.visibility',
|
|
291
|
+
],
|
|
292
|
+
workspaceDir: root,
|
|
293
|
+
});
|
|
294
|
+
const diagnostics: Array<{
|
|
295
|
+
name: string;
|
|
296
|
+
attributes?: Readonly<Record<string, unknown>>;
|
|
297
|
+
}> = [];
|
|
298
|
+
const firstStored = stored(1, 1, stateAt(1, 900));
|
|
299
|
+
const context = pluginContext(
|
|
300
|
+
plugin,
|
|
301
|
+
firstStored.scope,
|
|
302
|
+
0,
|
|
303
|
+
undefined,
|
|
304
|
+
(name, attributes) => diagnostics.push({ name, attributes }),
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
await expect(plugin.start(context)).resolves.toBeUndefined();
|
|
309
|
+
expect(plugin.moduleDescriptors().map(({ id }) => id)).toEqual([
|
|
310
|
+
'visual.healthy_start',
|
|
311
|
+
'visual.visibility',
|
|
312
|
+
]);
|
|
313
|
+
expect(plugin.localizedModuleDescriptors('en-US').map(({ id }) => id))
|
|
314
|
+
.toEqual(['visual.healthy_start', 'visual.visibility']);
|
|
315
|
+
expect(plugin.moduleStateSnapshot()).toMatchObject({
|
|
316
|
+
'visual.healthy_start': { updates: 0 },
|
|
317
|
+
'visual.visibility': {
|
|
318
|
+
previous_tick: null,
|
|
319
|
+
visible_player_ids: [],
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
expect((plugin as any).analysisPool.snapshot()).toMatchObject({
|
|
323
|
+
state: 'running',
|
|
324
|
+
workerCount: 2,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
const failures = diagnostics.filter(({ name }) => name === 'perception.module.failed');
|
|
328
|
+
expect(failures).toEqual(expect.arrayContaining([
|
|
329
|
+
expect.objectContaining({
|
|
330
|
+
attributes: expect.objectContaining({
|
|
331
|
+
module_id: 'visual.bad_start',
|
|
332
|
+
operation: 'start',
|
|
333
|
+
}),
|
|
334
|
+
}),
|
|
335
|
+
expect.objectContaining({
|
|
336
|
+
attributes: expect.objectContaining({
|
|
337
|
+
module_id: 'visual.worker_bad_start',
|
|
338
|
+
operation: 'worker_start',
|
|
339
|
+
}),
|
|
340
|
+
}),
|
|
341
|
+
expect.objectContaining({
|
|
342
|
+
attributes: expect.objectContaining({
|
|
343
|
+
module_id: 'visual.worker_exit_start',
|
|
344
|
+
operation: 'worker_start',
|
|
345
|
+
}),
|
|
346
|
+
}),
|
|
347
|
+
]));
|
|
348
|
+
|
|
349
|
+
const persisted = journals.get(plugin)!.appendStateFrame(firstStored).frame;
|
|
350
|
+
const input = epochInput(persisted);
|
|
351
|
+
const committed = await plugin.commit(input, await plugin.update(input, context), context);
|
|
352
|
+
expect(committed.events).toEqual([
|
|
353
|
+
expect.objectContaining({
|
|
354
|
+
type: 'visual.healthy_start',
|
|
355
|
+
payload: { frame_seq: 1, updates: 1 },
|
|
356
|
+
}),
|
|
357
|
+
]);
|
|
358
|
+
const second = journals.get(plugin)!.appendStateFrame(
|
|
359
|
+
stored(2, 2, stateAt(2, 906, 840)),
|
|
360
|
+
).frame;
|
|
361
|
+
const secondInput = epochInput(second);
|
|
362
|
+
await plugin.commit(secondInput, await plugin.update(secondInput, context), context);
|
|
363
|
+
const third = journals.get(plugin)!.appendStateFrame(
|
|
364
|
+
stored(3, 3, stateAt(3, 912, 846)),
|
|
365
|
+
).frame;
|
|
366
|
+
const thirdInput = epochInput(third);
|
|
367
|
+
const thirdCommit = await plugin.commit(
|
|
368
|
+
thirdInput,
|
|
369
|
+
await plugin.update(thirdInput, context),
|
|
370
|
+
context,
|
|
371
|
+
);
|
|
372
|
+
expect(thirdCommit.events).toEqual(expect.arrayContaining([
|
|
373
|
+
expect.objectContaining({ type: 'visual.healthy_start' }),
|
|
374
|
+
expect.objectContaining({ type: 'visual.player_entered' }),
|
|
375
|
+
]));
|
|
376
|
+
expect(plugin.moduleStateSnapshot()).toMatchObject({
|
|
377
|
+
'visual.healthy_start': { updates: 3 },
|
|
378
|
+
'visual.visibility': { previous_tick: 3 },
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
await plugin.stopForReplay();
|
|
382
|
+
expect(plugin.moduleDescriptors()).toEqual([]);
|
|
383
|
+
expect(plugin.moduleStateSnapshot()).toEqual({});
|
|
384
|
+
|
|
385
|
+
await expect(plugin.start(context)).resolves.toBeUndefined();
|
|
386
|
+
expect(plugin.moduleDescriptors().map(({ id }) => id)).toEqual([
|
|
387
|
+
'visual.healthy_start',
|
|
388
|
+
'visual.visibility',
|
|
389
|
+
]);
|
|
390
|
+
expect(plugin.moduleStateSnapshot()).toMatchObject({
|
|
391
|
+
'visual.healthy_start': { updates: 0 },
|
|
392
|
+
'visual.visibility': { previous_tick: null },
|
|
393
|
+
});
|
|
394
|
+
expect((plugin as any).analysisPool.snapshot()).toMatchObject({
|
|
395
|
+
state: 'running',
|
|
396
|
+
workerCount: 2,
|
|
397
|
+
});
|
|
398
|
+
} finally {
|
|
399
|
+
await plugin.stopForReplay();
|
|
400
|
+
rmSync(root, { recursive: true, force: true });
|
|
401
|
+
}
|
|
402
|
+
}, 20_000);
|
|
403
|
+
|
|
204
404
|
it('caps the Runtime in-flight perception window at ten', () => {
|
|
205
405
|
expect(() => new ClawclawPerceptionPlugin({ maxBackfillVisualFrames: 11 }))
|
|
206
406
|
.toThrow('maxBackfillVisualFrames must be an integer between 1 and 10');
|
|
@@ -213,6 +413,11 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
213
413
|
expect(official.catchUp).toBe('every_epoch');
|
|
214
414
|
});
|
|
215
415
|
|
|
416
|
+
it('exposes a separate recovery deadline', () => {
|
|
417
|
+
const plugin = new ClawclawPerceptionPlugin({ modules: ['visual.motion'] });
|
|
418
|
+
expect(plugin.recoveryTimeoutMs).toBe(30_000);
|
|
419
|
+
});
|
|
420
|
+
|
|
216
421
|
it('aggregates every perception module duration into a compact lifecycle timing window', async () => {
|
|
217
422
|
const plugin = new ClawclawPerceptionPlugin({
|
|
218
423
|
modules: ['visual.visibility', 'visual.motion'],
|
|
@@ -264,15 +469,25 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
264
469
|
});
|
|
265
470
|
|
|
266
471
|
it('projects self and visible players into one explicitly marked visual set', () => {
|
|
267
|
-
const visual = new
|
|
268
|
-
expect(visual?.
|
|
472
|
+
const visual = new ObservationFrameProjector().project(stored(1, 10, stateAt(10, 900)));
|
|
473
|
+
expect(visual?.gameState).toMatchObject({
|
|
474
|
+
tick: 10,
|
|
475
|
+
you: { player: { seat: 1, name: 'Observer' } },
|
|
476
|
+
});
|
|
477
|
+
expect(visual?.observation.players).toEqual(expect.arrayContaining([
|
|
269
478
|
expect.objectContaining({ seat: 1, observer: true }),
|
|
270
479
|
expect.objectContaining({ seat: 7, observer: false }),
|
|
271
480
|
]));
|
|
481
|
+
expect(visual?.observation.visibleSetComplete).toBe(true);
|
|
482
|
+
expect(visual).not.toHaveProperty('players');
|
|
483
|
+
expect(visual).not.toHaveProperty('corpses');
|
|
484
|
+
expect(visual).not.toHaveProperty('visibleSetComplete');
|
|
485
|
+
expect(visual).not.toHaveProperty('phase');
|
|
486
|
+
expect(visual).not.toHaveProperty('provenance');
|
|
272
487
|
});
|
|
273
488
|
|
|
274
489
|
it('uses packaged map geometry as the only room authority', () => {
|
|
275
|
-
const visual = new
|
|
490
|
+
const visual = new ObservationFrameProjector().project(stored(1, 10, {
|
|
276
491
|
players: [{ seat: 1, name: 'Observer', known_status: { is_alive: true } }],
|
|
277
492
|
you: {
|
|
278
493
|
player: { seat: 1, name: 'Observer' },
|
|
@@ -285,11 +500,11 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
285
500
|
visible_corpses: [],
|
|
286
501
|
}));
|
|
287
502
|
|
|
288
|
-
expect(visual?.players[0]?.room).toBeNull();
|
|
503
|
+
expect(visual?.observation.players[0]?.room).toBeNull();
|
|
289
504
|
});
|
|
290
505
|
|
|
291
506
|
it('projects v2 visible_corpses and rejects legacy flat visual identities', () => {
|
|
292
|
-
const projector = new
|
|
507
|
+
const projector = new ObservationFrameProjector();
|
|
293
508
|
const visual = projector.project(stored(1, 10, {
|
|
294
509
|
players: [
|
|
295
510
|
{ seat: 1, name: 'Observer', known_status: { is_alive: true } },
|
|
@@ -304,6 +519,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
304
519
|
},
|
|
305
520
|
visible_players: [],
|
|
306
521
|
visible_corpses: [{
|
|
522
|
+
corpse_id: 'body-7',
|
|
307
523
|
player: { seat: 7, name: 'Seven' },
|
|
308
524
|
x: 900,
|
|
309
525
|
y: 2200,
|
|
@@ -311,24 +527,60 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
311
527
|
distance: 140,
|
|
312
528
|
}],
|
|
313
529
|
}));
|
|
314
|
-
expect(visual?.corpses).toEqual([expect.objectContaining({
|
|
315
|
-
id: 'corpse:7',
|
|
530
|
+
expect(visual?.observation.corpses).toEqual([expect.objectContaining({
|
|
531
|
+
id: 'corpse:body-7',
|
|
316
532
|
playerId: 'seat:7',
|
|
317
533
|
name: 'Seven',
|
|
318
534
|
seat: 7,
|
|
319
535
|
})]);
|
|
320
536
|
|
|
321
|
-
|
|
537
|
+
const anonymous = projector.project(stored(2, 11, {
|
|
538
|
+
players: [{ seat: 1, name: 'Observer', known_status: { is_alive: true } }],
|
|
539
|
+
you: {
|
|
540
|
+
player: { seat: 1, name: 'Observer' },
|
|
541
|
+
x: 760,
|
|
542
|
+
y: 2200,
|
|
543
|
+
is_alive: true,
|
|
544
|
+
},
|
|
545
|
+
visible_players: [],
|
|
546
|
+
visible_corpses: [{
|
|
547
|
+
corpse_id: 'anonymous-body',
|
|
548
|
+
x: 900,
|
|
549
|
+
y: 2200,
|
|
550
|
+
room: '导航仓',
|
|
551
|
+
}],
|
|
552
|
+
}))?.observation.corpses[0];
|
|
553
|
+
expect(anonymous).toMatchObject({
|
|
554
|
+
id: 'corpse:anonymous-body',
|
|
555
|
+
});
|
|
556
|
+
expect(anonymous).not.toHaveProperty('name');
|
|
557
|
+
expect(anonymous).not.toHaveProperty('seat');
|
|
558
|
+
|
|
559
|
+
expect(projector.project(stored(3, 12, {
|
|
322
560
|
you: { name: 'Observer', seat: 1, x: 760, y: 2200, is_alive: true },
|
|
323
561
|
visible_players: [{ name: 'Seven', seat: 7, x: 900, y: 2200 }],
|
|
324
562
|
nearby_corpses: [{ name: 'Seven', seat: 7, x: 900, y: 2200 }],
|
|
325
563
|
}))).toBeNull();
|
|
326
564
|
});
|
|
327
565
|
|
|
328
|
-
it('
|
|
566
|
+
it('marks the visual set complete only when both player and corpse sets are present', () => {
|
|
567
|
+
const visual = new ObservationFrameProjector().project(stored(1, 10, {
|
|
568
|
+
you: {
|
|
569
|
+
player: { seat: 1, name: 'Observer' },
|
|
570
|
+
x: 760,
|
|
571
|
+
y: 2200,
|
|
572
|
+
is_alive: true,
|
|
573
|
+
},
|
|
574
|
+
visible_players: [],
|
|
575
|
+
}));
|
|
576
|
+
|
|
577
|
+
expect(visual?.observation.visibleSetComplete).toBe(false);
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
it('hosts all materialized official modules through the shared source runner and preserves subject scopes', () => {
|
|
329
581
|
const plugin = new ClawclawPerceptionPlugin();
|
|
330
582
|
expect(plugin.id).toBe(CLAWCLAW_PERCEPTION_PLUGIN_ID);
|
|
331
|
-
expect(plugin.moduleDescriptors()).toHaveLength(
|
|
583
|
+
expect(plugin.moduleDescriptors()).toHaveLength(8);
|
|
332
584
|
expect(new Set(plugin.moduleDescriptors().map((module) => module.pluginId))).toEqual(
|
|
333
585
|
new Set([CLAWCLAW_PERCEPTION_PLUGIN_ID]),
|
|
334
586
|
);
|
|
@@ -337,10 +589,11 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
337
589
|
&& module.boundaryBaseline === 'current_only'
|
|
338
590
|
))).toBe(true);
|
|
339
591
|
expect((plugin as any).modules.every(({ runner }: any) => (
|
|
340
|
-
runner instanceof
|
|
592
|
+
runner instanceof ImportedLocalPerceptionModuleRunner
|
|
341
593
|
))).toBe(true);
|
|
342
594
|
expect(plugin.moduleDescriptors()).toEqual(expect.arrayContaining([
|
|
343
595
|
expect.objectContaining({ id: 'visual.visibility', subjectScope: 'others' }),
|
|
596
|
+
expect.objectContaining({ id: 'visual.corpse_visibility', subjectScope: 'corpses' }),
|
|
344
597
|
expect.objectContaining({ id: 'visual.motion', subjectScope: 'self_and_others' }),
|
|
345
598
|
expect.objectContaining({ id: 'visual.follow', subjectScope: 'visible_pairs' }),
|
|
346
599
|
]));
|
|
@@ -376,7 +629,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
376
629
|
]);
|
|
377
630
|
});
|
|
378
631
|
|
|
379
|
-
it('starts, analyzes, commits, and stops all
|
|
632
|
+
it('starts, analyzes, commits, and stops all eight official Worker modules together', async () => {
|
|
380
633
|
const plugin = new ClawclawPerceptionPlugin();
|
|
381
634
|
replayPlugins.add(plugin);
|
|
382
635
|
const outcomes = [];
|
|
@@ -391,6 +644,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
391
644
|
expect(outcomes.every((outcome) => outcome.outcome === 'processed')).toBe(true);
|
|
392
645
|
expect(Object.keys(plugin.moduleStateSnapshot()).sort()).toEqual([
|
|
393
646
|
'visual.co_movement',
|
|
647
|
+
'visual.corpse_visibility',
|
|
394
648
|
'visual.follow',
|
|
395
649
|
'visual.motion',
|
|
396
650
|
'visual.route',
|
|
@@ -509,7 +763,31 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
509
763
|
}]);
|
|
510
764
|
expect(result.proposals[0].payload).not.toHaveProperty('status');
|
|
511
765
|
expect(result.visual?.continuousFromPrevious).toBe(false);
|
|
512
|
-
expect(result.visual?.phase).toBe('meeting');
|
|
766
|
+
expect(result.visual?.gameState.phase).toBe('meeting');
|
|
767
|
+
expect(result.visual).not.toHaveProperty('phase');
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
it('hard-cuts the visual lifecycle when the observer dies without inventing a dead phase', async () => {
|
|
771
|
+
const plugin = pluginFor('visual.motion');
|
|
772
|
+
for (let tick = 1; tick <= 5; tick += 1) {
|
|
773
|
+
await plugin.inspectFrame(stored(tick, tick, stateAt(tick, 900 + (tick - 1) * 5)));
|
|
774
|
+
}
|
|
775
|
+
const state = stateAt(6, 925);
|
|
776
|
+
const result = await plugin.inspectFrame(stored(6, 6, {
|
|
777
|
+
...state,
|
|
778
|
+
you: { ...state.you, is_alive: false },
|
|
779
|
+
}));
|
|
780
|
+
|
|
781
|
+
expect(result.proposals).toMatchObject([{
|
|
782
|
+
type: 'visual.player_moved',
|
|
783
|
+
payload: { from_tick: 1, to_tick: 5 },
|
|
784
|
+
}]);
|
|
785
|
+
expect(result.visual?.continuousFromPrevious).toBe(false);
|
|
786
|
+
expect(result.visual?.gameState).toMatchObject({
|
|
787
|
+
phase: 'wandering',
|
|
788
|
+
you: { is_alive: false },
|
|
789
|
+
});
|
|
790
|
+
expect(result.visual).not.toHaveProperty('phase');
|
|
513
791
|
});
|
|
514
792
|
|
|
515
793
|
it('lets the module enforce its own maximum open-slice length', async () => {
|
|
@@ -562,9 +840,9 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
562
840
|
});
|
|
563
841
|
});
|
|
564
842
|
|
|
565
|
-
it('runs official motion analysis in a warm Worker pool and changes state only in ordered commit', async () => {
|
|
843
|
+
it('runs materialized official motion analysis in a warm Worker pool and changes state only in ordered commit', async () => {
|
|
566
844
|
const plugin = pluginFor('visual.motion');
|
|
567
|
-
expect((plugin as any).modules[0].runner).toBeInstanceOf(
|
|
845
|
+
expect((plugin as any).modules[0].runner).toBeInstanceOf(ImportedLocalPerceptionModuleRunner);
|
|
568
846
|
const scope = stored(1, 1, {}).scope;
|
|
569
847
|
const context = pluginContext(plugin, scope);
|
|
570
848
|
const journal = journals.get(plugin)!;
|
|
@@ -611,6 +889,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
611
889
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
612
890
|
export default class Lookback extends ClawclawParallelPerception {
|
|
613
891
|
static manifest = {
|
|
892
|
+
apiVersion: 2,
|
|
614
893
|
id: 'visual.lookback', name: 'Lookback', description: 'Checks immutable lookback.',
|
|
615
894
|
subjectScope: 'others', produces: ['visual.lookback'], execution: 'parallel_analysis',
|
|
616
895
|
};
|
|
@@ -732,6 +1011,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
732
1011
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
733
1012
|
export default class Generation extends ClawclawParallelPerception {
|
|
734
1013
|
static manifest = {
|
|
1014
|
+
apiVersion: 2,
|
|
735
1015
|
id: 'visual.generation', name: 'Generation', description: 'Checks failure barriers.',
|
|
736
1016
|
subjectScope: 'others', produces: ['visual.generation'], execution: 'parallel_analysis',
|
|
737
1017
|
};
|
|
@@ -755,6 +1035,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
755
1035
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
756
1036
|
export default class Healthy extends ClawclawParallelPerception {
|
|
757
1037
|
static manifest = {
|
|
1038
|
+
apiVersion: 2,
|
|
758
1039
|
id: 'visual.healthy', name: 'Healthy', description: 'Stays independent of peer failures.',
|
|
759
1040
|
subjectScope: 'others', produces: ['visual.healthy'], execution: 'parallel_analysis',
|
|
760
1041
|
};
|
|
@@ -846,6 +1127,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
846
1127
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
847
1128
|
export default class BoundarySuccessors extends ClawclawParallelPerception {
|
|
848
1129
|
static manifest = {
|
|
1130
|
+
apiVersion: 2,
|
|
849
1131
|
id: 'visual.boundary_successors', name: 'Boundary successors',
|
|
850
1132
|
description: 'Rejects a bridge across discarded reducer frames.',
|
|
851
1133
|
subjectScope: 'others', produces: ['visual.boundary_successors'],
|
|
@@ -932,7 +1214,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
932
1214
|
}
|
|
933
1215
|
}, 20_000);
|
|
934
1216
|
|
|
935
|
-
it('
|
|
1217
|
+
it('starts every parallel module fresh after restart regardless of its old failure floor', async () => {
|
|
936
1218
|
const root = mkdtempSync(join(tmpdir(), 'ccl-perception-recovery-floor-'));
|
|
937
1219
|
const perceptions = join(root, 'user-data', 'perceptions');
|
|
938
1220
|
mkdirSync(perceptions, { recursive: true });
|
|
@@ -941,6 +1223,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
941
1223
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
942
1224
|
export default class Transient extends ClawclawParallelPerception {
|
|
943
1225
|
static manifest = {
|
|
1226
|
+
apiVersion: 2,
|
|
944
1227
|
id: 'visual.transient', name: 'Transient', description: 'Fails one live analysis.',
|
|
945
1228
|
subjectScope: 'others', produces: ['visual.transient'], execution: 'parallel_analysis',
|
|
946
1229
|
};
|
|
@@ -964,6 +1247,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
964
1247
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
965
1248
|
export default class RecoveryHealthy extends ClawclawParallelPerception {
|
|
966
1249
|
static manifest = {
|
|
1250
|
+
apiVersion: 2,
|
|
967
1251
|
id: 'visual.recovery_healthy', name: 'Recovery healthy',
|
|
968
1252
|
description: 'Keeps its original replay slice.',
|
|
969
1253
|
subjectScope: 'others', produces: ['visual.recovery_healthy'], execution: 'parallel_analysis',
|
|
@@ -1036,12 +1320,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1036
1320
|
await recovered.start(recoveryContext);
|
|
1037
1321
|
await recovered.recover(recoveryContext);
|
|
1038
1322
|
expect(recovered.moduleStateSnapshot()).toEqual({
|
|
1039
|
-
'visual.recovery_healthy': {
|
|
1040
|
-
frames: [
|
|
1041
|
-
expect.objectContaining({ frame_seq: 1 }),
|
|
1042
|
-
expect.objectContaining({ frame_seq: 2 }),
|
|
1043
|
-
],
|
|
1044
|
-
},
|
|
1323
|
+
'visual.recovery_healthy': { frames: [] },
|
|
1045
1324
|
'visual.transient': { frames: [] },
|
|
1046
1325
|
});
|
|
1047
1326
|
|
|
@@ -1050,7 +1329,14 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1050
1329
|
await recovered.update(thirdInput, recoveryContext),
|
|
1051
1330
|
recoveryContext,
|
|
1052
1331
|
);
|
|
1053
|
-
expect(recovered.moduleStateSnapshot()).toEqual(
|
|
1332
|
+
expect(recovered.moduleStateSnapshot()).toEqual({
|
|
1333
|
+
'visual.recovery_healthy': {
|
|
1334
|
+
frames: [{ frame_seq: 3, history_frame_seqs: [] }],
|
|
1335
|
+
},
|
|
1336
|
+
'visual.transient': {
|
|
1337
|
+
frames: [{ frame_seq: 3, history_frame_seqs: [] }],
|
|
1338
|
+
},
|
|
1339
|
+
});
|
|
1054
1340
|
} finally {
|
|
1055
1341
|
await Promise.allSettled([
|
|
1056
1342
|
plugin.stopForReplay(),
|
|
@@ -1061,7 +1347,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1061
1347
|
}
|
|
1062
1348
|
}, 30_000);
|
|
1063
1349
|
|
|
1064
|
-
it('persists
|
|
1350
|
+
it('persists live reducer boundaries but starts a new boundary after process restart', async () => {
|
|
1065
1351
|
const root = mkdtempSync(join(tmpdir(), 'ccl-perception-reducer-replay-'));
|
|
1066
1352
|
const perceptions = join(root, 'user-data', 'perceptions');
|
|
1067
1353
|
mkdirSync(perceptions, { recursive: true });
|
|
@@ -1070,6 +1356,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1070
1356
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
1071
1357
|
export default class ReplayExact extends ClawclawParallelPerception {
|
|
1072
1358
|
static manifest = {
|
|
1359
|
+
apiVersion: 2,
|
|
1073
1360
|
id: 'visual.replay_exact', name: 'Replay exact',
|
|
1074
1361
|
description: 'Records only frames that reached the reducer.',
|
|
1075
1362
|
subjectScope: 'others', produces: ['visual.replay_exact'], execution: 'parallel_analysis',
|
|
@@ -1149,7 +1436,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1149
1436
|
'visual.replay_exact': { frames: [11] },
|
|
1150
1437
|
});
|
|
1151
1438
|
expect(afterRecovery.checkpoint).toMatchObject({
|
|
1152
|
-
parallelModuleHistoryFloors: { 'visual.replay_exact':
|
|
1439
|
+
parallelModuleHistoryFloors: { 'visual.replay_exact': 11 },
|
|
1153
1440
|
parallelModuleReducerReplayStarts: { 'visual.replay_exact': 11 },
|
|
1154
1441
|
parallelModuleBaselinePending: { 'visual.replay_exact': false },
|
|
1155
1442
|
});
|
|
@@ -1243,7 +1530,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1243
1530
|
await gapRecovered.start(gapRecoveryContext);
|
|
1244
1531
|
await gapRecovered.recover(gapRecoveryContext);
|
|
1245
1532
|
expect(gapRecovered.moduleStateSnapshot()).toEqual({
|
|
1246
|
-
'visual.replay_exact': { frames: [
|
|
1533
|
+
'visual.replay_exact': { frames: [] },
|
|
1247
1534
|
});
|
|
1248
1535
|
} finally {
|
|
1249
1536
|
await Promise.allSettled([
|
|
@@ -1266,6 +1553,7 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1266
1553
|
import { ClawclawParallelPerception } from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
1267
1554
|
export default class ReducerReset extends ClawclawParallelPerception {
|
|
1268
1555
|
static manifest = {
|
|
1556
|
+
apiVersion: 2,
|
|
1269
1557
|
id: 'visual.reducer_reset', name: 'Reducer reset', description: 'Checks dirty reducer reset.',
|
|
1270
1558
|
subjectScope: 'others', produces: ['visual.reducer_reset'], execution: 'parallel_analysis',
|
|
1271
1559
|
};
|
|
@@ -1392,15 +1680,8 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1392
1680
|
const recoveryContext = pluginContext(recovered, scope, 8, result.checkpoint);
|
|
1393
1681
|
await recovered.start(recoveryContext);
|
|
1394
1682
|
await recovered.recover(recoveryContext);
|
|
1395
|
-
expect(recovered.moduleStateSnapshot()).
|
|
1396
|
-
'visual.motion': {
|
|
1397
|
-
latest_tick: 8,
|
|
1398
|
-
tracks: expect.arrayContaining([expect.objectContaining({
|
|
1399
|
-
point_count: 1,
|
|
1400
|
-
from_tick: 8,
|
|
1401
|
-
to_tick: 8,
|
|
1402
|
-
})]),
|
|
1403
|
-
},
|
|
1683
|
+
expect(recovered.moduleStateSnapshot()).toEqual({
|
|
1684
|
+
'visual.motion': { latest_tick: null, tracks: [] },
|
|
1404
1685
|
});
|
|
1405
1686
|
|
|
1406
1687
|
const ninth = journal.appendStateFrame(stored(9, 9, stateAt(9, 940))).frame;
|
|
@@ -1413,8 +1694,15 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1413
1694
|
plugin.commit(ninthInput, liveNinthComputation, context),
|
|
1414
1695
|
recovered.commit(ninthInput, recoveredNinthComputation, recoveryContext),
|
|
1415
1696
|
]);
|
|
1416
|
-
expect(recoveredNinth.events ?? []).toEqual(
|
|
1417
|
-
expect(recovered.moduleStateSnapshot()).
|
|
1697
|
+
expect(recoveredNinth.events ?? []).toEqual([]);
|
|
1698
|
+
expect(recovered.moduleStateSnapshot()).toMatchObject({
|
|
1699
|
+
'visual.motion': {
|
|
1700
|
+
latest_tick: 9,
|
|
1701
|
+
tracks: expect.arrayContaining([
|
|
1702
|
+
expect.objectContaining({ from_tick: 9, to_tick: 9 }),
|
|
1703
|
+
]),
|
|
1704
|
+
},
|
|
1705
|
+
});
|
|
1418
1706
|
expect(plugin.moduleStateSnapshot()).toMatchObject({
|
|
1419
1707
|
'visual.motion': {
|
|
1420
1708
|
latest_tick: 9,
|
|
@@ -1524,23 +1812,67 @@ describe('ClawClaw Perception plugin', () => {
|
|
|
1524
1812
|
}));
|
|
1525
1813
|
});
|
|
1526
1814
|
|
|
1527
|
-
it('
|
|
1815
|
+
it('skips all persisted perception history and resumes from a fresh baseline', async () => {
|
|
1528
1816
|
const journal = new MemoryStateHistoryRepository<unknown, Record<string, any>>();
|
|
1529
1817
|
const scope = stored(1, 1, {}).scope;
|
|
1530
1818
|
journal.openScope(scope);
|
|
1531
|
-
for (let tick = 1; tick <=
|
|
1819
|
+
for (let tick = 1; tick <= 8; tick += 1) {
|
|
1532
1820
|
journal.appendStateFrame(stored(tick, tick, stateAt(tick, 900 + tick * 5)));
|
|
1533
1821
|
}
|
|
1534
|
-
const plugin =
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1822
|
+
const plugin = new ClawclawPerceptionPlugin({
|
|
1823
|
+
modules: ['visual.motion'],
|
|
1824
|
+
});
|
|
1825
|
+
replayPlugins.add(plugin);
|
|
1826
|
+
journals.set(plugin, journal);
|
|
1827
|
+
const diagnostics: Array<{
|
|
1828
|
+
name: string;
|
|
1829
|
+
attributes?: Readonly<Record<string, unknown>>;
|
|
1830
|
+
}> = [];
|
|
1831
|
+
const context = pluginContext(
|
|
1832
|
+
plugin,
|
|
1833
|
+
scope,
|
|
1834
|
+
8,
|
|
1835
|
+
undefined,
|
|
1836
|
+
(name, attributes) => diagnostics.push({ name, attributes }),
|
|
1837
|
+
);
|
|
1838
|
+
const query = vi.spyOn(journal, 'queryStateFrames');
|
|
1839
|
+
|
|
1539
1840
|
await plugin.start(context);
|
|
1540
1841
|
await plugin.recover(context);
|
|
1541
1842
|
|
|
1843
|
+
expect(query).toHaveBeenCalledTimes(1);
|
|
1844
|
+
expect(query).toHaveBeenCalledWith(expect.objectContaining({
|
|
1845
|
+
toEpochSeq: 8,
|
|
1846
|
+
order: 'desc',
|
|
1847
|
+
limit: 1,
|
|
1848
|
+
}));
|
|
1849
|
+
expect(plugin.moduleStateSnapshot()).toEqual({
|
|
1850
|
+
'visual.motion': { latest_tick: null, tracks: [] },
|
|
1851
|
+
});
|
|
1852
|
+
expect(diagnostics).toContainEqual(expect.objectContaining({
|
|
1853
|
+
name: 'perception.recovery_history_skipped',
|
|
1854
|
+
attributes: expect.objectContaining({
|
|
1855
|
+
skipped_through_frame_seq: 8,
|
|
1856
|
+
resume_from_frame_seq: 9,
|
|
1857
|
+
}),
|
|
1858
|
+
}));
|
|
1859
|
+
|
|
1860
|
+
const ninth = journal.appendStateFrame(stored(9, 9, stateAt(9, 945))).frame;
|
|
1861
|
+
const ninthInput = epochInput(ninth);
|
|
1862
|
+
const result = await plugin.commit(
|
|
1863
|
+
ninthInput,
|
|
1864
|
+
await plugin.update(ninthInput, context),
|
|
1865
|
+
context,
|
|
1866
|
+
);
|
|
1867
|
+
expect(result.events ?? []).toEqual([]);
|
|
1542
1868
|
expect(plugin.moduleStateSnapshot()).toMatchObject({
|
|
1543
|
-
'visual.motion': {
|
|
1869
|
+
'visual.motion': {
|
|
1870
|
+
latest_tick: 9,
|
|
1871
|
+
tracks: expect.arrayContaining([expect.objectContaining({
|
|
1872
|
+
from_tick: 9,
|
|
1873
|
+
to_tick: 9,
|
|
1874
|
+
})]),
|
|
1875
|
+
},
|
|
1544
1876
|
});
|
|
1545
1877
|
});
|
|
1546
1878
|
});
|