@principles/host-runtime 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adaptive-behavior-linkage.d.ts +223 -0
- package/dist/adaptive-behavior-linkage.js +1014 -0
- package/dist/adaptive-journal-reconciliation.d.ts +10 -0
- package/dist/adaptive-journal-reconciliation.js +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/prompt-injection-budget-observation.js +31 -2
- package/package.json +2 -2
|
@@ -76,6 +76,12 @@ export interface AdaptiveJournalTotals {
|
|
|
76
76
|
rejectedRecords: number | null;
|
|
77
77
|
countsAreLowerBounds: boolean;
|
|
78
78
|
}
|
|
79
|
+
export interface AdaptiveJournalConfigIdentity {
|
|
80
|
+
hostVersion: string | null;
|
|
81
|
+
pluginVersion: string | null;
|
|
82
|
+
effectiveHookSetFingerprint: string | null;
|
|
83
|
+
evidenceCoverage: string | null;
|
|
84
|
+
}
|
|
79
85
|
export interface AdaptiveJournalRecordProjection {
|
|
80
86
|
ts: string;
|
|
81
87
|
receiptState: 'open' | 'closed' | 'reconciled';
|
|
@@ -88,6 +94,10 @@ export interface AdaptiveJournalRecordProjection {
|
|
|
88
94
|
artifactId: string | null;
|
|
89
95
|
activationId: string | null;
|
|
90
96
|
requestId: string | null;
|
|
97
|
+
/** PRI-1114: recorded target body hash; never re-computed by this reader. */
|
|
98
|
+
targetBodySha256: string | null;
|
|
99
|
+
/** PRI-1114: recorded call-configuration identity (PRI-1109 §3.3 contract). */
|
|
100
|
+
configIdentity: AdaptiveJournalConfigIdentity | null;
|
|
91
101
|
evidenceReferencePresent: boolean;
|
|
92
102
|
/** Transcribed as recorded; never re-verified by this reader. */
|
|
93
103
|
evidenceIndependentlyVerifiedAsRecorded: boolean | null;
|
|
@@ -407,6 +407,20 @@ function countDistinctIdentities(records) {
|
|
|
407
407
|
function buildProjection(data, fallbackTs) {
|
|
408
408
|
const receiptState = data.receiptState === 'closed' || data.receiptState === 'reconciled' ? data.receiptState : 'open';
|
|
409
409
|
const evidence = isRecord(data.evidence) ? data.evidence : null;
|
|
410
|
+
const configIdentity = (() => {
|
|
411
|
+
const identity = {
|
|
412
|
+
hostVersion: optionalString(data.hostVersion),
|
|
413
|
+
pluginVersion: optionalString(data.pluginVersion),
|
|
414
|
+
effectiveHookSetFingerprint: optionalString(data.effectiveHookSetFingerprint),
|
|
415
|
+
evidenceCoverage: optionalString(data.evidenceCoverage),
|
|
416
|
+
};
|
|
417
|
+
return identity.hostVersion === null
|
|
418
|
+
&& identity.pluginVersion === null
|
|
419
|
+
&& identity.effectiveHookSetFingerprint === null
|
|
420
|
+
&& identity.evidenceCoverage === null
|
|
421
|
+
? null
|
|
422
|
+
: identity;
|
|
423
|
+
})();
|
|
410
424
|
return {
|
|
411
425
|
ts: fallbackTs,
|
|
412
426
|
receiptState,
|
|
@@ -419,6 +433,8 @@ function buildProjection(data, fallbackTs) {
|
|
|
419
433
|
artifactId: optionalString(data.artifactId) ?? optionalString(data.principleArtifactId),
|
|
420
434
|
activationId: optionalString(data.activationId) ?? optionalString(data.activationRunId),
|
|
421
435
|
requestId: optionalString(data.requestId),
|
|
436
|
+
targetBodySha256: optionalString(data.targetBodySha256),
|
|
437
|
+
configIdentity,
|
|
422
438
|
evidenceReferencePresent: evidence !== null && optionalString(evidence.reference) !== null,
|
|
423
439
|
evidenceIndependentlyVerifiedAsRecorded: evidence === null ? null : optionalBoolean(evidence.independentlyVerified),
|
|
424
440
|
hostKillConfirmedAsRecorded: evidence === null ? null : optionalBoolean(evidence.hostKillConfirmed),
|
package/dist/index.d.ts
CHANGED
|
@@ -113,3 +113,4 @@ export { readDesignGateSpecSnapshot, describeCodexRuleContextFact } from './desi
|
|
|
113
113
|
export { createCodexArtificerTrustedFactsPort } from './codex-artificer-trusted-facts.js';
|
|
114
114
|
export { revalidateAdaptivePrinciple, createAdaptivePrincipleRevalidator, type AdaptivePrincipleReader } from './adaptive-principle-revalidation.js';
|
|
115
115
|
export * from './adaptive-journal-reconciliation.js';
|
|
116
|
+
export * from './adaptive-behavior-linkage.js';
|
package/dist/index.js
CHANGED
|
@@ -361,3 +361,5 @@ export { readDesignGateSpecSnapshot, describeCodexRuleContextFact } from './desi
|
|
|
361
361
|
export { createCodexArtificerTrustedFactsPort } from './codex-artificer-trusted-facts.js';
|
|
362
362
|
export { revalidateAdaptivePrinciple, createAdaptivePrincipleRevalidator } from './adaptive-principle-revalidation.js';
|
|
363
363
|
export * from './adaptive-journal-reconciliation.js';
|
|
364
|
+
// PRI-1114: read-only behavior evidence linkage (no writes, no model runs).
|
|
365
|
+
export * from './adaptive-behavior-linkage.js';
|
|
@@ -2,6 +2,35 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { PROMPT_BUDGET_POLICY_VERSION, RUNTIME_V2_PRINCIPLE_BUDGET, isValidContextWindowTokens, promptBudgetCharsForContextWindow, resolvePromptBudget, operatorDeclaredContextWindow, } from '@principles/core/runtime-v2';
|
|
4
4
|
import { isPromptInjectionTargetHost, } from './prompt-injection-projection.js';
|
|
5
|
+
/**
|
|
6
|
+
* PRI-1104 Stage 0 (expand): accepted budget policy provenance versions.
|
|
7
|
+
*
|
|
8
|
+
* Injection events written to the JSONL event log carry `budgetPolicyVersion`
|
|
9
|
+
* as a durable wire literal. PR-6 renames the CURRENT policy id from
|
|
10
|
+
* `model_aware_v2` to a version-neutral `model_aware`; without this read-side
|
|
11
|
+
* allowance, every historical event would suddenly be classified as
|
|
12
|
+
* "computed under a different policy" and silently skipped (and a revert of
|
|
13
|
+
* PR-6 would strand events written with the new id).
|
|
14
|
+
*
|
|
15
|
+
* These are FROZEN WIRE LITERALS, not a second policy definition: they exist
|
|
16
|
+
* only so events remain readable across the PR-6 rename AND its revert. The
|
|
17
|
+
* PR-6 target id `model_aware` is listed up front (PR #2367 CodeRabbit #2):
|
|
18
|
+
* if PR-6 is reverted after it wrote `model_aware` events, a reader accepting
|
|
19
|
+
* only `model_aware_v2` would silently skip those observations and the console
|
|
20
|
+
* would fall back to a stale budget.
|
|
21
|
+
*
|
|
22
|
+
* Today the writer emits only `model_aware_v2`, so listing the future and
|
|
23
|
+
* historical literals does not change any current read result.
|
|
24
|
+
*/
|
|
25
|
+
const ACCEPTED_BUDGET_POLICY_VERSIONS = new Set([
|
|
26
|
+
PROMPT_BUDGET_POLICY_VERSION,
|
|
27
|
+
'model_aware_v2',
|
|
28
|
+
'model_aware',
|
|
29
|
+
]);
|
|
30
|
+
/** Narrow an untrusted event field to an accepted policy provenance id. */
|
|
31
|
+
function isAcceptedBudgetPolicyVersion(value) {
|
|
32
|
+
return typeof value === 'string' && ACCEPTED_BUDGET_POLICY_VERSIONS.has(value);
|
|
33
|
+
}
|
|
5
34
|
/**
|
|
6
35
|
* PRI-1017: runtime budget OBSERVATION read model over the EXISTING
|
|
7
36
|
* injection-event JSONL (`<workspaceDir>/{.pd,.state}/logs/events_<date>.jsonl`,
|
|
@@ -162,7 +191,7 @@ function narrowObservation(parsed, workspaceDir, nowMs) {
|
|
|
162
191
|
// A budget computed under another policy version is not evidence about the
|
|
163
192
|
// CURRENT formula. Absent provenance is pre-policy, not "current by
|
|
164
193
|
// default": both are skipped, never reinterpreted.
|
|
165
|
-
if (data.budgetPolicyVersion
|
|
194
|
+
if (!isAcceptedBudgetPolicyVersion(data.budgetPolicyVersion))
|
|
166
195
|
return null;
|
|
167
196
|
const rawSource = data.budgetCapacitySource;
|
|
168
197
|
const rawStatus = data.budgetCapacityStatus;
|
|
@@ -335,7 +364,7 @@ export function readRuntimePromptBudgetObservations(input) {
|
|
|
335
364
|
if (isRecord(parsed) && parsed.type === 'runtime_v2_prompt_activations_injected' && isRecord(parsed.data)) {
|
|
336
365
|
const { data } = parsed;
|
|
337
366
|
const rawPolicyVersion = data.budgetPolicyVersion;
|
|
338
|
-
if (rawPolicyVersion !== undefined && rawPolicyVersion
|
|
367
|
+
if (rawPolicyVersion !== undefined && !isAcceptedBudgetPolicyVersion(rawPolicyVersion)) {
|
|
339
368
|
// A budget computed under a DIFFERENT policy version is not
|
|
340
369
|
// evidence about the current formula — counted, not reinterpreted.
|
|
341
370
|
foreignPolicyEventsSkipped.count += 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/host-runtime",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -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": "e2f66fab6d7e1830c6552c73ad9b3292996c254f"
|
|
53
53
|
}
|