Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/daemon/__tests__/session-script-publication-state.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { expect, test } from 'vitest';
import { armRepair, resolveScriptTarget } from '../session-script-publication-state.ts';

// The retention table for the per-target force model (#1258). The repair suites pin these
// transitively through healed-sibling paths; this pins the transition itself, so a regression
// names the rule it broke instead of a downstream path assertion.

test('a bare re-arm keeps a materialized explicit target and its grant', () => {
const previous = { kind: 'explicit', path: '/flows/a.healed.ad', force: true } as const;
expect(resolveScriptTarget(previous, { force: false })).toEqual(previous);
});

test('a bare re-arm with live force adds the grant without touching the path', () => {
expect(
resolveScriptTarget(
{ kind: 'explicit', path: '/flows/a.healed.ad', force: false },
{ force: true },
),
).toEqual({ kind: 'explicit', path: '/flows/a.healed.ad', force: true });
});

test('re-arming the same explicit path keeps an existing grant', () => {
expect(
resolveScriptTarget(
{ kind: 'explicit', path: '/flows/a.ad', force: true },
{ path: '/flows/a.ad', force: false },
),
).toEqual({ kind: 'explicit', path: '/flows/a.ad', force: true });
});

test('retargeting to a different explicit path without live force drops the grant', () => {
expect(
resolveScriptTarget(
{ kind: 'explicit', path: '/flows/a.ad', force: true },
{ path: '/flows/b.ad', force: false },
),
).toEqual({ kind: 'explicit', path: '/flows/b.ad', force: false });
});

test('moving from default to an explicit path keeps the grant (#1258 flagged retention)', () => {
expect(
resolveScriptTarget({ kind: 'default', force: true }, { path: '/flows/out.ad', force: false }),
).toEqual({ kind: 'explicit', path: '/flows/out.ad', force: true });
});

test('per-step repair re-arms never move the boundary or wipe the healed sibling', () => {
const armed = armRepair(
{ kind: 'none' },
{
requested: { path: '/flows/login.healed.ad', force: false },
boundary: 3,
sourcePath: '/flows/login.ad',
},
);
const rearmed = armRepair(armed, { requested: { force: false }, boundary: 0 });
expect(rearmed).toEqual(armed);
});
Loading