fix: fifth review round (durable mount failures, {#key} hydration slots)

cursor[bot]:
- variant_mount_failed now sets the session's pendingEvent (without
  clobbering a still-pending generate), so a helper restart replays it
  onto /poll and a repair --reply resolves instead of returning
  unknown_poll_reply_id. live-resume's next action names the real event
  id instead of a literal EVENT_ID placeholder.
- Contract v2 text hydration strips {#key} DELIMITERS from the zip
  source (content stays; it always renders), so key blocks can no longer
  shift expression slots against the live DOM.

This work was produced with AI assistance (Claude Code).

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-07-27 16:33:34 -07:00
co-authored by Claude Code
parent 39df25ee5a
commit e5f6d27a9c
5 changed files with 74 additions and 3 deletions
+1 -1
View File
@@ -163,7 +163,7 @@ describe('live recovery CLI commands', () => {
'event=live_resume.mount_failure_action actor=agent operation=recover_session risk=agent_thinks_variants_are_on_screen expected=named failing variant and url actual=' + resume.nextAction,
);
assert.match(resume.nextAction, /variant_mount_failed/);
assert.match(resume.nextAction, /--reply EVENT_ID done --file/);
assert.match(resume.nextAction, /--reply cli-render-2 done --file/);
const status = runJson(STATUS_SCRIPT, [], cwd);
assert.match(status.recoveryHint, /failed to mount variant 2/);
+36
View File
@@ -730,3 +730,39 @@ describe('live-session-store', () => {
});
});
});
describe('review regressions: durable mount failures', () => {
it('variant_mount_failed survives a helper restart as the pending event', () => {
const tmp = mkdtempSync(join(tmpdir(), 'impeccable-store-mountfail-'));
try {
const store = createLiveSessionStore({ cwd: tmp });
store.appendEvent({ type: 'generate', id: 'mf123456', count: 3, pageUrl: '/', element: { tagName: 'h1' } });
store.appendEvent({ type: 'agent_done', id: 'mf123456' });
store.appendEvent({ type: 'variant_mount_failed', id: 'mf123456', variant: 2, url: 'http://x/v2.svelte', error: 'boom' });
// A second store instance = the restarted helper.
const restarted = createLiveSessionStore({ cwd: tmp });
const snapshot = restarted.getSnapshot('mf123456');
assert.equal(snapshot.pendingEvent?.type, 'variant_mount_failed');
assert.equal(snapshot.pendingEvent?.variant, 2);
// The repair reply retires it.
restarted.appendEvent({ type: 'agent_done', id: 'mf123456', sourceEventType: 'variant_mount_failed' });
assert.equal(restarted.getSnapshot('mf123456').pendingEvent, null);
} finally {
rmSync(tmp, { recursive: true, force: true });
}
});
it('a mount failure does not clobber a still-pending generate', () => {
const tmp = mkdtempSync(join(tmpdir(), 'impeccable-store-mountfail2-'));
try {
const store = createLiveSessionStore({ cwd: tmp });
store.appendEvent({ type: 'generate', id: 'mf223456', count: 3, pageUrl: '/', element: { tagName: 'h1' } });
store.appendEvent({ type: 'variant_mount_failed', id: 'mf223456', variant: 1, url: 'http://x/v1.svelte', error: 'early' });
assert.equal(store.getSnapshot('mf223456').pendingEvent?.type, 'generate');
} finally {
rmSync(tmp, { recursive: true, force: true });
}
});
});