test: preserve Speko hangup evidence and retry cleanup

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-09 17:15:27 -05:00
1 parent 0f99954f93
commit 8027a51137
9 files changed
+118 -1159

No files matched your search

@@ -34,7 +34,7 @@ Fresh review-repair evidence:
| Final setup, task launcher and incoming-call recovery stories | Passed: 153-story build, 220 affected checks | UI 43be85d01 with runtime 04a69ea6a; `/tmp/speko-pr-storybook-all-review-final.log`, `/tmp/speko-pr-storybook-all-review-checks.log`; no unrelated baseline updates |
| Authenticated E03/E14 isolation and revocation | Passed: 1 journey | Feature f121270c8; `/tmp/speko-pr-authenticated-final.log` |
| Integrated browser/phone journeys | Two passed; main journey failed in latest retry | `/tmp/speko-pr-integrated-startup-budget-final.log`; initial browser transcript did not retrieve saved answers. Execution and publication success do not supersede the visible delivery failure. Earlier successful portions are historical. |
| Frozen SDK dependency installation | Prepared update passes; uncommitted | UI SDK needs a 95-line root-lockfile update; repository skill exception awaits user authorization |
| Dependency locking | Repository automation | The user explicitly requested no lockfiles. Root locking is managed by the existing refresh-lockfile workflow; standalone proof installation uses --no-package-lock. |
The master-integrated combined source is preserved in feature commit 134d5b67c (origin/master 98e3cec78e); the successful authenticated run used the prior feature commit f121270c8. Speko migrations are now 0323–0329 after master added 0322. Earlier integrated attempts ran the preceding feature commit with the review patches applied. Reports do not promote those runs to exact-head acceptance.
@@ -42,7 +42,7 @@ The integrated test exposed a Slack-only communication-guidance join introduced
The new long-answer repair splits provider messages at 16,000 UTF-16 code units without cutting surrogate pairs, persists each part receipt, resumes known rate-limit failures, and blocks polling from replaying an accepted prefix. The 77-test persistence suite initially hit its explicit 30-second database startup hook before any assertions ran on the loaded host. It now uses the repository’s documented embedded-Postgres test startup budget. All 77 tests passed on runtime a7002737b, including multipart rate-limit/restart and unknown-outcome regressions and protection against polling replay of an accepted prefix (`/tmp/speko-pr-multipart-persistence-final.log`). Server typecheck passed (`/tmp/speko-pr-multipart-final-typecheck.log`).
Runtime 04a69ea6a received Greptile 5/5 with no unresolved review threads, and its CI typecheck/build passed. A chat-retry browser shard failed its authorization-denial feedback assertion twice on runtime 04a69ea6a. Runtime 82a96b128d begins that fixture directly on the canonical agent route, preserving authority and visible-error assertions. Its three-repeat local verification was blocked before tests ran by the 120-second server startup timeout (`/tmp/speko-pr-chat-retry-canonical.log`); fresh CI is pending. UI 43be85d01 passed its ordinary CI tests/build/Canary and received Greptile 5/5; its SDK frozen-lockfile finding remains open. Pending checks are not passes. The SDK frozen-lockfile review finding remains open pending user authorization for the repository-skill exception.
Runtime 04a69ea6a received Greptile 5/5 with no unresolved review threads, and its CI typecheck/build passed. A chat-retry browser shard failed its authorization-denial feedback assertion twice on runtime 04a69ea6a. Runtime 82a96b128d begins that fixture directly on the canonical agent route, preserving authority and visible-error assertions. Its three-repeat local verification was blocked before tests ran by the 120-second server startup timeout (`/tmp/speko-pr-chat-retry-canonical.log`); all ordinary CI checks subsequently passed. UI 43be85d01 passed its ordinary CI tests/build/Canary and received Greptile 5/5; dependency locking follows the existing repository automation. The user explicitly requested that no lockfiles be added.
A real OpenCode/OpenRouter DeepSeek task executed in the configured Daytona sandbox, preserved low_trust_review, ran df -h, and persisted its initial update and final answer. Its 10 GB root overlay had about 9.9 GB available. The ephemeral sandbox cleanup succeeded.
@@ -61,3 +61,7 @@ Browser voice, inbound telephone, outbound callback, Safari/mobile playback, and
Private call logs, provider account IDs, credentials, and transcripts remain outside these public PRs. The test harness writes new evidence to local report directories. Only consented, redacted results should be shared. Historical development reports are retained in the original feature worktree; they are not current-head proof.
See [the E2E runbook](2026-09-11-speko-voice-e2e-runbook.md) and [the component/story inventory](2026-09-11-speko-storybook-inventory.md). Keep Speko behind the existing experimental chat-connector setting until all supported real-provider journeys pass.
### Final merge preparation
The user authorized merging the feature and explicitly requested no lockfiles. The standalone proof lockfile was removed and its installation instructions updated. The final cleanup repairs preserve reports on failed provider hangup, allow retrying unconfirmed hangup, coalesce concurrent cleanup, and continue media cleanup after failures. Five deterministic cleanup/redaction tests passed. The connected live-browser harness now creates its qualification task in Todo, where submit_request can run. Syntax checks passed; no live calls were placed during merge preparation. Master integration renumbers Speko migrations to 0324–0330 and retains the new GitHub registration migration. Exact-head CI and review are checked before merge.
+1 -1
View File
@@ -98,7 +98,7 @@ try {
await page.getByRole('button', { name: `Talk to ${fixture.agentName}`, exact: true }).click();
} else if (process.env.SPEKO_NATIVE_CONNECTED === '1') {
if (!fixture.endpointId) throw new Error('Connected qualification requires the verified endpoint fixture');
const taskResponse = await page.request.post(`${origin}/api/companies/${fixture.companyId}/issues`, {headers: {Origin: origin}, data: {title: "Speko live browser qualification", assigneeAgentId: fixture.agentId, status: "backlog"}});
const taskResponse = await page.request.post(`${origin}/api/companies/${fixture.companyId}/issues`, {headers: {Origin: origin}, data: {title: "Speko live browser qualification", assigneeAgentId: fixture.agentId, status: "todo"}});
if (!taskResponse.ok()) throw new Error(`Qualification task creation rejected (${taskResponse.status()})`);
const task = await taskResponse.json();
await page.goto(`${origin}/${fixture.companyPrefix}/issues/${task.id}`);
+1 -1
View File
@@ -15,7 +15,7 @@ Paperclip permissions, persistence, or actual spoken playback.
```sh
cd tests/speko-voice-proof
npm ci --ignore-scripts
npm install --ignore-scripts --no-package-lock
npm test
```
+22 -12
View File
@@ -1,9 +1,11 @@
import { VoiceConversation } from '@spekoai/client';
import { createCleanup } from './cleanup.mjs';
const config = JSON.parse(document.querySelector('#config').textContent);
const $ = (id) => document.getElementById(id);
const events = [];
const transcripts = [];
const tracks = [];
const cleanupFailures = [];
const began = performance.now();
let conversation, context, destination, muted = false, running = false, ended = false;
let speaking = false, notificationSent = false, sessionId, interval, recorder;
@@ -66,24 +68,32 @@ function renderTranscript(list) {
}));
}
async function saveReport() {
const report = { sessionId, sdkVersion: '0.0.13', syntheticMicrophone: true, events, transcripts,
const report = { sessionId, sdkVersion: '0.0.13', syntheticMicrophone: true, events, transcripts, cleanupFailures,
sdkOpen: conversation?.isOpen() ?? false, audioElements: document.querySelectorAll('audio').length,
inputTrackStates: tracks.map((t) => ({ enabled: t.enabled, readyState: t.readyState })) };
await api('/report', report);
$('evidence').textContent = JSON.stringify({ ...report, transcripts: `${transcripts.length} reconciled segments` }, null, 2);
}
async function end() {
if (ended) return;
ended = true; clearInterval(interval); observer.disconnect();
$('scenario').disabled = $('mute').disabled = $('end').disabled = true;
if (recorder?.state === 'recording') recorder.stop();
try { await conversation?.endSession(); } finally {
// Record SDK cleanup before stopping fixture-owned tracks ourselves.
const cleanup = createCleanup({
local: async (attempt) => {
ended = true; clearInterval(interval); observer.disconnect();
$('scenario').disabled = $('mute').disabled = true;
await attempt('recorder.stop', () => { if (recorder?.state === 'recording') recorder.stop(); });
await attempt('sdk.end', () => conversation?.endSession());
event('sdk_cleanup', { inputTracksEnded: tracks.every((t) => t.readyState === 'ended'), audioElements: document.querySelectorAll('audio').length });
destination?.stream.getTracks().forEach((t) => t.stop());
tracks.forEach((t) => t.stop()); await context?.close();
await api('/end'); status('Ended'); await saveReport();
}
await attempt('tracks.stop', () => { destination?.stream.getTracks().forEach((t) => t.stop()); tracks.forEach((t) => t.stop()); });
await attempt('context.close', () => context?.close());
},
provider: () => api('/end'),
report: saveReport,
failed: (operation) => { cleanupFailures.push({ operation }); event('cleanup_failed', { operation }); },
});
async function end() {
$('end').disabled = true;
try {
const completed = await cleanup.end();
status(completed ? 'Ended' : 'Cleanup failed. Retry End and inspect evidence.');
} finally { $('end').disabled = cleanup.complete; }
}
$('connect').onclick = async () => {
$('connect').disabled = true; status('Connecting');
+1 -1
View File
@@ -13,7 +13,7 @@ const state = JSON.parse(await readFile(`${homedir()}/.paperclip/speko-proof/sta
const out = resolve(process.env.SPEKO_PROOF_OUTPUT ?? `${homedir()}/.paperclip/speko-proof/browser-${Date.now()}`);
await mkdir(dirname(out), { recursive: true, mode: 0o700 }); await mkdir(out, { mode: 0o700 });
const sourceDigests = {};
for (const file of ['browser-server.mjs', 'browser-client.mjs', 'browser.html', 'proof.mjs', 'application-notification.txt']) sourceDigests[file] = createHash('sha256').update(await readFile(new URL(file, import.meta.url))).digest('hex');
for (const file of ['browser-server.mjs', 'browser-client.mjs', 'cleanup.mjs', 'browser.html', 'proof.mjs', 'application-notification.txt']) sourceDigests[file] = createHash('sha256').update(await readFile(new URL(file, import.meta.url))).digest('hex');
await writeFile(resolve(out, 'source.json'), JSON.stringify({ startedAt: new Date().toISOString(), sourceDigests }), { mode: 0o600 });
const bundle = await build({ entryPoints: [new URL('./browser-client.mjs', import.meta.url).pathname], bundle: true, write: false, platform: 'browser', format: 'esm' });
const inputs = new Map();
+32
View File
@@ -0,0 +1,32 @@
/** Preserve final evidence and permit retrying an unconfirmed provider hangup. */
export function createCleanup({ local, provider, report, failed }) {
let localEnded = false, providerEnded = false, reportSaved = false, pending;
const attempt = async (operation, action) => {
try { await action(); return true; }
catch { failed(operation); return false; }
};
return {
get complete() { return providerEnded && reportSaved; },
end() {
if (pending) return pending;
pending = (async () => {
let ok = true;
try {
if (!localEnded) {
localEnded = true;
ok = await attempt('local.cleanup', () => local(async (operation, action) => {
const succeeded = await attempt(operation, action);
if (!succeeded) ok = false;
})) && ok;
}
if (!providerEnded) providerEnded = await attempt('session.end', provider);
ok = providerEnded && ok;
} finally {
reportSaved = await attempt('report.save', report);
}
return ok && reportSaved;
})().finally(() => { pending = undefined; });
return pending;
},
};
}
+51
View File
@@ -0,0 +1,51 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createCleanup } from './cleanup.mjs';
test('failed hangup preserves evidence and retries only the unconfirmed provider operation', async () => {
let locals = 0, ends = 0;
const failures = [], reports = [];
const cleanup = createCleanup({
local: async () => { locals++; },
provider: async () => { if (++ends === 1) throw new Error('private failure'); },
report: async () => { reports.push([...failures]); },
failed: (operation) => failures.push(operation),
});
assert.equal(await cleanup.end(), false);
assert.equal(cleanup.complete, false);
assert.deepEqual(reports, [['session.end']]);
assert.equal(await cleanup.end(), true);
assert.equal(cleanup.complete, true);
assert.equal(locals, 1);
assert.equal(ends, 2);
assert.equal(reports.length, 2);
});
test('media failures do not prevent hangup or final evidence; concurrent cleanup coalesces', async () => {
let ends = 0, reports = 0;
const failures = [];
const cleanup = createCleanup({
local: async (attempt) => {
await attempt('sdk.end', async () => { throw new Error('sdk failure'); });
await attempt('tracks.stop', async () => { throw new Error('media failure'); });
},
provider: async () => { ends++; },
report: async () => { reports++; },
failed: (operation) => failures.push(operation),
});
assert.deepEqual(await Promise.all([cleanup.end(), cleanup.end()]), [false, false]);
assert.equal(ends, 1);
assert.equal(reports, 1);
assert.deepEqual(failures, ['sdk.end', 'tracks.stop']);
});
test('failed report can be retried without redialing or repeating a confirmed hangup', async () => {
let ends = 0, reports = 0;
const cleanup = createCleanup({ local: async () => {}, provider: async () => { ends++; },
report: async () => { if (++reports === 1) throw new Error('disk failure'); }, failed: () => {} });
assert.equal(await cleanup.end(), false);
assert.equal(cleanup.complete, false);
assert.equal(await cleanup.end(), true);
assert.equal(ends, 1);
assert.equal(reports, 2);
});
+4 -2
View File
@@ -229,8 +229,10 @@ try {
await cleanup("proof.close", () => proof.close());
await cleanup("server.close", () => { server.close(); server.closeAllConnections(); });
if (sessionId) {
try { const ended = await api(`/v1/calls/${encodeURIComponent(sessionId)}/end`, {}); event("session_end_requested", { status: ended.status }); }
catch { event("session_end_failed"); }
await cleanup("session.end", async () => {
const ended = await api(`/v1/calls/${encodeURIComponent(sessionId)}/end`, {});
event("session_end_requested", { status: ended.status });
});
}
for (const [name, close] of [
["room.disconnect", () => room.disconnect()],
File diff suppressed because it is too large. Load diff