cortex-engine 0.4.1 → 0.5.0
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 +63 -57
- package/dist/bin/anomalies-cmd.d.ts +17 -0
- package/dist/bin/anomalies-cmd.d.ts.map +1 -0
- package/dist/bin/anomalies-cmd.js +417 -0
- package/dist/bin/anomalies-cmd.js.map +1 -0
- package/dist/bin/cli.d.ts +5 -0
- package/dist/bin/cli.d.ts.map +1 -1
- package/dist/bin/cli.js +84 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/health-cmd.d.ts +15 -0
- package/dist/bin/health-cmd.d.ts.map +1 -0
- package/dist/bin/health-cmd.js +273 -0
- package/dist/bin/health-cmd.js.map +1 -0
- package/dist/bin/init.d.ts.map +1 -1
- package/dist/bin/init.js +169 -12
- package/dist/bin/init.js.map +1 -1
- package/dist/bin/maintain-cmd.d.ts +17 -0
- package/dist/bin/maintain-cmd.d.ts.map +1 -0
- package/dist/bin/maintain-cmd.js +352 -0
- package/dist/bin/maintain-cmd.js.map +1 -0
- package/dist/bin/report-cmd.d.ts +17 -0
- package/dist/bin/report-cmd.d.ts.map +1 -0
- package/dist/bin/report-cmd.js +309 -0
- package/dist/bin/report-cmd.js.map +1 -0
- package/dist/bin/store-factory.d.ts +21 -0
- package/dist/bin/store-factory.d.ts.map +1 -0
- package/dist/bin/store-factory.js +64 -0
- package/dist/bin/store-factory.js.map +1 -0
- package/dist/bin/vitals-cmd.d.ts +16 -0
- package/dist/bin/vitals-cmd.d.ts.map +1 -0
- package/dist/bin/vitals-cmd.js +425 -0
- package/dist/bin/vitals-cmd.js.map +1 -0
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/engines/cognition.d.ts.map +1 -1
- package/dist/engines/cognition.js +39 -3
- package/dist/engines/cognition.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +1 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +22 -2
- package/dist/mcp/tools.js.map +1 -1
- package/dist/tools/evolution-list.d.ts +6 -0
- package/dist/tools/evolution-list.d.ts.map +1 -0
- package/dist/tools/evolution-list.js +52 -0
- package/dist/tools/evolution-list.js.map +1 -0
- package/dist/tools/evolve.d.ts +6 -0
- package/dist/tools/evolve.d.ts.map +1 -0
- package/dist/tools/evolve.js +63 -0
- package/dist/tools/evolve.js.map +1 -0
- package/dist/tools/journal-read.d.ts +6 -0
- package/dist/tools/journal-read.d.ts.map +1 -0
- package/dist/tools/journal-read.js +59 -0
- package/dist/tools/journal-read.js.map +1 -0
- package/dist/tools/journal-write.d.ts +6 -0
- package/dist/tools/journal-write.d.ts.map +1 -0
- package/dist/tools/journal-write.js +71 -0
- package/dist/tools/journal-write.js.map +1 -0
- package/dist/tools/thread-create.d.ts +6 -0
- package/dist/tools/thread-create.d.ts.map +1 -0
- package/dist/tools/thread-create.js +57 -0
- package/dist/tools/thread-create.js.map +1 -0
- package/dist/tools/thread-resolve.d.ts +6 -0
- package/dist/tools/thread-resolve.d.ts.map +1 -0
- package/dist/tools/thread-resolve.js +42 -0
- package/dist/tools/thread-resolve.js.map +1 -0
- package/dist/tools/thread-update.d.ts +6 -0
- package/dist/tools/thread-update.d.ts.map +1 -0
- package/dist/tools/thread-update.js +91 -0
- package/dist/tools/thread-update.js.map +1 -0
- package/dist/tools/threads-list.d.ts +6 -0
- package/dist/tools/threads-list.d.ts.map +1 -0
- package/dist/tools/threads-list.js +70 -0
- package/dist/tools/threads-list.js.map +1 -0
- package/fozikio.json +14 -0
- package/hooks/cognitive-grounding.sh +26 -0
- package/hooks/cortex-telemetry.sh +53 -0
- package/hooks/observe-first.sh +25 -0
- package/hooks/project-board-gate.sh +195 -0
- package/hooks/session-lifecycle.sh +21 -0
- package/package.json +119 -107
- package/reflex-rules/cognitive-grounding.yaml +17 -0
- package/reflex-rules/note-about-doing.yaml +17 -0
- package/reflex-rules/observe-first.yaml +17 -0
- package/skills/cortex-query/SKILL.md +86 -0
- package/skills/cortex-review/SKILL.md +67 -0
package/README.md
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# cortex-engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Persistent memory for AI agents. Open source, LLM-agnostic, works with any MCP client.
|
|
4
4
|
|
|
5
5
|
## What It Does
|
|
6
6
|
|
|
7
|
-
`cortex-engine`
|
|
7
|
+
Most AI agents forget everything when the session ends. `cortex-engine` fixes that — it gives agents a persistent memory layer that survives across sessions, models, and runtimes.
|
|
8
8
|
|
|
9
|
-
- **Semantic memory
|
|
10
|
-
- **
|
|
11
|
-
- **Dream consolidation** —
|
|
12
|
-
- **FSRS
|
|
13
|
-
- **
|
|
9
|
+
- **Semantic memory** — store and retrieve observations, beliefs, questions, and hypotheses as interconnected nodes
|
|
10
|
+
- **Belief tracking** — agents hold positions that update when new evidence contradicts them
|
|
11
|
+
- **Dream consolidation** — batches of short-term observations compress into durable long-term memories (like biological sleep consolidation)
|
|
12
|
+
- **Spaced repetition (FSRS)** — memories that aren't accessed fade over time, keeping retrieval relevant
|
|
13
|
+
- **Embeddings** — pluggable providers (built-in, OpenAI, Vertex AI, Ollama) — no external service required by default
|
|
14
|
+
- **MCP server** — 25 cognitive tools (`query`, `observe`, `believe`, `wander`, `dream`, etc.) over the Model Context Protocol
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
The result: personality and expertise emerge from accumulated experience, not system prompts. An agent with 200 observations about distributed systems doesn't need to be told "you care about distributed systems." It just knows.
|
|
17
|
+
|
|
18
|
+
Works with Claude Code, Cursor, Windsurf, or any MCP-compatible client. Runs locally (SQLite) or in the cloud (Firestore + Cloud Run).
|
|
16
19
|
|
|
17
20
|
## Architecture
|
|
18
21
|
|
|
@@ -37,7 +40,7 @@ cd my-agent
|
|
|
37
40
|
npx cortex-engine # starts MCP server
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
Your agent now has
|
|
43
|
+
Your agent now has 25 cognitive tools. See the **[Quick Start](https://github.com/Fozikio/cortex-engine/wiki/Quick-Start)** wiki page for the full 5-minute setup.
|
|
41
44
|
|
|
42
45
|
### Multi-Agent
|
|
43
46
|
|
|
@@ -47,11 +50,11 @@ npx fozikio agent add trader --description "Trading signals"
|
|
|
47
50
|
npx fozikio agent generate-mcp # writes .mcp.json with scoped servers
|
|
48
51
|
```
|
|
49
52
|
|
|
50
|
-
Each agent gets isolated memory via namespaces. See **[
|
|
53
|
+
Each agent gets isolated memory via namespaces. See the **[Architecture](https://github.com/Fozikio/cortex-engine/wiki/Architecture)** wiki page for details.
|
|
51
54
|
|
|
52
55
|
### Agent-First Setup
|
|
53
56
|
|
|
54
|
-
The fastest path: open an AI agent in an empty directory and say *"set up a cortex workspace."* The agent runs `npx fozikio init`, reads the generated files, and is immediately productive. See **[
|
|
57
|
+
The fastest path: open an AI agent in an empty directory and say *"set up a cortex workspace."* The agent runs `npx fozikio init`, reads the generated files, and is immediately productive. See the **[Installation](https://github.com/Fozikio/cortex-engine/wiki/Installation)** wiki page for the full guide.
|
|
55
58
|
|
|
56
59
|
### Development
|
|
57
60
|
|
|
@@ -69,45 +72,25 @@ npm run test:watch
|
|
|
69
72
|
|
|
70
73
|
Additional variables are required depending on which providers you enable (Firestore, Vertex AI, OpenAI, etc.). See `docs/` for provider-specific configuration.
|
|
71
74
|
|
|
72
|
-
##
|
|
73
|
-
|
|
74
|
-
`fozikio init` automatically installs
|
|
75
|
-
|
|
76
|
-
###
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
|
81
|
-
|
|
82
|
-
| `cognitive-grounding
|
|
83
|
-
| `observe-first
|
|
84
|
-
| `
|
|
85
|
-
| `session-lifecycle.sh` | `SessionStart` | Resets session-scoped state files (telemetry log, push-gate state) | — |
|
|
86
|
-
| `project-board-gate.sh` | `PreToolUse` (Bash) | Blocks `git push` to tracked repos until board updates and/or ops logging are done | `.claude/state/project-boards.json` config |
|
|
87
|
-
|
|
88
|
-
**To disable a hook:** Delete the `.sh` file from `.claude/hooks/`. No other config changes needed.
|
|
89
|
-
|
|
90
|
-
**To customize project-board-gate:** Create `.claude/state/project-boards.json` with your repos and requirements:
|
|
91
|
-
|
|
92
|
-
```json
|
|
93
|
-
{
|
|
94
|
-
"enabled": true,
|
|
95
|
-
"strength": "block",
|
|
96
|
-
"on_push": {
|
|
97
|
-
"require_board_update": true,
|
|
98
|
-
"require_ops_log": false
|
|
99
|
-
},
|
|
100
|
-
"repos": {
|
|
101
|
-
"my-repo": {
|
|
102
|
-
"board_number": 5,
|
|
103
|
-
"board_owner": "my-org",
|
|
104
|
-
"description": "My project"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
```
|
|
75
|
+
## Rules, Skills & Agents
|
|
76
|
+
|
|
77
|
+
`fozikio init` automatically installs safety rules, skills, and agent definitions from the `fozikio.json` manifest into the target workspace.
|
|
78
|
+
|
|
79
|
+
### Safety Rules (Reflex)
|
|
80
|
+
|
|
81
|
+
cortex-engine ships with [Reflex](https://github.com/Fozikio/reflex) rules — portable YAML-based guardrails that work across any agent runtime, not just Claude Code.
|
|
82
|
+
|
|
83
|
+
| Rule | Event | What It Does |
|
|
84
|
+
|------|-------|-------------|
|
|
85
|
+
| `cognitive-grounding` | `prompt_submit` | Nudges the agent to call `query()` before evaluation, design, review, or creation work |
|
|
86
|
+
| `observe-first` | `file_write` / `file_edit` | Warns if writing to memory directories without calling `observe()` or `query()` first |
|
|
87
|
+
| `note-about-doing` | `prompt_submit` | Suggests capturing new threads of thought with `thread_create()` |
|
|
109
88
|
|
|
110
|
-
|
|
89
|
+
Rules live in `reflex-rules/` as standard Reflex YAML. They're portable — use them with Claude Code, Cursor, Codex, or any runtime with a Reflex adapter. See [@fozikio/reflex](https://github.com/Fozikio/reflex) for the full rule format and tier enforcement.
|
|
90
|
+
|
|
91
|
+
**Claude Code users** also get platform-specific hooks (in `hooks/`) for telemetry, session lifecycle, and project board gating. These are runtime adapters, not rules — they handle side effects that the declarative rule format doesn't cover.
|
|
92
|
+
|
|
93
|
+
**To customize:** Edit the YAML rule files directly, or set `allow_disable: true` and disable them via Reflex config.
|
|
111
94
|
|
|
112
95
|
### Skills
|
|
113
96
|
|
|
@@ -127,19 +110,42 @@ Skills are invocable workflows that agents can use via `/skill-name`.
|
|
|
127
110
|
### How Auto-Install Works
|
|
128
111
|
|
|
129
112
|
1. `fozikio init` reads `fozikio.json` from the package root
|
|
130
|
-
2.
|
|
131
|
-
3.
|
|
132
|
-
|
|
113
|
+
2. Copies hooks, skills, and Reflex rules into the target workspace
|
|
114
|
+
3. Missing source files are skipped with a warning — init never fails due to missing assets
|
|
115
|
+
|
|
116
|
+
## Plugin Ecosystem
|
|
117
|
+
|
|
118
|
+
cortex-engine ships with 25 cognitive tools out of the box. Plugins add more:
|
|
119
|
+
[Fozikio Plugin Docs](https://www.fozikio.com/products/plugins/)
|
|
120
|
+
|
|
121
|
+
| Plugin | What It Adds |
|
|
122
|
+
|--------|-------------|
|
|
123
|
+
| [@fozikio/tools-threads](https://github.com/Fozikio/tools-threads) | Thought threads — create, update, resolve ongoing lines of thinking |
|
|
124
|
+
| [@fozikio/tools-journal](https://github.com/Fozikio/tools-journal) | Session journaling — structured reflections that persist |
|
|
125
|
+
| [@fozikio/tools-content](https://github.com/Fozikio/tools-content) | Content pipeline — draft, review, publish workflow |
|
|
126
|
+
| [@fozikio/tools-evolution](https://github.com/Fozikio/tools-evolution) | Identity evolution — track how the agent's personality changes over time |
|
|
127
|
+
| [@fozikio/tools-social](https://github.com/Fozikio/tools-social) | Social cognition — interaction patterns, engagement tracking |
|
|
128
|
+
| [@fozikio/tools-graph](https://github.com/Fozikio/tools-graph) | Graph analysis — memory connections, clustering, visualization data |
|
|
129
|
+
| [@fozikio/tools-maintenance](https://github.com/Fozikio/tools-maintenance) | Memory maintenance — cleanup, deduplication, health checks |
|
|
130
|
+
| [@fozikio/tools-vitals](https://github.com/Fozikio/tools-vitals) | Vitals tracking — agent health metrics and operational signals |
|
|
131
|
+
| [@fozikio/tools-reasoning](https://github.com/Fozikio/tools-reasoning) | Cognitive reasoning — abstraction, contradiction detection, surfacing |
|
|
132
|
+
|
|
133
|
+
Install any plugin: `npm install @fozikio/tools-threads` — cortex-engine auto-discovers and loads installed plugins.
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
## Documentation
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
- **[Wiki](https://github.com/Fozikio/cortex-engine/wiki)** — Installation, architecture, plugin authoring, MCP integration, deployment, FAQ
|
|
138
|
+
- **[Discussions](https://github.com/Fozikio/cortex-engine/discussions)** — Ask questions, share what you've built
|
|
139
|
+
- **[Contributing](https://github.com/Fozikio/.github/blob/main/CONTRIBUTING.md)** — How to contribute
|
|
140
|
+
- **[Project Board](https://github.com/orgs/Fozikio/projects/2)** — Roadmap and active work
|
|
141
|
+
- **[Security](https://github.com/Fozikio/.github/blob/main/SECURITY.md)** — Report vulnerabilities
|
|
140
142
|
|
|
141
143
|
## Related Projects
|
|
142
144
|
|
|
145
|
+
- [@fozikio/reflex](https://github.com/Fozikio/reflex) — Portable safety guardrails for agents. Rules as data, not code.
|
|
146
|
+
- [sigil](https://github.com/Fozikio/sigil) — Agent control surface. Signals and gestures, not conversations.
|
|
147
|
+
- [fozikio.com](https://www.fozikio.com) — Documentation and guides
|
|
148
|
+
- [r/fozikio](https://www.reddit.com/r/Fozikio/) — Community
|
|
143
149
|
|
|
144
150
|
## License
|
|
145
151
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* anomalies-cmd.ts — fozikio anomalies command handler.
|
|
3
|
+
*
|
|
4
|
+
* Loads session data from ops entries + retrieval traces, builds session
|
|
5
|
+
* feature vectors, and runs an Isolation Forest to detect anomalous sessions.
|
|
6
|
+
*
|
|
7
|
+
* Isolation Forest is implemented in pure TypeScript — no ML dependencies.
|
|
8
|
+
*
|
|
9
|
+
* Works with both SQLite and Firestore backends.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* fozikio anomalies
|
|
13
|
+
* fozikio anomalies --days 60
|
|
14
|
+
* fozikio anomalies --json
|
|
15
|
+
*/
|
|
16
|
+
export declare function runAnomalies(args: string[]): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=anomalies-cmd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anomalies-cmd.d.ts","sourceRoot":"","sources":["../../src/bin/anomalies-cmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqaH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwHhE"}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* anomalies-cmd.ts — fozikio anomalies command handler.
|
|
3
|
+
*
|
|
4
|
+
* Loads session data from ops entries + retrieval traces, builds session
|
|
5
|
+
* feature vectors, and runs an Isolation Forest to detect anomalous sessions.
|
|
6
|
+
*
|
|
7
|
+
* Isolation Forest is implemented in pure TypeScript — no ML dependencies.
|
|
8
|
+
*
|
|
9
|
+
* Works with both SQLite and Firestore backends.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* fozikio anomalies
|
|
13
|
+
* fozikio anomalies --days 60
|
|
14
|
+
* fozikio anomalies --json
|
|
15
|
+
*/
|
|
16
|
+
import { loadConfig } from './config-loader.js';
|
|
17
|
+
import { SqliteCortexStore } from '../stores/sqlite.js';
|
|
18
|
+
import { FirestoreCortexStore } from '../stores/firestore.js';
|
|
19
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
20
|
+
const DEFAULT_DAYS = 90;
|
|
21
|
+
const N_TREES = 100;
|
|
22
|
+
const SUBSAMPLE_SIZE = 256;
|
|
23
|
+
const ANOMALY_THRESHOLD = 0.6;
|
|
24
|
+
const WIDTH = 52;
|
|
25
|
+
function parseArgs(args) {
|
|
26
|
+
let json = false;
|
|
27
|
+
let days = DEFAULT_DAYS;
|
|
28
|
+
for (let i = 0; i < args.length; i++) {
|
|
29
|
+
const arg = args[i];
|
|
30
|
+
if (arg === '--json') {
|
|
31
|
+
json = true;
|
|
32
|
+
}
|
|
33
|
+
else if (arg === '--days' && args[i + 1]) {
|
|
34
|
+
const parsed = parseInt(args[++i], 10);
|
|
35
|
+
if (!isNaN(parsed) && parsed > 0)
|
|
36
|
+
days = parsed;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { json, days };
|
|
40
|
+
}
|
|
41
|
+
// ─── Store Factory ────────────────────────────────────────────────────────────
|
|
42
|
+
async function createStore(config) {
|
|
43
|
+
if (config.store === 'firestore') {
|
|
44
|
+
const { getApps, initializeApp } = await import('firebase-admin/app');
|
|
45
|
+
if (getApps().length === 0) {
|
|
46
|
+
initializeApp({ projectId: config.store_options?.gcp_project_id });
|
|
47
|
+
}
|
|
48
|
+
const { getFirestore, FieldValue } = await import('firebase-admin/firestore');
|
|
49
|
+
const db = config.store_options?.firestore_database_id
|
|
50
|
+
? getFirestore(config.store_options.firestore_database_id)
|
|
51
|
+
: getFirestore();
|
|
52
|
+
db.settings({ ignoreUndefinedProperties: true });
|
|
53
|
+
return new FirestoreCortexStore(db, '', FieldValue);
|
|
54
|
+
}
|
|
55
|
+
return new SqliteCortexStore(config.store_options?.sqlite_path ?? './cortex.db');
|
|
56
|
+
}
|
|
57
|
+
// ─── Date Helpers ─────────────────────────────────────────────────────────────
|
|
58
|
+
function toDate(v) {
|
|
59
|
+
if (!v)
|
|
60
|
+
return null;
|
|
61
|
+
if (v instanceof Date)
|
|
62
|
+
return v;
|
|
63
|
+
const t = v;
|
|
64
|
+
if (typeof t.toDate === 'function')
|
|
65
|
+
return t.toDate();
|
|
66
|
+
if (typeof v === 'string')
|
|
67
|
+
return new Date(v);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
// ─── Box Drawing ─────────────────────────────────────────────────────────────
|
|
71
|
+
function row(label, value) {
|
|
72
|
+
const content = ` ${label.padEnd(28)}${value}`;
|
|
73
|
+
return `\u2551${content.padEnd(WIDTH)}\u2551`;
|
|
74
|
+
}
|
|
75
|
+
function header(title) {
|
|
76
|
+
const padded = ` ${title} `;
|
|
77
|
+
const totalPad = WIDTH - padded.length;
|
|
78
|
+
const left = Math.floor(totalPad / 2);
|
|
79
|
+
const right = totalPad - left;
|
|
80
|
+
return `\u2551${' '.repeat(left)}${padded}${' '.repeat(right)}\u2551`;
|
|
81
|
+
}
|
|
82
|
+
function divider() { return `\u2560${'\u2550'.repeat(WIDTH)}\u2563`; }
|
|
83
|
+
function top() { return `\u2554${'\u2550'.repeat(WIDTH)}\u2557`; }
|
|
84
|
+
function bottom() { return `\u255a${'\u2550'.repeat(WIDTH)}\u255d`; }
|
|
85
|
+
function fmt(n, digits = 3) { return n.toFixed(digits); }
|
|
86
|
+
// ─── Session Feature Extraction ───────────────────────────────────────────────
|
|
87
|
+
const COMMIT_KEYWORDS = ['commit', 'push', 'merge'];
|
|
88
|
+
function hasCommitKeyword(content) {
|
|
89
|
+
const lower = content.toLowerCase();
|
|
90
|
+
return COMMIT_KEYWORDS.some(kw => lower.includes(kw));
|
|
91
|
+
}
|
|
92
|
+
function buildSessionFeatures(entries, traces, sessionRef) {
|
|
93
|
+
const dates = entries
|
|
94
|
+
.map(e => (e.created_at instanceof Date ? e.created_at : toDate(e.created_at)))
|
|
95
|
+
.filter((d) => d !== null)
|
|
96
|
+
.sort((a, b) => a.getTime() - b.getTime());
|
|
97
|
+
if (dates.length === 0)
|
|
98
|
+
return null;
|
|
99
|
+
const startTime = dates[0];
|
|
100
|
+
const endTime = dates[dates.length - 1];
|
|
101
|
+
const durationMinutes = (endTime.getTime() - startTime.getTime()) / (1000 * 60);
|
|
102
|
+
// Sessions under half a minute with fewer than 3 entries are likely incomplete data
|
|
103
|
+
if (durationMinutes < 0.5 && entries.length < 3)
|
|
104
|
+
return null;
|
|
105
|
+
const sessionTraces = traces.filter(t => t.session_id === sessionRef);
|
|
106
|
+
const retrieval_count = sessionTraces.length;
|
|
107
|
+
const retried = sessionTraces.filter(t => t.retry_within_60s === true).length;
|
|
108
|
+
const retry_rate = retrieval_count > 0 ? retried / retrieval_count : 0;
|
|
109
|
+
const has_commits = entries.some(e => hasCommitKeyword(e.content)) ? 1 : 0;
|
|
110
|
+
return {
|
|
111
|
+
session_ref: sessionRef,
|
|
112
|
+
start_time: startTime,
|
|
113
|
+
duration_minutes: durationMinutes,
|
|
114
|
+
retrieval_count,
|
|
115
|
+
retry_rate,
|
|
116
|
+
ops_entry_count: entries.length,
|
|
117
|
+
has_commits,
|
|
118
|
+
observation_count: 0, // filled in after building all features
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function featureToVector(f) {
|
|
122
|
+
return [
|
|
123
|
+
f.duration_minutes,
|
|
124
|
+
f.retrieval_count,
|
|
125
|
+
f.retry_rate,
|
|
126
|
+
f.ops_entry_count,
|
|
127
|
+
f.has_commits,
|
|
128
|
+
f.observation_count,
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
// ─── Isolation Forest ─────────────────────────────────────────────────────────
|
|
132
|
+
/**
|
|
133
|
+
* Average path length for a dataset of size n (theoretical expectation).
|
|
134
|
+
* Used as the normalization constant c(n) in the anomaly score formula.
|
|
135
|
+
*/
|
|
136
|
+
function avgPathLength(n) {
|
|
137
|
+
if (n <= 1)
|
|
138
|
+
return 0;
|
|
139
|
+
if (n === 2)
|
|
140
|
+
return 1;
|
|
141
|
+
// H(n-1) harmonic number approximation (Euler-Mascheroni constant = 0.5772156649)
|
|
142
|
+
const h = Math.log(n - 1) + 0.5772156649;
|
|
143
|
+
return 2 * h - (2 * (n - 1)) / n;
|
|
144
|
+
}
|
|
145
|
+
function buildTree(data, indices, currentDepth, maxDepth) {
|
|
146
|
+
const size = indices.length;
|
|
147
|
+
if (size <= 1 || currentDepth >= maxDepth) {
|
|
148
|
+
return { size, is_leaf: true };
|
|
149
|
+
}
|
|
150
|
+
const numFeatures = data[0].length;
|
|
151
|
+
const featureIdx = Math.floor(Math.random() * numFeatures);
|
|
152
|
+
let minVal = Infinity;
|
|
153
|
+
let maxVal = -Infinity;
|
|
154
|
+
for (const i of indices) {
|
|
155
|
+
const v = data[i][featureIdx];
|
|
156
|
+
if (v < minVal)
|
|
157
|
+
minVal = v;
|
|
158
|
+
if (v > maxVal)
|
|
159
|
+
maxVal = v;
|
|
160
|
+
}
|
|
161
|
+
if (minVal === maxVal) {
|
|
162
|
+
return { size, is_leaf: true };
|
|
163
|
+
}
|
|
164
|
+
const splitVal = minVal + Math.random() * (maxVal - minVal);
|
|
165
|
+
const leftIdx = [];
|
|
166
|
+
const rightIdx = [];
|
|
167
|
+
for (const i of indices) {
|
|
168
|
+
if (data[i][featureIdx] < splitVal) {
|
|
169
|
+
leftIdx.push(i);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
rightIdx.push(i);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
feature_index: featureIdx,
|
|
177
|
+
split_value: splitVal,
|
|
178
|
+
left: buildTree(data, leftIdx, currentDepth + 1, maxDepth),
|
|
179
|
+
right: buildTree(data, rightIdx, currentDepth + 1, maxDepth),
|
|
180
|
+
size,
|
|
181
|
+
is_leaf: false,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function pathLength(node, x, depth) {
|
|
185
|
+
if (node.is_leaf || node.feature_index === undefined) {
|
|
186
|
+
return depth + avgPathLength(node.size);
|
|
187
|
+
}
|
|
188
|
+
if (x[node.feature_index] < node.split_value) {
|
|
189
|
+
return pathLength(node.left, x, depth + 1);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return pathLength(node.right, x, depth + 1);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/** Fisher-Yates shuffle (unbiased). */
|
|
196
|
+
function fisherYatesShuffle(arr) {
|
|
197
|
+
const a = [...arr];
|
|
198
|
+
for (let i = a.length - 1; i > 0; i--) {
|
|
199
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
200
|
+
[a[i], a[j]] = [a[j], a[i]];
|
|
201
|
+
}
|
|
202
|
+
return a;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Build Isolation Forest and return anomaly scores (0–1, higher = more anomalous).
|
|
206
|
+
* Score formula: 2^(-avgPath / c), where c = avgPathLength(subsampleSize).
|
|
207
|
+
*/
|
|
208
|
+
function isolationForest(data) {
|
|
209
|
+
const n = data.length;
|
|
210
|
+
if (n === 0)
|
|
211
|
+
return [];
|
|
212
|
+
if (n === 1)
|
|
213
|
+
return [0];
|
|
214
|
+
const subsampleSize = Math.min(SUBSAMPLE_SIZE, n);
|
|
215
|
+
const maxDepth = Math.ceil(Math.log2(subsampleSize));
|
|
216
|
+
const trees = [];
|
|
217
|
+
for (let t = 0; t < N_TREES; t++) {
|
|
218
|
+
const shuffled = fisherYatesShuffle([...Array(n).keys()]);
|
|
219
|
+
const subset = shuffled.slice(0, subsampleSize);
|
|
220
|
+
trees.push(buildTree(data, subset, 0, maxDepth));
|
|
221
|
+
}
|
|
222
|
+
const c = avgPathLength(subsampleSize);
|
|
223
|
+
const scores = [];
|
|
224
|
+
for (let i = 0; i < n; i++) {
|
|
225
|
+
const x = data[i];
|
|
226
|
+
let totalPath = 0;
|
|
227
|
+
for (const tree of trees) {
|
|
228
|
+
totalPath += pathLength(tree, x, 0);
|
|
229
|
+
}
|
|
230
|
+
const avgPath = totalPath / N_TREES;
|
|
231
|
+
scores.push(Math.pow(2, -avgPath / c));
|
|
232
|
+
}
|
|
233
|
+
return scores;
|
|
234
|
+
}
|
|
235
|
+
// ─── Anomaly Explanation ──────────────────────────────────────────────────────
|
|
236
|
+
function explainAnomaly(features) {
|
|
237
|
+
const reasons = [];
|
|
238
|
+
if (features.duration_minutes > 60 && features.has_commits === 0) {
|
|
239
|
+
reasons.push('Long session with no commits — possible stuck session');
|
|
240
|
+
}
|
|
241
|
+
if (features.retry_rate > 0.3 && features.retrieval_count > 10) {
|
|
242
|
+
reasons.push('High retry rate with many tool calls — fighting the system');
|
|
243
|
+
}
|
|
244
|
+
if (features.observation_count > 5 && features.ops_entry_count < 3) {
|
|
245
|
+
reasons.push('Many observations but few ops entries — thinking without acting');
|
|
246
|
+
}
|
|
247
|
+
if (features.duration_minutes < 2 &&
|
|
248
|
+
features.has_commits === 0 &&
|
|
249
|
+
features.retrieval_count === 0) {
|
|
250
|
+
reasons.push('Very short session with no retrieval or commits — incomplete/crashed');
|
|
251
|
+
}
|
|
252
|
+
if (features.duration_minutes > 180) {
|
|
253
|
+
reasons.push('Unusually long session duration — possible runaway or stall');
|
|
254
|
+
}
|
|
255
|
+
if (features.retry_rate > 0.5 && features.retrieval_count > 5) {
|
|
256
|
+
reasons.push('Very high retry rate — repeated retrieval failures');
|
|
257
|
+
}
|
|
258
|
+
if (reasons.length === 0) {
|
|
259
|
+
reasons.push('Statistical outlier — unusual combination of features');
|
|
260
|
+
}
|
|
261
|
+
return reasons.join('; ');
|
|
262
|
+
}
|
|
263
|
+
// ─── Report Rendering ─────────────────────────────────────────────────────────
|
|
264
|
+
function renderReport(report) {
|
|
265
|
+
const now = new Date(report.generated_at);
|
|
266
|
+
const anomalies = report.results.filter(r => r.is_anomalous);
|
|
267
|
+
const pct = report.sessions_analyzed > 0
|
|
268
|
+
? ((anomalies.length / report.sessions_analyzed) * 100).toFixed(1)
|
|
269
|
+
: '0.0';
|
|
270
|
+
const lines = [];
|
|
271
|
+
lines.push(top());
|
|
272
|
+
lines.push(header('ANOMALY DETECTION REPORT'));
|
|
273
|
+
lines.push(header(now.toISOString().slice(0, 10)));
|
|
274
|
+
lines.push(divider());
|
|
275
|
+
lines.push(row('Sessions analyzed:', String(report.sessions_analyzed)));
|
|
276
|
+
lines.push(row('Anomalies detected:', `${anomalies.length} (${pct}%)`));
|
|
277
|
+
lines.push(row('Threshold:', String(report.threshold)));
|
|
278
|
+
lines.push(row('Trees:', String(N_TREES)));
|
|
279
|
+
lines.push(row('Window:', `last ${report.window_days} days`));
|
|
280
|
+
if (anomalies.length > 0) {
|
|
281
|
+
lines.push(divider());
|
|
282
|
+
lines.push(header('Flagged Sessions'));
|
|
283
|
+
lines.push(divider());
|
|
284
|
+
for (const a of anomalies.slice(0, 10)) {
|
|
285
|
+
const ts = a.start_time.slice(0, 16).replace('T', ' ');
|
|
286
|
+
const scoreStr = fmt(a.score);
|
|
287
|
+
const tag = a.explanation.split(';')[0].trim().slice(0, 20);
|
|
288
|
+
lines.push(row(` ${ts}`, `score=${scoreStr} ${tag}`));
|
|
289
|
+
}
|
|
290
|
+
if (anomalies.length > 10) {
|
|
291
|
+
lines.push(row(' ...and more', `(${anomalies.length - 10} not shown)`));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (report.feature_summary) {
|
|
295
|
+
const fs = report.feature_summary;
|
|
296
|
+
lines.push(divider());
|
|
297
|
+
lines.push(header('Feature Ranges'));
|
|
298
|
+
lines.push(divider());
|
|
299
|
+
lines.push(row('Avg duration (min):', fmt(fs.avg_duration_minutes, 1)));
|
|
300
|
+
lines.push(row('Avg retrieval count:', fmt(fs.avg_retrieval_count, 1)));
|
|
301
|
+
lines.push(row('Avg retry rate:', fmt(fs.avg_retry_rate)));
|
|
302
|
+
lines.push(row('Sessions with commits:', `${fs.commit_rate_pct.toFixed(1)}%`));
|
|
303
|
+
}
|
|
304
|
+
lines.push(bottom());
|
|
305
|
+
console.log('');
|
|
306
|
+
for (const line of lines)
|
|
307
|
+
console.log(line);
|
|
308
|
+
console.log('');
|
|
309
|
+
}
|
|
310
|
+
// ─── Main Export ─────────────────────────────────────────────────────────────
|
|
311
|
+
export async function runAnomalies(args) {
|
|
312
|
+
const { json, days } = parseArgs(args);
|
|
313
|
+
const config = loadConfig();
|
|
314
|
+
const store = await createStore(config);
|
|
315
|
+
const now = new Date();
|
|
316
|
+
const cutoff = new Date(now);
|
|
317
|
+
cutoff.setDate(cutoff.getDate() - days);
|
|
318
|
+
process.stderr.write(`[fozikio anomalies] Loading session data (last ${days} days)...\n`);
|
|
319
|
+
const cutoffFilter = { field: 'created_at', op: '>=', value: cutoff };
|
|
320
|
+
const traceCutoffFilter = { field: 'timestamp', op: '>=', value: cutoff };
|
|
321
|
+
const obsCutoffFilter = { field: 'created_at', op: '>=', value: cutoff };
|
|
322
|
+
const [opsEntries, rawTraces, rawObs] = await Promise.all([
|
|
323
|
+
store.queryOps({ days }),
|
|
324
|
+
store.query('retrieval_traces', [traceCutoffFilter], { limit: 5000, orderBy: 'timestamp', orderDir: 'asc' }),
|
|
325
|
+
store.query('observations', [obsCutoffFilter], { limit: 2000 }),
|
|
326
|
+
]);
|
|
327
|
+
// Silence unused variable warning — cutoffFilter used above
|
|
328
|
+
void cutoffFilter;
|
|
329
|
+
const traces = rawTraces;
|
|
330
|
+
// Group ops entries by session_ref
|
|
331
|
+
const opsByRef = new Map();
|
|
332
|
+
for (const e of opsEntries) {
|
|
333
|
+
const ref = e.session_ref ?? 'unknown';
|
|
334
|
+
if (ref === 'unknown')
|
|
335
|
+
continue;
|
|
336
|
+
if (!opsByRef.has(ref))
|
|
337
|
+
opsByRef.set(ref, []);
|
|
338
|
+
opsByRef.get(ref).push(e);
|
|
339
|
+
}
|
|
340
|
+
// Build session features
|
|
341
|
+
const allFeatures = [];
|
|
342
|
+
for (const [ref, entries] of opsByRef) {
|
|
343
|
+
const f = buildSessionFeatures(entries, traces, ref);
|
|
344
|
+
if (f)
|
|
345
|
+
allFeatures.push(f);
|
|
346
|
+
}
|
|
347
|
+
if (allFeatures.length === 0) {
|
|
348
|
+
process.stderr.write('[fozikio anomalies] No sessions found with sufficient data.\n');
|
|
349
|
+
const emptyReport = {
|
|
350
|
+
generated_at: now.toISOString(),
|
|
351
|
+
window_days: days,
|
|
352
|
+
sessions_analyzed: 0,
|
|
353
|
+
anomalies_detected: 0,
|
|
354
|
+
threshold: ANOMALY_THRESHOLD,
|
|
355
|
+
results: [],
|
|
356
|
+
feature_summary: null,
|
|
357
|
+
};
|
|
358
|
+
if (json) {
|
|
359
|
+
console.log(JSON.stringify(emptyReport, null, 2));
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
console.log('[fozikio anomalies] No sessions found with sufficient data.');
|
|
363
|
+
}
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
// Assign observation counts using session time windows
|
|
367
|
+
for (const f of allFeatures) {
|
|
368
|
+
const windowStart = new Date(f.start_time.getTime() - 2 * 60 * 60 * 1000);
|
|
369
|
+
const windowEnd = new Date(f.start_time.getTime() + 4 * 60 * 60 * 1000);
|
|
370
|
+
let count = 0;
|
|
371
|
+
for (const obs of rawObs) {
|
|
372
|
+
const created = obs.created_at;
|
|
373
|
+
const d = toDate(created);
|
|
374
|
+
if (d && d >= windowStart && d <= windowEnd)
|
|
375
|
+
count++;
|
|
376
|
+
}
|
|
377
|
+
f.observation_count = count;
|
|
378
|
+
}
|
|
379
|
+
process.stderr.write(`[fozikio anomalies] Analyzing ${allFeatures.length} sessions with ${N_TREES} trees...\n`);
|
|
380
|
+
const featureVectors = allFeatures.map(featureToVector);
|
|
381
|
+
const scores = isolationForest(featureVectors);
|
|
382
|
+
const results = allFeatures.map((f, i) => ({
|
|
383
|
+
session_ref: f.session_ref,
|
|
384
|
+
start_time: f.start_time.toISOString(),
|
|
385
|
+
score: scores[i],
|
|
386
|
+
is_anomalous: scores[i] >= ANOMALY_THRESHOLD,
|
|
387
|
+
features: f,
|
|
388
|
+
explanation: scores[i] >= ANOMALY_THRESHOLD ? explainAnomaly(f) : '',
|
|
389
|
+
}));
|
|
390
|
+
results.sort((a, b) => b.score - a.score);
|
|
391
|
+
const anomalies = results.filter(r => r.is_anomalous);
|
|
392
|
+
const avgDur = allFeatures.reduce((s, f) => s + f.duration_minutes, 0) / allFeatures.length;
|
|
393
|
+
const avgRetrieval = allFeatures.reduce((s, f) => s + f.retrieval_count, 0) / allFeatures.length;
|
|
394
|
+
const avgRetry = allFeatures.reduce((s, f) => s + f.retry_rate, 0) / allFeatures.length;
|
|
395
|
+
const commitRate = allFeatures.filter(f => f.has_commits).length / allFeatures.length;
|
|
396
|
+
const report = {
|
|
397
|
+
generated_at: now.toISOString(),
|
|
398
|
+
window_days: days,
|
|
399
|
+
sessions_analyzed: allFeatures.length,
|
|
400
|
+
anomalies_detected: anomalies.length,
|
|
401
|
+
threshold: ANOMALY_THRESHOLD,
|
|
402
|
+
results,
|
|
403
|
+
feature_summary: {
|
|
404
|
+
avg_duration_minutes: avgDur,
|
|
405
|
+
avg_retrieval_count: avgRetrieval,
|
|
406
|
+
avg_retry_rate: avgRetry,
|
|
407
|
+
commit_rate_pct: commitRate * 100,
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
if (json) {
|
|
411
|
+
console.log(JSON.stringify(report, null, 2));
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
renderReport(report);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
//# sourceMappingURL=anomalies-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anomalies-cmd.js","sourceRoot":"","sources":["../../src/bin/anomalies-cmd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAK9D,iFAAiF;AAEjF,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,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CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,YAAY,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/bin/cli.d.ts
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
* serve Start the MCP server
|
|
8
8
|
* config View or edit configuration
|
|
9
9
|
* digest Process documents through cortex
|
|
10
|
+
* health Show cortex health report
|
|
11
|
+
* vitals Show behavioral vitals and PE delta
|
|
12
|
+
* anomalies Detect anomalous sessions with Isolation Forest
|
|
13
|
+
* report Generate weekly quality report
|
|
14
|
+
* maintain Data maintenance (fix, re-embed)
|
|
10
15
|
* help Show help
|
|
11
16
|
*/
|
|
12
17
|
export {};
|