diff --git a/AGENTS.md b/AGENTS.md index 3897c7910e..81b4eed6fa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -101,7 +101,7 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import). ## Testing -- Before every commit run, in order: `npm run build`, `npm run skills:gen`, `npm run docs:sync`, `npm run skills:check`, `npm test` (4,700+ tests). Commit anything the generators changed. CI runs the same build, skills check and tests. +- Before every commit run, in order: `npm run build`, `npm run skills:gen`, `npm run docs:sync`, `npm run skills:check`, `npm test` (4,800+ tests). Commit anything the generators changed. CI runs the same build, skills check and tests. - Before any npm publish: `npm run release:gate` must pass. It installs the packed tarballs into a clean home and runs capture, recovery, restart, export/import, MCP and status checks against the installed CLI (see CONTRIBUTING.md, Release process) - Mock pattern: `vi.mock("iii-sdk")` with mock `sdk.trigger`, `kv.get/set/list` - Test files go in `test/` with `.test.ts` extension @@ -114,4 +114,4 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import). - 6 MCP resources, 3 MCP prompts - 12 hooks, 17 skills - 322+ iii functions -- 4,700+ tests +- 4,800+ tests diff --git a/README.md b/README.md index cd40701a05..7590f939b8 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1313,7 +1313,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ar-SA.md b/READMEs/README.ar-SA.md index 19dfdad2f8..40b6c0699d 100644 --- a/READMEs/README.ar-SA.md +++ b/READMEs/README.ar-SA.md @@ -71,7 +71,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1244,7 +1244,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.bn-BD.md b/READMEs/README.bn-BD.md index a0881d0c27..b16b1f7bd4 100644 --- a/READMEs/README.bn-BD.md +++ b/READMEs/README.bn-BD.md @@ -69,7 +69,7 @@ 54 MCP টুল 12 অটো হুক 0 এক্সটার্নাল ডিবি - 4,700+ টেস্ট পাস + 4,800+ টেস্ট পাস

@@ -1257,7 +1257,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.cs-CZ.md b/READMEs/README.cs-CZ.md index 3837c5eb6e..41c98ab4df 100644 --- a/READMEs/README.cs-CZ.md +++ b/READMEs/README.cs-CZ.md @@ -69,7 +69,7 @@ 54 MCP nástrojů 12 automatických hooks 0 externích databází - 4,700+ testů úspěšně proběhlo + 4,800+ testů úspěšně proběhlo

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.da-DK.md b/READMEs/README.da-DK.md index 209257de1f..6e96f1ad65 100644 --- a/READMEs/README.da-DK.md +++ b/READMEs/README.da-DK.md @@ -69,7 +69,7 @@ 54 MCP-værktøjer 12 automatiske hooks 0 eksterne databaser - 4,700+ beståede tests + 4,800+ beståede tests

@@ -1251,7 +1251,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.de-DE.md b/READMEs/README.de-DE.md index a0b4b683b8..f09b2211b6 100644 --- a/READMEs/README.de-DE.md +++ b/READMEs/README.de-DE.md @@ -69,7 +69,7 @@ 54 MCP-Tools 12 Auto-Hooks 0 externe DBs - 4,700+ bestandene Tests + 4,800+ bestandene Tests

@@ -1249,7 +1249,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.el-GR.md b/READMEs/README.el-GR.md index 49f0fb50b2..20190d727a 100644 --- a/READMEs/README.el-GR.md +++ b/READMEs/README.el-GR.md @@ -69,7 +69,7 @@ 54 εργαλεία MCP 12 αυτόματα hooks 0 εξωτερικές βάσεις δεδομένων - 4,700+ επιτυχημένες δοκιμές + 4,800+ επιτυχημένες δοκιμές

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.es-ES.md b/READMEs/README.es-ES.md index 0cf25dab97..6ca88703a2 100644 --- a/READMEs/README.es-ES.md +++ b/READMEs/README.es-ES.md @@ -69,7 +69,7 @@ 54 tools MCP 12 hooks automáticos 0 bases de datos externas - 4,700+ tests superados + 4,800+ tests superados

@@ -1245,7 +1245,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.fi-FI.md b/READMEs/README.fi-FI.md index c580718e9f..c82e700071 100644 --- a/READMEs/README.fi-FI.md +++ b/READMEs/README.fi-FI.md @@ -69,7 +69,7 @@ 54 MCP-työkalua 12 automaattista hookia 0 ulkoista tietokantaa - 4,700+ testiä läpäisty + 4,800+ testiä läpäisty

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.fr-FR.md b/READMEs/README.fr-FR.md index 3f508c8454..981e72e4f9 100644 --- a/READMEs/README.fr-FR.md +++ b/READMEs/README.fr-FR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1252,7 +1252,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.he-IL.md b/READMEs/README.he-IL.md index 73f6e4a233..313f456302 100644 --- a/READMEs/README.he-IL.md +++ b/READMEs/README.he-IL.md @@ -71,7 +71,7 @@ 54 כלי MCP 12 hooks אוטומטיים 0 מסדי נתונים חיצוניים - 4,700+ בדיקות עוברות + 4,800+ בדיקות עוברות

@@ -1244,7 +1244,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.hi-IN.md b/READMEs/README.hi-IN.md index 4c3a8d31e2..9bed3ca5eb 100644 --- a/READMEs/README.hi-IN.md +++ b/READMEs/README.hi-IN.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1258,7 +1258,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.hu-HU.md b/READMEs/README.hu-HU.md index 20d0e86604..819b196d68 100644 --- a/READMEs/README.hu-HU.md +++ b/READMEs/README.hu-HU.md @@ -69,7 +69,7 @@ 54 MCP eszköz 12 automatikus hook 0 külső adatbázis - 4,700+ sikeres teszt + 4,800+ sikeres teszt

@@ -1241,7 +1241,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.id-ID.md b/READMEs/README.id-ID.md index 855cd4dd52..a5813dcfc8 100644 --- a/READMEs/README.id-ID.md +++ b/READMEs/README.id-ID.md @@ -69,7 +69,7 @@ 54 tool MCP 12 hook otomatis 0 DB eksternal - 4,700+ pengujian lolos + 4,800+ pengujian lolos

@@ -1258,7 +1258,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.it-IT.md b/READMEs/README.it-IT.md index cd396e06e9..a2e6f3aa8e 100644 --- a/READMEs/README.it-IT.md +++ b/READMEs/README.it-IT.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1251,7 +1251,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ja-JP.md b/READMEs/README.ja-JP.md index 9dfe1e726c..412d9f4224 100644 --- a/READMEs/README.ja-JP.md +++ b/READMEs/README.ja-JP.md @@ -69,7 +69,7 @@ 54 MCP ツール 12 自動 hooks 外部 DB 0 個 - 4,700+ 件のテストが成功 + 4,800+ 件のテストが成功

@@ -1257,7 +1257,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ko-KR.md b/READMEs/README.ko-KR.md index 4c77e312b0..db1bee6bd2 100644 --- a/READMEs/README.ko-KR.md +++ b/READMEs/README.ko-KR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1256,7 +1256,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.nb-NO.md b/READMEs/README.nb-NO.md index e617bec5e1..def9fa24d0 100644 --- a/READMEs/README.nb-NO.md +++ b/READMEs/README.nb-NO.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1249,7 +1249,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.nl-NL.md b/READMEs/README.nl-NL.md index ab0aa4972b..a41ab0bf2e 100644 --- a/READMEs/README.nl-NL.md +++ b/READMEs/README.nl-NL.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1245,7 +1245,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.pl-PL.md b/READMEs/README.pl-PL.md index c24834e624..be1064ea75 100644 --- a/READMEs/README.pl-PL.md +++ b/READMEs/README.pl-PL.md @@ -69,7 +69,7 @@ 54 narzędzia MCP 12 automatycznych hooków 0 zewnętrznych baz danych - 4,700+ zaliczonych testów + 4,800+ zaliczonych testów

@@ -1241,7 +1241,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.pt-BR.md b/READMEs/README.pt-BR.md index 8cba9a4b83..14023e43ce 100644 --- a/READMEs/README.pt-BR.md +++ b/READMEs/README.pt-BR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1249,7 +1249,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.pt-PT.md b/READMEs/README.pt-PT.md index c237b780d8..3f2e79bb91 100644 --- a/READMEs/README.pt-PT.md +++ b/READMEs/README.pt-PT.md @@ -69,7 +69,7 @@ 54 ferramentas MCP 12 hooks automáticos 0 bases de dados externas - 4,700+ testes aprovados + 4,800+ testes aprovados

@@ -1245,7 +1245,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ro-RO.md b/READMEs/README.ro-RO.md index 620d55913d..91d70e2ffe 100644 --- a/READMEs/README.ro-RO.md +++ b/READMEs/README.ro-RO.md @@ -69,7 +69,7 @@ 54 de instrumente MCP 12 hook-uri automate 0 baze de date externe - 4,700+ teste trecute + 4,800+ teste trecute

@@ -1237,7 +1237,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ru-RU.md b/READMEs/README.ru-RU.md index 3086998cdd..aed56590dc 100644 --- a/READMEs/README.ru-RU.md +++ b/READMEs/README.ru-RU.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.sv-SE.md b/READMEs/README.sv-SE.md index c29d00dbee..fc2f4d5b80 100644 --- a/READMEs/README.sv-SE.md +++ b/READMEs/README.sv-SE.md @@ -69,7 +69,7 @@ 54 MCP-verktyg 12 automatiska hooks 0 externa databaser - 4,700+ godkända tester + 4,800+ godkända tester

@@ -1251,7 +1251,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.th-TH.md b/READMEs/README.th-TH.md index 49a0e9ce46..fa1bd6d710 100644 --- a/READMEs/README.th-TH.md +++ b/READMEs/README.th-TH.md @@ -69,7 +69,7 @@ 54 เครื่องมือ MCP 12 hook อัตโนมัติ ไม่ต้องพึ่ง external DB เลย - ผ่านการทดสอบ 4,700+ รายการ + ผ่านการทดสอบ 4,800+ รายการ

@@ -1244,7 +1244,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.tl-PH.md b/READMEs/README.tl-PH.md index 9eacba7baf..27cec827c0 100644 --- a/READMEs/README.tl-PH.md +++ b/READMEs/README.tl-PH.md @@ -69,7 +69,7 @@ 54 MCP tool 12 awtomatikong hook 0 panlabas na DB - 4,700+ pumapasang test + 4,800+ pumapasang test

@@ -1253,7 +1253,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.tr-TR.md b/READMEs/README.tr-TR.md index f1aa62a40a..d26df964c2 100644 --- a/READMEs/README.tr-TR.md +++ b/READMEs/README.tr-TR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.uk-UA.md b/READMEs/README.uk-UA.md index 11019c61fe..08832163f6 100644 --- a/READMEs/README.uk-UA.md +++ b/READMEs/README.uk-UA.md @@ -69,7 +69,7 @@ 54 інструменти MCP 12 автоматичних хуків 0 зовнішніх БД - 4,700+ тестів пройдено + 4,800+ тестів пройдено

@@ -1244,7 +1244,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ur-PK.md b/READMEs/README.ur-PK.md index a4a9b37b3c..c61fdbc3ef 100644 --- a/READMEs/README.ur-PK.md +++ b/READMEs/README.ur-PK.md @@ -71,7 +71,7 @@ 54 MCP ٹولز 12 خودکار ہکس 0 خارجی ڈیٹابیسز - 4,700+ ٹیسٹس پاس ہو رہے ہیں + 4,800+ ٹیسٹس پاس ہو رہے ہیں

@@ -1248,7 +1248,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.vi-VN.md b/READMEs/README.vi-VN.md index 47177b4c47..6b3d54b63f 100644 --- a/READMEs/README.vi-VN.md +++ b/READMEs/README.vi-VN.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1253,7 +1253,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.zh-CN.md b/READMEs/README.zh-CN.md index 0a5f9c2d05..e7a3f90896 100644 --- a/READMEs/README.zh-CN.md +++ b/READMEs/README.zh-CN.md @@ -69,7 +69,7 @@ 54 个 MCP 工具 12 个自动 hooks 0 个外部数据库 - 4,700+ 项测试通过 + 4,800+ 项测试通过

@@ -1254,7 +1254,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.zh-TW.md b/READMEs/README.zh-TW.md index c2e315c886..74e1eca426 100644 --- a/READMEs/README.zh-TW.md +++ b/READMEs/README.zh-TW.md @@ -69,7 +69,7 @@ 54 個 MCP 工具 12 個自動 hooks 0 個外部資料庫 - 4,700+ 測試通過 + 4,800+ 測試通過

@@ -1246,7 +1246,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,700+ tests +npm test # 4,800+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/assets/tags/light/stat-tests.svg b/assets/tags/light/stat-tests.svg index 1b4179cfc2..743b0d095d 100644 --- a/assets/tags/light/stat-tests.svg +++ b/assets/tags/light/stat-tests.svg @@ -1,5 +1,5 @@ - + - 4700+ + 4800+ TESTS PASSING diff --git a/assets/tags/stat-tests.svg b/assets/tags/stat-tests.svg index 2b679ac742..7b4a1c20eb 100644 --- a/assets/tags/stat-tests.svg +++ b/assets/tags/stat-tests.svg @@ -1,5 +1,5 @@ - + - 4700+ + 4800+ TESTS PASSING diff --git a/scripts/docs-sync.state.json b/scripts/docs-sync.state.json index ef3f2b4c6b..6d5580a194 100644 --- a/scripts/docs-sync.state.json +++ b/scripts/docs-sync.state.json @@ -20,7 +20,7 @@ "12" ], "tests": [ - "4700+" + "4800+" ], "functions": [ "323" diff --git a/src/functions/observe.ts b/src/functions/observe.ts index 818c1258a7..82022e86cd 100644 --- a/src/functions/observe.ts +++ b/src/functions/observe.ts @@ -12,9 +12,11 @@ import { DedupMap, recordDedupSkip } from "./dedup.js"; import { afterKeyedLock, withKeyedLock } from "../state/keyed-mutex.js"; import { getFinalizeIdleMs, isAutoCompressEnabled } from "../config.js"; import { buildSyntheticCompression } from "./compress-synthetic.js"; -import { isCaptureKey } from "../capture/event-record.js"; +import { isCaptureKey, markCaptureEventDeleted } from "../capture/event-record.js"; import { claimBackfillPrompt, isBackfillPrompt, recordLivePrompt } from "../capture/prompt-ledger.js"; -import { getSearchIndex, getVectorIndex, scheduleIndexSave, vectorIndexAddGuarded } from "./search.js"; +import { getSearchIndex, getVectorIndex, scheduleIndexSave, vectorIndexAddGuarded, vectorIndexRemove } from "./search.js"; +import { unindexObservationSession } from "../state/obs-index.js"; +import { safeAudit } from "./audit.js"; import { getAgentId } from "../config.js"; import { logger } from "../logger.js"; import { saveImageToDisk } from "../utils/image-store.js"; @@ -25,6 +27,79 @@ import { markCompressionDispatchFailed, pendingCompression } from "./compression import { requestSummaryRefresh } from "./summary-state.js"; import { scheduleSessionFinalize } from "./session-finalize.js"; +const DEFAULT_EVICTION_IMPORTANCE = 5; + +function byEvictionOrder(a: CompressedObservation, b: CompressedObservation): number { + const ia = a.importance ?? DEFAULT_EVICTION_IMPORTANCE; + const ib = b.importance ?? DEFAULT_EVICTION_IMPORTANCE; + if (ia !== ib) return ia - ib; + return new Date(a.timestamp ?? 0).getTime() - new Date(b.timestamp ?? 0).getTime(); +} + +function evictionCandidates(existing: CompressedObservation[], incomingId: string): CompressedObservation[] { + return existing.filter((o) => o?.id && o.id !== incomingId).sort(byEvictionOrder); +} + +async function evictForSessionCap( + sdk: IIIClient, + kv: StateKV, + sessionId: string, + incomingId: string, + existing: CompressedObservation[], + cap: number, +): Promise<{ evicted: CompressedObservation[]; needed: number }> { + const needed = existing.length - cap + 1; + const candidates = evictionCandidates(existing, incomingId); + const evicted: CompressedObservation[] = []; + for (const victim of candidates) { + if (evicted.length >= needed) break; + try { + await markCaptureEventDeleted(kv, victim); + await kv.delete(KV.observations(sessionId), victim.id); + } catch (err) { + logger.warn("Session cap eviction delete failed", { + sessionId, + obsId: victim.id, + error: err instanceof Error ? err.message : String(err), + }); + continue; + } + evicted.push(victim); + getSearchIndex().remove(victim.id); + vectorIndexRemove(victim.id); + } + if (evicted.length === 0) return { evicted, needed }; + + scheduleIndexSave(); + const { decrementImageRef } = await import("./image-refs.js"); + for (const victim of evicted) { + await unindexObservationSession(kv, victim.id).catch(() => {}); + const refs = new Set([victim.imageData, victim.imageRef].filter((r): r is string => typeof r === "string" && r.length > 0)); + for (const ref of refs) { + await decrementImageRef(kv, sdk, ref).catch((err) => { + logger.warn("Session cap eviction image ref release failed", { + sessionId, + obsId: victim.id, + error: err instanceof Error ? err.message : String(err), + }); + }); + } + } + await safeAudit(kv, "delete", "mem::observe", evicted.map((o) => o.id), { + resource: "observation", + reason: "session_observation_cap", + sessionId, + cap, + evicted: evicted.length, + }); + logger.warn("Session observation cap reached, evicted lowest-value observations", { + sessionId, + cap, + evicted: evicted.length, + }); + return { evicted, needed }; +} + export function extractImage(d: unknown): string | undefined { if (!d) return undefined; if (typeof d === "string") { @@ -198,14 +273,6 @@ export function registerObserveFunction( recordDedupSkip(); return { deduplicated: true, sessionId: payload.sessionId }; } - if (maxObservationsPerSession && maxObservationsPerSession > 0) { - if (existing.length >= maxObservationsPerSession) { - return { - success: false, - error: `Session observation limit reached (${maxObservationsPerSession})`, - }; - } - } // Existing session is the source of truth for agentId (even // undefined). Env AGENT_ID only fires when no session row @@ -254,7 +321,13 @@ export function registerObserveFunction( await requestSummaryRefresh(kv, payload.sessionId, dueAt); if (finalizeIdleMs > 0) await scheduleSessionFinalize(kv, payload.sessionId, dueAt); } - const synthetic = budgetLiveObservationSource(buildSyntheticCompression(raw), existing); + const cap = maxObservationsPerSession && maxObservationsPerSession > 0 ? maxObservationsPerSession : 0; + const plannedVictims = cap > 0 && existing.length >= cap + ? evictionCandidates(existing, obsId).slice(0, existing.length - cap + 1) + : []; + const plannedIds = new Set(plannedVictims.map((o) => o.id)); + const unbudgeted = buildSyntheticCompression(raw); + const synthetic = budgetLiveObservationSource(unbudgeted, existing.filter((o) => !plannedIds.has(o?.id))); if (autoCompress) synthetic.compression = pendingCompression(); try { await kv.set(KV.observations(payload.sessionId), obsId, synthetic); @@ -289,6 +362,43 @@ export function registerObserveFunction( throw error; } + let evictedCount = 0; + if (plannedVictims.length > 0) { + const { evicted, needed } = await evictForSessionCap( + sdk, + kv, + payload.sessionId, + obsId, + existing, + cap, + ); + evictedCount = evicted.length; + if (evicted.length < needed) { + logger.warn("Session observation cap eviction freed fewer slots than needed", { + sessionId: payload.sessionId, + cap, + evicted: evicted.length, + needed, + }); + } + const evictedIds = new Set(evicted.map((o) => o.id)); + if (plannedVictims.some((o) => !evictedIds.has(o.id))) { + const retained = existing.filter((o) => !evictedIds.has(o?.id)); + const rebudgeted = budgetLiveObservationSource(unbudgeted, retained); + if (JSON.stringify(rebudgeted.source) !== JSON.stringify(synthetic.source)) { + if (rebudgeted.source) synthetic.source = rebudgeted.source; + else delete synthetic.source; + await kv.set(KV.observations(payload.sessionId), obsId, synthetic).catch((err) => { + logger.warn("Session cap source re-budget write failed", { + sessionId: payload.sessionId, + obsId, + error: err instanceof Error ? err.message : String(err), + }); + }); + } + } + } + if (dedupMap && dedupHash) { dedupMap.record(dedupHash); } @@ -307,7 +417,7 @@ export function registerObserveFunction( { type: "set", path: "observationCount", - value: (session.observationCount || 0) + 1, + value: Math.max(1, (session.observationCount || 0) + 1 - evictedCount), }, ]; if (session.status !== "active" && finalizeIdleMs > 0) { diff --git a/src/functions/status.ts b/src/functions/status.ts index 6967f7249b..930e7c987c 100644 --- a/src/functions/status.ts +++ b/src/functions/status.ts @@ -570,7 +570,7 @@ function captureProblems(capture: CaptureStatus | null, now: Date, restPort: num code: "capture-dead-letters", message: `${plural(inbox.dead, "captured observation")} could not be stored and ${inbox.dead === 1 ? "is parked as a dead letter" : "are parked as dead letters"}${inbox.lastError ? `: ${inbox.lastError}` : "."}`, fix: sessionCap - ? `The session reached its MAX_OBS_PER_SESSION cap, so a retry is refused again until the cap is raised. Raise MAX_OBS_PER_SESSION in ~/.agentmemory/.env (0 = no cap) and restart agentmemory. ${listAndRetry}` + ? `The session reached its MAX_OBS_PER_SESSION cap and older observations could not be evicted to make room. Check the server log for "Session cap eviction delete failed", or raise MAX_OBS_PER_SESSION in ~/.agentmemory/.env (0 = no cap) and restart agentmemory. ${listAndRetry}` : listAndRetry, }); } diff --git a/test/observe-session-cap.test.ts b/test/observe-session-cap.test.ts new file mode 100644 index 0000000000..50ff9f879c --- /dev/null +++ b/test/observe-session-cap.test.ts @@ -0,0 +1,328 @@ +import { describe, it, expect, vi, beforeEach } from "vitest"; + +vi.mock("iii-sdk", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + getContext: () => ({ + logger: { info: vi.fn(), error: vi.fn(), warn: vi.fn() }, + }), + }; +}); + +vi.mock("../src/logger.js", () => ({ + logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() }, +})); + +const removedFromBm25: string[] = []; +const removedFromVector: string[] = []; +const releasedImageRefs: string[] = []; + +vi.mock("../src/functions/search.js", () => ({ + getSearchIndex: () => ({ + remove: (id: string) => { + removedFromBm25.push(id); + }, + add: () => {}, + has: () => false, + }), + getVectorIndex: () => null, + scheduleIndexSave: () => {}, + vectorIndexAddGuarded: async () => false, + vectorIndexRemove: (id: string) => { + removedFromVector.push(id); + }, +})); + +vi.mock("../src/functions/image-refs.js", () => ({ + incrementImageRef: async () => {}, + decrementImageRef: async (_kv: unknown, _sdk: unknown, ref: string) => { + releasedImageRefs.push(ref); + }, +})); + +import { mockKV, mockSdk, currentAuditScope } from "./helpers/mocks.js"; +import { indexObservationSession, lookupObservationSession } from "../src/state/obs-index.js"; +import type { AuditEntry } from "../src/types.js"; +import { SESSION_SOURCE_MAX_BYTES } from "../src/functions/observation-source-budget.js"; + +const SESSION = "ses_capped"; +const SCOPE = `mem:obs:${SESSION}`; + +type Row = { id: string; importance?: number; ts: string; imageData?: string }; + +async function seed(kv: ReturnType, rows: Row[]) { + for (const row of rows) { + await kv.set(SCOPE, row.id, { + id: row.id, + sessionId: SESSION, + timestamp: row.ts, + type: "command_run", + title: row.id, + facts: [], + narrative: "", + concepts: [], + files: [], + importance: row.importance, + ...(row.imageData ? { imageData: row.imageData } : {}), + }); + await indexObservationSession(kv as never, row.id, SESSION); + } +} + +async function observeOnce(sdk: ReturnType, text: string) { + return (await sdk.trigger("mem::observe", { + sessionId: SESSION, + hookType: "post_tool_use", + timestamp: new Date().toISOString(), + data: { tool_name: "Bash", tool_input: { command: text } }, + })) as { success?: boolean; observationId?: string; error?: string }; +} + +async function setup(cap: number) { + const { registerObserveFunction } = await import("../src/functions/observe.js"); + const sdk = mockSdk({ looseTrigger: true }); + const kv = mockKV(); + registerObserveFunction(sdk as never, kv as never, undefined, cap); + return { sdk, kv }; +} + +function storedIds(kv: ReturnType): string[] { + return Array.from(kv.store.get(SCOPE)?.keys() ?? []); +} + +describe("session observation cap evicts instead of refusing", () => { + beforeEach(() => { + vi.resetModules(); + removedFromBm25.length = 0; + removedFromVector.length = 0; + releasedImageRefs.length = 0; + }); + + it("accepts the new observation at the cap and drops the least valuable row", async () => { + const { sdk, kv } = await setup(3); + await seed(kv, [ + { id: "obs_keep_high", importance: 9, ts: "2026-01-01T00:00:00.000Z" }, + { id: "obs_evict_low", importance: 1, ts: "2026-01-02T00:00:00.000Z" }, + { id: "obs_keep_mid", importance: 5, ts: "2026-01-03T00:00:00.000Z" }, + ]); + + const result = await observeOnce(sdk, "the newest command"); + + expect(result.observationId).toBeTruthy(); + expect(result.error).toBeUndefined(); + const ids = storedIds(kv); + expect(ids).toHaveLength(3); + expect(ids).not.toContain("obs_evict_low"); + expect(ids).toContain("obs_keep_high"); + expect(ids).toContain("obs_keep_mid"); + expect(ids).toContain(result.observationId); + }); + + it("evicts the oldest row on an importance tie and clears it from every index", async () => { + const { sdk, kv } = await setup(2); + await seed(kv, [ + { id: "obs_older", importance: 4, ts: "2026-01-01T00:00:00.000Z" }, + { id: "obs_newer", importance: 4, ts: "2026-02-01T00:00:00.000Z" }, + ]); + + await observeOnce(sdk, "another command"); + + const ids = storedIds(kv); + expect(ids).not.toContain("obs_older"); + expect(ids).toContain("obs_newer"); + expect(removedFromBm25).toEqual(["obs_older"]); + expect(removedFromVector).toEqual(["obs_older"]); + expect(await lookupObservationSession(kv as never, "obs_older")).toBeNull(); + expect(await lookupObservationSession(kv as never, "obs_newer")).toBe(SESSION); + }); + + it("treats a missing importance like the synthetic default", async () => { + const { sdk, kv } = await setup(2); + await seed(kv, [ + { id: "obs_unscored", ts: "2026-01-01T00:00:00.000Z" }, + { id: "obs_low", importance: 4, ts: "2026-02-01T00:00:00.000Z" }, + ]); + + await observeOnce(sdk, "next command"); + + expect(storedIds(kv)).toContain("obs_unscored"); + expect(storedIds(kv)).not.toContain("obs_low"); + }); + + it("records one audit entry for the eviction", async () => { + const { sdk, kv } = await setup(1); + await seed(kv, [{ id: "obs_victim", importance: 2, ts: "2026-01-01T00:00:00.000Z" }]); + + await observeOnce(sdk, "audited command"); + + const audits = await kv.list(currentAuditScope()); + const evictions = audits.filter((a) => a.functionId === "mem::observe" && a.operation === "delete"); + expect(evictions).toHaveLength(1); + expect(evictions[0]!.targetIds).toEqual(["obs_victim"]); + expect(evictions[0]!.details).toMatchObject({ reason: "session_observation_cap", sessionId: SESSION, evicted: 1 }); + }); + + it("releases the image ref held by an evicted observation", async () => { + const { sdk, kv } = await setup(1); + await seed(kv, [ + { id: "obs_with_image", importance: 1, ts: "2026-01-01T00:00:00.000Z", imageData: "/tmp/agentmemory-test/img.png" }, + ]); + + await observeOnce(sdk, "text only"); + + expect(releasedImageRefs).toEqual(["/tmp/agentmemory-test/img.png"]); + }); + + it("evicts down to the cap when the session is already above it", async () => { + const { sdk, kv } = await setup(2); + await seed(kv, [ + { id: "obs_a", importance: 1, ts: "2026-01-01T00:00:00.000Z" }, + { id: "obs_b", importance: 2, ts: "2026-01-02T00:00:00.000Z" }, + { id: "obs_c", importance: 8, ts: "2026-01-03T00:00:00.000Z" }, + { id: "obs_d", importance: 9, ts: "2026-01-04T00:00:00.000Z" }, + ]); + + const result = await observeOnce(sdk, "over the cap"); + + const ids = storedIds(kv); + expect(ids).toHaveLength(2); + expect(ids).toContain("obs_d"); + expect(ids).toContain(result.observationId); + }); + + it("moves to the next candidate when a delete fails and keeps the cap", async () => { + const { sdk, kv } = await setup(2); + await seed(kv, [ + { id: "obs_stuck", importance: 1, ts: "2026-01-01T00:00:00.000Z" }, + { id: "obs_next", importance: 2, ts: "2026-01-02T00:00:00.000Z" }, + ]); + const realDelete = kv.delete; + kv.delete = async (scope: string, key: string) => { + if (key === "obs_stuck") throw new Error("disk busy"); + return realDelete(scope, key); + }; + + const result = await observeOnce(sdk, "after a failed delete"); + + expect(result.observationId).toBeTruthy(); + const ids = storedIds(kv); + expect(ids).toHaveLength(2); + expect(ids).toContain("obs_stuck"); + expect(ids).not.toContain("obs_next"); + expect(removedFromBm25).toEqual(["obs_next"]); + }); + + it("keeps the incoming write and retries eviction later when no row can be evicted", async () => { + const { sdk, kv } = await setup(1); + await seed(kv, [{ id: "obs_stuck", importance: 1, ts: "2026-01-01T00:00:00.000Z" }]); + const realDelete = kv.delete.bind(kv); + kv.delete = async () => { + throw new Error("disk busy"); + }; + + const result = await observeOnce(sdk, "cannot fit"); + + expect(typeof result.observationId).toBe("string"); + expect(storedIds(kv).sort()).toEqual([result.observationId!, "obs_stuck"].sort()); + expect(removedFromBm25).toHaveLength(0); + + kv.delete = realDelete; + const next = await observeOnce(sdk, "after recovery"); + + expect(storedIds(kv)).toEqual([next.observationId!]); + }); + + it("evicts nothing when the incoming write fails", async () => { + const { sdk, kv } = await setup(1); + await seed(kv, [{ id: "obs_keep", importance: 1, ts: "2026-01-01T00:00:00.000Z" }]); + const realSet = kv.set.bind(kv); + kv.set = (async (scope: string, key: string, value: unknown) => { + if (scope === SCOPE) throw new Error("write failed"); + return realSet(scope, key, value); + }) as typeof kv.set; + + await expect(observeOnce(sdk, "will fail")).rejects.toThrow("write failed"); + + expect(storedIds(kv)).toEqual(["obs_keep"]); + expect(removedFromBm25).toHaveLength(0); + expect(removedFromVector).toHaveLength(0); + }); + + it("budgets the incoming source against the rows that remain after eviction", async () => { + const { sdk, kv } = await setup(1); + await seed(kv, [{ id: "obs_big", importance: 1, ts: "2026-01-01T00:00:00.000Z" }]); + const big = (await kv.get>(SCOPE, "obs_big"))!; + await kv.set(SCOPE, "obs_big", { + ...big, + source: { hookType: "post_tool_use", toolOutput: "x".repeat(SESSION_SOURCE_MAX_BYTES - 1024) }, + }); + + const result = await observeOnce(sdk, "y".repeat(8 * 1024)); + + expect(storedIds(kv)).toEqual([result.observationId!]); + const stored = await kv.get<{ source?: { truncated?: boolean } }>(SCOPE, result.observationId!); + expect(stored?.source).toBeDefined(); + expect(stored?.source?.truncated).toBe(false); + }); + + it("re-budgets the incoming source when the planned victim cannot be evicted", async () => { + const { sdk, kv } = await setup(1); + await seed(kv, [{ id: "obs_big", importance: 1, ts: "2026-01-01T00:00:00.000Z" }]); + const big = (await kv.get>(SCOPE, "obs_big"))!; + await kv.set(SCOPE, "obs_big", { + ...big, + source: { hookType: "post_tool_use", toolOutput: "x".repeat(SESSION_SOURCE_MAX_BYTES - 1024) }, + }); + kv.delete = async () => { + throw new Error("disk busy"); + }; + + const result = await observeOnce(sdk, "y".repeat(8 * 1024)); + + expect(storedIds(kv).sort()).toEqual([result.observationId!, "obs_big"].sort()); + const stored = await kv.get<{ source?: { truncated?: boolean } }>(SCOPE, result.observationId!); + expect(stored?.source === undefined || stored.source.truncated === true).toBe(true); + }); + + it("keeps the session observation count equal to retained rows after eviction", async () => { + const { sdk, kv } = await setup(2); + await seed(kv, [ + { id: "obs_a", importance: 1, ts: "2026-01-01T00:00:00.000Z" }, + { id: "obs_b", importance: 5, ts: "2026-01-02T00:00:00.000Z" }, + ]); + await kv.set("mem:sessions", SESSION, { id: SESSION, status: "active", observationCount: 2 }); + + await observeOnce(sdk, "third"); + + const session = await kv.get<{ observationCount: number }>("mem:sessions", SESSION); + expect(storedIds(kv)).toHaveLength(2); + expect(session?.observationCount).toBe(2); + }); + + it("keeps the cap when several observations arrive at once", async () => { + const { sdk, kv } = await setup(3); + await seed(kv, [ + { id: "obs_1", importance: 5, ts: "2026-01-01T00:00:00.000Z" }, + { id: "obs_2", importance: 5, ts: "2026-01-02T00:00:00.000Z" }, + { id: "obs_3", importance: 5, ts: "2026-01-03T00:00:00.000Z" }, + ]); + + const results = await Promise.all( + Array.from({ length: 5 }, (_, i) => observeOnce(sdk, `parallel ${i}`)), + ); + + expect(results.every((r) => typeof r.observationId === "string")).toBe(true); + expect(storedIds(kv)).toHaveLength(3); + }); + + it("leaves capture untouched when the session is under the cap", async () => { + const { sdk, kv } = await setup(10); + await seed(kv, [{ id: "obs_only", importance: 1, ts: "2026-01-01T00:00:00.000Z" }]); + + await observeOnce(sdk, "still room"); + + expect(storedIds(kv)).toContain("obs_only"); + expect(removedFromBm25).toHaveLength(0); + }); +});