create-principles-disciple 1.97.0 → 1.98.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/console/dist/server/models/ActivationsConsoleModel.js +29 -3
- package/console/dist/server/models/ApprovalsConsoleModel.d.ts +13 -0
- package/console/dist/server/models/ApprovalsConsoleModel.js +94 -3
- package/console/dist/web/assets/app.js +9 -5
- package/console/package.json +3 -3
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +5 -4
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/dreamer-runner.test.js +15 -2
- package/core/dist/runtime-v2/__tests__/dreamer-runner.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js +44 -0
- package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/activation-re-dispatch.test.d.ts +2 -0
- package/core/dist/runtime-v2/activation/__tests__/activation-re-dispatch.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/activation-re-dispatch.test.js +149 -0
- package/core/dist/runtime-v2/activation/__tests__/activation-re-dispatch.test.js.map +1 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js +72 -2
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.js +5 -0
- package/core/dist/runtime-v2/activation/activation-dispatcher.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.d.ts +1 -0
- package/core/dist/runtime-v2/activation/activation-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.js.map +1 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.js +6 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts +1 -0
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js +64 -10
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js +11 -8
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.js +8 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/principle-tree-ledger-adapter.test.d.ts +2 -0
- package/core/dist/runtime-v2/adapter/__tests__/principle-tree-ledger-adapter.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/adapter/__tests__/principle-tree-ledger-adapter.test.js +134 -0
- package/core/dist/runtime-v2/adapter/__tests__/principle-tree-ledger-adapter.test.js.map +1 -0
- package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.d.ts +15 -0
- package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.js +23 -1
- package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +1 -1
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +1 -1
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/split-diagnostician-runner-retry.test.js +113 -0
- package/core/dist/runtime-v2/internalization/__tests__/split-diagnostician-runner-retry.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/dreamer-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/dreamer-runner.js +4 -0
- package/core/dist/runtime-v2/internalization/dreamer-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.js +3 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/split-diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/split-diagnostician-runner.js +27 -0
- package/core/dist/runtime-v2/internalization/split-diagnostician-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization-chain-integrity-read-model.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js +4 -1
- package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js.map +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js +4 -0
- package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime-v2/types/event-types.d.ts +4 -0
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js +5 -0
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/mvp-config.js +1 -1
- package/dist/mvp-config.js.map +1 -1
- package/package.json +3 -3
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +71 -4
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +21 -0
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts +26 -0
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +307 -3
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/config-reader.js +1 -1
- package/pd-cli/dist/config-reader.js.map +1 -1
- package/pd-cli/dist/index.js +22 -1
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/services/pd-config-loader.js +1 -1
- package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/core/pd-config-loader.js +1 -1
- package/plugin/dist/core/rule-host.d.ts +22 -1
- package/plugin/dist/core/rule-host.js +107 -18
- package/plugin/dist/core/workflow-funnel-loader.js +2 -2
- package/plugin/dist/core/workspace-context.d.ts +4 -0
- package/plugin/dist/core/workspace-context.js +13 -0
- package/plugin/dist/hooks/gate.js +36 -50
- package/plugin/package.json +2 -2
|
@@ -8,11 +8,9 @@
|
|
|
8
8
|
* 1. Early Return: Skip if not write/bash/agent tool or no workspace
|
|
9
9
|
* 2. Rule Host: Dynamic principle-based evaluation (sole gate)
|
|
10
10
|
*/
|
|
11
|
-
import { normalizePath } from '../utils/io.js';
|
|
12
11
|
import { WorkspaceContext } from '../core/workspace-context.js';
|
|
13
12
|
import { recordGateBlockAndReturn } from './gate-block-helper.js';
|
|
14
|
-
import {
|
|
15
|
-
import { validateCorrectionProposal, validateProposedPathBounds, computeFeatureFlagsFromConfig, UNAVAILABLE_RULE_CONTEXT } from '@principles/core/runtime-v2';
|
|
13
|
+
import { buildRuleHostAction, validateCorrectionProposal, validateProposedPathBounds, computeFeatureFlagsFromConfig, UNAVAILABLE_RULE_CONTEXT } from '@principles/core/runtime-v2';
|
|
16
14
|
import { AGENT_TOOLS, BASH_TOOLS_SET, WRITE_TOOLS } from '../constants/tools.js';
|
|
17
15
|
import { getSession, hasRecentThinking } from '../core/session-tracker.js';
|
|
18
16
|
import { getEvolutionEngine } from '../core/evolution-engine.js';
|
|
@@ -30,41 +28,27 @@ export function handleBeforeToolCall(event, ctx) {
|
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
32
30
|
const wctx = WorkspaceContext.fromHookContext(ctx);
|
|
33
|
-
// 2.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
filePath = command;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Write tools without a file path must still go through RuleHost evaluation.
|
|
48
|
-
// Use a synthetic path so RuleHost can evaluate and potentially block.
|
|
49
|
-
if (!filePath && isWriteTool) {
|
|
50
|
-
filePath = `<tool:${event.toolName}>`;
|
|
51
|
-
}
|
|
52
|
-
if (typeof filePath !== 'string')
|
|
31
|
+
// 2. Use the same action builder as Golden Trace replay. This is the single
|
|
32
|
+
// path extraction + normalization contract for production and evaluation.
|
|
33
|
+
const action = buildRuleHostAction(event.toolName, event.params ?? {}, ctx.workspaceDir, {
|
|
34
|
+
isBashTool: isBash,
|
|
35
|
+
isWriteTool,
|
|
36
|
+
});
|
|
37
|
+
const relPath = action.normalizedPath;
|
|
38
|
+
// buildRuleHostAction returns null when no path can be extracted (e.g. bash
|
|
39
|
+
// command with no file target and no clear mutation operator). Mirror the
|
|
40
|
+
// legacy guard: no path → no gate evaluation, let the tool through.
|
|
41
|
+
if (relPath === null)
|
|
53
42
|
return;
|
|
54
|
-
const relPath = normalizePath(filePath, ctx.workspaceDir);
|
|
55
43
|
// 3. Rule Host Evaluation — sole gate
|
|
56
44
|
try {
|
|
57
|
-
const ruleHost =
|
|
45
|
+
const ruleHost = wctx.getRuleHost(logger);
|
|
58
46
|
// PRI-483 Phase 4: assemble RuleContextV2 when `rulecode_context_v2` flag is ON.
|
|
59
47
|
// flag OFF → undefined (v1 zero-change, no trajectory access).
|
|
60
48
|
// flag ON → RuleContextV2 (available or unavailable). Never throws (ERR-024).
|
|
61
49
|
const ruleContext = _buildRuleContextIfEnabled(wctx, relPath, ctx.sessionId, logger);
|
|
62
50
|
const hostInput = {
|
|
63
|
-
action
|
|
64
|
-
toolName: event.toolName,
|
|
65
|
-
normalizedPath: relPath,
|
|
66
|
-
paramsSummary: _extractParamsSummary(event.params ?? {}),
|
|
67
|
-
},
|
|
51
|
+
action,
|
|
68
52
|
workspace: {
|
|
69
53
|
isRiskPath: false, // Rule Host determines risk dynamically
|
|
70
54
|
// DEPRECATED (PRI-286): planStatus/hasPlanFile are legacy compatibility fields.
|
|
@@ -88,7 +72,27 @@ export function handleBeforeToolCall(event, ctx) {
|
|
|
88
72
|
},
|
|
89
73
|
context: ruleContext,
|
|
90
74
|
};
|
|
91
|
-
const
|
|
75
|
+
const report = typeof ruleHost.evaluateDetailed === 'function'
|
|
76
|
+
? ruleHost.evaluateDetailed(hostInput)
|
|
77
|
+
: { liveDecision: ruleHost.evaluate(hostInput), shadowDecisions: [] };
|
|
78
|
+
const hostResult = report.liveDecision;
|
|
79
|
+
for (const shadowDecision of report.shadowDecisions) {
|
|
80
|
+
try {
|
|
81
|
+
const eventLog = EventLogService.get(wctx.stateDir, logger);
|
|
82
|
+
eventLog.recordRuleHostEvaluated({
|
|
83
|
+
toolName: event.toolName,
|
|
84
|
+
filePath: relPath,
|
|
85
|
+
matched: shadowDecision.matched,
|
|
86
|
+
decision: shadowDecision.decision,
|
|
87
|
+
ruleId: shadowDecision.ruleId,
|
|
88
|
+
activationId: shadowDecision.activationId,
|
|
89
|
+
activationMode: 'shadow',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (evErr) {
|
|
93
|
+
logger?.warn?.(`[PD_GATE] Failed to record shadow rulehost_evaluated: ${String(evErr)}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
92
96
|
// Always emit rulehost_evaluated
|
|
93
97
|
try {
|
|
94
98
|
const eventLog = EventLogService.get(wctx.stateDir, logger);
|
|
@@ -98,6 +102,7 @@ export function handleBeforeToolCall(event, ctx) {
|
|
|
98
102
|
matched: hostResult?.matched ?? false,
|
|
99
103
|
decision: hostResult?.decision ?? 'allow',
|
|
100
104
|
ruleId: hostResult?.ruleId,
|
|
105
|
+
activationMode: 'live',
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
108
|
catch (evErr) {
|
|
@@ -321,25 +326,6 @@ export function handleBeforeToolCall(event, ctx) {
|
|
|
321
326
|
// ---------------------------------------------------------------------------
|
|
322
327
|
// Private helpers
|
|
323
328
|
// ---------------------------------------------------------------------------
|
|
324
|
-
function _extractParamsSummary(params) {
|
|
325
|
-
const summary = {};
|
|
326
|
-
// NOTE: Do NOT redact here — this feeds into RuleHost.evaluate() which
|
|
327
|
-
// may match against paramsSummary.command. Redaction happens at
|
|
328
|
-
// EventLog.record() before persistence.
|
|
329
|
-
if (params.file_path)
|
|
330
|
-
summary.file_path = params.file_path;
|
|
331
|
-
if (params.path)
|
|
332
|
-
summary.path = params.path;
|
|
333
|
-
if (params.command)
|
|
334
|
-
summary.command = params.command;
|
|
335
|
-
if (params.args)
|
|
336
|
-
summary.args = params.args;
|
|
337
|
-
if (params.old_string)
|
|
338
|
-
summary.old_string = params.old_string;
|
|
339
|
-
if (params.new_string)
|
|
340
|
-
summary.new_string = params.new_string;
|
|
341
|
-
return summary;
|
|
342
|
-
}
|
|
343
329
|
function _getCurrentGfi(sessionId) {
|
|
344
330
|
if (!sessionId)
|
|
345
331
|
return 0;
|
package/plugin/package.json
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/better-sqlite3": "^7.6.13",
|
|
58
58
|
"@types/js-yaml": "^4.0.9",
|
|
59
59
|
"@types/micromatch": "^4.0.10",
|
|
60
|
-
"@types/node": "^
|
|
60
|
+
"@types/node": "^26.0.1",
|
|
61
61
|
"@types/ws": "^8.5.13",
|
|
62
62
|
"@typescript-eslint/eslint-plugin": "^8.61.0",
|
|
63
63
|
"@typescript-eslint/parser": "^8.58.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@sinclair/typebox": "^0.34.48",
|
|
84
84
|
"better-sqlite3": "^12.9.0",
|
|
85
85
|
"commander": "^12.0.0",
|
|
86
|
-
"js-yaml": "^
|
|
86
|
+
"js-yaml": "^5.2.0",
|
|
87
87
|
"micromatch": "^4.0.8"
|
|
88
88
|
}
|
|
89
89
|
}
|