principles-disciple 1.42.0 → 1.44.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 +1 -1
- package/package.json +1 -1
- package/src/commands/archive-impl.ts +5 -3
- package/src/commands/capabilities.ts +1 -1
- package/src/commands/context.ts +1 -0
- package/src/commands/disable-impl.ts +1 -1
- package/src/commands/evolution-status.ts +2 -2
- package/src/commands/export.ts +6 -6
- package/src/commands/nocturnal-train.ts +1 -1
- package/src/commands/principle-rollback.ts +1 -1
- package/src/commands/rollback.ts +0 -1
- package/src/commands/samples.ts +1 -1
- package/src/commands/thinking-os.ts +1 -0
- package/src/commands/workflow-debug.ts +1 -1
- package/src/core/adaptive-thresholds.ts +3 -3
- package/src/core/config.ts +2 -1
- package/src/core/dictionary.ts +1 -0
- package/src/core/event-log.ts +3 -3
- package/src/core/evolution-engine.ts +1 -1
- package/src/core/external-training-contract.ts +1 -1
- package/src/core/merge-gate-audit.ts +3 -3
- package/src/core/nocturnal-arbiter.ts +1 -1
- package/src/core/nocturnal-compliance.ts +28 -28
- package/src/core/nocturnal-executability.ts +1 -1
- package/src/core/nocturnal-reasoning-deriver.ts +4 -4
- package/src/core/nocturnal-rule-implementation-validator.ts +1 -1
- package/src/core/nocturnal-snapshot-contract.ts +1 -1
- package/src/core/pain-context-extractor.ts +2 -2
- package/src/core/path-resolver.ts +1 -0
- package/src/core/pd-task-reconciler.ts +1 -0
- package/src/core/pd-task-service.ts +1 -1
- package/src/core/pd-task-store.ts +1 -0
- package/src/core/principle-internalization/deprecated-readiness.ts +1 -1
- package/src/core/principle-internalization/principle-lifecycle-service.ts +1 -1
- package/src/core/principle-training-state.ts +2 -2
- package/src/core/principle-tree-migration.ts +1 -1
- package/src/core/profile.ts +1 -1
- package/src/core/promotion-gate.ts +0 -2
- package/src/core/replay-engine.ts +1 -0
- package/src/core/risk-calculator.ts +2 -1
- package/src/core/rule-host.ts +1 -1
- package/src/core/session-tracker.ts +1 -0
- package/src/core/shadow-observation-registry.ts +1 -1
- package/src/core/thinking-models.ts +1 -1
- package/src/core/thinking-os-parser.ts +1 -1
- package/src/core/trajectory.ts +2 -4
- package/src/core/workspace-context.ts +1 -1
- package/src/hooks/bash-risk.ts +2 -2
- package/src/hooks/edit-verification.ts +4 -4
- package/src/hooks/gate.ts +8 -8
- package/src/hooks/gfi-gate.ts +2 -2
- package/src/hooks/lifecycle-routing.ts +1 -1
- package/src/hooks/pain.ts +2 -2
- package/src/hooks/progressive-trust-gate.ts +3 -3
- package/src/hooks/prompt.ts +3 -5
- package/src/hooks/thinking-checkpoint.ts +1 -1
- package/src/index.ts +8 -8
- package/src/service/central-database.ts +3 -2
- package/src/service/central-health-service.ts +2 -1
- package/src/service/central-overview-service.ts +3 -2
- package/src/service/control-ui-query-service.ts +2 -2
- package/src/service/event-log-auditor.ts +2 -2
- package/src/service/evolution-query-service.ts +3 -3
- package/src/service/evolution-worker.ts +11 -18
- package/src/service/health-query-service.ts +11 -10
- package/src/service/monitoring-query-service.ts +4 -4
- package/src/service/nocturnal-runtime.ts +0 -3
- package/src/service/nocturnal-service.ts +8 -8
- package/src/service/nocturnal-target-selector.ts +2 -2
- package/src/service/queue-io.ts +5 -5
- package/src/service/runtime-summary-service.ts +1 -1
- package/src/service/sleep-cycle.ts +1 -1
- package/src/service/subagent-workflow/deep-reflect-workflow-manager.ts +1 -1
- package/src/service/subagent-workflow/empathy-observer-workflow-manager.ts +1 -0
- package/src/service/subagent-workflow/nocturnal-workflow-manager.ts +1 -1
- package/src/service/subagent-workflow/subagent-error-utils.ts +1 -1
- package/src/service/subagent-workflow/workflow-store.ts +3 -2
- package/src/service/workflow-watchdog.ts +1 -1
- package/src/tools/critique-prompt.ts +1 -1
- package/src/tools/model-index.ts +1 -1
- package/src/utils/file-lock.ts +1 -1
- package/src/utils/io.ts +1 -1
- package/src/utils/retry.ts +2 -2
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* Used for permanent cleanup of implementations that are no longer relevant.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
|
|
11
13
|
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
12
14
|
import { refreshPrincipleLifecycle } from '../core/principle-internalization/lifecycle-refresh.js';
|
|
13
15
|
import {
|
|
@@ -52,14 +54,14 @@ export function handleArchiveImplCommand(ctx: PluginCommandContext): PluginComma
|
|
|
52
54
|
// Subcommand: list
|
|
53
55
|
if (subcommand === 'list') {
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
|
|
56
58
|
return _handleListArchivable(stateDir, isZh);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
// Archive by ID
|
|
60
62
|
const targetId = subcommand;
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
|
|
63
65
|
return _handleArchiveImpl(workspaceDir, stateDir, targetId, isZh);
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -97,7 +99,7 @@ function _handleListArchivable(
|
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
|
|
101
103
|
function _handleArchiveImpl(
|
|
102
104
|
workspaceDir: string,
|
|
103
105
|
stateDir: string,
|
|
@@ -14,7 +14,7 @@ const TOOLS_TO_SCAN = [
|
|
|
14
14
|
{ name: 'shellcheck', cmd: ['shellcheck', '--version'] },
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
function scanEnvironment(wctx: WorkspaceContext): any {
|
|
19
19
|
const tools: Record<string, { available: boolean; version?: string }> = {};
|
|
20
20
|
|
package/src/commands/context.ts
CHANGED
|
@@ -46,7 +46,7 @@ function formatRouteRecommendations(
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
function buildEnglishOutput(
|
|
51
51
|
workspaceDir: string,
|
|
52
52
|
sessionId: string | null,
|
|
@@ -99,7 +99,7 @@ function buildEnglishOutput(
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
|
|
103
103
|
function buildChineseOutput(
|
|
104
104
|
workspaceDir: string,
|
|
105
105
|
sessionId: string | null,
|
package/src/commands/export.ts
CHANGED
|
@@ -46,12 +46,12 @@ export function handleExportCommand(ctx: PluginCommandContext): PluginCommandRes
|
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
text: zh
|
|
49
|
-
? `已导出 ORPO 决策点样本到 ${result.manifest!.exportPath},` +
|
|
50
|
-
`共 ${result.manifest!.sampleCount} 条,模型家族: ${result.manifest!.targetModelFamily},` +
|
|
51
|
-
`数据集指纹: ${result.manifest!.datasetFingerprint.substring(0, 16)}...`
|
|
52
|
-
: `Exported ORPO decision-point samples to ${result.manifest!.exportPath}, ` +
|
|
53
|
-
`${result.manifest!.sampleCount} samples, target: ${result.manifest!.targetModelFamily}, ` +
|
|
54
|
-
`dataset fingerprint: ${result.manifest!.datasetFingerprint.substring(0, 16)}...`,
|
|
49
|
+
? `已导出 ORPO 决策点样本到 ${result.manifest!.exportPath},` +
|
|
50
|
+
`共 ${result.manifest!.sampleCount} 条,模型家族: ${result.manifest!.targetModelFamily},` +
|
|
51
|
+
`数据集指纹: ${result.manifest!.datasetFingerprint.substring(0, 16)}...`
|
|
52
|
+
: `Exported ORPO decision-point samples to ${result.manifest!.exportPath}, ` +
|
|
53
|
+
`${result.manifest!.sampleCount} samples, target: ${result.manifest!.targetModelFamily}, ` +
|
|
54
|
+
`dataset fingerprint: ${result.manifest!.datasetFingerprint.substring(0, 16)}...`,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -538,7 +538,7 @@ Next steps:
|
|
|
538
538
|
}
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
-
|
|
541
|
+
|
|
542
542
|
let result: any;
|
|
543
543
|
try {
|
|
544
544
|
result = JSON.parse(resultJson);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
2
2
|
import type { PluginCommandContext } from '../openclaw-sdk.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
export function handlePrincipleRollbackCommand(ctx: PluginCommandContext): { text: string } {
|
|
6
6
|
const workspaceDir = (ctx.config?.workspaceDir as string) || process.cwd();
|
|
7
7
|
const argText = (ctx.args || '').trim();
|
package/src/commands/rollback.ts
CHANGED
package/src/commands/samples.ts
CHANGED
|
@@ -30,7 +30,7 @@ export function handleSamplesCommand(ctx: PluginCommandContext): PluginCommandRe
|
|
|
30
30
|
const normalizedDecision = decision === 'approve' ? 'approved' : 'rejected';
|
|
31
31
|
const note = noteParts.join(' ').trim();
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
let record;
|
|
35
35
|
try {
|
|
36
36
|
record = wctx.trajectory.reviewCorrectionSample(sampleId, normalizedDecision, note);
|
|
@@ -441,7 +441,7 @@ export function adjustThresholdsFromSignals(
|
|
|
441
441
|
currentThresholds.principleAlignmentMin + adjustment,
|
|
442
442
|
`High arbiter reject rate (${signals.arbiterRejectRate.toFixed(2)}) → tightening alignment threshold`
|
|
443
443
|
);
|
|
444
|
-
if (result.changed && (!bestResult.changed || ((result.newValue! - result.oldValue!) > 0))) {
|
|
444
|
+
if (result.changed && (!bestResult.changed || ((result.newValue! - result.oldValue!) > 0))) {
|
|
445
445
|
bestResult = result;
|
|
446
446
|
}
|
|
447
447
|
}
|
|
@@ -455,7 +455,7 @@ export function adjustThresholdsFromSignals(
|
|
|
455
455
|
currentThresholds.executabilityMin + adjustment,
|
|
456
456
|
`High executability reject rate (${signals.executabilityRejectRate.toFixed(2)}) → tightening executability threshold`
|
|
457
457
|
);
|
|
458
|
-
if (result.changed && (!bestResult.changed || ((result.newValue! - result.oldValue!) > 0))) {
|
|
458
|
+
if (result.changed && (!bestResult.changed || ((result.newValue! - result.oldValue!) > 0))) {
|
|
459
459
|
bestResult = result;
|
|
460
460
|
}
|
|
461
461
|
}
|
|
@@ -469,7 +469,7 @@ export function adjustThresholdsFromSignals(
|
|
|
469
469
|
Math.max(currentThresholds.aggregateMin - reward, THRESHOLD_MIN),
|
|
470
470
|
`Positive quality delta (${signals.qualityDelta.toFixed(2)}) → rewarding with slightly lower aggregate threshold`
|
|
471
471
|
);
|
|
472
|
-
if (result.changed && (!bestResult.changed || ((result.oldValue! - result.newValue!) > 0))) {
|
|
472
|
+
if (result.changed && (!bestResult.changed || ((result.oldValue! - result.newValue!) > 0))) {
|
|
473
473
|
bestResult = result;
|
|
474
474
|
}
|
|
475
475
|
}
|
package/src/core/config.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
import * as fs from 'fs';
|
|
2
3
|
import * as path from 'path';
|
|
3
4
|
import { atomicWriteFileSync } from '../utils/io.js';
|
|
@@ -265,7 +266,7 @@ export class PainConfig {
|
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
|
|
269
|
+
|
|
269
270
|
// Reason: deepMerge handles arbitrary nested object structures where static typing cannot precisely capture recursive object shapes
|
|
270
271
|
private deepMerge(target: any, source: any): any {
|
|
271
272
|
const output = { ...target };
|
package/src/core/dictionary.ts
CHANGED
package/src/core/event-log.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import type {
|
|
@@ -221,7 +221,7 @@ export class EventLog {
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
|
|
225
225
|
private updateStats(entry: EventLogEntry): void {
|
|
226
226
|
let stats = this.statsCache.get(entry.date);
|
|
227
227
|
if (!stats) {
|
|
@@ -500,7 +500,7 @@ export class EventLog {
|
|
|
500
500
|
/**
|
|
501
501
|
* Aggregate empathy stats for a specific session.
|
|
502
502
|
*/
|
|
503
|
-
|
|
503
|
+
|
|
504
504
|
private aggregateSessionEmpathy(sessionId: string, result: EmpathyEventStats): void {
|
|
505
505
|
for (const entry of this.getMergedEvents()) {
|
|
506
506
|
if (entry.sessionId === sessionId && entry.type === 'pain_signal') {
|
|
@@ -557,7 +557,7 @@ export function getEvolutionEngine(workspaceDir: string): EvolutionEngine {
|
|
|
557
557
|
if (!_instances.has(resolved)) {
|
|
558
558
|
_instances.set(resolved, new EvolutionEngine(resolved));
|
|
559
559
|
}
|
|
560
|
-
|
|
560
|
+
|
|
561
561
|
return _instances.get(resolved)!;
|
|
562
562
|
}
|
|
563
563
|
|
|
@@ -405,7 +405,7 @@ export function computeConfigFingerprint(config: Partial<TrainingHyperparameters
|
|
|
405
405
|
*/
|
|
406
406
|
export function computeDatasetFingerprint(exportPath: string, sampleCount: number): string {
|
|
407
407
|
|
|
408
|
-
|
|
408
|
+
|
|
409
409
|
let contentHash: string;
|
|
410
410
|
try {
|
|
411
411
|
const content = fs.readFileSync(exportPath, 'utf-8');
|
|
@@ -342,7 +342,7 @@ function hasValidEvidenceSummary(parsed: unknown): boolean {
|
|
|
342
342
|
* Validate a single replay report file and return its category.
|
|
343
343
|
*/
|
|
344
344
|
function validateSingleReplayReport(reportPath: string): ReplayValidationCategory {
|
|
345
|
-
|
|
345
|
+
|
|
346
346
|
let rawContent: string;
|
|
347
347
|
try {
|
|
348
348
|
rawContent = fs.readFileSync(reportPath, 'utf-8');
|
|
@@ -350,7 +350,7 @@ function validateSingleReplayReport(reportPath: string): ReplayValidationCategor
|
|
|
350
350
|
return 'io_error';
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
let parsed: unknown;
|
|
355
355
|
try {
|
|
356
356
|
parsed = JSON.parse(rawContent);
|
|
@@ -366,7 +366,7 @@ function validateSingleReplayReport(reportPath: string): ReplayValidationCategor
|
|
|
366
366
|
return 'missing_evidence_summary';
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
|
|
369
|
+
|
|
370
370
|
const evidenceSummary = parsed.evidenceSummary;
|
|
371
371
|
if (parsed.overallDecision === 'pass' && evidenceSummary.totalSamples === 0) {
|
|
372
372
|
return 'unsupported_pass';
|
|
@@ -242,31 +242,31 @@ export function detectOpportunity(principleId: string, session: SessionEvents):
|
|
|
242
242
|
|
|
243
243
|
switch (principleId) {
|
|
244
244
|
case 'T-01':
|
|
245
|
-
|
|
245
|
+
|
|
246
246
|
return detectT01Opportunity(session);
|
|
247
247
|
case 'T-02':
|
|
248
|
-
|
|
248
|
+
|
|
249
249
|
return detectT02Opportunity(session);
|
|
250
250
|
case 'T-03':
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
return detectT03Opportunity(session);
|
|
253
253
|
case 'T-04':
|
|
254
|
-
|
|
254
|
+
|
|
255
255
|
return detectT04Opportunity(session);
|
|
256
256
|
case 'T-05':
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
return detectT05Opportunity(session);
|
|
259
259
|
case 'T-06':
|
|
260
|
-
|
|
260
|
+
|
|
261
261
|
return detectT06Opportunity(session);
|
|
262
262
|
case 'T-07':
|
|
263
|
-
|
|
263
|
+
|
|
264
264
|
return detectT07Opportunity(session);
|
|
265
265
|
case 'T-08':
|
|
266
|
-
|
|
266
|
+
|
|
267
267
|
return detectT08Opportunity(session);
|
|
268
268
|
case 'T-09':
|
|
269
|
-
|
|
269
|
+
|
|
270
270
|
return detectT09Opportunity(session);
|
|
271
271
|
default:
|
|
272
272
|
return { applicable: false, reason: `Unknown principle: ${principleId}` };
|
|
@@ -384,7 +384,7 @@ function detectT05Opportunity(session: SessionEvents): OpportunityMatch {
|
|
|
384
384
|
if (RISKY_TOOLS.has(call.toolName)) return true;
|
|
385
385
|
// Check bash for dangerous patterns
|
|
386
386
|
if (call.toolName === 'bash' && call.errorMessage) {
|
|
387
|
-
|
|
387
|
+
|
|
388
388
|
return DANGEROUS_BASH_PATTERNS.some((p) => p.test(call.errorMessage!));
|
|
389
389
|
}
|
|
390
390
|
return false;
|
|
@@ -432,7 +432,7 @@ function detectT06Opportunity(session: SessionEvents): OpportunityMatch {
|
|
|
432
432
|
function detectT07Opportunity(session: SessionEvents): OpportunityMatch {
|
|
433
433
|
const filePaths = session.toolCalls
|
|
434
434
|
.filter((call) => call.filePath !== undefined)
|
|
435
|
-
|
|
435
|
+
|
|
436
436
|
.map((call) => normalizePathPosix(call.filePath!));
|
|
437
437
|
const uniqueFiles = new Set(filePaths);
|
|
438
438
|
if (uniqueFiles.size >= 3) {
|
|
@@ -478,7 +478,7 @@ function detectT09Opportunity(session: SessionEvents): OpportunityMatch {
|
|
|
478
478
|
const uniqueFiles = new Set(
|
|
479
479
|
session.toolCalls
|
|
480
480
|
.filter((call) => call.filePath !== undefined)
|
|
481
|
-
|
|
481
|
+
|
|
482
482
|
.map((call) => normalizePathPosix(call.filePath!))
|
|
483
483
|
);
|
|
484
484
|
const hasComplexity = toolCallCount >= 5 || uniqueFiles.size >= 3;
|
|
@@ -550,31 +550,31 @@ export function detectViolation(principleId: string, session: SessionEvents): Vi
|
|
|
550
550
|
|
|
551
551
|
switch (principleId) {
|
|
552
552
|
case 'T-01':
|
|
553
|
-
|
|
553
|
+
|
|
554
554
|
return detectT01Violation(session);
|
|
555
555
|
case 'T-02':
|
|
556
|
-
|
|
556
|
+
|
|
557
557
|
return detectT02Violation(session);
|
|
558
558
|
case 'T-03':
|
|
559
|
-
|
|
559
|
+
|
|
560
560
|
return detectT03Violation(session);
|
|
561
561
|
case 'T-04':
|
|
562
|
-
|
|
562
|
+
|
|
563
563
|
return detectT04Violation(session);
|
|
564
564
|
case 'T-05':
|
|
565
|
-
|
|
565
|
+
|
|
566
566
|
return detectT05Violation(session);
|
|
567
567
|
case 'T-06':
|
|
568
|
-
|
|
568
|
+
|
|
569
569
|
return detectT06Violation(session);
|
|
570
570
|
case 'T-07':
|
|
571
|
-
|
|
571
|
+
|
|
572
572
|
return detectT07Violation(session);
|
|
573
573
|
case 'T-08':
|
|
574
|
-
|
|
574
|
+
|
|
575
575
|
return detectT08Violation(session);
|
|
576
576
|
case 'T-09':
|
|
577
|
-
|
|
577
|
+
|
|
578
578
|
return detectT09Violation(session);
|
|
579
579
|
default:
|
|
580
580
|
console.warn(`[PD:Compliance] Unknown principle ID: ${principleId} — treating as no violation. Check for typos (P-001 vs P_001).`);
|
|
@@ -592,7 +592,7 @@ function detectT01Violation(session: SessionEvents): ViolationMatch {
|
|
|
592
592
|
const readFiles = new Set(
|
|
593
593
|
session.toolCalls
|
|
594
594
|
.filter((call) => READ_TOOLS.has(call.toolName) && call.filePath !== undefined)
|
|
595
|
-
|
|
595
|
+
|
|
596
596
|
.map((call) => normalizePathPosix(call.filePath!))
|
|
597
597
|
);
|
|
598
598
|
|
|
@@ -786,7 +786,7 @@ function detectT07Violation(session: SessionEvents): ViolationMatch {
|
|
|
786
786
|
const modifiedFiles = new Set(
|
|
787
787
|
session.toolCalls
|
|
788
788
|
.filter((call) => EDIT_TOOLS.has(call.toolName) && call.filePath !== undefined)
|
|
789
|
-
|
|
789
|
+
|
|
790
790
|
.map((call) => normalizePathPosix(call.filePath!))
|
|
791
791
|
);
|
|
792
792
|
|
|
@@ -843,7 +843,7 @@ function detectT09Violation(session: SessionEvents): ViolationMatch {
|
|
|
843
843
|
const uniqueFiles = new Set(
|
|
844
844
|
session.toolCalls
|
|
845
845
|
.filter((call) => call.filePath !== undefined)
|
|
846
|
-
|
|
846
|
+
|
|
847
847
|
.map((call) => normalizePathPosix(call.filePath!))
|
|
848
848
|
);
|
|
849
849
|
|
|
@@ -933,11 +933,11 @@ export function computeCompliance(
|
|
|
933
933
|
: 0;
|
|
934
934
|
|
|
935
935
|
// Compute violationTrend using windows
|
|
936
|
-
|
|
936
|
+
|
|
937
937
|
const violationTrend = computeViolationTrend(applicableSessions, windowSize);
|
|
938
938
|
|
|
939
939
|
// Build explanation
|
|
940
|
-
|
|
940
|
+
|
|
941
941
|
const explanation = buildExplanation(
|
|
942
942
|
principleId,
|
|
943
943
|
applicableOpportunityCount,
|
|
@@ -1009,7 +1009,7 @@ function computeViolationTrend(
|
|
|
1009
1009
|
* Builds a human-readable explanation for the compliance result.
|
|
1010
1010
|
*/
|
|
1011
1011
|
|
|
1012
|
-
|
|
1012
|
+
|
|
1013
1013
|
function buildExplanation(
|
|
1014
1014
|
principleId: string,
|
|
1015
1015
|
applicableOpportunityCount: number,
|
|
@@ -1086,7 +1086,7 @@ export function groupEventsIntoSessions(events: RawEventEntry[]): Map<string, Se
|
|
|
1086
1086
|
});
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
|
-
|
|
1089
|
+
|
|
1090
1090
|
const session = sessionMap.get(sessionId)!;
|
|
1091
1091
|
|
|
1092
1092
|
switch (event.type) {
|
|
@@ -278,7 +278,7 @@ function isTooGeneric(text: string): boolean {
|
|
|
278
278
|
* @param artifact - The validated artifact from arbiter (passed = true)
|
|
279
279
|
* @returns ExecutabilityResult
|
|
280
280
|
*/
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
export function validateExecutability(artifact: {
|
|
283
283
|
badDecision: string;
|
|
284
284
|
betterDecision: string;
|
|
@@ -144,7 +144,7 @@ export function deriveReasoningChain(assistantTurns: NocturnalAssistantTurn[]):
|
|
|
144
144
|
// Without thinking tags we cannot extract a genuine reasoning trace, so
|
|
145
145
|
// we fall back to 'low' rather than misleading the downstream pipeline
|
|
146
146
|
// with activation derived from non-thinking patterns in the response text.
|
|
147
|
-
|
|
147
|
+
|
|
148
148
|
let confidenceSignal: "high" | "medium" | "low";
|
|
149
149
|
if (thinkingContent.length === 0) {
|
|
150
150
|
confidenceSignal = 'low';
|
|
@@ -213,7 +213,7 @@ export function deriveDecisionPoints(
|
|
|
213
213
|
|
|
214
214
|
// Binary search: find rightmost assistant turn with createdAt < tcTime
|
|
215
215
|
const findBeforeTurn = (tcTime: number): NocturnalAssistantTurn | undefined => {
|
|
216
|
-
|
|
216
|
+
|
|
217
217
|
let lo = 0, hi = sortedTurns.length - 1, result: NocturnalAssistantTurn | undefined;
|
|
218
218
|
while (lo <= hi) {
|
|
219
219
|
const mid = (lo + hi) >>> 1;
|
|
@@ -236,9 +236,9 @@ export function deriveDecisionPoints(
|
|
|
236
236
|
: '';
|
|
237
237
|
|
|
238
238
|
// On failure, find next assistant turn after tool call
|
|
239
|
-
|
|
239
|
+
|
|
240
240
|
let afterReflection: string | undefined;
|
|
241
|
-
|
|
241
|
+
|
|
242
242
|
let confidenceDelta: number | undefined;
|
|
243
243
|
|
|
244
244
|
if (tc.outcome === 'failure') {
|
|
@@ -85,7 +85,7 @@ function extractHelperUsage(sourceCode: string): string[] {
|
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
function validateMeta(meta: unknown): RuleImplementationValidationFailure[] {
|
|
90
90
|
if (!meta || typeof meta !== 'object') {
|
|
91
91
|
return [
|
|
@@ -54,7 +54,7 @@ async function safeTail(filePath: string): Promise<string[]> {
|
|
|
54
54
|
try {
|
|
55
55
|
// Check existence and stats asynchronously
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
let stat: fs.Stats;
|
|
59
59
|
try {
|
|
60
60
|
stat = await fsPromises.stat(filePath);
|
|
@@ -237,7 +237,7 @@ export async function extractRecentConversation(
|
|
|
237
237
|
/**
|
|
238
238
|
* Extracts failed tool call context with argument correlation.
|
|
239
239
|
*/
|
|
240
|
-
|
|
240
|
+
|
|
241
241
|
export async function extractFailedToolContext(
|
|
242
242
|
sessionId: string,
|
|
243
243
|
agentId: string,
|
|
@@ -4,7 +4,7 @@ import { reconcilePDTasks } from './pd-task-reconciler.js';
|
|
|
4
4
|
export const PDTaskService: OpenClawPluginService = {
|
|
5
5
|
id: 'principles-disciple-task-manager',
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
async start(ctx: OpenClawPluginServiceContext): Promise<void> {
|
|
9
9
|
const {workspaceDir} = ctx;
|
|
10
10
|
if (!workspaceDir) {
|
|
@@ -38,7 +38,7 @@ export interface PrincipleLifecycleAssessment {
|
|
|
38
38
|
routeRecommendation: InternalizationRouteRecommendation;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
function createValueMetrics(
|
|
43
43
|
principle: PrincipleLifecycleEvidence,
|
|
44
44
|
adherence: PrincipleAdherenceResult,
|
|
@@ -63,7 +63,7 @@ export function createDefaultPrincipleState(principleId: string): PrincipleTrain
|
|
|
63
63
|
|
|
64
64
|
export function loadStore(stateDir: string): PrincipleTrainingStore {
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
return ledgerTrainingStore(stateDir);
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -77,7 +77,7 @@ export function saveStore(stateDir: string, store: PrincipleTrainingStore): void
|
|
|
77
77
|
|
|
78
78
|
export async function loadStoreAsync(stateDir: string): Promise<PrincipleTrainingStore> {
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
return ledgerTrainingStore(stateDir);
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -50,7 +50,7 @@ function trainingStateToTreePrinciple(
|
|
|
50
50
|
text: `Principle ${principleId}`, // Minimal text, will be enriched from PRINCIPLES.md if available
|
|
51
51
|
triggerPattern: '', // Unknown from legacy data
|
|
52
52
|
action: '', // Unknown from legacy data
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
status: mapInternalizationStatusToPrincipleStatus(state.internalizationStatus),
|
|
55
55
|
priority: 'P1', // Default priority
|
|
56
56
|
scope: 'general',
|
package/src/core/profile.ts
CHANGED
|
@@ -57,7 +57,7 @@ export const PROFILE_DEFAULTS = {
|
|
|
57
57
|
custom_guards: [] as { pattern: string; message: string; severity: string }[],
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
// Reason: normalizeProfile handles arbitrary JSON profile shapes where static typing cannot capture runtime field existence
|
|
62
62
|
export function normalizeProfile(rawProfile: any): any {
|
|
63
63
|
const defaults = JSON.parse(JSON.stringify(PROFILE_DEFAULTS));
|