instar 0.23.12 → 0.23.13
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/cli.js +0 -0
- package/dist/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +5 -2
- package/dist/commands/server.js.map +1 -1
- package/dist/core/ResponseReviewGate.d.ts +182 -0
- package/dist/core/ResponseReviewGate.d.ts.map +1 -0
- package/dist/core/ResponseReviewGate.js +956 -0
- package/dist/core/ResponseReviewGate.js.map +1 -0
- package/dist/lifeline/TelegramLifeline.d.ts.map +1 -1
- package/dist/lifeline/TelegramLifeline.js +19 -1
- package/dist/lifeline/TelegramLifeline.js.map +1 -1
- package/dist/messaging/TelegramAdapter.d.ts +2 -0
- package/dist/messaging/TelegramAdapter.d.ts.map +1 -1
- package/dist/messaging/TelegramAdapter.js +2 -0
- package/dist/messaging/TelegramAdapter.js.map +1 -1
- package/dist/publishing/TelegraphService.d.ts +4 -0
- package/dist/publishing/TelegraphService.d.ts.map +1 -1
- package/dist/publishing/TelegraphService.js +34 -19
- package/dist/publishing/TelegraphService.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +39 -1
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +47 -47
- package/upgrades/0.23.10.md +19 -0
- package/upgrades/0.23.11.md +21 -0
- package/upgrades/0.23.13.md +25 -0
- package/upgrades/NEXT.md +23 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResponseReviewGate — Main orchestrator for the response review pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Evaluates agent responses before they reach users. Architecture:
|
|
5
|
+
* 1. Policy Enforcement Layer (PEL) — deterministic hard blocks
|
|
6
|
+
* 2. Gate Reviewer — fast LLM triage (does this need full review?)
|
|
7
|
+
* 3. Specialist Reviewers — parallel LLM calls checking specific dimensions
|
|
8
|
+
*
|
|
9
|
+
* Implements the 15-row normative decision matrix from the Coherence Gate spec.
|
|
10
|
+
* Handles retry tracking, conversation advancement detection, feedback composition,
|
|
11
|
+
* per-channel fail behavior, and reviewer criticality tiers.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: The existing CoherenceGate.ts is a pre-action verification system
|
|
14
|
+
* (checks before deployment/git push). This is a response review pipeline —
|
|
15
|
+
* completely different purpose, same "Coherence Gate" branding.
|
|
16
|
+
*/
|
|
17
|
+
import { type GateResult } from './reviewers/gate-reviewer.js';
|
|
18
|
+
import type { ResponseReviewConfig } from './types.js';
|
|
19
|
+
export interface EvaluateRequest {
|
|
20
|
+
message: string;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
stopHookActive: boolean;
|
|
23
|
+
context: {
|
|
24
|
+
channel: string;
|
|
25
|
+
topicId?: number;
|
|
26
|
+
recipientType?: 'primary-user' | 'secondary-user' | 'agent' | 'external-contact';
|
|
27
|
+
recipientId?: string;
|
|
28
|
+
isExternalFacing?: boolean;
|
|
29
|
+
transcriptPath?: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface EvaluateResponse {
|
|
33
|
+
pass: boolean;
|
|
34
|
+
feedback?: string;
|
|
35
|
+
issueCategories?: string[];
|
|
36
|
+
warnings?: string[];
|
|
37
|
+
retryCount?: number;
|
|
38
|
+
/** Internal: full violations for audit log (not sent to agent) */
|
|
39
|
+
_auditViolations?: AuditViolation[];
|
|
40
|
+
/** Internal: whether this was a PEL block */
|
|
41
|
+
_pelBlock?: boolean;
|
|
42
|
+
/** Internal: gate result */
|
|
43
|
+
_gateResult?: GateResult;
|
|
44
|
+
/** Internal: outcome for decision matrix tracking */
|
|
45
|
+
_outcome?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface AuditViolation {
|
|
48
|
+
reviewer: string;
|
|
49
|
+
severity: 'block' | 'warn';
|
|
50
|
+
issue: string;
|
|
51
|
+
suggestion: string;
|
|
52
|
+
latencyMs: number;
|
|
53
|
+
}
|
|
54
|
+
export interface ResponseReviewGateOptions {
|
|
55
|
+
config: ResponseReviewConfig;
|
|
56
|
+
stateDir: string;
|
|
57
|
+
apiKey: string;
|
|
58
|
+
relationships?: {
|
|
59
|
+
getContextForPerson(id: string): string | null;
|
|
60
|
+
} | null;
|
|
61
|
+
adaptiveTrust?: {
|
|
62
|
+
getProfile(): any;
|
|
63
|
+
} | null;
|
|
64
|
+
}
|
|
65
|
+
export declare class ResponseReviewGate {
|
|
66
|
+
private config;
|
|
67
|
+
private stateDir;
|
|
68
|
+
private pel;
|
|
69
|
+
private gateReviewer;
|
|
70
|
+
private reviewers;
|
|
71
|
+
private recipientResolver;
|
|
72
|
+
private retrySessions;
|
|
73
|
+
private sessionMutexes;
|
|
74
|
+
private valueDocCache;
|
|
75
|
+
private reviewHistory;
|
|
76
|
+
private proposals;
|
|
77
|
+
private static RETENTION_DAYS;
|
|
78
|
+
constructor(options: ResponseReviewGateOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Evaluate an agent's draft response. Main entry point.
|
|
81
|
+
* Implements the 15-row normative decision matrix.
|
|
82
|
+
*/
|
|
83
|
+
evaluate(request: EvaluateRequest): Promise<EvaluateResponse>;
|
|
84
|
+
private _evaluate;
|
|
85
|
+
private initializeReviewers;
|
|
86
|
+
private loadCustomReviewers;
|
|
87
|
+
private getEnabledReviewers;
|
|
88
|
+
private getReviewerMode;
|
|
89
|
+
private resolveChannelConfig;
|
|
90
|
+
private isExternalChannel;
|
|
91
|
+
private composeFeedback;
|
|
92
|
+
private composePELFeedback;
|
|
93
|
+
private getIssueCategories;
|
|
94
|
+
private extractToolContext;
|
|
95
|
+
private extractUrls;
|
|
96
|
+
private loadValueDocs;
|
|
97
|
+
/**
|
|
98
|
+
* Deterministic value document summarization.
|
|
99
|
+
* Extracts headers, bullets, and bold text — not LLM summarization.
|
|
100
|
+
* Target: ~200-400 tokens for all three tiers combined.
|
|
101
|
+
*/
|
|
102
|
+
private extractValueSection;
|
|
103
|
+
private getTranscriptVersion;
|
|
104
|
+
private acquireMutex;
|
|
105
|
+
private releaseMutex;
|
|
106
|
+
private logAudit;
|
|
107
|
+
getReviewHistory(options?: {
|
|
108
|
+
sessionId?: string;
|
|
109
|
+
reviewer?: string;
|
|
110
|
+
verdict?: string;
|
|
111
|
+
since?: string;
|
|
112
|
+
recipientId?: string;
|
|
113
|
+
limit?: number;
|
|
114
|
+
}): AuditLogEntry[];
|
|
115
|
+
/**
|
|
116
|
+
* Delete review history for a specific session (DSAR compliance).
|
|
117
|
+
*/
|
|
118
|
+
deleteHistory(sessionId: string): number;
|
|
119
|
+
getReviewerStats(options?: {
|
|
120
|
+
period?: 'daily' | 'weekly' | 'all';
|
|
121
|
+
since?: string;
|
|
122
|
+
}): Record<string, any>;
|
|
123
|
+
/** Check if the gate is enabled and ready */
|
|
124
|
+
isEnabled(): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Run canary tests with known-bad messages. Returns results showing
|
|
127
|
+
* which canary messages were caught and which were missed.
|
|
128
|
+
*/
|
|
129
|
+
runCanaryTests(): Promise<CanaryTestResult[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Get reviewer health — per-reviewer pass rate relative to baseline expectations.
|
|
132
|
+
*/
|
|
133
|
+
getReviewerHealth(): ReviewerHealthReport;
|
|
134
|
+
private lastCanaryResults;
|
|
135
|
+
/** Store canary results for health reporting */
|
|
136
|
+
setCanaryResults(results: CanaryTestResult[]): void;
|
|
137
|
+
getProposals(status?: 'pending' | 'approved' | 'rejected'): ReviewProposal[];
|
|
138
|
+
addProposal(proposal: Omit<ReviewProposal, 'id' | 'status' | 'createdAt'>): ReviewProposal;
|
|
139
|
+
resolveProposal(id: string, action: 'approve' | 'reject', resolution?: string): ReviewProposal | null;
|
|
140
|
+
getHealthDashboard(): Record<string, any>;
|
|
141
|
+
}
|
|
142
|
+
interface AuditLogEntry {
|
|
143
|
+
timestamp: string;
|
|
144
|
+
sessionId: string;
|
|
145
|
+
channel: string;
|
|
146
|
+
recipientType: string;
|
|
147
|
+
recipientId?: string;
|
|
148
|
+
verdict: string;
|
|
149
|
+
violations: AuditViolation[];
|
|
150
|
+
note: string;
|
|
151
|
+
}
|
|
152
|
+
export interface ReviewProposal {
|
|
153
|
+
id: string;
|
|
154
|
+
type: 'new-reviewer' | 'modify-reviewer' | 'config-change';
|
|
155
|
+
title: string;
|
|
156
|
+
description: string;
|
|
157
|
+
source: string;
|
|
158
|
+
status: 'pending' | 'approved' | 'rejected';
|
|
159
|
+
createdAt: string;
|
|
160
|
+
resolvedAt?: string;
|
|
161
|
+
resolution?: string;
|
|
162
|
+
data?: Record<string, unknown>;
|
|
163
|
+
}
|
|
164
|
+
export interface CanaryTestResult {
|
|
165
|
+
canaryId: string;
|
|
166
|
+
description: string;
|
|
167
|
+
expectedDimension: string;
|
|
168
|
+
caught: boolean;
|
|
169
|
+
verdict: string;
|
|
170
|
+
pass: boolean;
|
|
171
|
+
}
|
|
172
|
+
export interface ReviewerHealthReport {
|
|
173
|
+
overallStatus: 'healthy' | 'degraded' | 'failing';
|
|
174
|
+
reviewers: Record<string, {
|
|
175
|
+
passRate: number;
|
|
176
|
+
total: number;
|
|
177
|
+
status: 'healthy' | 'degraded' | 'failing';
|
|
178
|
+
}>;
|
|
179
|
+
lastCanaryRun: CanaryTestResult[] | null;
|
|
180
|
+
}
|
|
181
|
+
export {};
|
|
182
|
+
//# sourceMappingURL=ResponseReviewGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseReviewGate.d.ts","sourceRoot":"","sources":["../../src/core/ResponseReviewGate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAW7E,OAAO,KAAK,EAAE,oBAAoB,EAAuB,MAAM,YAAY,CAAC;AAI5E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EA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