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.
Files changed (75) hide show
  1. package/README.md +15 -0
  2. package/dist/activity.d.ts +5 -1
  3. package/dist/activity.js +1 -1
  4. package/dist/adapters/claude.d.ts +7 -0
  5. package/dist/adapters/claude.js +133 -7
  6. package/dist/adapters/codex.d.ts +5 -0
  7. package/dist/adapters/codex.js +121 -11
  8. package/dist/adapters/recovering.d.ts +2 -0
  9. package/dist/adapters/recovering.js +11 -1
  10. package/dist/adapters/types.d.ts +47 -1
  11. package/dist/agentRun.d.ts +2 -0
  12. package/dist/agentRun.js +8 -2
  13. package/dist/branch/resume.js +11 -1
  14. package/dist/branch/runner.d.ts +12 -3
  15. package/dist/branch/runner.js +131 -67
  16. package/dist/buildRuns.d.ts +6 -2
  17. package/dist/buildRuns.js +76 -32
  18. package/dist/cli/doctor.d.ts +7 -0
  19. package/dist/cli/doctor.js +84 -1
  20. package/dist/cli/manager.d.ts +17 -0
  21. package/dist/cli/manager.js +135 -0
  22. package/dist/cli/recovery.d.ts +4 -0
  23. package/dist/cli/recovery.js +80 -0
  24. package/dist/cli/start.js +446 -142
  25. package/dist/cli/status.js +13 -2
  26. package/dist/cli/tickets.js +27 -9
  27. package/dist/config.d.ts +4 -0
  28. package/dist/config.js +28 -1
  29. package/dist/continuity.js +14 -9
  30. package/dist/diagnostics.d.ts +25 -0
  31. package/dist/diagnostics.js +428 -0
  32. package/dist/foreman.d.ts +26 -6
  33. package/dist/foreman.js +147 -104
  34. package/dist/handoffs.d.ts +35 -3
  35. package/dist/handoffs.js +155 -17
  36. package/dist/index.js +6 -0
  37. package/dist/log.d.ts +3 -3
  38. package/dist/log.js +4 -1
  39. package/dist/managerPacket.d.ts +25 -0
  40. package/dist/managerPacket.js +83 -0
  41. package/dist/markers.d.ts +1 -1
  42. package/dist/markers.js +4 -1
  43. package/dist/notify.d.ts +4 -0
  44. package/dist/notify.js +15 -0
  45. package/dist/observability.d.ts +248 -0
  46. package/dist/observability.js +1018 -0
  47. package/dist/planChanges.d.ts +4 -0
  48. package/dist/planChanges.js +16 -0
  49. package/dist/projectDiagnostics.d.ts +27 -0
  50. package/dist/projectDiagnostics.js +407 -0
  51. package/dist/qaRecovery.d.ts +140 -0
  52. package/dist/qaRecovery.js +595 -0
  53. package/dist/qaReview.d.ts +133 -14
  54. package/dist/qaReview.js +984 -59
  55. package/dist/qaSnapshot.d.ts +31 -5
  56. package/dist/qaSnapshot.js +209 -134
  57. package/dist/recoveryPolicy.d.ts +37 -0
  58. package/dist/recoveryPolicy.js +251 -0
  59. package/dist/roles.js +1 -0
  60. package/dist/supervisor.d.ts +40 -0
  61. package/dist/supervisor.js +102 -0
  62. package/dist/ticketHistoryReader.d.ts +19 -0
  63. package/dist/ticketHistoryReader.js +58 -0
  64. package/dist/tickets/details.d.ts +8 -0
  65. package/dist/tickets/details.js +59 -11
  66. package/dist/tickets/output.d.ts +5 -0
  67. package/dist/tickets/output.js +73 -0
  68. package/dist/tickets/stateDb.d.ts +1 -0
  69. package/dist/tickets/stateDb.js +5 -0
  70. package/dist/workflowDb.d.ts +31 -2
  71. package/dist/workflowDb.js +192 -23
  72. package/dist/workflowReader.d.ts +42 -0
  73. package/dist/workflowReader.js +171 -0
  74. package/foreman.yaml +13 -0
  75. package/package.json +51 -3
@@ -1,48 +1,166 @@
1
- import type { ProviderSessionRefV1, SessionStrategy } from "rafi-spec";
1
+ import { type ProviderSessionRefV1, type QaFailureReportV1, type SessionStrategy } from "rafi-spec";
2
2
  import type { BuilderAdapter, CompactResult } from "./adapters/types.js";
3
+ import type { RunObserver } from "./observability.js";
3
4
  import type { TicketDef } from "./tickets/ticketSchema.js";
5
+ import { type QaRecoveryPacket } from "./qaRecovery.js";
4
6
  export interface QaStreamState {
5
7
  sessionId?: string;
6
8
  sessionRef?: ProviderSessionRefV1;
7
9
  reviews: number;
8
10
  modificationViolations: number;
11
+ remediationGeneration?: number;
12
+ /** Exact host-observed Builder responses; prompt-facing summaries remain separately bounded. */
13
+ builderResponseHistory?: Array<{
14
+ ticketId: string;
15
+ cycle: number;
16
+ kind: "completion" | "remediation" | "plain-fallback";
17
+ response: string;
18
+ summary: string;
19
+ }>;
20
+ }
21
+ export interface QaReportHistoryEntry {
22
+ cycle: number;
23
+ reviewAttempt?: number;
24
+ remediationGeneration?: number;
25
+ attemptId?: string;
26
+ outcome: string;
27
+ detail: string;
28
+ reportDigest?: string;
29
+ report?: QaFailureReportV1;
30
+ findingIds?: string[];
31
+ fixSummaryDigest?: string;
32
+ fixSummary?: string;
33
+ remediationDigest?: string;
34
+ remediation?: string;
9
35
  }
10
36
  export interface QaNonconvergenceContext {
11
37
  ticket: TicketDef;
12
- history: Array<{
13
- cycle: number;
14
- outcome: string;
15
- detail: string;
16
- }>;
38
+ history: QaReportHistoryEntry[];
17
39
  builderWorktree: string;
18
40
  }
19
41
  export type QaNonconvergenceDecision = {
20
42
  action: "retry" | "pause" | "waive" | "remediate";
21
43
  remediation?: string;
22
44
  };
45
+ export type QaFixRequest = {
46
+ kind: "validated-report";
47
+ report: QaFailureReportV1;
48
+ reportDigest: string;
49
+ history: QaReportHistoryEntry[];
50
+ latestBuilderResult: string;
51
+ } | {
52
+ kind: "planner-remediation";
53
+ report: QaFailureReportV1;
54
+ reportDigest: string;
55
+ remediation: string;
56
+ history: QaReportHistoryEntry[];
57
+ latestBuilderResult: string;
58
+ } | {
59
+ kind: "plain-issues";
60
+ issues: string;
61
+ operatorApproved: true;
62
+ history: QaReportHistoryEntry[];
63
+ latestBuilderResult: string;
64
+ };
65
+ export type QaFixResult = {
66
+ ok: true;
67
+ response: string;
68
+ summary: string;
69
+ detail?: string;
70
+ } | {
71
+ ok: false;
72
+ detail?: string;
73
+ response?: string;
74
+ summary?: string;
75
+ };
76
+ export interface QaSessionHandle {
77
+ adapter: BuilderAdapter;
78
+ sessionIdentity?: ProviderSessionRefV1 | string;
79
+ effectiveRoleInstructions: string;
80
+ runtimeContext: unknown;
81
+ skills: Array<{
82
+ name: string;
83
+ digest: string | "unavailable";
84
+ reason?: string;
85
+ path?: string;
86
+ }>;
87
+ handoffReceipt?: unknown;
88
+ }
89
+ export interface QaSessionBoundaryRecovery {
90
+ packetDigest: string;
91
+ reviewedStateDigest: string;
92
+ packetPath: string;
93
+ resources: Array<{
94
+ label: string;
95
+ digest: string;
96
+ requiredForRecovery: boolean;
97
+ mediaType: string;
98
+ path: string;
99
+ }>;
100
+ }
101
+ export type QaReportRecoveryDecision = {
102
+ action: "fresh";
103
+ } | {
104
+ action: "plain";
105
+ } | {
106
+ action: "manual";
107
+ } | {
108
+ action: "guidance";
109
+ instructions: string;
110
+ route?: "current" | "compact" | "fresh";
111
+ } | {
112
+ action: "pause";
113
+ };
114
+ export type QaReportRecoveryHandler = NonNullable<IsolatedQaOptions["onReportRecovery"]>;
23
115
  export interface IsolatedQaOptions {
24
116
  ticket: TicketDef;
25
117
  builderWorktree: string;
26
118
  builderSummary: string;
27
119
  qaStrategy: SessionStrategy;
28
120
  state: QaStreamState;
29
- createQa: (cwd: string, sessionId?: string) => Promise<BuilderAdapter>;
121
+ createQa: (cwd: string, sessionId?: string) => Promise<BuilderAdapter | QaSessionHandle>;
30
122
  /** Host-owned ordinary QA boundary. Fresh strategies must return a validated successor. */
31
- sessionBoundary?: (adapter: BuilderAdapter, frozenAction: string, strategy: SessionStrategy, cwd: string) => Promise<BuilderAdapter>;
123
+ sessionBoundary?: (adapter: BuilderAdapter, frozenAction: string, strategy: SessionStrategy, cwd: string, recovery?: QaSessionBoundaryRecovery) => Promise<BuilderAdapter>;
32
124
  /** Persist provider-native automatic compactions without imposing an ordinary QA boundary. */
33
125
  observeNativeCompactions?: (adapter: BuilderAdapter) => Promise<void>;
34
- fix: (issues: string) => Promise<{
35
- ok: boolean;
36
- detail?: string;
37
- }>;
126
+ fix: (request: QaFixRequest) => Promise<QaFixResult>;
38
127
  maxCycles: number;
128
+ /** Durable QA execution scope; review/fix budgets survive worker restarts. */
129
+ recovery: {
130
+ projectDir: string;
131
+ runId: string;
132
+ };
133
+ observer?: RunObserver;
39
134
  evidence?: (entry: {
40
135
  cycle: number;
136
+ reviewAttempt?: number;
137
+ remediationGeneration?: number;
138
+ attemptId?: string;
41
139
  outcome: string;
42
140
  detail: string;
141
+ durationMs?: number;
43
142
  qaDiff?: string[];
44
143
  }) => void;
45
144
  onNonconvergence?: (context: QaNonconvergenceContext) => Promise<QaNonconvergenceDecision>;
145
+ /** Resolve a QA blocker with the same still-open QA session before disposal. */
146
+ resolveBlocked?: (adapter: BuilderAdapter, reason: string) => Promise<{
147
+ result: import("./adapters/types.js").TurnResult;
148
+ status: import("./foreman.js").StepStatus;
149
+ }>;
150
+ onReportRecovery?: (context: {
151
+ packet: QaRecoveryPacket;
152
+ menu: readonly string[];
153
+ originalIssues?: string;
154
+ liveSession: boolean;
155
+ contextUsage?: unknown;
156
+ }) => Promise<QaReportRecoveryDecision>;
157
+ /** Accumulated authoritative QA/fix history, populated by runIsolatedQa. */
158
+ qaHistory?: QaReportHistoryEntry[];
159
+ qaRuntimeContext?: unknown;
160
+ /** A durable packet selected by build:resume and transferred by validated handoff. */
161
+ resumedRecovery?: QaRecoveryPacket;
162
+ /** True when a continuity wrapper validates and strips deltas before returning turn text. */
163
+ continuityManaged?: boolean;
46
164
  }
47
165
  export interface IsolatedQaResult {
48
166
  outcome: "passed" | "blocked" | "needs-human" | "nonconverged" | "waived";
@@ -50,6 +168,7 @@ export interface IsolatedQaResult {
50
168
  summary?: string;
51
169
  }
52
170
  export declare function runIsolatedQa(opts: IsolatedQaOptions): Promise<IsolatedQaResult>;
53
- export declare function buildQaReviewHandoff(ticket: TicketDef, builderSummary: string, diffDigest: string, validationChecklist: string[]): string;
171
+ export declare function buildQaReviewHandoff(ticket: TicketDef, builderSummary: string, diffDigest: string, validationChecklist: string[], changeSummary?: unknown): string;
54
172
  export declare function compactWithRetry(adapter: BuilderAdapter): Promise<CompactResult>;
55
- export declare function buildDurableQaFixHandoff(ticket: TicketDef, issues: string, worktree: string, priorResult: string, diffDigest: string): string;
173
+ export declare function buildDurableQaFixHandoff(ticket: TicketDef, request: QaFixRequest, worktree: string, priorResult: string, diffDigest: string, changeSummary?: string): string;
174
+ export declare const QA_REPORT_RECOVERY_MENU: readonly ["Try another fresh QA.", "Use plain issues fallback.", "Manually fix saved JSON.", "Give QA specific instructions.", "Pause."];