ai-foreman 1.7.11 → 1.7.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/README.md +15 -0
- package/dist/activity.d.ts +5 -1
- package/dist/activity.js +1 -1
- package/dist/adapters/claude.d.ts +7 -0
- package/dist/adapters/claude.js +133 -7
- package/dist/adapters/codex.d.ts +5 -0
- package/dist/adapters/codex.js +121 -11
- package/dist/adapters/recovering.d.ts +2 -0
- package/dist/adapters/recovering.js +11 -1
- package/dist/adapters/types.d.ts +47 -1
- package/dist/agentRun.d.ts +2 -0
- package/dist/agentRun.js +8 -2
- package/dist/branch/resume.js +11 -1
- package/dist/branch/runner.d.ts +12 -3
- package/dist/branch/runner.js +131 -67
- package/dist/buildRuns.d.ts +6 -2
- package/dist/buildRuns.js +76 -32
- package/dist/cli/doctor.d.ts +7 -0
- package/dist/cli/doctor.js +84 -1
- package/dist/cli/manager.d.ts +17 -0
- package/dist/cli/manager.js +135 -0
- package/dist/cli/recovery.d.ts +4 -0
- package/dist/cli/recovery.js +80 -0
- package/dist/cli/start.js +446 -142
- package/dist/cli/status.js +13 -2
- package/dist/cli/tickets.js +27 -9
- package/dist/config.d.ts +4 -0
- package/dist/config.js +28 -1
- package/dist/continuity.js +14 -9
- package/dist/diagnostics.d.ts +25 -0
- package/dist/diagnostics.js +428 -0
- package/dist/foreman.d.ts +26 -6
- package/dist/foreman.js +147 -104
- package/dist/handoffs.d.ts +35 -3
- package/dist/handoffs.js +155 -17
- package/dist/index.js +6 -0
- package/dist/log.d.ts +3 -3
- package/dist/log.js +4 -1
- package/dist/managerPacket.d.ts +25 -0
- package/dist/managerPacket.js +83 -0
- package/dist/markers.d.ts +1 -1
- package/dist/markers.js +4 -1
- package/dist/notify.d.ts +4 -0
- package/dist/notify.js +15 -0
- package/dist/observability.d.ts +248 -0
- package/dist/observability.js +1018 -0
- package/dist/planChanges.d.ts +4 -0
- package/dist/planChanges.js +16 -0
- package/dist/projectDiagnostics.d.ts +27 -0
- package/dist/projectDiagnostics.js +407 -0
- package/dist/qaRecovery.d.ts +140 -0
- package/dist/qaRecovery.js +595 -0
- package/dist/qaReview.d.ts +133 -14
- package/dist/qaReview.js +984 -59
- package/dist/qaSnapshot.d.ts +31 -5
- package/dist/qaSnapshot.js +209 -134
- package/dist/recoveryPolicy.d.ts +37 -0
- package/dist/recoveryPolicy.js +251 -0
- package/dist/roles.js +1 -0
- package/dist/supervisor.d.ts +40 -0
- package/dist/supervisor.js +102 -0
- package/dist/ticketHistoryReader.d.ts +19 -0
- package/dist/ticketHistoryReader.js +58 -0
- package/dist/tickets/details.d.ts +8 -0
- package/dist/tickets/details.js +59 -11
- package/dist/tickets/output.d.ts +5 -0
- package/dist/tickets/output.js +73 -0
- package/dist/tickets/stateDb.d.ts +1 -0
- package/dist/tickets/stateDb.js +5 -0
- package/dist/workflowDb.d.ts +31 -2
- package/dist/workflowDb.js +192 -23
- package/dist/workflowReader.d.ts +42 -0
- package/dist/workflowReader.js +171 -0
- package/foreman.yaml +13 -0
- package/package.json +51 -3
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { ConfigurableAgentRole, DiagnosticSourceResultV1, ManagerRunSummaryV1, RunCurrentStateV1, RunRollupV1, RunSpanV1 } from "rafi-spec";
|
|
2
|
+
export declare const OBSERVABILITY_DB_FILE = ".rafi/observability.sqlite3";
|
|
3
|
+
export declare const OBSERVABILITY_SCHEMA_VERSION: 2;
|
|
4
|
+
export interface ObservabilityConfig {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
sample_interval_seconds: number;
|
|
7
|
+
detail_retention_days: number;
|
|
8
|
+
log_retention_days: number;
|
|
9
|
+
detail_soft_limit_mb: number;
|
|
10
|
+
detail_hard_limit_mb: number;
|
|
11
|
+
log_limit_mb: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_OBSERVABILITY_CONFIG: ObservabilityConfig;
|
|
14
|
+
export interface ObservationContext {
|
|
15
|
+
runId: string;
|
|
16
|
+
executionId?: string;
|
|
17
|
+
parentSpanId?: string;
|
|
18
|
+
providerTurnId?: string;
|
|
19
|
+
ticketId?: string;
|
|
20
|
+
deliveryUnitId?: string;
|
|
21
|
+
role?: ConfigurableAgentRole | "host";
|
|
22
|
+
stream?: string;
|
|
23
|
+
providerSessionId?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface StartSpanInput extends Partial<Omit<RunSpanV1, "version" | "spanId" | "runId" | "startedAt" | "completionKnown">> {
|
|
26
|
+
spanId?: string;
|
|
27
|
+
kind: string;
|
|
28
|
+
name: string;
|
|
29
|
+
attributes?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface FinishSpanInput {
|
|
32
|
+
outcome?: string;
|
|
33
|
+
completionKnown?: boolean;
|
|
34
|
+
attributes?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
export interface ObservabilityStoreOptions {
|
|
37
|
+
path?: string;
|
|
38
|
+
config?: Partial<ObservabilityConfig>;
|
|
39
|
+
now?: () => Date;
|
|
40
|
+
monotonicNow?: () => number;
|
|
41
|
+
ensureIgnore?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ManagerSessionRecord {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
runId: string;
|
|
46
|
+
provider?: string;
|
|
47
|
+
startedAt: string;
|
|
48
|
+
endedAt?: string;
|
|
49
|
+
outcome?: string;
|
|
50
|
+
reportDigest?: string;
|
|
51
|
+
inputTokens?: number;
|
|
52
|
+
outputTokens?: number;
|
|
53
|
+
costUsd?: number;
|
|
54
|
+
errorCode?: string;
|
|
55
|
+
scope?: "project";
|
|
56
|
+
latestFocusRunId?: string;
|
|
57
|
+
projectReportDigest?: string;
|
|
58
|
+
lookupRounds?: number;
|
|
59
|
+
lookupOperations?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Bounded, failure-isolated writer for diagnostic data. Recovery never depends on
|
|
63
|
+
* this database. Boundary records are synchronous; high-rate state and samples
|
|
64
|
+
* are coalesced by primary key and minute bucket.
|
|
65
|
+
*/
|
|
66
|
+
export declare class ObservabilityStore {
|
|
67
|
+
readonly path: string;
|
|
68
|
+
readonly config: ObservabilityConfig;
|
|
69
|
+
private readonly db;
|
|
70
|
+
private readonly projectDir;
|
|
71
|
+
private readonly now;
|
|
72
|
+
private readonly monotonicNow;
|
|
73
|
+
private readonly openMonotonic;
|
|
74
|
+
private disabled;
|
|
75
|
+
private warned;
|
|
76
|
+
private summaryOnly;
|
|
77
|
+
private priorCpu?;
|
|
78
|
+
constructor(projectDir: string, options?: ObservabilityStoreOptions);
|
|
79
|
+
close(): void;
|
|
80
|
+
isDisabled(): boolean;
|
|
81
|
+
isSummaryOnly(): boolean;
|
|
82
|
+
recordCapabilities(runId: string, capabilities: Record<string, DiagnosticSourceResultV1>, rafiVersion?: string): void;
|
|
83
|
+
beginExecution(input: {
|
|
84
|
+
runId: string;
|
|
85
|
+
executionId?: string;
|
|
86
|
+
leaseGeneration?: number;
|
|
87
|
+
pid?: number;
|
|
88
|
+
host?: string;
|
|
89
|
+
processStart?: string;
|
|
90
|
+
}): string;
|
|
91
|
+
endExecution(executionId: string, outcome: string): void;
|
|
92
|
+
attachExecutionLease(executionId: string, leaseGeneration: number | undefined): void;
|
|
93
|
+
abandonPriorExecutionSpans(runId: string, executionId: string): void;
|
|
94
|
+
startSpan(context: ObservationContext, input: StartSpanInput): string;
|
|
95
|
+
finishSpan(spanId: string, input?: FinishSpanInput): void;
|
|
96
|
+
recordEvent(context: ObservationContext, kind: string, input?: {
|
|
97
|
+
eventId?: string;
|
|
98
|
+
spanId?: string;
|
|
99
|
+
severity?: string;
|
|
100
|
+
attributes?: Record<string, unknown>;
|
|
101
|
+
}): string;
|
|
102
|
+
updateCurrentState(state: Omit<RunCurrentStateV1, "version" | "updatedAt"> & {
|
|
103
|
+
updatedAt?: string;
|
|
104
|
+
}): void;
|
|
105
|
+
recordMetric(context: ObservationContext, metric: string, value: number, input?: {
|
|
106
|
+
unit?: string;
|
|
107
|
+
boundary?: boolean;
|
|
108
|
+
attributes?: Record<string, unknown>;
|
|
109
|
+
}): void;
|
|
110
|
+
sampleProcess(context: ObservationContext, eventLoopDelayMs?: number, boundary?: boolean): void;
|
|
111
|
+
upsertRollup(rollup: RunRollupV1): void;
|
|
112
|
+
upsertRunSummary(summary: ManagerRunSummaryV1): void;
|
|
113
|
+
finalizeRun(runId: string, input: {
|
|
114
|
+
status: string;
|
|
115
|
+
branchMode?: string;
|
|
116
|
+
qaEnabled?: boolean;
|
|
117
|
+
primaryProvider?: "claude" | "codex";
|
|
118
|
+
model?: string;
|
|
119
|
+
ticketCount?: number;
|
|
120
|
+
ticketIds?: string[];
|
|
121
|
+
deliveryUnit?: string;
|
|
122
|
+
checkpoint?: string;
|
|
123
|
+
failureCategory?: string;
|
|
124
|
+
ticketSizeBucket?: string;
|
|
125
|
+
createdAt?: string;
|
|
126
|
+
updatedAt?: string;
|
|
127
|
+
completedAt?: string;
|
|
128
|
+
git?: ManagerRunSummaryV1["git"];
|
|
129
|
+
}): RunRollupV1 | undefined;
|
|
130
|
+
recordManagerSession(input: ManagerSessionRecord): void;
|
|
131
|
+
indexLogFile(path: string, runId: string): void;
|
|
132
|
+
closeLogFile(path: string, status: string): void;
|
|
133
|
+
maintainLogs(projectDir: string): {
|
|
134
|
+
compressed: number;
|
|
135
|
+
deleted: number;
|
|
136
|
+
reclaimedBytes: number;
|
|
137
|
+
};
|
|
138
|
+
enforceLimits(protectedRunIds?: readonly string[]): {
|
|
139
|
+
summaryOnly: boolean;
|
|
140
|
+
prunedRows: number;
|
|
141
|
+
};
|
|
142
|
+
checkpoint(): void;
|
|
143
|
+
compact(): void;
|
|
144
|
+
private meta;
|
|
145
|
+
private setMeta;
|
|
146
|
+
private guard;
|
|
147
|
+
private migrate;
|
|
148
|
+
private backfillBuildSnapshots;
|
|
149
|
+
}
|
|
150
|
+
/** Strictly read-only access. Construction never creates directories, journals, migrations, or ignore entries. */
|
|
151
|
+
export declare class ObservabilityReader {
|
|
152
|
+
readonly path: string;
|
|
153
|
+
private readonly db?;
|
|
154
|
+
constructor(projectDir: string, path?: string);
|
|
155
|
+
close(): void;
|
|
156
|
+
available(): boolean;
|
|
157
|
+
schemaVersion(): number | undefined;
|
|
158
|
+
currentState(runId: string): RunCurrentStateV1[];
|
|
159
|
+
spans(runId: string): RunSpanV1[];
|
|
160
|
+
executions(runId: string): Array<{
|
|
161
|
+
executionId: string;
|
|
162
|
+
startedAt: string;
|
|
163
|
+
endedAt?: string;
|
|
164
|
+
outcome?: string;
|
|
165
|
+
leaseGeneration?: number;
|
|
166
|
+
}>;
|
|
167
|
+
rollups(): RunRollupV1[];
|
|
168
|
+
runSummaries(input?: {
|
|
169
|
+
runIds?: readonly string[];
|
|
170
|
+
statuses?: readonly string[];
|
|
171
|
+
providers?: readonly string[];
|
|
172
|
+
models?: readonly string[];
|
|
173
|
+
branchModes?: readonly string[];
|
|
174
|
+
qaEnabled?: boolean;
|
|
175
|
+
ticketIds?: readonly string[];
|
|
176
|
+
createdFrom?: string;
|
|
177
|
+
createdTo?: string;
|
|
178
|
+
completedFrom?: string;
|
|
179
|
+
completedTo?: string;
|
|
180
|
+
detailLevels?: readonly string[];
|
|
181
|
+
limit?: number;
|
|
182
|
+
offset?: number;
|
|
183
|
+
}): ManagerRunSummaryV1[];
|
|
184
|
+
phaseRollups(runIds: readonly string[]): Array<{
|
|
185
|
+
runId: string;
|
|
186
|
+
phase: string;
|
|
187
|
+
role: string;
|
|
188
|
+
ticketId: string;
|
|
189
|
+
durationMs: number;
|
|
190
|
+
count: number;
|
|
191
|
+
}>;
|
|
192
|
+
boundedSpans(runIds: readonly string[], perRunLimit?: number): Record<string, RunSpanV1[]>;
|
|
193
|
+
boundedEvidence(runIds: readonly string[], perRunLimit?: number): Record<string, {
|
|
194
|
+
spans: RunSpanV1[];
|
|
195
|
+
events: Array<{
|
|
196
|
+
eventId: string;
|
|
197
|
+
kind: string;
|
|
198
|
+
severity?: string;
|
|
199
|
+
observedAt: string;
|
|
200
|
+
attributes?: unknown;
|
|
201
|
+
}>;
|
|
202
|
+
metrics: Array<{
|
|
203
|
+
metric: string;
|
|
204
|
+
value: number;
|
|
205
|
+
unit?: string;
|
|
206
|
+
observedAt: string;
|
|
207
|
+
}>;
|
|
208
|
+
currentState: RunCurrentStateV1[];
|
|
209
|
+
executions: ReturnType<ObservabilityReader["executions"]>;
|
|
210
|
+
}>;
|
|
211
|
+
capability(runId: string): {
|
|
212
|
+
rafiVersion?: string;
|
|
213
|
+
sources: Record<string, DiagnosticSourceResultV1>;
|
|
214
|
+
} | undefined;
|
|
215
|
+
storage(): {
|
|
216
|
+
databaseBytes: number;
|
|
217
|
+
walBytes: number;
|
|
218
|
+
summaryOnly: boolean;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/** Records Manager session accounting only when observability already exists. It never creates or migrates schema. */
|
|
222
|
+
export declare class ManagerSessionRecorder {
|
|
223
|
+
private readonly db?;
|
|
224
|
+
private readonly v2;
|
|
225
|
+
constructor(projectDir: string, path?: string);
|
|
226
|
+
close(): void;
|
|
227
|
+
record(input: ManagerSessionRecord): void;
|
|
228
|
+
}
|
|
229
|
+
/** One observer is owned by one build process attachment. */
|
|
230
|
+
export declare class RunObserver {
|
|
231
|
+
readonly store: ObservabilityStore;
|
|
232
|
+
readonly runId: string;
|
|
233
|
+
readonly executionId: string;
|
|
234
|
+
private readonly storage;
|
|
235
|
+
private resourceTimer?;
|
|
236
|
+
constructor(store: ObservabilityStore, runId: string, input?: {
|
|
237
|
+
executionId?: string;
|
|
238
|
+
leaseGeneration?: number;
|
|
239
|
+
});
|
|
240
|
+
context(): ObservationContext;
|
|
241
|
+
withContext<T>(values: Partial<ObservationContext>, fn: () => T): T;
|
|
242
|
+
span<T>(kind: string, name: string, fn: () => Promise<T> | T, attributes?: Record<string, unknown>): Promise<T>;
|
|
243
|
+
signal(semantic?: boolean): void;
|
|
244
|
+
startResourceSampling(): void;
|
|
245
|
+
finish(outcome: string, metadata?: Omit<Parameters<ObservabilityStore["finalizeRun"]>[1], "status">): void;
|
|
246
|
+
}
|
|
247
|
+
export declare function sanitizeDiagnosticValue(value: unknown): unknown;
|
|
248
|
+
export declare function diagnosticDigest(value: unknown): string;
|