@principles/host-runtime 4.11.0 → 5.0.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.
@@ -2,7 +2,6 @@ import fs from 'node:fs';
2
2
  import { buildRuleHostAction, buildToolSemanticRegistry, deriveToolHintsFromCanonicalKind, estimateLineChanges, mergeDecisions, normalizeRuleHostResult, SqliteConnection, UNAVAILABLE_RULE_CONTEXT, validateRuleContextV2, verifyPiArtifactRowDigest, RECOVERY_CONTROL_SURFACES, } from '@principles/core/runtime';
3
3
  import { buildRuleHostInput, isRuleHostEvaluableKind } from '@principles/core/runtime/internalization/rule-host-input-builder';
4
4
  import { classifyBashRisk } from '@principles/core/runtime/internalization/bash-risk';
5
- import { scanRetiredContractSymbols } from './legacy-rule-contract-symbols.js';
6
5
  import { recordDegradedEnforcement } from './degraded-enforcement-marker.js';
7
6
  import { createNodeRuleImplementationRuntime, MAX_ACTIVE_RULES, RULE_BATCH_SOURCE_BYTES, RULE_SOURCE_BYTES, } from './rule-implementation-runtime.js';
8
7
  import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
@@ -639,24 +638,6 @@ export function createProductionRuleHostGate(options = {}) {
639
638
  }
640
639
  const ruleId = typeof content.ruleId === 'string' ? content.ruleId : typeof row.source_rule_id === 'string' ? row.source_rule_id : artifactId;
641
640
  const principleId = typeof content.principleId === 'string' ? content.principleId : typeof row.source_principle_id === 'string' ? row.source_principle_id : ruleId;
642
- // Retired-contract backstop (2026-08-19; host-liveness correction
643
- // 2026-08-21):
644
- // persisted LIVE RuleCode that references removed RuleHost
645
- // contract symbols can never run safely against the new contract
646
- // — reads silently resolve to undefined and change owner-approved
647
- // behavior. The incompatible activation is therefore skipped and
648
- // surfaced with an actionable warning. It must not turn a runtime
649
- // compatibility defect into a host-wide deny; healthy sibling
650
- // rules continue to evaluate. The scan is a local copy (see
651
- // legacy-rule-contract-symbols.ts) so the published bundle keeps
652
- // working against the currently published core.
653
- const retiredSymbols = scanRetiredContractSymbols(content.implementationCode);
654
- if (retiredSymbols.length > 0) {
655
- const nextAction = 'migrate the RuleCode off the retired contract symbols or deactivate the activation, then re-approve a migrated rule';
656
- addWarning(warnings, `legacy_rule_contract_dependency: ${retiredSymbols.join(', ')} (activation=${activationId})`, nextAction);
657
- addFault(evaluationFaults, 'skipped', { ...faultSource, ruleId }, `legacy_rule_contract_dependency: ${retiredSymbols.join(', ')} (activation=${activationId})`, nextAction);
658
- continue;
659
- }
660
641
  const fallbackMeta = { name: activationId, version: '1', ruleId, coversCondition: 'all' };
661
642
  // PRI-1187: resolved for the observation-only mismatch signal; it
662
643
  // is attached to the candidate but never filters the batch.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "4.11.0",
3
+ "version": "5.0.0",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,7 +39,7 @@
39
39
  "lint": "eslint \"src/**/*.ts\""
40
40
  },
41
41
  "dependencies": {
42
- "@principles/core": "^9.0.0",
42
+ "@principles/core": "^10.0.0",
43
43
  "@principles/install-layout": "^0.12.0",
44
44
  "better-sqlite3": "^13.0.3",
45
45
  "js-yaml": "^5.4.3"
@@ -57,5 +57,5 @@
57
57
  "url": "git+https://github.com/csuzngjh/principles.git"
58
58
  },
59
59
  "license": "Apache-2.0",
60
- "gitHead": "1e6fc5c3f3083d24dc50a65c420609e21307d9d5"
60
+ "gitHead": "293825348a6f4a40cc561f6a59fc42c64d532766"
61
61
  }
@@ -1,20 +0,0 @@
1
- /**
2
- * Retired RuleHost contract symbol scan — host-runtime local copy.
3
- *
4
- * The shared canonical scanner lives in @principles/core
5
- * (internalization/legacy-rule-contract-scanner.ts) and is used by the
6
- * plugin, console, installer, and pd-cli. This module deliberately does NOT
7
- * import it: the published codex-adapter bundle installs host-runtime
8
- * against the CURRENTLY PUBLISHED @principles/core from the npm registry,
9
- * and a new runtime import would break clean installs until the next core
10
- * release (see tests/published-codex-adapter-bundle.test.ts — it enforces
11
- * exactly this constraint). Keep the symbol patterns in sync with the core
12
- * scanner; the host-runtime tests cover the same detection behavior.
13
- */
14
- /**
15
- * Conservative scan of persisted RuleCode source for retired RuleHost
16
- * contract symbols (field reads and helper calls). A hit means the rule must
17
- * NOT execute against the current contract — its reads would silently
18
- * resolve to undefined and change owner-approved behavior.
19
- */
20
- export declare function scanRetiredContractSymbols(implementationCode: string): string[];
@@ -1,124 +0,0 @@
1
- /**
2
- * Retired RuleHost contract symbol scan — host-runtime local copy.
3
- *
4
- * The shared canonical scanner lives in @principles/core
5
- * (internalization/legacy-rule-contract-scanner.ts) and is used by the
6
- * plugin, console, installer, and pd-cli. This module deliberately does NOT
7
- * import it: the published codex-adapter bundle installs host-runtime
8
- * against the CURRENTLY PUBLISHED @principles/core from the npm registry,
9
- * and a new runtime import would break clean installs until the next core
10
- * release (see tests/published-codex-adapter-bundle.test.ts — it enforces
11
- * exactly this constraint). Keep the symbol patterns in sync with the core
12
- * scanner; the host-runtime tests cover the same detection behavior.
13
- */
14
- // Helper-call form is listed before the bare-word form; the field pattern's
15
- // negative lookahead prevents one hasPlanFile( call reporting twice.
16
- const RETIRED_SYMBOL_PATTERNS = [
17
- { symbol: 'recentThinking', pattern: /\brecentThinking\b/ },
18
- { symbol: 'planStatus', pattern: /\bplanStatus\b/ },
19
- { symbol: 'getPlanStatus', pattern: /\bgetPlanStatus\s*\(/ },
20
- { symbol: 'hasPlanFileHelper', pattern: /\bhasPlanFile\s*\(/ },
21
- { symbol: 'hasPlanFile', pattern: /\bhasPlanFile\b(?!\s*\()/ },
22
- ];
23
- function maskNonExecutableText(source) {
24
- let state = 'code';
25
- let templateExpressionDepth = 0;
26
- let masked = '';
27
- for (let index = 0; index < source.length; index += 1) {
28
- const char = source[index] ?? '';
29
- const next = source[index + 1] ?? '';
30
- if (state === 'code') {
31
- if (templateExpressionDepth > 0 && char === '{') {
32
- templateExpressionDepth += 1;
33
- masked += char;
34
- }
35
- else if (templateExpressionDepth > 0 && char === '}') {
36
- templateExpressionDepth -= 1;
37
- masked += char;
38
- if (templateExpressionDepth === 0)
39
- state = 'template';
40
- }
41
- else if (char === '/' && next === '/') {
42
- masked += ' ';
43
- index += 1;
44
- state = 'line_comment';
45
- }
46
- else if (char === '/' && next === '*') {
47
- masked += ' ';
48
- index += 1;
49
- state = 'block_comment';
50
- }
51
- else if (char === "'") {
52
- masked += ' ';
53
- state = 'single_quote';
54
- }
55
- else if (char === '"') {
56
- masked += ' ';
57
- state = 'double_quote';
58
- }
59
- else if (char === '`') {
60
- masked += ' ';
61
- state = 'template';
62
- }
63
- else {
64
- masked += char;
65
- }
66
- continue;
67
- }
68
- if (state === 'line_comment') {
69
- masked += char === '\n' || char === '\r' ? char : ' ';
70
- if (char === '\n' || char === '\r')
71
- state = 'code';
72
- continue;
73
- }
74
- if (state === 'block_comment') {
75
- if (char === '*' && next === '/') {
76
- masked += ' ';
77
- index += 1;
78
- state = 'code';
79
- }
80
- else {
81
- masked += char === '\n' || char === '\r' ? char : ' ';
82
- }
83
- continue;
84
- }
85
- if (state === 'template' && char === '$' && next === '{') {
86
- masked += ' {';
87
- index += 1;
88
- templateExpressionDepth = 1;
89
- state = 'code';
90
- continue;
91
- }
92
- if (char === '\\') {
93
- masked += ' ';
94
- if (index + 1 < source.length) {
95
- masked += source[index + 1] === '\n' || source[index + 1] === '\r' ? source[index + 1] : ' ';
96
- index += 1;
97
- }
98
- continue;
99
- }
100
- const closesLiteral = (state === 'single_quote' && char === "'") ||
101
- (state === 'double_quote' && char === '"') ||
102
- (state === 'template' && char === '`');
103
- masked += char === '\n' || char === '\r' ? char : ' ';
104
- if (closesLiteral)
105
- state = 'code';
106
- }
107
- return masked;
108
- }
109
- /**
110
- * Conservative scan of persisted RuleCode source for retired RuleHost
111
- * contract symbols (field reads and helper calls). A hit means the rule must
112
- * NOT execute against the current contract — its reads would silently
113
- * resolve to undefined and change owner-approved behavior.
114
- */
115
- export function scanRetiredContractSymbols(implementationCode) {
116
- const executableSource = maskNonExecutableText(implementationCode);
117
- const symbols = [];
118
- for (const { symbol, pattern } of RETIRED_SYMBOL_PATTERNS) {
119
- if (pattern.test(executableSource)) {
120
- symbols.push(symbol);
121
- }
122
- }
123
- return symbols;
124
- }