feat(index): offline-first build + mcpp index status (WS3)#155
Merged
Conversation
… on TTL ensure_official_package_index_fresh no longer runs a network `xlings update` merely because a TTL expired. It now fetches ONLY when the local index entry for the package is MISSING (first run / never-seen package), so steady-state commands (mcpp build) work offline once init succeeded. Routine refresh is the user's explicit `mcpp index update`. Fixes the Termux first-run/build hang where every build git-synced several index repos and stalled for minutes on slow/blocked networks.
A read-only, network-free snapshot of the local indexes (xim + mcpplibs):
presence, freshness vs the search TTL, age since last refresh, and on-disk
path. When an index is missing it points at the explicit `mcpp index
update`; otherwise it confirms the local copy is usable offline.
Rounds out the offline-first model: build never auto-fetches on a TTL
(prior commit), and users get a cheap way to check/refresh on demand
instead of every command hitting the network.
- src/xlings.cppm: exported IndexStatus + {default,official}_index_status
(read-only; reuses the existing refresh-marker logic).
- src/pm/index_management.cppm: index_status() formats the table + hint.
- src/cli{,/cmd_registry}.cppm: wire `mcpp index status`.
- tests/e2e/75_index_status_offline.sh: guards presence-after-init +
the offline re-run invariant.
Refine the offline-first gate per review: fully offline is too strict. Keep the common case zero-network (dependency present in the local index), but when a requested dependency is NOT in the local index, refresh once to fetch it — instead of failing offline. - Announce it: the build path now calls with quiet=false, printing 'Refreshing package index — `<pkg>` not found locally (one-time)' so a rare one-time network pause doesn't look like a silent hang. Steady-state builds (deps present) still print nothing. - Guard against thrash: if the index was refreshed <120s ago and the package is still missing, upstream genuinely lacks it — don't re-run the heavy `xlings update` per missing package in one build. src/xlings.cppm: rework ensure_official_package_index_fresh. src/pm/package_fetcher.cppm: quiet=false at the call site. docs: correct the '稳态不再联网' wording to 'present→offline, missing→refresh once'.
Sunrisepeak
added a commit
that referenced
this pull request
Jun 23, 2026
Ships the WS3/WS5/WS6 + manifest work merged for this cycle: - offline-first miss-triggered index refresh + `mcpp index status` (#155) - first-init timestamped --verbose timing logs (#153) - install.sh linux-aarch64 + GitHub→GitCode(CN) mirror fallback (#154) - TOML-native namespaced self-host dep (#156) Bumps mcpp.toml + MCPP_VERSION together (test 01 ties --version to the manifest) and adds the 0.0.61 CHANGELOG entry. The .xlings.json bootstrap pin stays at 0.0.60 until 0.0.61 is published+mirrored+indexed (CI bootstraps from the published version), then bumps in a follow-up.
Sunrisepeak
added a commit
that referenced
this pull request
Jun 23, 2026
Ships the WS3/WS5/WS6 + manifest work merged for this cycle: - offline-first miss-triggered index refresh + `mcpp index status` (#155) - first-init timestamped --verbose timing logs (#153) - install.sh linux-aarch64 + GitHub→GitCode(CN) mirror fallback (#154) - TOML-native namespaced self-host dep (#156) Bumps mcpp.toml + MCPP_VERSION together (test 01 ties --version to the manifest) and adds the 0.0.61 CHANGELOG entry. The .xlings.json bootstrap pin stays at 0.0.60 until 0.0.61 is published+mirrored+indexed (CI bootstraps from the published version), then bumps in a follow-up.
Sunrisepeak
added a commit
that referenced
this pull request
Jun 24, 2026
…e-miss (#161) WS3's offline-first gate (ensure_official_package_index_fresh) refreshes the index only when the package *file* is missing locally. A stale-but-present index file that lacks the requested *version* slipped through: e.g. `mcpp toolchain install llvm@20.1.7` on a cached sandbox whose llvm.lua predates 20.1.7 resolved to 'package xim:llvm@20.1.7 not found' and never refreshed (ci-linux LLVM-toolchain step, post-#155). Fix: in the install-failure path (exitCode != 0), refresh the xim index ONCE before the existing direct-install retry. This is lazy refresh-on-miss — steady-state installs (package+version already local) succeed first try and never reach here, so they stay offline; an actual miss (package OR version) now triggers one refresh + retry. Honors the '缺包/缺版本就刷新一次' intent at the version level too. Build: clean self-host.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make steady-state mcpp commands offline-first, fixing the Termux first-run / build hang where every
mcpp buildgit-synced several index repos and stalled for minutes on slow/blocked networks.Changes
ensure_official_package_index_freshno longer auto-updates on TTL. It now fetches only when the local index entry is missing (first run / never-seen package). Once init has succeeded,mcpp builddoes no network I/O for the index. Routine refresh is the user's explicitmcpp index update.mcpp index status— read-only, fully offline. Shows each index's present/fresh/age/path; hintsmcpp index updatewhen one is missing, otherwise confirms the local copy is usable offline.src/xlings.cppm: exportedIndexStatus+{default,official}_index_status(reuses the existing refresh-marker logic; no network).src/pm/index_management.cppm:index_status()formats the table + hint.src/cli.cppm,src/cli/cmd_registry.cppm: wiremcpp index status.tests/e2e/75_index_status_offline.sh: guards present-after-init + the offline re-run invariant.Invariant
Any steady-state command works offline once init succeeded. First-init still guarantees an index (auto-fetch once if missing).
Test
mcpp buildself-host: green locally.mcpp index statussmoke-tested (fresh + missing paths).tests/e2e/75_index_status_offline.sh: OK.Part of the index-publishing-decoupling + offline-first effort. Design:
.agents/docs/2026-06-24-offline-first-index-and-mcpp-index-publish.md§4.1.