pi-mega-compact 0.11.3 → 0.11.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/dist/extensions/dashboard-server/api-contracts/endpoints.js +19 -0
- package/dist/extensions/dashboard-server/api-contracts/memory.js +8 -0
- package/dist/extensions/dashboard-server/api-contracts/provider-cache.js +1 -0
- package/dist/extensions/dashboard-server/api-contracts/setup.js +10 -0
- package/dist/extensions/dashboard-server/index-reader.js +6 -2
- package/dist/extensions/dashboard-server/routes-cache.js +115 -55
- package/dist/extensions/dashboard-server/routes-memory.js +51 -0
- package/dist/extensions/dashboard-server/routes-repo.js +2 -2
- package/dist/extensions/dashboard-server/routes-setup.js +162 -0
- package/dist/extensions/dashboard-server/routes.js +2 -0
- package/dist/extensions/dashboard-server/server.js +7 -1
- package/dist/extensions/mega-commands.js +189 -1
- package/dist/extensions/mega-config.js +3 -0
- package/dist/extensions/mega-events/agent-handlers.js +41 -6
- package/dist/extensions/mega-events/compact-handlers.js +1 -0
- package/dist/extensions/mega-events/context-handler.js +37 -92
- package/dist/extensions/mega-events/context-hwm.js +51 -0
- package/dist/extensions/mega-events/error-classifier.js +118 -128
- package/dist/extensions/mega-events/mirror-append.js +107 -0
- package/dist/extensions/mega-events/outage-advisor.js +59 -0
- package/dist/extensions/mega-events/perf-handler.js +51 -1
- package/dist/extensions/mega-events/recall-tail.js +59 -0
- package/dist/extensions/mega-events/session-handlers.js +15 -8
- package/dist/extensions/mega-runtime/reset-runtime.js +6 -0
- package/dist/extensions/mega-runtime/runtime.js +7 -0
- package/dist/src/embedder.js +41 -2
- package/dist/src/memoryStats.js +75 -0
- package/dist/src/prefix-break.js +43 -0
- package/dist/src/pricing.js +1 -1
- package/dist/src/store/sqlite/perf-samples.js +144 -16
- package/dist/src/store/turns/memory-store.js +8 -0
- package/dist/src/store/turns/sqlite-store.js +14 -3
- package/dist/src/store/turns/types.js +18 -1
- package/dist/src/store/vectorIndex.js +26 -5
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js → AchievementTiles-BoL7qBOJ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AchievementTiles-vEo2MtE2.js.map → AchievementTiles-BoL7qBOJ.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/AchievementsTab-BFDE3HYc.js +2 -0
- package/extensions/dashboard-client/dist/assets/{AchievementsTab-DjxfYrDc.js.map → AchievementsTab-BFDE3HYc.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js +2 -0
- package/extensions/dashboard-client/dist/assets/CacheTab-eKVc-NV1.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js → ConfigTab-DDFE-ckA.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-Cm6ymbmx.js.map → ConfigTab-DDFE-ckA.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js → EventsTab-B6UxZ7PM.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-DXWl_YzI.js.map → EventsTab-B6UxZ7PM.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js → GameTab-DehUX-KE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{GameTab-BLDudcO5.js.map → GameTab-DehUX-KE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js → MaintenanceTab-0GWRt4wn.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-DLkKCztn.js.map → MaintenanceTab-0GWRt4wn.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js → MetricsTab-C3rwMVsN.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsTab-Cq4u-rZF.js.map → MetricsTab-C3rwMVsN.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-39O9_x5j.js +2 -0
- package/extensions/dashboard-client/dist/assets/{OverviewTab-D4kGvsiQ.js.map → OverviewTab-39O9_x5j.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js +2 -0
- package/extensions/dashboard-client/dist/assets/ReposTab-Cfj6Q5sH.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js → SessionsTab-DXDTCi3r.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-DZC2-GCn.js.map → SessionsTab-DXDTCi3r.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js +2 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-mMlfunJa.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js +2 -0
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-Cw1dJ4e9.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js → TopicsTab-BAw972BV.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TopicsTab-01G71hv1.js.map → TopicsTab-BAw972BV.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js → TurnsTab-Cf5mGIdl.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnsTab-DLRg0LZT.js.map → TurnsTab-Cf5mGIdl.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js +2 -0
- package/extensions/dashboard-client/dist/assets/format-COjDIVGj.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{index-BX0bcgLu.js → index-4gQ7auad.js} +10 -10
- package/extensions/dashboard-client/dist/assets/index-4gQ7auad.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js +2 -0
- package/extensions/dashboard-client/dist/assets/pricing-CvE4NllQ.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js → useSSE-DNgMuyP6.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BBYt5UPB.js.map → useSSE-DNgMuyP6.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/App.tsx +4 -0
- package/extensions/dashboard-client/src/api/client.ts +14 -0
- package/extensions/dashboard-client/src/components/ActiveReposTable.tsx +21 -12
- package/extensions/dashboard-client/src/components/ProviderCacheCard.tsx +56 -0
- package/extensions/dashboard-client/src/components/SavingsByModelTable.tsx +38 -57
- package/extensions/dashboard-client/src/tabs/CacheTab.tsx +1 -0
- package/extensions/dashboard-client/src/tabs/SetupTab.tsx +355 -0
- package/extensions/dashboard-client/tsconfig.json +3 -2
- package/extensions/dashboard-client/vite.config.ts +2 -0
- package/extensions/dashboard-server/api-contracts/endpoints.ts +36 -3
- package/extensions/dashboard-server/api-contracts/index.ts +7 -0
- package/extensions/dashboard-server/api-contracts/memory.ts +27 -0
- package/extensions/dashboard-server/api-contracts/multi-repo.ts +231 -231
- package/extensions/dashboard-server/api-contracts/provider-cache.ts +37 -0
- package/extensions/dashboard-server/api-contracts/setup.ts +58 -0
- package/extensions/dashboard-server/index-reader.ts +138 -121
- package/extensions/dashboard-server/routes-cache.ts +161 -85
- package/extensions/dashboard-server/routes-memory.ts +63 -0
- package/extensions/dashboard-server/routes-repo.ts +36 -36
- package/extensions/dashboard-server/routes-setup.ts +181 -0
- package/extensions/dashboard-server/routes.ts +2 -0
- package/extensions/dashboard-server/server.ts +6 -0
- package/extensions/mega-commands.ts +211 -1
- package/extensions/mega-config.ts +18 -0
- package/extensions/mega-events/agent-handlers.ts +44 -5
- package/extensions/mega-events/compact-handlers.ts +1 -0
- package/extensions/mega-events/context-handler.ts +45 -110
- package/extensions/mega-events/context-hwm.ts +85 -0
- package/extensions/mega-events/error-classifier.ts +156 -124
- package/extensions/mega-events/mirror-append.ts +155 -0
- package/extensions/mega-events/outage-advisor.ts +79 -0
- package/extensions/mega-events/perf-handler.ts +79 -5
- package/extensions/mega-events/recall-tail.ts +88 -0
- package/extensions/mega-events/session-handlers.ts +14 -7
- package/extensions/mega-runtime/helpers.ts +14 -0
- package/extensions/mega-runtime/reset-runtime.ts +6 -0
- package/extensions/mega-runtime/runtime.ts +7 -0
- package/package.json +5 -2
- package/src/embedder.ts +42 -2
- package/src/memoryStats.ts +107 -0
- package/src/prefix-break.ts +83 -0
- package/src/pricing.ts +2 -2
- package/src/store/sqlite/perf-samples.ts +215 -22
- package/src/store/turns/memory-store.ts +10 -1
- package/src/store/turns/sqlite-store.ts +27 -15
- package/src/store/turns/types.ts +21 -0
- package/src/store/vectorIndex.ts +33 -4
- package/dist/extensions/conflict-scan.test.js +0 -115
- package/dist/extensions/dashboard-server/api-contracts.test.js +0 -884
- package/dist/extensions/dashboard-server/html.test.js +0 -52
- package/dist/extensions/dashboard-server/perf-server.test.js +0 -80
- package/dist/extensions/dashboard-server/routes-cache.test.js +0 -248
- package/dist/extensions/dashboard-server/server.test.js +0 -120
- package/dist/extensions/dashboard-server-s32.test.js +0 -181
- package/dist/extensions/dashboard-server.test.js +0 -339
- package/dist/extensions/mega-cache-replay.test.js +0 -400
- package/dist/extensions/mega-compact-s38.test.js +0 -820
- package/dist/extensions/mega-compact.test.js +0 -1112
- package/dist/extensions/mega-events.test.js +0 -47
- package/dist/extensions/mega-game-cmds.test.js +0 -163
- package/dist/extensions/mega-runtime/snapshot.test.js +0 -127
- package/dist/extensions/mega-runtime/state.test.js +0 -266
- package/dist/extensions/mega-runtime/widget.test.js +0 -343
- package/dist/extensions/mega-shutdown-widget.test.js +0 -121
- package/dist/extensions/mega-teamrun.test.js +0 -156
- package/dist/extensions/mega-trim.test.js +0 -58
- package/dist/extensions/mega-turn-store.test.js +0 -68
- package/dist/src/boundary.test.js +0 -170
- package/dist/src/compact.test.js +0 -78
- package/dist/src/config/themes.test.js +0 -94
- package/dist/src/dedup/dedup.test.js +0 -41
- package/dist/src/dedup/l1.test.js +0 -50
- package/dist/src/dedup/raptor/buildHistory.test.js +0 -292
- package/dist/src/dedup/raptor/multilevel-serve.test.js +0 -229
- package/dist/src/dedup/raptor/multilevel.test.js +0 -238
- package/dist/src/dedup/raptor/promote.test.js +0 -69
- package/dist/src/dedup/raptor/raptor.test.js +0 -248
- package/dist/src/dedup/raptor/retrieval.test.js +0 -95
- package/dist/src/dedup/raptor/serve-gate.test.js +0 -298
- package/dist/src/dedup/sprint12.test.js +0 -219
- package/dist/src/dedup-engine.test.js +0 -472
- package/dist/src/driftDetection.test.js +0 -87
- package/dist/src/e2e.test.js +0 -698
- package/dist/src/engine.test.js +0 -111
- package/dist/src/extractive.test.js +0 -147
- package/dist/src/fork.test.js +0 -81
- package/dist/src/game/scoring.test.js +0 -98
- package/dist/src/httpEmbedder.test.js +0 -277
- package/dist/src/importance.test.js +0 -372
- package/dist/src/intent.test.js +0 -78
- package/dist/src/log.test.js +0 -42
- package/dist/src/mechanical-fix.test.js +0 -65
- package/dist/src/memory.test.js +0 -70
- package/dist/src/memoryConsolidate.test.js +0 -38
- package/dist/src/memoryOps.test.js +0 -129
- package/dist/src/memoryRecall.test.js +0 -171
- package/dist/src/memoryRoundtrip.test.js +0 -137
- package/dist/src/metrics/turns.test.js +0 -152
- package/dist/src/mirror/mirror.test.js +0 -185
- package/dist/src/raptor-inject-summaries.test.js +0 -162
- package/dist/src/ratio.bench.test.js +0 -897
- package/dist/src/recall.integration.test.js +0 -77
- package/dist/src/recall.test.js +0 -379
- package/dist/src/sprint14.test.js +0 -219
- package/dist/src/sprint4x-rag-verification.test.js +0 -93
- package/dist/src/store/compression.test.js +0 -139
- package/dist/src/store/memoryIndex.test.js +0 -51
- package/dist/src/store/migrate.test.js +0 -139
- package/dist/src/store/pgOpenGuard.test.js +0 -74
- package/dist/src/store/phase01.test.js +0 -81
- package/dist/src/store/phase04.test.js +0 -54
- package/dist/src/store/sprint10.test.js +0 -186
- package/dist/src/store/sqlite/game-achievements.test.js +0 -67
- package/dist/src/store/sqlite/game-scores.test.js +0 -106
- package/dist/src/store/sqlite/game-state.test.js +0 -76
- package/dist/src/store/sqlite/global-index.test.js +0 -136
- package/dist/src/store/sqlite/mechanical-fix.test.js +0 -146
- package/dist/src/store/sqlite/perf-samples.test.js +0 -146
- package/dist/src/store/sqlite/raptor.test.js +0 -106
- package/dist/src/store/sqlite/turns.test.js +0 -183
- package/dist/src/store/sqlite.cachehit.test.js +0 -55
- package/dist/src/store/sqlite.dbmaint.test.js +0 -158
- package/dist/src/store/sqlite.dbmirror.test.js +0 -184
- package/dist/src/store/turns/contract-compliance.test.js +0 -428
- package/dist/src/store/turns/memory-store.test.js +0 -9
- package/dist/src/store/turns/migrations.test.js +0 -138
- package/dist/src/store/turns/sqlite-store.test.js +0 -144
- package/dist/src/store/vectorIndex.test.js +0 -123
- package/dist/src/store.test.js +0 -161
- package/dist/src/supersede.test.js +0 -36
- package/dist/src/topics/cluster.test.js +0 -150
- package/dist/src/topics/store.test.js +0 -117
- package/dist/src/types.test.js +0 -9
- package/dist/src/vector-search-cache.test.js +0 -157
- package/dist/src/vectorStore.test.js +0 -479
- package/dist/src/wiki.test.js +0 -171
- package/extensions/conflict-scan.test.ts +0 -129
- package/extensions/dashboard-client/dist/assets/AchievementsTab-DjxfYrDc.js +0 -2
- package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js +0 -2
- package/extensions/dashboard-client/dist/assets/CacheTab-Dnpv94wq.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/OverviewTab-D4kGvsiQ.js +0 -2
- package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js +0 -2
- package/extensions/dashboard-client/dist/assets/ReposTab-C0Wnrf2u.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js +0 -2
- package/extensions/dashboard-client/dist/assets/TimeSavedCard-UqljSyP-.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/index-BX0bcgLu.js.map +0 -1
- package/extensions/dashboard-server/api-contracts.test.ts +0 -1065
- package/extensions/dashboard-server/html.test.ts +0 -62
- package/extensions/dashboard-server/perf-server.test.ts +0 -101
- package/extensions/dashboard-server/routes-cache.test.ts +0 -302
- package/extensions/dashboard-server/server.test.ts +0 -131
- package/extensions/dashboard-server-s32.test.ts +0 -195
- package/extensions/dashboard-server.test.ts +0 -382
- package/extensions/mega-cache-replay.test.ts +0 -526
- package/extensions/mega-compact-s38.test.ts +0 -872
- package/extensions/mega-compact.test.ts +0 -1509
- package/extensions/mega-events.test.ts +0 -55
- package/extensions/mega-game-cmds.test.ts +0 -197
- package/extensions/mega-runtime/snapshot.test.ts +0 -139
- package/extensions/mega-runtime/state.test.ts +0 -262
- package/extensions/mega-runtime/widget.test.ts +0 -468
- package/extensions/mega-shutdown-widget.test.ts +0 -141
- package/extensions/mega-teamrun.test.ts +0 -176
- package/extensions/mega-trim.test.ts +0 -64
- package/extensions/mega-turn-store.test.ts +0 -108
- package/src/boundary.test.ts +0 -187
- package/src/compact.test.ts +0 -99
- package/src/config/themes.test.ts +0 -116
- package/src/dedup/dedup.test.ts +0 -46
- package/src/dedup/l1.test.ts +0 -57
- package/src/dedup/raptor/buildHistory.test.ts +0 -353
- package/src/dedup/raptor/multilevel-serve.test.ts +0 -273
- package/src/dedup/raptor/multilevel.test.ts +0 -325
- package/src/dedup/raptor/promote.test.ts +0 -82
- package/src/dedup/raptor/raptor.test.ts +0 -297
- package/src/dedup/raptor/retrieval.test.ts +0 -118
- package/src/dedup/raptor/serve-gate.test.ts +0 -348
- package/src/dedup/sprint12.test.ts +0 -242
- package/src/dedup-engine.test.ts +0 -670
- package/src/driftDetection.test.ts +0 -100
- package/src/e2e.test.ts +0 -843
- package/src/engine.test.ts +0 -123
- package/src/extractive.test.ts +0 -174
- package/src/fork.test.ts +0 -94
- package/src/game/scoring.test.ts +0 -103
- package/src/httpEmbedder.test.ts +0 -286
- package/src/importance.test.ts +0 -538
- package/src/intent.test.ts +0 -87
- package/src/log.test.ts +0 -47
- package/src/mechanical-fix.test.ts +0 -70
- package/src/memory.test.ts +0 -92
- package/src/memoryConsolidate.test.ts +0 -47
- package/src/memoryOps.test.ts +0 -148
- package/src/memoryRecall.test.ts +0 -194
- package/src/memoryRoundtrip.test.ts +0 -155
- package/src/metrics/turns.test.ts +0 -165
- package/src/mirror/mirror.test.ts +0 -240
- package/src/raptor-inject-summaries.test.ts +0 -228
- package/src/ratio.bench.test.ts +0 -1316
- package/src/recall.integration.test.ts +0 -96
- package/src/recall.test.ts +0 -467
- package/src/sprint14.test.ts +0 -245
- package/src/sprint4x-rag-verification.test.ts +0 -119
- package/src/store/compression.test.ts +0 -168
- package/src/store/memoryIndex.test.ts +0 -61
- package/src/store/migrate.test.ts +0 -158
- package/src/store/pgOpenGuard.test.ts +0 -89
- package/src/store/phase01.test.ts +0 -88
- package/src/store/phase04.test.ts +0 -58
- package/src/store/sprint10.test.ts +0 -214
- package/src/store/sqlite/game-achievements.test.ts +0 -80
- package/src/store/sqlite/game-scores.test.ts +0 -132
- package/src/store/sqlite/game-state.test.ts +0 -89
- package/src/store/sqlite/global-index.test.ts +0 -222
- package/src/store/sqlite/mechanical-fix.test.ts +0 -162
- package/src/store/sqlite/perf-samples.test.ts +0 -169
- package/src/store/sqlite/raptor.test.ts +0 -139
- package/src/store/sqlite/turns.test.ts +0 -218
- package/src/store/sqlite.cachehit.test.ts +0 -68
- package/src/store/sqlite.dbmaint.test.ts +0 -193
- package/src/store/sqlite.dbmirror.test.ts +0 -229
- package/src/store/turns/contract-compliance.test.ts +0 -562
- package/src/store/turns/memory-store.test.ts +0 -15
- package/src/store/turns/migrations.test.ts +0 -161
- package/src/store/turns/sqlite-store.test.ts +0 -161
- package/src/store/vectorIndex.test.ts +0 -140
- package/src/store.test.ts +0 -191
- package/src/supersede.test.ts +0 -42
- package/src/topics/cluster.test.ts +0 -176
- package/src/topics/store.test.ts +0 -132
- package/src/types.test.ts +0 -10
- package/src/vector-search-cache.test.ts +0 -190
- package/src/vectorStore.test.ts +0 -533
- package/src/wiki.test.ts +0 -217
package/dist/src/engine.test.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { test } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { VectorStore, vectorMarkInjected, vectorSearch } from "./vectorStore.js";
|
|
7
|
-
import { compactSession, recall, mergeSummary, supersededCount } from "./engine.js";
|
|
8
|
-
const baseTmp = mkdtempSync(join(tmpdir(), "mc-engine-"));
|
|
9
|
-
let counter = 0;
|
|
10
|
-
function store() {
|
|
11
|
-
return new VectorStore({ dedupSim: 0.9, stateDir: join(baseTmp, `run-${counter++}`) });
|
|
12
|
-
}
|
|
13
|
-
const SESS = "sess_engine";
|
|
14
|
-
function msg(role, text, toolName) {
|
|
15
|
-
return toolName ? { role, text, toolName, input: text, output: text } : { role, text };
|
|
16
|
-
}
|
|
17
|
-
test("compactSession supersedes then persists a checkpoint", () => {
|
|
18
|
-
const s = store();
|
|
19
|
-
const messages = [
|
|
20
|
-
msg("user", "read src/server.ts"),
|
|
21
|
-
msg("assistant", "ok", "Read"),
|
|
22
|
-
msg("user", "edit src/server.ts"),
|
|
23
|
-
msg("assistant", "ok", "Edit"),
|
|
24
|
-
msg("user", "now fix the bug in src/server.ts"),
|
|
25
|
-
msg("assistant", "done", "Edit"),
|
|
26
|
-
];
|
|
27
|
-
const r = compactSession({ sessionId: SESS, messages, keepFrom: 4, timestamp: 1 }, s);
|
|
28
|
-
assert.equal(r.skipped, false);
|
|
29
|
-
assert.equal(r.deduped, false);
|
|
30
|
-
assert.match(r.checkpointId ?? "", /^chkpt_001$/);
|
|
31
|
-
assert.ok(r.summary.length > 0, "summary produced by COLLAPSE");
|
|
32
|
-
assert.ok(r.regionHash.length > 0);
|
|
33
|
-
// SUPERSEDE dropped the obsolete first read turn (user read @0 superseded by
|
|
34
|
-
// the edit @2) — so exactly one superseded message in the compacted slice.
|
|
35
|
-
assert.equal(supersededCount(messages.slice(0, 4)), 1);
|
|
36
|
-
assert.equal(r.compactedFrom, 4);
|
|
37
|
-
// The persisted checkpoint is searchable.
|
|
38
|
-
assert.equal(vectorSearch(s, SESS, "bug src/server.ts", 5).length, 1);
|
|
39
|
-
});
|
|
40
|
-
test("compactSession is idempotent on identical region (dedup sentinel)", () => {
|
|
41
|
-
const s = store();
|
|
42
|
-
const messages = [
|
|
43
|
-
msg("user", "alpha work on the parser"),
|
|
44
|
-
msg("assistant", "did it", "Edit"),
|
|
45
|
-
msg("user", "beta work on the renderer"),
|
|
46
|
-
msg("assistant", "done", "Edit"),
|
|
47
|
-
];
|
|
48
|
-
const r1 = compactSession({ sessionId: SESS, messages, keepFrom: 4, timestamp: 1 }, s);
|
|
49
|
-
const r2 = compactSession({ sessionId: SESS, messages, keepFrom: 4, timestamp: 2 }, s);
|
|
50
|
-
assert.equal(r1.deduped, false);
|
|
51
|
-
assert.equal(r2.deduped, true);
|
|
52
|
-
assert.equal(r1.checkpointId, r2.checkpointId);
|
|
53
|
-
assert.equal(vectorSearch(s, SESS, "parser", 10).length, 1);
|
|
54
|
-
});
|
|
55
|
-
test("compactSession skipped when slice is empty", () => {
|
|
56
|
-
const s = store();
|
|
57
|
-
const r = compactSession({ sessionId: SESS, messages: [msg("user", "only tail")], keepFrom: 0 }, s);
|
|
58
|
-
assert.equal(r.skipped, true);
|
|
59
|
-
assert.equal(vectorSearch(s, SESS, "x", 5).length, 0);
|
|
60
|
-
});
|
|
61
|
-
test("recall drops already-injected checkpoints", () => {
|
|
62
|
-
const s = store();
|
|
63
|
-
compactSession({ sessionId: SESS, messages: [msg("user", "investigated src/vectorStore.ts"), msg("assistant", "ok", "Edit")], keepFrom: 2, timestamp: 1 }, s);
|
|
64
|
-
const first = recall({ sessionId: SESS, query: "vectorStore", limit: 5, skipInjected: true }, s);
|
|
65
|
-
assert.equal(first.newHits.length, 1);
|
|
66
|
-
vectorMarkInjected(s, SESS, first.hits[0].checkpoint.checkpointId);
|
|
67
|
-
const second = recall({ sessionId: SESS, query: "vectorStore", limit: 5, skipInjected: true }, s);
|
|
68
|
-
assert.equal(second.newHits.length, 0);
|
|
69
|
-
// Without the skip flag, both hits still surface.
|
|
70
|
-
assert.equal(second.hits.length, 1);
|
|
71
|
-
});
|
|
72
|
-
test("mergeSummary accumulates prior + new context", () => {
|
|
73
|
-
const prior = "<summary>Conversation summary:\n- Key files referenced: src/a.ts.\n</summary>";
|
|
74
|
-
const next = "<summary>Conversation summary:\n- Key files referenced: src/b.ts.\n</summary>";
|
|
75
|
-
const merged = mergeSummary(prior, next);
|
|
76
|
-
assert.ok(merged.includes("src/a.ts"));
|
|
77
|
-
assert.ok(merged.includes("src/b.ts"));
|
|
78
|
-
assert.ok(merged.includes("Newly compacted"));
|
|
79
|
-
});
|
|
80
|
-
test("supersededCount reports obsolete reads", () => {
|
|
81
|
-
const messages = [
|
|
82
|
-
msg("user", "read src/x.ts"),
|
|
83
|
-
msg("assistant", "ok", "Read"),
|
|
84
|
-
msg("user", "write src/x.ts"),
|
|
85
|
-
msg("assistant", "ok", "Edit"),
|
|
86
|
-
];
|
|
87
|
-
assert.equal(supersededCount(messages), 1);
|
|
88
|
-
});
|
|
89
|
-
test("compactSession with useExtractive produces topicSummary on checkpoint", () => {
|
|
90
|
-
const s = store();
|
|
91
|
-
const messages = [
|
|
92
|
-
msg("user", "let's refactor the auth module in src/auth.ts"),
|
|
93
|
-
msg("assistant", "I'll start by reading the current implementation", "Read"),
|
|
94
|
-
msg("user", "extract the login logic into a separate function"),
|
|
95
|
-
msg("assistant", "Extracted login() into src/auth.ts:45", "Edit"),
|
|
96
|
-
msg("user", "now add the session token generation"),
|
|
97
|
-
msg("assistant", "Added generateSessionToken in src/auth.ts:78", "Edit"),
|
|
98
|
-
];
|
|
99
|
-
const r = compactSession({ sessionId: "sess_extr", messages, keepFrom: 4, timestamp: 1, useExtractiveSummary: true }, s);
|
|
100
|
-
assert.equal(r.skipped, false);
|
|
101
|
-
assert.ok(r.checkpointId, "checkpoint created");
|
|
102
|
-
// The checkpoint should have topicSummary populated
|
|
103
|
-
const hits = vectorSearch(s, "sess_extr", "auth refactor", 5);
|
|
104
|
-
assert.ok(hits.length > 0);
|
|
105
|
-
// topicSummary should be present on the stored checkpoint (via extractive path)
|
|
106
|
-
assert.ok(hits[0].checkpoint.topicSummary, "topicSummary should be populated when useExtractive is true");
|
|
107
|
-
assert.ok(hits[0].checkpoint.topicSummary.length > 0);
|
|
108
|
-
});
|
|
109
|
-
test("cleanup", () => {
|
|
110
|
-
rmSync(baseTmp, { recursive: true, force: true });
|
|
111
|
-
});
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { test } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { extractiveSummarize } from "./extractive.js";
|
|
4
|
-
function msg(role, text, toolName) {
|
|
5
|
-
return toolName ? { role, text, toolName, input: text, output: text } : { role, text };
|
|
6
|
-
}
|
|
7
|
-
// ---- Crash regression: undefined text (S25 hotfix) ------------------------
|
|
8
|
-
// pi tool/custom messages can arrive with `text: undefined` when only
|
|
9
|
-
// input/output is set. The adapter (adapt.ts) now coerces to "", and
|
|
10
|
-
// extractiveSummarize guards its entry too. This test pins the no-crash
|
|
11
|
-
// contract directly against the engine entry (defense in depth).
|
|
12
|
-
test("extractiveSummarize does not crash on messages with undefined text", () => {
|
|
13
|
-
const messages = [
|
|
14
|
-
{ role: "user", text: "please edit src/index.ts" },
|
|
15
|
-
{ role: "assistant", text: undefined, toolName: "Edit", input: "src/index.ts" },
|
|
16
|
-
{ role: "tool", text: undefined, toolName: "Edit", output: "ok" },
|
|
17
|
-
{ role: "assistant", text: "done editing src/index.ts" },
|
|
18
|
-
];
|
|
19
|
-
// Must not throw — previously crashed at text.matchAll in extractFilePaths.
|
|
20
|
-
const s = extractiveSummarize(messages);
|
|
21
|
-
assert.ok(typeof s.topicSummary === "string");
|
|
22
|
-
assert.ok(s.topicSummary.length >= 0);
|
|
23
|
-
});
|
|
24
|
-
// ---- Determinism -----------------------------------------------------------
|
|
25
|
-
test("extractive summary is deterministic", () => {
|
|
26
|
-
const messages = [
|
|
27
|
-
msg("user", "please write src/index.ts"),
|
|
28
|
-
msg("assistant", "I'll write src/index.ts now."),
|
|
29
|
-
msg("tool", '{"file_path":"src/index.ts"}', "write"),
|
|
30
|
-
msg("assistant", "Done."),
|
|
31
|
-
];
|
|
32
|
-
const s1 = extractiveSummarize(messages);
|
|
33
|
-
const s2 = extractiveSummarize(messages);
|
|
34
|
-
assert.deepStrictEqual(s1, s2);
|
|
35
|
-
});
|
|
36
|
-
// ---- Compression -----------------------------------------------------------
|
|
37
|
-
test("extractive summary produces small output", () => {
|
|
38
|
-
// Build 70 messages (simulating a session)
|
|
39
|
-
const messages = [];
|
|
40
|
-
for (let i = 0; i < 70; i++) {
|
|
41
|
-
messages.push(msg("user", `request ${i}: please help with feature ${i}`));
|
|
42
|
-
messages.push(msg("assistant", `working on feature ${i} in src/file${i % 5}.ts`));
|
|
43
|
-
messages.push(msg("tool", `{"file_path":"src/file${i % 5}.ts","content":"..."}`, "write"));
|
|
44
|
-
messages.push(msg("assistant", `done with feature ${i}`));
|
|
45
|
-
}
|
|
46
|
-
const rawText = messages.map((m) => m.text).join("\n");
|
|
47
|
-
const rawTokens = Math.ceil(rawText.length / 4);
|
|
48
|
-
const summary = extractiveSummarize(messages);
|
|
49
|
-
const ratio = rawTokens / summary.tokenEstimate;
|
|
50
|
-
// Compression should be at least 5:1 (target is 35:1)
|
|
51
|
-
assert.ok(ratio >= 5, `compression ratio ${ratio.toFixed(1)}:1 is less than 5:1`);
|
|
52
|
-
assert.ok(summary.tokenEstimate < 5000, `summary is ${summary.tokenEstimate} tokens (expected < 5000)`);
|
|
53
|
-
});
|
|
54
|
-
// ---- Empty input ------------------------------------------------------------
|
|
55
|
-
test("empty messages returns minimal summary", () => {
|
|
56
|
-
const summary = extractiveSummarize([]);
|
|
57
|
-
assert.equal(summary.topicSummary, "(empty)");
|
|
58
|
-
assert.equal(summary.keyDecisions.length, 0);
|
|
59
|
-
assert.equal(summary.nextSteps.length, 0);
|
|
60
|
-
assert.equal(summary.filesModified.length, 0);
|
|
61
|
-
assert.equal(summary.tokenEstimate, 0);
|
|
62
|
-
});
|
|
63
|
-
// ---- Key decisions ----------------------------------------------------------
|
|
64
|
-
test("extracts decisions from assistant messages", () => {
|
|
65
|
-
const messages = [
|
|
66
|
-
msg("user", "which database should we use?"),
|
|
67
|
-
msg("assistant", "I recommend using better-sqlite3 for the local vector store."),
|
|
68
|
-
msg("assistant", "Let's go with the Trident pipeline architecture."),
|
|
69
|
-
];
|
|
70
|
-
const summary = extractiveSummarize(messages);
|
|
71
|
-
assert.ok(summary.keyDecisions.length >= 1, "should extract at least 1 decision");
|
|
72
|
-
assert.ok(summary.keyDecisions.some((d) => d.includes("better-sqlite3")), `decisions: ${JSON.stringify(summary.keyDecisions)}`);
|
|
73
|
-
});
|
|
74
|
-
test("no decisions in tool messages", () => {
|
|
75
|
-
const messages = [
|
|
76
|
-
msg("tool", "I recommend something", "bash"),
|
|
77
|
-
];
|
|
78
|
-
const summary = extractiveSummarize(messages);
|
|
79
|
-
// Tool messages should not be checked for decisions
|
|
80
|
-
assert.equal(summary.keyDecisions.length, 0);
|
|
81
|
-
});
|
|
82
|
-
// ---- Files modified ---------------------------------------------------------
|
|
83
|
-
test("extracts files from write/edit tool calls", () => {
|
|
84
|
-
const messages = [
|
|
85
|
-
msg("tool", '{"file_path":"/home/user/project/src/index.ts","content":"..."}', "write"),
|
|
86
|
-
msg("tool", '{"file_path":"/home/user/project/README.md","content":"..."}', "edit"),
|
|
87
|
-
];
|
|
88
|
-
const summary = extractiveSummarize(messages);
|
|
89
|
-
assert.ok(summary.filesModified.includes("/home/user/project/src/index.ts"));
|
|
90
|
-
assert.ok(summary.filesModified.includes("/home/user/project/README.md"));
|
|
91
|
-
});
|
|
92
|
-
test("extracts files from git commands in bash", () => {
|
|
93
|
-
const messages = [
|
|
94
|
-
msg("tool", "git add src/index.ts src/types.ts", "bash"),
|
|
95
|
-
];
|
|
96
|
-
const summary = extractiveSummarize(messages);
|
|
97
|
-
assert.ok(summary.filesModified.some((f) => f.includes("index.ts")));
|
|
98
|
-
});
|
|
99
|
-
// ---- Pending work -----------------------------------------------------------
|
|
100
|
-
test("extracts pending work markers", () => {
|
|
101
|
-
const messages = [
|
|
102
|
-
msg("user", "run the tests"),
|
|
103
|
-
msg("assistant", "Tests pass. TODO: add integration tests for the dedup path."),
|
|
104
|
-
];
|
|
105
|
-
const summary = extractiveSummarize(messages);
|
|
106
|
-
assert.ok(summary.nextSteps.length >= 1, "should find TODO");
|
|
107
|
-
assert.ok(summary.nextSteps.some((s) => /integration tests/i.test(s)));
|
|
108
|
-
});
|
|
109
|
-
// ---- topicSummary structure -------------------------------------------------
|
|
110
|
-
test("topicSummary contains scope line", () => {
|
|
111
|
-
const messages = [
|
|
112
|
-
msg("user", "hello"),
|
|
113
|
-
msg("assistant", "hi there"),
|
|
114
|
-
];
|
|
115
|
-
const summary = extractiveSummarize(messages);
|
|
116
|
-
assert.ok(summary.topicSummary.includes("Conversation: 2 messages"));
|
|
117
|
-
assert.ok(summary.topicSummary.includes("1 user"));
|
|
118
|
-
assert.ok(summary.topicSummary.includes("1 assistant"));
|
|
119
|
-
});
|
|
120
|
-
test("topicSummary includes tools when present", () => {
|
|
121
|
-
const messages = [
|
|
122
|
-
msg("tool", "ok", "write"),
|
|
123
|
-
msg("tool", "ok", "bash"),
|
|
124
|
-
];
|
|
125
|
-
const summary = extractiveSummarize(messages);
|
|
126
|
-
assert.ok(summary.topicSummary.includes("Tools:"));
|
|
127
|
-
assert.ok(summary.topicSummary.includes("write"));
|
|
128
|
-
assert.ok(summary.topicSummary.includes("bash"));
|
|
129
|
-
});
|
|
130
|
-
// ---- Same messages produce same summary ------------------------------------
|
|
131
|
-
test("deterministic across invocations with complex input", () => {
|
|
132
|
-
const messages = [
|
|
133
|
-
msg("user", "help me refactor the auth module"),
|
|
134
|
-
msg("assistant", "I'll look at the current auth implementation."),
|
|
135
|
-
msg("tool", '{"file_path":"src/auth.ts"}', "read"),
|
|
136
|
-
msg("assistant", "I recommend splitting auth.ts into separate files."),
|
|
137
|
-
msg("user", "sounds good, go ahead"),
|
|
138
|
-
msg("assistant", "I'll create src/auth/login.ts and src/auth/register.ts."),
|
|
139
|
-
msg("tool", '{"file_path":"src/auth/login.ts","content":"..."}', "write"),
|
|
140
|
-
msg("tool", '{"file_path":"src/auth/register.ts","content":"..."}', "write"),
|
|
141
|
-
msg("assistant", "Done. TODO: update the import paths in main.ts."),
|
|
142
|
-
];
|
|
143
|
-
const results = Array.from({ length: 5 }, () => extractiveSummarize(messages));
|
|
144
|
-
for (let i = 1; i < results.length; i++) {
|
|
145
|
-
assert.deepStrictEqual(results[i], results[0], `run ${i} differs from run 0`);
|
|
146
|
-
}
|
|
147
|
-
});
|
package/dist/src/fork.test.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* fork.test.ts — S50C fork primitive tests. No network; temp dirs.
|
|
3
|
-
*
|
|
4
|
-
* Uses the contract-first TurnStore (createTurnStore({ stateDir })).
|
|
5
|
-
*/
|
|
6
|
-
import { test, beforeEach, afterEach } from "node:test";
|
|
7
|
-
import assert from "node:assert/strict";
|
|
8
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
9
|
-
import { tmpdir } from "node:os";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
import { createTurnStore, closeAllTurnDbs } from "./store/turns/index.js";
|
|
12
|
-
import { forkFromConversation, ForkError } from "./fork.js";
|
|
13
|
-
let tmpDir;
|
|
14
|
-
let counter = 0;
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
tmpDir = mkdtempSync(join(tmpdir(), "mc-fork-"));
|
|
17
|
-
});
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
closeAllTurnDbs();
|
|
20
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
21
|
-
});
|
|
22
|
-
function stateDir() {
|
|
23
|
-
return join(tmpDir, `run-${counter++}`);
|
|
24
|
-
}
|
|
25
|
-
test("fork resolves the turn + returns the recall set to rehydrate", () => {
|
|
26
|
-
const dir = stateDir();
|
|
27
|
-
const store = createTurnStore({ stateDir: dir });
|
|
28
|
-
const conv = store.ensureConversationId("sess_f");
|
|
29
|
-
const turnId = store.appendTurn({
|
|
30
|
-
conversationId: conv,
|
|
31
|
-
sessionId: "sess_f",
|
|
32
|
-
turnIndex: 2,
|
|
33
|
-
role: "assistant",
|
|
34
|
-
endedAt: Date.now(),
|
|
35
|
-
});
|
|
36
|
-
store.appendRecall({
|
|
37
|
-
turnId: turnId,
|
|
38
|
-
checkpointId: "cp_a",
|
|
39
|
-
score: 0.9,
|
|
40
|
-
source: "checkpoint",
|
|
41
|
-
});
|
|
42
|
-
store.appendRecall({
|
|
43
|
-
turnId: turnId,
|
|
44
|
-
checkpointId: "cp_b",
|
|
45
|
-
score: 0.7,
|
|
46
|
-
source: "cluster_summary",
|
|
47
|
-
raptorLevel: 1,
|
|
48
|
-
});
|
|
49
|
-
const out = forkFromConversation(store, conv, 2);
|
|
50
|
-
assert.ok(out.childConversationId.startsWith("conv_"));
|
|
51
|
-
assert.notEqual(out.childConversationId, conv);
|
|
52
|
-
assert.equal(out.forkTurn.turnIndex, 2);
|
|
53
|
-
assert.deepEqual(out.checkpointIds.sort(), ["cp_a", "cp_b"]);
|
|
54
|
-
assert.equal(out.recalled.length, 2);
|
|
55
|
-
store.close();
|
|
56
|
-
});
|
|
57
|
-
test("unknown turn → ForkError TURN_NOT_FOUND", () => {
|
|
58
|
-
const dir = stateDir();
|
|
59
|
-
const store = createTurnStore({ stateDir: dir });
|
|
60
|
-
const conv = store.ensureConversationId("sess_g");
|
|
61
|
-
assert.throws(() => forkFromConversation(store, conv, 99), (e) => {
|
|
62
|
-
return e instanceof ForkError && e.code === "TURN_NOT_FOUND";
|
|
63
|
-
});
|
|
64
|
-
store.close();
|
|
65
|
-
});
|
|
66
|
-
test("turn with no recall set → ForkError NO_RECALL", () => {
|
|
67
|
-
const dir = stateDir();
|
|
68
|
-
const store = createTurnStore({ stateDir: dir });
|
|
69
|
-
const conv = store.ensureConversationId("sess_h");
|
|
70
|
-
store.appendTurn({
|
|
71
|
-
conversationId: conv,
|
|
72
|
-
sessionId: "sess_h",
|
|
73
|
-
turnIndex: 0,
|
|
74
|
-
role: "assistant",
|
|
75
|
-
endedAt: Date.now(),
|
|
76
|
-
});
|
|
77
|
-
assert.throws(() => forkFromConversation(store, conv, 0), (e) => {
|
|
78
|
-
return e instanceof ForkError && e.code === "NO_RECALL";
|
|
79
|
-
});
|
|
80
|
-
store.close();
|
|
81
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scoring.test.ts — S33 pure scoring helpers. Pi-agnostic, no I/O.
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it } from "node:test";
|
|
5
|
-
import assert from "node:assert/strict";
|
|
6
|
-
import { turnLevel, isMegaCache, cacheScore, evaluateAchievements, maxCompactCount, ACHIEVEMENT_DEFS } from "./scoring.js";
|
|
7
|
-
describe("scoring (S33)", () => {
|
|
8
|
-
it("turnLevel: floor(log2(n+1))+1 sequence", () => {
|
|
9
|
-
assert.equal(turnLevel(0), 1);
|
|
10
|
-
assert.equal(turnLevel(1), 2);
|
|
11
|
-
assert.equal(turnLevel(2), 2);
|
|
12
|
-
assert.equal(turnLevel(3), 3);
|
|
13
|
-
assert.equal(turnLevel(4), 3);
|
|
14
|
-
assert.equal(turnLevel(7), 4);
|
|
15
|
-
assert.equal(turnLevel(15), 5);
|
|
16
|
-
// defensive: non-finite / negative inputs collapse to level 1
|
|
17
|
-
assert.equal(turnLevel(-1), 1);
|
|
18
|
-
assert.equal(turnLevel(NaN), 1);
|
|
19
|
-
});
|
|
20
|
-
it("isMegaCache: 100% is the boundary", () => {
|
|
21
|
-
assert.equal(isMegaCache(99.9), false);
|
|
22
|
-
assert.equal(isMegaCache(100), true);
|
|
23
|
-
assert.equal(isMegaCache(150), true);
|
|
24
|
-
assert.equal(isMegaCache(0), false);
|
|
25
|
-
assert.equal(isMegaCache(NaN), false);
|
|
26
|
-
});
|
|
27
|
-
it("cacheScore: 0 lookups -> 0 (not NaN), else hits/lookups*100", () => {
|
|
28
|
-
assert.equal(cacheScore(0, 0), 0);
|
|
29
|
-
assert.equal(cacheScore(7, 10), 70);
|
|
30
|
-
assert.equal(cacheScore(0, 5), 0);
|
|
31
|
-
assert.equal(cacheScore(10, 10), 100);
|
|
32
|
-
// non-finite inputs are guarded (no NaN leaks)
|
|
33
|
-
assert.equal(cacheScore(1, NaN), 0);
|
|
34
|
-
assert.equal(cacheScore(NaN, 5), 0);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
function achRow(value, opts = {}) {
|
|
38
|
-
return { repo_root: "/repo/a", value, ts: opts.ts ?? 1_700_000_000_000, meta: opts.meta ?? null };
|
|
39
|
-
}
|
|
40
|
-
describe("evaluateAchievements (S35)", () => {
|
|
41
|
-
const empty = { dedupe: [], turns: [], cache: [], megaCache: [], reposCount: 0 };
|
|
42
|
-
it("ACHIEVEMENT_DEFS: 9 achievements, exactly 1 hidden", () => {
|
|
43
|
-
assert.equal(ACHIEVEMENT_DEFS.length, 9);
|
|
44
|
-
assert.equal(ACHIEVEMENT_DEFS.filter((d) => d.hidden).length, 1);
|
|
45
|
-
});
|
|
46
|
-
it("first_compact: >=1 dedupe row", () => {
|
|
47
|
-
const r = evaluateAchievements({ ...empty, dedupe: [achRow(1)] }, []);
|
|
48
|
-
assert.ok(r.unlocked.includes("first_compact"));
|
|
49
|
-
assert.ok(r.newlyUnlocked.includes("first_compact"));
|
|
50
|
-
});
|
|
51
|
-
it("compact_streak: max meta.compactCount >= 5", () => {
|
|
52
|
-
const r = evaluateAchievements({ ...empty, dedupe: [achRow(1, { meta: { compactCount: 5 } })] }, []);
|
|
53
|
-
assert.ok(r.unlocked.includes("compact_streak"));
|
|
54
|
-
});
|
|
55
|
-
it("turn_veteran: max turns >= 25", () => {
|
|
56
|
-
const r = evaluateAchievements({ ...empty, turns: [achRow(25)] }, []);
|
|
57
|
-
assert.ok(r.unlocked.includes("turn_veteran"));
|
|
58
|
-
});
|
|
59
|
-
it("level_five: turnLevel(maxTurns) >= 5 (15 turns)", () => {
|
|
60
|
-
const r = evaluateAchievements({ ...empty, turns: [achRow(15)] }, []);
|
|
61
|
-
assert.ok(r.unlocked.includes("level_five"));
|
|
62
|
-
});
|
|
63
|
-
it("dedupe_master: sum dedupe >= 100", () => {
|
|
64
|
-
const r = evaluateAchievements({ ...empty, dedupe: [achRow(60), achRow(40)] }, []);
|
|
65
|
-
assert.ok(r.unlocked.includes("dedupe_master"));
|
|
66
|
-
});
|
|
67
|
-
it("repo_explorer: reposCount >= 3", () => {
|
|
68
|
-
const r = evaluateAchievements({ ...empty, reposCount: 3 }, []);
|
|
69
|
-
assert.ok(r.unlocked.includes("repo_explorer"));
|
|
70
|
-
});
|
|
71
|
-
it("night_owl: a row whose local hour is in [0,5)", () => {
|
|
72
|
-
const d = new Date();
|
|
73
|
-
d.setHours(2, 0, 0, 0);
|
|
74
|
-
const r = evaluateAchievements({ ...empty, cache: [achRow(50, { ts: d.getTime() })] }, []);
|
|
75
|
-
assert.ok(r.unlocked.includes("night_owl"));
|
|
76
|
-
});
|
|
77
|
-
it("flawless: maxCache >= 100 AND no mega_cache overshoot", () => {
|
|
78
|
-
const r = evaluateAchievements({ ...empty, cache: [achRow(100)], megaCache: [] }, []);
|
|
79
|
-
assert.ok(r.unlocked.includes("flawless"));
|
|
80
|
-
});
|
|
81
|
-
it("flawless NOT when a mega_cache overshoot row (>100) exists", () => {
|
|
82
|
-
const r = evaluateAchievements({ ...empty, cache: [achRow(100)], megaCache: [achRow(101)] }, []);
|
|
83
|
-
assert.ok(!r.unlocked.includes("flawless"));
|
|
84
|
-
});
|
|
85
|
-
it("opie_wild_ride: any mega_cache trophy row exists", () => {
|
|
86
|
-
const r = evaluateAchievements({ ...empty, megaCache: [achRow(100)] }, []);
|
|
87
|
-
assert.ok(r.unlocked.includes("opie_wild_ride"));
|
|
88
|
-
});
|
|
89
|
-
it("newlyUnlocked excludes ids already unlocked", () => {
|
|
90
|
-
const r = evaluateAchievements({ ...empty, dedupe: [achRow(1)] }, ["first_compact"]);
|
|
91
|
-
assert.ok(r.unlocked.includes("first_compact"));
|
|
92
|
-
assert.ok(!r.newlyUnlocked.includes("first_compact"));
|
|
93
|
-
});
|
|
94
|
-
it("maxCompactCount: 0 when meta absent, else the max", () => {
|
|
95
|
-
assert.equal(maxCompactCount([achRow(1)]), 0);
|
|
96
|
-
assert.equal(maxCompactCount([achRow(1, { meta: { compactCount: 7 } })]), 7);
|
|
97
|
-
});
|
|
98
|
-
});
|