eleven / messenger Public

Clone
git clone https://amadan.net/eleven/messenger

Plain git — no account needed to clone.

Download

Download this file

1// Guards Eleven's knowledge base. node test/knowledge.test.mjs
2// This text is injected into Eleven's system prompt and is effectively extractable
3// by anyone chatting with it, so the critical invariant is: it contains OPEN
4// design knowledge and NO operational secrets. This test fails loudly if a future
5// edit ever pastes an address, token, key, or instance name into it.
6import assert from "node:assert/strict";
7import { APP_KNOWLEDGE } from "../agent/knowledge.mjs";
8
9let failures = 0;
10function test(name, fn) {
11 try {
12 fn();
13 console.log(`PASS ${name}`);
14 } catch (e) {
15 failures++;
16 console.log(`FAIL ${name} — ${e && e.message}`);
17 }
18}
19
20test("the knowledge base is substantial (not accidentally emptied)", () => {
21 assert.equal(typeof APP_KNOWLEDGE, "string");
22 assert.ok(APP_KNOWLEDGE.length > 10000, `too short: ${APP_KNOWLEDGE.length} chars`);
23 // Spot-check that it actually covers the core topics.
24 for (const topic of [/end-to-end/i, /thread/i, /invite/i, /remind/i, /Announcer/, /passkey|backup/i]) {
25 assert.match(APP_KNOWLEDGE, topic);
26 }
27});
28
29test("the knowledge base leaks NO operational secrets", () => {
30 const forbidden = [
31 [/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/, "an IP address"],
32 [/run\.garden|elevenmessenger\.com|paulca/i, "a real hostname/instance"],
33 [/hetzner|\bmiren\b|1password|\bop\b\s+(?:read|item)/i, "an operator/tooling name"],
34 [/\.p8\b|J5NDF5|ZKYQ9|9X6NKTF|admintok|LCHAT_ADMIN_TOKEN|Bearer\s+\w/i, "a key/token"],
35 [/BEGIN (?:EC |RSA |OPENSSH )?PRIVATE KEY/i, "a private key"],
36 [/ssh\s+root@|root@\d/i, "an SSH target"],
37 ];
38 for (const [re, what] of forbidden) {
39 assert.doesNotMatch(APP_KNOWLEDGE, re, `knowledge base appears to contain ${what}`);
40 }
41});
42
43console.log(failures === 0 ? "\nALL PASSED" : `\n${failures} FAILED`);
44process.exit(failures === 0 ? 0 : 1);
45