principles-disciple 1.40.0 → 1.41.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/esbuild.config.js +32 -3
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
- package/scripts/compile-principles.mjs +94 -0
- package/scripts/sync-plugin.mjs +96 -281
- package/src/core/principle-compiler/code-validator.ts +120 -0
- package/src/core/principle-compiler/compiler.ts +242 -0
- package/src/core/principle-compiler/index.ts +10 -0
- package/src/core/principle-compiler/ledger-registrar.ts +107 -0
- package/src/core/principle-compiler/template-generator.ts +108 -0
- package/src/core/reflection/reflection-context.ts +228 -0
- package/tests/core/code-validator.test.ts +197 -0
- package/tests/core/ledger-registrar.test.ts +232 -0
- package/tests/core/principle-compiler.test.ts +348 -0
- package/tests/core/reflection-context.test.ts +356 -0
- package/tests/core/template-generator.test.ts +101 -0
- package/tests/integration/principle-compiler-e2e.test.ts +335 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { generateFromTemplate, PainPattern } from '../../src/core/principle-compiler/template-generator';
|
|
3
|
+
|
|
4
|
+
describe('generateFromTemplate', () => {
|
|
5
|
+
it('should generate code for a single tool with path pattern', () => {
|
|
6
|
+
const patterns: PainPattern[] = [
|
|
7
|
+
{ toolName: 'write', pathRegex: 'secrets/.*\\.env' },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const result = generateFromTemplate('P_066', 'Writing to secrets directory', patterns);
|
|
11
|
+
|
|
12
|
+
expect(result).not.toBeNull();
|
|
13
|
+
expect(result).toContain("export const meta");
|
|
14
|
+
expect(result).toContain("export function evaluate(input)");
|
|
15
|
+
expect(result).toContain('name: "Auto_P_066"');
|
|
16
|
+
expect(result).toContain('ruleId: "R_P_066_auto"');
|
|
17
|
+
expect(result).toContain('sourcePrincipleId: "P_066"');
|
|
18
|
+
expect(result).toContain('coversCondition: "Writing to secrets directory"');
|
|
19
|
+
expect(result).toContain('input.action.toolName === "write"');
|
|
20
|
+
expect(result).toContain("secrets/.*\\\\.env");
|
|
21
|
+
expect(result).toContain("input.action.normalizedPath");
|
|
22
|
+
expect(result).toContain("decision: 'block'");
|
|
23
|
+
expect(result).toContain("matched: true");
|
|
24
|
+
expect(result).toContain("[P_066]");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should generate code for write tool with content pattern', () => {
|
|
28
|
+
const patterns: PainPattern[] = [
|
|
29
|
+
{ toolName: 'write', contentRegex: 'BEGIN RSA PRIVATE KEY' },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const result = generateFromTemplate('P_007', 'Writing private keys', patterns);
|
|
33
|
+
|
|
34
|
+
expect(result).not.toBeNull();
|
|
35
|
+
expect(result).toContain('input.action.toolName === "write"');
|
|
36
|
+
expect(result).toContain("BEGIN RSA PRIVATE KEY");
|
|
37
|
+
expect(result).toContain("paramsSummary.content");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should generate code for multiple tool patterns', () => {
|
|
41
|
+
const patterns: PainPattern[] = [
|
|
42
|
+
{ toolName: 'bash', commandRegex: 'rm\\s+-rf\\s+/' },
|
|
43
|
+
{ toolName: 'write', pathRegex: 'secrets/', contentRegex: 'password' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const result = generateFromTemplate('P_010', 'Destructive operations', patterns);
|
|
47
|
+
|
|
48
|
+
expect(result).not.toBeNull();
|
|
49
|
+
expect(result).toContain('input.action.toolName === "bash"');
|
|
50
|
+
expect(result).toContain("rm\\\\s+-rf\\\\s+/");
|
|
51
|
+
expect(result).toContain("paramsSummary.command");
|
|
52
|
+
expect(result).toContain('input.action.toolName === "write"');
|
|
53
|
+
expect(result).toContain("secrets/");
|
|
54
|
+
expect(result).toContain("password");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should return null when patterns array is empty', () => {
|
|
58
|
+
const result = generateFromTemplate('P_066', 'some condition', []);
|
|
59
|
+
expect(result).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should not contain forbidden patterns (require, import, fetch)', () => {
|
|
63
|
+
const patterns: PainPattern[] = [
|
|
64
|
+
{ toolName: 'bash', commandRegex: 'dangerous' },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const result = generateFromTemplate('P_099', 'Dangerous commands', patterns);
|
|
68
|
+
|
|
69
|
+
expect(result).not.toBeNull();
|
|
70
|
+
expect(result).not.toContain('require(');
|
|
71
|
+
expect(result).not.toContain('import ');
|
|
72
|
+
expect(result).not.toContain('fetch(');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should have proper structure with meta and evaluate function', () => {
|
|
76
|
+
const patterns: PainPattern[] = [
|
|
77
|
+
{ toolName: 'edit', pathRegex: '\\.json$', contentRegex: 'admin.*true' },
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
const result = generateFromTemplate('P_050', 'Modifying admin config', patterns);
|
|
81
|
+
|
|
82
|
+
expect(result).not.toBeNull();
|
|
83
|
+
|
|
84
|
+
// Check meta structure
|
|
85
|
+
expect(result).toMatch(/export const meta = \{/);
|
|
86
|
+
expect(result).toMatch(/name: "Auto_P_050"/);
|
|
87
|
+
expect(result).toMatch(/version: '1\.0\.0'/);
|
|
88
|
+
expect(result).toMatch(/ruleId: "R_P_050_auto"/);
|
|
89
|
+
expect(result).toMatch(/sourcePrincipleId: "P_050"/);
|
|
90
|
+
expect(result).toMatch(/compiledAt: "\d{4}-\d{2}-\d{2}T/);
|
|
91
|
+
|
|
92
|
+
// Check evaluate function structure
|
|
93
|
+
expect(result).toMatch(/export function evaluate\(input\)/);
|
|
94
|
+
expect(result).toMatch(/decision: 'block'/);
|
|
95
|
+
expect(result).toMatch(/matched: true/);
|
|
96
|
+
expect(result).toMatch(/return \{ matched: false \}/);
|
|
97
|
+
|
|
98
|
+
// Check edit tool uses new_string fallback
|
|
99
|
+
expect(result).toContain("input.action.paramsSummary.content || input.action.paramsSummary.new_string");
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E2E Test: Principle Compiler → RuleHost Enforcement
|
|
3
|
+
*
|
|
4
|
+
* Tests the full chain:
|
|
5
|
+
* 1. Set up principle in ledger with derivedFromPainIds
|
|
6
|
+
* 2. Record tool call (bash, failure) and pain event in trajectory DB
|
|
7
|
+
* 3. Compile principle via PrincipleCompiler (registers as active + persists code)
|
|
8
|
+
* 4. RuleHost.evaluate(matching input) → block
|
|
9
|
+
* 5. RuleHost.evaluate(non-matching input) → undefined (passthrough)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
13
|
+
import * as fs from 'fs';
|
|
14
|
+
import * as os from 'os';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
import { TrajectoryDatabase } from '../../src/core/trajectory.js';
|
|
17
|
+
import { PrincipleCompiler } from '../../src/core/principle-compiler/compiler.js';
|
|
18
|
+
import { RuleHost } from '../../src/core/rule-host.js';
|
|
19
|
+
import {
|
|
20
|
+
loadLedger,
|
|
21
|
+
saveLedger,
|
|
22
|
+
} from '../../src/core/principle-tree-ledger.js';
|
|
23
|
+
import type { RuleHostInput } from '../../src/core/rule-host-types.js';
|
|
24
|
+
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Helpers
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
interface TestWorkspace {
|
|
30
|
+
workspaceDir: string;
|
|
31
|
+
stateDir: string;
|
|
32
|
+
trajectory: TrajectoryDatabase;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createTestWorkspace(): TestWorkspace {
|
|
36
|
+
const workspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pd-compiler-e2e-'));
|
|
37
|
+
const stateDir = path.join(workspaceDir, '.state');
|
|
38
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
39
|
+
|
|
40
|
+
const trajectory = new TrajectoryDatabase({ workspaceDir });
|
|
41
|
+
|
|
42
|
+
return { workspaceDir, stateDir, trajectory };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function disposeTestWorkspace(ws: TestWorkspace): void {
|
|
46
|
+
ws.trajectory.dispose();
|
|
47
|
+
fs.rmSync(ws.workspaceDir, { recursive: true, force: true });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Tests
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
describe('Principle Compiler E2E: compile → promote → RuleHost blocks', () => {
|
|
55
|
+
let ws: TestWorkspace;
|
|
56
|
+
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
ws = createTestWorkspace();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
disposeTestWorkspace(ws);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should compile a principle, promote it, and have RuleHost block matching input', () => {
|
|
66
|
+
const sessionId = 'session-e2e-001';
|
|
67
|
+
const principleId = 'P_066';
|
|
68
|
+
|
|
69
|
+
// ── Step 1: Record a tool call and pain event in trajectory DB ──
|
|
70
|
+
ws.trajectory.recordToolCall({
|
|
71
|
+
sessionId,
|
|
72
|
+
toolName: 'bash',
|
|
73
|
+
outcome: 'failure',
|
|
74
|
+
errorType: 'command_not_found',
|
|
75
|
+
errorMessage: 'heartbeat: command not found',
|
|
76
|
+
paramsJson: { command: 'heartbeat --status' },
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Pain event whose reason contains "bash" (known tool) so
|
|
80
|
+
// extractPatterns() can infer the toolName.
|
|
81
|
+
ws.trajectory.recordPainEvent({
|
|
82
|
+
sessionId,
|
|
83
|
+
source: 'gate_block',
|
|
84
|
+
score: 75,
|
|
85
|
+
reason: 'Blocked bash heartbeat command due to unsafe operation',
|
|
86
|
+
severity: 'moderate',
|
|
87
|
+
origin: 'system_infer',
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// ── Step 2: Set up principle P_066 in the ledger with derivedFromPainIds ──
|
|
91
|
+
const store = loadLedger(ws.stateDir);
|
|
92
|
+
|
|
93
|
+
const now = new Date().toISOString();
|
|
94
|
+
|
|
95
|
+
// Principle must have derivedFromPainIds for the ReflectionContextCollector
|
|
96
|
+
// to return a non-null context. The painIds are arbitrary strings that
|
|
97
|
+
// we make match the pain event's auto-increment row ID via the
|
|
98
|
+
// best-effort resolution logic (it checks if painId appears in
|
|
99
|
+
// pe.reason, pe.origin, or String(pe.id)).
|
|
100
|
+
store.tree.principles[principleId] = {
|
|
101
|
+
id: principleId,
|
|
102
|
+
version: 1,
|
|
103
|
+
text: 'Do not run heartbeat commands via bash',
|
|
104
|
+
triggerPattern: 'heartbeat.*bash',
|
|
105
|
+
action: 'Block heartbeat commands in bash',
|
|
106
|
+
status: 'active',
|
|
107
|
+
priority: 'P1',
|
|
108
|
+
scope: 'general',
|
|
109
|
+
evaluability: 'deterministic',
|
|
110
|
+
valueScore: 0,
|
|
111
|
+
adherenceRate: 0,
|
|
112
|
+
painPreventedCount: 0,
|
|
113
|
+
derivedFromPainIds: ['1'], // references pain event row id (stringified)
|
|
114
|
+
ruleIds: [],
|
|
115
|
+
conflictsWithPrincipleIds: [],
|
|
116
|
+
createdAt: now,
|
|
117
|
+
updatedAt: now,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
saveLedger(ws.stateDir, store);
|
|
121
|
+
|
|
122
|
+
// ── Step 3: Create PrincipleCompiler and compile P_066 ──
|
|
123
|
+
const compiler = new PrincipleCompiler(ws.stateDir, ws.trajectory);
|
|
124
|
+
const result = compiler.compileOne(principleId);
|
|
125
|
+
|
|
126
|
+
// Verify compilation succeeded
|
|
127
|
+
expect(result.success).toBe(true);
|
|
128
|
+
expect(result.principleId).toBe(principleId);
|
|
129
|
+
expect(result.code).toBeDefined();
|
|
130
|
+
expect(result.ruleId).toBeDefined();
|
|
131
|
+
expect(result.implementationId).toBeDefined();
|
|
132
|
+
|
|
133
|
+
const implId = result.implementationId!;
|
|
134
|
+
|
|
135
|
+
// Verify the implementation was registered as active (not candidate)
|
|
136
|
+
const ledger = loadLedger(ws.stateDir);
|
|
137
|
+
const impl = ledger.tree.implementations[implId];
|
|
138
|
+
expect(impl.lifecycleState).toBe('active');
|
|
139
|
+
|
|
140
|
+
// ── Step 4: Create RuleHost and evaluate with matching input ──
|
|
141
|
+
const host = new RuleHost(ws.stateDir, { warn: () => {} });
|
|
142
|
+
|
|
143
|
+
// Matching input: bash tool with a heartbeat command
|
|
144
|
+
const matchingInput: RuleHostInput = {
|
|
145
|
+
action: {
|
|
146
|
+
toolName: 'bash',
|
|
147
|
+
normalizedPath: null,
|
|
148
|
+
paramsSummary: { command: 'heartbeat --status' },
|
|
149
|
+
},
|
|
150
|
+
workspace: {
|
|
151
|
+
isRiskPath: false,
|
|
152
|
+
planStatus: 'NONE',
|
|
153
|
+
hasPlanFile: false,
|
|
154
|
+
},
|
|
155
|
+
session: {
|
|
156
|
+
sessionId: 'session-eval-001',
|
|
157
|
+
currentGfi: 50,
|
|
158
|
+
recentThinking: false,
|
|
159
|
+
},
|
|
160
|
+
evolution: {
|
|
161
|
+
epTier: 0,
|
|
162
|
+
},
|
|
163
|
+
derived: {
|
|
164
|
+
estimatedLineChanges: 0,
|
|
165
|
+
bashRisk: 'unknown',
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const blockResult = host.evaluate(matchingInput);
|
|
170
|
+
|
|
171
|
+
// Verify RuleHost blocks the matching input
|
|
172
|
+
expect(blockResult).toBeDefined();
|
|
173
|
+
expect(blockResult!.decision).toBe('block');
|
|
174
|
+
expect(blockResult!.matched).toBe(true);
|
|
175
|
+
expect(blockResult!.reason).toContain(principleId);
|
|
176
|
+
|
|
177
|
+
// ── Step 5: Verify non-matching input returns undefined (passthrough) ──
|
|
178
|
+
const nonMatchingInput: RuleHostInput = {
|
|
179
|
+
action: {
|
|
180
|
+
toolName: 'write', // different tool, not bash
|
|
181
|
+
normalizedPath: '/home/user/project/src/index.ts',
|
|
182
|
+
paramsSummary: { content: 'console.log("hello")' },
|
|
183
|
+
},
|
|
184
|
+
workspace: {
|
|
185
|
+
isRiskPath: false,
|
|
186
|
+
planStatus: 'NONE',
|
|
187
|
+
hasPlanFile: false,
|
|
188
|
+
},
|
|
189
|
+
session: {
|
|
190
|
+
sessionId: 'session-eval-002',
|
|
191
|
+
currentGfi: 50,
|
|
192
|
+
recentThinking: false,
|
|
193
|
+
},
|
|
194
|
+
evolution: {
|
|
195
|
+
epTier: 0,
|
|
196
|
+
},
|
|
197
|
+
derived: {
|
|
198
|
+
estimatedLineChanges: 5,
|
|
199
|
+
bashRisk: 'safe',
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const passthroughResult = host.evaluate(nonMatchingInput);
|
|
204
|
+
expect(passthroughResult).toBeUndefined();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('should return undefined when no active implementations exist', () => {
|
|
208
|
+
const host = new RuleHost(ws.stateDir, { warn: () => {} });
|
|
209
|
+
|
|
210
|
+
const input: RuleHostInput = {
|
|
211
|
+
action: {
|
|
212
|
+
toolName: 'bash',
|
|
213
|
+
normalizedPath: null,
|
|
214
|
+
paramsSummary: { command: 'rm -rf /' },
|
|
215
|
+
},
|
|
216
|
+
workspace: {
|
|
217
|
+
isRiskPath: true,
|
|
218
|
+
planStatus: 'NONE',
|
|
219
|
+
hasPlanFile: false,
|
|
220
|
+
},
|
|
221
|
+
session: {
|
|
222
|
+
sessionId: 'session-empty-001',
|
|
223
|
+
currentGfi: 0,
|
|
224
|
+
recentThinking: false,
|
|
225
|
+
},
|
|
226
|
+
evolution: {
|
|
227
|
+
epTier: 0,
|
|
228
|
+
},
|
|
229
|
+
derived: {
|
|
230
|
+
estimatedLineChanges: 0,
|
|
231
|
+
bashRisk: 'dangerous',
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const result = host.evaluate(input);
|
|
236
|
+
expect(result).toBeUndefined();
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('should return compilation failure when principle has no derivedFromPainIds', () => {
|
|
240
|
+
const sessionId = 'session-no-pain-001';
|
|
241
|
+
const principleId = 'P_099';
|
|
242
|
+
|
|
243
|
+
// Set up a principle WITHOUT derivedFromPainIds
|
|
244
|
+
const store = loadLedger(ws.stateDir);
|
|
245
|
+
const now = new Date().toISOString();
|
|
246
|
+
|
|
247
|
+
store.tree.principles[principleId] = {
|
|
248
|
+
id: principleId,
|
|
249
|
+
version: 1,
|
|
250
|
+
text: 'A principle with no pain grounding',
|
|
251
|
+
triggerPattern: 'noop',
|
|
252
|
+
action: 'do nothing',
|
|
253
|
+
status: 'active',
|
|
254
|
+
priority: 'P2',
|
|
255
|
+
scope: 'general',
|
|
256
|
+
evaluability: 'manual_only',
|
|
257
|
+
valueScore: 0,
|
|
258
|
+
adherenceRate: 0,
|
|
259
|
+
painPreventedCount: 0,
|
|
260
|
+
derivedFromPainIds: [], // EMPTY — no pain grounding
|
|
261
|
+
ruleIds: [],
|
|
262
|
+
conflictsWithPrincipleIds: [],
|
|
263
|
+
createdAt: now,
|
|
264
|
+
updatedAt: now,
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
saveLedger(ws.stateDir, store);
|
|
268
|
+
|
|
269
|
+
const compiler = new PrincipleCompiler(ws.stateDir, ws.trajectory);
|
|
270
|
+
const result = compiler.compileOne(principleId);
|
|
271
|
+
|
|
272
|
+
// Should fail because no context (no derivedFromPainIds)
|
|
273
|
+
expect(result.success).toBe(false);
|
|
274
|
+
expect(result.reason).toBe('no context');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should compile using session snapshot tool calls as pattern source', () => {
|
|
278
|
+
const sessionId = 'session-snapshot-001';
|
|
279
|
+
const principleId = 'P_077';
|
|
280
|
+
|
|
281
|
+
// Record a tool call that the session snapshot will pick up.
|
|
282
|
+
// Avoid file paths in the reason/params to prevent path-based regex
|
|
283
|
+
// generation which has a known escaping limitation in the template generator.
|
|
284
|
+
ws.trajectory.recordToolCall({
|
|
285
|
+
sessionId,
|
|
286
|
+
toolName: 'grep',
|
|
287
|
+
outcome: 'failure',
|
|
288
|
+
errorType: 'timeout',
|
|
289
|
+
errorMessage: 'grep command timed out',
|
|
290
|
+
paramsJson: { pattern: 'TODO' },
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// Pain event referencing this session
|
|
294
|
+
ws.trajectory.recordPainEvent({
|
|
295
|
+
sessionId,
|
|
296
|
+
source: 'gate_block',
|
|
297
|
+
score: 60,
|
|
298
|
+
reason: 'grep tool failed with timeout error',
|
|
299
|
+
severity: 'moderate',
|
|
300
|
+
origin: 'system_infer',
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// Set up principle
|
|
304
|
+
const store = loadLedger(ws.stateDir);
|
|
305
|
+
const now = new Date().toISOString();
|
|
306
|
+
|
|
307
|
+
store.tree.principles[principleId] = {
|
|
308
|
+
id: principleId,
|
|
309
|
+
version: 1,
|
|
310
|
+
text: 'Block grep tool on timeout patterns',
|
|
311
|
+
triggerPattern: 'grep.*timeout',
|
|
312
|
+
action: 'Block grep commands that time out',
|
|
313
|
+
status: 'active',
|
|
314
|
+
priority: 'P1',
|
|
315
|
+
scope: 'general',
|
|
316
|
+
evaluability: 'deterministic',
|
|
317
|
+
valueScore: 0,
|
|
318
|
+
adherenceRate: 0,
|
|
319
|
+
painPreventedCount: 0,
|
|
320
|
+
derivedFromPainIds: ['1'], // reference to pain event (auto-increment ID)
|
|
321
|
+
ruleIds: [],
|
|
322
|
+
conflictsWithPrincipleIds: [],
|
|
323
|
+
createdAt: now,
|
|
324
|
+
updatedAt: now,
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
saveLedger(ws.stateDir, store);
|
|
328
|
+
|
|
329
|
+
const compiler = new PrincipleCompiler(ws.stateDir, ws.trajectory);
|
|
330
|
+
const result = compiler.compileOne(principleId);
|
|
331
|
+
|
|
332
|
+
expect(result.success).toBe(true);
|
|
333
|
+
expect(result.code).toContain('grep'); // generated code should check for grep tool
|
|
334
|
+
});
|
|
335
|
+
});
|