@principles/host-runtime 0.7.12 → 0.7.13
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/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,8 @@ export declare function createProductionHostRuntime(options?: Partial<Pick<HostR
|
|
|
66
66
|
painDatabaseFactory?: PainDatabaseFactory;
|
|
67
67
|
/** PRI-640: host attribution supplied by the constructing host adapter (OpenClaw / Codex). */
|
|
68
68
|
hostKind?: GovernanceHostKind;
|
|
69
|
+
/** Host project cwd, distinct from the workspace owning shared PD state. */
|
|
70
|
+
projectDir?: string;
|
|
69
71
|
/** PRI-634-F: host-declared tool semantics supplied by the constructing host adapter. */
|
|
70
72
|
toolSemantics?: ToolSemanticRegistry;
|
|
71
73
|
/**
|
package/dist/index.js
CHANGED
|
@@ -163,6 +163,7 @@ export function createHostRuntime(options) {
|
|
|
163
163
|
}
|
|
164
164
|
export function createProductionHostRuntime(options = {}) {
|
|
165
165
|
const productionGate = createProductionRuleHostGate({
|
|
166
|
+
...(options.projectDir ? { projectDir: options.projectDir } : {}),
|
|
166
167
|
...(options.ruleContextProvider ? { ruleContextProvider: options.ruleContextProvider } : {}),
|
|
167
168
|
...(options.ruleInputEnrichmentProvider ? { ruleInputEnrichmentProvider: options.ruleInputEnrichmentProvider } : {}),
|
|
168
169
|
...(options.ruleImplementationRuntime ? { implementationRuntime: options.ruleImplementationRuntime } : {}),
|
|
@@ -16,6 +16,7 @@ export interface RuleInputEnrichment {
|
|
|
16
16
|
}
|
|
17
17
|
export type RuleInputEnrichmentProvider = (request: ProductionRuleContextRequest) => unknown | Promise<unknown>;
|
|
18
18
|
export interface ProductionRuleHostGateOptions {
|
|
19
|
+
projectDir?: string;
|
|
19
20
|
ruleContextProvider?: RuleContextProvider;
|
|
20
21
|
ruleInputEnrichmentProvider?: RuleInputEnrichmentProvider;
|
|
21
22
|
implementationRuntime?: RuleImplementationRuntime;
|
|
@@ -81,7 +81,7 @@ export function createProductionRuleHostGate(options = {}) {
|
|
|
81
81
|
}
|
|
82
82
|
const canonicalKind = toolSemantics.resolve(input.toolName);
|
|
83
83
|
const { isBashTool: isBash, isWriteTool: isWrite } = deriveToolHintsFromCanonicalKind(canonicalKind);
|
|
84
|
-
const action = buildRuleHostAction(input.toolName, input.params, event.context.workspaceDir, { isBashTool: isBash, isWriteTool: isWrite, canonicalKind });
|
|
84
|
+
const action = buildRuleHostAction(input.toolName, input.params, options.projectDir ?? event.context.workspaceDir, { isBashTool: isBash, isWriteTool: isWrite, canonicalKind });
|
|
85
85
|
if (action.normalizedPath === null)
|
|
86
86
|
return { decision: 'allow', source: event.source, metadata: { evaluatedLiveRules: 0 } };
|
|
87
87
|
let context;
|
|
@@ -15,14 +15,14 @@ export interface PromptInjectionProjection {
|
|
|
15
15
|
injectedActivationIds: string[];
|
|
16
16
|
warnings: string[];
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* PR-1894: the budget-packing policy that produced THIS projection
|
|
19
19
|
* (`legacy_fifo_prefix_v1` | `fair_rotation_v1`). The console must not
|
|
20
20
|
* describe a fair-rotation workspace in FIFO terms, so the policy travels
|
|
21
21
|
* with the projection instead of being re-derived by each consumer.
|
|
22
22
|
*/
|
|
23
23
|
selectionPolicy: PromptSelectionPolicy;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* PR-1894: activations that the production route will inject under SOME
|
|
26
26
|
* round key, i.e. activations that are merely rotated out of the current
|
|
27
27
|
* window rather than structurally starved.
|
|
28
28
|
*
|
|
@@ -38,7 +38,7 @@ export interface PromptInjectionProjection {
|
|
|
38
38
|
/** Number of eligible candidates that reached the selector. */
|
|
39
39
|
eligibleCount: number;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* PR-1894: whether the PRODUCTION route for this workspace rotates.
|
|
42
42
|
* The forecast's own `selectionPolicy` answers "which policy did THIS
|
|
43
43
|
* projection run", which is legacy for a console that holds no session
|
|
44
44
|
* round key; this answers "will the agent's real injection rotate",
|
|
@@ -65,7 +65,7 @@ export interface PromptInjectionProjection {
|
|
|
65
65
|
* console cannot replay that reducer read-only, so this projection may
|
|
66
66
|
* forecast slightly MORE consumption than the real injection (never less).
|
|
67
67
|
*
|
|
68
|
-
*
|
|
68
|
+
* PR-1894 — round-key alignment. The plugin derives its fair-rotation round
|
|
69
69
|
* key from the CURRENT session's turn ordinal
|
|
70
70
|
* (`nextSessionTurnOrdinal`), which the console has no access to. Passing no
|
|
71
71
|
* key therefore does NOT make the forecast "more conservative": it selects a
|
|
@@ -79,7 +79,7 @@ export declare function buildLivePromptInjectionProjection(input: {
|
|
|
79
79
|
workspaceDir: string;
|
|
80
80
|
excludePrincipleIds?: ReadonlySet<string>;
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
82
|
+
* PR-1894: the fair-rotation round key the production route is using this
|
|
83
83
|
* turn. Callers that hold one (the plugin) pass it; callers that do not
|
|
84
84
|
* (the console) omit it and MUST read `selectionPolicy` off the result
|
|
85
85
|
* rather than assuming FIFO.
|
|
@@ -3,7 +3,7 @@ import { escapeXml } from '@principles/core/prompt-builder';
|
|
|
3
3
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
4
4
|
import { buildActivePrinciplePromptContext, readPromptActivationCandidates } from './active-principle-prompt.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* PR-1894: which activations a fair-rotation selector injects across the
|
|
7
7
|
* whole ring. The plugin's round key advances by one per recorded user turn
|
|
8
8
|
* within a continuously advancing session, so N consecutive turns cover all
|
|
9
9
|
* N ring positions: an activation absent from the current window but present
|
|
@@ -42,7 +42,7 @@ function collectReachableActivationIds(principles, budget) {
|
|
|
42
42
|
* console cannot replay that reducer read-only, so this projection may
|
|
43
43
|
* forecast slightly MORE consumption than the real injection (never less).
|
|
44
44
|
*
|
|
45
|
-
*
|
|
45
|
+
* PR-1894 — round-key alignment. The plugin derives its fair-rotation round
|
|
46
46
|
* key from the CURRENT session's turn ordinal
|
|
47
47
|
* (`nextSessionTurnOrdinal`), which the console has no access to. Passing no
|
|
48
48
|
* key therefore does NOT make the forecast "more conservative": it selects a
|
|
@@ -90,11 +90,11 @@ export async function buildLivePromptInjectionProjection(input) {
|
|
|
90
90
|
productionRotates: false,
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
//
|
|
93
|
+
// PR-1894: pass the caller's round key so the forecast runs the SAME
|
|
94
94
|
// packing policy production runs this turn.
|
|
95
95
|
const trimmed = trimToBudget(principles, RUNTIME_V2_PRINCIPLE_BUDGET, escapeXml, input.roundKey);
|
|
96
96
|
const injected = principles.filter((p) => trimmed.injectedIds.has(p.principleId));
|
|
97
|
-
//
|
|
97
|
+
// PR-1894: the legacy_trim route IS the OpenClaw plugin-local route, which
|
|
98
98
|
// rotates on every recorded user turn (PRI-904). Reachability is therefore
|
|
99
99
|
// computed under fair rotation regardless of whether THIS forecast holds a
|
|
100
100
|
// round key — a console without a session key must still be able to tell
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/host-runtime",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lint": "eslint \"src/**/*.ts\""
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@principles/core": "^1.
|
|
24
|
+
"@principles/core": "^1.289.0",
|
|
25
25
|
"@principles/install-layout": "^0.2.7",
|
|
26
26
|
"better-sqlite3": "^13.0.3",
|
|
27
27
|
"js-yaml": "^5.4.1"
|