Skip to content

fix(platform): keep the network out of package-manager reads - #549

Merged
David-Noble-at-work merged 1 commit into
developfrom
package-manager-present
Aug 18, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
package-manager-present

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

The bug

TestResolveWithConfidence_NativePackage hung twice in one day on ubuntu, each time killing its whole
package's verdict:

panic: test timed out after 2m0s
running tests:
    TestResolveWithConfidence_NativePackage (1m59s)
FAIL  github.com/NobleFactor/devlore-cli/cmd/internal/lorepackage  120.050s

No --- FAIL: line, because the binary panicked rather than any test failing.

It was sitting in apt-get update. A GitHub runner appears to ship with its apt lists cleaned -- inferred from
the fact that every workflow installing a deb must run apt-get update first, ours included; I have not
confirmed it on a runner. Either way indexAgeOf stats nothing, returns the unknownIndexAge sentinel of a
year, and the 24h gate fires on every run. Not a stall -- a cold, complete fetch of every source the image
carries. Unremarkable in itself; wrong only in where it was triggered from.

Two fixes

1. Confidence no longer consults an index.

ResolveWithConfidence used router.Available(purl) to pick ConfidenceMedium over ConfidenceLow -- asking
a per-package question to answer a per-machine one, so the fact was re-derived once per package at a subprocess
each. PackageManager gains Present(): an exec.LookPath over a new rawDriver.executable(), supplied by
each of the eight leaves.

apt reports apt-get -- what it actually shells out to, and the interface Debian declares stable for
scripts. The router reports any leaf present, since a host with flatpak but not apt can still install
natively.

2. The staleness gate distinguishes absence from age.

Needs an index Needs it fresh
Install / Upgrade Yes Yes -- resolve a specific version
Available / Search Yes No -- tokenFor returns p.Name, no version
Installed / Version No No -- local state (already ungated)

Age costs the queries nothing: names and descriptions barely churn. Absence costs them everything, and
silently
-- with no index Available reports false for every package, which a caller cannot distinguish
from "no such package".

The rule: refresh when the index is absent, or when the operation is a mutator. Never merely because it is
old.

Not test-only

lore search reaches searchNative, and compositeManager.Search fans out to every leaf rather than
routing to one -- so each refresher leaf gated its own refresh. An interactive command blocking on a network
fetch with nothing on screen.

Also

Removes VerifySyntheticPackage -- no callers anywhere, tests included -- and with it one of the three sites
that detect the host directly instead of asking the runtime environment. The two survivors are both Registry
methods in search.go, now tracked under #446.

Verified

  • make check -- exit 0, zero FAIL lines
  • present_test.go: driver resolves a present binary, rejects a missing one; router reports any-leaf-present
    across four cases
  • update_test.go: mutators still refresh on a stale index; queries no longer do; both refresh on a missing one

Refs #439 rather than Fixes: that issue is the class, and its charter requires enumerating every
network-reaching test before a fix is designed. This is one instance, which was not on its list.

TestResolveWithConfidence_NativePackage hung twice in one day on the ubuntu leg, each time taking the whole
package down with it: 119s, no --- FAIL: line, because the test binary's 2m deadline expired while the process
sat inside apt-get update.

A GitHub runner appears to ship with its apt lists cleaned -- inferred, not measured, from the fact that every
workflow installing a deb must run apt-get update first, ours included. Whatever the cause, indexAgeOf stats
nothing, returns the unknownIndexAge sentinel of a year, and the 24h staleness gate fires on every run. The
refresh was not a stall; it was a cold, complete index fetch of every source the image carries. Two minutes for
that is unremarkable. Only its position was wrong.

Two fixes, both narrowing what a read is allowed to do.

Confidence no longer consults an index. ResolveWithConfidence asked router.Available(purl) to choose between
ConfidenceMedium and ConfidenceLow, which made a per-machine fact -- is there a package manager here -- get
re-derived once per package, at a subprocess each. PackageManager gains Present(), an exec.LookPath over a new
rawDriver.executable() that each of the eight leaves supplies. Note apt reports apt-get: that is what it shells
out to and what Debian declares stable for scripts. The router reports any leaf present, since a host with
flatpak but not apt can still install natively.

The staleness gate now distinguishes absence from age. Install and Upgrade resolve a specific version, so a
lagging index installs a superseded build or fetches one the mirror has withdrawn -- they keep the age gate.
Available and Search name no version (tokenFor returns p.Name), so age costs them nothing: package names and
descriptions barely churn. Absence costs them everything, and silently -- with no index Available reports false
for every package, indistinguishable from "no such package". So queries refresh for absence only, where the
alternative is a confident wrong answer rather than a slightly old one.

The rule, now in one line: refresh when the index is absent, or when the operation is a mutator; never merely
because it is old.

Also removes VerifySyntheticPackage, which had no callers anywhere including tests, and with it one of the
three sites that detect the host directly instead of asking the runtime environment for it.

This was never test-only. lore search reaches searchNative, and compositeManager.Search fans out to every leaf
rather than routing to one, so each refresher leaf gated its own refresh -- an interactive command blocking on
a network fetch with nothing on screen.

Refs #439.
@David-Noble-at-work David-Noble-at-work self-assigned this Aug 18, 2026
@David-Noble-at-work
David-Noble-at-work merged commit 4976c10 into develop Aug 18, 2026
7 of 8 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the package-manager-present branch August 19, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant