@principles/host-runtime 2.2.2 → 3.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.
- package/dist/active-principle-prompt.d.ts +88 -3
- package/dist/active-principle-prompt.js +132 -41
- package/dist/adaptive-journal-reconciliation.js +1 -1
- package/dist/adaptive-principle-revalidation.d.ts +1 -1
- package/dist/adaptive-principle-revalidation.js +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 +11 -1
- package/dist/index.js +33 -15
- 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 +26 -16
- package/dist/prompt-activation-deliverability.js +60 -30
- 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 +106 -49
- package/dist/prompt-injection-projection.js +190 -212
- package/dist/prompt-injection-status.d.ts +1 -1
- package/dist/prompt-injection-status.js +17 -8
- 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
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';
|
|
@@ -77,6 +77,16 @@ export declare function createProductionHostRuntime(options?: Partial<Pick<HostR
|
|
|
77
77
|
projectDir?: string;
|
|
78
78
|
/** PRI-634-F: host-declared tool semantics supplied by the constructing host adapter. */
|
|
79
79
|
toolSemantics?: ToolSemanticRegistry;
|
|
80
|
+
/**
|
|
81
|
+
* PRI-1137: optional authoritative session-round key supplied by the host
|
|
82
|
+
* adapter that actually owns an advancing user-turn authority. The
|
|
83
|
+
* OpenClaw adapter forwards the trusted `nextSessionTurnOrdinal` value
|
|
84
|
+
* here; Codex / WorkBuddy supply nothing because they have no user_turns
|
|
85
|
+
* authority (a constant or a synthetic value would be a false fair-rotation
|
|
86
|
+
* claim). Absent / `undefined` → `legacy_fifo_prefix_v1`, exactly as
|
|
87
|
+
* before this convergence. Must be a positive integer when present.
|
|
88
|
+
*/
|
|
89
|
+
roundKeyProvider?: (event: HostEvent) => number | undefined | Promise<number | undefined>;
|
|
80
90
|
/** Optional, already-scoped single prompt target from the host adapter. Errors fail closed to Native. */
|
|
81
91
|
adaptivePriorityProvider?: (event: HostEvent) => {
|
|
82
92
|
artifactId: string;
|
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';
|
|
@@ -203,16 +203,32 @@ export function createProductionHostRuntime(options = {}) {
|
|
|
203
203
|
}),
|
|
204
204
|
beforeToolCall: options.beforeToolCall ?? productionGate,
|
|
205
205
|
async beforePromptBuild(event) {
|
|
206
|
-
// PRI-904 Phase-1 (Option 3):
|
|
207
|
-
//
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
//
|
|
211
|
-
//
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
206
|
+
// PRI-904 Phase-1 (Option 3): Codex never writes
|
|
207
|
+
// trajectory.db::user_turns — its ingestion writes governance_* rows
|
|
208
|
+
// instead. Reading a session turn ordinal there would be a false round
|
|
209
|
+
// authority: either it throws (→ legacy) or returns a constant 1 (→
|
|
210
|
+
// fixed start, a different positional starvation while the event still
|
|
211
|
+
// claimed a fair rotation). PRI-1137: this is now enforced through
|
|
212
|
+
// `roundKeyProvider` — only the host that owns a real advancing
|
|
213
|
+
// user-turn authority (OpenClaw) supplies one, and everything else
|
|
214
|
+
// honestly reports `legacy_fifo_prefix_v1`.
|
|
215
|
+
let roundKey;
|
|
216
|
+
if (options.roundKeyProvider) {
|
|
217
|
+
try {
|
|
218
|
+
// The provider may perform the host's PRE-SELECTION work (OpenClaw:
|
|
219
|
+
// signal collection + user_turns write) before returning the ordinal,
|
|
220
|
+
// so it must run before the prompt context is built.
|
|
221
|
+
const candidate = await options.roundKeyProvider(event);
|
|
222
|
+
if (typeof candidate === 'number' && Number.isInteger(candidate) && candidate >= 1) {
|
|
223
|
+
roundKey = candidate;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
// Degradation is observable through the resulting selectionPolicy
|
|
228
|
+
// (`legacy_fifo_prefix_v1`); the provider logs its own reason.
|
|
229
|
+
roundKey = undefined;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
216
232
|
// PRI-1020: the Owner's declared window (.pd/config.yaml promptBudget)
|
|
217
233
|
// is tier 0 of the budget chain — resolved per host and fed into the
|
|
218
234
|
// SAME single resolver below. One extra sync config read per prompt
|
|
@@ -249,6 +265,7 @@ export function createProductionHostRuntime(options = {}) {
|
|
|
249
265
|
}
|
|
250
266
|
const prompt = await buildActivePrinciplePromptContext({
|
|
251
267
|
workspaceDir: event.context.workspaceDir,
|
|
268
|
+
...(roundKey !== undefined ? { roundKey } : {}),
|
|
252
269
|
...(adaptivePriority ? {
|
|
253
270
|
adaptivePriority: { artifactId: adaptivePriority.artifactId, activationId: adaptivePriority.activationId },
|
|
254
271
|
...(adaptivePriority.signal ? { signal: adaptivePriority.signal } : {}),
|
|
@@ -293,7 +310,7 @@ export function createProductionHostRuntime(options = {}) {
|
|
|
293
310
|
// observable warning (rc-9).
|
|
294
311
|
const emissionWarnings = [];
|
|
295
312
|
try {
|
|
296
|
-
options.events?.
|
|
313
|
+
options.events?.recordRuntimeActivationsInjected({
|
|
297
314
|
sessionId: event.context.sessionId,
|
|
298
315
|
workspaceDir: event.context.workspaceDir,
|
|
299
316
|
principleIds: prompt.principleIds,
|
|
@@ -318,9 +335,10 @@ export function createProductionHostRuntime(options = {}) {
|
|
|
318
335
|
// operators can tell model-identity absence from catalog ambiguity
|
|
319
336
|
// etc. without touching logs. Detail stays out of events.
|
|
320
337
|
...(prompt.budgetFallbackReason !== undefined ? { budgetFallbackReason: prompt.budgetFallbackReason } : {}),
|
|
321
|
-
// PRI-904: selection diagnostics (bounded, optional).
|
|
322
|
-
//
|
|
323
|
-
//
|
|
338
|
+
// PRI-904/PRI-1137: selection diagnostics (bounded, optional).
|
|
339
|
+
// The policy reflects the real selection: `fair_rotation_v1` only
|
|
340
|
+
// when a trusted roundKey was supplied, `legacy_fifo_prefix_v1`
|
|
341
|
+
// otherwise — never a claim the selection did not make.
|
|
324
342
|
...(prompt.selectionPolicy !== undefined ? { selectionPolicy: prompt.selectionPolicy } : {}),
|
|
325
343
|
...(prompt.eligibleCount !== undefined ? { eligibleCount: prompt.eligibleCount } : {}),
|
|
326
344
|
...(prompt.rotationStartIndex !== undefined ? { rotationStartIndex: prompt.rotationStartIndex } : {}),
|
|
@@ -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,13 +1,13 @@
|
|
|
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
|
|
5
5
|
* precheck, shared by every real prompt-activation write entry (Console
|
|
6
|
-
* approve, CLI approve) and by the pre-approval candidate fit (R-A2).
|
|
7
|
-
* cost is measured with the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
6
|
+
* approve, CLI approve) and by the pre-approval candidate fit (R-A2).
|
|
7
|
+
* PRI-1137: the cost is measured with the ONE live production serializer —
|
|
8
|
+
* the full single-principle directive render (including the self-report
|
|
9
|
+
* footer when that flag is on). The retired list-route selected-lines
|
|
10
|
+
* arithmetic is gone. The principle identity is
|
|
11
11
|
* the REAL resolved id (content `principleId` or draft title) — never a
|
|
12
12
|
* fixed-length UUID allowance (a title-derived id can only be longer).
|
|
13
13
|
*
|
|
@@ -91,23 +91,21 @@ export declare function resolvePromptCandidatePrinciple(artifact: PromptDelivera
|
|
|
91
91
|
warning: string;
|
|
92
92
|
};
|
|
93
93
|
/**
|
|
94
|
-
* Positive single-item evidence under
|
|
95
|
-
*
|
|
96
|
-
* fits — never because it is absent from a bounded diagnostic list).
|
|
94
|
+
* Positive single-item evidence under the live route, using the production
|
|
95
|
+
* serializer itself (AC-06: a row is "fits" because its own serialized
|
|
96
|
+
* directive fits — never because it is absent from a bounded diagnostic list).
|
|
97
97
|
*
|
|
98
|
-
* `costChars` is what the single-entry selection
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* DID return plus the real entry line (same format authority, listEntryLine).
|
|
98
|
+
* `costChars` is what the single-entry selection consumes, measured exactly as
|
|
99
|
+
* the shared projection reports `usedChars`. PRI-1137: there is one live route,
|
|
100
|
+
* so there is no route parameter and no list-route `trimToBudget` arithmetic to
|
|
101
|
+
* keep in sync — a forecast may not measure a deleted path.
|
|
103
102
|
*
|
|
104
|
-
* The budget parameter defaults to the
|
|
103
|
+
* The budget parameter defaults to the fixed fallback budget: approval-time
|
|
105
104
|
* callers hold no runtime model facts, and SPEC §6.3 requires the fixed
|
|
106
105
|
* fallback — never an invented capacity — when none can be confirmed.
|
|
107
106
|
*/
|
|
108
107
|
export declare function computePromptSingleItemFit(input: {
|
|
109
108
|
principle: ActivatedPrinciple;
|
|
110
|
-
route: PromptInjectionRouteName;
|
|
111
109
|
selfReportEnabled: boolean;
|
|
112
110
|
budget?: number;
|
|
113
111
|
}): {
|
|
@@ -122,6 +120,16 @@ export declare function checkPromptArtifactDeliverability(input: {
|
|
|
122
120
|
workspaceDir: string;
|
|
123
121
|
targetHost?: PromptInjectionTargetHost;
|
|
124
122
|
artifact: PromptDeliverabilityCandidateArtifact | null | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* PRI-1137 final review P2: the authority the DECISION under measurement
|
|
125
|
+
* will stamp on this artifact. Approve-time callers pass `'owner'` (the
|
|
126
|
+
* console/CLI approval IS an owner decision — the post-approval directive
|
|
127
|
+
* bills `authority="owner"`, and billing the pre-approval default
|
|
128
|
+
* `system_policy` overstated the entry by the attribute delta and could
|
|
129
|
+
* refuse a borderline-fitting entry). Absent → the current DB fact (the
|
|
130
|
+
* honest pre-decision view for candidate-fit surfaces).
|
|
131
|
+
*/
|
|
132
|
+
authority?: 'owner' | 'system_policy';
|
|
125
133
|
}): Promise<PromptArtifactDeliverability>;
|
|
126
134
|
/** Load one artifact read-only from `<workspace>/.pd/state.db`. Failures carry a reason (rc-9). */
|
|
127
135
|
export declare function loadPromptArtifactById(workspaceDir: string, artifactId: string): Promise<{
|
|
@@ -136,4 +144,6 @@ export declare function checkPromptArtifactDeliverabilityById(input: {
|
|
|
136
144
|
workspaceDir: string;
|
|
137
145
|
artifactId: string;
|
|
138
146
|
targetHost?: PromptInjectionTargetHost;
|
|
147
|
+
/** See `checkPromptArtifactDeliverability.authority` (approve-time = 'owner'). */
|
|
148
|
+
authority?: 'owner' | 'system_policy';
|
|
139
149
|
}): Promise<PromptArtifactDeliverability>;
|
|
@@ -1,9 +1,10 @@
|
|
|
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,
|
|
3
|
+
import { PROMPT_BUDGET_FALLBACK_CHARS, PROMPT_BUDGET_MAX_CHARS, PROMPT_BUDGET_MIN_CHARS, SqliteConnection, SqlitePIArtifactStore, classifySingleItemBudgetTier, computeFeatureFlagsFromConfig, renderPrinciplesToDirectives, resolvePrincipleFromArtifact, } from '@principles/core/runtime';
|
|
4
4
|
import { escapeXml } from '@principles/core/prompt-builder';
|
|
5
5
|
import { loadPdConfigForPlugin } from './pd-config.js';
|
|
6
|
-
import {
|
|
6
|
+
import { readPromptActivationAuthority } from './prompt-activation-authority.js';
|
|
7
|
+
import { PROMPT_INJECTION_TARGET_HOSTS, PROMPT_INJECTION_UNIT, resolvePromptInjectionRouteDecision, } from './prompt-injection-projection.js';
|
|
7
8
|
function syntheticPendingActivation(artifactId) {
|
|
8
9
|
return {
|
|
9
10
|
activationId: `pending:${artifactId}`,
|
|
@@ -29,35 +30,52 @@ function selfReportEnabledFor(workspaceDir) {
|
|
|
29
30
|
return computeFeatureFlagsFromConfig(loadPdConfigForPlugin(workspaceDir).effective).flags.principle_receipt_self_report?.enabled === true;
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
|
-
* Positive single-item evidence under
|
|
33
|
-
*
|
|
34
|
-
* fits — never because it is absent from a bounded diagnostic list).
|
|
33
|
+
* Positive single-item evidence under the live route, using the production
|
|
34
|
+
* serializer itself (AC-06: a row is "fits" because its own serialized
|
|
35
|
+
* directive fits — never because it is absent from a bounded diagnostic list).
|
|
35
36
|
*
|
|
36
|
-
* `costChars` is what the single-entry selection
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* DID return plus the real entry line (same format authority, listEntryLine).
|
|
37
|
+
* `costChars` is what the single-entry selection consumes, measured exactly as
|
|
38
|
+
* the shared projection reports `usedChars`. PRI-1137: there is one live route,
|
|
39
|
+
* so there is no route parameter and no list-route `trimToBudget` arithmetic to
|
|
40
|
+
* keep in sync — a forecast may not measure a deleted path.
|
|
41
41
|
*
|
|
42
|
-
* The budget parameter defaults to the
|
|
42
|
+
* The budget parameter defaults to the fixed fallback budget: approval-time
|
|
43
43
|
* callers hold no runtime model facts, and SPEC §6.3 requires the fixed
|
|
44
44
|
* fallback — never an invented capacity — when none can be confirmed.
|
|
45
45
|
*/
|
|
46
46
|
export function computePromptSingleItemFit(input) {
|
|
47
47
|
const budget = input.budget ?? PROMPT_BUDGET_FALLBACK_CHARS;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return { fits: render.length <= budget, costChars: render.length };
|
|
51
|
-
}
|
|
52
|
-
const trimmed = trimToBudget([input.principle], budget, escapeXml);
|
|
53
|
-
const fits = trimmed.injectedIds.has(input.principle.principleId);
|
|
54
|
-
const costChars = trimmed.lines.length > 1
|
|
55
|
-
? trimmed.lines.join('\n').length
|
|
56
|
-
: (trimmed.lines[0]?.length ?? 0) + 1 + listEntryLine(input.principle, escapeXml).length;
|
|
57
|
-
return { fits, costChars };
|
|
48
|
+
const render = renderPrinciplesToDirectives([input.principle], new Set([input.principle.principleId]), { escapeFn: escapeXml, selfReportInstruction: input.selfReportEnabled });
|
|
49
|
+
return { fits: render.length <= budget, costChars: render.length };
|
|
58
50
|
}
|
|
59
51
|
const UNDELIVERABLE_NEXT_ACTION = 'shorten the principle statement and resubmit, or use the activations page "modify to injectable version" entry to create a replacement artifact (the approval facts are preserved)';
|
|
60
52
|
const MODEL_DEPENDENT_NEXT_ACTION = 'this principle fits the injection budget only on models with a larger context window; it may be excluded at runtime on smaller-context models — the approval itself is unaffected';
|
|
53
|
+
/**
|
|
54
|
+
* PRI-1137: the production prompt annotates each directive with its authority,
|
|
55
|
+
* so an approval-time cost that omitted the attribute would understate the real
|
|
56
|
+
* bytes. Unknown/unreadable stays unannotated — never inferred.
|
|
57
|
+
*
|
|
58
|
+
* PRI-1137 final review P2: a BROKEN authority read is distinguished from
|
|
59
|
+
* "no annotation" — the caller refuses as unconfirmed instead of silently
|
|
60
|
+
* billing an unannotated (cheaper) entry (rc-3/rc-9).
|
|
61
|
+
*/
|
|
62
|
+
function readAuthorityForArtifact(workspaceDir, artifactId) {
|
|
63
|
+
const stateDbPath = path.join(workspaceDir, '.pd', 'state.db');
|
|
64
|
+
if (!fs.existsSync(stateDbPath))
|
|
65
|
+
return { ok: true, authority: undefined };
|
|
66
|
+
let connection;
|
|
67
|
+
try {
|
|
68
|
+
connection = new SqliteConnection({ workspaceDir, readonly: true, bootstrapIfMissing: false, busyTimeoutMs: 0 });
|
|
69
|
+
return { ok: true, authority: readPromptActivationAuthority(connection, artifactId, 'prompt').authority };
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
73
|
+
return { ok: false, reason: `authority_read_failed: ${message.slice(0, 160)}` };
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
connection?.close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
61
79
|
/**
|
|
62
80
|
* Precheck one artifact against the workspace's effective injection route.
|
|
63
81
|
* Pure read — no state mutation, safe to call before any governance write.
|
|
@@ -79,19 +97,30 @@ export async function checkPromptArtifactDeliverability(input) {
|
|
|
79
97
|
};
|
|
80
98
|
}
|
|
81
99
|
const selfReportEnabled = selfReportEnabledFor(input.workspaceDir);
|
|
100
|
+
const authorityRead = readAuthorityForArtifact(input.workspaceDir, input.artifact.artifactId);
|
|
101
|
+
if (!authorityRead.ok) {
|
|
102
|
+
// A broken authority read must not be billed as "unannotated" — the cost
|
|
103
|
+
// evidence would be fabricated-cheap (final review P2, rc-3).
|
|
104
|
+
return {
|
|
105
|
+
status: 'unconfirmed',
|
|
106
|
+
reason: `${authorityRead.reason}; the single-entry cost cannot be measured with the authority annotation this route bills`,
|
|
107
|
+
nextAction: 'repair the workspace state.db readability (the authority join read failed), then retry',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const authority = input.authority ?? authorityRead.authority;
|
|
111
|
+
const principle = authority === undefined
|
|
112
|
+
? resolved.principle
|
|
113
|
+
: { ...resolved.principle, authority };
|
|
82
114
|
const decision = resolvePromptInjectionRouteDecision({
|
|
83
115
|
workspaceDir: input.workspaceDir,
|
|
84
116
|
targetHost: input.targetHost,
|
|
85
117
|
});
|
|
86
118
|
if (decision.status === 'confirmed' && decision.route !== undefined) {
|
|
87
119
|
const { costChars } = computePromptSingleItemFit({
|
|
88
|
-
principle
|
|
89
|
-
route: decision.route,
|
|
120
|
+
principle,
|
|
90
121
|
selfReportEnabled,
|
|
91
122
|
});
|
|
92
|
-
const budgetScope =
|
|
93
|
-
? 'full_directive_context'
|
|
94
|
-
: 'selected_lines';
|
|
123
|
+
const budgetScope = 'full_directive_context';
|
|
95
124
|
const shared = {
|
|
96
125
|
route: decision.route,
|
|
97
126
|
...(decision.hostKind !== undefined ? { hostKind: decision.hostKind } : {}),
|
|
@@ -135,10 +164,8 @@ export async function checkPromptArtifactDeliverability(input) {
|
|
|
135
164
|
// hand-typed two-host array dropped WorkBuddy from unconfirmed
|
|
136
165
|
// deliverability reports).
|
|
137
166
|
const perHost = PROMPT_INJECTION_TARGET_HOSTS.map((hostKind) => {
|
|
138
|
-
const route = promptRouteForHost(hostKind, decision.flagEnabled);
|
|
139
167
|
const { costChars } = computePromptSingleItemFit({
|
|
140
|
-
principle
|
|
141
|
-
route,
|
|
168
|
+
principle,
|
|
142
169
|
selfReportEnabled,
|
|
143
170
|
});
|
|
144
171
|
return { hostKind, tierFit: classifySingleItemBudgetTier(costChars), costChars };
|
|
@@ -191,5 +218,8 @@ export async function checkPromptArtifactDeliverabilityById(input) {
|
|
|
191
218
|
nextAction: 'fix the artifact store readability, then retry the approval',
|
|
192
219
|
};
|
|
193
220
|
}
|
|
194
|
-
return checkPromptArtifactDeliverability({
|
|
221
|
+
return checkPromptArtifactDeliverability({
|
|
222
|
+
...input,
|
|
223
|
+
artifact: loaded.artifact,
|
|
224
|
+
});
|
|
195
225
|
}
|
|
@@ -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: {
|