Treat closed_unknown as final in MCP acceptance gate; add UI-only browser script for human unknown-job closure
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-17 13:34:04 +01:00
parent af9e9ec479
commit b9a1b1db76
2 changed files with 55 additions and 1 deletions
+54
View File
@@ -0,0 +1,54 @@
// Actual UI only: closes exactly one unknown job through the dev/test WebUI as the
// visibly simulated test principal. No page.request, fetch injection, API or DB access.
// Usage: node close_unknown_job.cjs <operation_id> <job_id> <reason>
const fs = require('node:fs');
const path = require('node:path');
const { chromium } = require('../../web/node_modules/playwright');
const root = path.resolve(__dirname, '../..');
const assert = (value, code) => { if (!value) throw new Error(code || 'UI contract mismatch'); };
(async () => {
const [operationId, jobId, reason] = process.argv.slice(2);
assert(/^[0-9a-f-]{36}$/.test(operationId) && /^[0-9a-f-]{36}$/.test(jobId) && reason && reason.length <= 1024, 'ARGS');
const loginFile = path.join(root, 'credentials/server-browser-login.json');
const loginStat = fs.lstatSync(loginFile);
assert(loginStat.isFile() && !loginStat.isSymbolicLink() && loginStat.uid === process.getuid() && (loginStat.mode & 0o777) === 0o600, 'LOGIN_FILE');
const login = JSON.parse(fs.readFileSync(loginFile, 'utf8'));
const cache = path.join(root, 'web/node_modules/.cache/cloud-acceptance');
const browserRoot = path.join(root, 'web/node_modules/.cache/playwright-browsers');
const version = fs.readdirSync(browserRoot).find(x => /^chromium-/.test(x));
const candidates = ['chrome-linux/chrome', 'chrome-linux64/chrome'].map(x => path.join(browserRoot, version, x));
const browser = await chromium.launch({ headless: true, executablePath: candidates.find(x => fs.existsSync(x)),
env: { ...process.env, HOME: path.join(cache, 'home') } });
try {
const page = await browser.newPage({ ignoreHTTPSErrors: false });
await page.goto('https://localhost:18443/');
await page.getByLabel('Benutzername').fill(login.username);
await page.getByLabel('Passwort', { exact: true }).fill(login.password);
const sessionResponse = page.waitForResponse(r => new URL(r.url()).pathname === '/auth/session' && r.status() === 200);
await page.getByRole('button', { name: 'Anmelden', exact: true }).click();
const session = await (await sessionResponse).json();
assert(session.testsimulation === true && session.approval_origin === 'dev_test_browser_simulation' && session.principal === 'simulated-testprincipal-a', 'SESSION');
await page.getByRole('status').filter({ hasText: 'SIMULIERT' }).waitFor();
await page.getByRole('button', { name: operationId, exact: true }).click();
await page.getByRole('button', { name: `Job ${jobId} · unknown`, exact: true }).click();
const job = page.locator('article').filter({ has: page.getByRole('heading', { name: `Job ${jobId}`, exact: true }) });
const before = JSON.parse(await job.getByLabel('Vollständige Originaldaten: Versuch, Zustand, Ausgabe, Trunkierung, Nachprüfungen und Ergebnis', { exact: true }).innerText());
assert(before.job_id === jobId && before.state === 'unknown', 'NOT_UNKNOWN');
const region = job.getByRole('region', { name: 'Unknown-Job abschließen', exact: true });
const button = region.getByRole('button', { name: 'SIMULIERT: Unknown-Job ausdrücklich abschließen', exact: true });
assert(await button.isDisabled(), 'BUTTON_NOT_GATED');
await region.getByLabel('Begründung').fill(reason);
await region.getByRole('checkbox', { name: 'Ich akzeptiere, dass die Wirkung', exact: false }).check();
const response = page.waitForResponse(r => new URL(r.url()).pathname.endsWith(`/jobs/${jobId}/unknown-closure`));
await button.click();
const closed = await (await response).json();
assert(closed.state === 'closed_unknown' && closed.result.error_code === 'OPERATOR_CLOSED_UNKNOWN'
&& closed.result.evidence.effect === 'unknown' && closed.result.evidence.retry === false
&& closed.result.evidence.testsimulation === true
&& closed.result.evidence.approval_origin === 'dev_test_browser_simulation', 'CLOSURE_RESULT');
console.log(JSON.stringify({ closed: true, job_id: jobId, before_state: before.state, before_revision: before.revision,
state: closed.state, revision: closed.revision, closure_id: closed.result.evidence.closure_id,
principal: session.principal, approval_origin: session.approval_origin, testsimulation: session.testsimulation }));
await page.getByRole('button', { name: 'Abmelden', exact: true }).click();
} finally { await browser.close(); }
})().catch(error => { console.log('UNKNOWN_CLOSURE_INCOMPLETE:' + error.message); process.exitCode = 1; });
+1 -1
View File
@@ -140,7 +140,7 @@ def server(payload):
selected.replace('tenant_id=', 'j.tenant_id=').replace('agent_id=', 'j.agent_id=').replace('job_id=', 'j.job_id=')+")," selected.replace('tenant_id=', 'j.tenant_id=').replace('agent_id=', 'j.agent_id=').replace('job_id=', 'j.job_id=')+"),"
"'permits',(SELECT count(*) FROM execution_permits e JOIN jobs j USING(tenant_id,job_id,attempt_id) WHERE "+ "'permits',(SELECT count(*) FROM execution_permits e JOIN jobs j USING(tenant_id,job_id,attempt_id) WHERE "+
selected.replace('tenant_id=', 'j.tenant_id=').replace('agent_id=', 'j.agent_id=').replace('job_id=', 'j.job_id=')+")," selected.replace('tenant_id=', 'j.tenant_id=').replace('agent_id=', 'j.agent_id=').replace('job_id=', 'j.job_id=')+"),"
"'unresolved',(SELECT count(*) FROM jobs WHERE "+scope+" AND state NOT IN ('succeeded','failed','cancelled','expired')));") "'unresolved',(SELECT count(*) FROM jobs WHERE "+scope+" AND state NOT IN ('succeeded','failed','cancelled','expired','closed_unknown')));")
else: else:
require(payload['kind'] == 'audit', 'unknown evidence query') require(payload['kind'] == 'audit', 'unknown evidence query')
operation = str(uuid.UUID(payload['operation_id'])) operation = str(uuid.UUID(payload['operation_id']))