mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 12:27:28 +01:00
feat/parallel-implement
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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>
|
||
|
|
b71941be63 |
feat(providers): one-tap switch to a provider that still has quota (#757)
* feat(providers): one-tap switch to a provider that still has quota When the agent building a project hits a rate limit, the way out already existed — four other agent CLIs, most with untouched quota. Taking it was the problem. The only chooser lived in the Terminal right rail, it offered every agent in a fixed order whether or not the connected builder had it installed, and taking it swapped the live PTY without recording the choice, so the next dispatch went straight back to the agent that had just run out. One ranking, three surfaces: - src/lib/provider-switch.ts — the whole decision as pure functions. Ranks the operator's order, filters on two pieces of OBSERVED evidence (the builder's installed-agent report, and recent runs that died with capacity language), and holds the three-state rule provider_quota is built on: an agent nothing was reported about is unknown, and unknown reads as usable. Nothing is hidden — a provider that cannot answer still appears, disabled, saying why. 18 inline checks in scripts/test/provider-switch.ts. - GET /api/providers — that ranking, once, for every surface. Accepts either the user_projects id or the entity id, because the Feedback row holds one and Control/Terminal hold the other. - ProviderSwitch — "Try <next>" plus a menu of the rest, now the PRIMARY control on a Needs-you / Failed feedback row (Retry steps down beside it), in the Control inbox, and in the Terminal rail. And it sticks: POST /api/feedback/<id>/dispatch takes an `agent`, records it as the project's agentPref, then dispatches on it — no scavenger hunt through project settings. The order is the operator's, not the fleet's: user_preferences.agent_order (migration 0072, nullable and additive) with a reorder list in Settings → Agent. Null means "never stated", and the fleet default applies. Two SSOT repairs the work ran into: - AGENT_FALLBACK_ORDER was defined TWICE (agent-registry.ts and agent-resolution.ts) — the server reroute and the client reroute each read their own copy. agent-registry now re-exports the client-safe leaf. - QUOTA_ALTERNATIVE_AGENTS is derived from that order instead of being a second hand-written list of the same five ids. - TerminalRunView.alternatives is gone; quotaDeath stays as the flag that asks the shared chooser. provider_quota is deliberately NOT an input: it meters the ai-kit inference chain (groq, openrouter) behind Loki's own chat, not the agent CLIs. The agent-CLI equivalent is the run evidence above — observed, never probed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(providers): never offer the agent the project would actually run on Self-review caught a gap in the chooser's exclusion rule. It read "current" straight off `user_projects.agent_pref`, so a project that has never had a preference set reported no current agent at all — and dispatch does not work that way. Such a project still runs, on DEFAULT_ADAPTER_ID, which means the escape offered from a Claude Code rate limit could be Claude Code. currentProviderFor() answers the question the exclusion is actually asking — which agent just died — in the order the evidence deserves: 1. what this project LAST RAN on (freshest run inside the window). A stored preference can be stale by one switch; a run is what happened. 2. else its stored preference. 3. else the fleet default, because that is what the next dispatch picks. A run on an agent the chooser cannot offer (openclaw) is not "current" — it falls through rather than excluding nothing. Three more checks in scripts/test/provider-switch.ts, 21 total. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |