@myclaw163/clawclaw-cli 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/docs/configuration.md +44 -26
- package/docs/custom-modules/README.md +7 -10
- package/docs/custom-modules/behavior.md +3 -1
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/README.md +4 -4
- package/docs/runtime/official-perception-modules.md +2 -2
- package/docs/runtime/owner-lifecycle-and-observability.md +1 -1
- package/package.json +9 -2
- package/scripts/build-official-hub-behaviors.mjs +136 -0
- package/scripts/build-official-hub-behaviors.test.mjs +178 -0
- package/scripts/enable_ccl_permissions.cjs +4 -2
- package/scripts/enable_ccl_permissions.test.mjs +8 -4
- package/scripts/postinstall.mjs +1 -4
- package/scripts/sync-bundled-skill.mjs +12 -159
- package/scripts/sync-bundled-skill.test.mjs +9 -74
- package/skills/clawclaw/SKILL.md +14 -9
- package/skills/clawclaw/references/BEHAVIORS.md +4 -4
- package/skills/clawclaw/references/COMMANDS.md +32 -16
- package/skills/clawclaw/references/HUB.md +25 -38
- package/src/commands/account.ts +58 -14
- package/src/commands/behavior.ts +116 -38
- package/src/commands/hub.ts +110 -153
- package/src/commands/load.ts +138 -33
- package/src/commands/perception.ts +55 -24
- package/src/commands/persona.ts +66 -20
- package/src/commands/skill.ts +12 -48
- package/src/commands/trigger.ts +68 -40
- package/src/hub-official-behaviors/kill-lone.ts +138 -0
- package/src/hub-official-behaviors/patrol.ts +30 -0
- package/src/hub-official-behaviors/shared.ts +125 -0
- package/src/hub-official-behaviors/task-only.ts +158 -0
- package/src/lib/account-guidance.ts +54 -9
- package/src/lib/agent-workspace-client.ts +135 -0
- package/src/lib/agent-workspace-runtime.ts +154 -0
- package/src/lib/agent-workspace-skills.ts +177 -0
- package/src/lib/agent-workspace-sync.ts +852 -0
- package/src/lib/gameplay-config.ts +29 -15
- package/src/lib/hub-client.ts +252 -34
- package/src/lib/hub-reminder.ts +22 -7
- package/src/lib/init-command.ts +0 -6
- package/src/lib/load-context.ts +12 -6
- package/src/lib/persona.ts +141 -69
- package/src/lib/server-status.ts +78 -0
- package/src/lib/skill-host.ts +160 -0
- package/src/lib/user-data.ts +197 -4
- package/src/runtime/clawclaw/owner.ts +63 -19
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +8 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +2 -2
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +4 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +11 -5
- package/src/runtime/clawclaw/plugins/perception/replay.ts +0 -2
- package/personas//345/217/243/346/230/257/345/277/203/351/235/236.md +0 -50
- package/personas//345/277/240/345/277/203/350/200/201/344/273/206.md +0 -51
- package/personas//346/227/240/344/272/272/350/256/276.md +0 -1
- package/personas//350/264/253/345/230/264/346/215/237/345/217/213.md +0 -48
- package/personas//350/275/257/350/220/214/350/205/271/351/273/221.md +0 -51
- package/src/behaviors/official-finite/index.test.ts +0 -249
- package/src/channel/claude-channel-server.test.ts +0 -202
- package/src/commands/account.test.ts +0 -570
- package/src/commands/behavior.test.ts +0 -158
- package/src/commands/communication.test.ts +0 -282
- package/src/commands/competition.test.ts +0 -116
- package/src/commands/data.test.ts +0 -89
- package/src/commands/events-canonical-state.test.ts +0 -406
- package/src/commands/events.test.ts +0 -58
- package/src/commands/game/index.test.ts +0 -1251
- package/src/commands/game-map.test.ts +0 -69
- package/src/commands/hub.test.ts +0 -124
- package/src/commands/load.test.ts +0 -440
- package/src/commands/perception.test.ts +0 -75
- package/src/commands/setup/hermes.test.ts +0 -96
- package/src/commands/setup/openclaw.test.ts +0 -124
- package/src/commands/trigger.test.ts +0 -140
- package/src/commands/upgrade.test.ts +0 -82
- package/src/lib/account-guidance.test.ts +0 -36
- package/src/lib/auth.test.ts +0 -151
- package/src/lib/behavior-export.test.ts +0 -326
- package/src/lib/behavior-export.ts +0 -537
- package/src/lib/clawclaw-skill-spectate-guidance.test.ts +0 -21
- package/src/lib/custom-tts.test.ts +0 -387
- package/src/lib/diagnostics-config.test.ts +0 -59
- package/src/lib/game-client-tts.test.ts +0 -151
- package/src/lib/game-client.test.ts +0 -250
- package/src/lib/gameplay-config.test.ts +0 -301
- package/src/lib/host-config-patcher.test.ts +0 -130
- package/src/lib/http-transport.test.ts +0 -124
- package/src/lib/hub-client.test.ts +0 -57
- package/src/lib/hub-install.test.ts +0 -135
- package/src/lib/hub-install.ts +0 -185
- package/src/lib/hub-unzip.test.ts +0 -69
- package/src/lib/init-command.test.ts +0 -103
- package/src/lib/load-context.test.ts +0 -62
- package/src/lib/match-state.test.ts +0 -134
- package/src/lib/official-resource-sync.test.ts +0 -199
- package/src/lib/official-resource-sync.ts +0 -221
- package/src/lib/perception-config.test.ts +0 -143
- package/src/lib/perception-export.test.ts +0 -145
- package/src/lib/perception-export.ts +0 -178
- package/src/lib/persona.test.ts +0 -84
- package/src/lib/room.test.ts +0 -88
- package/src/lib/server-registry.test.ts +0 -64
- package/src/lib/service-status.test.ts +0 -81
- package/src/lib/skill-version.test.ts +0 -48
- package/src/lib/trigger-config.test.ts +0 -102
- package/src/lib/trigger-export.test.ts +0 -80
- package/src/lib/trigger-export.ts +0 -210
- package/src/lib/user-data.test.ts +0 -121
- package/src/lib/workspace-argv.test.ts +0 -49
- package/src/pipeline/canonical-event-presentation.test.ts +0 -257
- package/src/pipeline/event-format.test.ts +0 -879
- package/src/pipeline/event-hints.test.ts +0 -337
- package/src/pipeline/game-sync-event-normalization.test.ts +0 -419
- package/src/pipeline/player-projection.test.ts +0 -247
- package/src/runtime/auto-upgrade.test.ts +0 -66
- package/src/runtime/canonical-event-emitter.test.ts +0 -70
- package/src/runtime/canonical-monitor.test.ts +0 -577
- package/src/runtime/clawclaw/agent-event-policy.test.ts +0 -60
- package/src/runtime/clawclaw/behavior-decision.test.ts +0 -43
- package/src/runtime/clawclaw/behavior-input-fields.test.ts +0 -175
- package/src/runtime/clawclaw/behavior-input.test.ts +0 -173
- package/src/runtime/clawclaw/behavior-observation-memory.test.ts +0 -59
- package/src/runtime/clawclaw/behavior-read-api.test.ts +0 -123
- package/src/runtime/clawclaw/notifications.test.ts +0 -47
- package/src/runtime/clawclaw/owner-lock.test.ts +0 -221
- package/src/runtime/clawclaw/owner.test.ts +0 -203
- package/src/runtime/clawclaw/plugins/action/action-plugin.test.ts +0 -328
- package/src/runtime/clawclaw/plugins/assembly.test.ts +0 -200
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.test.ts +0 -180
- package/src/runtime/clawclaw/plugins/behavior/behavior-action.test.ts +0 -43
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.test.ts +0 -156
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.test.ts +0 -182
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.test.ts +0 -1094
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.test.ts +0 -174
- package/src/runtime/clawclaw/plugins/behavior/control-driver.test.ts +0 -195
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.test.ts +0 -283
- package/src/runtime/clawclaw/plugins/behavior-input-source.test.ts +0 -80
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.test.ts +0 -267
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.test.ts +0 -226
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.test.ts +0 -239
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.test.ts +0 -407
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-push.integration.test.ts +0 -397
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.test.ts +0 -270
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-agent-event-batch.test.ts +0 -166
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.test.ts +0 -194
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.test.ts +0 -87
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.test.ts +0 -2012
- package/src/runtime/clawclaw/plugins/perception/module-runner.test.ts +0 -214
- package/src/runtime/clawclaw/plugins/perception/modules/co-movement-module.ts +0 -347
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.test.ts +0 -92
- package/src/runtime/clawclaw/plugins/perception/modules/corpse-visibility-module.ts +0 -248
- package/src/runtime/clawclaw/plugins/perception/modules/follow-module.ts +0 -389
- package/src/runtime/clawclaw/plugins/perception/modules/index.ts +0 -8
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.test.ts +0 -342
- package/src/runtime/clawclaw/plugins/perception/modules/motion-module.ts +0 -475
- package/src/runtime/clawclaw/plugins/perception/modules/parallel-module-test-helpers.ts +0 -30
- package/src/runtime/clawclaw/plugins/perception/modules/relation-stability.test.ts +0 -304
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.test.ts +0 -179
- package/src/runtime/clawclaw/plugins/perception/modules/route-module.ts +0 -364
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.test.ts +0 -81
- package/src/runtime/clawclaw/plugins/perception/modules/spatial-module.ts +0 -200
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.test.ts +0 -216
- package/src/runtime/clawclaw/plugins/perception/modules/stop-module.ts +0 -284
- package/src/runtime/clawclaw/plugins/perception/modules/temporal-evidence.test.ts +0 -120
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.test.ts +0 -105
- package/src/runtime/clawclaw/plugins/perception/modules/visibility-module.ts +0 -269
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.test.ts +0 -865
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.test.ts +0 -1878
- package/src/runtime/clawclaw/plugins/perception/perception-source.test.ts +0 -278
- package/src/runtime/clawclaw/plugins/perception/replay.test.ts +0 -77
- package/src/runtime/clawclaw/plugins/runtime-plugins.test.ts +0 -853
- package/src/runtime/clawclaw/plugins/source/game-transport.test.ts +0 -287
- package/src/runtime/clawclaw/plugins/source/player-change-tracker.test.ts +0 -321
- package/src/runtime/clawclaw/plugins/source/room-transport.test.ts +0 -307
- package/src/runtime/clawclaw/plugins/source/source-plugin.test.ts +0 -2646
- package/src/runtime/clawclaw/plugins/source/task-change-tracker.test.ts +0 -212
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.test.ts +0 -548
- package/src/runtime/clawclaw/plugins/trigger/trigger-source.test.ts +0 -169
- package/src/runtime/clawclaw/runtime-data-export.test.ts +0 -249
- package/src/runtime/clawclaw-event-catalog.test.ts +0 -128
- package/src/runtime/framework/action-diagnostics.test.ts +0 -81
- package/src/runtime/framework/capability-registry.test.ts +0 -423
- package/src/runtime/framework/control-coordinator.test.ts +0 -675
- package/src/runtime/framework/events/event-delivery-service.test.ts +0 -84
- package/src/runtime/framework/events/event-ingress.test.ts +0 -203
- package/src/runtime/framework/events/mailbox-event-repositories.test.ts +0 -710
- package/src/runtime/framework/events/sqlite-event-repository.test.ts +0 -802
- package/src/runtime/framework/mailbox/coalescer.test.ts +0 -55
- package/src/runtime/framework/mailbox/identity.test.ts +0 -38
- package/src/runtime/framework/mailbox/mailbox-dispatcher.test.ts +0 -513
- package/src/runtime/framework/mailbox/notification-projector.test.ts +0 -77
- package/src/runtime/framework/modules/runtime-module-loader.test.ts +0 -435
- package/src/runtime/framework/participation-manager.test.ts +0 -108
- package/src/runtime/framework/plugins/runtime-input-journal.test.ts +0 -179
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.test.ts +0 -2040
- package/src/runtime/framework/state/durable-agent-state-snapshot.test.ts +0 -144
- package/src/runtime/framework/state/history/sqlite-state-history-repository.test.ts +0 -157
- package/src/runtime/framework/state/history/state-history.test.ts +0 -251
- package/src/runtime/framework/state/state-core.test.ts +0 -197
- package/src/runtime/game-sync-protocol.test.ts +0 -123
- package/src/runtime/host-monitor-rate-gate.test.ts +0 -73
- package/src/runtime/mailbox-host-relay.test.ts +0 -293
- package/src/runtime/observability/observability.test.ts +0 -583
- package/src/runtime/owner-control.test.ts +0 -153
- package/src/runtime/parent-process-watch.test.ts +0 -27
- package/src/runtime/pending-event-handoff.test.ts +0 -29
- package/src/runtime/raw-ws-log.test.ts +0 -102
- package/src/runtime/runtime-logger.test.ts +0 -58
- package/src/runtime/runtime-persistence.test.ts +0 -26
- package/src/runtime/runtime.test.ts +0 -1770
- package/src/runtime/ws-client.test.ts +0 -562
- package/src/sdk/action.test.ts +0 -8
- package/src/sdk/behavior-plugin/index.test.ts +0 -74
- package/src/sdk/index.test.ts +0 -45
- package/src/sdk/module-input/index.test.ts +0 -49
- package/src/sdk/perception-plugin/index.test.ts +0 -22
- package/src/sdk/resource-metadata.test.ts +0 -40
- package/src/sdk/trigger-plugin/index.test.ts +0 -41
- package/src/short-command/classifier.test.ts +0 -107
- package/src/short-command/presenter.test.ts +0 -119
- package/src/short-command/runner.test.ts +0 -78
- package/src/short-command/sensitive-data-filter.test.ts +0 -56
- package/src/short-command/transport-response.test.ts +0 -39
- package/src/strategies/custom-module.test.ts +0 -267
- package/src/strategies/game-utils.test.ts +0 -305
- package/src/strategies/goals/avoid-players-top.test.ts +0 -95
- package/src/strategies/goals/crab-sabotage-top.test.ts +0 -131
- package/src/strategies/goals/kill-lone-top.test.ts +0 -96
- package/src/strategies/goals/kill-target-top.test.ts +0 -65
- package/src/strategies/goals/lone-kill-task-top.test.ts +0 -84
- package/src/strategies/goals/normal-shrimp-top.test.ts +0 -112
- package/src/strategies/goals/paradise-fish-top.test.ts +0 -203
- package/src/strategies/goals/task-only-top.test.ts +0 -88
- package/src/strategies/goals/warrior-shrimp-top.test.ts +0 -138
- package/src/strategies/meeting-gate.test.ts +0 -59
- package/src/strategies/official-long-behavior.test.ts +0 -89
- package/src/strategies/pathfind/astar-path.test.ts +0 -198
- package/src/strategies/pathfind/escape-planner.test.ts +0 -223
- package/src/strategies/player-targets.test.ts +0 -10
- package/src/strategies/task-only.test.ts +0 -138
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { PerceptionBoundary, VisualPlayer, PerceptionFrame } from '../contracts.js';
|
|
3
|
-
import { perceptionTestGameState } from '../perception-test-fixtures.js';
|
|
4
|
-
import { CoMovementModule } from './co-movement-module.js';
|
|
5
|
-
import { FollowModule } from './follow-module.js';
|
|
6
|
-
import { runParallelFrame } from './parallel-module-test-helpers.js';
|
|
7
|
-
|
|
8
|
-
function player(id: string, x: number, observer = false): VisualPlayer {
|
|
9
|
-
return {
|
|
10
|
-
id,
|
|
11
|
-
name: id,
|
|
12
|
-
observer,
|
|
13
|
-
alive: true,
|
|
14
|
-
x,
|
|
15
|
-
y: 100,
|
|
16
|
-
room: 'bar',
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function frame(
|
|
21
|
-
frameSeq: number,
|
|
22
|
-
tick: number,
|
|
23
|
-
leaderX: number,
|
|
24
|
-
followerX: number,
|
|
25
|
-
): PerceptionFrame {
|
|
26
|
-
return {
|
|
27
|
-
frameKey: `frame-${frameSeq}`,
|
|
28
|
-
frameSeq,
|
|
29
|
-
tick,
|
|
30
|
-
timeMs: tick * 100,
|
|
31
|
-
tickDelta: frameSeq === 1 ? null : 1,
|
|
32
|
-
continuousFromPrevious: frameSeq > 1,
|
|
33
|
-
gameState: perceptionTestGameState(tick),
|
|
34
|
-
observation: {
|
|
35
|
-
players: [
|
|
36
|
-
player('leader', leaderX, true),
|
|
37
|
-
player('follower', followerX),
|
|
38
|
-
],
|
|
39
|
-
corpses: [],
|
|
40
|
-
visibleSetComplete: true,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function boundary(through: PerceptionFrame, mode: 'snapshot' | 'close' = 'snapshot'):
|
|
46
|
-
PerceptionBoundary {
|
|
47
|
-
return {
|
|
48
|
-
kind: mode === 'snapshot' ? 'events_requested' : 'segment_ending',
|
|
49
|
-
mode,
|
|
50
|
-
through,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
describe('relation perception stability', () => {
|
|
55
|
-
it('confirms co-movement after stable evidence and tolerates a brief threshold miss', () => {
|
|
56
|
-
const module = new CoMovementModule();
|
|
57
|
-
const proposals = [];
|
|
58
|
-
for (let tick = 1; tick <= 12; tick += 1) {
|
|
59
|
-
proposals.push(...runParallelFrame(module, frame(tick, tick, 100 + tick * 5, 40 + tick * 5)));
|
|
60
|
-
}
|
|
61
|
-
expect(proposals).toEqual([]);
|
|
62
|
-
|
|
63
|
-
proposals.push(...runParallelFrame(module, frame(13, 13, 165, 105)));
|
|
64
|
-
expect(proposals.map((proposal) => proposal.type)).toEqual([
|
|
65
|
-
'visual.players_moving_together',
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
expect(runParallelFrame(module, frame(14, 14, 170, 105))).toEqual([]);
|
|
69
|
-
expect(runParallelFrame(module, frame(15, 15, 175, 115))).toEqual([]);
|
|
70
|
-
expect(module.debugSnapshot()).toMatchObject({
|
|
71
|
-
pairs: [expect.objectContaining({ active: true, miss_ticks: 0 })],
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
for (let tick = 16; tick <= 24; tick += 1) {
|
|
75
|
-
expect(runParallelFrame(module, frame(tick, tick, 175, 115))).toEqual([]);
|
|
76
|
-
}
|
|
77
|
-
expect(runParallelFrame(module, frame(25, 25, 175, 115)).map((proposal) => proposal.type)).toEqual([
|
|
78
|
-
'visual.players_stopped_moving_together',
|
|
79
|
-
]);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('reports co-movement ongoing only after a three-second query span', () => {
|
|
83
|
-
const module = new CoMovementModule();
|
|
84
|
-
let latest = frame(1, 1, 105, 45);
|
|
85
|
-
for (let tick = 1; tick <= 30; tick += 1) {
|
|
86
|
-
latest = frame(tick, tick, 100 + tick * 5, 40 + tick * 5);
|
|
87
|
-
runParallelFrame(module, latest);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
expect(module.flush(boundary(latest))).toEqual([]);
|
|
91
|
-
for (let tick = 31; tick <= 43; tick += 1) {
|
|
92
|
-
latest = frame(tick, tick, 100 + tick * 5, 40 + tick * 5);
|
|
93
|
-
expect(runParallelFrame(module, latest)).toEqual([]);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const snapshot = module.flush(boundary(latest));
|
|
97
|
-
expect(snapshot).toHaveLength(1);
|
|
98
|
-
expect(snapshot[0]).toMatchObject({
|
|
99
|
-
type: 'visual.players_moving_together',
|
|
100
|
-
payload: { from_tick: 14, to_tick: 43, status: 'ongoing' },
|
|
101
|
-
});
|
|
102
|
-
expect(module.flush(boundary(latest))).toEqual([]);
|
|
103
|
-
expect(module.debugSnapshot()).toMatchObject({
|
|
104
|
-
pairs: [expect.objectContaining({ active: true, miss_ticks: 0 })],
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('does not call a hysteresis miss ongoing and closes only through last evidence', () => {
|
|
109
|
-
const module = new CoMovementModule();
|
|
110
|
-
let latest = frame(1, 1, 105, 45);
|
|
111
|
-
for (let tick = 1; tick <= 23; tick += 1) {
|
|
112
|
-
latest = frame(tick, tick, 100 + tick * 5, 40 + tick * 5);
|
|
113
|
-
runParallelFrame(module, latest);
|
|
114
|
-
}
|
|
115
|
-
for (let tick = 24; tick <= 28; tick += 1) {
|
|
116
|
-
latest = frame(tick, tick, 215, 155);
|
|
117
|
-
expect(runParallelFrame(module, latest)).toEqual([]);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
expect(module.flush(boundary(latest))).toEqual([]);
|
|
121
|
-
const closed = module.flush(boundary(latest, 'close'));
|
|
122
|
-
expect(closed).toHaveLength(1);
|
|
123
|
-
expect(closed[0]).toMatchObject({
|
|
124
|
-
type: 'visual.players_moving_together',
|
|
125
|
-
payload: { from_tick: 14, to_tick: 23, status: 'closed' },
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('closes on definitive visibility loss at the last evidence without claiming a stop', () => {
|
|
130
|
-
const coMovement = new CoMovementModule();
|
|
131
|
-
const follow = new FollowModule();
|
|
132
|
-
let latest = frame(1, 1, 105, 45);
|
|
133
|
-
for (let tick = 1; tick <= 13; tick += 1) {
|
|
134
|
-
latest = frame(tick, tick, 100 + tick * 5, 40 + tick * 5);
|
|
135
|
-
runParallelFrame(coMovement, latest);
|
|
136
|
-
runParallelFrame(follow, latest);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const followerHidden: PerceptionFrame = {
|
|
140
|
-
...latest,
|
|
141
|
-
frameKey: 'frame-14',
|
|
142
|
-
frameSeq: 14,
|
|
143
|
-
tick: 14,
|
|
144
|
-
timeMs: 1_400,
|
|
145
|
-
observation: {
|
|
146
|
-
...latest.observation,
|
|
147
|
-
players: [player('leader', 170, true)],
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
expect(runParallelFrame(coMovement, followerHidden)).toEqual([]);
|
|
151
|
-
expect(runParallelFrame(follow, followerHidden)).toEqual([]);
|
|
152
|
-
expect(coMovement.debugSnapshot()).toMatchObject({
|
|
153
|
-
pairs: [expect.objectContaining({ active: true })],
|
|
154
|
-
pending_absence_tick: 14,
|
|
155
|
-
});
|
|
156
|
-
expect(follow.debugSnapshot()).toMatchObject({
|
|
157
|
-
candidates: [expect.objectContaining({ active: true })],
|
|
158
|
-
pending_absence_tick: 14,
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const absenceFinalized: PerceptionFrame = {
|
|
162
|
-
...followerHidden,
|
|
163
|
-
frameKey: 'frame-15',
|
|
164
|
-
frameSeq: 15,
|
|
165
|
-
tick: 15,
|
|
166
|
-
timeMs: 1_500,
|
|
167
|
-
observation: {
|
|
168
|
-
...followerHidden.observation,
|
|
169
|
-
players: [player('leader', 175, true)],
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
expect(runParallelFrame(coMovement, absenceFinalized)).toEqual([]);
|
|
173
|
-
expect(runParallelFrame(follow, absenceFinalized)).toEqual([]);
|
|
174
|
-
expect(coMovement.debugSnapshot()).toMatchObject({ pairs: [] });
|
|
175
|
-
expect(follow.debugSnapshot()).toMatchObject({ candidates: [] });
|
|
176
|
-
|
|
177
|
-
const incomplete = new CoMovementModule();
|
|
178
|
-
for (let tick = 1; tick <= 13; tick += 1) {
|
|
179
|
-
runParallelFrame(incomplete, frame(tick, tick, 100 + tick * 5, 40 + tick * 5));
|
|
180
|
-
}
|
|
181
|
-
expect(runParallelFrame(incomplete, {
|
|
182
|
-
...followerHidden,
|
|
183
|
-
observation: { ...followerHidden.observation, visibleSetComplete: false },
|
|
184
|
-
})).toEqual([]);
|
|
185
|
-
expect(incomplete.debugSnapshot()).toMatchObject({
|
|
186
|
-
pairs: [expect.objectContaining({ active: true, miss_ticks: 0 })],
|
|
187
|
-
});
|
|
188
|
-
const reappeared = frame(15, 15, 175, 115);
|
|
189
|
-
expect(runParallelFrame(incomplete, reappeared)).toEqual([]);
|
|
190
|
-
expect(incomplete.debugSnapshot()).toMatchObject({
|
|
191
|
-
pairs: [expect.objectContaining({ active: true, miss_ticks: 0 })],
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('keeps an active relation when a later complete same-tick revision restores the player', () => {
|
|
196
|
-
const coMovement = new CoMovementModule();
|
|
197
|
-
const follow = new FollowModule();
|
|
198
|
-
let latest = frame(1, 1, 105, 45);
|
|
199
|
-
for (let tick = 1; tick <= 13; tick += 1) {
|
|
200
|
-
latest = frame(tick, tick, 100 + tick * 5, 40 + tick * 5);
|
|
201
|
-
runParallelFrame(coMovement, latest);
|
|
202
|
-
runParallelFrame(follow, latest);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const absentRevision: PerceptionFrame = {
|
|
206
|
-
...latest,
|
|
207
|
-
frameKey: 'frame-14-absent',
|
|
208
|
-
frameSeq: 14,
|
|
209
|
-
tickDelta: 0,
|
|
210
|
-
observation: {
|
|
211
|
-
...latest.observation,
|
|
212
|
-
players: [player('leader', 165, true)],
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
expect(runParallelFrame(coMovement, absentRevision)).toEqual([]);
|
|
216
|
-
expect(runParallelFrame(follow, absentRevision)).toEqual([]);
|
|
217
|
-
expect(coMovement.debugSnapshot()).toMatchObject({
|
|
218
|
-
pairs: [expect.objectContaining({ active: true })],
|
|
219
|
-
pending_absence_tick: 13,
|
|
220
|
-
});
|
|
221
|
-
expect(follow.debugSnapshot()).toMatchObject({
|
|
222
|
-
candidates: [expect.objectContaining({ active: true })],
|
|
223
|
-
pending_absence_tick: 13,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
const restoredRevision: PerceptionFrame = {
|
|
227
|
-
...latest,
|
|
228
|
-
frameKey: 'frame-15-restored',
|
|
229
|
-
frameSeq: 15,
|
|
230
|
-
tickDelta: 0,
|
|
231
|
-
};
|
|
232
|
-
expect(runParallelFrame(coMovement, restoredRevision)).toEqual([]);
|
|
233
|
-
expect(runParallelFrame(follow, restoredRevision)).toEqual([]);
|
|
234
|
-
expect(coMovement.debugSnapshot()).toMatchObject({
|
|
235
|
-
pairs: [expect.objectContaining({ active: true })],
|
|
236
|
-
pending_absence_tick: null,
|
|
237
|
-
});
|
|
238
|
-
expect(follow.debugSnapshot()).toMatchObject({
|
|
239
|
-
candidates: [expect.objectContaining({ active: true })],
|
|
240
|
-
pending_absence_tick: null,
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
const next = frame(16, 14, 170, 110);
|
|
244
|
-
expect(runParallelFrame(coMovement, next)).toEqual([]);
|
|
245
|
-
expect(runParallelFrame(follow, next)).toEqual([]);
|
|
246
|
-
expect(coMovement.debugSnapshot()).toMatchObject({
|
|
247
|
-
pairs: [expect.objectContaining({ active: true, miss_ticks: 0 })],
|
|
248
|
-
});
|
|
249
|
-
expect(follow.debugSnapshot()).toMatchObject({
|
|
250
|
-
candidates: [expect.objectContaining({ active: true, miss_ticks: 0 })],
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('requires stronger follow evidence and does not end it on a short mismatch', () => {
|
|
255
|
-
const module = new FollowModule();
|
|
256
|
-
const proposals = [];
|
|
257
|
-
for (let tick = 1; tick <= 12; tick += 1) {
|
|
258
|
-
proposals.push(...runParallelFrame(module, frame(tick, tick, 100 + tick * 5, 40 + tick * 5)));
|
|
259
|
-
}
|
|
260
|
-
expect(proposals).toEqual([]);
|
|
261
|
-
|
|
262
|
-
proposals.push(...runParallelFrame(module, frame(13, 13, 165, 105)));
|
|
263
|
-
expect(proposals.map((proposal) => proposal.type)).toEqual(['visual.following']);
|
|
264
|
-
|
|
265
|
-
for (let tick = 14; tick <= 18; tick += 1) {
|
|
266
|
-
expect(runParallelFrame(module, frame(tick, tick, 165, 105))).toEqual([]);
|
|
267
|
-
}
|
|
268
|
-
expect(runParallelFrame(module, frame(19, 19, 170, 110))).toEqual([]);
|
|
269
|
-
expect(module.debugSnapshot()).toMatchObject({
|
|
270
|
-
candidates: [expect.objectContaining({
|
|
271
|
-
active: true,
|
|
272
|
-
evidence_ticks: 13,
|
|
273
|
-
miss_ticks: 0,
|
|
274
|
-
})],
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
for (let tick = 20; tick <= 28; tick += 1) {
|
|
278
|
-
expect(runParallelFrame(module, frame(tick, tick, 170, 110))).toEqual([]);
|
|
279
|
-
}
|
|
280
|
-
expect(runParallelFrame(module, frame(29, 29, 170, 110)).map((proposal) => proposal.type)).toEqual([
|
|
281
|
-
'visual.following_ended',
|
|
282
|
-
]);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it('does not turn a follow query snapshot into a semantic ending', () => {
|
|
286
|
-
const module = new FollowModule();
|
|
287
|
-
let latest = frame(1, 1, 105, 45);
|
|
288
|
-
for (let tick = 1; tick <= 43; tick += 1) {
|
|
289
|
-
latest = frame(tick, tick, 100 + tick * 5, 40 + tick * 5);
|
|
290
|
-
runParallelFrame(module, latest);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const snapshot = module.flush(boundary(latest));
|
|
294
|
-
expect(snapshot).toHaveLength(1);
|
|
295
|
-
expect(snapshot[0]).toMatchObject({
|
|
296
|
-
type: 'visual.following',
|
|
297
|
-
payload: { status: 'ongoing' },
|
|
298
|
-
});
|
|
299
|
-
expect(snapshot.some((proposal) => proposal.type === 'visual.following_ended')).toBe(false);
|
|
300
|
-
expect(module.debugSnapshot()).toMatchObject({
|
|
301
|
-
candidates: [expect.objectContaining({ active: true, miss_ticks: 0 })],
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
});
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { PerceptionBoundary, VisualPlayer, PerceptionFrame } from '../contracts.js';
|
|
3
|
-
import { perceptionTestGameState } from '../perception-test-fixtures.js';
|
|
4
|
-
import { runParallelFrame } from './parallel-module-test-helpers.js';
|
|
5
|
-
import { RouteModule } from './route-module.js';
|
|
6
|
-
|
|
7
|
-
function player(x: number, y = 100): VisualPlayer {
|
|
8
|
-
return {
|
|
9
|
-
id: 'self',
|
|
10
|
-
name: 'self',
|
|
11
|
-
observer: true,
|
|
12
|
-
alive: true,
|
|
13
|
-
x,
|
|
14
|
-
y,
|
|
15
|
-
room: 'bar',
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function frame(
|
|
20
|
-
frameSeq: number,
|
|
21
|
-
tick: number,
|
|
22
|
-
players: readonly VisualPlayer[],
|
|
23
|
-
options: { tickDelta?: number | null; visibleSetComplete?: boolean } = {},
|
|
24
|
-
): PerceptionFrame {
|
|
25
|
-
const tickDelta = options.tickDelta ?? (frameSeq === 1 ? null : 1);
|
|
26
|
-
return {
|
|
27
|
-
frameKey: `frame-${frameSeq}`,
|
|
28
|
-
frameSeq,
|
|
29
|
-
tick,
|
|
30
|
-
timeMs: frameSeq * 100,
|
|
31
|
-
tickDelta,
|
|
32
|
-
continuousFromPrevious: tickDelta !== null && tickDelta >= 0 && tickDelta <= 3,
|
|
33
|
-
gameState: perceptionTestGameState(tick),
|
|
34
|
-
observation: { players, corpses: [], visibleSetComplete: options.visibleSetComplete ?? true },
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function routeState(module: RouteModule) {
|
|
39
|
-
return module.debugSnapshot().tracks[0];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function boundary(
|
|
43
|
-
mode: PerceptionBoundary['mode'],
|
|
44
|
-
through: PerceptionFrame,
|
|
45
|
-
): PerceptionBoundary {
|
|
46
|
-
return {
|
|
47
|
-
kind: mode === 'snapshot' ? 'events_requested' : 'segment_ending',
|
|
48
|
-
mode,
|
|
49
|
-
through,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
describe('RouteModule tick finalization', () => {
|
|
54
|
-
it('uses the latest coordinate from each tick when accumulating path length', () => {
|
|
55
|
-
const module = new RouteModule();
|
|
56
|
-
|
|
57
|
-
expect(runParallelFrame(module, frame(1, 1, [player(0)]))).toEqual([]);
|
|
58
|
-
expect(runParallelFrame(module, frame(2, 2, [player(10)]))).toEqual([]);
|
|
59
|
-
expect(runParallelFrame(module, frame(3, 2, [player(100)], { tickDelta: 0 }))).toEqual([]);
|
|
60
|
-
expect(runParallelFrame(module, frame(4, 3, [player(110)]))).toEqual([]);
|
|
61
|
-
|
|
62
|
-
expect(routeState(module)).toMatchObject({
|
|
63
|
-
path_length_px: 110,
|
|
64
|
-
committed_path_length_px: 100,
|
|
65
|
-
pending_tick: 3,
|
|
66
|
-
reversal_count: 0,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('rolls a same-tick correction back before the next edge is accumulated', () => {
|
|
71
|
-
const module = new RouteModule();
|
|
72
|
-
runParallelFrame(module, frame(1, 1, [player(0)]));
|
|
73
|
-
runParallelFrame(module, frame(2, 2, [player(10)]));
|
|
74
|
-
runParallelFrame(module, frame(3, 3, [player(20)]));
|
|
75
|
-
|
|
76
|
-
expect(runParallelFrame(module, frame(4, 3, [player(10)], { tickDelta: 0 }))).toEqual([]);
|
|
77
|
-
expect(routeState(module)).toMatchObject({ path_length_px: 10, reversal_count: 0 });
|
|
78
|
-
|
|
79
|
-
expect(runParallelFrame(module, frame(5, 4, [player(20)]))).toEqual([]);
|
|
80
|
-
expect(routeState(module)).toMatchObject({
|
|
81
|
-
path_length_px: 20,
|
|
82
|
-
committed_path_length_px: 10,
|
|
83
|
-
reversal_count: 0,
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('does not emit a turn from a provisional coordinate that is revised straight', () => {
|
|
88
|
-
const module = new RouteModule();
|
|
89
|
-
runParallelFrame(module, frame(1, 1, [player(0, 0)]));
|
|
90
|
-
runParallelFrame(module, frame(2, 2, [player(10, 0)]));
|
|
91
|
-
|
|
92
|
-
expect(runParallelFrame(module, frame(3, 3, [player(10, 10)]))).toEqual([]);
|
|
93
|
-
expect(runParallelFrame(module, frame(4, 3, [player(20, 0)], { tickDelta: 0 }))).toEqual([]);
|
|
94
|
-
expect(runParallelFrame(module, frame(5, 4, [player(30, 0)]))).toEqual([]);
|
|
95
|
-
expect(routeState(module)).toMatchObject({ path_length_px: 30, reversal_count: 0 });
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('emits a confirmed turn one distinct tick later with the original route tick', () => {
|
|
99
|
-
const module = new RouteModule();
|
|
100
|
-
runParallelFrame(module, frame(1, 1, [player(0, 0)]));
|
|
101
|
-
runParallelFrame(module, frame(2, 2, [player(10, 0)]));
|
|
102
|
-
expect(runParallelFrame(module, frame(3, 3, [player(10, 10)]))).toEqual([]);
|
|
103
|
-
|
|
104
|
-
expect(runParallelFrame(module, frame(4, 4, [player(10, 20)]))).toMatchObject([{
|
|
105
|
-
type: 'visual.player_turned',
|
|
106
|
-
payload: {
|
|
107
|
-
from_tick: 3,
|
|
108
|
-
to_tick: 3,
|
|
109
|
-
data: { player_id: 'self', direction: '下' },
|
|
110
|
-
},
|
|
111
|
-
}]);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('does not finalize provisional evidence for an events query', () => {
|
|
115
|
-
const module = new RouteModule();
|
|
116
|
-
const tick1 = frame(1, 1, [player(0, 0)]);
|
|
117
|
-
const tick2 = frame(2, 2, [player(10, 0)]);
|
|
118
|
-
const provisionalTurn = frame(3, 3, [player(10, 10)]);
|
|
119
|
-
runParallelFrame(module, tick1);
|
|
120
|
-
runParallelFrame(module, tick2);
|
|
121
|
-
runParallelFrame(module, provisionalTurn);
|
|
122
|
-
|
|
123
|
-
expect(module.flush(boundary('snapshot', provisionalTurn))).toEqual([]);
|
|
124
|
-
expect(routeState(module)).toMatchObject({
|
|
125
|
-
committed_path_length_px: 10,
|
|
126
|
-
pending_tick: 3,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
expect(runParallelFrame(module, frame(4, 3, [player(20, 0)], { tickDelta: 0 }))).toEqual([]);
|
|
130
|
-
expect(runParallelFrame(module, frame(5, 4, [player(30, 0)]))).toEqual([]);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('finalizes provisional evidence once at a hard close', () => {
|
|
134
|
-
const module = new RouteModule();
|
|
135
|
-
const tick1 = frame(1, 1, [player(0, 0)]);
|
|
136
|
-
const tick2 = frame(2, 2, [player(10, 0)]);
|
|
137
|
-
const tick3 = frame(3, 3, [player(10, 10)]);
|
|
138
|
-
runParallelFrame(module, tick1);
|
|
139
|
-
runParallelFrame(module, tick2);
|
|
140
|
-
runParallelFrame(module, tick3);
|
|
141
|
-
|
|
142
|
-
expect(module.flush(boundary('close', tick3))).toMatchObject([{
|
|
143
|
-
type: 'visual.player_turned',
|
|
144
|
-
payload: { from_tick: 3, to_tick: 3 },
|
|
145
|
-
}]);
|
|
146
|
-
expect(routeState(module)).toMatchObject({
|
|
147
|
-
committed_path_length_px: 20,
|
|
148
|
-
pending_tick: null,
|
|
149
|
-
});
|
|
150
|
-
expect(module.flush(boundary('close', tick3))).toEqual([]);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('drops a track on complete same-tick absence so reappearance cannot bridge it', () => {
|
|
154
|
-
const module = new RouteModule();
|
|
155
|
-
runParallelFrame(module, frame(1, 1, [player(0)]));
|
|
156
|
-
runParallelFrame(module, frame(2, 2, [player(10)]));
|
|
157
|
-
|
|
158
|
-
expect(runParallelFrame(module, frame(3, 2, [], { tickDelta: 0 }))).toEqual([]);
|
|
159
|
-
expect(module.debugSnapshot().tracks).toEqual([]);
|
|
160
|
-
expect(runParallelFrame(module, frame(4, 2, [player(100)], { tickDelta: 0 }))).toEqual([]);
|
|
161
|
-
expect(runParallelFrame(module, frame(5, 3, [player(110)]))).toEqual([]);
|
|
162
|
-
expect(routeState(module)).toMatchObject({ path_length_px: 10, reversal_count: 0 });
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('retains a track across an incomplete same-tick visible set', () => {
|
|
166
|
-
const module = new RouteModule();
|
|
167
|
-
runParallelFrame(module, frame(1, 1, [player(0)]));
|
|
168
|
-
runParallelFrame(module, frame(2, 2, [player(10)]));
|
|
169
|
-
|
|
170
|
-
expect(runParallelFrame(module, frame(3, 2, [], {
|
|
171
|
-
tickDelta: 0,
|
|
172
|
-
visibleSetComplete: false,
|
|
173
|
-
}))).toEqual([]);
|
|
174
|
-
expect(module.debugSnapshot().tracks).toHaveLength(1);
|
|
175
|
-
expect(runParallelFrame(module, frame(4, 2, [player(100)], { tickDelta: 0 }))).toEqual([]);
|
|
176
|
-
expect(runParallelFrame(module, frame(5, 3, [player(110)]))).toEqual([]);
|
|
177
|
-
expect(routeState(module)).toMatchObject({ path_length_px: 110, reversal_count: 0 });
|
|
178
|
-
});
|
|
179
|
-
});
|