@principles/core 1.168.0 → 1.169.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.
Files changed (112) hide show
  1. package/dist/runtime-v2/__tests__/activation-types-helpers.test.js +6 -14
  2. package/dist/runtime-v2/__tests__/activation-types-helpers.test.js.map +1 -1
  3. package/dist/runtime-v2/__tests__/architecture-regression.test.js +2 -66
  4. package/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
  5. package/dist/runtime-v2/__tests__/intake-to-internalization-bridge.test.js +1 -2
  6. package/dist/runtime-v2/__tests__/intake-to-internalization-bridge.test.js.map +1 -1
  7. package/dist/runtime-v2/__tests__/internalization-orchestrator.test.js +8 -8
  8. package/dist/runtime-v2/__tests__/internalization-orchestrator.test.js.map +1 -1
  9. package/dist/runtime-v2/__tests__/internalization-peer-runner-contracts.test.js +45 -80
  10. package/dist/runtime-v2/__tests__/internalization-peer-runner-contracts.test.js.map +1 -1
  11. package/dist/runtime-v2/__tests__/internalization-state-machine.test.js +31 -130
  12. package/dist/runtime-v2/__tests__/internalization-state-machine.test.js.map +1 -1
  13. package/dist/runtime-v2/__tests__/pain-to-principle-service.test.js +0 -1
  14. package/dist/runtime-v2/__tests__/pain-to-principle-service.test.js.map +1 -1
  15. package/dist/runtime-v2/__tests__/pitask-metadata.test.js +4 -4
  16. package/dist/runtime-v2/__tests__/pitask-metadata.test.js.map +1 -1
  17. package/dist/runtime-v2/__tests__/proven-channel-baseline.test.js +2 -5
  18. package/dist/runtime-v2/__tests__/proven-channel-baseline.test.js.map +1 -1
  19. package/dist/runtime-v2/__tests__/story-a-demo.test.js +2 -2
  20. package/dist/runtime-v2/__tests__/story-a-demo.test.js.map +1 -1
  21. package/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js +7 -10
  22. package/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js.map +1 -1
  23. package/dist/runtime-v2/activation/__tests__/approval-queue.test.js +1 -3
  24. package/dist/runtime-v2/activation/__tests__/approval-queue.test.js.map +1 -1
  25. package/dist/runtime-v2/activation/__tests__/approval-store-extended.test.js +4 -4
  26. package/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js +6 -6
  27. package/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js.map +1 -1
  28. package/dist/runtime-v2/activation/activation-dispatcher.d.ts.map +1 -1
  29. package/dist/runtime-v2/activation/activation-dispatcher.js +0 -1
  30. package/dist/runtime-v2/activation/activation-dispatcher.js.map +1 -1
  31. package/dist/runtime-v2/activation/activation-types.d.ts.map +1 -1
  32. package/dist/runtime-v2/activation/activation-types.js +0 -1
  33. package/dist/runtime-v2/activation/activation-types.js.map +1 -1
  34. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  35. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +0 -2
  36. package/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
  37. package/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +0 -7
  38. package/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
  39. package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +5 -6
  40. package/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
  41. package/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js +0 -1
  42. package/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js.map +1 -1
  43. package/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +0 -1
  44. package/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
  45. package/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  46. package/dist/runtime-v2/config/pd-config-defaults.js +0 -1
  47. package/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  48. package/dist/runtime-v2/config/pd-config-types.d.ts +1 -1
  49. package/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  50. package/dist/runtime-v2/config/pd-config-types.js +0 -1
  51. package/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  52. package/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  53. package/dist/runtime-v2/feature-flags/feature-flag-contract.js +0 -2
  54. package/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  55. package/dist/runtime-v2/index.d.ts +1 -7
  56. package/dist/runtime-v2/index.d.ts.map +1 -1
  57. package/dist/runtime-v2/index.js +1 -4
  58. package/dist/runtime-v2/index.js.map +1 -1
  59. package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +0 -3
  60. package/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -1
  61. package/dist/runtime-v2/internalization/__tests__/internalization-job-graph.test.js +4 -36
  62. package/dist/runtime-v2/internalization/__tests__/internalization-job-graph.test.js.map +1 -1
  63. package/dist/runtime-v2/internalization/__tests__/peer-runner-lineage-injection.test.js +0 -1
  64. package/dist/runtime-v2/internalization/__tests__/peer-runner-lineage-injection.test.js.map +1 -1
  65. package/dist/runtime-v2/internalization/__tests__/queue-actionability.test.js +0 -15
  66. package/dist/runtime-v2/internalization/__tests__/queue-actionability.test.js.map +1 -1
  67. package/dist/runtime-v2/internalization/index.d.ts +1 -7
  68. package/dist/runtime-v2/internalization/index.d.ts.map +1 -1
  69. package/dist/runtime-v2/internalization/index.js +1 -4
  70. package/dist/runtime-v2/internalization/index.js.map +1 -1
  71. package/dist/runtime-v2/internalization/internalization-job-graph.d.ts +7 -18
  72. package/dist/runtime-v2/internalization/internalization-job-graph.d.ts.map +1 -1
  73. package/dist/runtime-v2/internalization/internalization-job-graph.js +7 -24
  74. package/dist/runtime-v2/internalization/internalization-job-graph.js.map +1 -1
  75. package/dist/runtime-v2/internalization/internalization-state-machine.d.ts +3 -2
  76. package/dist/runtime-v2/internalization/internalization-state-machine.d.ts.map +1 -1
  77. package/dist/runtime-v2/internalization/internalization-state-machine.js +4 -3
  78. package/dist/runtime-v2/internalization/internalization-state-machine.js.map +1 -1
  79. package/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +6 -6
  80. package/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
  81. package/dist/runtime-v2/internalization/peer-runner-contracts.js +0 -3
  82. package/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
  83. package/dist/runtime-v2/recovery-sweep-service.d.ts.map +1 -1
  84. package/dist/runtime-v2/recovery-sweep-service.js +2 -2
  85. package/dist/runtime-v2/recovery-sweep-service.js.map +1 -1
  86. package/dist/runtime-v2/store/candidate/__tests__/recommendation-kind-resolver.test.js +1 -1
  87. package/dist/runtime-v2/store/candidate/__tests__/recommendation-kind-resolver.test.js.map +1 -1
  88. package/package.json +1 -1
  89. package/dist/runtime-v2/__tests__/trainer-output-validator.test.d.ts +0 -2
  90. package/dist/runtime-v2/__tests__/trainer-output-validator.test.d.ts.map +0 -1
  91. package/dist/runtime-v2/__tests__/trainer-output-validator.test.js +0 -257
  92. package/dist/runtime-v2/__tests__/trainer-output-validator.test.js.map +0 -1
  93. package/dist/runtime-v2/__tests__/trainer-runner-vslice.test.d.ts +0 -2
  94. package/dist/runtime-v2/__tests__/trainer-runner-vslice.test.d.ts.map +0 -1
  95. package/dist/runtime-v2/__tests__/trainer-runner-vslice.test.js +0 -514
  96. package/dist/runtime-v2/__tests__/trainer-runner-vslice.test.js.map +0 -1
  97. package/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.d.ts +0 -2
  98. package/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.d.ts.map +0 -1
  99. package/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.js +0 -141
  100. package/dist/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.js.map +0 -1
  101. package/dist/runtime-v2/internalization/trainer-output.d.ts +0 -122
  102. package/dist/runtime-v2/internalization/trainer-output.d.ts.map +0 -1
  103. package/dist/runtime-v2/internalization/trainer-output.js +0 -223
  104. package/dist/runtime-v2/internalization/trainer-output.js.map +0 -1
  105. package/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts +0 -24
  106. package/dist/runtime-v2/internalization/trainer-prompt-builder.d.ts.map +0 -1
  107. package/dist/runtime-v2/internalization/trainer-prompt-builder.js +0 -57
  108. package/dist/runtime-v2/internalization/trainer-prompt-builder.js.map +0 -1
  109. package/dist/runtime-v2/internalization/trainer-runner.d.ts +0 -76
  110. package/dist/runtime-v2/internalization/trainer-runner.d.ts.map +0 -1
  111. package/dist/runtime-v2/internalization/trainer-runner.js +0 -540
  112. package/dist/runtime-v2/internalization/trainer-runner.js.map +0 -1
@@ -1,141 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { TrainerPromptBuilder, TRAINER_PROTOCOL_INSTRUCTION, TRAINER_PROMPT_CONTRACT_VERSION } from '../trainer-prompt-builder.js';
3
- const TASK_ID = 'trainer-001';
4
- const CONTEXT_HASH = 'ctx-abc123';
5
- const SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID = 'pi-art-rollout-reviewer-001';
6
- const ROLLOUT_REVIEWER_ARTIFACT = {
7
- taskId: 'rollout-reviewer-001',
8
- sourceEvaluatorArtifactId: 'pi-art-evaluator-001',
9
- review: {
10
- decision: 'approve_rollout',
11
- summary: 'The rollout plan is safe to proceed',
12
- confidence: 0.9,
13
- requiredChanges: [],
14
- rolloutRisks: ['Feature flag configuration may need adjustment'],
15
- safetyChecks: ['Verify feature flag is properly configured'],
16
- },
17
- sourceTrace: {
18
- evaluatorArtifactId: 'pi-art-evaluator-001',
19
- },
20
- risks: ['Rollback plan should be tested before deployment'],
21
- generatedAt: '2026-05-11T12:00:00.000Z',
22
- };
23
- describe('TrainerPromptBuilder (vertical slice)', () => {
24
- it('buildPrompt returns a message string', () => {
25
- const builder = new TrainerPromptBuilder();
26
- const result = builder.buildPrompt({
27
- taskId: TASK_ID,
28
- contextHash: CONTEXT_HASH,
29
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
30
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
31
- });
32
- expect(typeof result.message).toBe('string');
33
- expect(result.message.length).toBeGreaterThan(0);
34
- });
35
- it('promptInput includes taskId', () => {
36
- const builder = new TrainerPromptBuilder();
37
- const result = builder.buildPrompt({
38
- taskId: TASK_ID,
39
- contextHash: CONTEXT_HASH,
40
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
41
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
42
- });
43
- expect(result.promptInput.taskId).toBe(TASK_ID);
44
- });
45
- it('promptInput includes contextHash', () => {
46
- const builder = new TrainerPromptBuilder();
47
- const result = builder.buildPrompt({
48
- taskId: TASK_ID,
49
- contextHash: CONTEXT_HASH,
50
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
51
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
52
- });
53
- expect(result.promptInput.contextHash).toBe(CONTEXT_HASH);
54
- });
55
- it('promptInput includes sourceRolloutReviewerArtifactId', () => {
56
- const builder = new TrainerPromptBuilder();
57
- const result = builder.buildPrompt({
58
- taskId: TASK_ID,
59
- contextHash: CONTEXT_HASH,
60
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
61
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
62
- });
63
- expect(result.promptInput.sourceRolloutReviewerArtifactId).toBe(SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID);
64
- });
65
- it('promptInput includes rolloutReviewerArtifact', () => {
66
- const builder = new TrainerPromptBuilder();
67
- const result = builder.buildPrompt({
68
- taskId: TASK_ID,
69
- contextHash: CONTEXT_HASH,
70
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
71
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
72
- });
73
- expect(result.promptInput.rolloutReviewerArtifact).toBe(ROLLOUT_REVIEWER_ARTIFACT);
74
- });
75
- it('promptInput includes trainerInstruction', () => {
76
- const builder = new TrainerPromptBuilder();
77
- const result = builder.buildPrompt({
78
- taskId: TASK_ID,
79
- contextHash: CONTEXT_HASH,
80
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
81
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
82
- });
83
- expect(typeof result.promptInput.trainerInstruction).toBe('string');
84
- expect(result.promptInput.trainerInstruction.length).toBeGreaterThan(0);
85
- });
86
- it('promptInput includes promptContractVersion', () => {
87
- const builder = new TrainerPromptBuilder();
88
- const result = builder.buildPrompt({
89
- taskId: TASK_ID,
90
- contextHash: CONTEXT_HASH,
91
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
92
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
93
- });
94
- expect(result.promptInput.promptContractVersion).toBe('trainer-output-v1.prompt.v1');
95
- });
96
- it('message is valid JSON parseable', () => {
97
- const builder = new TrainerPromptBuilder();
98
- const result = builder.buildPrompt({
99
- taskId: TASK_ID,
100
- contextHash: CONTEXT_HASH,
101
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
102
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
103
- });
104
- expect(() => JSON.parse(result.message)).not.toThrow();
105
- });
106
- it('parsed message contains all required fields', () => {
107
- const builder = new TrainerPromptBuilder();
108
- const result = builder.buildPrompt({
109
- taskId: TASK_ID,
110
- contextHash: CONTEXT_HASH,
111
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
112
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
113
- });
114
- const parsed = JSON.parse(result.message);
115
- expect(parsed.taskId).toBe(TASK_ID);
116
- expect(parsed.contextHash).toBe(CONTEXT_HASH);
117
- expect(parsed.sourceRolloutReviewerArtifactId).toBe(SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID);
118
- expect(parsed.rolloutReviewerArtifact).toBeDefined();
119
- expect(parsed.trainerInstruction).toBeDefined();
120
- expect(parsed.promptContractVersion).toBe('trainer-output-v1.prompt.v1');
121
- });
122
- it('message does not include markdown code fences', () => {
123
- const builder = new TrainerPromptBuilder();
124
- const result = builder.buildPrompt({
125
- taskId: TASK_ID,
126
- contextHash: CONTEXT_HASH,
127
- sourceRolloutReviewerArtifactId: SOURCE_ROLLOUT_REVIEWER_ARTIFACT_ID,
128
- rolloutReviewerArtifact: ROLLOUT_REVIEWER_ARTIFACT,
129
- });
130
- expect(result.message).not.toMatch(/^```/);
131
- expect(result.message).not.toMatch(/```$/);
132
- });
133
- it('trainerInstruction contains JSON-only directive', () => {
134
- expect(TRAINER_PROTOCOL_INSTRUCTION).toContain('JSON');
135
- expect(TRAINER_PROTOCOL_INSTRUCTION).toContain('only');
136
- });
137
- it('promptContractVersion constant is trainer-output-v1.prompt.v1', () => {
138
- expect(TRAINER_PROMPT_CONTRACT_VERSION).toBe('trainer-output-v1.prompt.v1');
139
- });
140
- });
141
- //# sourceMappingURL=trainer-prompt-builder.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trainer-prompt-builder.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/trainer-prompt-builder.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAEnI,MAAM,OAAO,GAAG,aAAa,CAAC;AAC9B,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,mCAAmC,GAAG,6BAA6B,CAAC;AAE1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AAO,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,CAAC,4BAA4B,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,CAAC,4BAA4B,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,CAAC,+BAA+B,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,122 +0,0 @@
1
- import { type Static } from '@sinclair/typebox';
2
- export interface TrainerRuleCandidate {
3
- readonly toolScope: string;
4
- readonly triggerCondition: string;
5
- readonly proposedDecision: 'allow' | 'block' | 'require_approval' | 'auto_correct';
6
- readonly proposedCorrection?: {
7
- readonly description: string;
8
- readonly proposedParams: unknown;
9
- };
10
- readonly rationale: string;
11
- readonly confidence: number;
12
- }
13
- export interface TrainerSafety {
14
- readonly limitations: readonly string[];
15
- readonly falsePositiveRisks: readonly string[];
16
- readonly requiredReplayCases: readonly string[];
17
- }
18
- export interface TrainerSourceTrace {
19
- readonly rolloutReviewerArtifactId: string;
20
- readonly evaluatorArtifactId?: string;
21
- readonly artificerArtifactId?: string;
22
- readonly scribeArtifactId?: string;
23
- readonly philosopherArtifactId?: string;
24
- readonly dreamerArtifactId?: string;
25
- }
26
- export interface TrainerOutputV1 {
27
- readonly taskId: string;
28
- readonly sourceRolloutReviewerArtifactId: string;
29
- readonly ruleCandidate: TrainerRuleCandidate;
30
- readonly goldenTraceRefs?: readonly string[];
31
- readonly inlineGoldenTraceCases?: readonly {
32
- readonly caseId: string;
33
- readonly kind: 'negative' | 'positive';
34
- readonly toolName: string;
35
- readonly params: unknown;
36
- readonly expectedDecision: 'allow' | 'block' | 'propose_correction';
37
- readonly expectedProposedParams?: unknown;
38
- readonly expectedApplicationMode?: 'shadow' | 'live';
39
- readonly sourceRefs?: readonly string[];
40
- }[];
41
- readonly safety: TrainerSafety;
42
- readonly sourceTrace: TrainerSourceTrace;
43
- readonly generatedAt: string;
44
- }
45
- export declare const TRAINER_DECISIONS: readonly ["allow", "block", "require_approval", "auto_correct"];
46
- export declare const TrainerRuleCandidateSchema: import("@sinclair/typebox").TObject<{
47
- toolScope: import("@sinclair/typebox").TString;
48
- triggerCondition: import("@sinclair/typebox").TString;
49
- proposedDecision: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"allow">, import("@sinclair/typebox").TLiteral<"block">, import("@sinclair/typebox").TLiteral<"require_approval">, import("@sinclair/typebox").TLiteral<"auto_correct">]>;
50
- proposedCorrection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
51
- description: import("@sinclair/typebox").TString;
52
- proposedParams: import("@sinclair/typebox").TAny;
53
- }>>;
54
- rationale: import("@sinclair/typebox").TString;
55
- confidence: import("@sinclair/typebox").TNumber;
56
- }>;
57
- export declare const TrainerSafetySchema: import("@sinclair/typebox").TObject<{
58
- limitations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
59
- falsePositiveRisks: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
60
- requiredReplayCases: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
61
- }>;
62
- export declare const TrainerSourceTraceSchema: import("@sinclair/typebox").TObject<{
63
- rolloutReviewerArtifactId: import("@sinclair/typebox").TString;
64
- evaluatorArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
65
- artificerArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
66
- scribeArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
67
- philosopherArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
68
- dreamerArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
69
- }>;
70
- export declare const TrainerOutputV1Schema: import("@sinclair/typebox").TObject<{
71
- taskId: import("@sinclair/typebox").TString;
72
- sourceRolloutReviewerArtifactId: import("@sinclair/typebox").TString;
73
- ruleCandidate: import("@sinclair/typebox").TObject<{
74
- toolScope: import("@sinclair/typebox").TString;
75
- triggerCondition: import("@sinclair/typebox").TString;
76
- proposedDecision: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"allow">, import("@sinclair/typebox").TLiteral<"block">, import("@sinclair/typebox").TLiteral<"require_approval">, import("@sinclair/typebox").TLiteral<"auto_correct">]>;
77
- proposedCorrection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
78
- description: import("@sinclair/typebox").TString;
79
- proposedParams: import("@sinclair/typebox").TAny;
80
- }>>;
81
- rationale: import("@sinclair/typebox").TString;
82
- confidence: import("@sinclair/typebox").TNumber;
83
- }>;
84
- goldenTraceRefs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
85
- inlineGoldenTraceCases: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
86
- caseId: import("@sinclair/typebox").TString;
87
- kind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"negative">, import("@sinclair/typebox").TLiteral<"positive">]>;
88
- toolName: import("@sinclair/typebox").TString;
89
- params: import("@sinclair/typebox").TAny;
90
- expectedDecision: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"allow">, import("@sinclair/typebox").TLiteral<"block">, import("@sinclair/typebox").TLiteral<"propose_correction">]>;
91
- expectedProposedParams: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
92
- expectedApplicationMode: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"shadow">, import("@sinclair/typebox").TLiteral<"live">]>>;
93
- sourceRefs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
94
- }>>>;
95
- safety: import("@sinclair/typebox").TObject<{
96
- limitations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
97
- falsePositiveRisks: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
98
- requiredReplayCases: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
99
- }>;
100
- sourceTrace: import("@sinclair/typebox").TObject<{
101
- rolloutReviewerArtifactId: import("@sinclair/typebox").TString;
102
- evaluatorArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
103
- artificerArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
104
- scribeArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
105
- philosopherArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
106
- dreamerArtifactId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
107
- }>;
108
- generatedAt: import("@sinclair/typebox").TString;
109
- }>;
110
- export type TrainerOutputV1TB = Static<typeof TrainerOutputV1Schema>;
111
- export interface TrainerValidationResult {
112
- readonly valid: boolean;
113
- readonly errors: readonly string[];
114
- readonly errorCategory?: string;
115
- }
116
- export interface TrainerValidator {
117
- validate(output: TrainerOutputV1, taskId: string, expectedSourceRolloutReviewerArtifactId?: string): Promise<TrainerValidationResult>;
118
- }
119
- export declare class DefaultTrainerValidator implements TrainerValidator {
120
- validate(output: TrainerOutputV1, taskId: string, expectedSourceRolloutReviewerArtifactId?: string): Promise<TrainerValidationResult>;
121
- }
122
- //# sourceMappingURL=trainer-output.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trainer-output.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/trainer-output.ts"],"names":[],"mappings":"AAAA,OAAO,EA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Ae,EAAE,MAAM,EAAE,MAAM,EAAE,uCAAuC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACvI;AAED,qBAAa,uBAAwB,YAAW,gBAAgB;IAExD,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,uCAAuC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAiK5I"}
@@ -1,223 +0,0 @@
1
- import { Type } from '@sinclair/typebox';
2
- export const TRAINER_DECISIONS = ['allow', 'block', 'require_approval', 'auto_correct'];
3
- export const TrainerRuleCandidateSchema = Type.Object({
4
- toolScope: Type.String({ minLength: 1 }),
5
- triggerCondition: Type.String({ minLength: 1 }),
6
- proposedDecision: Type.Union([
7
- Type.Literal('allow'),
8
- Type.Literal('block'),
9
- Type.Literal('require_approval'),
10
- Type.Literal('auto_correct'),
11
- ]),
12
- proposedCorrection: Type.Optional(Type.Object({
13
- description: Type.String({ minLength: 1 }),
14
- proposedParams: Type.Any(),
15
- })),
16
- rationale: Type.String({ minLength: 1 }),
17
- confidence: Type.Number({ minimum: 0, maximum: 1 }),
18
- });
19
- export const TrainerSafetySchema = Type.Object({
20
- limitations: Type.Array(Type.String()),
21
- falsePositiveRisks: Type.Array(Type.String()),
22
- requiredReplayCases: Type.Array(Type.String()),
23
- });
24
- export const TrainerSourceTraceSchema = Type.Object({
25
- rolloutReviewerArtifactId: Type.String({ minLength: 1 }),
26
- evaluatorArtifactId: Type.Optional(Type.String()),
27
- artificerArtifactId: Type.Optional(Type.String()),
28
- scribeArtifactId: Type.Optional(Type.String()),
29
- philosopherArtifactId: Type.Optional(Type.String()),
30
- dreamerArtifactId: Type.Optional(Type.String()),
31
- });
32
- export const TrainerOutputV1Schema = Type.Object({
33
- taskId: Type.String({ minLength: 1 }),
34
- sourceRolloutReviewerArtifactId: Type.String({ minLength: 1 }),
35
- ruleCandidate: TrainerRuleCandidateSchema,
36
- goldenTraceRefs: Type.Optional(Type.Array(Type.String())),
37
- inlineGoldenTraceCases: Type.Optional(Type.Array(Type.Object({
38
- caseId: Type.String({ minLength: 1 }),
39
- kind: Type.Union([Type.Literal('negative'), Type.Literal('positive')]),
40
- toolName: Type.String({ minLength: 1 }),
41
- params: Type.Any(),
42
- expectedDecision: Type.Union([
43
- Type.Literal('allow'),
44
- Type.Literal('block'),
45
- Type.Literal('propose_correction'),
46
- ]),
47
- expectedProposedParams: Type.Optional(Type.Any()),
48
- expectedApplicationMode: Type.Optional(Type.Union([
49
- Type.Literal('shadow'),
50
- Type.Literal('live'),
51
- ])),
52
- sourceRefs: Type.Optional(Type.Array(Type.String())),
53
- }))),
54
- safety: TrainerSafetySchema,
55
- sourceTrace: TrainerSourceTraceSchema,
56
- generatedAt: Type.String({ minLength: 1 }),
57
- });
58
- export class DefaultTrainerValidator {
59
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this
60
- async validate(output, taskId, expectedSourceRolloutReviewerArtifactId) {
61
- const errors = [];
62
- if (typeof output !== 'object' || output === null) {
63
- return { valid: false, errors: ['Output is not an object'], errorCategory: 'output_invalid' };
64
- }
65
- if (output.taskId !== taskId) {
66
- errors.push(`taskId mismatch: expected ${taskId}, got ${String(output.taskId)}`);
67
- }
68
- if (typeof output.sourceRolloutReviewerArtifactId !== 'string' || output.sourceRolloutReviewerArtifactId.trim() === '') {
69
- errors.push('sourceRolloutReviewerArtifactId must be non-empty string');
70
- }
71
- else if (expectedSourceRolloutReviewerArtifactId && output.sourceRolloutReviewerArtifactId !== expectedSourceRolloutReviewerArtifactId) {
72
- errors.push(`sourceRolloutReviewerArtifactId mismatch: expected ${expectedSourceRolloutReviewerArtifactId}, got ${output.sourceRolloutReviewerArtifactId}`);
73
- }
74
- if (typeof output.ruleCandidate !== 'object' || output.ruleCandidate === null) {
75
- errors.push('ruleCandidate must be an object');
76
- }
77
- else {
78
- const rc = output.ruleCandidate;
79
- if (typeof rc.toolScope !== 'string' || (rc.toolScope).trim() === '') {
80
- errors.push('ruleCandidate.toolScope must be non-empty string');
81
- }
82
- if (typeof rc.triggerCondition !== 'string' || (rc.triggerCondition).trim() === '') {
83
- errors.push('ruleCandidate.triggerCondition must be non-empty string');
84
- }
85
- if (!TRAINER_DECISIONS.includes(rc.proposedDecision)) {
86
- errors.push(`ruleCandidate.proposedDecision must be one of ${TRAINER_DECISIONS.join('/')}, got ${String(rc.proposedDecision)}`);
87
- }
88
- if (typeof rc.rationale !== 'string' || (rc.rationale).trim() === '') {
89
- errors.push('ruleCandidate.rationale must be non-empty string');
90
- }
91
- if (typeof rc.confidence !== 'number' || !Number.isFinite(rc.confidence)) {
92
- errors.push('ruleCandidate.confidence must be number');
93
- }
94
- else if (rc.confidence < 0 || rc.confidence > 1) {
95
- errors.push('ruleCandidate.confidence must be in [0, 1]');
96
- }
97
- const isAutoCorrect = rc.proposedDecision === 'auto_correct';
98
- const hasProposedCorrection = rc.proposedCorrection !== undefined && rc.proposedCorrection !== null;
99
- if (isAutoCorrect && !hasProposedCorrection) {
100
- errors.push('ruleCandidate.proposedCorrection is required when proposedDecision is auto_correct');
101
- }
102
- if (!isAutoCorrect && hasProposedCorrection) {
103
- errors.push('ruleCandidate.proposedCorrection must not exist when proposedDecision is not auto_correct');
104
- }
105
- if (hasProposedCorrection) {
106
- const pc = rc.proposedCorrection;
107
- if (typeof pc !== 'object' || pc === null) {
108
- errors.push('ruleCandidate.proposedCorrection must be an object');
109
- }
110
- else {
111
- if (typeof pc.description !== 'string' || (pc.description).trim() === '') {
112
- errors.push('ruleCandidate.proposedCorrection.description must be a non-empty string');
113
- }
114
- if (pc.proposedParams === undefined) {
115
- errors.push('ruleCandidate.proposedCorrection.proposedParams is required');
116
- }
117
- }
118
- }
119
- }
120
- if (typeof output.safety !== 'object' || output.safety === null) {
121
- errors.push('safety must be an object');
122
- }
123
- else {
124
- const s = output.safety;
125
- if (!Array.isArray(s.limitations)) {
126
- errors.push('safety.limitations must be an array');
127
- }
128
- else if (!s.limitations.every(e => typeof e === 'string')) {
129
- errors.push('safety.limitations must be an array of strings');
130
- }
131
- if (!Array.isArray(s.falsePositiveRisks)) {
132
- errors.push('safety.falsePositiveRisks must be an array');
133
- }
134
- else if (!s.falsePositiveRisks.every(e => typeof e === 'string')) {
135
- errors.push('safety.falsePositiveRisks must be an array of strings');
136
- }
137
- if (!Array.isArray(s.requiredReplayCases)) {
138
- errors.push('safety.requiredReplayCases must be an array');
139
- }
140
- else if (!s.requiredReplayCases.every(e => typeof e === 'string')) {
141
- errors.push('safety.requiredReplayCases must be an array of strings');
142
- }
143
- }
144
- if (typeof output.sourceTrace !== 'object' || output.sourceTrace === null) {
145
- errors.push('sourceTrace must be an object');
146
- }
147
- else {
148
- const st = output.sourceTrace;
149
- if (typeof st.rolloutReviewerArtifactId !== 'string' || (st.rolloutReviewerArtifactId).trim() === '') {
150
- errors.push('sourceTrace.rolloutReviewerArtifactId must be non-empty string');
151
- }
152
- else if (expectedSourceRolloutReviewerArtifactId && st.rolloutReviewerArtifactId !== expectedSourceRolloutReviewerArtifactId) {
153
- errors.push(`sourceTrace.rolloutReviewerArtifactId mismatch: expected ${expectedSourceRolloutReviewerArtifactId}, got ${st.rolloutReviewerArtifactId}`);
154
- }
155
- if (st.evaluatorArtifactId !== undefined && typeof st.evaluatorArtifactId !== 'string') {
156
- errors.push('sourceTrace.evaluatorArtifactId must be string if present');
157
- }
158
- if (st.artificerArtifactId !== undefined && typeof st.artificerArtifactId !== 'string') {
159
- errors.push('sourceTrace.artificerArtifactId must be string if present');
160
- }
161
- if (st.scribeArtifactId !== undefined && typeof st.scribeArtifactId !== 'string') {
162
- errors.push('sourceTrace.scribeArtifactId must be string if present');
163
- }
164
- if (st.philosopherArtifactId !== undefined && typeof st.philosopherArtifactId !== 'string') {
165
- errors.push('sourceTrace.philosopherArtifactId must be string if present');
166
- }
167
- if (st.dreamerArtifactId !== undefined && typeof st.dreamerArtifactId !== 'string') {
168
- errors.push('sourceTrace.dreamerArtifactId must be string if present');
169
- }
170
- }
171
- if (typeof output.sourceRolloutReviewerArtifactId === 'string' && output.sourceRolloutReviewerArtifactId.trim() !== ''
172
- && typeof output.sourceTrace === 'object' && output.sourceTrace !== null
173
- && typeof output.sourceTrace.rolloutReviewerArtifactId === 'string'
174
- && output.sourceRolloutReviewerArtifactId !== output.sourceTrace.rolloutReviewerArtifactId) {
175
- errors.push('sourceRolloutReviewerArtifactId and sourceTrace.rolloutReviewerArtifactId must match');
176
- }
177
- if (output.goldenTraceRefs !== undefined) {
178
- if (!Array.isArray(output.goldenTraceRefs)) {
179
- errors.push('goldenTraceRefs must be an array');
180
- }
181
- else if (!output.goldenTraceRefs.every(e => typeof e === 'string')) {
182
- errors.push('goldenTraceRefs must be an array of strings');
183
- }
184
- }
185
- if (output.inlineGoldenTraceCases !== undefined) {
186
- if (!Array.isArray(output.inlineGoldenTraceCases)) {
187
- errors.push('inlineGoldenTraceCases must be an array');
188
- }
189
- else {
190
- const VALID_CASE_KINDS = ['negative', 'positive'];
191
- const VALID_EXPECTED_DECISIONS = ['allow', 'block', 'propose_correction'];
192
- for (let i = 0; i < output.inlineGoldenTraceCases.length; i++) {
193
- const tc = output.inlineGoldenTraceCases[i];
194
- if (typeof tc.caseId !== 'string' || (tc.caseId).trim() === '') {
195
- errors.push(`inlineGoldenTraceCases[${i}].caseId must be a non-empty string`);
196
- }
197
- if (!VALID_CASE_KINDS.includes(tc.kind)) {
198
- errors.push(`inlineGoldenTraceCases[${i}].kind must be one of ${VALID_CASE_KINDS.join('/')}, got ${String(tc.kind)}`);
199
- }
200
- if (typeof tc.toolName !== 'string' || (tc.toolName).trim() === '') {
201
- errors.push(`inlineGoldenTraceCases[${i}].toolName must be a non-empty string`);
202
- }
203
- if (!VALID_EXPECTED_DECISIONS.includes(tc.expectedDecision)) {
204
- errors.push(`inlineGoldenTraceCases[${i}].expectedDecision must be one of ${VALID_EXPECTED_DECISIONS.join('/')}, got ${String(tc.expectedDecision)}`);
205
- }
206
- }
207
- }
208
- }
209
- if (typeof output.generatedAt !== 'string' || output.generatedAt.trim() === '') {
210
- errors.push('generatedAt must be non-empty string');
211
- }
212
- else {
213
- const date = new Date(output.generatedAt);
214
- if (isNaN(date.getTime())) {
215
- errors.push('generatedAt must be a parseable ISO-8601 timestamp');
216
- }
217
- }
218
- return errors.length > 0
219
- ? { valid: false, errors, errorCategory: 'output_invalid' }
220
- : { valid: true, errors: [] };
221
- }
222
- }
223
- //# sourceMappingURL=trainer-output.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trainer-output.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/trainer-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AAiDtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,cAAc,CAAU,CAAC;AAEjG,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC,MAAM,CAAC;IACpD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IACxC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAC/C,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;KAC7B,CAAC;IACF,kBAAkB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5C,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;QAC1C,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;KAC3B,CAAC,CAAC;IACH,SAAS,EAAE,I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;YACpE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE;YAC3D,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAClC,CAAC;CACF"}
@@ -1,24 +0,0 @@
1
- export interface TrainerPromptBuilderInput {
2
- taskId: string;
3
- contextHash: string;
4
- sourceRolloutReviewerArtifactId: string;
5
- rolloutReviewerArtifact: unknown;
6
- }
7
- export interface TrainerPromptInput {
8
- taskId: string;
9
- contextHash: string;
10
- sourceRolloutReviewerArtifactId: string;
11
- rolloutReviewerArtifact: unknown;
12
- trainerInstruction: string;
13
- promptContractVersion: string;
14
- }
15
- export interface TrainerPromptBuildResult {
16
- readonly message: string;
17
- readonly promptInput: TrainerPromptInput;
18
- }
19
- export declare const TRAINER_PROTOCOL_INSTRUCTION = "You are a Trainer agent in a principle internalization pipeline. Your role is to generate an L2 rule candidate from the RolloutReviewer's assessment, producing a structured decision, safety constraints, and test cases for replay.\n\nPROTOCOL:\n1. Review the rolloutReviewerArtifact to understand the rollout decision, safety checks, and risks\n2. Extract the tool scope and trigger condition for the rule candidate\n3. Produce a decision: allow (safe to use), block (unsafe), require_approval (needs human review), or auto_correct (safe to self-correct)\n4. If decision is auto_correct, provide a proposed correction with description and params\n5. Provide a confidence score from 0.0 to 1.0 reflecting certainty in the decision\n6. Identify safety limitations, false positive risks, and required replay test cases\n7. Preserve the lineage trace from evaluator, artificer, scribe, philosopher, and dreamer artifacts\n8. Reference golden trace cases if available\n\nCRITICAL: Your ENTIRE response must be ONLY the JSON object below. Do NOT include any text before or after the JSON. Do NOT wrap the JSON in markdown code fences. Do NOT add explanatory prose. Output the raw JSON object and nothing else.\n\nCOMPLETE EXAMPLE OUTPUT (follow this exact structure):\n{\"taskId\":\"task-123\",\"sourceRolloutReviewerArtifactId\":\"pi-art-rollout-reviewer-001\",\"ruleCandidate\":{\"toolScope\":\"tool_call\",\"triggerCondition\":\"When a tool is called with invalid parameters\",\"proposedDecision\":\"auto_correct\",\"proposedCorrection\":{\"description\":\"Use default parameters instead\",\"proposedParams\":{\"defaultTimeout\":5000}},\"rationale\":\"Safe to auto-correct with sensible defaults\",\"confidence\":0.88},\"safety\":{\"limitations\":[\"Requires feature flag enabled\"],\"falsePositiveRisks\":[\"May incorrectly auto-correct edge case inputs\"],\"requiredReplayCases\":[\"tool_call with null params\",\"tool_call with empty toolName\"]},\"sourceTrace\":{\"rolloutReviewerArtifactId\":\"pi-art-rollout-reviewer-001\"},\"goldenTraceRefs\":[\"gt-case-001\",\"gt-case-002\"],\"generatedAt\":\"<current ISO-8601 timestamp>\"}\n\nCONSTRAINTS:\n- Output ONLY valid JSON \u2014 no markdown, no explanatory text, no code fences, no prose before or after\n- ruleCandidate.toolScope MUST be a non-empty string\n- ruleCandidate.triggerCondition MUST be a non-empty string\n- ruleCandidate.proposedDecision MUST be one of: allow, block, require_approval, auto_correct\n- ruleCandidate.rationale MUST be a non-empty string\n- ruleCandidate.confidence MUST be a number between 0.0 and 1.0 (NOT a string, NOT a percentage)\n- ruleCandidate.proposedCorrection is ONLY allowed when proposedDecision is auto_correct \u2014 it must be omitted otherwise\n- ruleCandidate.proposedCorrection.description MUST be a non-empty string if present\n- safety.limitations MUST be an array of strings (can be empty)\n- safety.falsePositiveRisks MUST be an array of strings (can be empty)\n- safety.requiredReplayCases MUST be an array of strings (can be empty)\n- sourceRolloutReviewerArtifactId MUST be copied exactly from input.sourceRolloutReviewerArtifactId (non-empty string)\n- sourceTrace.rolloutReviewerArtifactId MUST be copied exactly from input.sourceRolloutReviewerArtifactId\n- sourceTrace.evaluatorArtifactId is optional \u2014 include only if available from rollout reviewer artifact\n- sourceTrace.artificerArtifactId is optional \u2014 include only if available from rollout reviewer artifact\n- sourceTrace.scribeArtifactId is optional \u2014 include only if available from rollout reviewer artifact\n- sourceTrace.philosopherArtifactId is optional \u2014 include only if available from rollout reviewer artifact\n- sourceTrace.dreamerArtifactId is optional \u2014 include only if available from rollout reviewer artifact\n- goldenTraceRefs is optional \u2014 array of strings if present\n- inlineGoldenTraceCases is optional \u2014 array of case objects if present\n- generatedAt MUST be the current ISO-8601 timestamp (use the actual current time, NOT a placeholder)\n";
20
- export declare const TRAINER_PROMPT_CONTRACT_VERSION = "trainer-output-v1.prompt.v1";
21
- export declare class TrainerPromptBuilder {
22
- buildPrompt(input: TrainerPromptBuilderInput): TrainerPromptBuildResult;
23
- }
24
- //# sourceMappingURL=trainer-prompt-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trainer-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/trainer-prompt-builder.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B,EAAE,MAAM,CAAC;IACxC,uBAAuB,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,+BAA+B,EAAE,MAAM,CAAC;IACxC,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;CAC1C;AAED,eAAO,MAAM,4BAA4B,s+HAuCxC,CAAC;AAEF,eAAO,MAAM,+BAA+B,gCAAgC,CAAC;AAE7E,qBAAa,oBAAoB;IAE/B,WAAW,CAAC,KAAK,EAAE,yBAAyB,GAAG,wBAAwB;CAcxE"}
@@ -1,57 +0,0 @@
1
- export const TRAINER_PROTOCOL_INSTRUCTION = `You are a Trainer agent in a principle internalization pipeline. Your role is to generate an L2 rule candidate from the RolloutReviewer's assessment, producing a structured decision, safety constraints, and test cases for replay.
2
-
3
- PROTOCOL:
4
- 1. Review the rolloutReviewerArtifact to understand the rollout decision, safety checks, and risks
5
- 2. Extract the tool scope and trigger condition for the rule candidate
6
- 3. Produce a decision: allow (safe to use), block (unsafe), require_approval (needs human review), or auto_correct (safe to self-correct)
7
- 4. If decision is auto_correct, provide a proposed correction with description and params
8
- 5. Provide a confidence score from 0.0 to 1.0 reflecting certainty in the decision
9
- 6. Identify safety limitations, false positive risks, and required replay test cases
10
- 7. Preserve the lineage trace from evaluator, artificer, scribe, philosopher, and dreamer artifacts
11
- 8. Reference golden trace cases if available
12
-
13
- CRITICAL: Your ENTIRE response must be ONLY the JSON object below. Do NOT include any text before or after the JSON. Do NOT wrap the JSON in markdown code fences. Do NOT add explanatory prose. Output the raw JSON object and nothing else.
14
-
15
- COMPLETE EXAMPLE OUTPUT (follow this exact structure):
16
- {"taskId":"task-123","sourceRolloutReviewerArtifactId":"pi-art-rollout-reviewer-001","ruleCandidate":{"toolScope":"tool_call","triggerCondition":"When a tool is called with invalid parameters","proposedDecision":"auto_correct","proposedCorrection":{"description":"Use default parameters instead","proposedParams":{"defaultTimeout":5000}},"rationale":"Safe to auto-correct with sensible defaults","confidence":0.88},"safety":{"limitations":["Requires feature flag enabled"],"falsePositiveRisks":["May incorrectly auto-correct edge case inputs"],"requiredReplayCases":["tool_call with null params","tool_call with empty toolName"]},"sourceTrace":{"rolloutReviewerArtifactId":"pi-art-rollout-reviewer-001"},"goldenTraceRefs":["gt-case-001","gt-case-002"],"generatedAt":"<current ISO-8601 timestamp>"}
17
-
18
- CONSTRAINTS:
19
- - Output ONLY valid JSON — no markdown, no explanatory text, no code fences, no prose before or after
20
- - ruleCandidate.toolScope MUST be a non-empty string
21
- - ruleCandidate.triggerCondition MUST be a non-empty string
22
- - ruleCandidate.proposedDecision MUST be one of: allow, block, require_approval, auto_correct
23
- - ruleCandidate.rationale MUST be a non-empty string
24
- - ruleCandidate.confidence MUST be a number between 0.0 and 1.0 (NOT a string, NOT a percentage)
25
- - ruleCandidate.proposedCorrection is ONLY allowed when proposedDecision is auto_correct — it must be omitted otherwise
26
- - ruleCandidate.proposedCorrection.description MUST be a non-empty string if present
27
- - safety.limitations MUST be an array of strings (can be empty)
28
- - safety.falsePositiveRisks MUST be an array of strings (can be empty)
29
- - safety.requiredReplayCases MUST be an array of strings (can be empty)
30
- - sourceRolloutReviewerArtifactId MUST be copied exactly from input.sourceRolloutReviewerArtifactId (non-empty string)
31
- - sourceTrace.rolloutReviewerArtifactId MUST be copied exactly from input.sourceRolloutReviewerArtifactId
32
- - sourceTrace.evaluatorArtifactId is optional — include only if available from rollout reviewer artifact
33
- - sourceTrace.artificerArtifactId is optional — include only if available from rollout reviewer artifact
34
- - sourceTrace.scribeArtifactId is optional — include only if available from rollout reviewer artifact
35
- - sourceTrace.philosopherArtifactId is optional — include only if available from rollout reviewer artifact
36
- - sourceTrace.dreamerArtifactId is optional — include only if available from rollout reviewer artifact
37
- - goldenTraceRefs is optional — array of strings if present
38
- - inlineGoldenTraceCases is optional — array of case objects if present
39
- - generatedAt MUST be the current ISO-8601 timestamp (use the actual current time, NOT a placeholder)
40
- `;
41
- export const TRAINER_PROMPT_CONTRACT_VERSION = 'trainer-output-v1.prompt.v1';
42
- export class TrainerPromptBuilder {
43
- // eslint-disable-next-line @typescript-eslint/class-methods-use-this
44
- buildPrompt(input) {
45
- const promptInput = {
46
- taskId: input.taskId,
47
- contextHash: input.contextHash,
48
- sourceRolloutReviewerArtifactId: input.sourceRolloutReviewerArtifactId,
49
- rolloutReviewerArtifact: input.rolloutReviewerArtifact,
50
- trainerInstruction: TRAINER_PROTOCOL_INSTRUCTION,
51
- promptContractVersion: TRAINER_PROMPT_CONTRACT_VERSION,
52
- };
53
- const message = JSON.stringify(promptInput);
54
- return { message, promptInput };
55
- }
56
- }
57
- //# sourceMappingURL=trainer-prompt-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trainer-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/trainer-prompt-builder.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,4BAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuC3C,CAAC;AAEF,MAAM,CAAC,MAAM,+BAA+B,GAAG,6BAA6B,CAAC;AAE7E,MAAM,OAAO,oBAAoB;IAC/B,qEAAqE;IACrE,WAAW,CAAC,KAAgC;QAC1C,MAAM,WAAW,GAAuB;YACtC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,+BAA+B,EAAE,KAAK,CAAC,+BAA+B;YACtE,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;YACtD,kBAAkB,EAAE,4BAA4B;YAChD,qBAAqB,EAAE,+BAA+B;SACvD,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAClC,CAAC;CACF"}