@principles/host-runtime 2.2.2 → 2.2.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.
- package/dist/active-principle-prompt.d.ts +1 -1
- package/dist/active-principle-prompt.js +1 -1
- package/dist/adaptive-journal-reconciliation.js +1 -1
- package/dist/adaptive-principle-revalidation.d.ts +1 -1
- package/dist/behavior-example-pack-assembler.d.ts +2 -2
- package/dist/behavior-example-pack-assembler.js +6 -6
- package/dist/behavior-history.d.ts +1 -1
- package/dist/behavior-history.js +1 -1
- package/dist/cli-recovery-probe.d.ts +1 -1
- package/dist/codex-artificer-trusted-facts.d.ts +1 -1
- package/dist/codex-rule-context-provider.d.ts +1 -1
- package/dist/codex-rule-context-provider.js +1 -1
- package/dist/codex-worker-status.js +1 -1
- package/dist/design-gate-facts.d.ts +1 -1
- package/dist/design-gate-facts.js +1 -1
- package/dist/evaluator-runtime-context.d.ts +1 -1
- package/dist/evaluator-runtime-context.js +1 -1
- package/dist/governance-observation-store.js +1 -1
- package/dist/governance-signal-admission.d.ts +2 -2
- package/dist/governance-signal-admission.js +3 -3
- package/dist/host-liveness-contract.d.ts +1 -1
- package/dist/host-tool-declaration.d.ts +1 -1
- package/dist/host-tool-declaration.js +1 -1
- package/dist/host-tool-semantic-resolver.d.ts +1 -1
- package/dist/host-tool-semantic-resolver.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/internalization-consumer-cycle.d.ts +2 -2
- package/dist/internalization-consumer-cycle.js +2 -2
- package/dist/internalization-consumer-governance.d.ts +1 -1
- package/dist/internalization-consumer-governance.js +1 -1
- package/dist/intervention-evidence-ingress.d.ts +1 -1
- package/dist/intervention-evidence-ingress.js +1 -1
- package/dist/pd-config.d.ts +1 -1
- package/dist/pd-config.js +1 -1
- package/dist/product-telemetry/consent-store.js +1 -1
- package/dist/product-telemetry/exporter.d.ts +1 -1
- package/dist/product-telemetry/milestone-readers.d.ts +1 -1
- package/dist/product-telemetry/service.d.ts +1 -1
- package/dist/product-telemetry/service.js +1 -1
- package/dist/product-telemetry/workspace-scope.js +1 -1
- package/dist/production-pain-evidence.d.ts +1 -1
- package/dist/production-pain-evidence.js +3 -3
- package/dist/production-rulehost-gate.d.ts +1 -1
- package/dist/production-rulehost-gate.js +3 -3
- package/dist/prompt-activation-authority.d.ts +1 -1
- package/dist/prompt-activation-deliverability.d.ts +1 -1
- package/dist/prompt-activation-deliverability.js +1 -1
- package/dist/prompt-injection-budget-observation.d.ts +16 -5
- package/dist/prompt-injection-budget-observation.js +23 -9
- package/dist/prompt-injection-projection.d.ts +1 -1
- package/dist/prompt-injection-projection.js +1 -1
- package/dist/prompt-injection-status.d.ts +1 -1
- package/dist/prompt-injection-status.js +1 -1
- package/dist/signal-classifier.d.ts +2 -2
- package/dist/signal-classifier.js +3 -3
- package/dist/workbuddy-rule-context-provider.d.ts +1 -1
- package/dist/workbuddy-rule-context-provider.js +1 -1
- package/dist/workbuddy-worker-status.js +1 -1
- package/dist/workspace-behavior-evidence.d.ts +1 -1
- package/dist/workspace-behavior-evidence.js +2 -2
- package/dist/workspace-telemetry-emitter.d.ts +1 -1
- package/dist/workspace-telemetry-emitter.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActivatedPrinciple, type PromptBudgetResolution, type PromptSelectionPolicy } from '@principles/core/runtime
|
|
1
|
+
import { type ActivatedPrinciple, type PromptBudgetResolution, type PromptSelectionPolicy } from '@principles/core/runtime';
|
|
2
2
|
/** PRI-904 SPEC §10: bounded diagnostic id lists (mirrors the core selector's cap of 16). */
|
|
3
3
|
export declare const MAX_SHARED_DIAGNOSTIC_IDS = 16;
|
|
4
4
|
export interface ActivePrinciplePromptResult {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SqliteActivationStateStore, SqliteConnection, SqlitePIArtifactStore, computeFeatureFlagsFromConfig, filterPromptActivations, renderPrinciplesToDirectives, resolvePrincipleFromArtifact, resolvePromptBudget, } from '@principles/core/runtime
|
|
1
|
+
import { SqliteActivationStateStore, SqliteConnection, SqlitePIArtifactStore, computeFeatureFlagsFromConfig, filterPromptActivations, renderPrinciplesToDirectives, resolvePrincipleFromArtifact, resolvePromptBudget, } from '@principles/core/runtime';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { escapeXml } from '@principles/core/prompt-builder';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
-
import { INTERVENTION_SHORT_SOURCE_RETENTION_DAYS, canonicalStringify, validateAdaptiveDeliveryRecord, } from '@principles/core/runtime
|
|
3
|
+
import { INTERVENTION_SHORT_SOURCE_RETENTION_DAYS, canonicalStringify, validateAdaptiveDeliveryRecord, } from '@principles/core/runtime';
|
|
4
4
|
/**
|
|
5
5
|
* PRI-1109 — conservative, read-only reconciliation of adaptive-delivery journal
|
|
6
6
|
* records (approved design: docs/specs/PD-AA-PRI-1109-JOURNAL-RECONCILE-DESIGN-v0.2.md).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PromptActivationCandidates } from './active-principle-prompt.js';
|
|
2
|
-
import type { ActivatedPrinciple } from '@principles/core/runtime
|
|
2
|
+
import type { ActivatedPrinciple } from '@principles/core/runtime';
|
|
3
3
|
export type AdaptivePrincipleReader = (input: {
|
|
4
4
|
workspaceDir: string;
|
|
5
5
|
}) => Promise<PromptActivationCandidates>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BehaviorExamplePack } from '@principles/core/runtime
|
|
1
|
+
import type { BehaviorExamplePack } from '@principles/core/runtime';
|
|
2
2
|
import type { RuleHostEvidenceRow, RuleHostContextRow } from '@principles/core/trajectory-types';
|
|
3
|
-
import type { ToolSemanticRegistry } from '@principles/core/runtime
|
|
3
|
+
import type { ToolSemanticRegistry } from '@principles/core/runtime';
|
|
4
4
|
export interface BehaviorExampleDataSource {
|
|
5
5
|
getPainEventByCanonicalId(id: string): {
|
|
6
6
|
id: number;
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
* Spec: docs/superpowers/specs/2026-06-27-rulecode-context-vision-design.md §7.2
|
|
21
21
|
*
|
|
22
22
|
* Boundary: this module is I/O. Pure logic (type + validator) lives in
|
|
23
|
-
* `@principles/core/runtime
|
|
23
|
+
* `@principles/core/runtime` → `behavior-example-pack.ts`.
|
|
24
24
|
*/
|
|
25
|
-
import { buildRuleHostAction } from '@principles/core/runtime
|
|
26
|
-
import { computeBehaviorFacts } from '@principles/core/runtime
|
|
27
|
-
import { validateBehaviorExamplePack } from '@principles/core/runtime
|
|
25
|
+
import { buildRuleHostAction } from '@principles/core/runtime/internalization/rule-host-input-builder';
|
|
26
|
+
import { computeBehaviorFacts } from '@principles/core/runtime/internalization/rule-context-v2';
|
|
27
|
+
import { validateBehaviorExamplePack } from '@principles/core/runtime/internalization/behavior-example-pack';
|
|
28
28
|
// Factory lives in evidence-readiness.ts (the classification authority); it is
|
|
29
29
|
// consumed through its registered LEAF subpath. A VALUE import of the
|
|
30
|
-
// runtime
|
|
30
|
+
// runtime barrel on this satellite path re-pulls the whole LLM graph and
|
|
31
31
|
// fails the satellite-purity guard (OPT-002, scripts/build/check-satellite-purity.mjs) —
|
|
32
32
|
// the leaf is on core's exports allowlist for exactly this consumer.
|
|
33
|
-
import { createOwnerEvidenceScopeError } from '@principles/core/runtime
|
|
33
|
+
import { createOwnerEvidenceScopeError } from '@principles/core/runtime/internalization/evidence-readiness';
|
|
34
34
|
import { assembleBehaviorHistory } from './behavior-history.js';
|
|
35
35
|
// ── internal constants ─────────────────────────────────────────────────────
|
|
36
36
|
const MAX_POSITIVES = 3;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuleHistoryWindow, ToolSemanticRegistry } from '@principles/core/runtime
|
|
1
|
+
import type { RuleHistoryWindow, ToolSemanticRegistry } from '@principles/core/runtime';
|
|
2
2
|
import type { RuleHostContextRow } from '@principles/core/trajectory-types';
|
|
3
3
|
export declare function assembleBehaviorHistory(rows: readonly RuleHostContextRow[], truncated: boolean, options: {
|
|
4
4
|
projectDir: string;
|
package/dist/behavior-history.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Shared validated history assembly; host vocabulary is supplied by its owner. */
|
|
2
|
-
import { buildRuleHostAction } from '@principles/core/runtime
|
|
2
|
+
import { buildRuleHostAction } from '@principles/core/runtime/internalization/rule-host-input-builder';
|
|
3
3
|
const VALID_OUTCOMES = new Set(['success', 'failure', 'blocked']);
|
|
4
4
|
function isPlainObject(value) {
|
|
5
5
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RecoveryCapabilityEvidence } from '@principles/core/runtime
|
|
1
|
+
import type { RecoveryCapabilityEvidence } from '@principles/core/runtime';
|
|
2
2
|
export declare const DEACTIVATE_DRY_RUN_PROBE_ACTIVATION_ID = "recovery-probe-nonexistent";
|
|
3
3
|
/**
|
|
4
4
|
* Resolve the built pd CLI entry for the CURRENT environment. Both layouts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArtificerTrustedFactsPort } from '@principles/core/runtime
|
|
1
|
+
import type { ArtificerTrustedFactsPort } from '@principles/core/runtime';
|
|
2
2
|
/**
|
|
3
3
|
* Codex generation can author rules against the same DesignGateFact schema
|
|
4
4
|
* that the native PreToolUse provider supplies. This declares capability only;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ToolSemanticRegistry } from '@principles/core/runtime
|
|
1
|
+
import { type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
2
2
|
import type { RuleContextProvider } from './production-rulehost-gate.js';
|
|
3
3
|
export interface CodexRuleContextProviderOptions {
|
|
4
4
|
/** The resolved PD workspace whose trajectory database is authoritative. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { computeBehaviorFacts, } from '@principles/core/runtime
|
|
2
|
+
import { computeBehaviorFacts, } from '@principles/core/runtime';
|
|
3
3
|
import { assembleBehaviorHistory } from './behavior-history.js';
|
|
4
4
|
import { readWorkspaceRuleContextRowsBefore } from './workspace-behavior-evidence.js';
|
|
5
5
|
import { readLatestCodexDesignGateDeclaration, resolveCodexDesignGateFact } from './design-gate-facts.js';
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import * as fs from 'node:fs';
|
|
16
16
|
import * as path from 'node:path';
|
|
17
17
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
18
|
-
import { computeFeatureFlagsFromConfig } from '@principles/core/runtime
|
|
18
|
+
import { computeFeatureFlagsFromConfig } from '@principles/core/runtime';
|
|
19
19
|
function directoryExists(dir) {
|
|
20
20
|
try {
|
|
21
21
|
return fs.statSync(dir).isDirectory();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DesignGateFact } from '@principles/core/runtime
|
|
1
|
+
import { type DesignGateFact } from '@principles/core/runtime';
|
|
2
2
|
export declare const DESIGN_GATE_FACT_KIND: 'design_approval';
|
|
3
3
|
export declare const DESIGN_GATE_FACT_INPUT_PATH: 'input.context.facts.designGate';
|
|
4
4
|
export declare const CODEX_DESIGN_GATE_SOURCE: 'codex-native-pretool-design-gate-v1';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { DESIGN_GATE_FACT_SCHEMA_VERSION, SqliteConnection, SqliteDesignGateStore, isDesignGateDeclaration, } from '@principles/core/runtime
|
|
4
|
+
import { DESIGN_GATE_FACT_SCHEMA_VERSION, SqliteConnection, SqliteDesignGateStore, isDesignGateDeclaration, } from '@principles/core/runtime';
|
|
5
5
|
export const DESIGN_GATE_FACT_KIND = 'design_approval';
|
|
6
6
|
export const DESIGN_GATE_FACT_INPUT_PATH = 'input.context.facts.designGate';
|
|
7
7
|
export const CODEX_DESIGN_GATE_SOURCE = 'codex-native-pretool-design-gate-v1';
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* consumer cycle (live registry) or a CLI entry (durable declaration), because
|
|
33
33
|
* hosts persist the same mapping constants they pass in memory.
|
|
34
34
|
*/
|
|
35
|
-
import { type RefinerRuleHostGateDeps, type ToolSemanticRegistry } from '@principles/core/runtime
|
|
35
|
+
import { type RefinerRuleHostGateDeps, type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
36
36
|
export interface EvaluatorRuntimeContextInput {
|
|
37
37
|
/** Workspace root the replay normalizes paths against (projectDir). */
|
|
38
38
|
readonly workspaceDir: string;
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* consumer cycle (live registry) or a CLI entry (durable declaration), because
|
|
33
33
|
* hosts persist the same mapping constants they pass in memory.
|
|
34
34
|
*/
|
|
35
|
-
import { createProductionGateDeps, } from '@principles/core/runtime
|
|
35
|
+
import { createProductionGateDeps, } from '@principles/core/runtime';
|
|
36
36
|
import { resolveWorkspaceHostToolSemantics } from './host-tool-semantic-resolver.js';
|
|
37
37
|
/**
|
|
38
38
|
* Build the evaluator's deterministic replay context.
|
|
@@ -28,7 +28,7 @@ import fs from 'node:fs';
|
|
|
28
28
|
import path from 'node:path';
|
|
29
29
|
import { createHash } from 'node:crypto';
|
|
30
30
|
import Database from 'better-sqlite3';
|
|
31
|
-
import { sanitizeString, sanitizeValue } from '@principles/core/runtime
|
|
31
|
+
import { sanitizeString, sanitizeValue } from '@principles/core/runtime';
|
|
32
32
|
// ─── Retention policy constants (Owner-approved, SPEC rev 2 §11) ────────────
|
|
33
33
|
export const GOVERNANCE_RETENTION_MAX_TURNS = 32;
|
|
34
34
|
export const GOVERNANCE_RETENTION_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LlmClassificationResult, type SignalCollectorOutput, type Stage2GateVerdict, type UnifiedKeywordStore } from '@principles/core/runtime
|
|
1
|
+
import { type LlmClassificationResult, type SignalCollectorOutput, type Stage2GateVerdict, type UnifiedKeywordStore } from '@principles/core/runtime';
|
|
2
2
|
import { type ObservationDatabaseFactory } from './governance-observation-store.js';
|
|
3
3
|
export declare const GOVERNANCE_STRONG_PAIN_SCORE = 70;
|
|
4
4
|
export declare const GOVERNANCE_STRONG_RATE_LIMIT_PER_HOUR = 5;
|
|
@@ -388,7 +388,7 @@ export interface ReconcileGovernanceContinuationResult {
|
|
|
388
388
|
}
|
|
389
389
|
/**
|
|
390
390
|
* Narrow idempotent reconciliation between the trajectory admission markers
|
|
391
|
-
* and the Runtime
|
|
391
|
+
* and the Runtime task store (separate SQLite databases — no cross-store
|
|
392
392
|
* transaction exists, SPEC §13). Current conversation-ingestion consent is
|
|
393
393
|
* mandatory because it controls whether Codex observations may be read and
|
|
394
394
|
* promoted; task/link recovery remains available when consent is off. Recovers:
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* process-local state dead state; OpenClaw's in-memory bucket and the
|
|
20
20
|
* tool-pain cooldown keep their existing behavior);
|
|
21
21
|
* - one admitted pain → exactly one pending Diagnostician task via
|
|
22
|
-
* PainToPrincipleService async mode (Runtime
|
|
22
|
+
* PainToPrincipleService async mode (Runtime task authority), with the
|
|
23
23
|
* task link persisted on the admission marker;
|
|
24
24
|
* - one narrow, idempotent reconciliation pass for the cross-store crash gaps
|
|
25
25
|
* (trajectory.db ↔ .pd/state.db cannot share a transaction).
|
|
@@ -35,7 +35,7 @@ import fs from 'node:fs';
|
|
|
35
35
|
import path from 'node:path';
|
|
36
36
|
import { randomUUID } from 'node:crypto';
|
|
37
37
|
import Database from 'better-sqlite3';
|
|
38
|
-
import { collectSync, computeFeatureFlagsFromConfig, CORRECTION_SEED_KEYWORDS, PainToPrincipleService, PrincipleTreeLedgerAdapter, RuntimeStateManager, createDiagnosticianTaskId, disposePainSignalBridgesForWorkspace, sanitizeString, boundCorrectionEvidenceText, MAX_EVIDENCE_VALUE_CHARS, evaluateStage2ConfidenceGate, evaluatePainIngress, migrateLegacyGfiSchema, STAGE2_MAX_ATTEMPTS, PENDING_CANDIDATE_TTL_MS, } from '@principles/core/runtime
|
|
38
|
+
import { collectSync, computeFeatureFlagsFromConfig, CORRECTION_SEED_KEYWORDS, PainToPrincipleService, PrincipleTreeLedgerAdapter, RuntimeStateManager, createDiagnosticianTaskId, disposePainSignalBridgesForWorkspace, sanitizeString, boundCorrectionEvidenceText, MAX_EVIDENCE_VALUE_CHARS, evaluateStage2ConfidenceGate, evaluatePainIngress, migrateLegacyGfiSchema, STAGE2_MAX_ATTEMPTS, PENDING_CANDIDATE_TTL_MS, } from '@principles/core/runtime';
|
|
39
39
|
import { deriveProductionCorrectionPainIdentity, hasProductionPainSchema, } from './production-pain-evidence.js';
|
|
40
40
|
import { promoteGovernanceEvidence, ensureGovernanceSchema } from './governance-observation-store.js';
|
|
41
41
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
@@ -1977,7 +1977,7 @@ export async function ensureGovernanceContinuation(input) {
|
|
|
1977
1977
|
}
|
|
1978
1978
|
/**
|
|
1979
1979
|
* Narrow idempotent reconciliation between the trajectory admission markers
|
|
1980
|
-
* and the Runtime
|
|
1980
|
+
* and the Runtime task store (separate SQLite databases — no cross-store
|
|
1981
1981
|
* transaction exists, SPEC §13). Current conversation-ingestion consent is
|
|
1982
1982
|
* mandatory because it controls whether Codex observations may be read and
|
|
1983
1983
|
* promoted; task/link recovery remains available when consent is off. Recovers:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HostLivenessContract } from '@principles/core/runtime
|
|
1
|
+
import type { HostLivenessContract } from '@principles/core/runtime';
|
|
2
2
|
/** Adapter-owned facts consumed by the non-bypassable RuleCode promotion gate. */
|
|
3
3
|
export declare const OPENCLAW_HOST_LIVENESS_CONTRACT: HostLivenessContract;
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* unknown and structurally validated (rc-1/rc-2/rc-4); malformed files fail
|
|
17
17
|
* loud with a typed per-host reason, never degrade silently (rc-3/rc-9).
|
|
18
18
|
*/
|
|
19
|
-
import { type ToolSemanticMappingV1 } from '@principles/core/runtime
|
|
19
|
+
import { type ToolSemanticMappingV1 } from '@principles/core/runtime';
|
|
20
20
|
export declare const HOST_TOOL_DECLARATION_DIRNAME = "host-tool-semantics";
|
|
21
21
|
export declare const HOST_TOOL_DECLARATION_VERSION: 1;
|
|
22
22
|
export interface HostToolDeclaration {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { readFileSync, writeFileSync, mkdirSync, mkdtempSync, renameSync, rmSync, readdirSync } from 'node:fs';
|
|
20
20
|
import path from 'node:path';
|
|
21
|
-
import { validateToolSemanticMappings, } from '@principles/core/runtime
|
|
21
|
+
import { validateToolSemanticMappings, } from '@principles/core/runtime';
|
|
22
22
|
export const HOST_TOOL_DECLARATION_DIRNAME = 'host-tool-semantics';
|
|
23
23
|
export const HOST_TOOL_DECLARATION_VERSION = 1;
|
|
24
24
|
const MAX_DECLARATION_BYTES = 256 * 1024;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
* Pure logic + declared-file I/O only. Merging is order-independent.
|
|
27
27
|
*/
|
|
28
|
-
import { type ToolSemanticRegistry } from '@principles/core/runtime
|
|
28
|
+
import { type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
29
29
|
import { saveHostToolDeclaration, type HostToolDeclaration } from './host-tool-declaration.js';
|
|
30
30
|
export type HostToolSemanticResolution = {
|
|
31
31
|
readonly ok: true;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
* Pure logic + declared-file I/O only. Merging is order-independent.
|
|
27
27
|
*/
|
|
28
|
-
import { buildToolSemanticRegistry, } from '@principles/core/runtime
|
|
28
|
+
import { buildToolSemanticRegistry, } from '@principles/core/runtime';
|
|
29
29
|
import { loadHostToolDeclarations, saveHostToolDeclaration, } from './host-tool-declaration.js';
|
|
30
30
|
/**
|
|
31
31
|
* Resolve the merged workspace registry from durable host provenance.
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { buildActivePrinciplePromptContext } from './active-principle-prompt.js'
|
|
|
3
3
|
import { type RuleContextProvider, type RuleInputEnrichmentProvider } from './production-rulehost-gate.js';
|
|
4
4
|
import type { RuleImplementationRuntime } from './rule-implementation-runtime.js';
|
|
5
5
|
import { type PainDatabaseFactory, type PainEnrichmentProvider } from './production-pain-evidence.js';
|
|
6
|
-
import type { GovernanceHostKind, ToolSemanticRegistry } from '@principles/core/runtime
|
|
6
|
+
import type { GovernanceHostKind, ToolSemanticRegistry } from '@principles/core/runtime';
|
|
7
7
|
export * from './active-principle-prompt.js';
|
|
8
8
|
export * from './prompt-activation-authority.js';
|
|
9
9
|
export * from './prompt-injection-projection.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { isHostEvent, isHostEventResult, } from '@principles/core/host';
|
|
3
|
-
import { getPromptModelCatalog, operatorDeclaredContextWindow, resolvePromptBudget } from '@principles/core/runtime
|
|
3
|
+
import { getPromptModelCatalog, operatorDeclaredContextWindow, resolvePromptBudget } from '@principles/core/runtime';
|
|
4
4
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
5
5
|
import { buildActivePrinciplePromptContext } from './active-principle-prompt.js';
|
|
6
6
|
import { createProductionRuleHostGate } from './production-rulehost-gate.js';
|
|
@@ -293,7 +293,7 @@ export function createProductionHostRuntime(options = {}) {
|
|
|
293
293
|
// observable warning (rc-9).
|
|
294
294
|
const emissionWarnings = [];
|
|
295
295
|
try {
|
|
296
|
-
options.events?.
|
|
296
|
+
options.events?.recordRuntimeActivationsInjected({
|
|
297
297
|
sessionId: event.context.sessionId,
|
|
298
298
|
workspaceDir: event.context.workspaceDir,
|
|
299
299
|
principleIds: prompt.principleIds,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* → runner construction (dreamer…rollout_reviewer) → runner.run
|
|
13
13
|
* → commit proposal → finally: recovery sweep + reconciliation budget
|
|
14
14
|
*
|
|
15
|
-
* The lease is acquired INSIDE runner.run by the Runtime
|
|
15
|
+
* The lease is acquired INSIDE runner.run by the Runtime lease manager
|
|
16
16
|
* (persisted in `<workspace>/.pd/state.db`, cross-process safe) — this cycle
|
|
17
17
|
* never leases by itself, so two schedulers (OpenClaw + Companion) racing on
|
|
18
18
|
* one workspace converge to exactly-once execution via lease_conflict.
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* Hosts inject: a logger, a structured-event sink, their tool catalog, and an
|
|
21
21
|
* env getter. Everything else is the existing production path.
|
|
22
22
|
*/
|
|
23
|
-
import { type ToolSemanticRegistry, type BehaviorEvidencePort, type ArtificerTrustedFactsPort } from '@principles/core/runtime
|
|
23
|
+
import { type ToolSemanticRegistry, type BehaviorEvidencePort, type ArtificerTrustedFactsPort } from '@principles/core/runtime';
|
|
24
24
|
import { type ConsumerGovernanceLogger } from './internalization-consumer-governance.js';
|
|
25
25
|
export declare const INTERNALIZATION_AUTO_CONSUMER_FLAG_ID = "internalization_auto_consumer";
|
|
26
26
|
/** Structural logger port — OpenClaw PluginLogger and worker loggers satisfy this. */
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* → runner construction (dreamer…rollout_reviewer) → runner.run
|
|
13
13
|
* → commit proposal → finally: recovery sweep + reconciliation budget
|
|
14
14
|
*
|
|
15
|
-
* The lease is acquired INSIDE runner.run by the Runtime
|
|
15
|
+
* The lease is acquired INSIDE runner.run by the Runtime lease manager
|
|
16
16
|
* (persisted in `<workspace>/.pd/state.db`, cross-process safe) — this cycle
|
|
17
17
|
* never leases by itself, so two schedulers (OpenClaw + Companion) racing on
|
|
18
18
|
* one workspace converge to exactly-once execution via lease_conflict.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import { createRuntimeStateHandle, InternalizationOrchestrator, DreamerRunner, PhilosopherRunner, ScribeRunner, ArtificerRunner, buildArtificerHostSemanticContext, EvaluatorRunner, RolloutReviewerRunner, DefaultDreamerValidator, DefaultPhilosopherValidator, DefaultScribeValidator, DefaultArtificerValidator, DefaultEvaluatorValidator, DefaultRolloutReviewerValidator, PiAiRuntimeAdapter, L2AgentLoopAdapter, ArtificerL2Adapter, buildL2PrincipleReaderFromLedger, storeEmitter, createProductionGateDeps, resolveRuntimeConfigFromPdConfig, resolveRuntimeConfigForAgent, AGENT_NAME_FOR_TASK_KIND, isRuntimeConfigError, computeConsumerDecision, FULL_CHAIN_CONSUMER_RUNNER_KINDS, DEFAULT_CONSUMER_RUNNER_KINDS, InternalizationQueueReadModel, MVP_CORE_TASK_KINDS, SqliteConnection, SqliteReconciliationCursorStore, SUCCEEDED_TRANSITIONS_SCOPE, PrincipleTreeLedgerAdapter,
|
|
24
24
|
// PRI-714: resolve outputLanguage from the same effective config the
|
|
25
25
|
// runners already receive (EP-07: canonical resolved value, not raw input).
|
|
26
|
-
resolveOutputLanguage, hydratePITaskRecord, preflightArtificerOwnerEvidence, preflightArtificerIntentBasis, consumeSourceFaultBackoffSkip, advanceSourceFaultBackoff, } from '@principles/core/runtime
|
|
26
|
+
resolveOutputLanguage, hydratePITaskRecord, preflightArtificerOwnerEvidence, preflightArtificerIntentBasis, consumeSourceFaultBackoffSkip, advanceSourceFaultBackoff, } from '@principles/core/runtime';
|
|
27
27
|
import { loadLedger } from '@principles/core/principle-tree-ledger';
|
|
28
28
|
import { loadPdConfigForPlugin, loadFeatureFlagFromConfig } from './pd-config.js';
|
|
29
29
|
import { createEvaluatorRepairDeps, createRolloutGovernanceDeps } from './internalization-consumer-governance.js';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* dedupes by `${artifactId}::${channel}`; reopen idempotency is owned by
|
|
15
15
|
* orchestrator.reopenTaskForRevision.
|
|
16
16
|
*/
|
|
17
|
-
import { type RolloutAutoDispatchInput, type RolloutAutoDispatchOutcome, type RolloutRevisionRoutingInput, type SeedArtificerRepairParams, type RuntimeStateManager, type InternalizationOrchestrator, type ToolSemanticRegistry } from '@principles/core/runtime
|
|
17
|
+
import { type RolloutAutoDispatchInput, type RolloutAutoDispatchOutcome, type RolloutRevisionRoutingInput, type SeedArtificerRepairParams, type RuntimeStateManager, type InternalizationOrchestrator, type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
18
18
|
/** Structural logger port — PluginLogger satisfies this without adaptation. */
|
|
19
19
|
export interface ConsumerGovernanceLogger {
|
|
20
20
|
info?: (msg: string) => void;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* dedupes by `${artifactId}::${channel}`; reopen idempotency is owned by
|
|
15
15
|
* orchestrator.reopenTaskForRevision.
|
|
16
16
|
*/
|
|
17
|
-
import { ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, SqliteConnection, SqliteActivationStateStore, SqliteApprovalQueueStore, SqlitePIArtifactStore, PrincipleTreeLedgerAdapter, createProductionGateDeps, createPITaskDiagnosticJson, artificerRepairTaskId, computeFeatureFlagsFromConfig, isFeatureEnabled, } from '@principles/core/runtime
|
|
17
|
+
import { ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, SqliteConnection, SqliteActivationStateStore, SqliteApprovalQueueStore, SqlitePIArtifactStore, PrincipleTreeLedgerAdapter, createProductionGateDeps, createPITaskDiagnosticJson, artificerRepairTaskId, computeFeatureFlagsFromConfig, isFeatureEnabled, } from '@principles/core/runtime';
|
|
18
18
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
19
19
|
function normalizeDecision(decision) {
|
|
20
20
|
if (decision.decision === 'activated') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type InterventionActivationOccurrenceRef, type InterventionContentRef, type InterventionEvidenceBatchInput } from '@principles/core/runtime
|
|
1
|
+
import { type InterventionActivationOccurrenceRef, type InterventionContentRef, type InterventionEvidenceBatchInput } from '@principles/core/runtime';
|
|
2
2
|
export interface InterventionIngressAppendResult {
|
|
3
3
|
ok: boolean;
|
|
4
4
|
insertedCount?: number;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import { createHash } from 'node:crypto';
|
|
22
22
|
import { isAbsolute, resolve } from 'node:path';
|
|
23
23
|
import { realpathSync } from 'node:fs';
|
|
24
|
-
import { normalizeInterventionEvidenceBatch, SqliteConnection, SqliteInterventionEvidenceStore, } from '@principles/core/runtime
|
|
24
|
+
import { normalizeInterventionEvidenceBatch, SqliteConnection, SqliteInterventionEvidenceStore, } from '@principles/core/runtime';
|
|
25
25
|
function isRecord(value) {
|
|
26
26
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
27
27
|
}
|
package/dist/pd-config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EffectivePdConfig } from '@principles/core/runtime
|
|
1
|
+
import { type EffectivePdConfig } from '@principles/core/runtime';
|
|
2
2
|
export declare const PD_CONFIG_DIR = ".pd";
|
|
3
3
|
export declare const PD_CONFIG_FILENAME = "config.yaml";
|
|
4
4
|
export interface PluginConfigLoadResult {
|
package/dist/pd-config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import * as yaml from 'js-yaml';
|
|
4
|
-
import { computeEffectivePdConfig, computeFeatureFlagsFromConfig, validatePdConfig, } from '@principles/core/runtime
|
|
4
|
+
import { computeEffectivePdConfig, computeFeatureFlagsFromConfig, validatePdConfig, } from '@principles/core/runtime';
|
|
5
5
|
export const PD_CONFIG_DIR = '.pd';
|
|
6
6
|
export const PD_CONFIG_FILENAME = 'config.yaml';
|
|
7
7
|
export function getPdConfigPath(workspaceDir) {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import fs from 'node:fs';
|
|
24
24
|
import path from 'node:path';
|
|
25
|
-
import { generateTelemetrySecretHex, isValidBucketDate, isValidTelemetrySecretHex, PRODUCT_TELEMETRY_CONSENT_VERSION, } from '@principles/core/runtime
|
|
25
|
+
import { generateTelemetrySecretHex, isValidBucketDate, isValidTelemetrySecretHex, PRODUCT_TELEMETRY_CONSENT_VERSION, } from '@principles/core/runtime';
|
|
26
26
|
export const PRODUCT_TELEMETRY_STATE_FILENAME = 'product-telemetry.json';
|
|
27
27
|
export const PRODUCT_TELEMETRY_CONTROL_SCHEMA_VERSION = '2';
|
|
28
28
|
/** v1 files are still read (then migrated in memory and rewritten as v2). */
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Failure mapping is coarse (SPEC §34): codes only, never messages, stacks,
|
|
7
7
|
* or response bodies. The injectable fetchFn keeps unit tests offline.
|
|
8
8
|
*/
|
|
9
|
-
import type { ProductTelemetrySnapshotV1 } from '@principles/core/runtime
|
|
9
|
+
import type { ProductTelemetrySnapshotV1 } from '@principles/core/runtime';
|
|
10
10
|
export declare const DEFAULT_PRODUCT_TELEMETRY_ENDPOINT = "https://principles-website.pages.dev/api/product-telemetry/snapshot";
|
|
11
11
|
export declare const PRODUCT_TELEMETRY_TIMEOUT_MS = 8000;
|
|
12
12
|
export declare const PRODUCT_TELEMETRY_MAX_BODY_BYTES = 4096;
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* Every connection is closed before return (leaked handles would block
|
|
47
47
|
* Windows file cleanup and accumulate in the gateway process).
|
|
48
48
|
*/
|
|
49
|
-
import type { ProductTelemetryMilestoneInput, TelemetryFact } from '@principles/core/runtime
|
|
49
|
+
import type { ProductTelemetryMilestoneInput, TelemetryFact } from '@principles/core/runtime';
|
|
50
50
|
export interface MilestoneFacts extends ProductTelemetryMilestoneInput {
|
|
51
51
|
initializationFailed: TelemetryFact;
|
|
52
52
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* lock are workspace-scope. One workspace's success/backoff/lock never
|
|
17
17
|
* suppresses another workspace on the same installation.
|
|
18
18
|
*/
|
|
19
|
-
import { type ProductTelemetrySnapshotV1 } from '@principles/core/runtime
|
|
19
|
+
import { type ProductTelemetrySnapshotV1 } from '@principles/core/runtime';
|
|
20
20
|
import { type ProductTelemetryConsent } from './consent-store.js';
|
|
21
21
|
import { type TelemetrySuppressionReason } from './eligibility.js';
|
|
22
22
|
import { type TelemetryFetchFn } from './exporter.js';
|
|
@@ -20,7 +20,7 @@ import fs from 'node:fs';
|
|
|
20
20
|
import os from 'node:os';
|
|
21
21
|
import path from 'node:path';
|
|
22
22
|
import { fileURLToPath } from 'node:url';
|
|
23
|
-
import { bucketDateFromTime, buildProductTelemetrySnapshot, deriveDailyTelemetryId, isValidTelemetrySecretHex, } from '@principles/core/runtime
|
|
23
|
+
import { bucketDateFromTime, buildProductTelemetrySnapshot, deriveDailyTelemetryId, isValidTelemetrySecretHex, } from '@principles/core/runtime';
|
|
24
24
|
import { getInstallLayoutPaths, parseInstallManifest, resolveInstallLayout } from '@principles/install-layout';
|
|
25
25
|
import { loadFeatureFlagFromConfig, loadPdConfigForPlugin } from '../pd-config.js';
|
|
26
26
|
import { deniedControlState, defaultProductTelemetryControlState, getProductTelemetryStatePath, grantedControlState, pruneWorkspaceExports, readProductTelemetryControlState, resetControlState, writeProductTelemetryControlState, } from './consent-store.js';
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import fs from 'node:fs';
|
|
21
21
|
import path from 'node:path';
|
|
22
|
-
import { deriveWorkspaceScopeId } from '@principles/core/runtime
|
|
22
|
+
import { deriveWorkspaceScopeId } from '@principles/core/runtime';
|
|
23
23
|
/**
|
|
24
24
|
* Canonicalize a workspace directory for scope derivation.
|
|
25
25
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Database from 'better-sqlite3';
|
|
2
|
-
import type { GovernanceHostKind } from '@principles/core/runtime
|
|
2
|
+
import type { GovernanceHostKind } from '@principles/core/runtime';
|
|
3
3
|
import type { HostEvent, HostEventEmitter, HostEventResult } from '@principles/core/host';
|
|
4
4
|
export interface ProductionPainEnrichment {
|
|
5
5
|
/** Stable host-supplied occurrence identity for the tool call. */
|
|
@@ -2,10 +2,10 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
|
-
import { applyTrajectorySchemaBase, migrateLegacyGfiSchema, sanitizeToolParams, sanitizeValue, } from '@principles/core/runtime
|
|
5
|
+
import { applyTrajectorySchemaBase, migrateLegacyGfiSchema, sanitizeToolParams, sanitizeValue, } from '@principles/core/runtime';
|
|
6
6
|
// PRI-1135: the canonical column declaration lives with the DDL owner. Import
|
|
7
|
-
// the subpath directly so the public runtime
|
|
8
|
-
import { TRAJECTORY_REQUIRED_COLUMNS } from '@principles/core/runtime
|
|
7
|
+
// the subpath directly so the public runtime barrel surface stays unchanged.
|
|
8
|
+
import { TRAJECTORY_REQUIRED_COLUMNS } from '@principles/core/runtime/trajectory-schema';
|
|
9
9
|
const MAX_PREVIEW = 500;
|
|
10
10
|
function isRecord(value) {
|
|
11
11
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ToolSemanticRegistry, type GovernanceHostKind } from '@principles/core/runtime
|
|
1
|
+
import { type ToolSemanticRegistry, type GovernanceHostKind } from '@principles/core/runtime';
|
|
2
2
|
import type { HostEvent, HostEventResult } from '@principles/core/host';
|
|
3
3
|
import { type RuleImplementationRuntime } from './rule-implementation-runtime.js';
|
|
4
4
|
export interface ProductionRuleContextRequest {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { buildRuleHostAction, buildToolSemanticRegistry, deriveToolHintsFromCanonicalKind, estimateLineChanges, mergeDecisions, SqliteConnection, UNAVAILABLE_RULE_CONTEXT, validateRuleContextV2, validateRuleHostResult, verifyPiArtifactRowDigest, RECOVERY_CONTROL_SURFACES, } from '@principles/core/runtime
|
|
4
|
-
import { isSensitiveSystemPath } from '@principles/core/runtime
|
|
5
|
-
import { classifyBashRisk } from '@principles/core/runtime
|
|
3
|
+
import { buildRuleHostAction, buildToolSemanticRegistry, deriveToolHintsFromCanonicalKind, estimateLineChanges, mergeDecisions, SqliteConnection, UNAVAILABLE_RULE_CONTEXT, validateRuleContextV2, validateRuleHostResult, verifyPiArtifactRowDigest, RECOVERY_CONTROL_SURFACES, } from '@principles/core/runtime';
|
|
4
|
+
import { isSensitiveSystemPath } from '@principles/core/runtime/internalization/rule-host-input-builder';
|
|
5
|
+
import { classifyBashRisk } from '@principles/core/runtime/internalization/bash-risk';
|
|
6
6
|
import { scanRetiredContractSymbols } from './legacy-rule-contract-symbols.js';
|
|
7
7
|
import { recordDegradedEnforcement } from './degraded-enforcement-marker.js';
|
|
8
8
|
import { createNodeRuleImplementationRuntime, MAX_ACTIVE_RULES, RULE_BATCH_SOURCE_BYTES, RULE_SOURCE_BYTES, } from './rule-implementation-runtime.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActivatedPrinciple, type PromptBudgetTierFit } from '@principles/core/runtime
|
|
1
|
+
import { type ActivatedPrinciple, type PromptBudgetTierFit } from '@principles/core/runtime';
|
|
2
2
|
import { PROMPT_INJECTION_UNIT, type PromptInjectionBudgetScope, type PromptInjectionRouteDecision, type PromptInjectionRouteName, type PromptInjectionTargetHost } from './prompt-injection-projection.js';
|
|
3
3
|
/**
|
|
4
4
|
* SPEC PD_PROMPT_CAPACITY_V1 R-B2: ONE route-aware single-artifact capacity
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { PROMPT_BUDGET_FALLBACK_CHARS, PROMPT_BUDGET_MAX_CHARS, PROMPT_BUDGET_MIN_CHARS, SqliteConnection, SqlitePIArtifactStore, classifySingleItemBudgetTier, computeFeatureFlagsFromConfig, listEntryLine, renderPrinciplesToDirectives, resolvePrincipleFromArtifact, trimToBudget, } from '@principles/core/runtime
|
|
3
|
+
import { PROMPT_BUDGET_FALLBACK_CHARS, PROMPT_BUDGET_MAX_CHARS, PROMPT_BUDGET_MIN_CHARS, SqliteConnection, SqlitePIArtifactStore, classifySingleItemBudgetTier, computeFeatureFlagsFromConfig, listEntryLine, renderPrinciplesToDirectives, resolvePrincipleFromArtifact, trimToBudget, } from '@principles/core/runtime';
|
|
4
4
|
import { escapeXml } from '@principles/core/prompt-builder';
|
|
5
5
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
6
6
|
import { PROMPT_INJECTION_TARGET_HOSTS, PROMPT_INJECTION_UNIT, promptRouteForHost, resolvePromptInjectionRouteDecision, } from './prompt-injection-projection.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PROMPT_BUDGET_POLICY_VERSION, type PromptBudgetCapacitySource, type PromptBudgetCapacityStatus, type PromptBudgetFallbackReason, type PromptBudgetResolution, type PromptBudgetConfig } from '@principles/core/runtime
|
|
1
|
+
import { PROMPT_BUDGET_POLICY_VERSION, type PromptBudgetCapacitySource, type PromptBudgetCapacityStatus, type PromptBudgetFallbackReason, type PromptBudgetResolution, type PromptBudgetConfig } from '@principles/core/runtime';
|
|
2
2
|
import { type PromptInjectionTargetHost } from './prompt-injection-projection.js';
|
|
3
3
|
/**
|
|
4
4
|
* PRI-1017: runtime budget OBSERVATION read model over the EXISTING
|
|
@@ -37,21 +37,32 @@ import { type PromptInjectionTargetHost } from './prompt-injection-projection.js
|
|
|
37
37
|
* other event payloads are not cached.
|
|
38
38
|
*/
|
|
39
39
|
/**
|
|
40
|
-
* Candidate directories for the runtime
|
|
40
|
+
* Candidate directories for the runtime event log, in priority order.
|
|
41
41
|
* Shared with the RuleCode telemetry collector (ERR-031: both readers derive
|
|
42
42
|
* from one list — the v1 EventLog writer emits `.state/logs`, no production
|
|
43
43
|
* code ever created `.pd/logs`).
|
|
44
44
|
*/
|
|
45
|
+
export declare const RUNTIME_EVENT_LOG_CANDIDATE_DIRS: readonly string[];
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use `RUNTIME_EVENT_LOG_CANDIDATE_DIRS`.
|
|
48
|
+
*
|
|
49
|
+
* PRI-1136 renamed this exported constant, and `src/index.ts` re-exports it
|
|
50
|
+
* through `export *`, so it is part of the package's public root API. Removing
|
|
51
|
+
* the old name in a patch release would break external consumers that
|
|
52
|
+
* `import { RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS } from '@principles/host-runtime'`.
|
|
53
|
+
* The alias is the exact same frozen array (not a copy) and will be removed in
|
|
54
|
+
* the next major release.
|
|
55
|
+
*/
|
|
45
56
|
export declare const RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS: readonly string[];
|
|
46
57
|
/**
|
|
47
58
|
* Bounded I/O: only the most recent daily files are scanned — PER candidate
|
|
48
|
-
* log directory (`
|
|
59
|
+
* log directory (`RUNTIME_EVENT_LOG_CANDIDATE_DIRS`), not globally. The
|
|
49
60
|
* cap is deliberately per directory: both directories describe the same
|
|
50
61
|
* workspace's log convention and either can hold the newest event for a given
|
|
51
62
|
* host (the reader takes latest-wins ACROSS them), so a global cap would let
|
|
52
63
|
* one directory's files starve the other and drop a live host observation.
|
|
53
64
|
* Worst case per read is therefore `RUNTIME_BUDGET_OBSERVATION_MAX_FILES ×
|
|
54
|
-
*
|
|
65
|
+
* RUNTIME_EVENT_LOG_CANDIDATE_DIRS.length` files (14 today) and the same
|
|
55
66
|
* count × `RUNTIME_BUDGET_OBSERVATION_MAX_FILE_BYTES` bytes (56 MiB today).
|
|
56
67
|
*/
|
|
57
68
|
export declare const RUNTIME_BUDGET_OBSERVATION_MAX_FILES = 7;
|
|
@@ -125,7 +136,7 @@ export type RuntimeBudgetObservationSelection = {
|
|
|
125
136
|
};
|
|
126
137
|
/**
|
|
127
138
|
* Read the most recent budget observation per host from the workspace's
|
|
128
|
-
* runtime
|
|
139
|
+
* runtime event logs. Never throws: an unreadable log directory degrades
|
|
129
140
|
* to an empty report with an explicit note (absence is UNKNOWN, not zero).
|
|
130
141
|
*/
|
|
131
142
|
export declare function readRuntimePromptBudgetObservations(input: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { PROMPT_BUDGET_POLICY_VERSION,
|
|
3
|
+
import { PROMPT_BUDGET_POLICY_VERSION, RUNTIME_PRINCIPLE_BUDGET, isValidContextWindowTokens, promptBudgetCharsForContextWindow, resolvePromptBudget, operatorDeclaredContextWindow, } from '@principles/core/runtime';
|
|
4
4
|
import { isPromptInjectionTargetHost, } from './prompt-injection-projection.js';
|
|
5
5
|
/**
|
|
6
6
|
* PRI-1104 Stage 0 (expand): accepted budget policy provenance versions.
|
|
@@ -68,21 +68,32 @@ function isAcceptedBudgetPolicyVersion(value) {
|
|
|
68
68
|
* other event payloads are not cached.
|
|
69
69
|
*/
|
|
70
70
|
/**
|
|
71
|
-
* Candidate directories for the runtime
|
|
71
|
+
* Candidate directories for the runtime event log, in priority order.
|
|
72
72
|
* Shared with the RuleCode telemetry collector (ERR-031: both readers derive
|
|
73
73
|
* from one list — the v1 EventLog writer emits `.state/logs`, no production
|
|
74
74
|
* code ever created `.pd/logs`).
|
|
75
75
|
*/
|
|
76
|
-
export const
|
|
76
|
+
export const RUNTIME_EVENT_LOG_CANDIDATE_DIRS = ['.pd/logs', '.state/logs'];
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated Use `RUNTIME_EVENT_LOG_CANDIDATE_DIRS`.
|
|
79
|
+
*
|
|
80
|
+
* PRI-1136 renamed this exported constant, and `src/index.ts` re-exports it
|
|
81
|
+
* through `export *`, so it is part of the package's public root API. Removing
|
|
82
|
+
* the old name in a patch release would break external consumers that
|
|
83
|
+
* `import { RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS } from '@principles/host-runtime'`.
|
|
84
|
+
* The alias is the exact same frozen array (not a copy) and will be removed in
|
|
85
|
+
* the next major release.
|
|
86
|
+
*/
|
|
87
|
+
export const RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS = RUNTIME_EVENT_LOG_CANDIDATE_DIRS;
|
|
77
88
|
/**
|
|
78
89
|
* Bounded I/O: only the most recent daily files are scanned — PER candidate
|
|
79
|
-
* log directory (`
|
|
90
|
+
* log directory (`RUNTIME_EVENT_LOG_CANDIDATE_DIRS`), not globally. The
|
|
80
91
|
* cap is deliberately per directory: both directories describe the same
|
|
81
92
|
* workspace's log convention and either can hold the newest event for a given
|
|
82
93
|
* host (the reader takes latest-wins ACROSS them), so a global cap would let
|
|
83
94
|
* one directory's files starve the other and drop a live host observation.
|
|
84
95
|
* Worst case per read is therefore `RUNTIME_BUDGET_OBSERVATION_MAX_FILES ×
|
|
85
|
-
*
|
|
96
|
+
* RUNTIME_EVENT_LOG_CANDIDATE_DIRS.length` files (14 today) and the same
|
|
86
97
|
* count × `RUNTIME_BUDGET_OBSERVATION_MAX_FILE_BYTES` bytes (56 MiB today).
|
|
87
98
|
*/
|
|
88
99
|
export const RUNTIME_BUDGET_OBSERVATION_MAX_FILES = 7;
|
|
@@ -229,7 +240,7 @@ function narrowObservation(parsed, workspaceDir, nowMs) {
|
|
|
229
240
|
return null;
|
|
230
241
|
if (!isBudgetFallbackReason(rawReason))
|
|
231
242
|
return null;
|
|
232
|
-
if (budget !==
|
|
243
|
+
if (budget !== RUNTIME_PRINCIPLE_BUDGET)
|
|
233
244
|
return null;
|
|
234
245
|
}
|
|
235
246
|
return {
|
|
@@ -253,7 +264,10 @@ function narrowObservation(parsed, workspaceDir, nowMs) {
|
|
|
253
264
|
function readBoundedLogText(filePath) {
|
|
254
265
|
let fd;
|
|
255
266
|
try {
|
|
256
|
-
|
|
267
|
+
// Read-only open. The mode is explicit anyway: this path can be derived
|
|
268
|
+
// from a temp-dir workspace, and an explicit 0600 keeps the file
|
|
269
|
+
// owner-only if this call is ever changed to a creating flag.
|
|
270
|
+
fd = fs.openSync(filePath, 'r', 0o600);
|
|
257
271
|
}
|
|
258
272
|
catch {
|
|
259
273
|
return null;
|
|
@@ -291,7 +305,7 @@ function readBoundedLogText(filePath) {
|
|
|
291
305
|
}
|
|
292
306
|
/**
|
|
293
307
|
* Read the most recent budget observation per host from the workspace's
|
|
294
|
-
* runtime
|
|
308
|
+
* runtime event logs. Never throws: an unreadable log directory degrades
|
|
295
309
|
* to an empty report with an explicit note (absence is UNKNOWN, not zero).
|
|
296
310
|
*/
|
|
297
311
|
export function readRuntimePromptBudgetObservations(input) {
|
|
@@ -304,7 +318,7 @@ export function readRuntimePromptBudgetObservations(input) {
|
|
|
304
318
|
const foreignPolicyEventsSkipped = { count: 0 };
|
|
305
319
|
const truncatedFiles = { count: 0 };
|
|
306
320
|
const latest = new Map();
|
|
307
|
-
for (const candidate of
|
|
321
|
+
for (const candidate of RUNTIME_EVENT_LOG_CANDIDATE_DIRS) {
|
|
308
322
|
const logsRoot = path.resolve(workspaceDir, ...candidate.split('/'));
|
|
309
323
|
if (!fs.existsSync(logsRoot))
|
|
310
324
|
continue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PromptBudgetResolution, type PromptSelectionPolicy } from '@principles/core/runtime
|
|
1
|
+
import { type PromptBudgetResolution, type PromptSelectionPolicy } from '@principles/core/runtime';
|
|
2
2
|
/** Hosts with a production prompt-injection path today (shared GovernanceHostKind boundary). */
|
|
3
3
|
export type PromptInjectionTargetHost = 'openclaw' | 'codex' | 'workbuddy';
|
|
4
4
|
/** Single host roster (review P2): every consumer derives from this list, so a
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computeFeatureFlagsFromConfig, renderPrinciplesToDirectives, resolvePromptBudget, trimToBudget, } from '@principles/core/runtime
|
|
1
|
+
import { computeFeatureFlagsFromConfig, renderPrinciplesToDirectives, resolvePromptBudget, trimToBudget, } from '@principles/core/runtime';
|
|
2
2
|
import { escapeXml } from '@principles/core/prompt-builder';
|
|
3
3
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
4
4
|
import { buildActivePrinciplePromptContext, readPromptActivationCandidates, MAX_SHARED_DIAGNOSTIC_IDS } from './active-principle-prompt.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PromptBudgetCapacitySource, type PromptBudgetCapacityStatus, type PromptBudgetFallbackReason, type PromptBudgetResolution, type PromptBudgetTierFit } from '@principles/core/runtime
|
|
1
|
+
import { type PromptBudgetCapacitySource, type PromptBudgetCapacityStatus, type PromptBudgetFallbackReason, type PromptBudgetResolution, type PromptBudgetTierFit } from '@principles/core/runtime';
|
|
2
2
|
import { type PromptInjectionBudgetScope, type PromptInjectionRouteDecision, type PromptInjectionRouteName, type PromptInjectionTargetHost } from './prompt-injection-projection.js';
|
|
3
3
|
/**
|
|
4
4
|
* SPEC PD_PROMPT_CAPACITY_V1 R-A3: per-live-activation injection status for
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { PROMPT_BUDGET_MAX_CHARS, PROMPT_BUDGET_MIN_CHARS, SqliteActivationStateStore, SqliteConnection, SqlitePIArtifactStore, classifySingleItemBudgetTier, computeFeatureFlagsFromConfig, filterPromptActivations, resolvePrincipleFromArtifact, } from '@principles/core/runtime
|
|
3
|
+
import { PROMPT_BUDGET_MAX_CHARS, PROMPT_BUDGET_MIN_CHARS, SqliteActivationStateStore, SqliteConnection, SqlitePIArtifactStore, classifySingleItemBudgetTier, computeFeatureFlagsFromConfig, filterPromptActivations, resolvePrincipleFromArtifact, } from '@principles/core/runtime';
|
|
4
4
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
5
5
|
import { computePromptSingleItemFit } from './prompt-activation-deliverability.js';
|
|
6
6
|
import { PROMPT_INJECTION_TARGET_HOSTS, buildLivePromptInjectionProjection, promptRouteForHost, resolvePromptInjectionRouteDecision, } from './prompt-injection-projection.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LlmClassificationResult } from '@principles/core/runtime
|
|
1
|
+
import { type LlmClassificationResult } from '@principles/core/runtime';
|
|
2
2
|
export interface SignalClassifierCallOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Per-call timeout override. The worker passes the cycle's REMAINING
|
|
@@ -26,7 +26,7 @@ export interface CreateSignalClassifierOptions {
|
|
|
26
26
|
/**
|
|
27
27
|
* The Stage-2 structured-output contract this classifier requests. It MUST stay
|
|
28
28
|
* in sync with the registry key in
|
|
29
|
-
* packages/principles-core/src/runtime
|
|
29
|
+
* packages/principles-core/src/runtime/adapter/output-schema-registry.ts:
|
|
30
30
|
* the adapter fails loud (`output_invalid`) on an unregistered ref, and the
|
|
31
31
|
* catch below would silently degrade Stage 2 to "no classification".
|
|
32
32
|
*/
|
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
*
|
|
8
8
|
* The classifier contract is core-owned: `buildLlmPrompt`,
|
|
9
9
|
* `signal-classification-output-v2` and `resolveLlmClassificationPayload`
|
|
10
|
-
* come from `@principles/core/runtime
|
|
10
|
+
* come from `@principles/core/runtime`. This module only owns acquisition:
|
|
11
11
|
* reading the signalCollector runtime profile and calling the adapter.
|
|
12
12
|
*
|
|
13
13
|
* No second model runtime is introduced (ADR-0029: pi-ai is the only backend).
|
|
14
14
|
*/
|
|
15
15
|
import path from 'node:path';
|
|
16
|
-
import { PiAiRuntimeAdapter, SIGNAL_CLASSIFIER_SYSTEM_PROMPT, buildLlmPrompt, resolveLlmClassificationPayload, safeStringifyPreview, } from '@principles/core/runtime
|
|
16
|
+
import { PiAiRuntimeAdapter, SIGNAL_CLASSIFIER_SYSTEM_PROMPT, buildLlmPrompt, resolveLlmClassificationPayload, safeStringifyPreview, } from '@principles/core/runtime';
|
|
17
17
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
18
18
|
/**
|
|
19
19
|
* The Stage-2 structured-output contract this classifier requests. It MUST stay
|
|
20
20
|
* in sync with the registry key in
|
|
21
|
-
* packages/principles-core/src/runtime
|
|
21
|
+
* packages/principles-core/src/runtime/adapter/output-schema-registry.ts:
|
|
22
22
|
* the adapter fails loud (`output_invalid`) on an unregistered ref, and the
|
|
23
23
|
* catch below would silently degrade Stage 2 to "no classification".
|
|
24
24
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ToolSemanticRegistry } from '@principles/core/runtime
|
|
1
|
+
import { type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
2
2
|
import type { RuleContextProvider } from './production-rulehost-gate.js';
|
|
3
3
|
export interface WorkbuddyRuleContextProviderOptions {
|
|
4
4
|
/** The WorkBuddy governance workspace whose trajectory database is authoritative. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { computeBehaviorFacts, } from '@principles/core/runtime
|
|
2
|
+
import { computeBehaviorFacts, } from '@principles/core/runtime';
|
|
3
3
|
import { assembleBehaviorHistory } from './behavior-history.js';
|
|
4
4
|
import { readWorkspaceRuleContextRowsBefore } from './workspace-behavior-evidence.js';
|
|
5
5
|
const HISTORY_LIMIT = 100;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import * as fs from 'node:fs';
|
|
16
16
|
import * as path from 'node:path';
|
|
17
17
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
18
|
-
import { computeFeatureFlagsFromConfig } from '@principles/core/runtime
|
|
18
|
+
import { computeFeatureFlagsFromConfig } from '@principles/core/runtime';
|
|
19
19
|
function directoryExists(dir) {
|
|
20
20
|
try {
|
|
21
21
|
return fs.statSync(dir).isDirectory();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BehaviorEvidencePort, ToolSemanticRegistry } from '@principles/core/runtime
|
|
1
|
+
import type { BehaviorEvidencePort, ToolSemanticRegistry } from '@principles/core/runtime';
|
|
2
2
|
import type { RuleHostContextRow } from '@principles/core/trajectory-types';
|
|
3
3
|
/** Lazy storage access: missing labels need no DB, and a failed open remains observable. */
|
|
4
4
|
export declare function createWorkspaceBehaviorEvidencePort(workspaceDir: string, toolSemantics?: ToolSemanticRegistry): BehaviorEvidencePort;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
5
|
-
import { SqliteConnection } from '@principles/core/runtime
|
|
6
|
-
import { createOwnerEvidenceScopeError } from '@principles/core/runtime
|
|
5
|
+
import { SqliteConnection } from '@principles/core/runtime';
|
|
6
|
+
import { createOwnerEvidenceScopeError } from '@principles/core/runtime/internalization/evidence-readiness';
|
|
7
7
|
import { BehaviorExamplePackAssembler } from './behavior-example-pack-assembler.js';
|
|
8
8
|
import { resolveWorkspaceHostToolSemantics } from './host-tool-semantic-resolver.js';
|
|
9
9
|
function record(value) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoreEventEmitter, type TelemetryEvent } from '@principles/core/runtime
|
|
1
|
+
import { StoreEventEmitter, type TelemetryEvent } from '@principles/core/runtime';
|
|
2
2
|
export type WorkspaceTelemetryPersistFailureSink = (detailJson: string) => void;
|
|
3
3
|
export declare class WorkspaceTelemetryEmitter extends StoreEventEmitter {
|
|
4
4
|
private readonly upstream;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
-
import { StoreEventEmitter } from '@principles/core/runtime
|
|
3
|
+
import { StoreEventEmitter } from '@principles/core/runtime';
|
|
4
4
|
/**
|
|
5
5
|
* PRI-634 A3 — workspace-scoped durable observability for critical runner
|
|
6
6
|
* telemetry (host-neutral; PRI-624 Slice C final integration).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/host-runtime",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"lint": "eslint \"src/**/*.ts\""
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@principles/core": "^
|
|
34
|
+
"@principles/core": "^5.0.0",
|
|
35
35
|
"@principles/install-layout": "^0.4.0",
|
|
36
36
|
"better-sqlite3": "^13.0.3",
|
|
37
37
|
"js-yaml": "^5.4.3"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"url": "git+https://github.com/csuzngjh/principles.git"
|
|
50
50
|
},
|
|
51
51
|
"license": "Apache-2.0",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "86b6208042b6083d4a7bbf840730d060188a1517"
|
|
53
53
|
}
|