@kinetica/admin-agent 0.1.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/LICENSE +191 -0
- package/NOTICE +2 -0
- package/README.md +484 -0
- package/dist/admin-agent.js +4961 -0
- package/knowledge/playbooks/config-drift.md +26 -0
- package/knowledge/playbooks/gpu-out-of-memory.md +27 -0
- package/knowledge/playbooks/memory-pressure.md +29 -0
- package/knowledge/playbooks/query-contention.md +28 -0
- package/knowledge/playbooks/resource-group-exhaustion.md +27 -0
- package/knowledge/playbooks/stale-rank.md +26 -0
- package/knowledge/references/catalog-enums.md +82 -0
- package/knowledge/references/catalog-joins.md +105 -0
- package/knowledge/references/gpudb-conf.md +93 -0
- package/knowledge/references/mutation-safety.md +89 -0
- package/knowledge/references/rank-architecture.md +54 -0
- package/knowledge/references/sql-alter-table.md +78 -0
- package/knowledge/references/sql-create-index.md +49 -0
- package/knowledge/references/tiered-objects.md +106 -0
- package/knowledge/references/version-quirks-7.2.md +96 -0
- package/knowledge/templates/report.md +57 -0
- package/package.json +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
# Kinetica Admin Agent
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
|
|
6
|
+
AI-powered diagnostic agent for [Kinetica](https://www.kinetica.com/) GPU databases. Connects to a live instance, autonomously investigates issues using 22 tools, and produces structured markdown reports with evidence-backed findings and actionable remediation.
|
|
7
|
+
|
|
8
|
+
Built with the [Claude Agent SDK](https://docs.anthropic.com/en/docs/agents-and-tools/claude-agent-sdk).
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [๐ Quick Start](#quick-start)
|
|
13
|
+
- [๐ How It Works](#how-it-works)
|
|
14
|
+
- [๐ Example Report Output](#example-report-output)
|
|
15
|
+
- [๐ Prerequisites](#prerequisites)
|
|
16
|
+
- [โ๏ธ Configuration](#configuration)
|
|
17
|
+
- [๐ Authentication](#authentication)
|
|
18
|
+
- [๐ฐ Session Budget](#session-budget)
|
|
19
|
+
- [โ ๏ธ Degraded Mode](#degraded-mode)
|
|
20
|
+
- [๐ฅ๏ธ CLI Flags](#cli-flags)
|
|
21
|
+
- [๐งฐ Tools](#tools)
|
|
22
|
+
- [๐ System Health & Monitoring](#system-health--monitoring)
|
|
23
|
+
- [๐ Resource & Performance](#resource--performance)
|
|
24
|
+
- [๐ Configuration & Logs](#configuration--logs)
|
|
25
|
+
- [๐ก๏ธ Data & Security](#data--security)
|
|
26
|
+
- [๐๏ธ SQL Execution (read-only)](#sql-execution-read-only)
|
|
27
|
+
- [โ๏ธ Administrative Mutations (require approval)](#administrative-mutations-require-approval)
|
|
28
|
+
- [๐ Batch Column Alter (self-approving)](#batch-column-alter-self-approving)
|
|
29
|
+
- [๐ Reporting](#reporting)
|
|
30
|
+
- [๐ Security](#security)
|
|
31
|
+
- [๐ Contributing Diagnostic Knowledge](#contributing-diagnostic-knowledge)
|
|
32
|
+
- [๐ Adding a Playbook](#adding-a-playbook)
|
|
33
|
+
- [๐ Adding a Reference](#adding-a-reference)
|
|
34
|
+
- [๐ง Current Knowledge](#current-knowledge)
|
|
35
|
+
- [๐ ๏ธ Development](#development)
|
|
36
|
+
- [๐ป Commands](#commands)
|
|
37
|
+
- [๐งช Evals](#evals)
|
|
38
|
+
- [๐ Project Structure](#project-structure)
|
|
39
|
+
- [๐๏ธ Architecture](#architecture)
|
|
40
|
+
- [๐ค Contributing](#contributing)
|
|
41
|
+
- [๐ Global Install](#global-install)
|
|
42
|
+
- [๐ง Troubleshooting](#troubleshooting)
|
|
43
|
+
- [๐ License](#license)
|
|
44
|
+
|
|
45
|
+
**Key capabilities:**
|
|
46
|
+
|
|
47
|
+
- Autonomous multi-round investigation with parallel tool calls
|
|
48
|
+
- 16 read-only diagnostic tools + 4 mutation tools with interactive approval + 2 self-managing tools (reporting, batch-column alter) = **22 tools total**
|
|
49
|
+
- Expert knowledge via pluggable playbooks (no code required to add new ones)
|
|
50
|
+
- Schema-aware SQL โ discovers actual column names at startup, never guesses
|
|
51
|
+
- HTTPS-first URL resolution with explicit consent required before any HTTP fallback
|
|
52
|
+
- Credential scrubbing on all saved reports
|
|
53
|
+
- Degraded mode โ useful diagnostics even when the DB engine is down
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
Run straight from GitHub (primary install path until the npm package ships):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx github:kineticadb/admin-agent
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Once published to npm (coming post-v1.0), you'll also be able to:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx @kinetica/admin-agent
|
|
67
|
+
# or globally: npm install -g @kinetica/admin-agent && admin-agent
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The agent loads connection details from `.env` if present, or prompts interactively. On repeat runs, it confirms the saved connection before proceeding.
|
|
71
|
+
|
|
72
|
+
> To run locally from source instead, see [Development](#development).
|
|
73
|
+
|
|
74
|
+
## How It Works
|
|
75
|
+
|
|
76
|
+
The agent follows a structured **5-round investigation protocol**:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
Round 1 โ Initial Sweep
|
|
80
|
+
Health check, metrics, logs, host manager status (parallel)
|
|
81
|
+
|
|
82
|
+
Round 2 โ Targeted Deep Dive
|
|
83
|
+
Follow anomalies from Round 1 (SQL queries, config checks, table details)
|
|
84
|
+
|
|
85
|
+
Round 3 โ Correlation & Root Cause
|
|
86
|
+
Cross-reference evidence, test hypotheses, fill gaps
|
|
87
|
+
|
|
88
|
+
Round 4 โ Remediation (requires approval)
|
|
89
|
+
Apply fixes: config changes, CREATE INDEX, ALTER TABLE, rebalance
|
|
90
|
+
|
|
91
|
+
Round 5 โ Verification
|
|
92
|
+
Confirm mutations took effect, document before/after state
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Each round uses multiple tools in parallel where possible. The agent names specific hypotheses, ties every conclusion to evidence, and never gives vague or generic advice.
|
|
96
|
+
|
|
97
|
+
### Example Report Output
|
|
98
|
+
|
|
99
|
+
After investigation, the agent produces a structured markdown report saved to `reports/`:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
reports/kinetica-diag-2026-03-26-040414.md
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
<details>
|
|
106
|
+
<summary>Example report excerpt</summary>
|
|
107
|
+
|
|
108
|
+
```markdown
|
|
109
|
+
# Kinetica Diagnostic Report
|
|
110
|
+
|
|
111
|
+
| Field | Value |
|
|
112
|
+
| --------------------------------- | ----------------------- |
|
|
113
|
+
| **Investigation Date/Time (UTC)** | 2026-03-26 00:00:00 UTC |
|
|
114
|
+
| **Kinetica Version** | 7.2.3.11.20260322135954 |
|
|
115
|
+
| **Tool Calls** | 11 |
|
|
116
|
+
| **Rounds** | 5 |
|
|
117
|
+
|
|
118
|
+
## Summary
|
|
119
|
+
|
|
120
|
+
`ki_home.taxi_data_historical` (478,843 rows, 52.97 MB) had no DICT encoding
|
|
121
|
+
on any of its 19 columns and no indexes. Five low-cardinality columns were
|
|
122
|
+
wasting ~28.7 MB as raw storage. Both issues have been remediated.
|
|
123
|
+
|
|
124
|
+
## Remediation
|
|
125
|
+
|
|
126
|
+
1. **DICT encoding applied** to 5 columns in a single batch ALTER TABLE
|
|
127
|
+
2. **Column index created** on `pickup_datetime`
|
|
128
|
+
3. **Manual review recommended** for `cab_type` (cardinality=1)
|
|
129
|
+
|
|
130
|
+
## Evidence Collected
|
|
131
|
+
|
|
132
|
+
| Finding | Source | Detail |
|
|
133
|
+
| ------------------------ | --------------------- | -------------------------------------- |
|
|
134
|
+
| 0 DICT-encoded columns | `kinetica_show_table` | All 19 columns showed no properties |
|
|
135
|
+
| store_and_fwd_flag waste | `ki_columns` | 15.8 MB on disk, cardinality=5, char32 |
|
|
136
|
+
| Combined DICT savings | `ki_columns` | 5 columns = 28.7 MB uncompressed |
|
|
137
|
+
|
|
138
|
+
## Mutations Applied
|
|
139
|
+
|
|
140
|
+
| Tool | Parameters | Approval | Verified |
|
|
141
|
+
| ------------------------------- | ------------------------------- | -------- | --------- |
|
|
142
|
+
| `kinetica_alter_table_columns` | DICT on 5 columns | APPROVED | confirmed |
|
|
143
|
+
| `kinetica_execute_mutation_sql` | CREATE INDEX on pickup_datetime | APPROVED | confirmed |
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
</details>
|
|
147
|
+
|
|
148
|
+
## Prerequisites
|
|
149
|
+
|
|
150
|
+
- **Node.js 20+**
|
|
151
|
+
- **Kinetica 7.2.x or later** โ network-accessible URL (default port 9191)
|
|
152
|
+
- **Anthropic API key** or **OAuth login** (Claude Pro/Max or Console account)
|
|
153
|
+
|
|
154
|
+
## Configuration
|
|
155
|
+
|
|
156
|
+
Set environment variables or use a `.env` file. The agent loads `.env` automatically at startup (shell-set variables always take precedence). Any missing values are prompted interactively.
|
|
157
|
+
|
|
158
|
+
| Variable | Description | Required |
|
|
159
|
+
| --------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------- |
|
|
160
|
+
| `ANTHROPIC_API_KEY` | Anthropic API key for Claude | No โ OAuth login used if unset |
|
|
161
|
+
| `KINETICA_URL` | Kinetica instance URL (e.g. `http://host:9191` or bare `host:9191`) | Prompted if unset |
|
|
162
|
+
| `KINETICA_USER` | Kinetica username | Prompted if unset |
|
|
163
|
+
| `KINETICA_PASS` | Kinetica password | Prompted if unset (masked, never saved to .env) |
|
|
164
|
+
| `KINETICA_HTTPS_ONLY` | Set to `1` to refuse plaintext HTTP fallback entirely โ strict mode for production clusters | No |
|
|
165
|
+
| `DEBUG` | Set to `1` to log HTTP requests and the assembled system-prompt token size to stderr | No |
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
cp .env.example .env # fill in values โ or let the agent create it for you
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
On first interactive connection, the agent offers to save `KINETICA_URL` and `KINETICA_USER` to `.env` (password is never saved). On subsequent runs with saved values, the agent shows the saved connection and asks to confirm before proceeding.
|
|
172
|
+
|
|
173
|
+
If you enter a URL without a protocol (e.g., `host:9191`), the agent auto-detects by probing HTTPS first. If HTTPS fails and HTTP succeeds, the agent displays a red warning (credentials would travel in cleartext) and asks for explicit y/n confirmation before falling back. Set `KINETICA_HTTPS_ONLY=1` to refuse the fallback outright โ recommended for production. In non-interactive environments (CI, piped input), the fallback is always refused; pass an explicit `http://` prefix if you really want HTTP. On authentication failure (401/403), the agent offers to re-enter credentials instead of retrying with the same values.
|
|
174
|
+
|
|
175
|
+
### Authentication
|
|
176
|
+
|
|
177
|
+
Anthropic authentication runs **before** Kinetica credential collection โ the agent verifies it can reach the Claude API first, then asks for database credentials.
|
|
178
|
+
|
|
179
|
+
The agent supports two Anthropic authentication methods:
|
|
180
|
+
|
|
181
|
+
1. **API key** โ set `ANTHROPIC_API_KEY` in environment or `.env` file. Get one at [console.anthropic.com](https://console.anthropic.com/).
|
|
182
|
+
2. **OAuth login** โ if no API key is set, the agent opens a browser for Anthropic OAuth login (same flow as `claude login`). OAuth tokens are cached across sessions โ subsequent runs reuse the cached credentials without reopening the browser. Use `--login` to force a fresh OAuth login, or `--logout` to clear cached credentials.
|
|
183
|
+
|
|
184
|
+
In non-interactive environments (CI, Docker without `-it`, piped input), an `ANTHROPIC_API_KEY` is required โ OAuth needs a browser and will fail immediately with a clear error.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# API key (traditional)
|
|
188
|
+
ANTHROPIC_API_KEY=sk-... npm run dev
|
|
189
|
+
|
|
190
|
+
# OAuth login (opens browser on first run, reuses cached token after)
|
|
191
|
+
npm run dev
|
|
192
|
+
|
|
193
|
+
# Force OAuth login (ignore existing API key or cached token)
|
|
194
|
+
npm run dev -- --login
|
|
195
|
+
|
|
196
|
+
# OAuth with Console billing (instead of Claude Pro/Max)
|
|
197
|
+
npm run dev -- --login --login-method=console
|
|
198
|
+
|
|
199
|
+
# Log out (clear cached OAuth credentials)
|
|
200
|
+
npm run dev -- --logout
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Session Budget
|
|
204
|
+
|
|
205
|
+
Each session enforces a **$5.00 maximum API cost**. The agent reports actual spend in the session summary on exit.
|
|
206
|
+
|
|
207
|
+
### Degraded Mode
|
|
208
|
+
|
|
209
|
+
If the DB engine on port 9191 is unreachable after 3 retries, the agent probes the host manager on port 9300. If it responds, the agent starts in **degraded mode** โ only `kinetica_host_manager_status` provides useful data (version, license, per-rank process status). If both ports are unreachable, the agent exits with code 1.
|
|
210
|
+
|
|
211
|
+
## CLI Flags
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
admin-agent --help # Show usage
|
|
215
|
+
admin-agent --version # Print version
|
|
216
|
+
admin-agent --verbose # Enable debug logging (stack traces on error)
|
|
217
|
+
admin-agent --login # Force OAuth login (even if API key is set)
|
|
218
|
+
admin-agent --login-method=TYPE # Login method: claudeai (Pro/Max) or console
|
|
219
|
+
admin-agent --login-org=UUID # Target organization UUID for OAuth
|
|
220
|
+
admin-agent --logout # Log out from Anthropic account and exit
|
|
221
|
+
admin-agent --model=NAME # Override agent model (sonnet | haiku | opus); default: sonnet
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
The `--model` flag swaps the primary model for a single session. `haiku` is cheaper and faster for simple triage; `opus` is slower and more expensive but produces deeper reasoning on complex investigations. The fallback model remains `haiku` regardless of the primary choice, so availability is unchanged.
|
|
225
|
+
|
|
226
|
+
## Tools
|
|
227
|
+
|
|
228
|
+
22 tools organized into categories. Diagnostic and SQL tools execute without approval. Mutation tools require explicit user confirmation via an interactive y/n/explain prompt. The batch column alter tool is self-approving via its own checklist + SQL preview flow.
|
|
229
|
+
|
|
230
|
+
### System Health & Monitoring
|
|
231
|
+
|
|
232
|
+
| Tool | Description |
|
|
233
|
+
| ------------------------------ | ----------------------------------------------------------------------- |
|
|
234
|
+
| `kinetica_health_check` | 11-component health status: system, ranks, hosts, HTTP server, HA, etc. |
|
|
235
|
+
| `kinetica_cluster_status` | Rebalance progress, shard distribution, alerts, active async jobs |
|
|
236
|
+
| `kinetica_verify_db` | Database integrity: null checks, persistence issues, orphaned tables |
|
|
237
|
+
| `kinetica_system_timing` | Last ~100 API calls with endpoint name and response time (ms) |
|
|
238
|
+
| `kinetica_host_manager_status` | Host manager cluster status, per-rank process info (no auth required) |
|
|
239
|
+
|
|
240
|
+
### Resource & Performance
|
|
241
|
+
|
|
242
|
+
| Tool | Description |
|
|
243
|
+
| --------------------------- | ------------------------------------------------------------------------------- |
|
|
244
|
+
| `kinetica_get_metrics` | Per-rank storage tier summary: RAM/persist/disk/VRAM used and limits |
|
|
245
|
+
| `kinetica_node_details` | Detailed per-rank breakdown: per-tier limits/usage, per-resource-group threads |
|
|
246
|
+
| `kinetica_resource_groups` | Resource group definitions: memory limits, CPU concurrency, scheduling priority |
|
|
247
|
+
| `kinetica_resource_objects` | Per-rank object placement: sizes, tier, priority, eviction stats, lock status |
|
|
248
|
+
|
|
249
|
+
### Configuration & Logs
|
|
250
|
+
|
|
251
|
+
| Tool | Description |
|
|
252
|
+
| -------------------------------- | -------------------------------------------------------------------------- |
|
|
253
|
+
| `kinetica_get_system_properties` | 260+ runtime config properties with optional category/key filtering |
|
|
254
|
+
| `kinetica_show_configuration` | Full `gpudb.conf` from host manager (port 9300) |
|
|
255
|
+
| `kinetica_get_logs` | Application logs by source/severity/time range (_7.2.x: use SQL fallback_) |
|
|
256
|
+
|
|
257
|
+
### Data & Security
|
|
258
|
+
|
|
259
|
+
| Tool | Description |
|
|
260
|
+
| ------------------------ | ------------------------------------------------------------------- |
|
|
261
|
+
| `kinetica_show_table` | Column names, Kinetica-native types, per-column properties, indexes |
|
|
262
|
+
| `kinetica_show_security` | Users, roles, permissions, resource group assignments |
|
|
263
|
+
|
|
264
|
+
### SQL Execution (read-only)
|
|
265
|
+
|
|
266
|
+
| Tool | Description |
|
|
267
|
+
| ------------------------ | ---------------------------------------------------------- |
|
|
268
|
+
| `kinetica_execute_sql` | SELECT/WITH queries against system catalog tables |
|
|
269
|
+
| `kinetica_explain_query` | Execution plan: step IDs, internal endpoints, dependencies |
|
|
270
|
+
|
|
271
|
+
### Administrative Mutations (require approval)
|
|
272
|
+
|
|
273
|
+
| Tool | Description |
|
|
274
|
+
| ---------------------------------- | ------------------------------------------------------------------------ |
|
|
275
|
+
| `kinetica_alter_system_properties` | Runtime config changes with before/after verification |
|
|
276
|
+
| `kinetica_execute_mutation_sql` | DDL/DML (CREATE INDEX, ALTER TABLE, etc.) โ DROP/TRUNCATE/DELETE blocked |
|
|
277
|
+
| `kinetica_admin_rebalance` | Shard rebalancing with aggressiveness cap and before/after capture |
|
|
278
|
+
| `kinetica_alter_configuration` | Replace `gpudb.conf` with before/after verification |
|
|
279
|
+
|
|
280
|
+
### Batch Column Alter (self-approving)
|
|
281
|
+
|
|
282
|
+
| Tool | Description |
|
|
283
|
+
| ------------------------------ | ------------------------------------------------------------------------------------------------------- |
|
|
284
|
+
| `kinetica_alter_table_columns` | Batch 2+ column changes into one ALTER TABLE. Two-step approval: interactive checklist then SQL preview |
|
|
285
|
+
|
|
286
|
+
### Reporting
|
|
287
|
+
|
|
288
|
+
| Tool | Description |
|
|
289
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
290
|
+
| `save_report` | Timestamped markdown report to `reports/` with credential scrubbing |
|
|
291
|
+
|
|
292
|
+
## Security
|
|
293
|
+
|
|
294
|
+
The agent is designed with defense-in-depth for database administration:
|
|
295
|
+
|
|
296
|
+
- **Credential isolation** โ Kinetica credentials are captured in a closure and never exposed to the agent or logged
|
|
297
|
+
- **HTTPS enforcement** โ URL resolution probes HTTPS first; any fallback to plaintext HTTP requires explicit interactive confirmation, is refused in non-interactive environments, and can be disabled entirely via `KINETICA_HTTPS_ONLY=1`
|
|
298
|
+
- **Read-only by default** โ 16 read-only diagnostic tools (including SQL execute/explain) run without approval; the agent has no access to `Bash`, `Edit`, `Write`, or `MultiEdit` and cannot run arbitrary shell commands
|
|
299
|
+
- **Mutation approval gate** โ the 4 administrative mutation tools each trigger an interactive y/n/explain prompt before execution; DROP/TRUNCATE/DELETE/UPDATE SQL is always blocked (with CTE-bypass protection)
|
|
300
|
+
- **Two-step approval for batch column alter** โ `kinetica_alter_table_columns` requires the operator to select columns via a checklist, then confirm the exact SQL preview
|
|
301
|
+
- **Audit trail** โ every mutation logs a redacted audit line to stderr (EXECUTED/FAILED + fingerprinted input summary) and appears in the report's "Mutations Applied" table with before/after state
|
|
302
|
+
- **Report scrubbing** โ saved reports are scrubbed of URLs, auth headers, Basic/Bearer credentials, cookies, and passwords before writing to disk
|
|
303
|
+
- **Budget cap** โ $5.00 max API cost per session prevents runaway spend
|
|
304
|
+
|
|
305
|
+
To report a security vulnerability, please see [SECURITY.md](SECURITY.md). Do not open a public GitHub issue for security issues.
|
|
306
|
+
|
|
307
|
+
## Contributing Diagnostic Knowledge
|
|
308
|
+
|
|
309
|
+
The agent's expert troubleshooting knowledge lives in `knowledge/` as Markdown files โ no TypeScript required.
|
|
310
|
+
|
|
311
|
+
### Adding a Playbook
|
|
312
|
+
|
|
313
|
+
Playbooks are diagnostic runbooks in `knowledge/playbooks/`. Create a new `.md` file:
|
|
314
|
+
|
|
315
|
+
```markdown
|
|
316
|
+
---
|
|
317
|
+
title: Shard Imbalance
|
|
318
|
+
category: cluster
|
|
319
|
+
severity: warning
|
|
320
|
+
keywords: [shard, imbalance, skew, distribution]
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Symptoms
|
|
324
|
+
|
|
325
|
+
- Uneven query response times across ranks
|
|
326
|
+
- One rank consistently at higher CPU/memory than others
|
|
327
|
+
|
|
328
|
+
## Detection
|
|
329
|
+
|
|
330
|
+
- `kinetica_get_metrics` -> compare `ram_percent` across worker ranks
|
|
331
|
+
- `kinetica_cluster_status` -> check shard distribution
|
|
332
|
+
|
|
333
|
+
## Root Cause
|
|
334
|
+
|
|
335
|
+
Data skew from poor shard key choice or post-rebalance drift.
|
|
336
|
+
|
|
337
|
+
## Remediation
|
|
338
|
+
|
|
339
|
+
1. Check shard key distribution via `kinetica_execute_sql`
|
|
340
|
+
2. Use `kinetica_admin_rebalance` with aggressiveness 1-3
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
| Field | Required | Description |
|
|
344
|
+
| ---------- | -------- | ---------------------------------------------------------- |
|
|
345
|
+
| `title` | Yes | Pattern name shown in agent's diagnostic knowledge |
|
|
346
|
+
| `category` | No | Grouping (e.g., `performance`, `cluster`, `configuration`) |
|
|
347
|
+
| `severity` | No | `critical`, `warning`, or `info` (default: `info`) |
|
|
348
|
+
| `keywords` | No | Search terms: `[term1, term2]` |
|
|
349
|
+
|
|
350
|
+
Playbooks are loaded automatically at startup โ no build step needed.
|
|
351
|
+
|
|
352
|
+
### Adding a Reference
|
|
353
|
+
|
|
354
|
+
References provide domain knowledge (not diagnostic runbooks). Create a `.md` file in `knowledge/references/` with the same frontmatter format but without `severity`.
|
|
355
|
+
|
|
356
|
+
### Current Knowledge
|
|
357
|
+
|
|
358
|
+
**Playbooks** (6): memory-pressure, gpu-out-of-memory, query-contention, resource-group-exhaustion, stale-rank, config-drift
|
|
359
|
+
|
|
360
|
+
**References** (9):
|
|
361
|
+
|
|
362
|
+
- `gpudb-conf` โ master config file structure, section index, tiered storage semantics
|
|
363
|
+
- `tiered-objects` โ `ki_tiered_objects` schema, ID format, diagnostic queries
|
|
364
|
+
- `catalog-enums` โ enum value decoders for `ki_catalog` integer columns
|
|
365
|
+
- `catalog-joins` โ safe join paths between `ki_catalog` tables (oid compatibility, naming caveats)
|
|
366
|
+
- `rank-architecture` โ rank 0 vs worker ranks, head-node resource profile, shard ownership model
|
|
367
|
+
- `mutation-safety` โ pre-execution checklist for rebalance, alter-config, and DDL paths
|
|
368
|
+
- `sql-alter-table` โ Kinetica 7.2 ALTER TABLE grammar, column property flags, shard-key immutability
|
|
369
|
+
- `sql-create-index` โ column index syntax, chunk skip index, when to use which
|
|
370
|
+
- `version-quirks-7.2` โ endpoint/property differences between 7.2.x and earlier releases
|
|
371
|
+
|
|
372
|
+
> **Heads up โ prompt budget:** all playbooks and references are front-loaded into a single system prompt at startup, so its token cost grows with the knowledge corpus. A startup tripwire (`agent/prompt-budget.ts`) prints the assembled prompt size under `DEBUG` and warns on stderr once it exceeds ~15,000 estimated tokens. Current baseline is ~13.4k tokens (6 playbooks + 9 references). If you add substantial knowledge and trip that warning, treat it as the cue to switch from "load everything" to keyword-based playbook selection.
|
|
373
|
+
|
|
374
|
+
## Development
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
git clone https://github.com/kineticadb/admin-agent.git
|
|
378
|
+
cd admin-agent
|
|
379
|
+
npm install
|
|
380
|
+
cp .env.example .env # optional โ all values are prompted on first run (OAuth login opens in browser if no API key)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Commands
|
|
384
|
+
|
|
385
|
+
| Command | Description |
|
|
386
|
+
| -------------------------- | ------------------------------------------------ |
|
|
387
|
+
| `npm run dev` | Run from source via tsx |
|
|
388
|
+
| `npm run dev -- --verbose` | Run with debug logging |
|
|
389
|
+
| `npm run build` | Bundle with tsup -> `dist/admin-agent.js` |
|
|
390
|
+
| `npm run typecheck` | Type-check without emitting |
|
|
391
|
+
| `npm test` | Run all tests (vitest) |
|
|
392
|
+
| `npm run test:watch` | Tests in watch mode |
|
|
393
|
+
| `npm run test:coverage` | Coverage report (80% line threshold) |
|
|
394
|
+
| `npm run eval` | Run the report-format eval against the real API |
|
|
395
|
+
| `npm run lint` | Run ESLint (typescript-eslint, type-aware rules) |
|
|
396
|
+
| `npm run lint:fix` | Run ESLint and auto-fix what it can |
|
|
397
|
+
| `npm run format` | Run Prettier to format all supported files |
|
|
398
|
+
| `npm run format:check` | Run Prettier in check-only mode (no writes) |
|
|
399
|
+
|
|
400
|
+
Run a single test file:
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
npx vitest run src/agent/turn-gate.test.ts
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Evals
|
|
407
|
+
|
|
408
|
+
Unit tests in `src/**/*.test.ts` verify the inputs to the model (system prompt, template files, tool catalog). Evals under `src/evals/` verify the outputs โ they run the full agent loop against a mocked Kinetica session and assert the model's generated report conforms to the template. Evals are deliberately **not** part of `npm test` (they hit the real Anthropic API, cost money, and are non-deterministic).
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# Requires ANTHROPIC_API_KEY (or a prior OAuth login)
|
|
412
|
+
npm run eval
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Exit codes: `0` pass, `1` assertion failed, `2` harness failure (e.g., missing API key). See [`src/evals/README.md`](src/evals/README.md) for the design rationale and how to add new evals.
|
|
416
|
+
|
|
417
|
+
### Project Structure
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
src/
|
|
421
|
+
cli/ # Entry point, banner, arg parsing
|
|
422
|
+
agent/ # Agent loop, system prompt, schema discovery
|
|
423
|
+
session/ # Kinetica connection, credentials, .env management, URL resolution
|
|
424
|
+
tools/ # 22 MCP tools (rest/, sql/, mutation/)
|
|
425
|
+
output/ # Formatting, truncation, table alignment
|
|
426
|
+
approval/ # Mutation approval gate and checklist UI
|
|
427
|
+
report/ # Report generation and credential scrubbing
|
|
428
|
+
evals/ # Model-output eval harness (separate from unit tests)
|
|
429
|
+
types/ # Shared type contracts
|
|
430
|
+
knowledge/
|
|
431
|
+
playbooks/ # Diagnostic runbooks (Markdown + YAML frontmatter)
|
|
432
|
+
references/ # Domain knowledge documents
|
|
433
|
+
reports/ # Generated diagnostic reports (git-ignored)
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Tests are co-located: every `*.ts` source file has a sibling `*.test.ts` in the same directory.
|
|
437
|
+
|
|
438
|
+
CI (`.github/workflows/ci.yml`) runs type-check, test, and bundle build against Node 20.x and 22.x on every pull request and push to `main`. A separate `lint` job runs linting via ESLint + typescript-eslint (`npm run lint`) and formatting checks via Prettier (`npm run format:check`) once on Node 20.x โ both gate every PR. Run them locally (or `npm run format` to auto-fix) before opening a PR.
|
|
439
|
+
|
|
440
|
+
### Architecture
|
|
441
|
+
|
|
442
|
+
For a detailed architecture reference (startup flow, tool internals, output pipeline, type contracts, API quirks), see [CLAUDE.md](CLAUDE.md).
|
|
443
|
+
|
|
444
|
+
## Contributing
|
|
445
|
+
|
|
446
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full development workflow, commit conventions, code style, and how to add new tools.
|
|
447
|
+
|
|
448
|
+
## Global Install
|
|
449
|
+
|
|
450
|
+
Once the npm package is published (coming post-v1.0):
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
npm install -g @kinetica/admin-agent
|
|
454
|
+
admin-agent
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
## Troubleshooting
|
|
458
|
+
|
|
459
|
+
**Agent can't connect to Kinetica**
|
|
460
|
+
|
|
461
|
+
- Verify the URL is reachable: `curl http://host:9191/show/system/status`
|
|
462
|
+
- Check firewall rules for ports 9191 (DB engine) and 9300 (host manager)
|
|
463
|
+
- If only port 9300 responds, the agent will start in [degraded mode](#degraded-mode)
|
|
464
|
+
|
|
465
|
+
**"Unknown URI" errors from tools**
|
|
466
|
+
|
|
467
|
+
- Some endpoints (e.g., `/admin/show/logs`) don't exist in Kinetica 7.2.x โ the agent falls back to SQL queries automatically
|
|
468
|
+
|
|
469
|
+
**Agent hits budget cap**
|
|
470
|
+
|
|
471
|
+
- Default is $5.00 per session. For complex multi-table investigations, consider running focused sessions per table
|
|
472
|
+
|
|
473
|
+
**Empty or missing report**
|
|
474
|
+
|
|
475
|
+
- Reports save to `reports/` in the working directory. If the session is interrupted, a partial report may be saved with a `(partial)` flag
|
|
476
|
+
|
|
477
|
+
**Agent refuses HTTP connection**
|
|
478
|
+
|
|
479
|
+
- If HTTPS probing fails and you want to allow HTTP, pass an explicit `http://` prefix in `KINETICA_URL` (not just a bare hostname)
|
|
480
|
+
- Production deployments should keep `KINETICA_HTTPS_ONLY=1` set to prevent any plaintext credential transmission
|
|
481
|
+
|
|
482
|
+
## License
|
|
483
|
+
|
|
484
|
+
[Apache-2.0](LICENSE)
|