Skip to content

feat(index): offline-first build + mcpp index status (WS3)#155

Merged
Sunrisepeak merged 4 commits into
mainfrom
feat/offline-first-index
Jun 23, 2026
Merged

feat(index): offline-first build + mcpp index status (WS3)#155
Sunrisepeak merged 4 commits into
mainfrom
feat/offline-first-index

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

What

Make steady-state mcpp commands offline-first, fixing the Termux first-run / build hang where every mcpp build git-synced several index repos and stalled for minutes on slow/blocked networks.

Changes

  • ensure_official_package_index_fresh no 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 build does no network I/O for the index. Routine refresh is the user's explicit mcpp index update.
  • New mcpp index status — read-only, fully offline. Shows each index's present/fresh/age/path; hints mcpp index update when one is missing, otherwise confirms the local copy is usable offline.
    • src/xlings.cppm: exported IndexStatus + {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: wire mcpp index status.
  • e2e 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 build self-host: green locally.
  • mcpp index status smoke-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.

… 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 Sunrisepeak merged commit c86d527 into main Jun 23, 2026
4 checks passed
@Sunrisepeak Sunrisepeak deleted the feat/offline-first-index branch June 23, 2026 23:06
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.
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