@principles/host-runtime 0.3.1 → 0.3.3

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.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Evaluator Runtime Context — PRI-661: ONE builder for the deterministic
3
+ * adversarial-replay context every HOST-NEUTRAL evaluator entry uses.
4
+ *
5
+ * WHY THIS EXISTS: PR #1495 wired the shared consumer cycle (in-host
6
+ * auto-consumer / Codex worker) with production gateDeps + the host-threaded
7
+ * tool registry, but the host-neutral CLI entries kept divergent wiring:
8
+ *
9
+ * - `pd runtime internalization run-once --runner evaluator` assembled
10
+ * EvaluatorRunner with NO gateDeps at all — the deterministic adversarial
11
+ * replay was structurally unreachable (the code-bearing guard fails loud
12
+ * with an assembly defect instead of evaluating anything);
13
+ * - `pd runtime internalization run-rulehost` (rulehost-pipeline-runner)
14
+ * replayed through the bare sandbox gate — no workspace root, no host
15
+ * tool registry — so a rule could pass generation-time replay and fail
16
+ * the production activation gate on the SAME workspace (the exact
17
+ * drift class PRI-634-F closed everywhere else).
18
+ *
19
+ * WHAT THIS MODULE IS NOT: it is not a second tool registry and not a new
20
+ * authority. Host-threaded callers (the consumer cycle) keep passing their
21
+ * live in-memory registry — the running host IS the authority for its own
22
+ * session. Host-neutral callers omit it and the DURABLE workspace provenance
23
+ * (`.pd/host-tool-semantics/<hostKind>.json`, persisted by every host on
24
+ * startup) is resolved through the ONE resolver
25
+ * (`resolveWorkspaceHostToolSemantics`). Unresolvable provenance is a
26
+ * structured refusal — never a silent fallback to the core baseline (an
27
+ * existence check against baseline names is a forged proof; ERR-114).
28
+ *
29
+ * Parity contract (pinned by evaluator-runtime-context.test.ts and the
30
+ * run-once evaluator parity test): the same artifact + workspace + declared
31
+ * host produces the SAME deterministic replay verdict whether it travels the
32
+ * consumer cycle (live registry) or a CLI entry (durable declaration), because
33
+ * hosts persist the same mapping constants they pass in memory.
34
+ */
35
+ import { type RefinerRuleHostGateDeps, type ToolSemanticRegistry } from '@principles/core/runtime-v2';
36
+ export interface EvaluatorRuntimeContextInput {
37
+ /** Workspace root the replay normalizes paths against (projectDir). */
38
+ readonly workspaceDir: string;
39
+ /**
40
+ * Host-threaded callers pass their live registry here (consumer-cycle
41
+ * ports). Host-neutral CLI callers omit it — the durable workspace
42
+ * declaration is resolved instead.
43
+ */
44
+ readonly toolSemantics?: ToolSemanticRegistry;
45
+ }
46
+ export type EvaluatorRuntimeContextResolution = {
47
+ readonly ok: true;
48
+ readonly gateDeps: RefinerRuleHostGateDeps;
49
+ } | {
50
+ readonly ok: false;
51
+ readonly reason: string;
52
+ readonly nextAction: string;
53
+ };
54
+ /**
55
+ * Build the evaluator's deterministic replay context.
56
+ *
57
+ * Mirrors the consumer-cycle assembly (PRI-634 A1/A3):
58
+ * gateDeps: createProductionGateDeps({ toolSemantics, projectDir: workspaceDir })
59
+ * — gateDeps belongs to evaluator PRODUCTION semantics, never to host-optional
60
+ * capability, and always travels in the runner OPTIONS (second constructor
61
+ * argument), never the deps argument.
62
+ */
63
+ export declare function createEvaluatorRuntimeContext(input: EvaluatorRuntimeContextInput): EvaluatorRuntimeContextResolution;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Evaluator Runtime Context — PRI-661: ONE builder for the deterministic
3
+ * adversarial-replay context every HOST-NEUTRAL evaluator entry uses.
4
+ *
5
+ * WHY THIS EXISTS: PR #1495 wired the shared consumer cycle (in-host
6
+ * auto-consumer / Codex worker) with production gateDeps + the host-threaded
7
+ * tool registry, but the host-neutral CLI entries kept divergent wiring:
8
+ *
9
+ * - `pd runtime internalization run-once --runner evaluator` assembled
10
+ * EvaluatorRunner with NO gateDeps at all — the deterministic adversarial
11
+ * replay was structurally unreachable (the code-bearing guard fails loud
12
+ * with an assembly defect instead of evaluating anything);
13
+ * - `pd runtime internalization run-rulehost` (rulehost-pipeline-runner)
14
+ * replayed through the bare sandbox gate — no workspace root, no host
15
+ * tool registry — so a rule could pass generation-time replay and fail
16
+ * the production activation gate on the SAME workspace (the exact
17
+ * drift class PRI-634-F closed everywhere else).
18
+ *
19
+ * WHAT THIS MODULE IS NOT: it is not a second tool registry and not a new
20
+ * authority. Host-threaded callers (the consumer cycle) keep passing their
21
+ * live in-memory registry — the running host IS the authority for its own
22
+ * session. Host-neutral callers omit it and the DURABLE workspace provenance
23
+ * (`.pd/host-tool-semantics/<hostKind>.json`, persisted by every host on
24
+ * startup) is resolved through the ONE resolver
25
+ * (`resolveWorkspaceHostToolSemantics`). Unresolvable provenance is a
26
+ * structured refusal — never a silent fallback to the core baseline (an
27
+ * existence check against baseline names is a forged proof; ERR-114).
28
+ *
29
+ * Parity contract (pinned by evaluator-runtime-context.test.ts and the
30
+ * run-once evaluator parity test): the same artifact + workspace + declared
31
+ * host produces the SAME deterministic replay verdict whether it travels the
32
+ * consumer cycle (live registry) or a CLI entry (durable declaration), because
33
+ * hosts persist the same mapping constants they pass in memory.
34
+ */
35
+ import { createProductionGateDeps, } from '@principles/core/runtime-v2';
36
+ import { resolveWorkspaceHostToolSemantics } from './host-tool-semantic-resolver.js';
37
+ /**
38
+ * Build the evaluator's deterministic replay context.
39
+ *
40
+ * Mirrors the consumer-cycle assembly (PRI-634 A1/A3):
41
+ * gateDeps: createProductionGateDeps({ toolSemantics, projectDir: workspaceDir })
42
+ * — gateDeps belongs to evaluator PRODUCTION semantics, never to host-optional
43
+ * capability, and always travels in the runner OPTIONS (second constructor
44
+ * argument), never the deps argument.
45
+ */
46
+ export function createEvaluatorRuntimeContext(input) {
47
+ if (input.toolSemantics) {
48
+ return {
49
+ ok: true,
50
+ gateDeps: createProductionGateDeps({ projectDir: input.workspaceDir, toolSemantics: input.toolSemantics }),
51
+ };
52
+ }
53
+ const resolved = resolveWorkspaceHostToolSemantics(input.workspaceDir);
54
+ if (!resolved.ok) {
55
+ return { ok: false, reason: resolved.reason, nextAction: resolved.nextAction };
56
+ }
57
+ return {
58
+ ok: true,
59
+ gateDeps: createProductionGateDeps({ projectDir: input.workspaceDir, toolSemantics: resolved.registry }),
60
+ };
61
+ }
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './internalization-consumer-governance.js';
17
17
  export * from './internalization-consumer-cycle.js';
18
18
  export * from './host-tool-declaration.js';
19
19
  export * from './host-tool-semantic-resolver.js';
20
+ export * from './evaluator-runtime-context.js';
20
21
  export * from './workspace-telemetry-emitter.js';
21
22
  export * from './product-telemetry/consent-store.js';
22
23
  export * from './product-telemetry/eligibility.js';
package/dist/index.js CHANGED
@@ -21,6 +21,8 @@ export * from './internalization-consumer-cycle.js';
21
21
  // neutral consumers (pd-cli/pd-console) resolve through the ONE resolver.
22
22
  export * from './host-tool-declaration.js';
23
23
  export * from './host-tool-semantic-resolver.js';
24
+ // PRI-661: ONE evaluator replay-context builder for host-neutral CLI entries.
25
+ export * from './evaluator-runtime-context.js';
24
26
  // PRI-634 A3: workspace-scoped critical telemetry — canonical implementation
25
27
  // moved from openclaw-plugin so both hosts share ONE semantics.
26
28
  export * from './workspace-telemetry-emitter.js';
@@ -321,7 +321,18 @@ export async function runInternalizationConsumerCycle(workspaceDir, ports) {
321
321
  // Issue 2: forward effectiveConfig so runners can resolve feature flags
322
322
  // (e.g. `artificer_output_retry`) — mirrors the diagnostician wiring
323
323
  // (ADR-0019). Flag-off / absent = legacy behavior.
324
- const runnerOptions = { owner, runtimeKind, effectiveConfig: configResult.effective };
324
+ // PRI-670: also forward the profile-resolved timeout as the runner
325
+ // deadline — before, runtimeProfile.timeoutMs only reached the adapter as
326
+ // a per-request timeout and the runner deadline stayed hardcoded at 300s,
327
+ // so slow/local models could never finish dreamer/evaluator stages.
328
+ // runtimeConfigResult.timeoutMs is profile-first with a 300s default —
329
+ // behavior only changes for workspaces that declare a larger timeoutMs.
330
+ const runnerOptions = {
331
+ owner,
332
+ runtimeKind,
333
+ effectiveConfig: configResult.effective,
334
+ timeoutMs: runtimeConfigResult.timeoutMs,
335
+ };
325
336
  // PRI-634 A3: workspace-scoped telemetry sink for the evaluator runner.
326
337
  // Constructed here (per-wake, workspaceDir in scope) so events from THIS
327
338
  // workspace's runner are attributable to THIS workspace — a global
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@principles/core": "^1.74.1",
25
- "@principles/install-layout": "0.1.0",
25
+ "@principles/install-layout": "^0.2.0",
26
26
  "better-sqlite3": "^13.0.3",
27
27
  "js-yaml": "^5.2.0"
28
28
  },