@principles/core 1.131.0 → 1.132.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.
@@ -0,0 +1,173 @@
1
+ /**
2
+ * EvidenceChainContract — shared core contracts and assembly mapper for
3
+ * the Pain Evidence Chain (PRI-385).
4
+ *
5
+ * This file is purely logical (no fs, db, or network dependencies) and
6
+ * lives inside principles-core to be shared by Console read models,
7
+ * CLI commands, and test fixtures.
8
+ */
9
+ export type EvidenceChainState = 'recorded-only' | 'evidence-only' | 'diagnosis-queued' | 'diagnosis-running' | 'diagnosis-succeeded' | 'diagnosis-failed' | 'diagnosis-retry-wait' | 'candidate-generated' | 'internalization-missing' | 'internalization-pending' | 'internalization-running' | 'internalization-failed' | 'internalization-succeeded' | 'owner-reviewable' | 'malformed' | 'degraded';
10
+ export declare const EvidenceChainStateSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"recorded-only">, import("@sinclair/typebox").TLiteral<"evidence-only">, import("@sinclair/typebox").TLiteral<"diagnosis-queued">, import("@sinclair/typebox").TLiteral<"diagnosis-running">, import("@sinclair/typebox").TLiteral<"diagnosis-succeeded">, import("@sinclair/typebox").TLiteral<"diagnosis-failed">, import("@sinclair/typebox").TLiteral<"diagnosis-retry-wait">, import("@sinclair/typebox").TLiteral<"candidate-generated">, import("@sinclair/typebox").TLiteral<"internalization-missing">, import("@sinclair/typebox").TLiteral<"internalization-pending">, import("@sinclair/typebox").TLiteral<"internalization-running">, import("@sinclair/typebox").TLiteral<"internalization-failed">, import("@sinclair/typebox").TLiteral<"internalization-succeeded">, import("@sinclair/typebox").TLiteral<"owner-reviewable">, import("@sinclair/typebox").TLiteral<"malformed">, import("@sinclair/typebox").TLiteral<"degraded">]>;
11
+ export interface EvidenceChainRecord {
12
+ id: string;
13
+ sourceKind: string;
14
+ observedAt: string;
15
+ state: EvidenceChainState;
16
+ summary: string;
17
+ admissionDecision?: string;
18
+ linkedPainId?: string;
19
+ linkedTaskId?: string;
20
+ linkedTaskStatus?: string;
21
+ linkedCandidateId?: string;
22
+ linkedPrincipleId?: string;
23
+ failureReason?: string;
24
+ degradedReason?: string;
25
+ nextAction?: string;
26
+ candidateTitle?: string;
27
+ candidateSummary?: string;
28
+ rootCauseSummary?: string;
29
+ confidence?: number;
30
+ recommendationKind?: string;
31
+ internalizationTaskId?: string;
32
+ dreamerTaskStatus?: string;
33
+ }
34
+ export declare const EvidenceChainRecordSchema: import("@sinclair/typebox").TObject<{
35
+ id: import("@sinclair/typebox").TString;
36
+ sourceKind: import("@sinclair/typebox").TString;
37
+ observedAt: import("@sinclair/typebox").TString;
38
+ state: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"recorded-only">, import("@sinclair/typebox").TLiteral<"evidence-only">, import("@sinclair/typebox").TLiteral<"diagnosis-queued">, import("@sinclair/typebox").TLiteral<"diagnosis-running">, import("@sinclair/typebox").TLiteral<"diagnosis-succeeded">, import("@sinclair/typebox").TLiteral<"diagnosis-failed">, import("@sinclair/typebox").TLiteral<"diagnosis-retry-wait">, import("@sinclair/typebox").TLiteral<"candidate-generated">, import("@sinclair/typebox").TLiteral<"internalization-missing">, import("@sinclair/typebox").TLiteral<"internalization-pending">, import("@sinclair/typebox").TLiteral<"internalization-running">, import("@sinclair/typebox").TLiteral<"internalization-failed">, import("@sinclair/typebox").TLiteral<"internalization-succeeded">, import("@sinclair/typebox").TLiteral<"owner-reviewable">, import("@sinclair/typebox").TLiteral<"malformed">, import("@sinclair/typebox").TLiteral<"degraded">]>;
39
+ summary: import("@sinclair/typebox").TString;
40
+ admissionDecision: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
41
+ linkedPainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
42
+ linkedTaskId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
43
+ linkedTaskStatus: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
44
+ linkedCandidateId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
45
+ linkedPrincipleId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
46
+ failureReason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
47
+ degradedReason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
48
+ nextAction: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
49
+ candidateTitle: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
50
+ candidateSummary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
51
+ rootCauseSummary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
52
+ confidence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
53
+ recommendationKind: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
54
+ internalizationTaskId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
55
+ dreamerTaskStatus: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
56
+ }>;
57
+ export interface EvidenceChainResponse {
58
+ records: EvidenceChainRecord[];
59
+ generatedAt: string;
60
+ degradedReason?: string;
61
+ nextAction?: string;
62
+ note?: string;
63
+ }
64
+ export declare const EvidenceChainResponseSchema: import("@sinclair/typebox").TObject<{
65
+ records: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
66
+ id: import("@sinclair/typebox").TString;
67
+ sourceKind: import("@sinclair/typebox").TString;
68
+ observedAt: import("@sinclair/typebox").TString;
69
+ state: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"recorded-only">, import("@sinclair/typebox").TLiteral<"evidence-only">, import("@sinclair/typebox").TLiteral<"diagnosis-queued">, import("@sinclair/typebox").TLiteral<"diagnosis-running">, import("@sinclair/typebox").TLiteral<"diagnosis-succeeded">, import("@sinclair/typebox").TLiteral<"diagnosis-failed">, import("@sinclair/typebox").TLiteral<"diagnosis-retry-wait">, import("@sinclair/typebox").TLiteral<"candidate-generated">, import("@sinclair/typebox").TLiteral<"internalization-missing">, import("@sinclair/typebox").TLiteral<"internalization-pending">, import("@sinclair/typebox").TLiteral<"internalization-running">, import("@sinclair/typebox").TLiteral<"internalization-failed">, import("@sinclair/typebox").TLiteral<"internalization-succeeded">, import("@sinclair/typebox").TLiteral<"owner-reviewable">, import("@sinclair/typebox").TLiteral<"malformed">, import("@sinclair/typebox").TLiteral<"degraded">]>;
70
+ summary: import("@sinclair/typebox").TString;
71
+ admissionDecision: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
72
+ linkedPainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
73
+ linkedTaskId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
74
+ linkedTaskStatus: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
75
+ linkedCandidateId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
76
+ linkedPrincipleId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
77
+ failureReason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
78
+ degradedReason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
79
+ nextAction: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
80
+ candidateTitle: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
81
+ candidateSummary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
82
+ rootCauseSummary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
83
+ confidence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
84
+ recommendationKind: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
85
+ internalizationTaskId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
86
+ dreamerTaskStatus: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
87
+ }>>;
88
+ generatedAt: import("@sinclair/typebox").TString;
89
+ degradedReason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
90
+ nextAction: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
91
+ note: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
92
+ }>;
93
+ export declare function mapSourceKind(source: string): string;
94
+ export declare function inferAdmissionDecision(sourceKind: string): string;
95
+ export interface ChainStateParams {
96
+ sourceKind: string;
97
+ taskStatus?: string;
98
+ hasCandidate: boolean;
99
+ dreamerStatus?: string;
100
+ ledgerPrincipleStatus?: string;
101
+ }
102
+ export declare function determineState(params: ChainStateParams): EvidenceChainState;
103
+ export interface NextActionContext {
104
+ state: EvidenceChainState;
105
+ workspaceDir: string;
106
+ /**
107
+ * Display record id (`pain_*` / `manual_*` / task-derived). Carried for context only;
108
+ * it is NOT a valid `--pain-id` (format mismatch with the `diagnosis_${painId}` convention).
109
+ */
110
+ recordId?: string;
111
+ /** The actual diagnostician task_id; the authoritative source for the retry painId (ERR-008). */
112
+ linkedTaskId?: string;
113
+ }
114
+ export declare function determineNextAction(ctx: NextActionContext): string | undefined;
115
+ export declare function resolveSummary(fields: {
116
+ candidateTitle?: string;
117
+ rootCauseSummary?: string;
118
+ painText?: string;
119
+ painReason?: string;
120
+ fallback: string;
121
+ }): string;
122
+ export interface NormalizationResult {
123
+ success: boolean;
124
+ normalized?: string;
125
+ reason?: string;
126
+ nextAction?: string;
127
+ }
128
+ export declare function normalizeDiagnosticianTaskId(taskId: string): NormalizationResult;
129
+ export interface TaskMapEntry {
130
+ taskId: string;
131
+ status: string;
132
+ lastError: string | null;
133
+ createdAt: string;
134
+ rootCauseSummary?: string;
135
+ diagnosticJsonDegraded?: boolean;
136
+ inputRef?: string;
137
+ }
138
+ export declare function crossReferenceByTimestamp(painEvents: {
139
+ painId: string;
140
+ createdAt: string;
141
+ source: string;
142
+ }[], taskMap: Map<string, TaskMapEntry>, coveredPainIds: Set<string>): Map<string, TaskMapEntry>;
143
+ export interface CandidateInfo {
144
+ candidateId: string;
145
+ title?: string;
146
+ description?: string;
147
+ confidence?: number;
148
+ recommendationKind?: string;
149
+ }
150
+ export interface DreamerTaskInfo {
151
+ taskId: string;
152
+ status: string;
153
+ }
154
+ export interface LedgerPrinciple {
155
+ id: string;
156
+ derivedFromPainIds?: string[];
157
+ text?: string;
158
+ status?: string;
159
+ createdAt?: string;
160
+ }
161
+ export declare function assembleEvidenceChain(params: {
162
+ workspaceDir: string;
163
+ painEvents: unknown[];
164
+ tasks: unknown[];
165
+ candidates: unknown[];
166
+ dreamerTasks: unknown[];
167
+ ledgerPrinciples: LedgerPrinciple[];
168
+ trajectoryDbAvailable: boolean;
169
+ stateDbAvailable: boolean;
170
+ degradedReasons?: string[];
171
+ degradedNextActions?: string[];
172
+ }): EvidenceChainResponse;
173
+ //# sourceMappingURL=evidence-chain-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evidence-chain-contract.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/types/evidence-chain-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,MAAM,kBAAkB,GAC1B,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,mBAAmB,GACnB,qBAAqB,GACrB,kBAAkB,GAClB,sBAAsB,GACtB,qBAAqB,GACrB,yBAAyB,GACzB,yBAAyB,GACzB,yBAAyB,GACzB,wBAAwB,GACxB,2BAA2B,GAC3B,kBAAkB,GAClB,WAAW,GACX,UAAU,CAAC;AAEf,eAAO,MAAM,wBAAwB,g+BAiBnC,CAAC;AAEH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAA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