feat(ql3): atomically withdraw quarantined automation

This commit is contained in:
whyour
2026-08-13 03:42:38 +08:00
parent a6ad636251
commit 4c2a0b6adf
39 changed files with 983 additions and 264 deletions
@@ -363,9 +363,9 @@ function composeDockerHarness(
'/opt/qinglong/node_modules/@qinglong/local-application/dist/cli.js',
],
Labels: {
'io.qinglong.local.sqlite-contract-min': '44',
'io.qinglong.local.sqlite-contract-max': '44',
'io.qinglong.local.sqlite-write-contract': '44',
'io.qinglong.local.sqlite-contract-min': '45',
'io.qinglong.local.sqlite-contract-max': '45',
'io.qinglong.local.sqlite-write-contract': '45',
'io.qinglong.local.application-config': '2',
'io.qinglong.local.compose-selection': '1',
'io.qinglong.ai': 'excluded',
@@ -975,9 +975,9 @@ test('preflights exact local image, Compose merge and SQLite capability', async
'/opt/qinglong/node_modules/@qinglong/local-application/dist/cli.js',
],
Labels: {
'io.qinglong.local.sqlite-contract-min': '44',
'io.qinglong.local.sqlite-contract-max': '44',
'io.qinglong.local.sqlite-write-contract': '44',
'io.qinglong.local.sqlite-contract-min': '45',
'io.qinglong.local.sqlite-contract-max': '45',
'io.qinglong.local.sqlite-write-contract': '45',
'io.qinglong.local.application-config': '2',
'io.qinglong.local.compose-selection': '1',
'io.qinglong.ai': 'excluded',
@@ -1029,7 +1029,7 @@ test('preflights exact local image, Compose merge and SQLite capability', async
assert.equal(result.status, 'ready');
assert.equal(result.generation, 1);
assert.equal(result.profile, 'edge');
assert.equal(result.sqlite.contractVersion, 44);
assert.equal(result.sqlite.contractVersion, 45);
assert.equal(result.image.architecture, 'arm64');
assert.equal(calls.length, 2);
assert.deepEqual(calls[0].slice(0, 2), ['image', 'inspect']);
@@ -1129,8 +1129,8 @@ test('applies one Compose generation and exactly replays its health receipt', as
assert.equal(mode(receiptPath), 0o600);
const receipt = JSON.parse(fs.readFileSync(receiptPath, 'utf8'));
assert.deepEqual(receipt.sqlite, {
contractVersion: 44,
writeContractVersion: 44,
contractVersion: 45,
writeContractVersion: 45,
writeObservation: 'unchanged',
backup: null,
});
@@ -1427,8 +1427,8 @@ test('rolls a failed Compose candidate forward to a healthy prior digest', async
`${command.request.rolloutId}.sqlite`,
);
assert.equal(mode(backupPath), 0o600);
assert.equal(receipt.sqlite.contractVersion, 44);
assert.equal(receipt.sqlite.writeContractVersion, 44);
assert.equal(receipt.sqlite.contractVersion, 45);
assert.equal(receipt.sqlite.writeContractVersion, 45);
assert.equal(receipt.sqlite.writeObservation, 'changed');
assert.match(receipt.sqlite.backup.sha256, /^[0-9a-f]{64}$/);
assert.equal(receipt.sqlite.backup.bytes > 0, true);
@@ -34,8 +34,8 @@ test('inspects the exact fresh Profile schema without exposing its path', async
assert.equal(result.status, 'ready');
assert.equal(result.profile, 'edge');
assert.equal(result.storage.contractName, 'local-control-core');
assert.equal(result.storage.contractVersion, 44);
assert.equal(result.storage.migrationCount, 88);
assert.equal(result.storage.contractVersion, 45);
assert.equal(result.storage.migrationCount, 90);
assert.equal(result.storage.journalMode, 'delete');
assert.equal(JSON.stringify(result).includes(state.directory), false);
});
@@ -193,12 +193,10 @@ function packageArtifact(manifest) {
path: 'package.json',
body: Buffer.from(serializePluginPackageManifest(manifest)),
},
...CLI_PACKAGE_RESOURCES
.map(({ reference, body }) => ({
path: reference.path,
body,
}))
.sort((left, right) => left.path.localeCompare(right.path)),
...CLI_PACKAGE_RESOURCES.map(({ reference, body }) => ({
path: reference.path,
body,
})).sort((left, right) => left.path.localeCompare(right.path)),
]);
}
@@ -259,13 +257,11 @@ function actionInput() {
artifactDigest,
artifactBytes: artifact.byteLength,
contentDigest: pluginPackageContentTreeDigest(
CLI_PACKAGE_RESOURCES
.map(({ reference, body }) => ({
path: reference.path,
bytes: body.byteLength,
digest: digest(body),
}))
.sort((left, right) => left.path.localeCompare(right.path)),
CLI_PACKAGE_RESOURCES.map(({ reference, body }) => ({
path: reference.path,
bytes: body.byteLength,
digest: digest(body),
})).sort((left, right) => left.path.localeCompare(right.path)),
),
},
architecture: 'arm64',
@@ -478,9 +474,7 @@ async function activatePackageAutomation(databasePath, lock, manifest) {
const revision = materializePluginPackageResources({
generation,
lock,
manifestBytes: Buffer.from(
serializePluginPackageManifest(manifest),
),
manifestBytes: Buffer.from(serializePluginPackageManifest(manifest)),
resources: generation.resources.map((reference) => ({
reference,
bytes: bodies.get(`${reference.kind}\0${reference.path}`),
@@ -521,10 +515,8 @@ function publisherTrustRunnerWithOneSnapshotFault() {
inspect: inspectLocalPluginPackagePublisherTrust,
publish: publishLocalPluginPackagePublisherTrust,
retire: retireLocalPluginPackagePublisherKey,
analyzePublisherKey:
analyzeLocalPluginPackageRecoveryCatalogPublisherKey,
proposeRevocation:
proposeLocalPluginPackagePublisherKeyRevocation,
analyzePublisherKey: analyzeLocalPluginPackageRecoveryCatalogPublisherKey,
proposeRevocation: proposeLocalPluginPackagePublisherKeyRevocation,
async confirmRevocation(options) {
return confirmLocalPluginPackagePublisherKeyRevocation({
...options,
@@ -896,10 +888,7 @@ test('runs the private command-file package lifecycle with replay-safe IDs', asy
const catalogHelp = spawnSync(
process.execPath,
[
path.join(
__dirname,
'../dist/plugin-package/pluginPackageCatalogCli.js',
),
path.join(__dirname, '../dist/plugin-package/pluginPackageCatalogCli.js'),
'--help',
],
{ encoding: 'utf8' },
@@ -1183,15 +1172,29 @@ test('runs the private command-file package lifecycle with replay-safe IDs', asy
WHERE project_id = ? AND package_name = ?`,
)
.get(lock.projectId, lock.packageName);
assert.deepEqual({ ...automationHead }, {
publicationDigest:
activeAutomation.publication.publicationDigest,
state: 'active',
});
assert.equal(
await new LocalSqlitePluginPackageAutomationPublicationRepository(
const automationRepository =
new LocalSqlitePluginPackageAutomationPublicationRepository(
quarantineAuthority,
).isStartAllowed(
);
const withdrawnAutomation = await automationRepository.findCurrent(
lock.projectId,
lock.packageName,
);
assert.ok(withdrawnAutomation);
assert.equal(withdrawnAutomation.state, 'withdrawn');
assert.equal(
withdrawnAutomation.previousPublicationDigest,
activeAutomation.publication.publicationDigest,
);
assert.deepEqual(
{ ...automationHead },
{
publicationDigest: withdrawnAutomation.publicationDigest,
state: 'withdrawn',
},
);
assert.equal(
await automationRepository.isStartAllowed(
lock.projectId,
lock.packageName,
activeAutomation.publication.publicationDigest,