@principles/host-runtime 0.14.0 → 0.14.1

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.
@@ -9,10 +9,6 @@ export interface ActivePrinciplePromptResult {
9
9
  warnings: string[];
10
10
  budget: number;
11
11
  truncated: boolean;
12
- excludedPrincipleIds: string[];
13
- excludedCount: number;
14
- exclusionReason?: 'host_principle_overlap';
15
- allValidatedPrinciplesExcluded: boolean;
16
12
  /** PRI-904: budget-packing policy that produced this selection. */
17
13
  selectionPolicy?: PromptSelectionPolicy;
18
14
  /** PRI-904: candidates that reached the budget selector. */
@@ -40,7 +36,6 @@ export interface ActivePrinciplePromptResult {
40
36
  }
41
37
  export interface PromptActivationCandidates {
42
38
  principles: ActivatedPrinciple[];
43
- excludedPrincipleIds: string[];
44
39
  warnings: string[];
45
40
  /** true = prompt flag off or state.db missing — candidates are necessarily empty */
46
41
  aborted: boolean;
@@ -50,16 +45,13 @@ export interface PromptActivationCandidates {
50
45
  /**
51
46
  * PR #1844 follow-up: the activation READ half of buildActivePrinciplePromptContext,
52
47
  * exported so the console budget projection can share the exact same input
53
- * selection (FIFO activations → artifact resolve → exclude partition) without
54
- * duplicating logic.
48
+ * selection (FIFO activations → artifact resolve) without duplicating logic.
55
49
  */
56
50
  export declare function readPromptActivationCandidates(input: {
57
51
  workspaceDir: string;
58
- excludePrincipleIds?: ReadonlySet<string>;
59
52
  }): Promise<PromptActivationCandidates>;
60
53
  export declare function buildActivePrinciplePromptContext(input: {
61
54
  workspaceDir: string;
62
- excludePrincipleIds?: ReadonlySet<string>;
63
55
  /**
64
56
  * PRI-904 fair-rotation round key (derive via roundKeyFromRunIdentity from
65
57
  * the host run/turn id). Absent → legacy FIFO prefix policy (rollback /
@@ -8,13 +8,11 @@ export const MAX_SHARED_DIAGNOSTIC_IDS = 16;
8
8
  /**
9
9
  * PR #1844 follow-up: the activation READ half of buildActivePrinciplePromptContext,
10
10
  * exported so the console budget projection can share the exact same input
11
- * selection (FIFO activations → artifact resolve → exclude partition) without
12
- * duplicating logic.
11
+ * selection (FIFO activations → artifact resolve) without duplicating logic.
13
12
  */
14
13
  export async function readPromptActivationCandidates(input) {
15
14
  const warnings = [];
16
15
  const principles = [];
17
- const excludedPrincipleIds = [];
18
16
  const config = loadPdConfigForPlugin(input.workspaceDir);
19
17
  if (!config.ok) {
20
18
  warnings.push(...config.errors.map((error) => `config_invalid: ${error.reason}; nextAction=${error.nextAction}`));
@@ -24,7 +22,7 @@ export async function readPromptActivationCandidates(input) {
24
22
  const abstractionLayerEnabled = flags.abstraction_layer_v1?.enabled === true;
25
23
  if (!promptFlag?.enabled) {
26
24
  warnings.push('prompt_feature_disabled; nextAction=set features.prompt.enabled=true in .pd/config.yaml');
27
- return { principles, excludedPrincipleIds, warnings, aborted: true, selfReportEnabled: false, abstractionLayerEnabled };
25
+ return { principles, warnings, aborted: true, selfReportEnabled: false, abstractionLayerEnabled };
28
26
  }
29
27
  // PRI-532: agent self-report instruction rides the directive template when
30
28
  // the flag is on (flag-off keeps the template byte-identical).
@@ -33,7 +31,7 @@ export async function readPromptActivationCandidates(input) {
33
31
  const stateDbPath = path.join(input.workspaceDir, '.pd', 'state.db');
34
32
  if (!fs.existsSync(stateDbPath)) {
35
33
  warnings.push('activation_db_not_found; nextAction=initialize_workspace_runtime_state');
36
- return { principles, excludedPrincipleIds, warnings, aborted: true, selfReportEnabled, abstractionLayerEnabled };
34
+ return { principles, warnings, aborted: true, selfReportEnabled, abstractionLayerEnabled };
37
35
  }
38
36
  try {
39
37
  connection = new SqliteConnection({ workspaceDir: input.workspaceDir, readonly: true, bootstrapIfMissing: false });
@@ -63,12 +61,7 @@ export async function readPromptActivationCandidates(input) {
63
61
  warnings.push(resolved.warning);
64
62
  continue;
65
63
  }
66
- if (input.excludePrincipleIds?.has(resolved.principle.principleId)) {
67
- excludedPrincipleIds.push(resolved.principle.principleId);
68
- }
69
- else {
70
- principles.push(resolved.principle);
71
- }
64
+ principles.push(resolved.principle);
72
65
  }
73
66
  }
74
67
  catch (error) {
@@ -78,19 +71,18 @@ export async function readPromptActivationCandidates(input) {
78
71
  finally {
79
72
  connection?.close();
80
73
  }
81
- return { principles, excludedPrincipleIds, warnings, aborted: false, selfReportEnabled, abstractionLayerEnabled };
74
+ return { principles, warnings, aborted: false, selfReportEnabled, abstractionLayerEnabled };
82
75
  }
83
76
  export async function buildActivePrinciplePromptContext(input) {
84
77
  // One resolution per request (SPEC §6.1): the caller's pre-resolved budget
85
78
  // or the fixed-fallback default — never a per-line constant read.
86
79
  const promptBudget = input.promptBudget ?? resolvePromptBudget();
87
80
  const { budgetChars } = promptBudget;
88
- const { principles, excludedPrincipleIds, warnings, aborted, selfReportEnabled } = await readPromptActivationCandidates(input);
81
+ const { principles, warnings, aborted, selfReportEnabled } = await readPromptActivationCandidates(input);
89
82
  if (aborted) {
90
83
  return {
91
84
  additionalContext: '', principleIds: [], activationIds: [], artifactIds: [], warnings,
92
- budget: budgetChars, truncated: false, excludedPrincipleIds,
93
- excludedCount: excludedPrincipleIds.length, allValidatedPrinciplesExcluded: false,
85
+ budget: budgetChars, truncated: false,
94
86
  selectionPolicy: 'legacy_fifo_prefix_v1', eligibleCount: 0,
95
87
  budgetCapacitySource: promptBudget.capacitySource,
96
88
  budgetCapacityStatus: promptBudget.capacityStatus,
@@ -110,9 +102,9 @@ export async function buildActivePrinciplePromptContext(input) {
110
102
  const { roundKey } = input;
111
103
  const selectionPolicy = roundKey === undefined || principles.length === 0 ? 'legacy_fifo_prefix_v1' : 'fair_rotation_v1';
112
104
  const n = principles.length;
113
- // Guard on the policy, not just the key: an all-excluded candidate list has
114
- // n === 0 and must not emit a NaN start (core trimToBudget omits the field
115
- // for empty input — parity requires the same here).
105
+ // Guard on the policy, not just the key: an empty candidate list has n === 0
106
+ // and must not emit a NaN start (core trimToBudget omits the field for empty
107
+ // input — parity requires the same here).
116
108
  const rotationStartIndex = selectionPolicy === 'fair_rotation_v1' && roundKey !== undefined
117
109
  ? ((roundKey % n) + n) % n
118
110
  : undefined;
@@ -156,10 +148,6 @@ export async function buildActivePrinciplePromptContext(input) {
156
148
  warnings,
157
149
  budget: budgetChars,
158
150
  truncated,
159
- excludedPrincipleIds,
160
- excludedCount: excludedPrincipleIds.length,
161
- allValidatedPrinciplesExcluded: excludedPrincipleIds.length > 0 && principles.length === 0,
162
- ...(excludedPrincipleIds.length > 0 ? { exclusionReason: 'host_principle_overlap' } : {}),
163
151
  selectionPolicy,
164
152
  eligibleCount: principles.length,
165
153
  ...(rotationStartIndex !== undefined ? { rotationStartIndex } : {}),
package/dist/index.d.ts CHANGED
@@ -63,7 +63,6 @@ export declare function createHostRuntime(options: HostRuntimeOptions): HostRunt
63
63
  export declare function createProductionHostRuntime(options?: Partial<Pick<HostRuntimeOptions, 'afterToolCall'>> & {
64
64
  beforeToolCall?: HostRuntimePort;
65
65
  beforePromptBuild?: (event: HostEvent, prompt: Awaited<ReturnType<typeof buildActivePrinciplePromptContext>>) => HostEventResult | Promise<HostEventResult>;
66
- promptExcludePrincipleIds?: (event: HostEvent) => ReadonlySet<string>;
67
66
  ruleContextProvider?: RuleContextProvider;
68
67
  ruleInputEnrichmentProvider?: RuleInputEnrichmentProvider;
69
68
  ruleImplementationRuntime?: RuleImplementationRuntime;
package/dist/index.js CHANGED
@@ -225,7 +225,6 @@ export function createProductionHostRuntime(options = {}) {
225
225
  : operatorDeclaredContextWindow(loadPdConfigForPlugin(event.context.workspaceDir).effective.config.promptBudget, promptBudgetHostKind);
226
226
  const prompt = await buildActivePrinciplePromptContext({
227
227
  workspaceDir: event.context.workspaceDir,
228
- excludePrincipleIds: options.promptExcludePrincipleIds?.(event),
229
228
  promptBudget: resolvePromptBudget({
230
229
  // SPEC-PD-MODEL-AWARE-PROMPT-BUDGET-001: resolve ONCE per request
231
230
  // from the host's own hook facts (OpenClaw effective window /
@@ -174,11 +174,6 @@ export interface PromptInjectionProjection {
174
174
  * `resolveLivePromptInjectionProjection`, which binds the route to real host
175
175
  * facts and refuses to guess).
176
176
  *
177
- * Known conservative gap: the plugin's legacy route additionally dedups
178
- * candidates against the legacy evolution ledger before trimming; the
179
- * console cannot replay that reducer read-only, so this projection may
180
- * forecast slightly MORE consumption than the real injection (never less).
181
- *
182
177
  * PR-1894 — round-key alignment. The plugin derives its fair-rotation round
183
178
  * key from the CURRENT session's turn ordinal (`nextSessionTurnOrdinal`),
184
179
  * which the console has no access to. Passing no key therefore does NOT make
@@ -190,7 +185,6 @@ export interface PromptInjectionProjection {
190
185
  */
191
186
  export declare function buildLivePromptInjectionProjection(input: {
192
187
  workspaceDir: string;
193
- excludePrincipleIds?: ReadonlySet<string>;
194
188
  /**
195
189
  * PR-1894: the fair-rotation round key the production route is using this
196
190
  * turn. Callers that hold one (the plugin) pass it; callers that do not
@@ -230,7 +224,6 @@ export type LivePromptInjectionProjectionResolution = {
230
224
  export declare function resolveLivePromptInjectionProjection(input: {
231
225
  workspaceDir: string;
232
226
  targetHost?: PromptInjectionTargetHost;
233
- excludePrincipleIds?: ReadonlySet<string>;
234
227
  roundKey?: number;
235
228
  /**
236
229
  * SPEC-PD-MODEL-AWARE-PROMPT-BUDGET-001 §6.1 / PRI-1017: budget resolution
@@ -208,11 +208,6 @@ function isDiagnosticCapHit(ids) {
208
208
  * `resolveLivePromptInjectionProjection`, which binds the route to real host
209
209
  * facts and refuses to guess).
210
210
  *
211
- * Known conservative gap: the plugin's legacy route additionally dedups
212
- * candidates against the legacy evolution ledger before trimming; the
213
- * console cannot replay that reducer read-only, so this projection may
214
- * forecast slightly MORE consumption than the real injection (never less).
215
- *
216
211
  * PR-1894 — round-key alignment. The plugin derives its fair-rotation round
217
212
  * key from the CURRENT session's turn ordinal (`nextSessionTurnOrdinal`),
218
213
  * which the console has no access to. Passing no key therefore does NOT make
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "lint": "eslint \"src/**/*.ts\""
32
32
  },
33
33
  "dependencies": {
34
- "@principles/core": "^1.297.3",
34
+ "@principles/core": "^1.297.4",
35
35
  "@principles/install-layout": "^0.4.0",
36
36
  "better-sqlite3": "^13.0.3",
37
37
  "js-yaml": "^5.4.3"