Remove pre-1.0 production governance surfaces

This commit is contained in:
npc0-hue
2026-08-21 00:06:00 +08:00
parent a7e2e4c6c0
commit da6c8d607e
30 changed files with 89 additions and 429 deletions
+12 -87
View File
@@ -86,7 +86,7 @@ async function main() {
throw new Error("AI provider response exposed Platform-owned endpoint or secret reference");
}
const productionSeed = await prepareProductionOperations(authHeaders, server, plugin);
const pluginSeed = await preparePluginOperations(authHeaders, server, plugin);
const chrome = await startChrome();
const evidence = {
@@ -114,7 +114,7 @@ async function main() {
logStreams: logStreams.items.map((stream) => pick(stream, ["id", "serverInstanceId", "streamKey", "source"])),
artifacts: artifacts.items.map((artifact) => pick(artifact, ["id", "ownerKind", "ownerId", "state", "checksum"])),
usage: pick(usage, ["cpuPercent", "memoryPercent", "diskPercent", "source"]),
production: productionSeed.apiProof
pluginOperations: pluginSeed.apiProof
},
routes: [],
safety: {
@@ -132,7 +132,7 @@ async function main() {
{
name: "首页",
hash: "#/home",
markers: ["平台概览", "运营数据已同步", "game.example", "运行节点", "CPU", "生产容量与告警", "运行槽位"]
markers: ["平台概览", "运营数据已同步", "game.example", "运行节点", "CPU"]
},
{
name: "服务器管理",
@@ -165,12 +165,12 @@ async function main() {
{
name: "AI 提供商管理",
hash: "#/aiProviders",
markers: ["AI 提供商管理", "平台 API", aiProvider.name, "密钥状态", "已配置", "AI 配置审查", productionSeed.diff.diffSummary, server.id]
markers: ["AI 提供商管理", "平台 API", aiProvider.name, "密钥状态", "已配置", "AI 配置审查", pluginSeed.diff.diffSummary, server.id]
},
{
name: "系统维护",
hash: "#/maintenance",
markers: ["系统维护", "容量与告警闭环", "运行槽位", productionSeed.alert.title]
markers: ["系统维护", "运行节点", "最近失败任务"]
},
{
name: "服务器详情",
@@ -202,10 +202,9 @@ async function main() {
const pluginPage = await clickAndVerify(chrome, "概览", ["插件概览", "dev-game-plugin 页面 bundle", "server.instances.read"]);
evidence.routes.push({ name: "服务器详情 / 插件声明页面", url: await chrome.url(), ...pluginPage });
evidence.productionInteractions = {
alert: await verifyAlertInteraction(chrome, authHeaders, productionSeed.alert),
evidence.pluginInteractions = {
pluginLifecycle: await verifyPluginLifecycleInteraction(chrome, authHeaders, plugin, server),
aiDiffApproval: await verifyAIConfigDiffInteraction(chrome, authHeaders, productionSeed.diff)
aiDiffApproval: await verifyAIConfigDiffInteraction(chrome, authHeaders, pluginSeed.diff)
};
evidence.walkthroughs = await verifyResponsiveThemeWalkthroughs(chrome, routeChecks, server);
@@ -558,7 +557,7 @@ async function ensureAiProvider(headers) {
);
}
async function prepareProductionOperations(headers, server, plugin) {
async function preparePluginOperations(headers, server, plugin) {
const stamp = Date.now();
const lifecycle = await postJson(
`/plugin-lifecycles/${encodeURIComponent(plugin.id)}/actions`,
@@ -589,99 +588,25 @@ async function prepareProductionOperations(headers, server, plugin) {
throw new Error(`AI invocation did not persist a reviewable diff: ${JSON.stringify(aiInvocation)}`);
}
const admission = await postJson(
"/production/capacity/admission",
{
serverInstanceId: server.id,
capability: "process.restart",
idempotencyKey: `browser-acceptance-capacity-gap-${stamp}`
},
headers
);
if (admission.accepted || admission.state !== "denied" || !admission.alertId) {
throw new Error(`capacity admission did not create durable denied evidence: ${JSON.stringify(admission)}`);
}
const [capacity, alerts, lifecycles, diffs] = await Promise.all([
getJson("/production/capacity", headers),
getJson("/alerts", headers),
const [lifecycles, diffs] = await Promise.all([
getJson(`/plugin-lifecycles?pluginId=${encodeURIComponent(plugin.id)}&serverInstanceId=${encodeURIComponent(server.id)}`, headers),
getJson(`/ai/config-diffs?serverInstanceId=${encodeURIComponent(server.id)}`, headers)
]);
const alert = findRequired(alerts.items, (item) => item.id === admission.alertId && item.state === "active", "active capacity alert");
const installation = findRequired(lifecycles.items, (item) => item.id === lifecycle.installation.id && item.jobId === lifecycle.job.id, "durable plugin lifecycle installation");
const diff = findRequired(diffs.items, (item) => item.id === aiInvocation.configRecommendation.diffId && item.state === "pending", "pending AI config diff");
if (capacity.activeAlerts < 1 || !capacity.endpoints.some((item) => item.runEndpointId === server.runEndpointId)) {
throw new Error(`production capacity summary did not include seeded state: ${JSON.stringify(capacity)}`);
}
for (const [label, value] of Object.entries({ admission, capacity, alert, installation, diff, aiInvocation })) {
assertNoForbiddenProjection(value, `production seed ${label}`);
for (const [label, value] of Object.entries({ installation, diff, aiInvocation })) {
assertNoForbiddenProjection(value, `plugin operations seed ${label}`);
}
return {
alert,
diff,
apiProof: {
admission: pick(admission, ["accepted", "state", "reason", "pressureCodes", "alertId"]),
capacity: {
...pick(capacity, ["totalMaxJobs", "totalRunningJobs", "totalQueuedJobs", "activeAlerts", "generatedAt"]),
endpoints: capacity.endpoints.map((item) => pick(item, ["runEndpointId", "status", "maxJobs", "runningJobs", "queuedJobs", "logBacklogBatches", "artifactBacklogChunks", "pressureCodes"]))
},
alert: pick(alert, ["id", "sourceKind", "sourceId", "ruleKey", "severity", "state", "occurrenceCount"]),
pluginLifecycle: pick(installation, ["id", "pluginId", "serverInstanceId", "currentVersion", "targetVersion", "desiredState", "currentState", "lastOperation", "compatibility", "dependencyState", "jobId"]),
aiConfigDiff: pick(diff, ["id", "requestId", "serverInstanceId", "pluginId", "providerId", "model", "key", "configVersion", "diffSummary", "state", "expiresAt"])
}
};
}
async function verifyAlertInteraction(chrome, headers, seededAlert) {
await chrome.navigate(`${webUrl}/#/home`);
await chrome.waitForText(["生产容量与告警", seededAlert.title, "确认"], "production alert interaction");
await chrome.evaluate((title) => {
const item = Array.from(document.querySelectorAll(".production-alert-list .operation-item")).find((candidate) => candidate.textContent?.includes(title));
const button = Array.from(item?.querySelectorAll("button") || []).find((candidate) => candidate.textContent?.trim() === "确认");
if (!(button instanceof HTMLButtonElement)) throw new Error("capacity alert acknowledge button not found");
button.click();
}, seededAlert.title);
await chrome.waitForText(["确认告警", seededAlert.id, "取消"], "alert confirmation dialog");
await chrome.evaluate(() => {
const cancel = document.querySelector(".confirm-panel .confirm-actions button");
if (!(cancel instanceof HTMLButtonElement)) throw new Error("alert confirmation cancel button not found");
cancel.click();
});
await delay(100);
if (await chrome.evaluate(() => Boolean(document.querySelector(".confirm-panel")))) {
throw new Error("alert confirmation dialog did not close after cancel");
}
const afterCancel = await getJson("/alerts", headers);
const stillActive = findRequired(afterCancel.items, (item) => item.id === seededAlert.id, "alert after confirmation cancel");
assertEqual(stillActive.state, "active", "cancel keeps durable alert active");
await chrome.evaluate((title) => {
const item = Array.from(document.querySelectorAll(".production-alert-list .operation-item")).find((candidate) => candidate.textContent?.includes(title));
const button = Array.from(item?.querySelectorAll("button") || []).find((candidate) => candidate.textContent?.trim() === "确认");
if (!(button instanceof HTMLButtonElement)) throw new Error("capacity alert acknowledge button not found after cancel");
button.click();
}, seededAlert.title);
await chrome.waitForText(["确认告警", seededAlert.id], "alert confirmation reopen");
await chrome.evaluate(() => {
const confirm = document.querySelector(".confirm-panel .confirm-primary");
if (!(confirm instanceof HTMLButtonElement)) throw new Error("alert confirmation submit button not found");
confirm.click();
});
await chrome.waitForText(["确认已由 Platform 持久化", "acknowledged"], "durable alert acknowledgement");
const alerts = await getJson("/alerts", headers);
const acknowledged = findRequired(alerts.items, (item) => item.id === seededAlert.id, "acknowledged capacity alert");
assertEqual(acknowledged.state, "acknowledged", "browser alert acknowledgement persisted");
assertNoForbiddenProjection(acknowledged, "acknowledged alert response");
return {
cancelPreservedState: stillActive.state,
persisted: pick(acknowledged, ["id", "state", "acknowledgedBy", "acknowledgedAt"]),
forbiddenFragmentScan: "passed",
textSample: (await chrome.visibleText()).slice(0, 1200)
};
}
async function verifyPluginLifecycleInteraction(chrome, headers, plugin, server) {
await chrome.navigate(`${webUrl}/#/plugins`);
await chrome.waitForText(["插件市场", plugin.id, "查看详情"], "plugin lifecycle marketplace");
@@ -719,7 +644,7 @@ async function verifyPluginLifecycleInteraction(chrome, headers, plugin, server)
}
assertNoForbiddenProjection(installation, "browser plugin lifecycle response");
return {
persisted: pick(installation, ["id", "pluginId", "serverInstanceId", "currentState", "desiredState", "lastOperation", "dependencyState", "jobId", "alertId"]),
persisted: pick(installation, ["id", "pluginId", "serverInstanceId", "currentState", "desiredState", "lastOperation", "dependencyState", "jobId"]),
forbiddenFragmentScan: "passed",
textSample: (await chrome.visibleText()).slice(0, 1200)
};