@ouro.bot/cli 0.1.0-alpha.296 → 0.1.0-alpha.297

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/changelog.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.297",
6
+ "changes": [
7
+ "feat(mind): add integrity scanning for diary entries at write time. New detectSuspiciousContent() in src/mind/diary-integrity.ts checks entry text for prompt injection patterns (instruction framing, override language, role injection, boundary markers) before persisting. Detection emits a mind.diary_integrity_warning nerves event with matched pattern categories, text preview, and entry ID. Entries still save (flag, don't block) to avoid false-positive data loss. 41 unit tests + 4 integration tests with 100% coverage on new code."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.296",
6
12
  "changes": [
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectSuspiciousContent = detectSuspiciousContent;
4
+ const PATTERN_CATEGORIES = [
5
+ {
6
+ name: "instruction_framing",
7
+ patterns: [
8
+ /\byou are (?:a|an) (?:ai|assistant|language model|helpful assistant)\b/i,
9
+ /\byour (?:new )?instructions are\b/i,
10
+ /\bsystem\s*:/i,
11
+ /\bignore (?:all |my )?previous instructions\b/i,
12
+ /\bdo not reveal\b/i,
13
+ ],
14
+ },
15
+ {
16
+ name: "override_language",
17
+ patterns: [
18
+ /\bdisregard\b/i,
19
+ /\bforget everything\b/i,
20
+ /\bnew instructions:/i,
21
+ /\boverride (?:all |any |previous )?instructions\b/i,
22
+ ],
23
+ },
24
+ {
25
+ name: "role_injection",
26
+ patterns: [
27
+ /\bas (?:a|an) (?:ai|language model)\b/i,
28
+ /\byou must always\b/i,
29
+ /\byou are now\b/i,
30
+ ],
31
+ },
32
+ {
33
+ name: "boundary_markers",
34
+ patterns: [
35
+ /```system/i,
36
+ /<<SYS>>/i,
37
+ /\[INST\]/i,
38
+ /<\/?system>/i,
39
+ /\[system\]/i,
40
+ ],
41
+ },
42
+ ];
43
+ function detectSuspiciousContent(text) {
44
+ if (!text) {
45
+ return { suspicious: false, patterns: [] };
46
+ }
47
+ const matched = new Set();
48
+ for (const category of PATTERN_CATEGORIES) {
49
+ for (const pattern of category.patterns) {
50
+ if (pattern.test(text)) {
51
+ matched.add(category.name);
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ return {
57
+ suspicious: matched.size > 0,
58
+ patterns: [...matched],
59
+ };
60
+ }
@@ -46,6 +46,7 @@ const crypto_1 = require("crypto");
46
46
  const identity_1 = require("../heart/identity");
47
47
  const runtime_1 = require("../nerves/runtime");
48
48
  const associative_recall_1 = require("./associative-recall");
49
+ const diary_integrity_1 = require("./diary-integrity");
49
50
  const embedding_provider_1 = require("./embedding-provider");
50
51
  const DEDUP_THRESHOLD = 0.6;
51
52
  const SEMANTIC_DEDUP_THRESHOLD = 0.95;
@@ -237,6 +238,20 @@ async function saveDiaryEntry(options) {
237
238
  embedding,
238
239
  ...(options.provenance ? { provenance: options.provenance } : {}),
239
240
  };
241
+ const integrity = (0, diary_integrity_1.detectSuspiciousContent)(text);
242
+ if (integrity.suspicious) {
243
+ (0, runtime_1.emitNervesEvent)({
244
+ level: "warn",
245
+ component: "mind",
246
+ event: "mind.diary_integrity_warning",
247
+ message: "suspicious content detected in diary entry",
248
+ meta: {
249
+ patterns: integrity.patterns,
250
+ textPreview: text.slice(0, 200),
251
+ entryId: fact.id,
252
+ },
253
+ });
254
+ }
240
255
  return appendEntriesWithDedup(stores, [fact], { semanticThreshold: SEMANTIC_DEDUP_THRESHOLD });
241
256
  }
242
257
  async function backfillEmbeddings(options) {
@@ -69,6 +69,9 @@ const DISPATCH_EXEMPT_PATTERNS = [
69
69
  "mind/embedding-provider",
70
70
  // Commerce utility module: error classes and pure helpers (no independent side effects).
71
71
  "repertoire/commerce-errors",
72
+ // Diary integrity: pure detection utility (pattern matching only). The caller
73
+ // (diary.ts saveDiaryEntry) owns observability via mind.diary_integrity_warning.
74
+ "mind/diary-integrity",
72
75
  // Log redaction: pure utility consumed by the NDJSON sink (no independent side effects).
73
76
  "nerves/redact",
74
77
  // Bundle templates: pure constants (gitignore template string, PII
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.296",
3
+ "version": "0.1.0-alpha.297",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",