Skip to content

Commit fd483da

Browse files
committed
refactor: keep session capture bindings in one module
Session teardown imported three per-capture binding modules plus their shared binding, which grew its eager closure past the merge-base. The audio, perf and screen-recording bindings now live beside bindSessionCapture.
1 parent df059d5 commit fd483da

12 files changed

Lines changed: 47 additions & 62 deletions

‎scripts/layering/session-resource-ownership.test.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,10 @@ test('session resources are constructed only by their durable domain owners', ()
2727
`sessionStore.update(ref, { appLog: log, appLogFailure: undefined });`,
2828
],
2929
[
30-
'src/daemon/audio-probe-session-binding.ts',
31-
`sessionStore.update(ref, { audioProbe: audio });`,
32-
],
33-
[
34-
'src/daemon/perf-capture-session-binding.ts',
35-
`sessionStore.update(ref, { perfCapture: perf });`,
36-
],
37-
[
38-
'src/daemon/screen-recording-session-binding.ts',
39-
`sessionStore.update(ref, { screenRecording: recording });`,
30+
'src/daemon/session-capture-binding.ts',
31+
`sessionStore.update(ref, { audioProbe: audio });
32+
sessionStore.update(ref, { perfCapture: perf });
33+
sessionStore.update(ref, { screenRecording: recording });`,
4034
],
4135
[
4236
'packages/capture-kit/src/capture-admission/audio-probe-session-resource.ts',

‎scripts/layering/session-resource-ownership.ts‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Catches: a session resource field (appLog, appLogFailure, audioProbe, perfCapture) written
1+
// Catches: a session resource field (appLog, appLogFailure, audioProbe, perfCapture, screenRecording) written
22
// from outside its declared owner module — R7's session-state-ownership shape applied to the
33
// narrower set of per-resource fields these session-scoped runtimes carry, where the same
44
// aliasing hazard (get()/set() hand back and re-put the live reference) applies.
@@ -27,15 +27,12 @@ const SCANNED_ROOTS = ['src/daemon/', 'packages/capture-kit/src/capture-admissio
2727
const RESOURCE_OWNERS: Readonly<Record<string, ReadonlySet<string>>> = {
2828
appLog: new Set(['src/daemon/app-log-session-resource.ts', 'src/daemon/session-state.ts']),
2929
appLogFailure: new Set(['src/daemon/app-log-session-resource.ts', 'src/daemon/session-state.ts']),
30-
audioProbe: new Set(['src/daemon/audio-probe-session-binding.ts', 'src/daemon/session-state.ts']),
30+
audioProbe: new Set(['src/daemon/session-capture-binding.ts', 'src/daemon/session-state.ts']),
3131
screenRecording: new Set([
32-
'src/daemon/screen-recording-session-binding.ts',
33-
'src/daemon/session-state.ts',
34-
]),
35-
perfCapture: new Set([
36-
'src/daemon/perf-capture-session-binding.ts',
32+
'src/daemon/session-capture-binding.ts',
3733
'src/daemon/session-state.ts',
3834
]),
35+
perfCapture: new Set(['src/daemon/session-capture-binding.ts', 'src/daemon/session-state.ts']),
3936
};
4037

4138
/** Durable session-resource records have one whole-record construction owner per domain. */

‎src/daemon/__tests__/perf-capture-session-resource.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bindSessionPerfCapture } from '../perf-capture-session-binding.ts';
1+
import { bindSessionPerfCapture } from '../session-capture-binding.ts';
22
import { beforeEach, expect, test, vi } from 'vitest';
33
import { localRuntimeOwner } from '@agent-device/contracts/platform-runtime';
44
import { AppError } from '@agent-device/kernel/errors';

‎src/daemon/__tests__/session-capture-binding.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, test } from 'vitest';
22
import { makeSessionStore } from '../../__tests__/test-utils/store-factory.ts';
33
import { makeRecordingSession } from './session-teardown.fixtures.ts';
4-
import { bindSessionScreenRecording } from '../screen-recording-session-binding.ts';
4+
import { bindSessionScreenRecording } from '../session-capture-binding.ts';
55

66
test('clearing a capture refreshes a rebuilt record without losing its other changes', () => {
77
const store = makeSessionStore();

‎src/daemon/audio-probe-session-binding.ts‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎src/daemon/handlers/record-runtime.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ import type { SessionStore } from '../session-store.ts';
3131
import type { BindDeviceRuntime, BindExactDeviceRuntime } from '../request-runtime-binding.ts';
3232
import type { DaemonRequest, DaemonResponse } from '../daemon-request.ts';
3333
import type { SessionRef, SessionState } from '../session-state.ts';
34-
import {
35-
bindRecordOnlyScreenRecording,
36-
bindSessionScreenRecording,
37-
} from '../screen-recording-session-binding.ts';
34+
import { bindRecordOnlyScreenRecording } from '../screen-recording-session-binding.ts';
35+
import { bindSessionScreenRecording } from '../session-capture-binding.ts';
3836
import { recordSessionAction } from '../session-action-recorder.ts';
3937
import {
4038
missingAppSessionResponse,

‎src/daemon/perf-capture-session-binding.ts‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎src/daemon/screen-recording-session-binding.ts‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
1-
import { bindSessionCapture } from './session-capture-binding.ts';
1+
import { bindSessionScreenRecording } from './session-capture-binding.ts';
22
import type { SessionRef } from './session-state.ts';
33
import type { SessionStore } from './session-store.ts';
44

5-
export function bindSessionScreenRecording(sessionStore: SessionStore, ref: SessionRef) {
6-
return bindSessionCapture(sessionStore, ref, {
7-
read: (session) => session.screenRecording,
8-
write: (screenRecording) => {
9-
sessionStore.update(ref, { screenRecording });
10-
},
11-
});
12-
}
13-
145
export function bindRecordOnlyScreenRecording(
156
sessionStore: SessionStore,
167
address: string,

‎src/daemon/session-capture-binding.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,30 @@ export function bindSessionCapture<K extends string, H extends AsyncDisposable>(
5151
},
5252
});
5353
}
54+
55+
export function bindSessionAudioProbe(sessionStore: SessionStore, ref: SessionRef) {
56+
return bindSessionCapture(sessionStore, ref, {
57+
read: (session) => session.audioProbe,
58+
write: (audioProbe) => {
59+
sessionStore.update(ref, { audioProbe });
60+
},
61+
});
62+
}
63+
64+
export function bindSessionPerfCapture(sessionStore: SessionStore, ref: SessionRef) {
65+
return bindSessionCapture(sessionStore, ref, {
66+
read: (session) => session.perfCapture,
67+
write: (perfCapture) => {
68+
sessionStore.update(ref, { perfCapture });
69+
},
70+
});
71+
}
72+
73+
export function bindSessionScreenRecording(sessionStore: SessionStore, ref: SessionRef) {
74+
return bindSessionCapture(sessionStore, ref, {
75+
read: (session) => session.screenRecording,
76+
write: (screenRecording) => {
77+
sessionStore.update(ref, { screenRecording });
78+
},
79+
});
80+
}

‎src/daemon/session-observability/internal/session-audio.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type {
2121
import type { SessionStore } from '../../session-store.ts';
2222
import type { DaemonRequest, DaemonResponse } from '../../daemon-request.ts';
2323
import type { SessionRef } from '../../session-state.ts';
24-
import { bindSessionAudioProbe } from '../../audio-probe-session-binding.ts';
24+
import { bindSessionAudioProbe } from '../../session-capture-binding.ts';
2525
import { type DaemonFailureResponse, errorResponse } from '@agent-device/kernel/contracts';
2626

2727
type AudioParams = {

0 commit comments

Comments
 (0)