@cortexkit/opencode-antigravity-auth 3.0.15 → 3.0.16
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/cli.js +257 -57
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +8 -8
- package/dist/index.js +257 -57
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +8 -8
- package/dist/server.js +257 -57
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/plugin/storage.d.ts +17 -0
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +44 -10
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/runtime-paths.d.ts +2 -1
- package/dist/src/runtime-paths.d.ts.map +1 -1
- package/dist/src/runtime-paths.js +5 -5
- package/dist/src/runtime-paths.js.map +1 -1
- package/dist/types/src/plugin/storage.d.ts +17 -0
- package/dist/types/src/plugin/storage.d.ts.map +1 -1
- package/dist/types/src/runtime-paths.d.ts +2 -1
- package/dist/types/src/runtime-paths.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -14634,14 +14634,52 @@ function decodeAccountStorePointer(value, legacyPath) {
|
|
|
14634
14634
|
throw new AccountMigrationError("pointer directory basename differs from its derived generation");
|
|
14635
14635
|
return { schemaVersion: 1, id, directoryBasename: basename(paths.storeDir) };
|
|
14636
14636
|
}
|
|
14637
|
-
|
|
14637
|
+
function decodeAccountStorePointerRecord(value, legacyPath) {
|
|
14638
|
+
if (object(value, "pointer").schemaVersion !== 2)
|
|
14639
|
+
return decodeAccountStorePointer(value, legacyPath);
|
|
14640
|
+
const raw = exact(value, ["schemaVersion", "id", "directoryBasename", "relocatedTo"], "forward");
|
|
14641
|
+
const id = text(raw.id, UUID, "forward source generation");
|
|
14642
|
+
const paths = generationPaths(legacyPath, id);
|
|
14643
|
+
if (raw.directoryBasename !== basename(paths.storeDir))
|
|
14644
|
+
throw new AccountMigrationError("forward directory basename differs from its derived generation");
|
|
14645
|
+
const target = exact(raw.relocatedTo, ["legacyPath", "id"], "forward target");
|
|
14646
|
+
if (typeof target.legacyPath !== "string")
|
|
14647
|
+
throw new AccountMigrationError("forward target path is invalid");
|
|
14648
|
+
const targetId = text(target.id, UUID, "forward target generation");
|
|
14649
|
+
const targetPaths = generationPaths(target.legacyPath, targetId);
|
|
14650
|
+
if (sameFilesystemPath(targetPaths.legacyPath, legacyPath))
|
|
14651
|
+
throw new AccountMigrationError("forward names its own anchor");
|
|
14652
|
+
return {
|
|
14653
|
+
schemaVersion: 2,
|
|
14654
|
+
id,
|
|
14655
|
+
directoryBasename: basename(paths.storeDir),
|
|
14656
|
+
relocatedTo: {
|
|
14657
|
+
legacyPath: targetPaths.legacyPath,
|
|
14658
|
+
id: targetId
|
|
14659
|
+
}
|
|
14660
|
+
};
|
|
14661
|
+
}
|
|
14662
|
+
async function readPointerRecord(legacyPath) {
|
|
14638
14663
|
const logical = resolveAccountStorePaths(legacyPath);
|
|
14639
14664
|
if (await exists(logical.storeDir))
|
|
14640
14665
|
throw new AccountMigrationError("foreign logical store directory is not pointer authority");
|
|
14641
14666
|
const path2 = accountStorePointerPath(legacyPath);
|
|
14642
14667
|
if (!await exists(path2))
|
|
14643
14668
|
return void 0;
|
|
14644
|
-
return
|
|
14669
|
+
return decodeAccountStorePointerRecord(jsonBytes(await secureRead(path2)), legacyPath);
|
|
14670
|
+
}
|
|
14671
|
+
async function readPointer(legacyPath) {
|
|
14672
|
+
const record3 = await readPointerRecord(legacyPath);
|
|
14673
|
+
if (record3?.schemaVersion === 2)
|
|
14674
|
+
throw new AccountMigrationError(`the account store moved to ${record3.relocatedTo.legacyPath}; this operation does not follow a moved store`);
|
|
14675
|
+
return record3;
|
|
14676
|
+
}
|
|
14677
|
+
async function forwardTarget(legacyPath, forward) {
|
|
14678
|
+
const target = forward.relocatedTo.legacyPath;
|
|
14679
|
+
const published = await readPointerRecord(target);
|
|
14680
|
+
if (published?.schemaVersion !== 1 || published.id !== forward.relocatedTo.id)
|
|
14681
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(legacyPath)} names generation ${forward.relocatedTo.id}, which ${accountStorePointerPath(target)} does not publish`);
|
|
14682
|
+
return target;
|
|
14645
14683
|
}
|
|
14646
14684
|
async function resolvePublishedAccountStorePaths(legacyPath) {
|
|
14647
14685
|
const pointer = await readPointer(legacyPath);
|
|
@@ -14897,7 +14935,7 @@ function decodeAccountStoreGeneration(value) {
|
|
|
14897
14935
|
"sourceKind",
|
|
14898
14936
|
"initialManifestSha256"
|
|
14899
14937
|
], "generation");
|
|
14900
|
-
if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent")
|
|
14938
|
+
if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent" && raw.sourceKind !== "generation")
|
|
14901
14939
|
throw new AccountMigrationError("generation schema is invalid");
|
|
14902
14940
|
const id = text(raw.id, UUID, "generation id");
|
|
14903
14941
|
const paths = generationPaths(raw.legacyPath, id);
|
|
@@ -14996,7 +15034,8 @@ function decodeAccountMigrationJournal(value) {
|
|
|
14996
15034
|
"verification",
|
|
14997
15035
|
"retiredSha256",
|
|
14998
15036
|
"rollback",
|
|
14999
|
-
"cancelled"
|
|
15037
|
+
"cancelled",
|
|
15038
|
+
"relocation"
|
|
15000
15039
|
], "journal");
|
|
15001
15040
|
if (raw.schemaVersion !== 1)
|
|
15002
15041
|
throw new AccountMigrationError("unsupported journal schema");
|
|
@@ -15016,10 +15055,10 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15016
15055
|
if (phase === void 0)
|
|
15017
15056
|
throw new AccountMigrationError("journal phase is invalid");
|
|
15018
15057
|
const sourceKind = raw.sourceKind;
|
|
15019
|
-
if (sourceKind !== "file" && sourceKind !== "absent")
|
|
15058
|
+
if (sourceKind !== "file" && sourceKind !== "absent" && sourceKind !== "generation")
|
|
15020
15059
|
throw new AccountMigrationError("journal source kind is invalid");
|
|
15021
|
-
const sourceSha256 = sourceKind
|
|
15022
|
-
const captureSha256 = sourceKind
|
|
15060
|
+
const sourceSha256 = sourceKind !== "absent" ? text(raw.sourceSha256, SHA256, "journal.sourceSha256") : void 0;
|
|
15061
|
+
const captureSha256 = sourceKind !== "absent" ? text(raw.captureSha256, SHA256, "journal.captureSha256") : void 0;
|
|
15023
15062
|
if (sourceKind === "absent" && Object.hasOwn(raw, "captureSha256"))
|
|
15024
15063
|
throw new AccountMigrationError("absent source cannot claim a captured file snapshot");
|
|
15025
15064
|
if (sourceKind === "absent" && Object.hasOwn(raw, "sourceSha256"))
|
|
@@ -15036,7 +15075,7 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15036
15075
|
const sourceVersion = m.sourceVersion;
|
|
15037
15076
|
if (sourceVersion !== null && sourceVersion !== 1 && sourceVersion !== 2 && sourceVersion !== 3 && sourceVersion !== 4)
|
|
15038
15077
|
throw new AccountMigrationError("manifest source version is invalid");
|
|
15039
|
-
if (sourceKind === "file" && sourceVersion === null || sourceKind
|
|
15078
|
+
if (sourceKind === "file" && sourceVersion === null || sourceKind !== "file" && sourceVersion !== null)
|
|
15040
15079
|
throw new AccountMigrationError("manifest version differs from source kind");
|
|
15041
15080
|
if (!finite(m.normalizationClock) || !finite(m.effectiveActiveIndex))
|
|
15042
15081
|
throw new AccountMigrationError("manifest clock or cursor is invalid");
|
|
@@ -15066,6 +15105,10 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15066
15105
|
schemaVersion: 1
|
|
15067
15106
|
}) || manifest.effectiveActiveIndex !== 0))
|
|
15068
15107
|
throw new AccountMigrationError("absent-source manifest must be explicitly empty with no invented cursors");
|
|
15108
|
+
if (sourceKind === "generation" && (accounts.length || !isDeepStrictEqual(encodeRoutingSettings(manifest.routing), {
|
|
15109
|
+
schemaVersion: 1
|
|
15110
|
+
}) || manifest.effectiveActiveIndex !== 0))
|
|
15111
|
+
throw new AccountMigrationError("moved-store manifest must be explicitly empty");
|
|
15069
15112
|
const effective = accounts.length ? Math.max(0, Math.min(manifest.routing.activeIndex ?? 0, accounts.length - 1)) : 0;
|
|
15070
15113
|
if (effective !== manifest.effectiveActiveIndex)
|
|
15071
15114
|
throw new AccountMigrationError("manifest effective cursor differs");
|
|
@@ -15113,6 +15156,24 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15113
15156
|
throw new AccountMigrationError("absent source cannot claim retired bytes");
|
|
15114
15157
|
if (retiredSha256 !== void 0 && retiredSha256 !== sourceSha256)
|
|
15115
15158
|
throw new AccountMigrationError("retired bytes are not associated with source");
|
|
15159
|
+
const relocation = decodeRelocation(raw, sourceKind, paths.legacyPath);
|
|
15160
|
+
if (sourceKind === "generation") {
|
|
15161
|
+
if (retiredSha256 !== void 0)
|
|
15162
|
+
throw new AccountMigrationError("moved source cannot claim retired pool-file bytes");
|
|
15163
|
+
if (relocation === void 0)
|
|
15164
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15165
|
+
if (operation === "rollback")
|
|
15166
|
+
throw new AccountMigrationError("a moved account store is not rolled back; move it back first with `antigravity-auth store relocate --back --offline`");
|
|
15167
|
+
if (relocation.sourceForwarded && !relocation.sourceTombstoned)
|
|
15168
|
+
throw new AccountMigrationError("source forward precedes its management tombstone");
|
|
15169
|
+
if ((relocation.sourceTombstoned || relocation.sourceForwarded) && (!verification || phase !== "retire" && phase !== "activate"))
|
|
15170
|
+
throw new AccountMigrationError("source tombstone or forward precedes durable verification");
|
|
15171
|
+
if (status === "active" && !relocation.sourceForwarded)
|
|
15172
|
+
throw new AccountMigrationError("active moved store lacks its source forward");
|
|
15173
|
+
if (phase === "activate" && !relocation.sourceForwarded)
|
|
15174
|
+
throw new AccountMigrationError("moved-store activation lacks its source forward");
|
|
15175
|
+
}
|
|
15176
|
+
const retirementRecorded = sourceKind === "file" ? retiredSha256 !== void 0 : sourceKind === "absent" ? raw.sourceAbsenceVerified === true : relocation?.sourceForwarded === true;
|
|
15116
15177
|
let rollback;
|
|
15117
15178
|
if (Object.hasOwn(raw, "rollback")) {
|
|
15118
15179
|
const r = exact(raw.rollback, ["id", "snapshotSha256", "exportSha256", "rows", "successorInactive"], "rollback");
|
|
@@ -15138,13 +15199,13 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15138
15199
|
throw new AccountMigrationError("verification acknowledged an incomplete import");
|
|
15139
15200
|
if (operation === "migrate" && (retiredSha256 !== void 0 || raw.sourceAbsenceVerified === true) && (!verification || phase !== "retire" && phase !== "activate"))
|
|
15140
15201
|
throw new AccountMigrationError("retirement association precedes durable verification");
|
|
15141
|
-
if (operation === "migrate" && phase === "activate" &&
|
|
15202
|
+
if (operation === "migrate" && phase === "activate" && !retirementRecorded)
|
|
15142
15203
|
throw new AccountMigrationError("activation lacks its actual source retirement association");
|
|
15143
|
-
if (status === "active" && (operation !== "migrate" || phase !== "activate" ||
|
|
15204
|
+
if (status === "active" && (operation !== "migrate" || phase !== "activate" || !retirementRecorded || rollback !== void 0 || cancelled))
|
|
15144
15205
|
throw new AccountMigrationError("active receipt is incomplete");
|
|
15145
15206
|
if (operation === "rollback" && rollback === void 0 && !cancelled)
|
|
15146
15207
|
throw new AccountMigrationError("rollback lacks its current-credential snapshot");
|
|
15147
|
-
if (operation === "rollback" && !cancelled && (verification === void 0 ||
|
|
15208
|
+
if (operation === "rollback" && !cancelled && (verification === void 0 || !retirementRecorded))
|
|
15148
15209
|
throw new AccountMigrationError("rollback lacks the original verified retirement");
|
|
15149
15210
|
if (status === "inactive" && !cancelled && (operation !== "rollback" || phase !== "activate" || rollback === void 0))
|
|
15150
15211
|
throw new AccountMigrationError("inactive receipt lacks a completed rollback");
|
|
@@ -15168,7 +15229,53 @@ function decodeAccountMigrationJournal(value) {
|
|
|
15168
15229
|
...verification === void 0 ? {} : { verification },
|
|
15169
15230
|
...retiredSha256 === void 0 ? {} : { retiredSha256 },
|
|
15170
15231
|
...rollback === void 0 ? {} : { rollback },
|
|
15171
|
-
...cancelled ? { cancelled: true } : {}
|
|
15232
|
+
...cancelled ? { cancelled: true } : {},
|
|
15233
|
+
...relocation === void 0 ? {} : { relocation }
|
|
15234
|
+
};
|
|
15235
|
+
}
|
|
15236
|
+
function decodeRelocation(raw, sourceKind, legacyPath) {
|
|
15237
|
+
if (!Object.hasOwn(raw, "relocation"))
|
|
15238
|
+
return void 0;
|
|
15239
|
+
if (sourceKind !== "generation")
|
|
15240
|
+
throw new AccountMigrationError("only a moved store records relocation evidence");
|
|
15241
|
+
const r = exact(raw.relocation, ["source", "rows", "sourceTombstoned", "sourceForwarded"], "relocation");
|
|
15242
|
+
const s = exact(r.source, [
|
|
15243
|
+
"legacyPath",
|
|
15244
|
+
"storeDir",
|
|
15245
|
+
"journalId",
|
|
15246
|
+
"configSha256",
|
|
15247
|
+
"stateSha256",
|
|
15248
|
+
"statePresent"
|
|
15249
|
+
], "relocation source");
|
|
15250
|
+
if (typeof s.legacyPath !== "string")
|
|
15251
|
+
throw new AccountMigrationError("relocation source path is invalid");
|
|
15252
|
+
const journalId = text(s.journalId, UUID, "relocation source journal");
|
|
15253
|
+
const source = generationPaths(s.legacyPath, journalId);
|
|
15254
|
+
if (s.storeDir !== source.storeDir)
|
|
15255
|
+
throw new AccountMigrationError("relocation source association differs");
|
|
15256
|
+
if (sameFilesystemPath(source.legacyPath, legacyPath))
|
|
15257
|
+
throw new AccountMigrationError("relocation source and target share one anchor");
|
|
15258
|
+
if (typeof s.statePresent !== "boolean")
|
|
15259
|
+
throw new AccountMigrationError("relocation state presence is invalid");
|
|
15260
|
+
if (!s.statePresent && Object.hasOwn(s, "stateSha256"))
|
|
15261
|
+
throw new AccountMigrationError("absent source state cannot claim a file hash");
|
|
15262
|
+
const rows = list(r.rows, "relocation rows").map((id) => text(id, UUID, "relocation row id"));
|
|
15263
|
+
if (new Set(rows).size !== rows.length)
|
|
15264
|
+
throw new AccountMigrationError("relocation rows are duplicated");
|
|
15265
|
+
if (typeof r.sourceTombstoned !== "boolean" || typeof r.sourceForwarded !== "boolean")
|
|
15266
|
+
throw new AccountMigrationError("relocation progress flags are invalid");
|
|
15267
|
+
return {
|
|
15268
|
+
source: {
|
|
15269
|
+
legacyPath: source.legacyPath,
|
|
15270
|
+
storeDir: source.storeDir,
|
|
15271
|
+
journalId,
|
|
15272
|
+
configSha256: text(s.configSha256, SHA256, "relocation config hash"),
|
|
15273
|
+
...s.statePresent ? { stateSha256: text(s.stateSha256, SHA256, "relocation state hash") } : {},
|
|
15274
|
+
statePresent: s.statePresent
|
|
15275
|
+
},
|
|
15276
|
+
rows,
|
|
15277
|
+
sourceTombstoned: r.sourceTombstoned,
|
|
15278
|
+
sourceForwarded: r.sourceForwarded
|
|
15172
15279
|
};
|
|
15173
15280
|
}
|
|
15174
15281
|
function pendingLockFailure(modules, error) {
|
|
@@ -15458,6 +15565,8 @@ async function verifyCopies(paths, journal, retired) {
|
|
|
15458
15565
|
const capture2 = await secureRead(join(paths.transfersDir, `${journal.id}.capture.json`));
|
|
15459
15566
|
if (digest(capture2) !== journal.captureSha256 || !isDeepStrictEqual(jsonBytes(capture2), captureJson(journal)))
|
|
15460
15567
|
throw new AccountMigrationError("journal differs from its exclusive capture snapshot");
|
|
15568
|
+
if (journal.sourceKind === "generation")
|
|
15569
|
+
return verifyRelocationSnapshot(backup, journal);
|
|
15461
15570
|
const expected = parseLegacyAccountStorage(new TextDecoder("utf-8", { fatal: true }).decode(backup), journal.manifest.normalizationClock);
|
|
15462
15571
|
if (!isDeepStrictEqual(manifestJson(expected), manifestJson(journal.manifest)))
|
|
15463
15572
|
throw new AccountMigrationError("captured manifest differs from its verified original source");
|
|
@@ -15476,9 +15585,40 @@ function captureJson(journal) {
|
|
|
15476
15585
|
sourceKind: journal.sourceKind,
|
|
15477
15586
|
sourceSha256: journal.sourceSha256,
|
|
15478
15587
|
manifest: manifestJson(journal.manifest),
|
|
15479
|
-
mapping: journal.mapping
|
|
15588
|
+
mapping: journal.mapping,
|
|
15589
|
+
...journal.relocation === void 0 ? {} : { relocation: { source: journal.relocation.source } }
|
|
15590
|
+
};
|
|
15591
|
+
}
|
|
15592
|
+
function base64Bytes(value, path2) {
|
|
15593
|
+
if (typeof value !== "string")
|
|
15594
|
+
throw new AccountMigrationError(`${path2} is invalid`);
|
|
15595
|
+
const bytes = Buffer.from(value, "base64");
|
|
15596
|
+
if (bytes.toString("base64") !== value)
|
|
15597
|
+
throw new AccountMigrationError(`${path2} is not canonical base64`);
|
|
15598
|
+
return bytes;
|
|
15599
|
+
}
|
|
15600
|
+
function decodeRelocationSnapshot(value) {
|
|
15601
|
+
const raw = exact(value, ["config", "state", "journal"], "moved snapshot");
|
|
15602
|
+
return {
|
|
15603
|
+
config: base64Bytes(raw.config, "moved snapshot config"),
|
|
15604
|
+
...Object.hasOwn(raw, "state") ? { state: base64Bytes(raw.state, "moved snapshot state") } : {},
|
|
15605
|
+
journal: base64Bytes(raw.journal, "moved snapshot journal")
|
|
15480
15606
|
};
|
|
15481
15607
|
}
|
|
15608
|
+
function verifyRelocationSnapshot(backup, journal) {
|
|
15609
|
+
const source = journal.relocation?.source;
|
|
15610
|
+
if (source === void 0)
|
|
15611
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15612
|
+
const snapshot2 = decodeRelocationSnapshot(jsonBytes(backup));
|
|
15613
|
+
if (digest(snapshot2.config) !== source.configSha256 || snapshot2.state !== void 0 !== source.statePresent || snapshot2.state !== void 0 && digest(snapshot2.state) !== source.stateSha256)
|
|
15614
|
+
throw new AccountMigrationError("moved source snapshot differs from its recorded hashes");
|
|
15615
|
+
const copied = decodeAccountMigrationJournal(jsonBytes(snapshot2.journal));
|
|
15616
|
+
if (copied.id !== source.journalId || copied.legacyPath !== source.legacyPath || copied.storeDir !== source.storeDir || copied.status !== "active")
|
|
15617
|
+
throw new AccountMigrationError("moved source snapshot is not the active source generation");
|
|
15618
|
+
const config = object(jsonBytes(snapshot2.config), "moved source config");
|
|
15619
|
+
if (!isDeepStrictEqual(decodeAccountStoreGeneration(config[ACCOUNT_STORE_GENERATION_SETTINGS_KEY]), generationJson(copied)))
|
|
15620
|
+
throw new AccountMigrationError("moved source snapshot belongs to another generation");
|
|
15621
|
+
}
|
|
15482
15622
|
async function synchronizedSnapshot(paths, boundary) {
|
|
15483
15623
|
await syncFile(paths.configPath);
|
|
15484
15624
|
const statePresent = await exists(paths.statePath);
|
|
@@ -15550,7 +15690,7 @@ function receipt(journal) {
|
|
|
15550
15690
|
storeDir: journal.storeDir,
|
|
15551
15691
|
sourceKind: journal.sourceKind,
|
|
15552
15692
|
durability: journal.verification?.durability ?? accountMigrationDurability(),
|
|
15553
|
-
restartRequired: journal.sourceKind
|
|
15693
|
+
restartRequired: journal.sourceKind !== "absent" || journal.operation === "rollback"
|
|
15554
15694
|
};
|
|
15555
15695
|
}
|
|
15556
15696
|
async function currentSuccessor(store, paths, journal) {
|
|
@@ -15634,35 +15774,13 @@ async function trustedCurrentGeneration(store, paths, journal) {
|
|
|
15634
15774
|
}
|
|
15635
15775
|
async function readAccountStoreBinding(legacyPath, modules, now, expectedGeneration) {
|
|
15636
15776
|
try {
|
|
15637
|
-
const
|
|
15638
|
-
if (
|
|
15639
|
-
|
|
15640
|
-
|
|
15641
|
-
|
|
15642
|
-
throw new AccountMigrationError("published binding journal missing");
|
|
15643
|
-
if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
|
|
15644
|
-
throw new AccountMigrationError("bound repository generation differs from pointer");
|
|
15645
|
-
if (journal.status === "pending")
|
|
15646
|
-
return {
|
|
15647
|
-
status: "pending",
|
|
15648
|
-
phase: journal.phase,
|
|
15649
|
-
operation: journal.operation
|
|
15650
|
-
};
|
|
15651
|
-
if (journal.status === "inactive")
|
|
15652
|
-
return { status: "inactive", id: journal.id };
|
|
15653
|
-
if (await exists(legacyPath))
|
|
15654
|
-
throw new AccountMigrationError("legacy source was recreated after activation");
|
|
15655
|
-
await verifyCopies(paths, journal, true);
|
|
15656
|
-
const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
|
|
15657
|
-
const pending = settings[MANAGEMENT_SETTINGS_KEY];
|
|
15658
|
-
if (pending !== void 0) {
|
|
15659
|
-
const record3 = object(pending, "repository management");
|
|
15660
|
-
if (record3.kind === "migration")
|
|
15661
|
-
return { status: "pending", phase: "activate", operation: "migrate" };
|
|
15662
|
-
if (record3.kind !== "clear" && record3.kind !== "replace-pool")
|
|
15663
|
-
throw new AccountMigrationError("unknown management owner prevents binding");
|
|
15777
|
+
const record3 = await readPointerRecord(legacyPath);
|
|
15778
|
+
if (record3?.schemaVersion === 2) {
|
|
15779
|
+
if (await exists(legacyPath))
|
|
15780
|
+
throw new AccountMigrationError(`a pool file reappeared at ${legacyPath} after the account store moved to ${record3.relocatedTo.legacyPath}`);
|
|
15781
|
+
return await bindPublishedGeneration(await forwardTarget(legacyPath, record3), modules, now, expectedGeneration, legacyPath);
|
|
15664
15782
|
}
|
|
15665
|
-
return
|
|
15783
|
+
return await bindPublishedGeneration(legacyPath, modules, now, expectedGeneration);
|
|
15666
15784
|
} catch (error) {
|
|
15667
15785
|
return {
|
|
15668
15786
|
status: "error",
|
|
@@ -15670,6 +15788,65 @@ async function readAccountStoreBinding(legacyPath, modules, now, expectedGenerat
|
|
|
15670
15788
|
};
|
|
15671
15789
|
}
|
|
15672
15790
|
}
|
|
15791
|
+
async function assertSourceForwarded(journal, forwardedFrom) {
|
|
15792
|
+
const source = journal.relocation?.source;
|
|
15793
|
+
if (source === void 0)
|
|
15794
|
+
throw new AccountMigrationError("moved source lacks its relocation evidence");
|
|
15795
|
+
const pointer = accountStorePointerPath(source.legacyPath);
|
|
15796
|
+
if (forwardedFrom !== void 0 && forwardedFrom !== source.legacyPath)
|
|
15797
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store moved from ${source.legacyPath}`);
|
|
15798
|
+
if (await exists(source.legacyPath))
|
|
15799
|
+
throw new AccountMigrationError(`a pool file reappeared at ${source.legacyPath} after the account store moved to ${journal.legacyPath}`);
|
|
15800
|
+
const record3 = await readPointerRecord(source.legacyPath);
|
|
15801
|
+
if (record3 === void 0)
|
|
15802
|
+
throw new AccountMigrationError(`the forwarding pointer ${pointer} to the moved account store at ${journal.storeDir} is missing; restore it`);
|
|
15803
|
+
if (record3.schemaVersion === 1)
|
|
15804
|
+
throw new AccountMigrationError(`the account store in ${dirname(source.legacyPath)} was reactivated: ${pointer} publishes generation ${record3.id} while the moved store at ${journal.storeDir} is active; restore the forwarding pointer, or run \`antigravity-auth store relocate\``);
|
|
15805
|
+
if (record3.id !== source.journalId || record3.relocatedTo.legacyPath !== journal.legacyPath || record3.relocatedTo.id !== journal.id)
|
|
15806
|
+
throw new AccountMigrationError(`the forwarding pointer ${pointer} names another store than the moved account store at ${journal.storeDir}`);
|
|
15807
|
+
}
|
|
15808
|
+
async function bindPublishedGeneration(legacyPath, modules, now, expectedGeneration, forwardedFrom) {
|
|
15809
|
+
const paths = await resolvePublishedAccountStorePaths(legacyPath);
|
|
15810
|
+
if (!paths) {
|
|
15811
|
+
if (forwardedFrom !== void 0)
|
|
15812
|
+
throw new AccountMigrationError("forwarded anchor publishes no generation");
|
|
15813
|
+
return await exists(legacyPath) ? { status: "pending" } : { status: "initialization-required" };
|
|
15814
|
+
}
|
|
15815
|
+
const journal = await readJournal(paths);
|
|
15816
|
+
if (!journal)
|
|
15817
|
+
throw new AccountMigrationError("published binding journal missing");
|
|
15818
|
+
if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
|
|
15819
|
+
throw new AccountMigrationError("bound repository generation differs from pointer");
|
|
15820
|
+
if (forwardedFrom !== void 0 && journal.sourceKind !== "generation")
|
|
15821
|
+
throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store that was not moved there`);
|
|
15822
|
+
if (journal.sourceKind === "generation" && journal.status === "pending")
|
|
15823
|
+
throw new AccountMigrationError(`a move of the account store to ${journal.storeDir} is unfinished; finish it with the version that started it`);
|
|
15824
|
+
if (journal.status === "pending")
|
|
15825
|
+
return {
|
|
15826
|
+
status: "pending",
|
|
15827
|
+
phase: journal.phase,
|
|
15828
|
+
operation: journal.operation
|
|
15829
|
+
};
|
|
15830
|
+
if (journal.status === "inactive")
|
|
15831
|
+
return { status: "inactive", id: journal.id };
|
|
15832
|
+
if (await exists(legacyPath))
|
|
15833
|
+
throw new AccountMigrationError("legacy source was recreated after activation");
|
|
15834
|
+
await verifyCopies(paths, journal, true);
|
|
15835
|
+
if (journal.sourceKind === "generation")
|
|
15836
|
+
await assertSourceForwarded(journal, forwardedFrom);
|
|
15837
|
+
const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
|
|
15838
|
+
const pending = settings[MANAGEMENT_SETTINGS_KEY];
|
|
15839
|
+
if (pending !== void 0) {
|
|
15840
|
+
const record3 = object(pending, "repository management");
|
|
15841
|
+
if (record3.kind === "migration" && record3.id !== journal.id)
|
|
15842
|
+
throw new AccountMigrationError(`the account store at ${paths.storeDir} was moved to generation ${String(record3.id)}, but ${accountStorePointerPath(legacyPath)} publishes the old store again; restore the forwarding pointer, or run \`antigravity-auth store relocate\``);
|
|
15843
|
+
if (record3.kind === "migration")
|
|
15844
|
+
return { status: "pending", phase: "activate", operation: "migrate" };
|
|
15845
|
+
if (record3.kind !== "clear" && record3.kind !== "replace-pool")
|
|
15846
|
+
throw new AccountMigrationError("unknown management owner prevents binding");
|
|
15847
|
+
}
|
|
15848
|
+
return { status: "bound", receipt: receipt(journal), paths };
|
|
15849
|
+
}
|
|
15673
15850
|
async function readAccountStoreAdmission(legacyPath, modules, now, expectedGeneration) {
|
|
15674
15851
|
const binding = await readAccountStoreBinding(legacyPath, modules, now, expectedGeneration);
|
|
15675
15852
|
if (binding.status !== "bound")
|
|
@@ -15963,6 +16140,8 @@ function createAccountMigrationFactory(modules) {
|
|
|
15963
16140
|
const existing = await readJournal(paths);
|
|
15964
16141
|
if (!existing)
|
|
15965
16142
|
throw new AccountMigrationError("published generation journal missing");
|
|
16143
|
+
if (existing.sourceKind === "generation")
|
|
16144
|
+
throw new AccountMigrationError("a moved account store is finished by `antigravity-auth store relocate`, not by migrate");
|
|
15966
16145
|
if (existing.status === "inactive") {
|
|
15967
16146
|
previous = existing;
|
|
15968
16147
|
await modules.fs.withLock(paths.configPath, {
|
|
@@ -16138,6 +16317,9 @@ function createAccountRollbackFactory(modules) {
|
|
|
16138
16317
|
throw new AccountMigrationError("stopped processes and timers must be explicitly confirmed");
|
|
16139
16318
|
try {
|
|
16140
16319
|
return await withParentTopology(modules, options.legacyPath, async () => {
|
|
16320
|
+
const record3 = await readPointerRecord(options.legacyPath);
|
|
16321
|
+
if (record3?.schemaVersion === 2)
|
|
16322
|
+
throw new AccountMigrationError(`the account store moved to ${record3.relocatedTo.legacyPath}; move it back with \`antigravity-auth store relocate --back --offline\` before rolling it back`);
|
|
16141
16323
|
const paths = await resolvePublishedAccountStorePaths(options.legacyPath);
|
|
16142
16324
|
if (!paths)
|
|
16143
16325
|
throw new AccountMigrationError("rollback requires a published generation");
|
|
@@ -16150,6 +16332,8 @@ function createAccountRollbackFactory(modules) {
|
|
|
16150
16332
|
const initialJournal = await readJournal(paths);
|
|
16151
16333
|
if (!initialJournal)
|
|
16152
16334
|
throw new AccountMigrationError("rollback requires an owned migration generation");
|
|
16335
|
+
if (initialJournal.sourceKind === "generation")
|
|
16336
|
+
throw new AccountMigrationError(`this account store was moved here from ${initialJournal.relocation?.source.legacyPath}; move it back with \`antigravity-auth store relocate --back --offline\` before rolling it back`);
|
|
16153
16337
|
let journal = initialJournal;
|
|
16154
16338
|
const store = openMigrationStore(modules, paths, options.now, writeObserver(paths, lease, options.onBoundary));
|
|
16155
16339
|
if (journal.status === "inactive") {
|
|
@@ -22102,23 +22286,37 @@ function migrateLegacyWindowsConfig() {
|
|
|
22102
22286
|
return false;
|
|
22103
22287
|
}
|
|
22104
22288
|
}
|
|
22289
|
+
function resolveWindowsAccountAnchor(newPath, legacyPath) {
|
|
22290
|
+
const standard = resolve12(newPath);
|
|
22291
|
+
const legacy = resolve12(legacyPath);
|
|
22292
|
+
if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
|
|
22293
|
+
const standardPointer = existsSync3(accountStorePointerPath(standard));
|
|
22294
|
+
const legacyPointer = existsSync3(accountStorePointerPath(legacy));
|
|
22295
|
+
if (standardPointer && legacyPointer) {
|
|
22296
|
+
throw new Error(
|
|
22297
|
+
`Two migrated account stores exist: one is published at ${newPath} and another at ${legacyPath}. Keep one store and remove the other, then restart OpenCode.`
|
|
22298
|
+
);
|
|
22299
|
+
}
|
|
22300
|
+
if (legacyPointer && !standardPointer) return legacyPath;
|
|
22301
|
+
if (!existsSync3(standard) && existsSync3(legacy)) return legacyPath;
|
|
22302
|
+
return newPath;
|
|
22303
|
+
}
|
|
22105
22304
|
function getStoragePathWithMigration() {
|
|
22106
22305
|
const newPath = join10(getConfigDir(), "antigravity-accounts.json");
|
|
22107
22306
|
if (process.platform === "win32") {
|
|
22108
22307
|
migrateLegacyWindowsConfig();
|
|
22109
|
-
|
|
22110
|
-
|
|
22111
|
-
|
|
22112
|
-
|
|
22113
|
-
|
|
22114
|
-
|
|
22115
|
-
|
|
22116
|
-
|
|
22117
|
-
|
|
22118
|
-
|
|
22119
|
-
return legacyPath;
|
|
22120
|
-
}
|
|
22308
|
+
const legacyPath = join10(
|
|
22309
|
+
getLegacyWindowsConfigDir(),
|
|
22310
|
+
"antigravity-accounts.json"
|
|
22311
|
+
);
|
|
22312
|
+
const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
|
|
22313
|
+
if (resolve12(anchored).toLowerCase() !== resolve12(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve12(anchored)))) {
|
|
22314
|
+
log5.info("Using legacy Windows config path (migration failed)", {
|
|
22315
|
+
legacyPath,
|
|
22316
|
+
newPath
|
|
22317
|
+
});
|
|
22121
22318
|
}
|
|
22319
|
+
return anchored;
|
|
22122
22320
|
}
|
|
22123
22321
|
return newPath;
|
|
22124
22322
|
}
|
|
@@ -22481,9 +22679,11 @@ function stateHomeLogsDir() {
|
|
|
22481
22679
|
}
|
|
22482
22680
|
function legacyAccountFile(configDir = getConfigDir()) {
|
|
22483
22681
|
const standard = join12(configDir, ACCOUNT_FILE_NAME);
|
|
22484
|
-
if (process.platform !== "win32"
|
|
22485
|
-
|
|
22486
|
-
|
|
22682
|
+
if (process.platform !== "win32") return standard;
|
|
22683
|
+
return resolveWindowsAccountAnchor(
|
|
22684
|
+
standard,
|
|
22685
|
+
join12(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
|
|
22686
|
+
);
|
|
22487
22687
|
}
|
|
22488
22688
|
function legacyVaultDir(accountFile) {
|
|
22489
22689
|
return join12(dirname16(accountFile), VAULT_DIR_NAME);
|