Skip to content

Commit 49a4033

Browse files
committed
fix(daemon): retain explicitly recorded snapshots only during repair
ADR 0012 decision 6 scopes --record observation retention to repair-armed sessions. Preserve ordinary authoring snapshot exclusion even when project configuration supplies record=true; keep authored source observations and explicit repair corrections. Regression proof on 17b30bf plus tests: 1 failed, 1 passed, 39 skipped (ordinary record=true published a diagnostic snapshot). With the fix: 2 passed, 39 skipped. All four focused suites: 95 passed.
1 parent 2de2405 commit 49a4033

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎packages/daemon/src/core/__tests__/session-script-writer.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,3 +863,23 @@ test('#1533: an ARMED authoring recording is untouched by the abort gate', () =>
863863
const { parsed } = writeAndParse(writer, session);
864864
expect(parsed.actions.map((a) => a.command)).toEqual(['click']);
865865
});
866+
867+
test.each([undefined, true])(
868+
'ordinary authoring strips diagnostic snapshots with effective record=%s',
869+
(record) => {
870+
const root = mkdtempForTestSync('agent-device-script-writer-authoring-snapshot-');
871+
const writer = new SessionScriptWriter(path.join(root, 'sessions'));
872+
const session = makeAuthoringSession('default', {
873+
actions: [action({ command: 'open', positionals: ['Demo'] })],
874+
});
875+
recordActionEntry(session, {
876+
command: 'snapshot',
877+
positionals: [],
878+
flags: { record, snapshotInteractiveOnly: true },
879+
interactiveObservation: true,
880+
});
881+
882+
const { parsed } = writeAndParse(writer, session);
883+
expect(parsed.actions.map((entry) => entry.command)).toEqual(['open']);
884+
},
885+
);

‎packages/daemon/src/core/session-script-writer.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,13 @@ function buildOptimizedActions(
312312
const relevantActions = session.actions.slice(boundary ?? 0);
313313
const optimized: SessionAction[] = [];
314314
for (const action of relevantActions) {
315-
if (action.command === 'snapshot' && action.publicationIntent === undefined) continue;
315+
if (
316+
action.command === 'snapshot' &&
317+
action.publicationIntent !== 'authored' &&
318+
!(repairArmed && action.publicationIntent === 'explicit-record')
319+
) {
320+
continue;
321+
}
316322
const optimizedAction = optimizeSelectorChainAction(action);
317323
if (optimizedAction) {
318324
optimized.push(optimizedAction);

0 commit comments

Comments
 (0)