Skip to content

fix(tui): read the setup plan's NPU verdict in preflight (#6698) - #7124

Merged
kovtcharov-amd merged 3 commits into
amd:mainfrom
bniladridas:review/6698-preflight
Nov 13, 2026
Merged

kovtcharov-amd merged 3 commits into
amd:mainfrom
bniladridas:review/6698-preflight

Conversation

@bniladridas

@bniladridas bniladridas commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Preflight now reads the setup plan's npu verdict when it judges an NPU chat model, so a PC with no NPU and a PC whose NPU is present but not set up no longer read the same. The verdict is read only for FLM models, through an attach-only daemon, and a plan that omits the field or cannot be read keeps Lemonade's memory verdict with a readiness caveat rather than reading as an absent NPU.

Why

The preflight chat line could only judge gemma4-it-e4b-FLM from Lemonade's capacity report, which carries no NPU state. Every branch about the NPU was therefore inferred from memory alone, so the line could not name the server's own reason. The daemon's setup plan already answers this: build_plan() returns an npu field with present, ready and problems from the same checks in npu_linux.py that the Agent UI uses. The TUI's setup client never decoded it.

This is one part of #6698. It covers the preflight surface only. The setup picker and the local catalog are separate changes, and none of the three resolves the issue alone.

Linked issue

Refs #6698

This PR does not complete #6698. The NPU-less Linux check has not been run (see Outstanding), and the local catalog remains in #7125.

Changes

  • setupapi.Plan gains NPU *NPU, with Present, Ready and Problems (code, title, fix). params is deliberately not decoded: preflight never reads it. A pointer tells an omitted field apart from a reported absence.
  • readNPUVerdict returns the verdict plus a known flag. A plan that failed to load or omitted npu returns false, so the zero value never stands in for two different facts. This covers daemons before v0.25.4, which answer without the field; the attach-only client accepts them because their API major matches.
  • localFit asks for the verdict only when the chat model is an FLM model. A GGUF or other local model no longer pays for a plan read, let alone a daemon attach, to read an answer it ignores.
  • readNPUVerdict uses setupapi.NewAttachedDaemon() so drawing the first-run fit line does not start a daemon. A cold start falls back to Lemonade's capacity report.
  • fitLine keeps four states distinct: plan unreadable with no NPU memory figure ("could not be checked", claiming neither absence nor readiness), confirmed absent ("Lemonade reports none on this PC"), present but not ready (the server's first reason and fix, with a count of the rest, and the model stays listed), and ready (judged on NPU memory, as before).
  • When the plan is unreadable but Lemonade still reports NPU memory, the line keeps the memory fit decision and appends "Whether the NPU is set up could not be checked." The old "could not be checked" line remains for the case with no NPU memory either.
  • The second known flag in fitLine, about whether the model's size is known, is renamed knownSize now that the NPU verdict has its own.
  • One more fix in the same area: when the plan called the NPU ready but Lemonade reported no NPU memory, the line used to say "reports none on this PC", contradicting the plan it had just read. It now says the memory figure is missing instead.
  • Two comments in preflight/chat.go lost their em dashes.

Rebase

Rebased onto main at a7cb7dc9f, producing 285ad7362, dc19b5469, and 2ceecd59b. This rebase had no conflicts. The earlier rebase onto 6d27b91ff had one conflict in the import block in tui/internal/ui/preflight/chat.go; both setupapi and ui/components were kept, with no logic conflict.

Test plan

  • cd tui && go test ./internal/ui/preflight/... ./internal/setupapi/... -count=1 on head 2ceecd59b: preflight passed in 23.083s, setupapi passed in 0.508s.
  • cd tui && go test ./... -count=1 -race -timeout=15m on head 2ceecd59b: all TUI packages passed.
  • cd tui && gofmt -l . on head 2ceecd59b: no output.
  • cd tui && go vet ./... on head 2ceecd59b: exit 0 on darwin.
  • git diff --check on head 2ceecd59b: clean.
  • golangci-lint was not run on 2ceecd59b because it is not installed in this environment. The earlier v2.12.2 GOOS=linux run passed on 224657781; CI's Lint job is the check for this head.
  • Seven tests in fitline_npu_test.go pass, covering ready, present-not-ready, absent, unreadable, and the unreadable-with-memory case.
  • TestFitLineDoesNotClaimAbsenceWhenThePlanIsUnreadable fails when the !known guard is removed, with got "gemma4-it-e4b-FLM will not fit: it runs on a Ryzen AI NPU, and Lemonade reports none on this PC." That is the exact misleading line the fix removes.
  • npuverdict_test.go checks that a plan which answers reports known, and a plan that fails to load does not. TestLocalFitReadsTheNPUVerdictOnlyForAnNPUModel counts verdict reads for a GGUF model (0) and an FLM model (1).
  • TestNewAttachedDaemonNeverStartsOne pins the attach-only constructor used by the probe.
  • TestFitLineKeepsTheMemoryVerdictWhenReadinessIsUnknown checks the memory fit decision survives with the caveat, and the no-memory case still says readiness could not be checked.
  • TestReadNPUVerdictIsUnknownWhenThePlanOmitsNPU uses a plan with no NPU, checks known is false, and checks the line keeps "fits" with the caveat. TestDecodeLeavesAMissingNPUVerdictUnknown covers both an omitted field and explicit null.

Evidence

  • Agent exposed in the Agent UI (Chat, Email, ...) - N/A, this changes the Go TUI's first run screen, not the Agent UI.
  • MCP tools / servers - N/A, no tool surface changed.
  • CLI - N/A, no subcommand changed. The preflight screen is a TUI view and this was not captured on video.
  • HTTP API / REST - N/A, the Go client only reads a route that already exists; the wire shape it parses is pinned by the existing tests/unit/test_npu_linux.py::test_plan_reports_npu_problems.

Outstanding

  • NPU-less Linux end to end verification has not been run. Linux GOOS lint proves the code compiles for Linux; it says nothing about what the screen prints on a machine without a usable NPU. The new lines are proven against stubbed plans only.
  • The Linux acceptance check, when it runs, should confirm three things: a PC whose memlock limit is unmet shows the NPU as not ready, with that reason, in the place this PR covers; a PC with no NPU is reported as absent; and a PC whose setup plan cannot be read is reported as unknown, not as absent. Those three are the states this change keeps apart.
  • Wording is the server's, not the Agent UI's translation. The line shows the plan's title and fix verbatim and does not decode params. The Agent UI maps each problem code to its own localized sentence, and for memlock picks a different one depending on whether the fix is restart or stuck. The underlying reason is the same; the exact wording is not. Matching the Agent UI's code-aware copy is a decision for review, not a defect in this change.
  • The setup picker change merged in fix(tui): block NPU chat models this PC can't run yet (#6698) #7122; the local catalog remains in fix(tui): judge NPU models by the plan's verdict, not NPU memory (#6698) #7125. All three belong to TUI model picker offers the NPU model on a Linux PC whose NPU isn't set up #6698, which stays open.

Checklist

  • I have linked a GitHub issue above (Closes #N / Fixes #N / Refs #N).
  • I have described why this change is being made, not just what changed.
  • I have run linting and tests locally. This PR touches only the Go TUI, so the gates are gofmt, go vet and go test ./... under tui/; golangci-lint is covered by CI because it is not installed locally; util/lint.py --all and pytest tests/unit/ do not cover that module.
  • I have attached real-world evidence matched to the surface I changed (see Evidence above), or marked each surface N/A. All four surfaces are marked N/A; a TUI screenshot on a PC with an NPU was not produced.
  • I have updated documentation if user-visible behavior changed. No docs describe the preflight fit line, so no doc change was needed; say if a changelog entry is wanted.

@github-actions github-actions Bot added the tui Go terminal UI (gaia-tui) label Nov 10, 2026
@bniladridas

Copy link
Copy Markdown
Contributor Author

Recording a scope decision for review, not a request to change this PR.

This line shows the setup plan's title and fix as the server sends them, and does not decode params. The Agent UI goes further: it maps each problem code to its own localized sentence, and for memlock it picks a different sentence from params.fix being restart, stuck or apply.

On guidance specifically, the server already chooses between those memlock cases itself. _memlock_problem in src/gaia/llm/npu_linux.py emits a different title and fix for each of the three states, so this TUI shows the state-appropriate advice without reading params. What it does not reproduce is the Agent UI's own translations of those strings.

The question for reviewers: is guidance parity at the level of the sentence expected here, or is showing the server's English text enough? If the former, the change would be code-aware handling for memlock in both the preflight and the catalog, ideally one shared formatter. I have not added that, because without a stated requirement it would be scope beyond the issue.

The acceptance check on real Linux hardware is unaffected either way, and remains outstanding.

@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes

The TUI's first-run screen now tells apart three NPU cases that used to look the same: no NPU, an NPU that isn't set up yet (with the server's own reason), and a status that couldn't be read. The four-way logic is right and well tested. The problem is how the NPU status is fetched.

  • NPU users can lose their "fits" verdict on first run, and the check slows down for everyone. The status comes from the background service, which this check will start if it isn't running, with only 3 seconds to start it and build the plan. On a cold first launch that usually isn't enough, so a PC whose NPU works fine would now see "could not be checked" where it used to see "fits". The fetch also runs, and can start the service, on every check, even when the chat model doesn't run on the NPU and the answer is never used. Only fetch the status for NPU models, don't start the service just to read it, and when it can't be read, still show the memory verdict and say readiness wasn't checked.

Real-world evidence

N/A: no evidence bundle was produced for this run. The change is the Go TUI's first-run screen, and the PR marks every evidence surface N/A and says end-to-end Linux verification hasn't been done. This verdict rests on static review alone. I ran go test ./internal/ui/preflight/ ./internal/setupapi/... here and both packages pass. The cold-start case above isn't covered by those tests because they stub the plan out.

🔍 Technical details

🟡 The NPU read starts the daemon, runs on every check and has a 3 s budget (tui/internal/ui/preflight/chat.go:178, :186-197)

  • readNPUVerdict uses newSetupAPI(), which is setupapi.NewDaemon() and calls StartOrAttach. That means a status check spawns gaia daemon start. The repo only starts the daemon where it's warranted (see the comment on replayKeptKey, local.go:716-720).
  • The context is lemonadeProbeTimeout (3 s). A cold Python daemon start plus build_plan (which lists Lemonade models, reads system info and runs the npu_linux checks) will often go past that. The cold first-run screen is exactly when the daemon isn't up yet. Today gemma4-it-e4b-FLM on a working NPU gets fits: …. After this PR it gets could not be checked, which is a regression from the user's real starting state (CLAUDE.md, "Test from the user's real initial state").
  • localFit calls it before the -flm check, so a GPU chat model pays up to 3 s and a possible daemon spawn for a value fitLine ignores.

Suggested shape: read the verdict only for an FLM model, attach-only:

chat, ok := gaiainit.Status{Models: models}.Chat()
var npu setupapi.NPU
known := false
if strings.HasSuffix(strings.ToLower(chat.ID), "-flm") {
	npu, known = readNPUVerdict(ctx)
}
return fitLine(capacity, npu, known, chat, ok)

Then use setupapi.NewAttachedDaemon() in readNPUVerdict. In the !known branch, keep judging on c.NPU() memory and label it, for example "… fits on NPU memory (…); whether the NPU is set up could not be checked.". That stays honest (no claim of readiness) without dropping the verdict users have today. Add a test for "plan unreadable + NPU memory present" pinning the result.

🟢 The plan can itself report "absent" without observing it (src/gaia/ui/setup_plan.py:356-362, outside the diff)
_npu_status sets present=False when the plan's own capacity read is None, for example when Lemonade timed out during build_plan. The TUI then prints "Lemonade reports none on this PC", the unobserved-absence claim this PR set out to remove. That's out of scope here, but worth noting on #6698.

Strengths

  • The known flag keeps "plan unreadable" separate from "no NPU" instead of reusing the zero value. TestFitLineDoesNotClaimAbsenceWhenThePlanIsUnreadable was shown to fail without the guard.
  • Fixing the old "reports none" line when the plan says ready but Lemonade has no NPU memory removes a real contradiction.
  • Decoding only present/ready/problems keeps the Go client's contract minimal.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Thanks for turning the review around so cleanly. The probe now attaches to a running daemon instead of starting one, runs only for NPU models, and an unreadable plan keeps the memory verdict with a plain "could not be checked" caveat, so a working NPU no longer loses its "fits" line on a cold first run. Every point in the review is addressed on this head, and tests and lint pass.

Suggested order for the three #6698 PRs: #7122 and this one (independent, no conflicts), then #7125 after it drops its copy of the setupapi.NPU types.

🔍 Technical details
  • Verified on b41d2a1d5: go test ./... in tui/ passes; TestLocalFitReadsTheNPUVerdictOnlyForAnNPUModel and TestFitLineKeepsTheMemoryVerdictWhenReadinessIsUnknown pin the two review fixes.
  • The review's note that _npu_status reports present=False when its own capacity read fails is server-side and out of scope here.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

One gap left before merge: a GAIA daemon older than v0.25.4 makes an NPU model read as "Lemonade reports none on this PC", even on a PC whose NPU is working. That is the unobserved-absence claim this PR sets out to remove, and before this change the same PC got a memory "fits" verdict.

Suggested fix: treat a plan with no npu field as unknown, the same as an unreadable plan, and add a test for it.

🔍 Technical details
  • The plan's npu field arrived with fix(npu): lift Linux's 8 MB memlock cap so the NPU can load #6666 (first in v0.25.4). The attach-only client happily attaches to an older daemon (CheckVersion only gates the API major), so Plan decodes with NPU at its zero value and readNPUVerdictFrom returns known == true, Present == false. fitLine then takes the "reports none" branch.
  • A running daemon survives a TUI upgrade until it is restarted, so this is the state an upgrading user is in.
  • One shape: make the field NPU *NPU \json:"npu"`insetupapi.Plan, and in readNPUVerdictFromreturnsetupapi.NPU{}, falsewhenplan.NPU == nil. The daemon client already distinguishes absent from null the same way for older daemons (daemon/client.go`, the raw field read).
  • Test: a setupapitest.Fake plan with no NPU set reports known == false, and fitLine with NPU memory present still says "fits" with the "could not be checked" caveat.
  • Everything else checked out on b41d2a1d5: CI green, merges cleanly with main, go test ./... in tui/ passes, and the probe uses the attach-only client.

kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
…#7122)

## Summary

The TUI's setup picker no longer offers an NPU model as a chat choice on
a PC that can't run it: the row is hard-blocked, shows the server's
reason, and its caption stops claiming the model runs on the NPU.

## Why

On a PC whose NPU is absent or not set up, the picker listed the FLM
model as a normal chat option and let the user tick it. The download
then failed, because Lemonade's `ensure_npu_backend` refuses the pull
before any bytes move. The backend already knew: it marks the entry
`fits: false` with `fit_code: "npu"` and the reason in `fit_reason`. The
TUI dropped `fit_code`, and every warning path in the picker required
both memory numbers, which the NPU verdict leaves empty: so the row got
a bare "won't fit" chip and stayed selectable.

This is the picker's share of amd#6698. It is not the whole issue; see
"Scope" below.

## Linked issue

Refs amd#6698

## Changes

- `setupapi.CatalogEntry` carries `FitCode`, `fit_code`, the
machine-readable reason the backend already sends alongside
`fit_reason`.
- A row with `fits: false` and `fit_code: "npu"` is hard-blocked rather
than acknowledgement-gated, because nothing on this PC can pull it.
Memory shortfalls (`fit_code: "memory"`) keep the existing
confirm-and-continue path, which can still download a model. `backend`
fit is untouched.
- The block covers every route to the chat model. `canChat` was not
enough on its own: first-run mode picks chat through `pickChat`, and an
installed row's toggle sets the chat model directly. Both are now
guarded, and `pending()` keeps a blocked model out of the download set
even when the plan delivered it ticked.
- The blocked row shows the server's `fit_reason` as its own clause: the
first letter is capitalised, a final full stop is removed even inside a
closing parenthesis, and exactly one stop is appended. The backend's
"this Lemonade cannot run flm models" reason no longer reads "it this".
- The blocked row's job caption reads "Requires a Ryzen AI NPU that is
ready on this PC." instead of implying the model currently runs.
- The recommendation star is suppressed on blocked rows.

## Test plan

- [x] `gofmt -l .` in `tui/`: no output
- [x] `go vet ./...` in `tui/`: exit 0
- [x] `go test ./... -count=1 -race -timeout=15m` in `tui/`: all 29
packages passed on head `99e6dd229`
- [x] `golangci-lint run` at v2.12.2 with `GOOS=linux` (as the Lint job
runs it): 0 issues on head `c735e789`; not rerun on `99e6dd229` because
it is not installed in this environment, so CI's Lint job is the check
for the new head

Seven tests added in `tui/internal/ui/modelsetup/flow_test.go`, plus
fixtures in `helpers_test.go`:

- `TestUnreadyNPUModelIsBlockedNotAcknowledged`: chip shown, star
suppressed, no memory warning invented
- `TestUnreadyNPUModelShowsEachReasonVerbatim`: four server reasons (no
NPU, NPU not set up, backend cannot run FLM, and a driver message
already ending in a stop) render as a clause with exactly one full stop
- `TestUnreadyNPUModelCaptionDoesNotSayItRuns`: caption wording
- `TestUnreadyNPUModelIsNeverTheChatModel`: not a chat candidate, and
space on an installed row does not make it the chat model
- `TestUnreadyNPUModelCannotEnterTheDownloadSet`: space cannot tick it,
and it stays out of `pending()` when the plan delivered it already
ticked
- `TestCloudPickerUnaffectedByNPUBlock`: cloud chat candidates unchanged
- `TestMemoryUnfitModelStillAsksAndCanBeConfirmed`: the memory
acknowledgement path is unchanged

## Evidence

- [ ] **Agent exposed in the Agent UI** (Chat, Email, ...): N/A, no
Agent UI change.
- [ ] **MCP tools / servers**: N/A, no MCP change.
- [x] **CLI**: the setup picker rendered from a stubbed setup plan, both
NPU cases:

```
===== NPU present, not ready (focus on gemma4-it-e2b-FLM) =====
  Choose your models                                 step 2 of 2 · part 1 of 3
  ────────────────────────────────────────────────────────────────────────────
  Chat
    (•) Gemma-4-E4B-it         Verified 6.0 GB    * recommended
    ( ) Qwen3.6-35B-A3B        Verified 23.3 GB   [!] won't fit
    [ ] Already in Lemonade (press l to hide)
  > ( ) gemma4-it-e2b-FLM      Untested on PC     [!] won't fit NPU
        Requires a Ryzen AI NPU that is ready on this PC.
        [!] This model can't be used on this PC: Needs this PC's NPU set up
        first: Locked-memory limit is too low. Raise the limit.

===== No NPU on this PC (focus on gemma4-it-e2b-FLM) =====
  > ( ) gemma4-it-e2b-FLM      Untested on PC     [!] won't fit NPU
        Requires a Ryzen AI NPU that is ready on this PC.
        [!] This model can't be used on this PC: Runs on a Ryzen AI NPU,
        and Lemonade reports none on this PC.
```

**Not validated on real NPU hardware.** This was developed on macOS,
which has no Ryzen AI NPU and no Lemonade server, so the picker was
driven against the stub plan in `setupapi/setupapitest` rather than a
live Linux NPU machine. A maintainer should confirm the messages on a
Linux PC with an NPU before relying on them.

- [ ] **HTTP API / REST**, N/A, no endpoint changed.

## Scope

This PR fixes the setup model picker only. amd#6698 also names
`Capacity.NPU()` (`tui/internal/lemonade/capacity.go`), the local
catalog judge (`tui/internal/lemonade/catalog.go`) and the chat
preflight (`tui/internal/ui/preflight/chat.go`). Those surfaces still
judge an FLM model by memory alone in `main`, but separate PRs now
address them: amd#7124 changes the preflight and amd#7125 changes the local
catalog. This PR does not touch them, so amd#6698 is not closed here.

## Checklist

- [x] I have linked a GitHub issue above (`Refs amd#6698`).
- [x] I have described **why** this change is being made, not just what
changed.
- [ ] I have run linting and tests locally (`python util/lint.py --all`,
`pytest tests/unit/`): N/A, this PR changes no Python. The Go gates are
in the test plan.
- [x] I have attached **real-world evidence matched to the surface I
changed**, or marked each surface N/A.
- [ ] I have updated documentation if user-visible behavior changed:
N/A, the picker's copy is self-describing and no docs describe the old
behaviour.

---------

Signed-off-by: Niladri Das <[email protected]>
@kovtcharov-amd kovtcharov-amd added bug Something isn't working npu Ryzen AI NPU: FastFlowLM, NPU models, memlock, NPU runners labels Nov 12, 2026
…reflight could only judge an NPU chat model from Lemonade's capacity report, which carries no NPU state at all, so a PC whose NPU was absent and one whose NPU was there but not set up read the same. The daemon's setup plan already answers this in its `npu` field, with the same checks `npu_linux.py` applies, but the TUI's setup client never decoded it. The chat line now reads that verdict, and keeps four states apart that were previously two: an unread plan says the NPU could not be checked, an absent one says Lemonade reports none, one that is present but not ready shows the server's own reason and fix, and a ready one is judged on NPU memory as before. The unreadable case has its own flag rather than a zero struct, because a plan that failed to load is not evidence that the PC has no NPU, and the line must not claim absence it did not observe. The same confusion turned up one branch later: a plan that called the NPU ready plus a capacity report with no NPU memory used to print "reports none on this PC", contradicting the plan it had just read, and now says the memory figure is missing instead. This is the preflight half of the issue; the picker is fixed in amd#7122. Refs amd#6698

Signed-off-by: Niladri Das <[email protected]>
Preflight read the setup plan for every local model, could start a daemon on a first-run screen, and dropped Lemonade's memory verdict whenever the plan was unreadable. The verdict is now read only for FLM models, through an attach-only daemon constructor, and an unreadable plan keeps the memory fit decision with a readiness caveat. Tests cover the non-FLM skip, the attach-only constructor, and the unreadable-plan memory path. Refs amd#6698

Signed-off-by: Niladri Das <[email protected]>
A daemon before v0.25.4 answers the setup plan without an npu field, and the attach-only client accepts such a daemon. The zero-value verdict made a working NPU read as "Lemonade reports none on this PC". The plan's NPU field is now a pointer, so a missing or null field keeps the readiness answer unknown, and the fit line retains Lemonade's memory verdict with the "could not be checked" caveat. Regression tests decode the old plan shape and check the memory line end to end. Refs amd#6698

Signed-off-by: Niladri Das <[email protected]>
@bniladridas
bniladridas force-pushed the review/6698-preflight branch from 2246577 to 2ceecd5 Compare November 13, 2026 02:53
@kovtcharov-amd kovtcharov-amd added the p2 low priority label Nov 13, 2026
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 13, 2026
Merged via the queue into amd:main with commit 43cdadd Nov 13, 2026
101 of 104 checks passed
kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Nov 14, 2026
…#6698) (amd#7125)

## Summary

The local model catalog now judges NPU models by the setup plan's NPU
verdict instead of by NPU memory, so a PC with no NPU, one whose NPU is
not set up, and one whose setup plan could not be read are told apart
rather than collapsed into "no NPU". A downloaded FLM model on an NPU
that is known not ready is blocked with the server's reason, while an
unreadable plan falls back to the memory verdict and keeps a downloaded
model selectable. A confirmed-absent NPU hides the unlisted
recommendation instead of showing it as a broken option. An unknown
verdict hides that recommendation too when Lemonade reports no NPU
memory, because the row could never be selected.

With amd#7124 merged, this branch now uses the shared `setupapi.NPU` types
and treats a plan without an `npu` field as unknown.

## Why

`Capacity.NPU()` reports NPU memory, and the catalog treated a report of
none as a PC with no NPU. That figure is zero both for a PC that has no
NPU and for one whose NPU Lemonade did not measure, so an unreadable
machine produced the same rows, with the same claim of absence, as one
known to have none. Two consequences followed: an NPU model could be
offered for download on a PC whose NPU cannot run it, and an NPU
recommendation was silently dropped when no NPU memory was reported, so
the row could not explain itself. The first version of this change also
read the plan for cloud providers and let an unreadable plan block a
model already on disk; both are corrected here.

The setup plan already answers this. This PR carries that answer into
the catalog.

This is one part of amd#6698. The provider picker and the preflight screen
are separate surfaces with separate changes.

## Linked issue

Refs amd#6698

This PR does not complete amd#6698. The NPU-less Linux check has not been
run (see Outstanding), and the preflight surface landed in amd#7124.

## Changes

- `lemonade.NPUVerdict` carries `Present`, `Ready`, `Known` and the
server's `Reasons`. `Blocks()` returns a reason only for a known absent
or known not-ready verdict; ready and unknown leave the memory rule in
charge.
- `Catalog` and `BuildEntries` take the verdict as a new parameter,
placed before the existing variadic `added`. Existing callers pass it
explicitly.
- `BuildEntries` checks the verdict before the checks that decide
whether a download is needed, because readiness is about the hardware
and not the file. Ready keeps the memory rule; present-but-not-ready
blocks with the server's own reason and fix; absent keeps the absence
line; unknown falls through to memory rather than claiming absence or
permission.
- `Selectable()` keeps a downloaded model selectable unless a known
verdict set `FitUnknown`. That blocks a downloaded FLM model on a known
not-ready or known absent NPU, and keeps it selectable when the plan is
unknown.
- A confirmed-absent NPU hides an unlisted NPU recommendation, because
there it is not an option. A not-ready NPU keeps the row so its reason
stays visible. An unknown verdict keeps it when NPU memory is reported
and leaves it to the memory rule; with no NPU memory, it hides the row
as before.
- `providers.loadCatalog` reads the plan only for the local provider,
through `setupapi.NewAttachedDaemon()`, so a cloud catalog neither reads
the plan nor starts a daemon for it. A plan that cannot be read becomes
unknown, never absent.
- `readNPUVerdictFrom` treats `plan.NPU == nil` as an unknown verdict. A
daemon older than v0.25.4 sends no `npu` field, so its plan must not
read as a PC without an NPU.
- Existing tests that asserted memory-as-presence were updated: the
no-NPU recommendation is hidden, the unknown verdict follows memory, and
downloaded FLM rows are blocked only by a known verdict.

## Integration with main

amd#7124 merged as `43cdaddc`, so this branch merged `main` at `4c5d11bcb`
and dropped its duplicate `setupapi.NPU` and `setupapi.NPUProblem`
types. The plan's `NPU` is now the shared `*setupapi.NPU`, which is
`nil` when the daemon omits the field.

The merge keeps main's `OnlyProvenNPU` filter after the verdict-aware
catalog build, so the amd#7975 rule still applies to the merged entries.
`TestOnlyProvenNPUModelsAreOffered` was updated to pass the verdict
parameter.

`TestAnOlderPlanWithoutAnNPUFieldLeavesADownloadedFLMModelSelectable`
decodes a plan with no `npu` field, asserts the verdict is unknown, and
asserts a downloaded FLM model on a PC with enough memory stays
selectable. Removing the `plan.NPU == nil` guard makes that test panic,
and restoring the guard makes it pass.

## Review follow-up

Fixed in `9bae0f1b4`.

An unknown NPU verdict now hides an unlisted recommendation when no NPU
memory is reported. Unknown verdicts with reported NPU memory still
defer to the memory check. Added regression coverage for both missing
and unreadable memory.

## Test plan

The full local suite passed on the merge head `4c5d11bcb`, and the full
CI run passed on `9bae0f1b4` (`TUI Build and Test`, run 43461799707).
The review fix on `9bae0f1b4` also passed the focused tests and checks
below.

- [x] `cd tui && go test ./... -count=1` on head `4c5d11bcb`: every TUI
package passed.
- [x] `cd tui && go test ./internal/lemonade/...
./internal/ui/providers/... -count=1` on head `9bae0f1b4`: both packages
passed.
- [x] `cd tui && gofmt -l .` on head `9bae0f1b4`: no output.
- [x] `cd tui && go vet ./...` on head `9bae0f1b4`: exit 0 on darwin.
- [x] `git diff --check` on head `9bae0f1b4`: clean.
- [x] Mutation check on the nil guard: without `plan.NPU == nil` the
older-daemon regression panics, and with it restored the test passes.
- [x] Mutation check on the new recommendation condition: without it
both unknown-verdict cases fail, and with it restored they pass.
- [x] `cd tui && go test ./... -count=1 -race -timeout=15m` on head
`84952d9a8`, and CI's race-enabled suite on `4c5d11bcb` and `9bae0f1b4`:
all TUI packages passed.
- [x] golangci-lint v2.12.2 with `GOOS=linux` reported `0 issues` on an
earlier head, and CI's Lint job passed on `4c5d11bcb` and `9bae0f1b4`.
- [x] `catalog_verdict_test.go` covers ready, known not ready, known
absent, and unknown. The unknown cases check a fitting memory report, a
tight one, and the downloaded case.
- [x] `TestCloudCatalogDoesNotReadTheNPUPlan` counts zero verdict reads
for a cloud provider.
- [x] `TestAConfirmedAbsentNPUHidesAnUnlistedNPURecommendation` checks
the absent case, `TestAnUnlistedNPURecommendationStaysWithItsReason`
keeps the not-ready case visible, and
`TestAnUnknownVerdictWithNoNPUMemoryHidesTheRecommendation` covers
missing and unreadable memory.
- [x] `providers/verdict_test.go` checks the plan-to-verdict wiring,
that an unreadable plan keeps the memory verdict rather than claiming
absence, and that a plan without an `npu` field leaves a downloaded FLM
model selectable.

## Evidence

- [ ] **Agent exposed in the Agent UI** (Chat, Email, ...) - N/A, this
changes the Go TUI's model picker, not the Agent UI.
- [ ] **MCP tools / servers** - N/A, no tool surface changed.
- [ ] **CLI** - N/A, no subcommand changed. The picker is a TUI view and
this was not captured on video.
- [ ] **HTTP API / REST** - N/A, the change reads a plan route that
already exists; its wire shape is pinned by the existing
`tests/unit/test_npu_linux.py::test_plan_reports_npu_problems`.

## Outstanding

- **NPU-less Linux end to end verification has not been run.** Every
verdict in the tests is a stub. Nothing here shows what the picker
displays on a real machine whose NPU is absent, unready, or not
measurable.
- **The Linux acceptance check, when it runs, should confirm three
things:** a PC whose memlock limit is unmet shows the NPU as not ready,
with that reason, in the place this PR covers; a PC with no NPU is
reported as absent; and a PC whose setup plan cannot be read is reported
as unknown, not as absent. Those three are the states this change keeps
apart.
- **Wording is the server's, not the Agent UI's translation.** The line
shows the plan's `title` and `fix` verbatim and does not decode
`params`. The Agent UI maps each problem `code` to its own localized
sentence, and for `memlock` picks a different one depending on whether
the fix is `restart` or `stuck`. The underlying reason is the same; the
exact wording is not. Matching the Agent UI's code-aware copy is a
decision for review, not a defect in this change.
- The verdict is a positional parameter with a safe unknown default. A
future caller that omits it silently gets unknown rather than a compile
error. That is deliberate for this change and left for a later API
cleanup.

## Checklist

- [x] I have linked a GitHub issue above (`Closes #N` / `Fixes #N` /
`Refs #N`).
- [x] I have described **why** this change is being made, not just what
changed.
- [x] I have run the available local checks and tests. This PR touches
only the Go TUI, so the gates are `gofmt`, `go vet`, the pinned
golangci-lint and `go test ./...` under `tui/`; `util/lint.py --all` and
`pytest tests/unit/` do not cover that module. The pinned golangci-lint
check remains for CI.
- [ ] I have attached **real-world evidence matched to the surface I
changed** (see Evidence above), or marked each surface N/A. All four
surfaces are marked N/A; a picker screenshot on a PC with an NPU was not
produced.
- [ ] I have updated documentation if user-visible behavior changed. No
docs describe the catalog fit rules, so no doc change was needed; say if
a changelog entry is wanted.

---------

Signed-off-by: Niladri Das <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working npu Ryzen AI NPU: FastFlowLM, NPU models, memlock, NPU runners p2 low priority tui Go terminal UI (gaia-tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants