Files
loki/scripts
CatoandClaude Opus 5 7cbdbf0db5 fix(providers): scope the installed list to the builder that would run it (#790)
Risk 2 of the 2026-09-17 review: /api/providers read
getRuntimeSnapshot(userId) — no channel.

That function's own doc says what the channel-less form returns:
"whichever channel pushed last". Both builders push their own row every
~5 minutes, so which machine's capability report the chooser saw was
decided by a race between two heartbeats. A cloud push could make a
laptop-only agent read "not installed"; a laptop push did the same to
the box. The chooser DISABLES rows on that evidence, so this was a
confident claim about a different computer.

The project already knows where it would dispatch —
pickDispatchChannel() is the SSOT for that decision — so now we ask that
channel. Without a project there is no "the" builder, so the honest
input is the union across this user's builders: an agent installed on
ANY of them is launchable somewhere, and only an agent no builder
reports is genuinely absent.

Unknown stays unknown. No row for a channel means null, not [] — the
three-state rule this module is already built on. Rendering silence as
"none installed" would disable every alternative, which is the one
control the operator came to that row for.

And the claim is now stamped. `evidence: { channel, observedAt }` rides
along, and the chooser says "Installed list as observed on This computer
(Fleet Runner), 4m ago" — or, when nothing has reported, that
availability here is unknown rather than empty. A capability claim with
no machine and no time reads as "true now, everywhere"; it is neither.

Lint caught a real defect mid-change: describeProviderEvidence took a
`now` it never used, because the phrasing comes from timeAgo(), which
reads the clock itself. A parameter the function ignores is worse than
none — it makes a test look deterministic when it isn't — so it is gone
rather than papered over with an underscore.

Tests: three cases, proved by mutation — disabling the unknown branch
fails "The input did not match /unknown, not empty/". tsc clean, lint 0
errors, test:unit 204/204.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 09:31:50 -07:00
..
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00
2026-08-31 09:23:30 +00:00