@cortexkit/antigravity-auth-core 3.0.38 → 3.0.39
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/common-auth-embedded/claustrum/availability.d.ts +7 -1
- package/dist/common-auth-embedded/claustrum/availability.js +9 -1
- package/dist/common-auth-embedded/claustrum/custody.d.ts +11 -2
- package/dist/common-auth-embedded/claustrum/custody.js +89 -31
- package/dist/common-auth-embedded/claustrum/enrollment.d.ts +4 -0
- package/dist/common-auth-embedded/claustrum/enrollment.js +33 -2
- package/dist/common-auth-embedded/claustrum/host.js +11 -7
- package/dist/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/common-auth-embedded/claustrum/index.js +1 -1
- package/dist/common-auth-embedded/fs/lock-record.js +55 -0
- package/dist/common-auth-embedded/fs/refresh-file-lock.js +148 -92
- package/dist/common-auth-embedded/fs/with-lock.js +19 -13
- package/dist/common-auth-embedded/source-output.json +48 -40
- package/dist/model-registry.d.ts +3 -0
- package/dist/model-registry.d.ts.map +1 -1
- package/dist/model-registry.js +59 -0
- package/dist/model-registry.js.map +1 -1
- package/dist/transform/agy-generation.d.ts.map +1 -1
- package/dist/transform/agy-generation.js +7 -4
- package/dist/transform/agy-generation.js.map +1 -1
- package/dist/transform/model-resolver.d.ts.map +1 -1
- package/dist/transform/model-resolver.js +8 -3
- package/dist/transform/model-resolver.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { link, lstat, mkdir, open, readFile, rename, rm, stat, } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
+
import { DisappearedLockRecordError, isWindowsAccessDeniedCreate, isWindowsAccessDeniedRead, readLockRecord, } from './lock-record.js';
|
|
4
5
|
import { createPrivateBytes, createPrivateDirectoryExclusive, ensurePrivateDirectory, isWindowsSharingViolation, PrivateFileError, privateOperation, readPrivateText, verifyPrivate, windowsPrivateFiles, writePrivateAtomic, } from './private-files.js';
|
|
5
6
|
import { LockOwnershipError, lockPathFor } from './with-lock.js';
|
|
6
7
|
let leaseCreationTestHooks;
|
|
@@ -192,17 +193,22 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
192
193
|
const evictOwnerId = randomUUID();
|
|
193
194
|
const EVICT_TTL = 5_000;
|
|
194
195
|
const MAX_STEAL_ATTEMPTS = 8;
|
|
196
|
+
function isChangingLockCreate(error) {
|
|
197
|
+
return (windowsPrivateFiles &&
|
|
198
|
+
(isWindowsAccessDeniedCreate(error, [lockPath], 'create') ||
|
|
199
|
+
isWindowsAccessDeniedCreate(error, [evictPath], 'directory-create')));
|
|
200
|
+
}
|
|
195
201
|
async function readOwner() {
|
|
196
202
|
if (windowsPrivateFiles) {
|
|
197
203
|
try {
|
|
198
|
-
return JSON.parse(await readPrivateText(lockPath, true));
|
|
204
|
+
return JSON.parse(await readLockRecord(lockPath, () => readPrivateText(lockPath, true)));
|
|
199
205
|
}
|
|
200
206
|
catch (error) {
|
|
201
207
|
if (error.code !== 'EISDIR' &&
|
|
202
208
|
error.reason !== 'wrong-kind')
|
|
203
209
|
throw error;
|
|
204
|
-
await verifyPrivate(lockPath, 'directory', true);
|
|
205
|
-
return JSON.parse(await readPrivateText(legacyOwnerPath, true));
|
|
210
|
+
await readLockRecord(lockPath, () => verifyPrivate(lockPath, 'directory', true));
|
|
211
|
+
return JSON.parse(await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true)));
|
|
206
212
|
}
|
|
207
213
|
}
|
|
208
214
|
try {
|
|
@@ -280,8 +286,8 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
280
286
|
await options.onStep('lease-contention-read-ready');
|
|
281
287
|
try {
|
|
282
288
|
if (code === 'EISDIR') {
|
|
283
|
-
await verifyPrivate(lockPath, 'directory', true);
|
|
284
|
-
await readPrivateText(legacyOwnerPath, true);
|
|
289
|
+
await readLockRecord(lockPath, () => verifyPrivate(lockPath, 'directory', true));
|
|
290
|
+
await readLockRecord(legacyOwnerPath, () => readPrivateText(legacyOwnerPath, true));
|
|
285
291
|
}
|
|
286
292
|
else
|
|
287
293
|
await readOwner();
|
|
@@ -337,6 +343,10 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
337
343
|
owner = await readOwner();
|
|
338
344
|
}
|
|
339
345
|
catch (error) {
|
|
346
|
+
// A delete-pending owner that disappeared is a create opportunity,
|
|
347
|
+
// never an ownerless legacy directory eligible for stale eviction.
|
|
348
|
+
if (error instanceof DisappearedLockRecordError)
|
|
349
|
+
return { status: 'missing' };
|
|
340
350
|
if (windowsPrivateFiles &&
|
|
341
351
|
error.code !== 'ENOENT')
|
|
342
352
|
throw error;
|
|
@@ -395,7 +405,7 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
395
405
|
// Fail-closed: any read error means we do NOT own the marker.
|
|
396
406
|
async function ownsEvictionMarker() {
|
|
397
407
|
try {
|
|
398
|
-
const owner = JSON.parse(await readPrivateText(evictOwnerPath, windowsPrivateFiles));
|
|
408
|
+
const owner = JSON.parse(await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, windowsPrivateFiles)));
|
|
399
409
|
return owner?.ownerId === evictOwnerId;
|
|
400
410
|
}
|
|
401
411
|
catch (error) {
|
|
@@ -581,7 +591,7 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
581
591
|
}
|
|
582
592
|
if (windowsPrivateFiles) {
|
|
583
593
|
try {
|
|
584
|
-
await verifyPrivate(evictPath, 'directory', true);
|
|
594
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, 'directory', true));
|
|
585
595
|
}
|
|
586
596
|
catch (error) {
|
|
587
597
|
// The marker's holder can remove it between the stat above and this
|
|
@@ -654,8 +664,8 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
654
664
|
if (error.code === 'EEXIST') {
|
|
655
665
|
if (windowsPrivateFiles) {
|
|
656
666
|
try {
|
|
657
|
-
await verifyPrivate(evictPath, 'directory', true);
|
|
658
|
-
await readPrivateText(evictOwnerPath, true);
|
|
667
|
+
await readLockRecord(evictPath, () => verifyPrivate(evictPath, 'directory', true));
|
|
668
|
+
await readLockRecord(evictOwnerPath, () => readPrivateText(evictOwnerPath, true));
|
|
659
669
|
}
|
|
660
670
|
catch (ownerError) {
|
|
661
671
|
// A marker removed by its holder after the failed create is free:
|
|
@@ -681,10 +691,16 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
681
691
|
await releaseEvictionMarker(deadline);
|
|
682
692
|
}
|
|
683
693
|
catch (error) {
|
|
684
|
-
// Cleanup
|
|
685
|
-
//
|
|
686
|
-
if (isRetryableRemoval(actionError, lockPath)
|
|
687
|
-
|
|
694
|
+
// Cleanup IO failures must not replace the original lock refusal when
|
|
695
|
+
// both operations use the same deadline.
|
|
696
|
+
if ((isRetryableRemoval(actionError, lockPath) ||
|
|
697
|
+
isWindowsAccessDeniedRead(actionError, [
|
|
698
|
+
lockPath,
|
|
699
|
+
legacyOwnerPath,
|
|
700
|
+
evictOwnerPath,
|
|
701
|
+
])) &&
|
|
702
|
+
(isRetryableRemoval(error, evictPath) ||
|
|
703
|
+
isWindowsAccessDeniedRead(error, [evictOwnerPath])))
|
|
688
704
|
throw actionError;
|
|
689
705
|
throw error;
|
|
690
706
|
}
|
|
@@ -705,7 +721,8 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
705
721
|
owner = await readOwner();
|
|
706
722
|
}
|
|
707
723
|
catch (error) {
|
|
708
|
-
if (windowsPrivateFiles
|
|
724
|
+
if (windowsPrivateFiles &&
|
|
725
|
+
!(error instanceof DisappearedLockRecordError))
|
|
709
726
|
throw error;
|
|
710
727
|
return;
|
|
711
728
|
}
|
|
@@ -789,7 +806,9 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
789
806
|
}
|
|
790
807
|
}
|
|
791
808
|
catch (error) {
|
|
792
|
-
if (windowsPrivateFiles &&
|
|
809
|
+
if (windowsPrivateFiles &&
|
|
810
|
+
error instanceof PrivateFileError &&
|
|
811
|
+
!isChangingLockCreate(error)) {
|
|
793
812
|
terminalIOError = error;
|
|
794
813
|
recordLoss('renewal-failed');
|
|
795
814
|
shouldReschedule = false;
|
|
@@ -844,90 +863,112 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
844
863
|
}
|
|
845
864
|
return null;
|
|
846
865
|
}
|
|
847
|
-
let acquired =
|
|
866
|
+
let acquired = false;
|
|
867
|
+
let changingCreateError;
|
|
868
|
+
try {
|
|
869
|
+
acquired = await tryAcquire();
|
|
870
|
+
}
|
|
871
|
+
catch (error) {
|
|
872
|
+
if (!isChangingLockCreate(error))
|
|
873
|
+
throw error;
|
|
874
|
+
changingCreateError = error;
|
|
875
|
+
}
|
|
848
876
|
if (!acquired) {
|
|
849
877
|
for (let attempt = 0; attempt < MAX_STEAL_ATTEMPTS; attempt++) {
|
|
850
|
-
acquired = await tryAcquire();
|
|
851
|
-
if (acquired)
|
|
852
|
-
break;
|
|
853
|
-
const observed = await readLockState();
|
|
854
|
-
if (observed.status === 'live')
|
|
855
|
-
return contended();
|
|
856
|
-
// Absence is a create opportunity, never evidence of an expired lease.
|
|
857
|
-
if (observed.status === 'missing')
|
|
858
|
-
continue;
|
|
859
|
-
if (options.onStep)
|
|
860
|
-
await options.onStep('stale-lock-observed');
|
|
861
878
|
try {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
catch (evictError) {
|
|
868
|
-
const code = evictError.code;
|
|
869
|
-
if (code !== 'EEXIST')
|
|
870
|
-
throw evictError;
|
|
871
|
-
const recovered = await recoverStaleEvictionMarker();
|
|
872
|
-
if (recovered === 'fresh')
|
|
873
|
-
return null;
|
|
874
|
-
await backoff();
|
|
875
|
-
continue;
|
|
876
|
-
}
|
|
877
|
-
try {
|
|
878
|
-
const confirmed = await readLockState();
|
|
879
|
-
if (confirmed.status === 'live')
|
|
879
|
+
acquired = await tryAcquire();
|
|
880
|
+
if (acquired)
|
|
881
|
+
break;
|
|
882
|
+
const observed = await readLockState();
|
|
883
|
+
if (observed.status === 'live')
|
|
880
884
|
return contended();
|
|
881
|
-
|
|
885
|
+
// Absence is a create opportunity, never evidence of an expired lease.
|
|
886
|
+
if (observed.status === 'missing')
|
|
882
887
|
continue;
|
|
883
|
-
// Verify marker ownership before removing a lock found not live.
|
|
884
|
-
if (!(await ownsEvictionMarker()))
|
|
885
|
-
return null;
|
|
886
888
|
if (options.onStep)
|
|
887
|
-
await options.onStep('stale-lock-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
889
|
+
await options.onStep('stale-lock-observed');
|
|
890
|
+
try {
|
|
891
|
+
if (!(await tryAcquireEvictionMarker())) {
|
|
892
|
+
await backoff();
|
|
893
|
+
continue;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
catch (evictError) {
|
|
897
|
+
const code = evictError.code;
|
|
898
|
+
if (code !== 'EEXIST')
|
|
899
|
+
throw evictError;
|
|
900
|
+
const recovered = await recoverStaleEvictionMarker();
|
|
901
|
+
if (recovered === 'fresh')
|
|
902
|
+
return null;
|
|
903
|
+
await backoff();
|
|
895
904
|
continue;
|
|
896
|
-
// The final read and removal are not atomic. While this stale file
|
|
897
|
-
// exists, wx cannot create a successor; the marker excludes other
|
|
898
|
-
// evictors and release/renewal. An expired holder cannot renew: renewal
|
|
899
|
-
// rechecks expiry and marker ownership immediately before publishing.
|
|
900
|
-
// With the marker still owned, cooperating users cannot replace it in
|
|
901
|
-
// this window. Arbitrary suspension across marker expiry or filesystem
|
|
902
|
-
// changes still need a kernel lock for an atomic guarantee.
|
|
903
|
-
await removeLeaseObject(lockPath);
|
|
904
|
-
// Fence check 3: re-verify ownership after removing the stale lock.
|
|
905
|
-
if (!(await ownsEvictionMarker()))
|
|
906
|
-
return null;
|
|
907
|
-
if (options.onStep)
|
|
908
|
-
await options.onStep('stale-lock-removed');
|
|
909
|
-
acquired = await tryAcquire();
|
|
910
|
-
if (!acquired)
|
|
911
|
-
return null;
|
|
912
|
-
if (options.onStep)
|
|
913
|
-
await options.onStep('stale-lock-recreated');
|
|
914
|
-
// Fence check 4: re-verify ownership after acquiring the lock. If the
|
|
915
|
-
// marker was stolen between tryAcquire and this check, release the
|
|
916
|
-
// just-acquired lock and return null (fail-closed).
|
|
917
|
-
if (!(await ownsEvictionMarker())) {
|
|
918
|
-
await relinquishLockAfterMarkerLoss();
|
|
919
|
-
acquired = false;
|
|
920
|
-
return null;
|
|
921
905
|
}
|
|
922
|
-
|
|
906
|
+
try {
|
|
907
|
+
const confirmed = await readLockState();
|
|
908
|
+
if (confirmed.status === 'live')
|
|
909
|
+
return contended();
|
|
910
|
+
if (!sameStaleLock(observed.identity, confirmed))
|
|
911
|
+
continue;
|
|
912
|
+
// Verify marker ownership before removing a lock found not live.
|
|
913
|
+
if (!(await ownsEvictionMarker()))
|
|
914
|
+
return null;
|
|
915
|
+
if (options.onStep)
|
|
916
|
+
await options.onStep('stale-lock-confirmed');
|
|
917
|
+
// The onStep callback can pause while another contender renames
|
|
918
|
+
// our marker, so verify ownership again after the callback.
|
|
919
|
+
if (!(await ownsEvictionMarker()))
|
|
920
|
+
return null;
|
|
921
|
+
// Do not await a callback between this ownership check and the lock read.
|
|
922
|
+
const current = await readLockState(false);
|
|
923
|
+
if (!sameStaleLock(observed.identity, current))
|
|
924
|
+
continue;
|
|
925
|
+
// The final read and removal are not atomic. While this stale file
|
|
926
|
+
// exists, exclusive creation cannot publish a successor; the marker
|
|
927
|
+
// excludes other evictors and release/renewal. An expired holder cannot
|
|
928
|
+
// renew: renewal rechecks expiry and marker ownership before publishing.
|
|
929
|
+
// With the marker still owned, cooperating users cannot replace it in
|
|
930
|
+
// this window. Arbitrary suspension across marker expiry or filesystem
|
|
931
|
+
// changes still need a kernel lock for an atomic guarantee.
|
|
932
|
+
await removeLeaseObject(lockPath);
|
|
933
|
+
// Fence check 3: re-verify ownership after removing the stale lock.
|
|
934
|
+
if (!(await ownsEvictionMarker()))
|
|
935
|
+
return null;
|
|
936
|
+
if (options.onStep)
|
|
937
|
+
await options.onStep('stale-lock-removed');
|
|
938
|
+
acquired = await tryAcquire();
|
|
939
|
+
if (!acquired)
|
|
940
|
+
return null;
|
|
941
|
+
if (options.onStep)
|
|
942
|
+
await options.onStep('stale-lock-recreated');
|
|
943
|
+
// Fence check 4: re-verify ownership after acquiring the lock. If the
|
|
944
|
+
// marker was stolen between tryAcquire and this check, release the
|
|
945
|
+
// just-acquired lock and return null (fail-closed).
|
|
946
|
+
if (!(await ownsEvictionMarker())) {
|
|
947
|
+
await relinquishLockAfterMarkerLoss();
|
|
948
|
+
acquired = false;
|
|
949
|
+
return null;
|
|
950
|
+
}
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
finally {
|
|
954
|
+
await releaseEvictionMarker();
|
|
955
|
+
}
|
|
923
956
|
}
|
|
924
|
-
|
|
925
|
-
|
|
957
|
+
catch (error) {
|
|
958
|
+
if (!isChangingLockCreate(error))
|
|
959
|
+
throw error;
|
|
960
|
+
// A refused create is busy, not stale. Retry exclusive creation before
|
|
961
|
+
// any owner read or eviction, retaining the first persistent refusal.
|
|
962
|
+
changingCreateError ??= error;
|
|
963
|
+
await backoff();
|
|
926
964
|
}
|
|
927
965
|
}
|
|
928
966
|
}
|
|
929
|
-
if (!acquired)
|
|
967
|
+
if (!acquired) {
|
|
968
|
+
if (changingCreateError)
|
|
969
|
+
throw changingCreateError;
|
|
930
970
|
return null;
|
|
971
|
+
}
|
|
931
972
|
scheduleRenewal();
|
|
932
973
|
return {
|
|
933
974
|
ownerId,
|
|
@@ -977,6 +1018,7 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
977
1018
|
const deadline = performance.now() + EVICT_TTL + 1_000;
|
|
978
1019
|
let delayMs = 5;
|
|
979
1020
|
let removalError;
|
|
1021
|
+
let changingRecordError;
|
|
980
1022
|
for (;;) {
|
|
981
1023
|
try {
|
|
982
1024
|
let removalConfirmed = false;
|
|
@@ -1004,6 +1046,7 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
1004
1046
|
await removeLeaseObject(lockPath);
|
|
1005
1047
|
removalConfirmed = true;
|
|
1006
1048
|
}, deadline);
|
|
1049
|
+
changingRecordError = undefined;
|
|
1007
1050
|
if (markerAcquired) {
|
|
1008
1051
|
if (windowsPrivateFiles && !removalConfirmed)
|
|
1009
1052
|
throw new PrivateFileError(lockPath, 'release-not-confirmed', {
|
|
@@ -1017,15 +1060,27 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
1017
1060
|
await recoverStaleEvictionMarker(deadline);
|
|
1018
1061
|
}
|
|
1019
1062
|
catch (error) {
|
|
1020
|
-
|
|
1063
|
+
const changingRecord = windowsPrivateFiles &&
|
|
1064
|
+
(isChangingLockCreate(error) ||
|
|
1065
|
+
isWindowsAccessDeniedRead(error, [
|
|
1066
|
+
lockPath,
|
|
1067
|
+
legacyOwnerPath,
|
|
1068
|
+
evictPath,
|
|
1069
|
+
evictOwnerPath,
|
|
1070
|
+
]));
|
|
1071
|
+
if (!isRetryableRemoval(error, lockPath) && !changingRecord) {
|
|
1021
1072
|
if (windowsPrivateFiles)
|
|
1022
1073
|
throw error;
|
|
1023
1074
|
return;
|
|
1024
1075
|
}
|
|
1025
|
-
//
|
|
1026
|
-
//
|
|
1027
|
-
//
|
|
1028
|
-
|
|
1076
|
+
// Neither a refused delete nor an ambiguous record read or create
|
|
1077
|
+
// establishes loss or expiry. Back off under the release deadline and
|
|
1078
|
+
// re-confirm ownership before any removal; keep the original error
|
|
1079
|
+
// if the refusal persists.
|
|
1080
|
+
if (changingRecord)
|
|
1081
|
+
changingRecordError ??= error;
|
|
1082
|
+
else
|
|
1083
|
+
removalError ??= error;
|
|
1029
1084
|
}
|
|
1030
1085
|
const remainingMs = deadline - performance.now();
|
|
1031
1086
|
if (remainingMs <= 0)
|
|
@@ -1038,7 +1093,8 @@ export async function acquireRefreshFileLockWithClock(options) {
|
|
|
1038
1093
|
// Do not delete by pathname without the marker: bounded retries leave the
|
|
1039
1094
|
// lease to expire rather than risking removal of a successor's lock.
|
|
1040
1095
|
if (windowsPrivateFiles)
|
|
1041
|
-
throw (
|
|
1096
|
+
throw (changingRecordError ??
|
|
1097
|
+
removalError ??
|
|
1042
1098
|
new PrivateFileError(lockPath, 'release-not-confirmed', {
|
|
1043
1099
|
code: 'ETIMEDOUT',
|
|
1044
1100
|
}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, resolve } from 'node:path';
|
|
2
|
-
import {
|
|
2
|
+
import { isWindowsAccessDeniedCreate, isWindowsAccessDeniedRead, } from './lock-record.js';
|
|
3
|
+
import { isWindowsSharingViolation, windowsPrivateFiles, } from './private-files.js';
|
|
3
4
|
import { acquireRefreshFileLock } from './refresh-file-lock.js';
|
|
4
5
|
export function lockPathFor(target, name) {
|
|
5
6
|
return `${target}.${name}.lock`;
|
|
@@ -20,19 +21,23 @@ export class LockOwnershipError extends Error {
|
|
|
20
21
|
this.details = details;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
if (!isWindowsSharingViolation(error) ||
|
|
25
|
-
(error.stage !== 'read' && error.stage !== 'verify'))
|
|
26
|
-
return false;
|
|
24
|
+
function isChangingLockRecord(error, target, name) {
|
|
27
25
|
const path = resolve(lockPathFor(target, name));
|
|
28
|
-
|
|
26
|
+
const paths = [path, join(path, 'owner.json')];
|
|
27
|
+
return (((isWindowsSharingViolation(error) ||
|
|
28
|
+
isWindowsAccessDeniedRead(error, paths)) &&
|
|
29
|
+
(error.stage === 'read' || error.stage === 'verify') &&
|
|
30
|
+
paths.includes(error.path)) ||
|
|
31
|
+
(windowsPrivateFiles &&
|
|
32
|
+
(isWindowsAccessDeniedCreate(error, [path], 'create') ||
|
|
33
|
+
isWindowsAccessDeniedCreate(error, [`${path}.evicting`], 'directory-create'))));
|
|
29
34
|
}
|
|
30
35
|
export async function withLock(target, options, fn) {
|
|
31
36
|
const started = performance.now();
|
|
37
|
+
let changingRecordError;
|
|
32
38
|
for (;;) {
|
|
33
39
|
options.signal?.throwIfAborted();
|
|
34
40
|
let lock;
|
|
35
|
-
let changingReadError;
|
|
36
41
|
try {
|
|
37
42
|
lock = await acquireRefreshFileLock({
|
|
38
43
|
path: target,
|
|
@@ -44,14 +49,15 @@ export async function withLock(target, options, fn) {
|
|
|
44
49
|
? { onRenewalTimer: options.onRenewalTimer }
|
|
45
50
|
: {}),
|
|
46
51
|
});
|
|
52
|
+
changingRecordError = undefined;
|
|
47
53
|
}
|
|
48
54
|
catch (error) {
|
|
49
|
-
if (!
|
|
55
|
+
if (!isChangingLockRecord(error, target, options.name))
|
|
50
56
|
throw error;
|
|
51
|
-
//
|
|
52
|
-
//
|
|
57
|
+
// Ambiguous reads or creates reveal neither ownership nor expiry. Retry
|
|
58
|
+
// exclusive creation within the same deadline, never infer staleness from IO.
|
|
53
59
|
lock = null;
|
|
54
|
-
|
|
60
|
+
changingRecordError ??= error;
|
|
55
61
|
}
|
|
56
62
|
if (lock) {
|
|
57
63
|
try {
|
|
@@ -65,8 +71,8 @@ export async function withLock(target, options, fn) {
|
|
|
65
71
|
const remaining = options.timeoutMs - (performance.now() - started);
|
|
66
72
|
if (remaining <= 0) {
|
|
67
73
|
// Keep persistent native IO failures distinguishable from a live holder.
|
|
68
|
-
if (
|
|
69
|
-
throw
|
|
74
|
+
if (changingRecordError)
|
|
75
|
+
throw changingRecordError;
|
|
70
76
|
throw new LockContentionError({
|
|
71
77
|
target,
|
|
72
78
|
name: options.name,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@cortexkit/common-auth",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.43.0",
|
|
5
5
|
"artifactStatus": "published",
|
|
6
6
|
"publicRoots": {
|
|
7
7
|
"./store": {
|
|
@@ -37,15 +37,15 @@
|
|
|
37
37
|
"import": "./dist/pi-slot/index.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.
|
|
41
|
-
"tarballSha256": "
|
|
42
|
-
"sri": "sha512-
|
|
43
|
-
"canonicalFiles":
|
|
44
|
-
"canonicalBytes":
|
|
40
|
+
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.43.0.tgz",
|
|
41
|
+
"tarballSha256": "f2c384c880b08859ac3f0cca3575cedfcdcd47e6e96dd8f72dc78af1fe6a7620",
|
|
42
|
+
"sri": "sha512-J0vA1VHliTdDhBghn/G5oR6oRcm5sA0ScL/6ghwqMEsQjlSZ5K8q40vYVbW15gZcw69hcmVuA6Gbq1/26yKR4A==",
|
|
43
|
+
"canonicalFiles": 154,
|
|
44
|
+
"canonicalBytes": 1052730,
|
|
45
45
|
"generator": {
|
|
46
46
|
"path": "packages/opencode/scripts/embed-common-auth.ts",
|
|
47
47
|
"version": 4,
|
|
48
|
-
"sha256": "
|
|
48
|
+
"sha256": "aeda85685b8cd9c84862f722acdd650e0526db6cd56c539ef3c17f19fd0bf5c6"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
{
|
|
@@ -211,17 +211,17 @@
|
|
|
211
211
|
{
|
|
212
212
|
"source": "package/dist/claustrum/availability.d.ts",
|
|
213
213
|
"output": "claustrum/availability.d.ts",
|
|
214
|
-
"bytes":
|
|
215
|
-
"sourceSha256": "
|
|
216
|
-
"outputSha256": "
|
|
214
|
+
"bytes": 3781,
|
|
215
|
+
"sourceSha256": "3f87160823d131bf6e60e0bfd2398f10f3799ce45912c5480b327b59892b7157",
|
|
216
|
+
"outputSha256": "3f87160823d131bf6e60e0bfd2398f10f3799ce45912c5480b327b59892b7157",
|
|
217
217
|
"transform": "verbatim"
|
|
218
218
|
},
|
|
219
219
|
{
|
|
220
220
|
"source": "package/dist/claustrum/availability.js",
|
|
221
221
|
"output": "claustrum/availability.js",
|
|
222
|
-
"bytes":
|
|
223
|
-
"sourceSha256": "
|
|
224
|
-
"outputSha256": "
|
|
222
|
+
"bytes": 4615,
|
|
223
|
+
"sourceSha256": "11eaa35ab38ab433f249b4b11b9e284fac5ab7e785c965fe070aef8cde593089",
|
|
224
|
+
"outputSha256": "11eaa35ab38ab433f249b4b11b9e284fac5ab7e785c965fe070aef8cde593089",
|
|
225
225
|
"transform": "verbatim"
|
|
226
226
|
},
|
|
227
227
|
{
|
|
@@ -243,33 +243,33 @@
|
|
|
243
243
|
{
|
|
244
244
|
"source": "package/dist/claustrum/custody.d.ts",
|
|
245
245
|
"output": "claustrum/custody.d.ts",
|
|
246
|
-
"bytes":
|
|
247
|
-
"sourceSha256": "
|
|
248
|
-
"outputSha256": "
|
|
246
|
+
"bytes": 17862,
|
|
247
|
+
"sourceSha256": "ea33c127942652259ddf467d377da872cabfab1407339cc774c0e79ca5f83742",
|
|
248
|
+
"outputSha256": "ea33c127942652259ddf467d377da872cabfab1407339cc774c0e79ca5f83742",
|
|
249
249
|
"transform": "verbatim"
|
|
250
250
|
},
|
|
251
251
|
{
|
|
252
252
|
"source": "package/dist/claustrum/custody.js",
|
|
253
253
|
"output": "claustrum/custody.js",
|
|
254
|
-
"bytes":
|
|
255
|
-
"sourceSha256": "
|
|
256
|
-
"outputSha256": "
|
|
254
|
+
"bytes": 37468,
|
|
255
|
+
"sourceSha256": "e73ca575f9a97a20723e3371ff63be99a8cfea95bbe54ab694c298bebc30e853",
|
|
256
|
+
"outputSha256": "e73ca575f9a97a20723e3371ff63be99a8cfea95bbe54ab694c298bebc30e853",
|
|
257
257
|
"transform": "verbatim"
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
260
|
"source": "package/dist/claustrum/enrollment.d.ts",
|
|
261
261
|
"output": "claustrum/enrollment.d.ts",
|
|
262
|
-
"bytes":
|
|
263
|
-
"sourceSha256": "
|
|
264
|
-
"outputSha256": "
|
|
262
|
+
"bytes": 8990,
|
|
263
|
+
"sourceSha256": "395691b7c46020b5ab8850e1effdab1ce378312cf9f71b9b2ab613d4331a1669",
|
|
264
|
+
"outputSha256": "395691b7c46020b5ab8850e1effdab1ce378312cf9f71b9b2ab613d4331a1669",
|
|
265
265
|
"transform": "verbatim"
|
|
266
266
|
},
|
|
267
267
|
{
|
|
268
268
|
"source": "package/dist/claustrum/enrollment.js",
|
|
269
269
|
"output": "claustrum/enrollment.js",
|
|
270
|
-
"bytes":
|
|
271
|
-
"sourceSha256": "
|
|
272
|
-
"outputSha256": "
|
|
270
|
+
"bytes": 38799,
|
|
271
|
+
"sourceSha256": "3cb9bf3fae4b90b64b743a618b142047cad3a99b81b52932d0f9afc8540adad7",
|
|
272
|
+
"outputSha256": "3cb9bf3fae4b90b64b743a618b142047cad3a99b81b52932d0f9afc8540adad7",
|
|
273
273
|
"transform": "verbatim"
|
|
274
274
|
},
|
|
275
275
|
{
|
|
@@ -315,9 +315,9 @@
|
|
|
315
315
|
{
|
|
316
316
|
"source": "package/dist/claustrum/host.js",
|
|
317
317
|
"output": "claustrum/host.js",
|
|
318
|
-
"bytes":
|
|
319
|
-
"sourceSha256": "
|
|
320
|
-
"outputSha256": "
|
|
318
|
+
"bytes": 4610,
|
|
319
|
+
"sourceSha256": "c2eba15f35b996993ba7f0ec849ce84312d5f08e9b15e8f6458c6d8a0e03ae7b",
|
|
320
|
+
"outputSha256": "c2eba15f35b996993ba7f0ec849ce84312d5f08e9b15e8f6458c6d8a0e03ae7b",
|
|
321
321
|
"transform": "verbatim"
|
|
322
322
|
},
|
|
323
323
|
{
|
|
@@ -339,17 +339,17 @@
|
|
|
339
339
|
{
|
|
340
340
|
"source": "package/dist/claustrum/index.d.ts",
|
|
341
341
|
"output": "claustrum/index.d.ts",
|
|
342
|
-
"bytes":
|
|
343
|
-
"sourceSha256": "
|
|
344
|
-
"outputSha256": "
|
|
342
|
+
"bytes": 4965,
|
|
343
|
+
"sourceSha256": "6b95f03d2135a664e8960d3ba5d3fc294e4dea0cb7ca32ac183c3a3312f88a5d",
|
|
344
|
+
"outputSha256": "6b95f03d2135a664e8960d3ba5d3fc294e4dea0cb7ca32ac183c3a3312f88a5d",
|
|
345
345
|
"transform": "verbatim"
|
|
346
346
|
},
|
|
347
347
|
{
|
|
348
348
|
"source": "package/dist/claustrum/index.js",
|
|
349
349
|
"output": "claustrum/index.js",
|
|
350
|
-
"bytes":
|
|
351
|
-
"sourceSha256": "
|
|
352
|
-
"outputSha256": "
|
|
350
|
+
"bytes": 4090,
|
|
351
|
+
"sourceSha256": "57a6e23ad884e39989da2ffd8eadb1b62f744402a9d6c33bb68b25d6c329e4f0",
|
|
352
|
+
"outputSha256": "57a6e23ad884e39989da2ffd8eadb1b62f744402a9d6c33bb68b25d6c329e4f0",
|
|
353
353
|
"transform": "verbatim"
|
|
354
354
|
},
|
|
355
355
|
{
|
|
@@ -608,6 +608,14 @@
|
|
|
608
608
|
"outputSha256": "cd60090325fa8c4c17dddfc216a4ed326f2a6e48525e724a4dd260bf88041231",
|
|
609
609
|
"transform": "verbatim"
|
|
610
610
|
},
|
|
611
|
+
{
|
|
612
|
+
"source": "package/dist/fs/lock-record.js",
|
|
613
|
+
"output": "fs/lock-record.js",
|
|
614
|
+
"bytes": 2253,
|
|
615
|
+
"sourceSha256": "18468ed6c58d8a989164b566c3653dbeea0d46b3031b49bc8f23bc4028ae5ff3",
|
|
616
|
+
"outputSha256": "18468ed6c58d8a989164b566c3653dbeea0d46b3031b49bc8f23bc4028ae5ff3",
|
|
617
|
+
"transform": "verbatim"
|
|
618
|
+
},
|
|
611
619
|
{
|
|
612
620
|
"source": "package/dist/fs/private-files.d.ts",
|
|
613
621
|
"output": "fs/private-files.d.ts",
|
|
@@ -635,9 +643,9 @@
|
|
|
635
643
|
{
|
|
636
644
|
"source": "package/dist/fs/refresh-file-lock.js",
|
|
637
645
|
"output": "fs/refresh-file-lock.js",
|
|
638
|
-
"bytes":
|
|
639
|
-
"sourceSha256": "
|
|
640
|
-
"outputSha256": "
|
|
646
|
+
"bytes": 46870,
|
|
647
|
+
"sourceSha256": "fb2d2c236e468a1c38b28d2d628f5b01e246e6d34165d844b1ba8faf2f692b37",
|
|
648
|
+
"outputSha256": "fb2d2c236e468a1c38b28d2d628f5b01e246e6d34165d844b1ba8faf2f692b37",
|
|
641
649
|
"transform": "verbatim"
|
|
642
650
|
},
|
|
643
651
|
{
|
|
@@ -651,9 +659,9 @@
|
|
|
651
659
|
{
|
|
652
660
|
"source": "package/dist/fs/with-lock.js",
|
|
653
661
|
"output": "fs/with-lock.js",
|
|
654
|
-
"bytes":
|
|
655
|
-
"sourceSha256": "
|
|
656
|
-
"outputSha256": "
|
|
662
|
+
"bytes": 3278,
|
|
663
|
+
"sourceSha256": "3036b3e1cf9d80d33feebced3bdc14bbfd841ce69a8e784957be984d3c94a461",
|
|
664
|
+
"outputSha256": "3036b3e1cf9d80d33feebced3bdc14bbfd841ce69a8e784957be984d3c94a461",
|
|
657
665
|
"transform": "verbatim"
|
|
658
666
|
},
|
|
659
667
|
{
|
package/dist/model-registry.d.ts
CHANGED
|
@@ -64,5 +64,8 @@ export declare function getGemini38FlashAntigravityModel(tier?: ThinkingTier): s
|
|
|
64
64
|
export declare function getQuotaGroupForModel(modelId: string, hasArgonPool?: boolean): ModelQuotaGroup | undefined;
|
|
65
65
|
/** Recognize Argon selectors so family-specific wire and quota policy is consistent. */
|
|
66
66
|
export declare function isGeminiArgonModel(model: string): boolean;
|
|
67
|
+
/** Recognize Carbon selectors without assigning an unobserved quota pool. */
|
|
68
|
+
export declare function isGeminiCarbonModel(model: string): boolean;
|
|
69
|
+
export declare function getGeminiCarbonAntigravityModel(tier?: ThinkingTier): string;
|
|
67
70
|
export declare function getGeminiArgonAntigravityModel(tier?: ThinkingTier): string;
|
|
68
71
|
//# sourceMappingURL=model-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../src/model-registry.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