principles-disciple 1.88.0 → 1.90.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/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/src/commands/pain.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { EmpathyEventStats } from '../types/event-types.js';
|
|
|
7
7
|
import type { EvolutionLoopEvent } from '../core/evolution-types.js';
|
|
8
8
|
import { computeHash } from '../utils/hashing.js';
|
|
9
9
|
import { PainToPrincipleService, PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
|
|
10
|
+
import { loadPdConfigForPlugin } from '../core/pd-config-loader.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Creates a visual progress bar (e.g., [██████░░░░])
|
|
@@ -310,12 +311,16 @@ export async function handlePainReportCommand(ctx: PluginCommandContext): Promis
|
|
|
310
311
|
|
|
311
312
|
try {
|
|
312
313
|
const ledgerAdapter = new PrincipleTreeLedgerAdapter({ stateDir: wctx.stateDir });
|
|
314
|
+
// PRI-306: Load .pd/config.yaml for config-driven runtime binding
|
|
315
|
+
const configResult = loadPdConfigForPlugin(wctx.workspaceDir);
|
|
313
316
|
const service = new PainToPrincipleService({
|
|
314
317
|
workspaceDir: wctx.workspaceDir,
|
|
315
318
|
stateDir: wctx.stateDir,
|
|
316
319
|
ledgerAdapter,
|
|
317
320
|
owner: 'openclaw-plugin',
|
|
318
321
|
autoIntakeEnabled: true,
|
|
322
|
+
effectiveConfig: configResult.effective,
|
|
323
|
+
getEnvVar: (name: string) => process.env[name],
|
|
319
324
|
});
|
|
320
325
|
|
|
321
326
|
const result = await service.recordPain({
|
package/src/hooks/pain.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { resolveWorkspaceDirForRuntimeV2 } from '../utils/workspace-resolver.js'
|
|
|
14
14
|
import { PainToPrincipleService, PrincipleTreeLedgerAdapter, type PainDetectedData, type PainEvidenceEntry, MAX_EVIDENCE_ENTRIES, MAX_EVIDENCE_NOTE_CHARS } from '@principles/core/runtime-v2';
|
|
15
15
|
import { evaluatePainDiagnosticGate } from '../core/pain-diagnostic-gate.js';
|
|
16
16
|
import { sanitizeAssistantText } from './message-sanitize.js';
|
|
17
|
+
import { loadPdConfigForPlugin } from '../core/pd-config-loader.js';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Interface for tool parameters to avoid 'any'
|
|
@@ -34,12 +35,17 @@ const WRITE_TOOLS = ['write', 'edit', 'apply_patch', 'write_file', 'edit_file',
|
|
|
34
35
|
|
|
35
36
|
function createPainToPrincipleService(wctx: WorkspaceContext): PainToPrincipleService {
|
|
36
37
|
const ledgerAdapter = new PrincipleTreeLedgerAdapter({ stateDir: wctx.stateDir });
|
|
38
|
+
// PRI-306: Load .pd/config.yaml and pass effectiveConfig to PainToPrincipleService
|
|
39
|
+
// so createPainSignalBridge uses config-driven runtime binding resolution.
|
|
40
|
+
const configResult = loadPdConfigForPlugin(wctx.workspaceDir);
|
|
37
41
|
return new PainToPrincipleService({
|
|
38
42
|
workspaceDir: wctx.workspaceDir,
|
|
39
43
|
stateDir: wctx.stateDir,
|
|
40
44
|
ledgerAdapter,
|
|
41
45
|
owner: 'openclaw-plugin',
|
|
42
46
|
autoIntakeEnabled: true,
|
|
47
|
+
effectiveConfig: configResult.effective,
|
|
48
|
+
getEnvVar: (name: string) => process.env[name],
|
|
43
49
|
});
|
|
44
50
|
}
|
|
45
51
|
|
|
@@ -226,6 +226,7 @@ async function insertPromptActivation(overrides: {
|
|
|
226
226
|
action,
|
|
227
227
|
targetRef,
|
|
228
228
|
activatedAt: now,
|
|
229
|
+
deactivatedAt: null,
|
|
229
230
|
});
|
|
230
231
|
}
|
|
231
232
|
|
|
@@ -310,6 +311,35 @@ describe('Runtime V2 prompt activation injection', () => {
|
|
|
310
311
|
expect(result?.appendSystemContext).not.toContain(TEST_PRINCIPLE_TEXT);
|
|
311
312
|
});
|
|
312
313
|
|
|
314
|
+
it('deactivated activation is not injected into prompt', async () => {
|
|
315
|
+
const artifactId = 'art-v2-deactivated-200';
|
|
316
|
+
const principleId = 'princ-v2-deactivated-200';
|
|
317
|
+
|
|
318
|
+
insertValidatedPrincipleArtifact({ artifactId, principleId });
|
|
319
|
+
await insertPromptActivation({ artifactId, principleId });
|
|
320
|
+
|
|
321
|
+
// Deactivate the activation
|
|
322
|
+
const store = new SqliteActivationStateStore(sqliteConn);
|
|
323
|
+
const deactivated = await store.deactivateActivation(`act_prompt_${principleId}`, new Date().toISOString());
|
|
324
|
+
expect(deactivated).toBe(true);
|
|
325
|
+
|
|
326
|
+
// Close test connection so the reader gets a fresh view
|
|
327
|
+
sqliteConn.close();
|
|
328
|
+
|
|
329
|
+
// Verify the deactivation persisted via a fresh connection
|
|
330
|
+
const verifyConn = new SqliteConnection(tempWorkspaceDir);
|
|
331
|
+
const row = verifyConn.getDb().prepare(
|
|
332
|
+
'SELECT deactivated_at FROM activations WHERE activation_id = ?'
|
|
333
|
+
).get(`act_prompt_${principleId}`) as { deactivated_at: string | null } | undefined;
|
|
334
|
+
expect(row?.deactivated_at).toBeTruthy();
|
|
335
|
+
verifyConn.close();
|
|
336
|
+
|
|
337
|
+
const reader = new PromptActivationReader(tempWorkspaceDir);
|
|
338
|
+
const result = await reader.readActivatedPrinciples();
|
|
339
|
+
|
|
340
|
+
expect(result.principles).toHaveLength(0);
|
|
341
|
+
});
|
|
342
|
+
|
|
313
343
|
it('prompt feature flag check is present — core flag cannot be disabled by config', async () => {
|
|
314
344
|
const artifactId = 'art-v2-flag-004';
|
|
315
345
|
const principleId = 'princ-v2-flag-004';
|