Skip to content

Commit ac0e98f

Browse files
newbishtevnull
andauthored
docs: clarify token analytics install workflow (#50)
Co-authored-by: Rick <rick@tevpro.com>
1 parent ae99a89 commit ac0e98f

3 files changed

Lines changed: 130 additions & 5 deletions

File tree

docs/hermes-token-analytics-install-runbook.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ Before you start, confirm:
4343

4444
## Step 1. Install the plugin into the Hermes checkout
4545

46+
> [!WARNING]
47+
> This repository is a monorepo. The Hermes plugin is **not** at the repo root.
48+
> Do **not** install the repo root directly with `hermes plugins install <repo-url>`.
49+
> The actual plugin source lives at `plugins/hermes-token-analytics/`.
50+
51+
### Install target options
52+
53+
There are two valid install targets. They are not the same thing.
54+
55+
1. **Bundled checkout plugin path**, for development inside a Hermes repo checkout
56+
- target root: `~/.hermes/hermes-agent`
57+
- resulting plugin path: `~/.hermes/hermes-agent/plugins/hermes-token-analytics/`
58+
2. **User plugin path**, preferred for a normal operator install
59+
- resulting plugin path: `~/.hermes/plugins/hermes-token-analytics/`
60+
61+
Preferred default: use the **user plugin path** unless you are intentionally working inside a bundled Hermes checkout.
62+
63+
### Bundled checkout install
64+
4665
From this repo root, copy the plugin into the target Hermes checkout:
4766

4867
```bash
@@ -67,6 +86,22 @@ What the helper does:
6786
- writes a compatibility shim at `plugins/observability/token_analytics/`
6887
- lets older `plugins.enabled` entries keep working during migration
6988

89+
### User plugin install
90+
91+
If you are doing a normal user-level install instead of editing a Hermes checkout in place, copy this repo subdirectory into:
92+
93+
```text
94+
~/.hermes/plugins/hermes-token-analytics
95+
```
96+
97+
Use the contents of:
98+
99+
```text
100+
plugins/hermes-token-analytics/
101+
```
102+
103+
The main operational point is simple: copy the plugin directory, not the monorepo root.
104+
70105
## Step 2. Enable the plugin in Hermes
71106

72107
Enable the plugin by its path-derived key:
@@ -75,6 +110,12 @@ Enable the plugin by its path-derived key:
75110
hermes plugins enable hermes-token-analytics
76111
```
77112

113+
Then restart the gateway so Hermes reloads the plugin command surface:
114+
115+
```bash
116+
hermes gateway restart
117+
```
118+
78119
Then verify Hermes sees it:
79120

80121
```bash
@@ -84,6 +125,7 @@ hermes plugins list
84125
What you want to see:
85126

86127
- `hermes-token-analytics` listed as enabled
128+
- the plugin commands available after the restart
87129

88130
If the target install still references the old compatibility path, the shim also supports the legacy key:
89131

@@ -156,6 +198,10 @@ What success looks like:
156198
- `show-config` shows the resolved endpoint, workspace fields, and redacted shared secret
157199
- `sync` posts successfully to `/api/ingest/hermes-usage`
158200

201+
Important: a successful `hermes token-analytics sync` only proves the plugin works manually.
202+
It does **not** mean continuous reporting is active.
203+
Continuous reporting requires a cron job.
204+
159205
If `sync` fails, stop here and fix config before adding cron.
160206

161207
## Step 5. Create the scheduled job
@@ -214,6 +260,19 @@ Confirm:
214260
- the schedule is correct
215261
- the cron-triggered run behaves the same as the manual `sync`
216262

263+
## Production readiness checklist
264+
265+
- [ ] plugin copied from `plugins/hermes-token-analytics/` into the intended install target
266+
- [ ] plugin enabled
267+
- [ ] gateway restarted
268+
- [ ] `hermes token-analytics doctor` passes
269+
- [ ] `hermes token-analytics show-config` is correct
270+
- [ ] `hermes token-analytics sync` succeeds
271+
- [ ] `hermes token-analytics install-cron-wrapper` run
272+
- [ ] cron job created
273+
- [ ] `hermes cron list --all` shows `token-analytics-sync`
274+
- [ ] one cron-triggered run verified
275+
217276
## Normal operating procedure
218277

219278
Use this sequence for changes or repairs:

docs/hermes-token-analytics-plugin.md

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@
44

55
This integration is now a **Hermes-native Python plugin**, not a Node or bash sidecar.
66

7+
> [!WARNING]
8+
> This repository is a monorepo. The Hermes plugin is **not** at the repo root.
9+
> Do **not** install the repo root directly with `hermes plugins install <repo-url>`.
10+
> The actual plugin source lives at `plugins/hermes-token-analytics/`.
11+
712
Operator setup is:
813

9-
1. Set the Cloudflare Worker secret `HERMES_TOKEN_ANALYTICS_SHARED_SECRET`.
10-
2. Export the plugin env vars shown below.
11-
3. Validate the install with:
14+
1. Copy `plugins/hermes-token-analytics/` into the correct install target.
15+
2. Enable the plugin and restart the Hermes gateway.
16+
3. Set the Cloudflare Worker secret `HERMES_TOKEN_ANALYTICS_SHARED_SECRET`.
17+
4. Export the plugin env vars shown below.
18+
5. Validate the install with:
1219
```bash
1320
hermes token-analytics doctor
1421
hermes token-analytics show-config
1522
```
16-
4. Push one manual sync:
23+
6. Push one manual sync:
1724
```bash
1825
hermes token-analytics sync
1926
```
20-
5. Let **Hermes cron own the schedule** by creating a single cron job that runs the sync command on a cadence such as every 15 minutes. That one job covers both rollups and heartbeat freshness.
27+
7. Let **Hermes cron own the schedule** by creating a single cron job that runs the sync command on a cadence such as every 15 minutes. That one job covers both rollups and heartbeat freshness.
2128

2229
If you just need the exact install sequence, use:
2330

@@ -46,6 +53,18 @@ This repo is the dashboard and ingest target. The operator-facing runtime is the
4653

4754
For local Hermes checkout installs, the helper now copies the plugin into `plugins/hermes-token-analytics/` and also writes a legacy compatibility shim at `plugins/observability/token_analytics/` so existing enabled-plugin configs do not break mid-upgrade.
4855

56+
## Common operational failure modes
57+
58+
When operators report that token analytics is "not working," the failure is often in the workflow, not the plugin logic.
59+
60+
The main causes are:
61+
62+
- using the monorepo root instead of `plugins/hermes-token-analytics/`
63+
- enabling the plugin without restarting the Hermes gateway
64+
- proving only that a manual sync works, without creating a cron job for continuous reporting
65+
66+
Manual sync working is useful, but it is not the same thing as production readiness.
67+
4968
## Architecture and ownership
5069

5170
### Hermes-native plugin, not a sidecar
@@ -72,6 +91,28 @@ UI note: the dashboard may refer to these imported workspaces as **Agents** in u
7291
If a sync is running at the wrong time, fix Hermes cron.
7392
If a sync is reading the wrong DB or posting to the wrong workspace, fix plugin config.
7493

94+
### Install target choices
95+
96+
There are two supported install targets:
97+
98+
1. **Bundled checkout path**
99+
- use this when you are editing a Hermes repo checkout directly
100+
- plugin lives under `~/.hermes/hermes-agent/plugins/hermes-token-analytics/`
101+
2. **User plugin path**, preferred for normal operator installs
102+
- plugin lives under `~/.hermes/plugins/hermes-token-analytics/`
103+
104+
If both are technically available, prefer the **user plugin path** unless you specifically need the plugin to live inside a Hermes checkout for development.
105+
106+
### Gateway reload requirement
107+
108+
After `hermes plugins enable hermes-token-analytics`, run:
109+
110+
```bash
111+
hermes gateway restart
112+
```
113+
114+
Without the restart, Hermes may still be running without the newly enabled plugin command surface.
115+
75116
## Required Worker-side configuration
76117

77118
The Worker route rejects unauthenticated syncs.
@@ -206,6 +247,10 @@ A successful run should:
206247
4. receive a successful response from the ingest route
207248
5. make the imported workspace visible in the dashboard
208249

250+
A successful manual `hermes token-analytics sync` only proves that the plugin works in the foreground.
251+
It does **not** prove that continuous reporting is active.
252+
Continuous reporting requires a Hermes cron job.
253+
209254
### `hermes token-analytics install-cron-wrapper`
210255

211256
Install a thin shell wrapper for Hermes cron `no_agent` jobs.

plugins/hermes-token-analytics/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This directory is the source-of-truth copy of the Hermes token analytics plugin inside the monorepo.
44

5+
> [!WARNING]
6+
> This repository is a monorepo. The Hermes plugin is **not** at the repo root.
7+
> Do **not** install the repo root directly with `hermes plugins install <repo-url>`.
8+
> The actual plugin source lives at `plugins/hermes-token-analytics/`.
9+
510
## What lives here
611

712
- `plugins/hermes-token-analytics/` — the plugin files as they should exist inside a Hermes checkout
@@ -30,6 +35,13 @@ python3 -m pytest plugins/hermes-token-analytics/tests -q
3035

3136
## Local install helper
3237

38+
There are two install patterns:
39+
40+
1. **Bundled checkout install**, useful when you are modifying a Hermes repo checkout directly
41+
2. **User plugin install**, preferred for normal operator usage under `~/.hermes/plugins/hermes-token-analytics`
42+
43+
Bundled checkout helper:
44+
3345
```bash
3446
plugins/hermes-token-analytics/scripts/install-local-plugin.sh /path/to/hermes-agent
3547
```
@@ -39,3 +51,12 @@ Default target if no argument is passed:
3951
- `~/.hermes/hermes-agent`
4052

4153
The install helper also writes a small compatibility shim at `plugins/observability/token_analytics/` inside the target Hermes checkout so older `plugins.enabled` entries keep working during migration.
54+
55+
After enabling the plugin, restart the gateway:
56+
57+
```bash
58+
hermes plugins enable hermes-token-analytics
59+
hermes gateway restart
60+
```
61+
62+
A successful manual `hermes token-analytics sync` proves the plugin works manually. It does **not** prove continuous reporting is active. For that, create the cron job described in `docs/hermes-token-analytics-install-runbook.md`.

0 commit comments

Comments
 (0)