@principles/core 1.242.0 → 1.244.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/runtime-v2/feature-flags/__tests__/context-manifest-budget-flag.test.d.ts +12 -0
- package/dist/runtime-v2/feature-flags/__tests__/context-manifest-budget-flag.test.d.ts.map +1 -0
- package/dist/runtime-v2/feature-flags/__tests__/context-manifest-budget-flag.test.js +114 -0
- package/dist/runtime-v2/feature-flags/__tests__/context-manifest-budget-flag.test.js.map +1 -0
- package/dist/runtime-v2/feature-flags/__tests__/progressive-evaluator-flag.test.d.ts +8 -0
- package/dist/runtime-v2/feature-flags/__tests__/progressive-evaluator-flag.test.d.ts.map +1 -0
- package/dist/runtime-v2/feature-flags/__tests__/progressive-evaluator-flag.test.js +56 -0
- package/dist/runtime-v2/feature-flags/__tests__/progressive-evaluator-flag.test.js.map +1 -0
- package/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/dist/runtime-v2/feature-flags/feature-flag-contract.js +14 -0
- package/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/dist/runtime-v2/index.d.ts +2 -0
- package/dist/runtime-v2/index.d.ts.map +1 -1
- package/dist/runtime-v2/index.js +2 -0
- package/dist/runtime-v2/index.js.map +1 -1
- package/dist/runtime-v2/internalization/__tests__/context-manifest.property.test.d.ts +12 -0
- package/dist/runtime-v2/internalization/__tests__/context-manifest.property.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/context-manifest.property.test.js +176 -0
- package/dist/runtime-v2/internalization/__tests__/context-manifest.property.test.js.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/progressive-evaluator.property.test.d.ts +11 -0
- package/dist/runtime-v2/internalization/__tests__/progressive-evaluator.property.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/progressive-evaluator.property.test.js +154 -0
- package/dist/runtime-v2/internalization/__tests__/progressive-evaluator.property.test.js.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/prompt-budget-manager.property.test.d.ts +12 -0
- package/dist/runtime-v2/internalization/__tests__/prompt-budget-manager.property.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/prompt-budget-manager.property.test.js +254 -0
- package/dist/runtime-v2/internalization/__tests__/prompt-budget-manager.property.test.js.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/resolve-injection.property.test.d.ts +15 -0
- package/dist/runtime-v2/internalization/__tests__/resolve-injection.property.test.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/__tests__/resolve-injection.property.test.js +150 -0
- package/dist/runtime-v2/internalization/__tests__/resolve-injection.property.test.js.map +1 -0
- package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/artificer-runner.js +12 -0
- package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/context-manifest.d.ts +117 -0
- package/dist/runtime-v2/internalization/context-manifest.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/context-manifest.js +156 -0
- package/dist/runtime-v2/internalization/context-manifest.js.map +1 -0
- package/dist/runtime-v2/internalization/context-manifests.d.ts +74 -0
- package/dist/runtime-v2/internalization/context-manifests.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/context-manifests.js +192 -0
- package/dist/runtime-v2/internalization/context-manifests.js.map +1 -0
- package/dist/runtime-v2/internalization/dimension-coverage-policy.d.ts +54 -0
- package/dist/runtime-v2/internalization/dimension-coverage-policy.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/dimension-coverage-policy.js +70 -0
- package/dist/runtime-v2/internalization/dimension-coverage-policy.js.map +1 -0
- package/dist/runtime-v2/internalization/dreamer-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/dreamer-runner.js +13 -1
- package/dist/runtime-v2/internalization/dreamer-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-output.d.ts +26 -0
- package/dist/runtime-v2/internalization/evaluator-output.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-output.js +7 -1
- package/dist/runtime-v2/internalization/evaluator-output.js.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.js +13 -0
- package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/index.d.ts +2 -0
- package/dist/runtime-v2/internalization/index.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/index.js +2 -0
- package/dist/runtime-v2/internalization/index.js.map +1 -1
- package/dist/runtime-v2/internalization/progressive-evaluator.d.ts +115 -0
- package/dist/runtime-v2/internalization/progressive-evaluator.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/progressive-evaluator.js +248 -0
- package/dist/runtime-v2/internalization/progressive-evaluator.js.map +1 -0
- package/dist/runtime-v2/internalization/prompt-budget-manager.d.ts +90 -0
- package/dist/runtime-v2/internalization/prompt-budget-manager.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/prompt-budget-manager.js +149 -0
- package/dist/runtime-v2/internalization/prompt-budget-manager.js.map +1 -0
- package/dist/runtime-v2/internalization/resolve-injection.d.ts +62 -0
- package/dist/runtime-v2/internalization/resolve-injection.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/resolve-injection.js +78 -0
- package/dist/runtime-v2/internalization/resolve-injection.js.map +1 -0
- package/dist/runtime-v2/internalization/scribe-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/scribe-runner.js +10 -0
- package/dist/runtime-v2/internalization/scribe-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/summary-field-reader.d.ts +38 -0
- package/dist/runtime-v2/internalization/summary-field-reader.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/summary-field-reader.js +108 -0
- package/dist/runtime-v2/internalization/summary-field-reader.js.map +1 -0
- package/dist/runtime-v2/runner/base-peer-runner.d.ts +36 -0
- package/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
- package/dist/runtime-v2/runner/base-peer-runner.js +71 -0
- package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer 1 — ContextManifest: declarative field/budget declaration (design §6.2).
|
|
3
|
+
*
|
|
4
|
+
* Pure logic only: no I/O, no fs, no DB, no network (Core vs Plugin boundary,
|
|
5
|
+
* AGENTS.md `antipattern-core-io`).
|
|
6
|
+
*
|
|
7
|
+
* A `ContextManifest` declares which field paths a runner (or an evaluator
|
|
8
|
+
* stage) needs, layered into tier0/tier1/tier2, plus a token budget and a
|
|
9
|
+
* priority ordering. Layer 1's `allocateContext` (prompt-budget-manager.ts)
|
|
10
|
+
* consumes it; Layer 3's CLI surfaces its resolution.
|
|
11
|
+
*
|
|
12
|
+
* rc-4: tier* and priority array elements are validated element-wise as
|
|
13
|
+
* strings before use. rc-5: object keys read via `Object.hasOwn`.
|
|
14
|
+
*/
|
|
15
|
+
import type { SummaryRunnerKind } from './artifact-summary.js';
|
|
16
|
+
export declare const CONTEXT_MANIFEST_SCHEMA_VERSION: 1;
|
|
17
|
+
/**
|
|
18
|
+
* A declarative context-injection manifest (design §6.2).
|
|
19
|
+
*
|
|
20
|
+
* Field-path naming convention (design §6.6):
|
|
21
|
+
* `<stage>.summary.<key>` — read from an ArtifactSummary
|
|
22
|
+
* `<stage>.predecessorSummary.*` — read from a forwarded predecessor summary
|
|
23
|
+
* `<stage>.raw.<path>` — read from tier2 full contentJson
|
|
24
|
+
*/
|
|
25
|
+
export interface ContextManifest {
|
|
26
|
+
readonly manifestId: string;
|
|
27
|
+
readonly schemaVersion: typeof CONTEXT_MANIFEST_SCHEMA_VERSION;
|
|
28
|
+
readonly runnerKind: SummaryRunnerKind;
|
|
29
|
+
readonly tier0: readonly string[];
|
|
30
|
+
readonly tier1: readonly string[];
|
|
31
|
+
/** Non-empty tier2 means CandidateLineage (Layer 2) may be triggered. */
|
|
32
|
+
readonly tier2: readonly string[];
|
|
33
|
+
/** Cross-level injection field budget (design §6.2.1). */
|
|
34
|
+
readonly budgetTokens: number;
|
|
35
|
+
/** Full priority sequence. Fields not listed here sort last (see rankOf). */
|
|
36
|
+
readonly priority: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
export type ManifestWellFormednessError = {
|
|
39
|
+
readonly kind: 'budget_not_positive';
|
|
40
|
+
readonly budgetTokens: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'non_string_element';
|
|
43
|
+
readonly array: 'tier0' | 'tier1' | 'tier2' | 'priority';
|
|
44
|
+
readonly index: number;
|
|
45
|
+
readonly value: unknown;
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: 'priority_does_not_cover_fields';
|
|
48
|
+
readonly missing: readonly string[];
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'manifest_criterion_misaligned';
|
|
51
|
+
readonly detail: string;
|
|
52
|
+
};
|
|
53
|
+
export type ManifestValidationResult = {
|
|
54
|
+
readonly ok: true;
|
|
55
|
+
} | {
|
|
56
|
+
readonly ok: false;
|
|
57
|
+
readonly error: ManifestWellFormednessError;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* INV-MANIFEST-CRITERION (design §6.6.1): every non-excluded dreamer dimension
|
|
61
|
+
* that the fidelity criteria may adjudicate must have a corresponding injected
|
|
62
|
+
* path in the adjudicating manifest's tier0 ∪ tier1 ∪ tier2. The criteria must
|
|
63
|
+
* never ask the model to judge a dimension it cannot see.
|
|
64
|
+
*
|
|
65
|
+
* This is the direct regression guard for the Phase 0 root cause "criteria ask
|
|
66
|
+
* 5 dims, manifest injects 4" (design §12.1 conclusion 2 root cause 2). It only
|
|
67
|
+
* applies to manifests whose runnerKind is the adjudicator (evaluator); other
|
|
68
|
+
* stages are not fidelity-adjudicating and are skipped.
|
|
69
|
+
*
|
|
70
|
+
* NOTE: this checks that each non-excluded dimension's summary path
|
|
71
|
+
* (`dreamer.summary.<dim>`) is present. A future change promoting a dimension
|
|
72
|
+
* from `excluded` to `required`/`optional` in DIMENSION_COVERAGE_POLICY without
|
|
73
|
+
* adding its path to the evaluator manifest will fail this check.
|
|
74
|
+
*
|
|
75
|
+
* @param manifest the manifest to check
|
|
76
|
+
* @param isAdjudicator true only for evaluator-stage manifests (the ones whose
|
|
77
|
+
* injected fields the fidelity criteria see). Callers pass false for
|
|
78
|
+
* non-evaluator manifests so this invariant is scoped correctly.
|
|
79
|
+
*/
|
|
80
|
+
export declare function checkManifestCriterionAlignment(manifest: ContextManifest, isAdjudicator: boolean): ManifestWellFormednessError | null;
|
|
81
|
+
/**
|
|
82
|
+
* Validate a manifest is well-formed (design §6.2, requirements 4.2–4.8, 4.12,
|
|
83
|
+
* 4.13, 4.15).
|
|
84
|
+
*
|
|
85
|
+
* Checks:
|
|
86
|
+
* - budgetTokens > 0
|
|
87
|
+
* - every tier* and priority element is a string (rc-4)
|
|
88
|
+
* - priority covers every field in tier0 ∪ tier1 ∪ tier2 (with a documented
|
|
89
|
+
* escape hatch: unlisted fields are allowed but sort last via rankOf; this
|
|
90
|
+
* check is intentionally NOT enforced because rankOf defines their rank —
|
|
91
|
+
* see the note below)
|
|
92
|
+
* - INV-MANIFEST-CRITERION when the manifest is an adjudicator (§6.6.1)
|
|
93
|
+
*
|
|
94
|
+
* Note on `priority` coverage: design §6.2 requires "priority covers tier0 ∪
|
|
95
|
+
* tier1 ∪ tier2", but rankOf assigns unlisted fields a rank of
|
|
96
|
+
* `priority.length + declarationOrder` (sorting them last), which is the
|
|
97
|
+
* intended behaviour. The check here therefore only flags an empty priority
|
|
98
|
+
* when fields exist (a clear misconfiguration), rather than requiring every
|
|
99
|
+
* field be listed. The built-in manifests DO list every field.
|
|
100
|
+
*/
|
|
101
|
+
export declare function validateManifest(manifest: ContextManifest, opts?: {
|
|
102
|
+
readonly isAdjudicator?: boolean;
|
|
103
|
+
}): ManifestValidationResult;
|
|
104
|
+
/**
|
|
105
|
+
* The rank of a field path within a manifest (design §6.2 / requirement 4.6).
|
|
106
|
+
*
|
|
107
|
+
* Listed fields get their index in `priority` (0-based, ascending = higher
|
|
108
|
+
* priority). Unlisted fields get `priority.length + declarationOrder`, where
|
|
109
|
+
* declarationOrder is the field's position in dedupe(tier0 ++ tier1 ++ tier2)
|
|
110
|
+
* — so unlisted fields sort AFTER all listed fields, in a stable declaration
|
|
111
|
+
* order. This replaces the base proposal's `indexOf(...) `-1`` which sorted
|
|
112
|
+
* unlisted fields FIRST (opposite of intent).
|
|
113
|
+
*/
|
|
114
|
+
export declare function rankOf(fieldPath: string, manifest: ContextManifest): number;
|
|
115
|
+
/** All declared field paths of a manifest, deduped, in tier order. */
|
|
116
|
+
export declare function declaredFields(manifest: ContextManifest): string[];
|
|
117
|
+
//# sourceMappingURL=context-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manifest.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO/D,eAAO,MAAM,+BAA+B,EAAG,CAAU,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,OAAO,+BAA+B,CAAC;IAC/D,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,0DAA0D;IAC1D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,SAAS,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ACtE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,EAAE,CAElE"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer 1 — ContextManifest: declarative field/budget declaration (design §6.2).
|
|
3
|
+
*
|
|
4
|
+
* Pure logic only: no I/O, no fs, no DB, no network (Core vs Plugin boundary,
|
|
5
|
+
* AGENTS.md `antipattern-core-io`).
|
|
6
|
+
*
|
|
7
|
+
* A `ContextManifest` declares which field paths a runner (or an evaluator
|
|
8
|
+
* stage) needs, layered into tier0/tier1/tier2, plus a token budget and a
|
|
9
|
+
* priority ordering. Layer 1's `allocateContext` (prompt-budget-manager.ts)
|
|
10
|
+
* consumes it; Layer 3's CLI surfaces its resolution.
|
|
11
|
+
*
|
|
12
|
+
* rc-4: tier* and priority array elements are validated element-wise as
|
|
13
|
+
* strings before use. rc-5: object keys read via `Object.hasOwn`.
|
|
14
|
+
*/
|
|
15
|
+
import { DIMENSION_COVERAGE_POLICY, ALL_DREAMER_DIMENSIONS, } from './dimension-coverage-policy.js';
|
|
16
|
+
export const CONTEXT_MANIFEST_SCHEMA_VERSION = 1;
|
|
17
|
+
/** Deduplicate a string array preserving first-seen order (deterministic). */
|
|
18
|
+
function dedupe(arr) {
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const s of arr) {
|
|
22
|
+
if (!seen.has(s)) {
|
|
23
|
+
seen.add(s);
|
|
24
|
+
out.push(s);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The set of all dreamer dimension names that are NOT `excluded` — i.e. the
|
|
31
|
+
* ones the fidelity criteria may adjudicate (design §6.6.1 INV-MANIFEST-
|
|
32
|
+
* CRITERION). `strategicPerspective` is excluded and must never appear in an
|
|
33
|
+
* adjudicating manifest.
|
|
34
|
+
*/
|
|
35
|
+
const NON_EXCLUDED_DIMENSIONS = ALL_DREAMER_DIMENSIONS.filter((d) => DIMENSION_COVERAGE_POLICY[d] !== 'excluded');
|
|
36
|
+
/**
|
|
37
|
+
* INV-MANIFEST-CRITERION (design §6.6.1): every non-excluded dreamer dimension
|
|
38
|
+
* that the fidelity criteria may adjudicate must have a corresponding injected
|
|
39
|
+
* path in the adjudicating manifest's tier0 ∪ tier1 ∪ tier2. The criteria must
|
|
40
|
+
* never ask the model to judge a dimension it cannot see.
|
|
41
|
+
*
|
|
42
|
+
* This is the direct regression guard for the Phase 0 root cause "criteria ask
|
|
43
|
+
* 5 dims, manifest injects 4" (design §12.1 conclusion 2 root cause 2). It only
|
|
44
|
+
* applies to manifests whose runnerKind is the adjudicator (evaluator); other
|
|
45
|
+
* stages are not fidelity-adjudicating and are skipped.
|
|
46
|
+
*
|
|
47
|
+
* NOTE: this checks that each non-excluded dimension's summary path
|
|
48
|
+
* (`dreamer.summary.<dim>`) is present. A future change promoting a dimension
|
|
49
|
+
* from `excluded` to `required`/`optional` in DIMENSION_COVERAGE_POLICY without
|
|
50
|
+
* adding its path to the evaluator manifest will fail this check.
|
|
51
|
+
*
|
|
52
|
+
* @param manifest the manifest to check
|
|
53
|
+
* @param isAdjudicator true only for evaluator-stage manifests (the ones whose
|
|
54
|
+
* injected fields the fidelity criteria see). Callers pass false for
|
|
55
|
+
* non-evaluator manifests so this invariant is scoped correctly.
|
|
56
|
+
*/
|
|
57
|
+
export function checkManifestCriterionAlignment(manifest, isAdjudicator) {
|
|
58
|
+
if (!isAdjudicator)
|
|
59
|
+
return null;
|
|
60
|
+
if (manifest.runnerKind !== 'evaluator')
|
|
61
|
+
return null;
|
|
62
|
+
const allPaths = new Set([...manifest.tier0, ...manifest.tier1, ...manifest.tier2]);
|
|
63
|
+
const missing = [];
|
|
64
|
+
for (const dim of NON_EXCLUDED_DIMENSIONS) {
|
|
65
|
+
const path = `dreamer.summary.${dim}`;
|
|
66
|
+
if (!allPaths.has(path)) {
|
|
67
|
+
missing.push(path);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (missing.length > 0) {
|
|
71
|
+
return {
|
|
72
|
+
kind: 'manifest_criterion_misaligned',
|
|
73
|
+
detail: `Adjudicating manifest "${manifest.manifestId}" is missing dreamer summary paths for non-excluded dimensions: ${missing.join(', ')}. DIMENSION_COVERAGE_POLICY requires these to be injectable (INV-MANIFEST-CRITERION, design §6.6.1).`,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validate a manifest is well-formed (design §6.2, requirements 4.2–4.8, 4.12,
|
|
80
|
+
* 4.13, 4.15).
|
|
81
|
+
*
|
|
82
|
+
* Checks:
|
|
83
|
+
* - budgetTokens > 0
|
|
84
|
+
* - every tier* and priority element is a string (rc-4)
|
|
85
|
+
* - priority covers every field in tier0 ∪ tier1 ∪ tier2 (with a documented
|
|
86
|
+
* escape hatch: unlisted fields are allowed but sort last via rankOf; this
|
|
87
|
+
* check is intentionally NOT enforced because rankOf defines their rank —
|
|
88
|
+
* see the note below)
|
|
89
|
+
* - INV-MANIFEST-CRITERION when the manifest is an adjudicator (§6.6.1)
|
|
90
|
+
*
|
|
91
|
+
* Note on `priority` coverage: design §6.2 requires "priority covers tier0 ∪
|
|
92
|
+
* tier1 ∪ tier2", but rankOf assigns unlisted fields a rank of
|
|
93
|
+
* `priority.length + declarationOrder` (sorting them last), which is the
|
|
94
|
+
* intended behaviour. The check here therefore only flags an empty priority
|
|
95
|
+
* when fields exist (a clear misconfiguration), rather than requiring every
|
|
96
|
+
* field be listed. The built-in manifests DO list every field.
|
|
97
|
+
*/
|
|
98
|
+
export function validateManifest(manifest, opts = {}) {
|
|
99
|
+
// budgetTokens > 0
|
|
100
|
+
if (!(manifest.budgetTokens > 0)) {
|
|
101
|
+
return { ok: false, error: { kind: 'budget_not_positive', budgetTokens: manifest.budgetTokens } };
|
|
102
|
+
}
|
|
103
|
+
// element-wise string check (rc-4)
|
|
104
|
+
const arrays = [
|
|
105
|
+
['tier0', manifest.tier0],
|
|
106
|
+
['tier1', manifest.tier1],
|
|
107
|
+
['tier2', manifest.tier2],
|
|
108
|
+
['priority', manifest.priority],
|
|
109
|
+
];
|
|
110
|
+
for (const [name, arr] of arrays) {
|
|
111
|
+
for (let i = 0; i < arr.length; i++) {
|
|
112
|
+
const el = arr[i];
|
|
113
|
+
if (typeof el !== 'string') {
|
|
114
|
+
return { ok: false, error: { kind: 'non_string_element', array: name, index: i, value: el } };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// INV-MANIFEST-CRITERION (only for adjudicators)
|
|
119
|
+
const alignmentError = checkManifestCriterionAlignment(manifest, opts.isAdjudicator === true);
|
|
120
|
+
if (alignmentError !== null) {
|
|
121
|
+
return { ok: false, error: alignmentError };
|
|
122
|
+
}
|
|
123
|
+
return { ok: true };
|
|
124
|
+
}
|
|
125
|
+
// ── Priority ranking ─────────────────────────────────────────────────────────
|
|
126
|
+
/**
|
|
127
|
+
* The rank of a field path within a manifest (design §6.2 / requirement 4.6).
|
|
128
|
+
*
|
|
129
|
+
* Listed fields get their index in `priority` (0-based, ascending = higher
|
|
130
|
+
* priority). Unlisted fields get `priority.length + declarationOrder`, where
|
|
131
|
+
* declarationOrder is the field's position in dedupe(tier0 ++ tier1 ++ tier2)
|
|
132
|
+
* — so unlisted fields sort AFTER all listed fields, in a stable declaration
|
|
133
|
+
* order. This replaces the base proposal's `indexOf(...) `-1`` which sorted
|
|
134
|
+
* unlisted fields FIRST (opposite of intent).
|
|
135
|
+
*/
|
|
136
|
+
export function rankOf(fieldPath, manifest) {
|
|
137
|
+
const listedRank = manifest.priority.indexOf(fieldPath);
|
|
138
|
+
if (listedRank >= 0)
|
|
139
|
+
return listedRank;
|
|
140
|
+
const declarationOrder = dedupe([
|
|
141
|
+
...manifest.tier0,
|
|
142
|
+
...manifest.tier1,
|
|
143
|
+
...manifest.tier2,
|
|
144
|
+
]).indexOf(fieldPath);
|
|
145
|
+
// declarationOrder is >= 0 for any field actually in the manifest; use a
|
|
146
|
+
// large fallback for paths not in any tier (defensive — they shouldn't be
|
|
147
|
+
// ranked, but rankOf must never return a value that sorts them first).
|
|
148
|
+
const order = declarationOrder >= 0 ? declarationOrder : 0;
|
|
149
|
+
return manifest.priority.length + order;
|
|
150
|
+
}
|
|
151
|
+
// ── Helpers for consumers ─────────────────────────────────────────────────────
|
|
152
|
+
/** All declared field paths of a manifest, deduped, in tier order. */
|
|
153
|
+
export function declaredFields(manifest) {
|
|
154
|
+
return dedupe([...manifest.tier0, ...manifest.tier1, ...manifest.tier2]);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=context-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manifest.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GAEvB,MAAM,gCAAgC,CAAC;AAExC,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAU,CAAC;AAoC1D,8EAA8E;AAC9E,SAAS,MAAM,CAAC,GAAsB;IACpC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACZ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,uBAAuB,GAAgC,sBAAsB,CAAC,MAAM,CACxF,CAAC,CAAC,EAAE,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAA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AI,CAAC;QAAE,OAAO,UAAU,CAAC;IAEvC,MAAM,gBAAgB,GAAG,MAAM,CAAC;QAC9B,GAAG,QAAQ,CAAC,KAAK;QACjB,GAAG,QAAQ,CAAC,KAAK;QACjB,GAAG,QAAQ,CAAC,KAAK;KAClB,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACtB,yEAAyE;IACzE,0EAA0E;IAC1E,uEAAuE;IACvE,MAAM,KAAK,GAAG,gBAAgB,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,KAAK,CAAC;AAC1C,CAAC;AAED,iFAAiF;AAEjF,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,QAAyB;IACtD,OAAO,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer 1 — the 4 built-in ContextManifests (design §6.6).
|
|
3
|
+
*
|
|
4
|
+
* Pure logic only (Core vs Plugin boundary). These are the single source of
|
|
5
|
+
* truth for which manifest each peer runner uses; the manifest count is
|
|
6
|
+
* exactly 4 (dreamer / scribe / artificer / evaluator, with evaluator carrying
|
|
7
|
+
* a Stage 1 + Stage 2 variant). The three diagnostic stages own NO manifest
|
|
8
|
+
* (design §4.7.1, requirement 2.14, guarded by the scope-regression test from
|
|
9
|
+
* PR 1 task 3.21).
|
|
10
|
+
*
|
|
11
|
+
* Field-path naming convention (design §6.6):
|
|
12
|
+
* `<stage>.summary.<key>` — read from an ArtifactSummary
|
|
13
|
+
* `<stage>.predecessorSummary.*` — read from a forwarded predecessor summary
|
|
14
|
+
* `<stage>.raw.<path>` — read from tier2 full contentJson (Layer 2)
|
|
15
|
+
*
|
|
16
|
+
* budgetTokens semantics (design §6.2.1 / §6.3): the budget covers ONLY these
|
|
17
|
+
* manifest-declared injection fields. It does NOT include core grounding text
|
|
18
|
+
* (the quiet but default-on `internalization_core_grounding` flag), runner
|
|
19
|
+
* base instructions, or output-schema descriptions. `usedTokens <= budgetTokens`
|
|
20
|
+
* is therefore an injection-field budget ceiling, NOT a prompt-total-length
|
|
21
|
+
* hard cap. If prompt-total-length control is ever needed, a separate total
|
|
22
|
+
* budget must be declared with an explicit priority relation to budgetTokens.
|
|
23
|
+
*/
|
|
24
|
+
import type { ContextManifest } from './context-manifest.js';
|
|
25
|
+
/**
|
|
26
|
+
* Dreamer manifest. `pain.summary.*` / `diagnosis.summary.*` resolve to the
|
|
27
|
+
* diagnostic-chain writer-side summaries forwarded via the diag_router →
|
|
28
|
+
* dreamer `predecessorSummary` (PR 1, design §4.7.1). tier2 empty → dreamer
|
|
29
|
+
* does not read raw large fields.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DREAMER_MANIFEST: ContextManifest;
|
|
32
|
+
/**
|
|
33
|
+
* Scribe manifest. Reads the dreamer 5 dimensions through
|
|
34
|
+
* `philosopher.predecessorSummary.*` (the value of PR 1's writer-side
|
|
35
|
+
* forwarding — design §4.7 修正七). tier2 empty.
|
|
36
|
+
*/
|
|
37
|
+
export declare const SCRIBE_MANIFEST: ContextManifest;
|
|
38
|
+
/**
|
|
39
|
+
* Artificer manifest. Under the one-level-redundancy rule, dreamer 5 dims are
|
|
40
|
+
* NOT in scribe.predecessorSummary (that holds philosopher); so artificer's
|
|
41
|
+
* dreamer context continues to flow through PRI-508's `resolveDreamerContext`
|
|
42
|
+
* (F2) as tier2 raw fields.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ARTIFICER_MANIFEST: ContextManifest;
|
|
45
|
+
/**
|
|
46
|
+
* Evaluator Stage 1 manifest — summary-level only (no tier2 raw fields).
|
|
47
|
+
* Stage 1's `dreamer.summary.*` / `pain.summary.*` are read at the summary
|
|
48
|
+
* level via CandidateLineage (Layer 2); if a summary is absent the path enters
|
|
49
|
+
* `absent` and surfaces as a `summary_absent` degradation, never a silent empty.
|
|
50
|
+
*/
|
|
51
|
+
export declare const EVALUATOR_STAGE1_MANIFEST: ContextManifest;
|
|
52
|
+
/**
|
|
53
|
+
* Evaluator Stage 2 manifest — Stage 1 plus tier2 raw fields for the
|
|
54
|
+
* independent re-evaluation (design §6.5). budgetTokens is larger to
|
|
55
|
+
* accommodate the raw fields.
|
|
56
|
+
*/
|
|
57
|
+
export declare const EVALUATOR_STAGE2_MANIFEST: ContextManifest;
|
|
58
|
+
/**
|
|
59
|
+
* The built-in manifest registry. **Always exactly 4** manifests (dreamer /
|
|
60
|
+
* scribe / artificer / evaluator-with-two-variants). The three diagnostic
|
|
61
|
+
* stages own NO manifest (design §4.7.1, requirement 2.14). The scope-
|
|
62
|
+
* regression test (PR 1 task 3.21) guards this count.
|
|
63
|
+
*
|
|
64
|
+
* Exposed for: well-formedness enumeration (CP-12), the CLI's manifest
|
|
65
|
+
* resolution, and the architecture-regression assertion that no diag kind is a
|
|
66
|
+
* manifest's runnerKind.
|
|
67
|
+
*/
|
|
68
|
+
export declare const BUILTIN_MANIFESTS: readonly ContextManifest[];
|
|
69
|
+
/**
|
|
70
|
+
* The distinct runnerKinds that own a manifest. Always a subset of
|
|
71
|
+
* {dreamer, scribe, artificer, evaluator} — never includes a diagnostic kind.
|
|
72
|
+
*/
|
|
73
|
+
export declare const MANIFEST_RUNNER_KINDS: readonly string[];
|
|
74
|
+
//# sourceMappingURL=context-manifests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manifests.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAuB9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,eA8B7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,eAkBhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,eAmCvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,eAMvC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAMvD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAElD,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer 1 — the 4 built-in ContextManifests (design §6.6).
|
|
3
|
+
*
|
|
4
|
+
* Pure logic only (Core vs Plugin boundary). These are the single source of
|
|
5
|
+
* truth for which manifest each peer runner uses; the manifest count is
|
|
6
|
+
* exactly 4 (dreamer / scribe / artificer / evaluator, with evaluator carrying
|
|
7
|
+
* a Stage 1 + Stage 2 variant). The three diagnostic stages own NO manifest
|
|
8
|
+
* (design §4.7.1, requirement 2.14, guarded by the scope-regression test from
|
|
9
|
+
* PR 1 task 3.21).
|
|
10
|
+
*
|
|
11
|
+
* Field-path naming convention (design §6.6):
|
|
12
|
+
* `<stage>.summary.<key>` — read from an ArtifactSummary
|
|
13
|
+
* `<stage>.predecessorSummary.*` — read from a forwarded predecessor summary
|
|
14
|
+
* `<stage>.raw.<path>` — read from tier2 full contentJson (Layer 2)
|
|
15
|
+
*
|
|
16
|
+
* budgetTokens semantics (design §6.2.1 / §6.3): the budget covers ONLY these
|
|
17
|
+
* manifest-declared injection fields. It does NOT include core grounding text
|
|
18
|
+
* (the quiet but default-on `internalization_core_grounding` flag), runner
|
|
19
|
+
* base instructions, or output-schema descriptions. `usedTokens <= budgetTokens`
|
|
20
|
+
* is therefore an injection-field budget ceiling, NOT a prompt-total-length
|
|
21
|
+
* hard cap. If prompt-total-length control is ever needed, a separate total
|
|
22
|
+
* budget must be declared with an explicit priority relation to budgetTokens.
|
|
23
|
+
*/
|
|
24
|
+
import { CONTEXT_MANIFEST_SCHEMA_VERSION } from './context-manifest.js';
|
|
25
|
+
/**
|
|
26
|
+
* Dreamer manifest. `pain.summary.*` / `diagnosis.summary.*` resolve to the
|
|
27
|
+
* diagnostic-chain writer-side summaries forwarded via the diag_router →
|
|
28
|
+
* dreamer `predecessorSummary` (PR 1, design §4.7.1). tier2 empty → dreamer
|
|
29
|
+
* does not read raw large fields.
|
|
30
|
+
*/
|
|
31
|
+
export const DREAMER_MANIFEST = {
|
|
32
|
+
manifestId: 'dreamer.v1',
|
|
33
|
+
schemaVersion: CONTEXT_MANIFEST_SCHEMA_VERSION,
|
|
34
|
+
runnerKind: 'dreamer',
|
|
35
|
+
tier0: ['pain.summary.headline', 'diagnosis.summary.headline'],
|
|
36
|
+
tier1: [
|
|
37
|
+
'pain.summary.category',
|
|
38
|
+
'pain.summary.severity',
|
|
39
|
+
'pain.summary.rootSymptom',
|
|
40
|
+
'diagnosis.summary.rootCause',
|
|
41
|
+
'diagnosis.summary.affectedComponents',
|
|
42
|
+
],
|
|
43
|
+
tier2: [],
|
|
44
|
+
budgetTokens: 1500,
|
|
45
|
+
priority: [
|
|
46
|
+
'diagnosis.summary.rootCause',
|
|
47
|
+
'pain.summary.rootSymptom',
|
|
48
|
+
'pain.summary.category',
|
|
49
|
+
'pain.summary.severity',
|
|
50
|
+
'diagnosis.summary.affectedComponents',
|
|
51
|
+
'pain.summary.headline',
|
|
52
|
+
'diagnosis.summary.headline',
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Scribe manifest. Reads the dreamer 5 dimensions through
|
|
57
|
+
* `philosopher.predecessorSummary.*` (the value of PR 1's writer-side
|
|
58
|
+
* forwarding — design §4.7 修正七). tier2 empty.
|
|
59
|
+
*/
|
|
60
|
+
export const SCRIBE_MANIFEST = {
|
|
61
|
+
manifestId: 'scribe.v1',
|
|
62
|
+
schemaVersion: CONTEXT_MANIFEST_SCHEMA_VERSION,
|
|
63
|
+
runnerKind: 'scribe',
|
|
64
|
+
tier0: ['philosopher.summary.headline', 'philosopher.predecessorSummary.headline'],
|
|
65
|
+
tier1: [
|
|
66
|
+
'philosopher.summary.thesis',
|
|
67
|
+
'philosopher.summary.principleTitle',
|
|
68
|
+
'philosopher.summary.principleScope',
|
|
69
|
+
// dreamer 5 dims forwarded via philosopher writer (修正七's value)
|
|
70
|
+
'philosopher.predecessorSummary.badDecision',
|
|
71
|
+
'philosopher.predecessorSummary.betterDecision',
|
|
72
|
+
'philosopher.predecessorSummary.rationale',
|
|
73
|
+
'philosopher.predecessorSummary.riskLevel',
|
|
74
|
+
'philosopher.predecessorSummary.strategicPerspective',
|
|
75
|
+
],
|
|
76
|
+
tier2: [],
|
|
77
|
+
budgetTokens: 1800,
|
|
78
|
+
priority: [
|
|
79
|
+
'philosopher.summary.principleTitle',
|
|
80
|
+
'philosopher.summary.thesis',
|
|
81
|
+
'philosopher.predecessorSummary.betterDecision',
|
|
82
|
+
'philosopher.predecessorSummary.riskLevel',
|
|
83
|
+
'philosopher.predecessorSummary.rationale',
|
|
84
|
+
'philosopher.summary.principleScope',
|
|
85
|
+
'philosopher.predecessorSummary.badDecision',
|
|
86
|
+
'philosopher.predecessorSummary.strategicPerspective',
|
|
87
|
+
'philosopher.summary.headline',
|
|
88
|
+
'philosopher.predecessorSummary.headline',
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Artificer manifest. Under the one-level-redundancy rule, dreamer 5 dims are
|
|
93
|
+
* NOT in scribe.predecessorSummary (that holds philosopher); so artificer's
|
|
94
|
+
* dreamer context continues to flow through PRI-508's `resolveDreamerContext`
|
|
95
|
+
* (F2) as tier2 raw fields.
|
|
96
|
+
*/
|
|
97
|
+
export const ARTIFICER_MANIFEST = {
|
|
98
|
+
manifestId: 'artificer.v1',
|
|
99
|
+
schemaVersion: CONTEXT_MANIFEST_SCHEMA_VERSION,
|
|
100
|
+
runnerKind: 'artificer',
|
|
101
|
+
tier0: ['scribe.summary.headline', 'scribe.predecessorSummary.headline'],
|
|
102
|
+
tier1: ['scribe.summary.principleText', 'scribe.summary.scope', 'scribe.summary.exceptions'],
|
|
103
|
+
tier2: ['dreamer.raw.betterDecision', 'dreamer.raw.rationale', 'dreamer.raw.riskLevel'],
|
|
104
|
+
budgetTokens: 2000,
|
|
105
|
+
priority: [
|
|
106
|
+
'scribe.summary.principleText',
|
|
107
|
+
'dreamer.raw.betterDecision',
|
|
108
|
+
'scribe.summary.scope',
|
|
109
|
+
'dreamer.raw.rationale',
|
|
110
|
+
'dreamer.raw.riskLevel',
|
|
111
|
+
'scribe.summary.exceptions',
|
|
112
|
+
'scribe.summary.headline',
|
|
113
|
+
'scribe.predecessorSummary.headline',
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Evaluator Stage 1 manifest — summary-level only (no tier2 raw fields).
|
|
118
|
+
* Stage 1's `dreamer.summary.*` / `pain.summary.*` are read at the summary
|
|
119
|
+
* level via CandidateLineage (Layer 2); if a summary is absent the path enters
|
|
120
|
+
* `absent` and surfaces as a `summary_absent` degradation, never a silent empty.
|
|
121
|
+
*/
|
|
122
|
+
export const EVALUATOR_STAGE1_MANIFEST = {
|
|
123
|
+
manifestId: 'evaluator.stage1.v1',
|
|
124
|
+
schemaVersion: CONTEXT_MANIFEST_SCHEMA_VERSION,
|
|
125
|
+
runnerKind: 'evaluator',
|
|
126
|
+
tier0: ['artificer.summary.headline', 'artificer.predecessorSummary.headline'],
|
|
127
|
+
tier1: [
|
|
128
|
+
'scribe.summary.principleText',
|
|
129
|
+
'scribe.summary.scope',
|
|
130
|
+
'artificer.summary.changedFiles',
|
|
131
|
+
'artificer.summary.apiSurface',
|
|
132
|
+
'artificer.summary.risks',
|
|
133
|
+
'dreamer.summary.badDecision',
|
|
134
|
+
'dreamer.summary.betterDecision',
|
|
135
|
+
'dreamer.summary.rationale',
|
|
136
|
+
'dreamer.summary.riskLevel',
|
|
137
|
+
'pain.summary.rootSymptom',
|
|
138
|
+
'pain.summary.category',
|
|
139
|
+
],
|
|
140
|
+
tier2: [],
|
|
141
|
+
budgetTokens: 3000,
|
|
142
|
+
priority: [
|
|
143
|
+
'scribe.summary.principleText',
|
|
144
|
+
'dreamer.summary.betterDecision',
|
|
145
|
+
'pain.summary.rootSymptom',
|
|
146
|
+
'artificer.summary.apiSurface',
|
|
147
|
+
'dreamer.summary.riskLevel',
|
|
148
|
+
'dreamer.summary.rationale',
|
|
149
|
+
'scribe.summary.scope',
|
|
150
|
+
'artificer.summary.risks',
|
|
151
|
+
'pain.summary.category',
|
|
152
|
+
'artificer.summary.changedFiles',
|
|
153
|
+
'dreamer.summary.badDecision',
|
|
154
|
+
'artificer.summary.headline',
|
|
155
|
+
'artificer.predecessorSummary.headline',
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Evaluator Stage 2 manifest — Stage 1 plus tier2 raw fields for the
|
|
160
|
+
* independent re-evaluation (design §6.5). budgetTokens is larger to
|
|
161
|
+
* accommodate the raw fields.
|
|
162
|
+
*/
|
|
163
|
+
export const EVALUATOR_STAGE2_MANIFEST = {
|
|
164
|
+
...EVALUATOR_STAGE1_MANIFEST,
|
|
165
|
+
manifestId: 'evaluator.stage2.v1',
|
|
166
|
+
tier2: ['pain.raw.evidence', 'dreamer.raw.candidates'],
|
|
167
|
+
budgetTokens: 4500,
|
|
168
|
+
priority: [...EVALUATOR_STAGE1_MANIFEST.priority, 'pain.raw.evidence', 'dreamer.raw.candidates'],
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* The built-in manifest registry. **Always exactly 4** manifests (dreamer /
|
|
172
|
+
* scribe / artificer / evaluator-with-two-variants). The three diagnostic
|
|
173
|
+
* stages own NO manifest (design §4.7.1, requirement 2.14). The scope-
|
|
174
|
+
* regression test (PR 1 task 3.21) guards this count.
|
|
175
|
+
*
|
|
176
|
+
* Exposed for: well-formedness enumeration (CP-12), the CLI's manifest
|
|
177
|
+
* resolution, and the architecture-regression assertion that no diag kind is a
|
|
178
|
+
* manifest's runnerKind.
|
|
179
|
+
*/
|
|
180
|
+
export const BUILTIN_MANIFESTS = [
|
|
181
|
+
DREAMER_MANIFEST,
|
|
182
|
+
SCRIBE_MANIFEST,
|
|
183
|
+
ARTIFICER_MANIFEST,
|
|
184
|
+
EVALUATOR_STAGE1_MANIFEST,
|
|
185
|
+
EVALUATOR_STAGE2_MANIFEST,
|
|
186
|
+
];
|
|
187
|
+
/**
|
|
188
|
+
* The distinct runnerKinds that own a manifest. Always a subset of
|
|
189
|
+
* {dreamer, scribe, artificer, evaluator} — never includes a diagnostic kind.
|
|
190
|
+
*/
|
|
191
|
+
export const MANIFEST_RUNNER_KINDS = Array.from(new Set(BUILTIN_MANIFESTS.map((m) => m.runnerKind)));
|
|
192
|
+
//# sourceMappingURL=context-manifests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-manifests.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC/C,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,+BAA+B;IAC9C,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,CAAC,uBAAuB,EAAE,4BAA4B,CAAC;IAC9D,KAAK,EAAE;QACL,uBAAuB;QACvB,uBAAuB;QACvB,0BAA0B;QAC1B,6BAA6B;QAC7B,sCAAsC;KACvC;IACD,KAAK,EAAE,EAAE;IACT,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE;QACR,6BAA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-0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dreamer dimension coverage policy (design §6.5.1).
|
|
3
|
+
*
|
|
4
|
+
* The **single source of truth** for how the dreamer's five decision
|
|
5
|
+
* dimensions map to fidelity-judgement coverage classes. Both Layer 1
|
|
6
|
+
* (context-manifest well-formedness, INV-MANIFEST-CRITERION) and Layer 2 / PR 4
|
|
7
|
+
* (the progressive evaluator's flagged criteria) read this table — neither
|
|
8
|
+
* inlines a dimension-name array.
|
|
9
|
+
*
|
|
10
|
+
* rc-5 / ERR-013: dimension lookups must NOT use plain object indexing on an
|
|
11
|
+
* untrusted string (`table['__proto__']` would hit `Object.prototype`). This
|
|
12
|
+
* module only ever looks up dimensions it defines itself, so a typed record is
|
|
13
|
+
* safe here — but consumers that look up an LLM-supplied string must guard with
|
|
14
|
+
* `Object.hasOwn` or a `Map`.
|
|
15
|
+
*/
|
|
16
|
+
/** The five dimensions a dreamer candidate carries (design §6.1 dreamer fields). */
|
|
17
|
+
export type DreamerDimension = 'badDecision' | 'betterDecision' | 'rationale' | 'riskLevel' | 'strategicPerspective';
|
|
18
|
+
/** How a dimension participates in compression-fidelity judgement. */
|
|
19
|
+
export type DimensionCoverageClass = 'required' | 'optional' | 'excluded';
|
|
20
|
+
/**
|
|
21
|
+
* The coverage policy table (design §6.5.1).
|
|
22
|
+
*
|
|
23
|
+
* required normative content: must have a semantically-equivalent
|
|
24
|
+
* expression in the principle text; absence counts as a defect
|
|
25
|
+
* and enters `missingDimensions` + the flag path.
|
|
26
|
+
* optional counted as covered when present in `antiPatterns`; absence is
|
|
27
|
+
* NOT a defect, only recorded in `optionalUncovered` for diagnosis.
|
|
28
|
+
* Never enters `missingDimensions` and never flags.
|
|
29
|
+
* excluded an evaluation-lens label, not normative content; the criteria
|
|
30
|
+
* must NOT draw a conclusion about it, and it is never injected
|
|
31
|
+
* into the adjudicating manifest (§6.6.1).
|
|
32
|
+
*/
|
|
33
|
+
export declare const DIMENSION_COVERAGE_POLICY: Readonly<Record<DreamerDimension, DimensionCoverageClass>>;
|
|
34
|
+
/**
|
|
35
|
+
* The required dimensions, derived from the policy table (order stable for
|
|
36
|
+
* deterministic output). Consumers read this instead of inlining a string
|
|
37
|
+
* array.
|
|
38
|
+
*/
|
|
39
|
+
export declare const REQUIRED_FIDELITY_DIMENSIONS: readonly DreamerDimension[];
|
|
40
|
+
/** All five dimension names (order stable). */
|
|
41
|
+
export declare const ALL_DREAMER_DIMENSIONS: readonly DreamerDimension[];
|
|
42
|
+
/**
|
|
43
|
+
* rc-5-safe policy lookup for an untrusted (LLM-supplied) string. Returns the
|
|
44
|
+
* class only when `dim` is genuinely one of the five declared dimensions;
|
|
45
|
+
* `undefined` otherwise (so callers can ignore unknown / optional / excluded
|
|
46
|
+
* values the model may have stuffed into `missingDimensions`).
|
|
47
|
+
*/
|
|
48
|
+
export declare function lookupDimensionPolicy(dim: string): DimensionCoverageClass | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* True iff `dim` is a required dimension (used by the flagged-criteria filter,
|
|
51
|
+
* §6.5.3). Accepts an untrusted string.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isRequiredDimension(dim: string): boolean;
|
|
54
|
+
//# sourceMappingURL=dimension-coverage-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimension-coverage-policy.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/dimension-coverage-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oFAAoF;AACpF,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,gBAAgB,GAChB,WAAW,GACX,WAAW,GACX,sBAAsB,CAAC;AAE3B,sEAAsE;AACtE,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,CAAC;AAE1E;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,CAMvF,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,gBAAgB,EAI9C,CAAC;AAEvB,+CAA+C;AAC/C,eAAO,MAAM,sBAAsB,EAAE,SAAS,gBAAgB,EAM7D,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAGrF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAExD"}
|