@aviaratech/ai-delivery 0.3.16 → 0.3.18

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.
@@ -1,4 +1,6 @@
1
1
  interface WithLockOptions<T> {
2
+ onCompromised?: (error: Error) => void;
3
+ onReleaseError?: (error: unknown) => void;
2
4
  onTimeout?: () => void;
3
5
  operation: () => Promise<T> | T;
4
6
  projectRoot?: string;
@@ -8,5 +10,5 @@ interface WithLockOptions<T> {
8
10
  * Execute a function with exclusive file lock
9
11
  * Prevents concurrent modifications to the worktree registry
10
12
  */
11
- export declare function withLock<T>(filePath: string, { onTimeout, operation, projectRoot, timeout }: WithLockOptions<T>): Promise<T>;
13
+ export declare function withLock<T>(filePath: string, { onCompromised, onReleaseError, onTimeout, operation, projectRoot, timeout }: WithLockOptions<T>): Promise<T>;
12
14
  export {};
@@ -11,7 +11,7 @@ const LOCK_RETRY_DELAY_MS = 200;
11
11
  * Execute a function with exclusive file lock
12
12
  * Prevents concurrent modifications to the worktree registry
13
13
  */
14
- export async function withLock(filePath, { onTimeout, operation, projectRoot, timeout }) {
14
+ export async function withLock(filePath, { onCompromised, onReleaseError, onTimeout, operation, projectRoot, timeout }) {
15
15
  const root = projectRoot ?? process.cwd();
16
16
  const lockPath = resolve(root, filePath);
17
17
  let release = null;
@@ -31,7 +31,10 @@ export async function withLock(filePath, { onTimeout, operation, projectRoot, ti
31
31
  const attemptLabel = maxAttempts !== null ? `${String(attempts)}/${String(maxAttempts)}` : String(attempts);
32
32
  logDebug(`Acquiring lock on ${lockPath}... (attempt ${attemptLabel})`);
33
33
  try {
34
- release = await lockfile.lock(lockPath, LOCK_OPTIONS);
34
+ release = await lockfile.lock(lockPath, {
35
+ ...LOCK_OPTIONS,
36
+ ...(onCompromised === undefined ? {} : { onCompromised }),
37
+ });
35
38
  logDebug(`Lock acquired on ${lockPath}`);
36
39
  break;
37
40
  }
@@ -59,6 +62,7 @@ export async function withLock(filePath, { onTimeout, operation, projectRoot, ti
59
62
  logDebug(`Lock released on ${lockPath}`);
60
63
  }
61
64
  catch (error) {
65
+ onReleaseError?.(error);
62
66
  // Lock release failure is non-fatal - stale lock will auto-expire
63
67
  logDebug(`Failed to release lock on ${lockPath}: ${error instanceof Error ? error.message : String(error)}`);
64
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lockfile.js","sourceRoot":"","sources":["../../src/utils/lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,KAAK,EAAE,wCAAwC;CACvD,CAAC;AAEF,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAShC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,QAAgB,EAChB,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAsB;IAElE,MAAM,IAAI,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEzC,IAAI,OAAO,GAAiC,IAAI,CAAC;IACjD,MAAM,eAAe,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACpF,MAAM,WAAW,GAAG,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvG,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,aAAa,GAAG,eAA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C;QAED,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC;gBACH,MAAM,OAAO,EAAE,CAAC;gBAChB,QAAQ,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC;gBACxB,kEAAkE;gBAClE,QAAQ,CAAC,6BAA6B,QAAQ,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC/G,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAI,KAA4B,CAAC,IAAI,CAAC;IAChD,OAAO,IAAI,KAAK,SAAS,CAAC;AAC5B,CAAC"}
@@ -53,6 +53,8 @@ export interface WorktreeTransitionWriterLeaseInput {
53
53
  afterClaim?(bytes: Buffer): void | Promise<void>;
54
54
  recordRelease(bytes: Buffer): void | Promise<void>;
55
55
  afterRelease?(): void | Promise<void>;
56
+ onLockReleaseError?: (error: unknown) => void;
57
+ onLockCompromised?: (error: Error) => void;
56
58
  }
57
59
  /** @internal Read-only closure check shared by inspection and the locked transition lease. */
58
60
  export declare function assertWorktreeTransitionWriterQuiescent(worktreePath: string, bytes: Buffer | undefined): void;
@@ -93,6 +95,142 @@ export declare function loadHistoricalMergedRun(repoRoot: string, headSha: strin
93
95
  };
94
96
  /** Recover an exact merged run after worktree removal interrupted terminal recording. */
95
97
  export declare function loadRemovedMergedRun(primaryRepoRoot: string, issueNumber: number): VerificationRun;
98
+ declare const SourceArtifactSchema: z.ZodObject<{
99
+ path: z.ZodString;
100
+ digest: z.ZodString;
101
+ }, z.core.$strict>;
102
+ declare const SourceSnapshotSchema: z.ZodObject<{
103
+ head: z.ZodString;
104
+ indexTree: z.ZodString;
105
+ branch: z.ZodString;
106
+ configDigest: z.ZodString;
107
+ dirty: z.ZodArray<z.ZodObject<{
108
+ path: z.ZodString;
109
+ digest: z.ZodNullable<z.ZodString>;
110
+ }, z.core.$strict>>;
111
+ }, z.core.$strict>;
112
+ declare const IssueSourcePhaseInputSchema: z.ZodObject<{
113
+ repoRoot: z.ZodString;
114
+ issueNumber: z.ZodNumber;
115
+ identity: z.ZodString;
116
+ rowDigest: z.ZodString;
117
+ controller: z.ZodObject<{
118
+ head: z.ZodString;
119
+ configDigest: z.ZodString;
120
+ admissionId: z.ZodString;
121
+ runtimeEntryPath: z.ZodString;
122
+ packageVersion: z.ZodString;
123
+ archiveDigest: z.ZodString;
124
+ }, z.core.$strict>;
125
+ source: z.ZodObject<{
126
+ head: z.ZodString;
127
+ indexTree: z.ZodString;
128
+ branch: z.ZodString;
129
+ configDigest: z.ZodString;
130
+ dirty: z.ZodArray<z.ZodObject<{
131
+ path: z.ZodString;
132
+ digest: z.ZodNullable<z.ZodString>;
133
+ }, z.core.$strict>>;
134
+ path: z.ZodString;
135
+ effect: z.ZodDiscriminatedUnion<[z.ZodObject<{
136
+ kind: z.ZodLiteral<"preserve">;
137
+ }, z.core.$strict>, z.ZodObject<{
138
+ kind: z.ZodLiteral<"commitOnce">;
139
+ parent: z.ZodString;
140
+ tree: z.ZodString;
141
+ }, z.core.$strict>], "kind">;
142
+ }, z.core.$strict>;
143
+ caller: z.ZodObject<{
144
+ path: z.ZodString;
145
+ digest: z.ZodString;
146
+ }, z.core.$strict>;
147
+ authorization: z.ZodObject<{
148
+ path: z.ZodString;
149
+ digest: z.ZodString;
150
+ }, z.core.$strict>;
151
+ inputs: z.ZodArray<z.ZodObject<{
152
+ path: z.ZodString;
153
+ digest: z.ZodString;
154
+ }, z.core.$strict>>;
155
+ commands: z.ZodArray<z.ZodObject<{
156
+ argv: z.ZodArray<z.ZodString>;
157
+ cwd: z.ZodString;
158
+ executable: z.ZodObject<{
159
+ path: z.ZodString;
160
+ digest: z.ZodString;
161
+ device: z.ZodNumber;
162
+ inode: z.ZodNumber;
163
+ uid: z.ZodNumber;
164
+ mode: z.ZodNumber;
165
+ }, z.core.$strict>;
166
+ }, z.core.$strict>>;
167
+ commandGraphDigest: z.ZodString;
168
+ environment: z.ZodObject<{
169
+ digest: z.ZodString;
170
+ overrides: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
171
+ }, z.core.$strict>;
172
+ bounds: z.ZodObject<{
173
+ maxAggregateRssBytes: z.ZodNumber;
174
+ maxNewOutputBytes: z.ZodNumber;
175
+ minFreeDiskBytes: z.ZodNumber;
176
+ outputRoots: z.ZodArray<z.ZodString>;
177
+ }, z.core.$strict>;
178
+ completionArtifacts: z.ZodArray<z.ZodString>;
179
+ reconciliation: z.ZodOptional<z.ZodObject<{
180
+ phaseId: z.ZodString;
181
+ recordId: z.ZodString;
182
+ baselineId: z.ZodOptional<z.ZodString>;
183
+ authorizationDigest: z.ZodString;
184
+ }, z.core.$strict>>;
185
+ }, z.core.$strict>;
186
+ export type IssueSourcePhaseInput = z.input<typeof IssueSourcePhaseInputSchema> & {
187
+ signal?: AbortSignal;
188
+ };
189
+ export interface IssueSourcePhaseContext {
190
+ readonly phaseId: string;
191
+ readonly signal: AbortSignal;
192
+ readonly source: Readonly<Omit<z.infer<typeof SourceSnapshotSchema>, 'dirty'>> & {
193
+ readonly dirty: readonly Readonly<{
194
+ path: string;
195
+ digest: string | null;
196
+ }>[];
197
+ };
198
+ readonly controller: Readonly<z.infer<typeof IssueSourcePhaseInputSchema>['controller']>;
199
+ readonly actor: Readonly<{
200
+ identity: string;
201
+ actorLogin: string;
202
+ credentialIdentity: string;
203
+ }>;
204
+ readonly inputs: readonly Readonly<z.infer<typeof SourceArtifactSchema>>[];
205
+ readonly run: (index: number) => Promise<Buffer>;
206
+ }
207
+ declare const IssueSourcePhaseReceiptSchema: z.ZodObject<{
208
+ status: z.ZodLiteral<"complete">;
209
+ phaseId: z.ZodString;
210
+ recordId: z.ZodString;
211
+ source: z.ZodObject<{
212
+ head: z.ZodString;
213
+ indexTree: z.ZodString;
214
+ branch: z.ZodString;
215
+ configDigest: z.ZodString;
216
+ dirty: z.ZodArray<z.ZodObject<{
217
+ path: z.ZodString;
218
+ digest: z.ZodNullable<z.ZodString>;
219
+ }, z.core.$strict>>;
220
+ }, z.core.$strict>;
221
+ commands: z.ZodArray<z.ZodObject<{
222
+ index: z.ZodNumber;
223
+ outputDigest: z.ZodNullable<z.ZodString>;
224
+ outputBytes: z.ZodNumber;
225
+ status: z.ZodEnum<{
226
+ failed: "failed";
227
+ complete: "complete";
228
+ }>;
229
+ }, z.core.$strict>>;
230
+ }, z.core.$strict>;
231
+ export type IssueSourcePhaseReceipt = z.infer<typeof IssueSourcePhaseReceiptSchema>;
232
+ /** Run an authorized, frozen source graph under the registered issue's existing writer fence. */
233
+ export declare function withIssueSourcePhase(supplied: IssueSourcePhaseInput, operation: (context: IssueSourcePhaseContext) => Promise<void>): Promise<IssueSourcePhaseReceipt>;
96
234
  /** @internal Runtime setup shares the existing writer, ownership handshake and bounded command runner. */
97
235
  export declare function withRuntimeSetupWriter<T>(root: string, operation: (runner: {
98
236
  assertQuiescent(): void;