chimericmesh 0.2.2__py3-none-any.whl
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.
- chimericmesh/__init__.py +3 -0
- chimericmesh/__main__.py +119 -0
- chimericmesh/agent/__init__.py +21 -0
- chimericmesh/agent/codesearch.py +131 -0
- chimericmesh/agent/digest.py +131 -0
- chimericmesh/agent/errors.py +38 -0
- chimericmesh/agent/feed.py +47 -0
- chimericmesh/agent/limits.py +98 -0
- chimericmesh/agent/ports.py +32 -0
- chimericmesh/agent/routes.py +92 -0
- chimericmesh/agent/service.py +116 -0
- chimericmesh/agent/snippet.py +135 -0
- chimericmesh/agent/verify.py +215 -0
- chimericmesh/agent/watch.py +156 -0
- chimericmesh/api.py +626 -0
- chimericmesh/approvals/__init__.py +25 -0
- chimericmesh/approvals/errors.py +72 -0
- chimericmesh/approvals/format.py +76 -0
- chimericmesh/approvals/irc.py +54 -0
- chimericmesh/approvals/ledger.py +149 -0
- chimericmesh/approvals/limits.py +87 -0
- chimericmesh/approvals/manager.py +935 -0
- chimericmesh/approvals/matching.py +107 -0
- chimericmesh/approvals/models.py +251 -0
- chimericmesh/approvals/ports.py +36 -0
- chimericmesh/approvals/routes.py +220 -0
- chimericmesh/approvals/rulebook.py +337 -0
- chimericmesh/approvals/schema.py +64 -0
- chimericmesh/approvals/scope.py +104 -0
- chimericmesh/approvals/validate.py +215 -0
- chimericmesh/catalog/demo_apps.json +41 -0
- chimericmesh/catalog/legacy_apps.json +612 -0
- chimericmesh/commands.py +223 -0
- chimericmesh/connectors/__init__.py +1 -0
- chimericmesh/connectors/config.py +55 -0
- chimericmesh/connectors/framing.py +132 -0
- chimericmesh/connectors/limiter.py +42 -0
- chimericmesh/connectors/manager.py +252 -0
- chimericmesh/connectors/offsets.py +157 -0
- chimericmesh/connectors/schema.py +31 -0
- chimericmesh/connectors/submit.py +26 -0
- chimericmesh/connectors/syslog_tcp.py +141 -0
- chimericmesh/connectors/tailer.py +236 -0
- chimericmesh/connectors/tailread.py +288 -0
- chimericmesh/demo/__init__.py +1 -0
- chimericmesh/demo/agent.py +32 -0
- chimericmesh/demo/apps/__init__.py +1 -0
- chimericmesh/demo/apps/__main__.py +83 -0
- chimericmesh/demo/apps/common.py +163 -0
- chimericmesh/demo/apps/mail_bridge.py +48 -0
- chimericmesh/demo/apps/orders_api.py +31 -0
- chimericmesh/demo/apps/spooler.py +28 -0
- chimericmesh/demo/config.py +38 -0
- chimericmesh/demo/engine.py +68 -0
- chimericmesh/demo/env.py +46 -0
- chimericmesh/demo/hub.py +172 -0
- chimericmesh/demo/launcher.py +165 -0
- chimericmesh/demo/ports.py +44 -0
- chimericmesh/demo/routes.py +81 -0
- chimericmesh/demo/samples.py +32 -0
- chimericmesh/demo/scenario.py +95 -0
- chimericmesh/demo/supervisor.py +267 -0
- chimericmesh/demo/watch.py +46 -0
- chimericmesh/diagnostics.py +253 -0
- chimericmesh/discovery/__init__.py +17 -0
- chimericmesh/discovery/accept.py +131 -0
- chimericmesh/discovery/catalog.py +313 -0
- chimericmesh/discovery/collect.py +131 -0
- chimericmesh/discovery/dismissals.py +46 -0
- chimericmesh/discovery/engine.py +41 -0
- chimericmesh/discovery/errors.py +34 -0
- chimericmesh/discovery/expand.py +151 -0
- chimericmesh/discovery/manager.py +220 -0
- chimericmesh/discovery/match.py +177 -0
- chimericmesh/discovery/models.py +174 -0
- chimericmesh/discovery/parse.py +166 -0
- chimericmesh/discovery/probe.py +69 -0
- chimericmesh/discovery/routes.py +129 -0
- chimericmesh/discovery/runner.py +147 -0
- chimericmesh/discovery/schema.py +25 -0
- chimericmesh/discovery/text.py +53 -0
- chimericmesh/events.py +74 -0
- chimericmesh/fsperms.py +72 -0
- chimericmesh/hub.py +757 -0
- chimericmesh/listeners.py +162 -0
- chimericmesh/mcp_server.py +199 -0
- chimericmesh/mute/__init__.py +10 -0
- chimericmesh/mute/models.py +14 -0
- chimericmesh/mute/mutelist.py +51 -0
- chimericmesh/mute/routes.py +49 -0
- chimericmesh/mute/schema.py +29 -0
- chimericmesh/mute/store.py +94 -0
- chimericmesh/notify.py +47 -0
- chimericmesh/parsers/__init__.py +12 -0
- chimericmesh/parsers/formats.py +23 -0
- chimericmesh/parsers/irc.py +91 -0
- chimericmesh/parsers/logctx.py +143 -0
- chimericmesh/parsers/ncsa.py +57 -0
- chimericmesh/parsers/plain.py +17 -0
- chimericmesh/parsers/syslog.py +82 -0
- chimericmesh/parsers/syslogtext.py +62 -0
- chimericmesh/parsers/telnet.py +56 -0
- chimericmesh/parsers/w3c.py +58 -0
- chimericmesh/parsers/xferlog.py +31 -0
- chimericmesh/replay.py +108 -0
- chimericmesh/replay_irc.py +202 -0
- chimericmesh/services/__init__.py +39 -0
- chimericmesh/services/access.py +224 -0
- chimericmesh/services/asgi.py +107 -0
- chimericmesh/services/deps.py +42 -0
- chimericmesh/services/errors.py +49 -0
- chimericmesh/services/limiter.py +130 -0
- chimericmesh/services/models.py +160 -0
- chimericmesh/services/paths.py +139 -0
- chimericmesh/services/registry.py +638 -0
- chimericmesh/services/routes.py +161 -0
- chimericmesh/services/schema.py +48 -0
- chimericmesh/services/status.py +239 -0
- chimericmesh/services/tagging.py +63 -0
- chimericmesh/services/token.py +129 -0
- chimericmesh/services/validate.py +184 -0
- chimericmesh/store/__init__.py +43 -0
- chimericmesh/store/audit.py +89 -0
- chimericmesh/store/config.py +88 -0
- chimericmesh/store/connection.py +98 -0
- chimericmesh/store/errors.py +65 -0
- chimericmesh/store/events.py +430 -0
- chimericmesh/store/incidents.py +292 -0
- chimericmesh/store/migrations.py +109 -0
- chimericmesh/store/models.py +49 -0
- chimericmesh/store/ports.py +61 -0
- chimericmesh/store/proposals.py +215 -0
- chimericmesh/store/schema.py +102 -0
- chimericmesh/store/store.py +173 -0
- chimericmesh/store/tx.py +143 -0
- chimericmesh/store/writer.py +315 -0
- chimericmesh/web/__init__.py +1 -0
- chimericmesh/web/feed.py +212 -0
- chimericmesh/web/index.html +3775 -0
- chimericmesh/web/sse.py +74 -0
- chimericmesh/web/stream.py +64 -0
- chimericmesh-0.2.2.dist-info/METADATA +537 -0
- chimericmesh-0.2.2.dist-info/RECORD +147 -0
- chimericmesh-0.2.2.dist-info/WHEEL +5 -0
- chimericmesh-0.2.2.dist-info/entry_points.txt +2 -0
- chimericmesh-0.2.2.dist-info/licenses/LICENSE +21 -0
- chimericmesh-0.2.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chimericmesh
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Legacy protocols (Syslog, IRC, Telnet) stitched to AI agents via MCP
|
|
5
|
+
Author-email: Harshit Dhaduk <dhadukharshit@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/HarshitDhaduk/chimericmesh
|
|
8
|
+
Project-URL: Repository, https://github.com/HarshitDhaduk/chimericmesh
|
|
9
|
+
Project-URL: Issues, https://github.com/HarshitDhaduk/chimericmesh/issues
|
|
10
|
+
Keywords: syslog,irc,telnet,mcp,incident,logging,ai-agents,kiro
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: System :: Logging
|
|
22
|
+
Classifier: Topic :: System :: Monitoring
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: fastapi>=0.115
|
|
27
|
+
Requires-Dist: uvicorn>=0.30
|
|
28
|
+
Requires-Dist: httpx>=0.27
|
|
29
|
+
Requires-Dist: pydantic>=2.7
|
|
30
|
+
Requires-Dist: mcp>=2.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
33
|
+
Requires-Dist: hypothesis>=6.100; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# ChimericMesh
|
|
37
|
+
|
|
38
|
+
Kiroween 2026, category: **Frankenstein**.
|
|
39
|
+
|
|
40
|
+
ChimericMesh stitches 1980s infrastructure protocols (Syslog, IRC, Telnet) onto modern AI agent workflows. Legacy systems keep talking the way they always have. Incidents are detected, exposed to Kiro agents through the Model Context Protocol (MCP), and announced back on IRC and via webhooks.
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
Syslog/UDP ─┐
|
|
44
|
+
Telnet/TCP ─┼─> parsers ─> Hub ─> incident detection ─┬─> IRC announce
|
|
45
|
+
IRC/TCP ────┘ └─> webhook
|
|
46
|
+
Kiro agent ── MCP (stdio) ──> REST API ──> Hub
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
### Install
|
|
54
|
+
|
|
55
|
+
Install the `chimericmesh` command with [pipx](https://pipx.pypa.io/), or run it without installing through `uvx` from [uv](https://docs.astral.sh/uv/). Python 3.11 or newer.
|
|
56
|
+
|
|
57
|
+
From GitHub:
|
|
58
|
+
|
|
59
|
+
```powershell
|
|
60
|
+
pipx install git+https://github.com/HarshitDhaduk/chimericmesh
|
|
61
|
+
uvx --from git+https://github.com/HarshitDhaduk/chimericmesh chimericmesh
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
From PyPI:
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
pipx install chimericmesh
|
|
68
|
+
uvx chimericmesh
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Then:
|
|
72
|
+
|
|
73
|
+
```powershell
|
|
74
|
+
chimericmesh # start the hub; dashboard at http://127.0.0.1:8000
|
|
75
|
+
chimericmesh --version
|
|
76
|
+
chimericmesh --help # start | token --rotate | mcp | demo | --version | --help
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`chimericmesh start` is the same as `chimericmesh`. `chimericmesh mcp` runs the MCP server for Kiro (see "MCP for Kiro"). `chimericmesh demo` runs the guided demo on its own, without your hub (see "Try the demo").
|
|
80
|
+
|
|
81
|
+
### Try the demo
|
|
82
|
+
|
|
83
|
+
Open http://127.0.0.1:8000 (the Home page) and press **Try the demo**. Nothing is typed and nothing is installed.
|
|
84
|
+
|
|
85
|
+
- The hub starts a second, throwaway hub on free loopback ports, with an in-memory database and a temporary home folder, plus three sample apps that fail on purpose (`orders-api`, `spooler`, `mail-bridge`). Their errors arrive over Syslog, Telnet and IRC. The first incident appears in about 20 seconds, and a demo agent leaves a fix under Proposals for you to approve or deny.
|
|
86
|
+
- Your hub, its database, its admin token and its ports are not used. The demo hub is started with an allow-listed environment, so `CHIMERICMESH_DB`, the token file and the webhook URL are never passed on. Approving a demo fix changes nothing outside the demo.
|
|
87
|
+
- A banner marks the demo page. A seven-step guided tour (Overview, an incident, Services, Discovery, a proposal, Mute, Exit demo) walks through it. Skip it at any time and bring it back with **Show tour**.
|
|
88
|
+
- There is no time limit. **Exit demo**, Ctrl+C, closing the real hub, or the real hub dying stops the demo hub and the sample apps and deletes the temporary folder. Exit demo returns you to Home with a note that the demo closed.
|
|
89
|
+
- `chimericmesh demo` runs the same demo from a terminal without the real hub. It prints the demo address and stops on Ctrl+C. It does not open a browser.
|
|
90
|
+
|
|
91
|
+
If the demo cannot start (no free ports, a child that exits), Home says why and nothing on your machine is changed.
|
|
92
|
+
|
|
93
|
+

|
|
94
|
+
|
|
95
|
+
### Mute a service
|
|
96
|
+
|
|
97
|
+
**Mute** on a service card, on its page or on the Unassigned card drops that service's incoming events at the hub. Muted events are not stored, do not count in the stats, do not open incidents and are not announced. They are counted, and the card shows how many were dropped. Log-file offsets still advance, so unmuting does not replay what was dropped. Existing incidents are not changed and show a "muted" tag.
|
|
98
|
+
|
|
99
|
+
| Route | Needs the admin token | Does |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `PUT /api/services/{id}/mute` | yes | Mute (also `unassigned`). |
|
|
102
|
+
| `DELETE /api/services/{id}/mute` | no | Unmute. |
|
|
103
|
+
| `GET /api/mutes` | no | The muted keys and the dropped counts. |
|
|
104
|
+
|
|
105
|
+
Mutes are saved in the database and every change goes to the audit log. `/api/ingest` answers a muted event with `id: 0` and `"muted": true`. Muting Unassigned asks for confirmation first.
|
|
106
|
+
|
|
107
|
+
### From a checkout (contributors)
|
|
108
|
+
|
|
109
|
+
```powershell
|
|
110
|
+
pip install -e ".[dev]"
|
|
111
|
+
python -m chimericmesh # same as `chimericmesh`, with the same arguments
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Ports (override with env vars): HTTP 8000, Syslog/UDP 5514, IRC 6667, Telnet 2323. Everything binds to 127.0.0.1 by default (`CHIMERICMESH_BIND`).
|
|
115
|
+
|
|
116
|
+
Try it:
|
|
117
|
+
|
|
118
|
+
- Run `.\scripts\demo.ps1` to send real Syslog, Telnet and IRC traffic (`-Only syslog|telnet|irc` to send one, `-Count 12` to trigger an `UPDATE` line).
|
|
119
|
+
- Click "Summon a failure storm" on the dashboard, or `POST /api/demo/storm`.
|
|
120
|
+
- Join IRC (`/server 127.0.0.1 6667`, `/join #ops`) and watch the bot announce incidents.
|
|
121
|
+
- Send syslog: `<27>Nov 13 11:10:08 db01 kernel: Out of memory: Kill process 4412`
|
|
122
|
+
- Open a Telnet session to port 2323 and type an `ERROR ...` line.
|
|
123
|
+
|
|
124
|
+
The dashboard's **Events seen** tile is a cumulative counter (`total_events` in `/api/stats`, with `total_by_source` and a 10 second `events_per_second`). The hub only keeps the latest 2000 events in memory for the log view (`events`, `buffer_capacity`), so the log header reads "latest N of TOTAL" once the buffer has wrapped.
|
|
125
|
+
|
|
126
|
+
## Data and proposal ids
|
|
127
|
+
|
|
128
|
+
The hub keeps events (bounded), incidents, proposals, an append-only audit log and counters in one local SQLite database, `~/.chimericmesh/chimericmesh.db` by default. The startup log prints its path. Proposal ids are unique per database; deleting the database restarts them at `p1`. Ids look like `p1`, `p2`, `p3` and nothing else.
|
|
129
|
+
|
|
130
|
+
| Variable | Meaning | Default |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
| `CHIMERICMESH_DB` | Database file, or `:memory:` for no file | `<home>/chimericmesh.db` |
|
|
133
|
+
| `CHIMERICMESH_HOME` | Directory for the database | `~/.chimericmesh` |
|
|
134
|
+
| `CHIMERICMESH_MAX_EVENTS` | Most event rows kept (1 to 10,000,000) | 100000 |
|
|
135
|
+
| `CHIMERICMESH_EVENT_TTL_DAYS` | Event rows older than this are removed (1 to 3650) | 7 |
|
|
136
|
+
| `CHIMERICMESH_REOPEN_AFTER_SECONDS` | A resolved incident reopens when a matching event arrives after this many seconds (0 to 86400) | 300 |
|
|
137
|
+
|
|
138
|
+
A bad value logs one warning and uses the default. An explicit relative `CHIMERICMESH_DB` is resolved once against the current directory at startup; the defaults never depend on the current directory, so starting the hub from two folders opens the same file.
|
|
139
|
+
|
|
140
|
+
Things to know:
|
|
141
|
+
|
|
142
|
+
- One database file supports one running hub process. Two processes serving one file are not supported. A start that fails before serving leaves the crash marker untouched.
|
|
143
|
+
- Event ids keep rising across restarts. After a crash a restart skips ahead by a safety margin so clients holding an `after_id` cursor stay valid. After a crash that follows a long storage outage, a restart may reuse event ids a client saw; this is the one known gap.
|
|
144
|
+
- A database written by a newer build is refused at startup and is not modified. Refusing a newer-schema database after a crash may still checkpoint its `-wal` file into the database file; the data is not changed.
|
|
145
|
+
- The audit log can only be appended to. Log text, secrets and URL credentials never reach it.
|
|
146
|
+
- On Windows the owner-only permission step uses `icacls` and is verified by hand; on other systems the directory is `0700` and the file `0600`.
|
|
147
|
+
- The decider name of a proposal is display text. These prefixes are reserved for the hub's own rule logic and never make a decision count as the hub's: `rule:`, `rule-`, `withdrawn:`, `expired:`, `expired-`.
|
|
148
|
+
|
|
149
|
+
## Replaying real logs
|
|
150
|
+
|
|
151
|
+
Besides the hand-written demo traffic, you can stream real public logs into the mesh over UDP syslog:
|
|
152
|
+
|
|
153
|
+
```powershell
|
|
154
|
+
$env:PYTHONPATH = "src"
|
|
155
|
+
python -m chimericmesh.replay --dataset openssh --rate 200 # real SSH brute-force traffic
|
|
156
|
+
python -m chimericmesh.replay --dataset linux # real /var/log/messages
|
|
157
|
+
python -m chimericmesh.replay --file my.log --limit 500 # your own file
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Samples are downloaded on first use into `data/` (git-ignored, never committed). Lines are sent exactly as they appear in the file, with no `<PRI>` header, so the parser infers severity from the text.
|
|
161
|
+
|
|
162
|
+
**Data credit:** [Loghub](https://github.com/logpai/loghub) by the logpai group. The datasets are free for research and academic use; please cite Zhu et al., "Loghub: A Large Collection of System Log Datasets for AI-driven Log Analytics", ISSRE 2023. Replayed data is real but is not a live production system.
|
|
163
|
+
|
|
164
|
+
What replaying real data taught us (each now has a regression test): real logs often have no `<PRI>` header, one attacker produces hundreds of near-identical lines that differ only in user and address, one-off errors are noise, and re-analyzing history on every event drops UDP packets. Incidents are now tracked incrementally and the syslog socket has a 4 MB receive buffer.
|
|
165
|
+
|
|
166
|
+
### Replaying real IRC chat
|
|
167
|
+
|
|
168
|
+
```powershell
|
|
169
|
+
$env:PYTHONPATH = "src"
|
|
170
|
+
python -m chimericmesh.replay_irc --dataset ubuntu-server --rate 100
|
|
171
|
+
python -m chimericmesh.replay_irc --file chat.txt --channel "#ops" --limit 200 # "[HH:MM] <nick> text" format
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This replays a real Ubuntu support channel through the mesh's IRC server, with one connection per speaker. The logs come from [irclogs.ubuntu.com](https://irclogs.ubuntu.com/); the Common Pile dataset card describes them as released into the public domain. Nicknames belong to real people, so they are replaced with pseudonyms by default (`--no-mask` disables this). The file is downloaded on first use into `data/` and never committed.
|
|
175
|
+
|
|
176
|
+
Things the real chat taught us: a chat line is evidence, not proof, so IRC text is capped at error severity and a single message about the OOM killer can no longer open an incident, and the IRC server now ignores any sender prefix a client supplies and uses the registered nickname. Clients must register (`NICK`) before their messages are ingested.
|
|
177
|
+
|
|
178
|
+
## Log files and TCP syslog
|
|
179
|
+
|
|
180
|
+
Servers that only write log files (Apache, nginx, IIS, vsftpd, Postfix) are read in place; nothing wraps or launches them. Register a file on a service with `POST /api/services/{id}/log-sources` and a body like `{"path": "C:\\inetpub\\logs\\u_ex.log", "format": "w3c"}`. The formats are `syslog-text`, `ncsa` (Apache and nginx access logs), `w3c` (IIS), `xferlog` (FTP) and `plain`. `GET /api/services/{id}` shows each source's status and counters.
|
|
181
|
+
|
|
182
|
+
- The hub opens the file for a moment on each poll and never holds it open, so rotation by rename works on Windows too. A rename that lands inside a read can fail with WinError 32; the rotating program should retry after a short wait. Measured on a Windows 11 machine while the file was being appended to, 1.5 to 3 percent of renames needed one retry; on an idle file none did.
|
|
183
|
+
- Lines written in the last half second before a rename or truncation can be lost, and so can a line without its newline at that moment.
|
|
184
|
+
- Read positions are saved every 5 seconds. After a crash the hub can repeat up to 5 seconds of lines, and can lose a few hundred milliseconds of events that the store had not yet written. A graceful stop saves the final position.
|
|
185
|
+
- A source that is disabled and enabled again starts at the end of the file. A new source starts at the end too, unless `backfill_lines` asks for recent lines.
|
|
186
|
+
- Event times are the arrival time at the hub, not the time written in the line.
|
|
187
|
+
- Limits: 2000 lines per second per source (extra lines are counted as dropped and summarised in one warning event), 8192 bytes per line, 1 MiB per poll.
|
|
188
|
+
- The path is fixed. Date-named files such as IIS `u_exYYMMDD.log` need a new path each day.
|
|
189
|
+
- Secrets in query strings and in `password=`, `token=` and `Authorization:` values are replaced by `<redacted>`. This is a best effort, not a guarantee.
|
|
190
|
+
|
|
191
|
+
Syslog over TCP (octet-counted or newline-framed) listens on `CHIMERICMESH_SYSLOG_TCP_PORT`, which defaults to 5514 (the UDP port number, on its own socket); `0` disables it. A busy port logs one warning and the hub starts anyway.
|
|
192
|
+
|
|
193
|
+
## Discovery
|
|
194
|
+
|
|
195
|
+
Discovery is an opt-in scan of the local machine that suggests services for well-known legacy servers (Apache, nginx, IIS, vsftpd, ProFTPD, FileZilla Server, Sendmail, Postfix, Exim, BIND, Samba, Squid, inetd and telnetd, syslog daemons, snmpd). It never runs on its own: no scan at startup, on a timer or as a side effect. Nothing is watched until you accept a suggestion.
|
|
196
|
+
|
|
197
|
+
Every route needs the admin token (`X-Admin-Token`), including reading the results, because a scan lists the software installed on the machine:
|
|
198
|
+
|
|
199
|
+
| Route | Does |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `POST /api/discovery/scan` | Start one scan. `202 {"scan_id", "state": "running"}`; `409` while a scan runs; `503` when the catalog could not be loaded. |
|
|
202
|
+
| `GET /api/discovery/scans/{id}` | `state` (`running`, `done`, `failed`), `started_at`, `finished_at`, `limited`, `os`, `reason` and the suggestions. Results are kept in memory for one hour (at most 5 scans). |
|
|
203
|
+
| `POST /api/discovery/suggestions/{id}/accept` | Body `{"id", "name", "log_paths": [{"path", "format"}], "code_folder"?, "app_names"?}`. Creates the service and its log sources in one step (`origin: discovery`), or `422` with a `field` and nothing created. |
|
|
204
|
+
| `POST /api/discovery/suggestions/{id}/dismiss` | Do not offer this app with these paths again. |
|
|
205
|
+
| `GET /api/discovery/dismissals` | List dismissals. |
|
|
206
|
+
| `DELETE /api/discovery/dismissals` | Clear all dismissals; the apps are offered again on the next scan. |
|
|
207
|
+
|
|
208
|
+
```powershell
|
|
209
|
+
$h = @{ "X-Admin-Token" = (Get-Content "$env:USERPROFILE\.chimericmesh\admin.token") }
|
|
210
|
+
$scan = Invoke-RestMethod -Method Post -Headers $h http://127.0.0.1:8000/api/discovery/scan
|
|
211
|
+
Invoke-RestMethod -Headers $h "http://127.0.0.1:8000/api/discovery/scans/$($scan.scan_id)"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
What a scan does: it runs the operating system's own tools with a fixed argument list, never through a shell, from their system directory (never the current folder or `PATH`), each with a 10 second timeout and 2 MB of output, 30 seconds in total. On Windows `tasklist /fo csv /nh` and `netstat -ano`; on Linux the names in `/proc/<pid>/comm` and `ss -ltnup` (or `netstat -ltnup` when `ss` fails); on macOS `ps -axo pid=,comm=` and `lsof -nP -iTCP -sTCP:LISTEN -iUDP`. It matches process names (and, for protocol-specific ports such as 21, 23 and 25, listening ports) against `src/chimericmesh/catalog/legacy_apps.json`, then looks at each candidate log path with `stat` only. It never reads log contents, never reads command lines, makes no network connection and keeps no process list: a suggestion holds only the matched process name, the lowest pid, the number of matching processes and the listening ports. It runs with your normal rights and never asks for elevation. When some details were not visible (a tool failed or timed out, output was cut, another user's processes are hidden, a candidate list was cut at 25 paths), the result says `limited: true` and gives a `reason`.
|
|
215
|
+
|
|
216
|
+
Discovery cannot be started by an agent: there is no MCP tool for it, and the results are not exposed to MCP. The dashboard's discovery screen (when built) uses the same routes; you can always add a path by hand with `POST /api/services/{id}/log-sources`.
|
|
217
|
+
|
|
218
|
+
Limits to know:
|
|
219
|
+
|
|
220
|
+
- Accept stores the files that exist at accept time, not the pattern. A rotating log needs its new file added by hand; patterns are not stored. This matters for daily files such as IIS `u_exYYMMDD.log` and FileZilla Server logs.
|
|
221
|
+
- IIS may not appear: its worker `w3wp` starts only after the first request to a site, and port 80 alone is not evidence of IIS. Make one request to the site, then scan again, or add the IIS log path by hand.
|
|
222
|
+
- Discovery never guesses a code folder. Suggestions contain no `code_folder`; you may type one at accept time, and the services rules refuse a home directory, a drive root or the hub's data directory.
|
|
223
|
+
- The demo `examples/legacy_app` is not in the catalog on purpose. Add it by hand as a service to show the manual path.
|
|
224
|
+
- To add or change an app, edit `catalog/legacy_apps.json` (it is validated at startup; an invalid file disables discovery and nothing else). If the `w3c` or `xferlog` format is ever dropped, change those entries to `plain` in the same change.
|
|
225
|
+
|
|
226
|
+
Manual checks (not automated):
|
|
227
|
+
|
|
228
|
+
1. Verify the catalog paths against vendor documentation or a sample machine for each of the 15 entries.
|
|
229
|
+
2. On the Windows development machine, scan with a real IIS or Apache if present, otherwise with the demo `legacy_app` running (it is not suggested and is added by hand; `examples/legacy_app/upstream.py` is not changed by discovery). Check that the suggestions and the `limited` flag are sensible.
|
|
230
|
+
3. Run once as a non-admin user on Linux and check `limited: true`.
|
|
231
|
+
4. Rehearse the demo with nginx or Apache: scan, accept, append an error line, watch the incident.
|
|
232
|
+
5. On a Windows machine with IIS, scan once before and once after the first request to the site: `iis` should appear only after `w3wp` runs.
|
|
233
|
+
6. Capture real output of `ss -ltnup`, `netstat -ltnup`, `lsof` and `netstat -ano` on a non-English Windows and add them as parser fixtures.
|
|
234
|
+
|
|
235
|
+
## MCP for Kiro
|
|
236
|
+
Installing the package does not change any Kiro settings. You add the MCP server yourself, in three steps.
|
|
237
|
+
### 1. Install
|
|
238
|
+
`pipx install chimericmesh`, or nothing at all if you use `uvx` (needs [uv](https://docs.astral.sh/uv/)). See "Install" above for the GitHub routes.
|
|
239
|
+
### 2. Start the hub
|
|
240
|
+
```powershell
|
|
241
|
+
chimericmesh
|
|
242
|
+
```
|
|
243
|
+
The dashboard is at http://127.0.0.1:8000. The MCP server only talks to this hub, so keep it running.
|
|
244
|
+
### 3. Add the MCP server named `chimericmesh`
|
|
245
|
+
Add one of these blocks to `~/.kiro/settings/mcp.json` (all your workspaces) or to `.kiro/settings/mcp.json` in a workspace. The server name must be exactly `chimericmesh`, because the agents and the power below refer to it by that name.
|
|
246
|
+
|
|
247
|
+
Installed with pipx:
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"mcpServers": {
|
|
251
|
+
"chimericmesh": {
|
|
252
|
+
"command": "chimericmesh",
|
|
253
|
+
"args": ["mcp"],
|
|
254
|
+
"env": { "CHIMERICMESH_URL": "http://127.0.0.1:8000" }
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
Or without installing, through `uvx` (from PyPI; put `"--from", "git+https://github.com/HarshitDhaduk/chimericmesh"` before `"chimericmesh"` to run it from GitHub):
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"mcpServers": {
|
|
263
|
+
"chimericmesh": {
|
|
264
|
+
"command": "uvx",
|
|
265
|
+
"args": ["chimericmesh", "mcp"],
|
|
266
|
+
"env": { "CHIMERICMESH_URL": "http://127.0.0.1:8000" }
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
From a checkout (contributors; this is what the repository's own `.kiro/settings/mcp.json` has, run with the repository root as the working directory):
|
|
272
|
+
```json
|
|
273
|
+
{
|
|
274
|
+
"mcpServers": {
|
|
275
|
+
"chimericmesh": {
|
|
276
|
+
"command": "python",
|
|
277
|
+
"args": ["-m", "chimericmesh.mcp_server"],
|
|
278
|
+
"env": { "PYTHONPATH": "src", "CHIMERICMESH_URL": "http://127.0.0.1:8000" }
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
Tools (17): `list_incidents`, `get_incident`, `find_code_for_incident`, `recent_events`, `announce_to_irc`, `resolve_incident`, `propose_remediation`, `get_proposal`, `list_proposals`, `complete_proposal`, `list_services`, `get_service`, `service_events`, `explain_log_window`, `find_code_for_service`, `verify_proposal`, `wait_for_work`.
|
|
284
|
+
Optional: set `CHIMERICMESH_WEBHOOK_URL` for webhooks and `CHIMERICMESH_CODE_ROOT` for code lookups.
|
|
285
|
+
## How incidents behave
|
|
286
|
+
|
|
287
|
+
- **Hosts:** Syslog carries a host field. For IRC and Telnet, a leading `hostname:` in the message (for example `web02: upstream timed out` or `ALERT sw-core-1: Failed password`) sets the host. Otherwise the IRC nick or the Telnet peer address is used.
|
|
288
|
+
- **Opening:** an incident is announced on IRC (and by webhook) once it has 3 events, or immediately at crit severity or worse.
|
|
289
|
+
- **Updates:** follow-up `UPDATE` lines go out when the count passes 10, 50, 100 and 500, so channels do not get flooded.
|
|
290
|
+
- **Code lookup:** searches `examples/legacy_app/` by default, a small sample app whose log lines match the demo storm. Point `CHIMERICMESH_CODE_ROOT` at your own source tree to use it for real.
|
|
291
|
+
|
|
292
|
+
## Screenshots
|
|
293
|
+
|
|
294
|
+
Captured from the running app in headless Edge.
|
|
295
|
+
|
|
296
|
+

|
|
297
|
+

|
|
298
|
+

|
|
299
|
+
|
|
300
|
+
## Tests
|
|
301
|
+
|
|
302
|
+
```powershell
|
|
303
|
+
python -m pytest -q
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Includes Hypothesis property tests for parser totality, IRC injection safety, and chunking.
|
|
307
|
+
|
|
308
|
+
## Kiro usage
|
|
309
|
+
|
|
310
|
+
The full write-up, with commit evidence for each claim, is in [`docs/kiro-usage.md`](https://github.com/HarshitDhaduk/chimericmesh/blob/main/docs/kiro-usage.md). Exported Kiro IDE sessions of the live agent runs are in [`docs/kiro-sessions/`](https://github.com/HarshitDhaduk/chimericmesh/tree/main/docs/kiro-sessions).
|
|
311
|
+
|
|
312
|
+
- Specs: `.kiro/specs/legacy-mesh/` (baseline) and seven V1 module specs in `.kiro/specs/<module>/` (requirements, design with correctness properties, tasks); the plan is in `docs/v1-capability-map.md`
|
|
313
|
+
- Steering: `.kiro/steering/`
|
|
314
|
+
- Hooks: `.kiro/hooks/` (smoke tests on save, about 40 seconds, not the full suite; innerHTML guard), plus the opt-in `.kiro/hooks-optional/mesh-verify-write`
|
|
315
|
+
- MCP: `src/chimericmesh/mcp_server.py`
|
|
316
|
+
- Custom agents: `.kiro/agents/mesh-responder.json` (on demand) and `.kiro/agents/mesh-watcher.json` (watch mode); both run in Kiro IDE and Kiro CLI
|
|
317
|
+
- Power: `powers/chimericmesh-remediation/`
|
|
318
|
+
|
|
319
|
+
## Kiro agent and power
|
|
320
|
+
Both are optional and need the MCP server from "MCP for Kiro" (named `chimericmesh`). Installing the package does not copy or enable them.
|
|
321
|
+
### 4. Optional: the custom agents
|
|
322
|
+
**`mesh-responder`** (`.kiro/agents/mesh-responder.json`) runs the human-approved remediation loop on demand. **`mesh-watcher`** (`.kiro/agents/mesh-watcher.json`) is the watch-mode profile (see "Agent watch mode"). Neither defines an MCP server itself: they set `includeMcpJson` to `true` and use the `chimericmesh` server from your `mcp.json`. They list `file://.kiro/steering/project.md` under `resources`, which is a ChimericMesh steering file; outside this repository, delete that line from your copy or add your own steering file. They auto-allow only the read-only MCP tools (`mesh-watcher` also the watch and proposal tools; the hub holds its approval gate), and keep the permission rules of the repository versions.
|
|
323
|
+
|
|
324
|
+
Copy the files into your workspace's `.kiro/agents/` folder (create it first). Raw URLs:
|
|
325
|
+
- https://raw.githubusercontent.com/HarshitDhaduk/chimericmesh/main/.kiro/agents/mesh-responder.json
|
|
326
|
+
- https://raw.githubusercontent.com/HarshitDhaduk/chimericmesh/main/.kiro/agents/mesh-watcher.json
|
|
327
|
+
|
|
328
|
+
```powershell
|
|
329
|
+
New-Item -ItemType Directory -Force .kiro\agents | Out-Null
|
|
330
|
+
Invoke-WebRequest https://raw.githubusercontent.com/HarshitDhaduk/chimericmesh/main/.kiro/agents/mesh-responder.json -OutFile .kiro\agents\mesh-responder.json
|
|
331
|
+
Invoke-WebRequest https://raw.githubusercontent.com/HarshitDhaduk/chimericmesh/main/.kiro/agents/mesh-watcher.json -OutFile .kiro\agents\mesh-watcher.json
|
|
332
|
+
```
|
|
333
|
+
Trust the workspace, start the hub, then select the agent with the agent picker in Kiro IDE or `/agent` in Kiro CLI. In a checkout the agents are already in place and use the repository's own `.kiro/settings/mcp.json`.
|
|
334
|
+
### 5. Optional: the power
|
|
335
|
+
**Power `chimericmesh-remediation`** (`powers/chimericmesh-remediation/`) uses the Agent Plugins layout: `plugin.json`, `mcp.json` and `skills/` (`getting-started`, `remediation-loop`, `triage`, `watch-mode`). Its `mcp.json` starts the server with `uvx chimericmesh mcp`, so it needs `uv` on your PATH. Kiro prefixes the power's server name on install, so it does not replace the `chimericmesh` server from step 3; the agents above use the one from `mcp.json`.
|
|
336
|
+
- From GitHub: open the Powers panel, choose Add Custom Power, then Import power from a repository URL, and enter https://github.com/HarshitDhaduk/chimericmesh/tree/main/powers/chimericmesh-remediation
|
|
337
|
+
- From a checkout: Add Custom Power, then Import power from a folder, and select `powers/chimericmesh-remediation`.
|
|
338
|
+
|
|
339
|
+
Kiro CLI installs powers only from a catalog name or a local folder.
|
|
340
|
+
|
|
341
|
+
`tests/unit/test_kiro_assets.py` checks the agents and the power statically (JSON validity, tool names against the MCP server, consistency with `.kiro/settings/mcp.json`). It does not show that Kiro loads them.
|
|
342
|
+
- PBT: `tests/pbt/`
|
|
343
|
+
|
|
344
|
+
## Agent watch mode
|
|
345
|
+
|
|
346
|
+
The custom agent **`mesh-watcher`** (`.kiro/agents/mesh-watcher.json`) keeps one Kiro session running as a watcher. It loops on `wait_for_work`, investigates an incident with the read-only tools, sends one `propose_remediation` per incident with `files` (absolute paths inside the service's code folder), `estimated_lines` and `verification`, and edits code only after the hub reports the proposal as approved and `verify_proposal` answers `ok`. Ids are `p1`, `p2` and so on. The power skill `watch-mode` carries the same loop. Like `mesh-responder`, it takes the `chimericmesh` server from `mcp.json` (`includeMcpJson`); see "Kiro agent and power" for installing it outside this repository.
|
|
347
|
+
|
|
348
|
+
Setup: trust the workspace in Kiro (an untrusted workspace does not load the profile or its MCP server), start the hub (`chimericmesh`, or `python -m chimericmesh` from a checkout), register a service with a code folder, and select `mesh-watcher`. Tools added for the loop: `list_services`, `get_service`, `service_events`, `explain_log_window`, `find_code_for_service`, `verify_proposal` and `wait_for_work`. They only read; none takes the admin token.
|
|
349
|
+
|
|
350
|
+
**Workspace root.** The hub finds the workspace root by walking up from its working directory to the nearest folder that has `.kiro/`; set `CHIMERICMESH_WORKSPACE_ROOT` (an existing absolute directory) to override it. The permissions snippet uses it to write workspace-relative paths. `files` in `verify_proposal` (and in the hook) are absolute paths; a relative path fails verify. `files` in `propose_remediation` are written relative to the service's code folder, as the proposal check of the standing rules requires.
|
|
351
|
+
|
|
352
|
+
### Prompt mode (default) and autonomous mode
|
|
353
|
+
|
|
354
|
+
**Prompt mode (default).** No snippet is pasted. The mesh tools run without a Kiro prompt, but every file edit and every shell command asks you. The approval gate is the hub: you approve a proposal with `!approve <id>` (or the dashboard terminal) and the agent edits only after `get_proposal` and `verify_proposal` agree.
|
|
355
|
+
|
|
356
|
+
**Autonomous (hands-off) mode.** Paste the snippet from `GET /api/services/<id>/permissions-snippet` (optional `?test_command=...`) into a Kiro `permissions.yaml`. It allows `fs_write` inside the service's code folder, denies writes to protected names (`.env`, keys, `.git`, `.kiro`, `.github`) and has one commented line for a single test command. Nothing writes the file for you; the hub only returns text. Prefer the workspace-scoped file (`~/.kiro/workspace-roots/<hash>/permissions.yaml`, the hash is looked up on your machine). The user-scoped `~/.kiro/settings/permissions.yaml` applies to every session and agent of this user, not only `mesh-watcher`, so use it only on purpose. Hands-off write allows use workspace-relative globs only. Permission rules are static: if the service's code folder changes, the old allow no longer matches and Kiro prompts again until you paste a new snippet.
|
|
357
|
+
|
|
358
|
+
The snippet is a standing allow. It also applies while a proposal is still `pending`, so in this mode the gate rests on the agent following its prompt, on `verify_proposal` and on the audit trail, not on a Kiro prompt. That the agent cannot approve its own proposal or widen the rules is a design goal with the limits stated below, not a guarantee.
|
|
359
|
+
|
|
360
|
+
**Hands-off test-command risk (accepted for hands-off mode only).** The one allowed test command in autonomous mode runs code the agent has just written, with your privileges. That code could read the admin token file or call the hub. You accepted this risk for hands-off mode; prompt mode stays the default and has no such command. Pause, revoke and withdraw need no token and can only reduce the agent's permissions; create, widen, re-enable and resume need the token.
|
|
361
|
+
|
|
362
|
+
### Waiting and timeouts
|
|
363
|
+
|
|
364
|
+
`wait_for_work` holds the request for 25 seconds at most (the hard ceiling; `CHIMERICMESH_WATCH_MAX_WAIT` can only lower it) and then returns `status: "timeout"`. The MCP server's own client timeout is 35 seconds, and Kiro's default `requestTimeout` is 120000 ms (the profile no longer sets it).
|
|
365
|
+
|
|
366
|
+
Live check, 2026-11-23, Kiro IDE with `mesh-watcher`: one call with the default returned `timeout` after the full wait, with no tool error. No fallback was needed. Which file the IDE reads `requestTimeout` from was **not** checked. The profile no longer carries a server, so it can only be set as `mcpServers.chimericmesh.requestTimeout` in your `.kiro/settings/mcp.json` (or `~/.kiro/settings/mcp.json`); add it there yourself if the call ever fails with an IDE timeout. As a fallback, set `CHIMERICMESH_WATCH_MAX_WAIT` (for example `10`) in the environment of the hub process, the terminal that runs `python -m chimericmesh`, and restart the hub. Only the hub reads it; an entry in the profile's `env` changes nothing.
|
|
367
|
+
|
|
368
|
+
### Optional enforcement hook
|
|
369
|
+
|
|
370
|
+
`.kiro/hooks-optional/` holds `mesh-verify-write.json` and `mesh_verify_write.py`. To opt in, copy both files into `.kiro/hooks/`; to remove it, delete both copies. While it is installed, every write needs an active proposal: the agent writes the proposal id (for example `p4`) to `.chimericmesh-active-proposal` in the workspace root, and the hook asks the hub's verify route about the target file and blocks (exit 2) when the answer is not `ok`, when the state file is missing or bad, or when the hub cannot be reached. The hook sends no token, talks to loopback only, and exits 0 (no block) when its input cannot be parsed. It covers `fs_write`, `fs_append` and `str_replace` only; it does not see shell commands. The state file is written by the agent, so an injected agent can name another approved proposal; verify then still limits the write to that proposal's declared files and folder. The snippet has a commented allow for that one state file. The hook files are not installed by default, and `.kiro/hooks/` is unchanged.
|
|
371
|
+
|
|
372
|
+
### Limits
|
|
373
|
+
|
|
374
|
+
- The agent runs as the same OS user as the hub. With a shell command allowed it could read the token file and call the REST API, including the token-free pause, revoke and withdraw routes. Kiro's own prompt on shell commands is the real gate for that.
|
|
375
|
+
- The `~/.chimericmesh/**` and token deny globs in the profile are **check live** items: confirm in the IDE that they match. If they do not, what remains is the name-based denies and Kiro's read prompt; the hook covers writes only.
|
|
376
|
+
- The `PermissionRequest` hook trigger is not part of V1.
|
|
377
|
+
- `verify_proposal` refuses `.env`-type and other protected names inside the code folder for a user approval without declared files, but it cannot see edits made through a shell command.
|
|
378
|
+
- In an in-memory (bare) hub the proposals list keeps the latest 200, so a user-denied proposal that falls off it makes its incident show up as work again. With the store, every proposal is kept.
|
|
379
|
+
- Code search and digests read only the service's code folder and its log text, and treat all log text as untrusted.
|
|
380
|
+
- **Demo precondition.** Restore the defect in `examples/legacy_app/upstream.py` yourself before the demo, for example with `git checkout -- examples/legacy_app/upstream.py`. Nothing in this module runs that command. The demo test `examples/legacy_app/tests/test_resilience.py::test_long_outage_keeps_running_with_bounded_positive_delays` fails by design until the upstream client has a bounded backoff; the root `python -m pytest -q` does not collect it.
|
|
381
|
+
## Standing approval rules
|
|
382
|
+
|
|
383
|
+
A standing rule lets the hub approve a fix without asking each time. The hub decides, never the agent: the agent has no tool to create, edit, widen or resume a rule, and "approved by a rule" is read from the `approved_by_rule` column of the proposal, never from the decider text.
|
|
384
|
+
|
|
385
|
+
**What a rule covers.** One service (it must have a code folder), plus either one incident signature or one category (`memory`, `disk`, `network`, `security`, `crash`, `unknown`), and a most-urgent severity (3 or 4; severity 0 to 2 is never covered). A proposal is approved by the rule only when every condition holds: the hub is not paused, the rule is active and not expired, the proposal says `kind` `code_change`, the incident belongs to the rule's service and matches, the hourly and per-incident limits have room, it declares 1 to `max_files` files that all lie inside the service's code folder with a source-file extension (no `.git`, `.kiro`, `.github`, `.env`, keys; no `.json`, `.yaml`, `.ini`, `.conf`, `.toml`), declares `estimated_lines` up to `max_lines`, names a `verification`, and the service's code folder is still the one the rule was made for.
|
|
386
|
+
|
|
387
|
+
**Limits (hub-side).** At most 10 proposals per service per hour (all proposals, not only rule approvals), `max_per_hour` 1 to 10 (default 3), `max_per_incident` 1 to 3 (default 1) per opening of an incident, `max_files` 1 to 20 (default 5), `max_lines` 1 to 500 (default 100), expiry at most 30 days (default 7). One rule approval is valid for 30 minutes; after that it is denied by the hub (`rule-expired:<id>`). A pending proposal older than `CHIMERICMESH_PROPOSAL_TTL_HOURS` (default 24) is denied (`expired:ttl`). 20 rules per service and 100 in total.
|
|
388
|
+
|
|
389
|
+
**Cooldown.** If an incident reopens within `CHIMERICMESH_AUTOFIX_COOLDOWN_SECONDS` (default 86400, 0 to 2592000) of an auto-fixed proposal being completed, the next proposal for it needs your approval. The hub announces it with the normal `PROPOSAL ... reply !approve` line plus a note and writes an `autofix_cooldown` audit row. The reopen time is the moment the hub first saw the new opening, which may be up to 60 seconds late.
|
|
390
|
+
|
|
391
|
+
**Creating a rule.** Approve a proposal as usual, let the fix pass its verification, then `GET /api/proposals/<id>/rule-defaults` shows the suggested rule and `POST /api/proposals/<id>/rule` (admin token, optional overrides in the body) creates it. `POST /api/rules` creates one directly. Create, widen (`PATCH /api/rules/<id>`), re-enable (`POST /api/rules/<id>/enable`) and resume (`POST /api/rules/resume`) need the token. Only a proposal approved by a person and completed with `verification_result` `passed` can seed a rule.
|
|
392
|
+
|
|
393
|
+
**Emergency stop, no token.** Pause, revoke and withdraw need no token, are never refused, are rate limited in the audit trail (ten rows a minute per caller, then one coalesced row) and are announced: `!rules`, `!revoke <rule id>`, `!pause` and `!withdraw <proposal id>` on IRC or the dashboard terminal for any registered nick, and `POST /api/rules/<id>/revoke`, `POST /api/rules/<id>/pause`, `POST /api/rules/pause`, `POST /api/proposals/<id>/withdraw` over REST. Revoking or suspending a rule denies its approved proposals at once (`rule-revoked:<id>`, `rule-suspended:<id>`). Changing or removing a service's code folder, or deleting the service, suspends its rules the same way. `!pause` stops all auto-approval without changing any rule; only `POST /api/rules/resume` (token) ends it. Every automatic decision is announced as `AUTO-APPROVED p3 by rule r1 (service api-gw): <action>. Revoke with !revoke r1` (nobody has to reply) and written to the audit log (`GET /api/audit`).
|
|
394
|
+
|
|
395
|
+
**Completion check.** When a rule-approved fix is completed with `files_changed`, `lines_changed` or `verification_result`, the hub compares them with the rule. A file outside the code folder or on the protected list, too many files, too many lines or a failed verification completes the proposal but suspends the rule (`rule_suspended` row, one announcement). A completion without details is recorded as unverified and leaves the rule active.
|
|
396
|
+
|
|
397
|
+
**Reserved decider names.** The prefixes `rule:`, `rule-`, `withdrawn:`, `expired:` and `expired-` (any case) are used only by the hub's own rule logic. They are refused as the `by` of `POST /api/proposals/<id>/decide` and as IRC nicks.
|
|
398
|
+
|
|
399
|
+
**Honest limits.** The hub checks the files a proposal and a completion declare; the hub does not stop file writes outside the code folder, because it never executes anything. The agent runs as the same OS user as the hub and could read the token file, so Kiro's shell permission prompt is the real gate for that. In short: pause, revoke and withdraw need no token; create, widen, re-enable and resume need the token.
|
|
400
|
+
|
|
401
|
+
## Security notes
|
|
402
|
+
|
|
403
|
+
Intended for localhost. Changes that widen what can happen (approving, denying, editing services) need the admin token; see "Access control". Log text is rendered as text only, and outbound IRC is stripped of control characters.
|
|
404
|
+
|
|
405
|
+
## Access control
|
|
406
|
+
|
|
407
|
+
`python -m chimericmesh` turns access enforcement on. A test or embedding that passes its own hub to `create_app` gets it off unless it asks for `enforce_access=True`.
|
|
408
|
+
|
|
409
|
+
- **Admin token.** A random token lives in `~/.chimericmesh/admin.token` (owner-only permissions). Set `CHIMERICMESH_TOKEN_FILE` to use another path. The path is chosen in this order: `CHIMERICMESH_TOKEN_FILE` if set, else `admin.token` inside `CHIMERICMESH_HOME` if set, else `~/.chimericmesh/admin.token`. `~` means the home of the account that runs the hub (`USERPROFILE` on Windows, `HOME` elsewhere), not the browser user's. The dashboard's Unlock box shows that exact absolute path, so read the file on the machine where the hub runs. The startup log prints the file's path, never the token. `python -m chimericmesh token --rotate` writes a new token and prints only the path. A running hub keeps its old token, and the new one takes effect at the next hub start. With `CHIMERICMESH_DB=:memory:` the token exists only in memory and no file is written.
|
|
410
|
+
- **What needs the token.** Creating, editing or deleting services and log sources (`/api/services...`), `POST /api/proposals/{id}/decide`, and `!approve` / `!deny` in the dashboard terminal. Clients send it in the `X-Admin-Token` header. Reads, ingest, creating or completing proposals, `!resolve` and the demo routes need no token.
|
|
411
|
+
- **Reducing operations are open.** Pause, revoke and withdraw need no token and are open to any local caller, including the agent from a shell. The cost is that a local process can stop auto-approvals or withdraw proposals: an annoyance, not escalation. Resume and every other rule change need the user.
|
|
412
|
+
- **Honest limit.** The token keeps out web pages and local processes that cannot read your files. It does not stop the agent, which runs as you and can read the token file. Kiro's shell prompt is the real gate for what the agent does.
|
|
413
|
+
- **Host check.** Requests to `/api/*` must carry a `Host` of `127.0.0.1`, `localhost` or `[::1]` (any port), which blocks DNS rebinding. `CHIMERICMESH_ALLOWED_HOSTS` (comma-separated) replaces that list. `CHIMERICMESH_BIND` sets the listen address; a non-loopback value logs a warning, because the dashboard is then reachable from other machines.
|
|
414
|
+
- **IRC operators.** `CHIMERICMESH_OPERATORS` lists the nicks that may use `!approve`, `!deny` and `!resolve`. With enforcement on, an IRC client must also set the server password to the admin token (`PASS`, for example `/server 127.0.0.1 6667 <token>`). The bundled `scripts/irc_client.py` does this with `--password <token>` or `--token-file` (reads the admin token file; honours `CHIMERICMESH_HOME` and `CHIMERICMESH_TOKEN_FILE`) and never prints the secret. If `CHIMERICMESH_OPERATORS` is unset, operator commands are refused on IRC. The nicks `dashboard` and `ChimericBot` are reserved.
|
|
415
|
+
- **Services and incidents.** Two services behind one sender host that log the same error signature share an incident; it belongs to the service of its first tagged event.
|
|
416
|
+
|
|
417
|
+
## License
|
|
418
|
+
|
|
419
|
+
MIT
|
|
420
|
+
|
|
421
|
+
## Talking to the mesh over IRC
|
|
422
|
+
|
|
423
|
+
IRC is a two-way operator interface. Registered clients can send commands (messages starting with `!`) in a channel the bot is in. Commands are never ingested as log events. Replies are posted to the channel, prefixed `[mesh]`.
|
|
424
|
+
|
|
425
|
+
| Command | Who | What it does |
|
|
426
|
+
| --- | --- | --- |
|
|
427
|
+
| `!help` | anyone | List commands |
|
|
428
|
+
| `!status` | anyone | Events seen, open incidents, pending proposals |
|
|
429
|
+
| `!incidents` | anyone | Up to 5 open incidents: `id category host xCOUNT severity` |
|
|
430
|
+
| `!explain <id>` | anyone | Hypothesis and up to 4 remediation steps |
|
|
431
|
+
| `!proposals` | anyone | Pending remediation proposals |
|
|
432
|
+
| `!resolve <id> [note]` | operator | Resolve an incident |
|
|
433
|
+
| `!approve <pid>` / `!deny <pid>` | operator | Decide a proposal |
|
|
434
|
+
|
|
435
|
+
Operators are set with `CHIMERICMESH_OPERATORS` (comma-separated nicks, case-insensitive) and, with enforcement on (the default for `python -m chimericmesh`), must also send the admin token as the server password; if it is unset or empty, operator commands are refused. Only with enforcement off (an injected hub, as in tests) does an unset list mean any registered nick counts as an operator. See "Access control".
|
|
436
|
+
|
|
437
|
+
### Human-approved remediation loop
|
|
438
|
+
|
|
439
|
+
```
|
|
440
|
+
agent (MCP) ChimericMesh / IRC #ops human
|
|
441
|
+
----------- ---------------------- -----
|
|
442
|
+
list_incidents, get_incident, find_code_for_incident
|
|
443
|
+
propose_remediation ----> "PROPOSAL p1 for <id> ... " ----> reads it
|
|
444
|
+
get_proposal (poll) <---- status: pending !approve p1 (or !deny p1)
|
|
445
|
+
get_proposal <---- status: approved <-----------------
|
|
446
|
+
(agent does the work itself)
|
|
447
|
+
complete_proposal ----> "p1 DONE: <note>"
|
|
448
|
+
resolve_incident ----> "RESOLVED <id> ..."
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
REST: `GET/POST /api/proposals`, `GET /api/proposals/{pid}`, `POST /api/proposals/{pid}/decide`, `POST /api/proposals/{pid}/complete`. MCP tools: `propose_remediation`, `get_proposal`, `list_proposals`, `complete_proposal`.
|
|
452
|
+
|
|
453
|
+
Safety: ChimericMesh never executes a proposed action on any host. It only records the human decision and announces it. The agent performs the real work under its own tool permissions, and must act only when the proposal is `approved`, never while it is `pending` or `denied`. Proposals are kept in the local database (see "Data and proposal ids"); an injected in-memory hub keeps the last 200.
|
|
454
|
+
|
|
455
|
+
## A real incident, a real fix
|
|
456
|
+
|
|
457
|
+
`examples/legacy_app` is a runnable service with a real bug (see its README). To fix it through the approval loop:
|
|
458
|
+
|
|
459
|
+
1. Run the hub: `chimericmesh` (from a checkout: `python -m chimericmesh`).
|
|
460
|
+
2. Run the service: `python examples/legacy_app/run.py`. It sends syslog to the hub.
|
|
461
|
+
3. Open the dashboard and wait for the `network` incident about the upstream timeout.
|
|
462
|
+
4. In Kiro, pick the `mesh-responder` agent and ask it to investigate and propose a fix.
|
|
463
|
+
5. Approve with `!approve p1` in the dashboard terminal: it needs the admin token, and the page asks for it once (paste the contents of `~/.chimericmesh/admin.token`). On IRC, set the server password to the admin token and use a nick listed in `CHIMERICMESH_OPERATORS`.
|
|
464
|
+
6. The agent edits the code, runs `python -m pytest examples/legacy_app/tests -q`, restarts nothing on its own, and reports the event rate. Restart `run.py` to load the fix and watch the rate fall.
|
|
465
|
+
7. Reset the buggy state: `git checkout -- examples/legacy_app` and `git clean -fd examples/legacy_app`.
|
|
466
|
+
|
|
467
|
+
## The dashboard terminal and guided workflow
|
|
468
|
+
|
|
469
|
+
The dashboard has a ChimericBot terminal: a transcript of everything the bot says plus an input line that accepts the same `!` commands as IRC (`!help`, `!status`, `!incidents`, `!explain <id>`, `!proposals`, `!approve`, `!deny`, `!resolve`). Dashboard buttons just send these commands, so every action appears in the transcript and one authorization check applies everywhere. Replies are also broadcast to IRC.
|
|
470
|
+
|
|
471
|
+
Web commands run as the fixed nick `dashboard`; the browser cannot choose a nick. With enforcement on, `!approve` and `!deny` in the terminal need the admin token instead of an operator nick (the page asks for it once and keeps it for the tab), so `CHIMERICMESH_OPERATORS` only governs IRC and `!resolve`.
|
|
472
|
+
|
|
473
|
+
The guided workflow (`GET /api/workflow`) has six steps:
|
|
474
|
+
1. Send some traffic (any event ingested)
|
|
475
|
+
2. Spot an incident
|
|
476
|
+
3. Ask ChimericBot (run any command)
|
|
477
|
+
4. Propose a fix
|
|
478
|
+
5. Approve or deny it
|
|
479
|
+
6. Lay the incident to rest (resolve)
|
|
480
|
+
|
|
481
|
+
Endpoints: `GET /api/chat?after=&limit=`, `POST /api/terminal {"text": "!status"}`, `GET /api/workflow`.
|
|
482
|
+
|
|
483
|
+
Origin check: POST/PUT/PATCH/DELETE requests carrying an `Origin` header that differs from `Host` get 403, which blocks other websites from driving a local instance. Clients that send no Origin (curl, scripts, the MCP server) are unaffected.
|
|
484
|
+
|
|
485
|
+
Security note: IRC nicks are unauthenticated, so `CHIMERICMESH_OPERATORS` is only a guard on trusted networks, not real authentication.
|
|
486
|
+
|
|
487
|
+
## Dashboard
|
|
488
|
+
|
|
489
|
+
The page at `http://127.0.0.1:8000/` is one static file (`src/chimericmesh/web/index.html`, no build step, no outside scripts, fonts or images). Five views, chosen with the buttons at the top (the address keeps the choice: `#/home`, `#/overview`, `#/services`, `#/discovery`, `#/rules`). An empty address opens Home every time; nothing is remembered about earlier visits:
|
|
490
|
+
|
|
491
|
+
- **Home**: what ChimericMesh is, a diagram of how it fits together, a live strip (events seen, open incidents, services), **Try the demo** and **Connect my apps**, and the install commands with a copy button. **Open app** goes to Overview. On a demo page a banner and the guided tour show here too (see "Try the demo").
|
|
492
|
+
|
|
493
|
+
- **Overview**: the stats, incident cards, proposals, séance log, ChimericBot terminal and guided workflow described above. The proposal cards' Approve and Deny buttons now call `POST /api/proposals/<id>/decide` instead of typing `!approve` into the terminal, so they are locked until you unlock the page. The terminal itself is unchanged.
|
|
494
|
+
- **Services**: a card per service (with **Mute** and **Unmute**, see "Mute a service") (state, last seen, errors per minute, open incidents, each log source and its status), an add and edit form, and a detail page with the Kiro permissions text, a live log, the service's incidents and its proposals. On a proposal you approved yourself, "Always approve fixes like this" opens a pre-filled rule form and creates the rule only when you confirm.
|
|
495
|
+
- **Discovery**: "Discover local apps" runs a scan, lists what it found with the candidate log files, and lets you accept (only the checked paths become log sources) or dismiss each suggestion.
|
|
496
|
+
- **Rules**: the standing approval rules, the Pause all button, per-rule Pause and Revoke, and the audit trail with filters and "Load more". While auto-approval is paused, a banner says so on every view.
|
|
497
|
+
|
|
498
|
+

|
|
499
|
+

|
|
500
|
+

|
|
501
|
+
|
|
502
|
+
**The admin token.** With access control on, the page asks for the admin token once per browser session (the Unlock button; the path of the token file is shown there). The token is kept only in `sessionStorage` (not `localStorage`), is sent only as the `X-Admin-Token` header on the routes that need it, and is never shown again, put in a URL or written to the page. While locked, the controls that add or widen things (save a service, scan, accept, approve, deny, create, edit or re-enable a rule, resume) are disabled with the title "unlock first"; pause, revoke and withdraw need no token, so Pause all, per-rule Pause, Revoke and Withdraw stay enabled. A wrong token is cleared and the page says "token rejected".
|
|
503
|
+
|
|
504
|
+
**Residual risk.** V1 sends no Content-Security-Policy. Any script that ran in the page's origin could read the token from `sessionStorage`. The defences are that the page never renders log text as HTML (every log line, host, service name, path and note is written with `textContent`; a hook and a test scan fail on `innerHTML` and its relatives) and that it loads nothing from another origin. Do not paste the token into a page you did not get from your own hub.
|
|
505
|
+
|
|
506
|
+
**Live log.** The service detail page opens `GET /api/services/<id>/stream` with Server-Sent Events: it first sends the newest 100 matching events (`?tail=100`), then new ones, with a heartbeat every 15 seconds. The hub allows 20 streams at once (the 21st gets `429` with `Retry-After: 5`), ends each after an hour, and resumes from `Last-Event-ID` or `?after=<id>`; the page reconnects with a 1 to 30 second backoff and resumes from the last id it showed. The page keeps at most 500 rows and 500 characters per message ("show more" reveals up to 4096). A browser holds about six connections per origin, so the 20-stream limit cannot be reached from browser tabs. Check it with a script:
|
|
507
|
+
|
|
508
|
+
```powershell
|
|
509
|
+
1..20 | ForEach-Object { Start-Process curl.exe -ArgumentList '-N','-s','-o','NUL','http://127.0.0.1:8000/api/services/unassigned/stream' -WindowStyle Hidden }
|
|
510
|
+
Start-Sleep 2
|
|
511
|
+
curl.exe -s -i -m 3 http://127.0.0.1:8000/api/services/unassigned/stream # HTTP/1.1 429 ... Retry-After: 5
|
|
512
|
+
Get-Process curl | Stop-Process # frees the 20 slots
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Checks you can run.** The page has a built-in self-test of its pure logic. It fetches nothing and writes `SELFTEST PASS` when every case passes. Edge prints the page only when its output is redirected, so use `Start-Process`:
|
|
516
|
+
|
|
517
|
+
```powershell
|
|
518
|
+
$edge = 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'
|
|
519
|
+
$page = (Resolve-Path src/chimericmesh/web/index.html).Path -replace '\\', '/'
|
|
520
|
+
Start-Process $edge -ArgumentList '--headless=new','--disable-gpu',"--user-data-dir=$env:TEMP\edge-check",'--virtual-time-budget=5000','--dump-dom',"`"file:///$page#selftest`"" -RedirectStandardOutput "$env:TEMP\dom.txt" -Wait -NoNewWindow
|
|
521
|
+
Select-String -Path "$env:TEMP\dom.txt" -Pattern 'SELFTEST (PASS|FAIL)'
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
Hostile text must stay text. Send `<img src=x onerror=alert(1)>` as a log line, create a service named `<script>x</script>`, dump the Services page, and look for the escaped form:
|
|
525
|
+
|
|
526
|
+
```powershell
|
|
527
|
+
$h = @{ 'content-type' = 'application/json' }
|
|
528
|
+
Invoke-RestMethod -Method Post http://127.0.0.1:8000/api/ingest -Headers $h -Body '{"source":"syslog","line":"<img src=x onerror=alert(1)>","host":"web01"}'
|
|
529
|
+
Invoke-RestMethod -Method Post http://127.0.0.1:8000/api/services -Headers ($h + @{ 'X-Admin-Token' = (Get-Content ~/.chimericmesh/admin.token -Raw).Trim() }) -Body '{"id":"xss","name":"<script>x</script>"}'
|
|
530
|
+
Start-Process $edge -ArgumentList '--headless=new','--disable-gpu',"--user-data-dir=$env:TEMP\edge-check",'--virtual-time-budget=8000','--dump-dom','"http://127.0.0.1:8000/#/services"' -RedirectStandardOutput "$env:TEMP\dom.txt" -Wait -NoNewWindow
|
|
531
|
+
Select-String -Path "$env:TEMP\dom.txt" -Pattern '<script>x</script>' # found: shown as text
|
|
532
|
+
Select-String -Path "$env:TEMP\dom.txt" -Pattern '<script>x</script>|<img src=x' # no match: no such element
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
`--dump-dom` with `--virtual-time-budget` can hang on a service detail page that has a live stream (the open connection keeps the virtual clock from finishing). The Overview, Services, Discovery and Rules views dump fine. For a detail page take a screenshot instead: `--screenshot=out.png --timeout=12000` (use a fresh `--user-data-dir`, or delete it between runs: Edge caches the page).
|
|
536
|
+
|
|
537
|
+
(With `<img src=x` in the Overview's dump for the log line.) The page never starts a scan or an approval when it loads: both need a click, and the scan also needs the token.
|