Commit a947817
committed
feat(pm): refresh the package index on a resolution miss, not on a timer (2026.7.30.3, fixes #315)
`mcpp build/run/test` refreshed the index whenever its marker was older than
an hour — a multi-repo `xlings update` (with 3 retries and 2s/4s backoff) run
whether or not anything was missing. On a slow or blocked network that is
minutes of waiting, once an hour, for data already on disk.
The offline-first policy was not missing: xlings.cppm's xim install gate has
had it for a while, and its comment names this exact symptom. prepare.cppm's
TTL gate simply fired first, making that policy unreachable. The same decision
was being derived in five places, two of which contradicted each other.
One source of truth now: mcpp.pm.index_refresh. build / add / the xim gate /
the install-failure retry all route through it. A refresh happens when there is
no local index, when a descriptor is missing from it, or when a SemVer
constraint matches none of the versions it knows — never merely because time
passed. Builds whose dependencies resolve locally make no network request.
Why the axis changed: "is the index fresh enough" is unanswerable and mtime is
a poor proxy (restored CI caches, clock skew, tars that preserve timestamps all
make the marker lie in both directions). "Can the resolver work with what is on
disk" IS answerable offline — every resolution input is a local file. The marker
is now only a debounce timer.
The load-bearing rule (SuppressedInconclusive): a miss means nothing unless the
index that would have answered is authoritative. xim descriptors declare no
namespace, so (xim, x) can never match the identity gate — counting that as a
miss would refresh on EVERY build with a toolchain-ish dependency, strictly
worse than the TTL being removed. Judgement reused from IndexRoute (#307),
locked by a unit test and by e2e 173 step 3.
Also in this change:
- `mcpp update` stops being a no-op. It only dropped lock entries and told the
user to run `mcpp build`, but the build path never reads mcpp.lock, so it
changed nothing at all. It now forces an index refresh (explicit intent: no
TTL, no debounce) and reports the revision change; skipped when nothing in
the project is served by the shared registry.
- `--offline` / MCPP_OFFLINE: no index refresh, no downloads, no toolchain
auto-install. Checked at the point of download, so an offline build with its
dependencies present still succeeds. MCPP_NO_AUTO_INSTALL stays accepted as
the older, narrower spelling — one concept had three names.
- `[index] auto_refresh` in the global config. Deliberately a boolean, not a
three-valued mode: keeping the old TTL path alive to emulate a policy being
deleted is how this debt accumulated. Policy lives in the global config, not
mcpp.toml — it describes the machine's network, and a project carrying it
would stop being portable between a LAN, a laptop and CI.
- A marker stamped in the future read as "fresh" forever (age < ttl is true for
negatives). Unusable timestamps now mean unknown, and unknown means stale.
- The index sync had no concurrency guard while the BMI cache has had one for
a while. Non-blocking: whoever holds the lock is already doing the work, and
a queue of stalled builds is the symptom this change exists to remove.
- mark_known_indexes_refreshed bailed out under a project-scoped env, so
machines with custom [indices] never recorded a refresh at all.
- `mcpp index status` grows a revision column. .xlings-index-version is the
index's content identity (artifact names carry it: mcpp-index-8d67478.tar.gz)
and mcpp had zero references to it. Treated as an opaque string — probing
showed sub-indexes carry a date version, not a sha.
- Resolution failures now carry the index revision and age plus the explicit
`mcpp index update` hint, so "no such package" and "your index is from last
month" stay distinguishable once refreshes are lazy.
Semantic change, documented in docs/05-mcpp-toml.md: `^1.2` resolves against
the versions your local index knows. A 1.3.0 published upstream since your last
refresh needs `mcpp index update` or `mcpp update` — which is what those
commands are for.
Design + probe results: .agents/docs/2026-07-30-issue315-index-refresh-policy-design.md1 parent d79ab00 commit a947817
19 files changed
Lines changed: 1919 additions & 66 deletions
File tree
- .agents/docs
- docs
- zh
- src
- build
- platform
- pm
- toolchain
- tests
- e2e
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
0 commit comments