Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion packages/user-intent-kit/src/adapters/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class DesktopAdapter {
#kind;
#model;
#modelProbe;
#hostSources;
#availabilityProbe;
#pollIntervalMs;
#publisher;
Expand All @@ -43,11 +44,18 @@ export class DesktopAdapter {
*/
constructor(client, {
pollIntervalMs = 30000, machine, kind, model, modelProbe, availabilityProbe,
hostSources,
} = {}) {
this.#client = client;
this.#machine = machine ?? client?.deviceId ?? undefined;
this.#kind = kind;
this.#model = model;
// Telemetry sources are injectable for the same reason they are in
// host-telemetry.js: on Linux the default sources read /proc, and a test
// machine that happens to run a llama-server would publish its model into
// every heartbeat a test builds — passing suites that quietly depend on
// an empty machine are the same bug as skipped ones.
this.#hostSources = hostSources;
// Order matters: the served-model probe's generation guard is wired to
// the disk scan, so the scan has to exist first. Without the guard a probe
// could ask a server to generate with a model that is half downloaded,
Expand Down Expand Up @@ -189,7 +197,7 @@ export class DesktopAdapter {
screen_active: active,
context: active ? 'active' : 'idle',
...(idleSec === undefined ? {} : { idle_sec: idleSec }),
...collectHostTelemetry({ machine: this.#machine, kind: this.#kind, model: this.#servedModel() }),
...collectHostTelemetry({ machine: this.#machine, kind: this.#kind, model: this.#servedModel(), sources: this.#hostSources ?? undefined }),
// The weaker claim, in its OWN keys. `model` still means served and
// nothing else, so a dashboard that has never heard of availability
// cannot start rendering "this box could run it" as "this box is
Expand Down
7 changes: 5 additions & 2 deletions packages/user-intent-kit/test/served-model.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ test('a heartbeat publishes before the probe has answered anything', async () =>
patchDevice: async (state) => { patched.push(state); },
startHeartbeat() {}, stopHeartbeat() {},
};
const desktop = new DesktopAdapter(client, { machine: 'macbook', modelProbe: probe, pollIntervalMs: 1e9 });
const desktop = new DesktopAdapter(client, { machine: 'macbook', modelProbe: probe, pollIntervalMs: 1e9, hostSources: macSources() });

// The whole point: this awaits nothing on the network.
await desktop.publishState();
Expand Down Expand Up @@ -623,7 +623,10 @@ async function stateFrom(opts) {
patchDevice: async (state) => { patched.push(state); },
startHeartbeat() {}, stopHeartbeat() {},
};
const desktop = new DesktopAdapter(client, { machine: 'testbox', pollIntervalMs: 1e9, ...opts });
// Faked sources by default: on Linux the real ones read /proc, and a box that
// happens to run a llama-server would leak its model name into every test
// payload — the suite must say the same thing on every machine.
const desktop = new DesktopAdapter(client, { machine: 'testbox', pollIntervalMs: 1e9, hostSources: macSources(), ...opts });
await desktop.publishState();
desktop.stop();
return patched[0];
Expand Down
Loading