@quantiya/codevibe-core 2.0.84 → 2.0.85
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.
|
@@ -84,7 +84,7 @@ interface ShadowMarkerScan {
|
|
|
84
84
|
detail: string;
|
|
85
85
|
}>;
|
|
86
86
|
}
|
|
87
|
-
export declare function scanShadowMarkers(env?: ShadowEnv): Promise<ShadowMarkerScan>;
|
|
87
|
+
export declare function scanShadowMarkers(env?: ShadowEnv, ownedTaskIds?: ReadonlySet<string>): Promise<ShadowMarkerScan>;
|
|
88
88
|
export declare function reconcileExposureRetentions(retentions: ShadowMarkerScan['exposureRetentions'], recovered: readonly RecoveredShadow[], physicalCopyScope: string, env: ShadowEnv, retained: string[], snapshotIncarnations: SnapshotIncarnationIndex | null): Promise<void>;
|
|
89
89
|
export declare function reclaimDisplacedShadow(record: DisplacedShadowMarkerRecord, env: ShadowEnv, physicalCopyScope: string, opts: {
|
|
90
90
|
allowLiveOwner: boolean;
|
|
@@ -110,7 +110,7 @@ export declare function reconcileDisplacedSnapshots(records: readonly DisplacedS
|
|
|
110
110
|
* self-consistent pair. A v2 root of a format this desktop does not know is list-only, so it is not offered for
|
|
111
111
|
* recovery at all — recovery acts on what it is given.
|
|
112
112
|
*/
|
|
113
|
-
export declare function listRecoverableShadows(env?: ShadowEnv): Promise<RecoveredShadow[]>;
|
|
113
|
+
export declare function listRecoverableShadows(env?: ShadowEnv, ownedTaskIds?: ReadonlySet<string>): Promise<RecoveredShadow[]>;
|
|
114
114
|
/** `env` pinned to one root pair, so every default inside a pass resolves to that pair and nothing else. */
|
|
115
115
|
export declare function pairEnv(env: ShadowEnv, pass: {
|
|
116
116
|
stateRootDir: string;
|
|
@@ -46359,7 +46359,24 @@ async function readAnchoredStateMarkerSnapshotForScan(stateRootAuthority, stateD
|
|
|
46359
46359
|
}
|
|
46360
46360
|
};
|
|
46361
46361
|
}
|
|
46362
|
-
|
|
46362
|
+
function pinShadowTaskScope(ownedTaskIds) {
|
|
46363
|
+
let taskScope = ownedTaskIds === void 0 ? void 0 : new Set(ownedTaskIds);
|
|
46364
|
+
if (taskScope)
|
|
46365
|
+
for (let taskId of taskScope) {
|
|
46366
|
+
if (taskId.length === 0) throw new Error("WorkspaceShadow: empty owned task id");
|
|
46367
|
+
assertSafeStateComponent(taskId);
|
|
46368
|
+
}
|
|
46369
|
+
return taskScope;
|
|
46370
|
+
}
|
|
46371
|
+
async function scanShadowMarkers(env = {}, ownedTaskIds) {
|
|
46372
|
+
let taskScope = pinShadowTaskScope(ownedTaskIds);
|
|
46373
|
+
if (taskScope?.size === 0) return {
|
|
46374
|
+
recovered: [],
|
|
46375
|
+
exposureRetentions: [],
|
|
46376
|
+
displacedSnapshots: [],
|
|
46377
|
+
protectedDirNames: /* @__PURE__ */ new Set(),
|
|
46378
|
+
unresolved: []
|
|
46379
|
+
};
|
|
46363
46380
|
let helperTimeout = env.helperTimeoutMs ?? env.workspaceAuthorityHelperTimeoutMs ?? (env.signal ? 2e3 : void 0), maxStateMarkerBytes = resolveStateMarkerByteLimit(env), requestedStateRoot = env.stateRootDir ?? defaultStateRoot(), requestedShadowRoot = (await resolveShadowRoots(env)).shadowRootDir;
|
|
46364
46381
|
if (env.signal?.aborted) return { recovered: [], exposureRetentions: [], displacedSnapshots: [], protectedDirNames: /* @__PURE__ */ new Set(), unresolved: [] };
|
|
46365
46382
|
let stateRootAuthority = await captureWorkspaceRootAuthority(requestedStateRoot, {
|
|
@@ -46413,7 +46430,9 @@ async function scanShadowMarkers(env = {}) {
|
|
|
46413
46430
|
for (let taskEntry of entries) {
|
|
46414
46431
|
if (env.signal?.aborted) break;
|
|
46415
46432
|
if (isStateRootInfrastructureDirectory(taskEntry.name) || !taskEntry.isDirectory() || taskEntry.isSymbolicLink()) continue;
|
|
46416
|
-
let taskId = taskEntry.name
|
|
46433
|
+
let taskId = taskEntry.name;
|
|
46434
|
+
if (taskScope && !taskScope.has(taskId)) continue;
|
|
46435
|
+
let stateDir = path54.join(stateRoot, taskId), stateDirAuthority;
|
|
46417
46436
|
try {
|
|
46418
46437
|
stateDirAuthority = await captureWorkspaceRootAuthority(stateDir, {
|
|
46419
46438
|
helperTimeoutMs: helperTimeout,
|
|
@@ -47075,7 +47094,9 @@ async function reconcileDisplacedSnapshots(records, keepTaskIds, ttlMs, now, phy
|
|
|
47075
47094
|
});
|
|
47076
47095
|
}
|
|
47077
47096
|
}
|
|
47078
|
-
async function listRecoverableShadows(env = {}) {
|
|
47097
|
+
async function listRecoverableShadows(env = {}, ownedTaskIds) {
|
|
47098
|
+
let taskScope = pinShadowTaskScope(ownedTaskIds);
|
|
47099
|
+
if (taskScope?.size === 0) return [];
|
|
47079
47100
|
let out = [];
|
|
47080
47101
|
for (let pass of await shadowRootPasses(env)) {
|
|
47081
47102
|
if (!await passIsActionable(pass)) {
|
|
@@ -47084,7 +47105,7 @@ async function listRecoverableShadows(env = {}) {
|
|
|
47084
47105
|
});
|
|
47085
47106
|
continue;
|
|
47086
47107
|
}
|
|
47087
|
-
let scan = await scanShadowMarkers(pairEnv(env, pass));
|
|
47108
|
+
let scan = await scanShadowMarkers(pairEnv(env, pass), taskScope);
|
|
47088
47109
|
for (let recovered of scan.recovered)
|
|
47089
47110
|
out.push({ ...recovered, rootPair: { stateRootDir: pass.stateRootDir, shadowRootDir: pass.shadowRootDir } });
|
|
47090
47111
|
}
|
|
@@ -47178,16 +47199,18 @@ async function reconcileShadowPublicationAuthorityInPair(taskIds, env) {
|
|
|
47178
47199
|
);
|
|
47179
47200
|
}
|
|
47180
47201
|
async function listShadowCleanupResidue(taskIds, env = {}) {
|
|
47202
|
+
let taskScope = pinShadowTaskScope(taskIds);
|
|
47203
|
+
if (taskScope.size === 0) return [];
|
|
47181
47204
|
let residue = [];
|
|
47182
47205
|
for (let pass of await shadowRootPasses(env))
|
|
47183
|
-
residue.push(...await listShadowCleanupResidueInPair(
|
|
47206
|
+
residue.push(...await listShadowCleanupResidueInPair(taskScope, pairEnv(env, pass)));
|
|
47184
47207
|
return residue;
|
|
47185
47208
|
}
|
|
47186
47209
|
async function listShadowCleanupResidueInPair(taskIds, env) {
|
|
47187
47210
|
if (taskIds.size === 0) return [];
|
|
47188
47211
|
for (let taskId of taskIds)
|
|
47189
47212
|
if (taskId.length === 0 || taskId === "." || taskId === ".." || taskId.includes("\0") || path54.basename(taskId) !== taskId) throw new Error("invalid owned task id for workspace cleanup audit");
|
|
47190
|
-
let scan = await scanShadowMarkers(env), residue = [], add = (record2) => {
|
|
47213
|
+
let scan = await scanShadowMarkers(env, taskIds), residue = [], add = (record2) => {
|
|
47191
47214
|
taskIds.has(record2.taskId) && (residue.some(
|
|
47192
47215
|
(item2) => item2.taskId === record2.taskId && item2.path === record2.path && item2.kind === record2.kind
|
|
47193
47216
|
) || residue.push(record2));
|
|
@@ -60849,7 +60872,7 @@ var LocalExecutorImpl = class {
|
|
|
60849
60872
|
try {
|
|
60850
60873
|
[canonicalRepo, recovered, owner] = await Promise.all([
|
|
60851
60874
|
captureWorkspaceRootAuthority(repoRoot).then((value) => value.canonicalPath),
|
|
60852
|
-
listRecoverableShadows(env),
|
|
60875
|
+
listRecoverableShadows(env, this.integrationTaskIdsOwned),
|
|
60853
60876
|
currentProcessIdentity()
|
|
60854
60877
|
]);
|
|
60855
60878
|
} catch (err) {
|
|
@@ -74246,7 +74269,8 @@ ${section}`);
|
|
|
74246
74269
|
* unresolved authority are preserved, but returned as explicit failures.
|
|
74247
74270
|
*/
|
|
74248
74271
|
async cleanupOwnedTaskSnapshots(taskIds, context) {
|
|
74249
|
-
|
|
74272
|
+
if (taskIds.size === 0) return [];
|
|
74273
|
+
let failures = [], attemptFailures = [], env = this.deps.shadowEnv ?? {}, cleanupStartedAt = Date.now();
|
|
74250
74274
|
(await Promise.allSettled([...taskIds].map(
|
|
74251
74275
|
(taskId) => this.runExclusiveShadowOp(taskId, async () => {
|
|
74252
74276
|
let shadow = this.shadowsByTask.get(taskId);
|
|
@@ -74258,11 +74282,11 @@ ${section}`);
|
|
|
74258
74282
|
`${context} mapped workspace ${[...taskIds][index]} disposal failed`
|
|
74259
74283
|
));
|
|
74260
74284
|
});
|
|
74261
|
-
let canonicalWorkingDir, recovered, currentOwner;
|
|
74285
|
+
let mappedSettledAt = Date.now(), canonicalWorkingDir, recovered, currentOwner;
|
|
74262
74286
|
try {
|
|
74263
74287
|
[canonicalWorkingDir, recovered, currentOwner] = await Promise.all([
|
|
74264
74288
|
captureWorkspaceRootAuthority(this.deps.workingDir).then((authority) => authority.canonicalPath),
|
|
74265
|
-
(this.deps.shadowRecoveryOps?.listRecoverableShadows ?? listRecoverableShadows)(env),
|
|
74289
|
+
(this.deps.shadowRecoveryOps?.listRecoverableShadows ?? listRecoverableShadows)(env, taskIds),
|
|
74266
74290
|
currentProcessIdentity()
|
|
74267
74291
|
]);
|
|
74268
74292
|
} catch (err) {
|
|
@@ -74271,10 +74295,10 @@ ${section}`);
|
|
|
74271
74295
|
`${context} durable workspace enumeration failed`
|
|
74272
74296
|
)), failures.push(...attemptFailures), failures;
|
|
74273
74297
|
}
|
|
74274
|
-
let ownedRecovered = recovered.filter(
|
|
74298
|
+
let enumeratedAt = Date.now(), ownedRecovered = recovered.filter(
|
|
74275
74299
|
(item2) => item2.workingDir === canonicalWorkingDir && taskIds.has(item2.taskId)
|
|
74276
74300
|
);
|
|
74277
|
-
|
|
74301
|
+
(await Promise.allSettled(ownedRecovered.map(
|
|
74278
74302
|
(item2) => this.runExclusiveShadowOp(item2.taskId, async () => {
|
|
74279
74303
|
if (!(item2.ownerProcessIdentity.pid === currentOwner.pid && item2.ownerProcessIdentity.incarnationId === currentOwner.incarnationId) && await isProcessIdentityAlive(item2.ownerProcessIdentity))
|
|
74280
74304
|
throw new Error(
|
|
@@ -74295,7 +74319,9 @@ ${section}`);
|
|
|
74295
74319
|
`${context} durable workspace ${item2.taskId} (${item2.stateFile}) disposal failed`
|
|
74296
74320
|
));
|
|
74297
74321
|
}
|
|
74298
|
-
})
|
|
74322
|
+
});
|
|
74323
|
+
let recoveredSettledAt = Date.now();
|
|
74324
|
+
if (!this.deps.shadowRecoveryOps)
|
|
74299
74325
|
try {
|
|
74300
74326
|
await reconcileShadowPublicationAuthority(taskIds, env);
|
|
74301
74327
|
} catch (err) {
|
|
@@ -74306,7 +74332,7 @@ ${section}`);
|
|
|
74306
74332
|
}
|
|
74307
74333
|
try {
|
|
74308
74334
|
let remaining;
|
|
74309
|
-
this.deps.shadowRecoveryOps?.listShadowCleanupResidue ? remaining = await this.deps.shadowRecoveryOps.listShadowCleanupResidue(taskIds, env) : this.deps.shadowRecoveryOps?.listRecoverableShadows ? remaining = (await this.deps.shadowRecoveryOps.listRecoverableShadows(env)).filter(
|
|
74335
|
+
this.deps.shadowRecoveryOps?.listShadowCleanupResidue ? remaining = await this.deps.shadowRecoveryOps.listShadowCleanupResidue(taskIds, env) : this.deps.shadowRecoveryOps?.listRecoverableShadows ? remaining = (await this.deps.shadowRecoveryOps.listRecoverableShadows(env, taskIds)).filter(
|
|
74310
74336
|
(item2) => item2.workingDir === canonicalWorkingDir && taskIds.has(item2.taskId)
|
|
74311
74337
|
).map((item2) => ({
|
|
74312
74338
|
taskId: item2.taskId,
|
|
@@ -74330,7 +74356,15 @@ ${section}`);
|
|
|
74330
74356
|
`${context} final durable workspace enumeration failed`
|
|
74331
74357
|
)), failures.push(...attemptFailures);
|
|
74332
74358
|
}
|
|
74333
|
-
return
|
|
74359
|
+
return logger.debug("[QuorumLoop] owned workspace cleanup phase durations", {
|
|
74360
|
+
context,
|
|
74361
|
+
taskCount: taskIds.size,
|
|
74362
|
+
recoveredCount: ownedRecovered.length,
|
|
74363
|
+
mappedRetirementMs: mappedSettledAt - cleanupStartedAt,
|
|
74364
|
+
durableEnumerationMs: enumeratedAt - mappedSettledAt,
|
|
74365
|
+
recoveredRetirementMs: recoveredSettledAt - enumeratedAt,
|
|
74366
|
+
publicationAndAuditMs: Date.now() - recoveredSettledAt
|
|
74367
|
+
}), failures;
|
|
74334
74368
|
}
|
|
74335
74369
|
async disposeWorkspaces(opts = {}) {
|
|
74336
74370
|
let strict = opts.strict ?? !0;
|
|
@@ -518,7 +518,7 @@ export interface QuorumLoopDeps {
|
|
|
518
518
|
* weakening any production timeout or filesystem check.
|
|
519
519
|
*/
|
|
520
520
|
shadowRecoveryOps?: {
|
|
521
|
-
listRecoverableShadows?: (env: ShadowEnv) => Promise<RecoveredShadow[]>;
|
|
521
|
+
listRecoverableShadows?: (env: ShadowEnv, ownedTaskIds?: ReadonlySet<string>) => Promise<RecoveredShadow[]>;
|
|
522
522
|
listShadowCleanupResidue?: (taskIds: ReadonlySet<string>, env: ShadowEnv) => Promise<ShadowCleanupResidue[]>;
|
|
523
523
|
captureWorkspaceRootAuthority?: typeof captureWorkspaceRootAuthority;
|
|
524
524
|
reopenShadow?: (recovered: RecoveredShadow, env: ShadowEnv) => Promise<WorkspaceShadow | null>;
|
package/package.json
CHANGED