|
| 1 | +# Index Refresh And Dependency Cache Label Fix |
| 2 | + |
| 3 | +> Date: 2026-05-31 | Status: active | Branch: |
| 4 | +> `codex/quiet-index-refresh-cache-labels` |
| 5 | +
|
| 6 | +Tracking issue: https://github.com/mcpp-community/mcpp/issues/90 |
| 7 | + |
| 8 | +## Scope |
| 9 | + |
| 10 | +This document tracks the mcpp-side fixes found while validating `mcpp build` |
| 11 | +against the `xlings` project. |
| 12 | + |
| 13 | +The current work is intentionally limited to build-tool behavior: |
| 14 | + |
| 15 | +- make automatic package-index refresh quiet from the mcpp user's perspective; |
| 16 | +- make index freshness use a reliable mcpp-owned timestamp marker; |
| 17 | +- make dependency cache status use canonical dependency identities; |
| 18 | +- keep local xlings validation as the integration proof. |
| 19 | + |
| 20 | +## Findings |
| 21 | + |
| 22 | +### 1. Auto-refresh leaks xlings update output |
| 23 | + |
| 24 | +`mcpp build` calls `ensure_index_fresh()` when a project has version-source |
| 25 | +dependencies. That path currently calls `xlings update` with `quiet=false`. |
| 26 | + |
| 27 | +Observed output: |
| 28 | + |
| 29 | +```text |
| 30 | +Updating package index (auto-refresh) |
| 31 | +[1/7] awesome::/home/speak/.mcpp/registry/data/xim-index-repos/... |
| 32 | +... |
| 33 | +index updated |
| 34 | +``` |
| 35 | + |
| 36 | +The `[N/M] awesome::...` lines are xlings internals. mcpp users should only see |
| 37 | +the mcpp-level status line unless they explicitly run a verbose/manual index |
| 38 | +update command. |
| 39 | + |
| 40 | +### 2. Freshness check uses an unstable directory mtime |
| 41 | + |
| 42 | +`is_index_fresh()` currently checks: |
| 43 | + |
| 44 | +```text |
| 45 | +~/.mcpp/registry/data/mcpplibs/pkgs |
| 46 | +``` |
| 47 | + |
| 48 | +Local evidence showed: |
| 49 | + |
| 50 | +```text |
| 51 | +mcpplibs/pkgs 2026-05-31 01:55:40 |
| 52 | +mcpplibs/.git/FETCH_HEAD 2026-05-31 04:31:24 |
| 53 | +xim-indexrepos.json 2026-05-31 04:31:27 |
| 54 | +``` |
| 55 | + |
| 56 | +So `xlings update` can refresh the repository without updating the `pkgs/` |
| 57 | +directory mtime. Once the TTL expires, every full `prepare_build()` can decide |
| 58 | +that the index is stale again. |
| 59 | + |
| 60 | +### 3. Dependency status labels can say `Compiling` for cached deps |
| 61 | + |
| 62 | +For xlings: |
| 63 | + |
| 64 | +```toml |
| 65 | +[dependencies.mcpplibs] |
| 66 | +xpkg = "0.0.41" |
| 67 | +tinyhttps = "0.2.3" |
| 68 | +``` |
| 69 | + |
| 70 | +The UI prints dependency names as `mcpplibs.xpkg` and `mcpplibs.tinyhttps`. |
| 71 | +The cache hit label is currently built from the dependency package's own |
| 72 | +`mcpp.toml` name. For tinyhttps that manifest uses: |
| 73 | + |
| 74 | +```toml |
| 75 | +namespace = "mcpplibs" |
| 76 | +name = "tinyhttps" |
| 77 | +version = "0.2.3" |
| 78 | +``` |
| 79 | + |
| 80 | +The cache directory is therefore: |
| 81 | + |
| 82 | +```text |
| 83 | +~/.mcpp/bmi/<fingerprint>/deps/mcpplibs/tinyhttps@0.2.3 |
| 84 | +``` |
| 85 | + |
| 86 | +The UI compares `tinyhttps` against `mcpplibs.tinyhttps`, so it can print |
| 87 | +`Compiling mcpplibs.tinyhttps` even when the cache entry exists. |
| 88 | + |
| 89 | +### 4. libxpkg 0.0.41 has stale embedded mcpp metadata |
| 90 | + |
| 91 | +The installed `mcpplibs.xpkg@0.0.41` archive contains: |
| 92 | + |
| 93 | +```toml |
| 94 | +name = "xpkg" |
| 95 | +version = "0.0.39" |
| 96 | +``` |
| 97 | + |
| 98 | +This causes mcpp to cache the resolved package as: |
| 99 | + |
| 100 | +```text |
| 101 | +deps/mcpplibs/xpkg@0.0.39 |
| 102 | +``` |
| 103 | + |
| 104 | +while the consumer dependency remains `mcpplibs.xpkg v0.0.41`. |
| 105 | + |
| 106 | +## Implementation Plan |
| 107 | + |
| 108 | +- [x] Add focused regression coverage for default-index refresh quietness. |
| 109 | +- [x] Add a reliable mcpp-owned index freshness marker after successful update. |
| 110 | +- [x] Make automatic refresh call `update_index(..., quiet=true)`. |
| 111 | +- [x] Keep explicit/manual index update output available for diagnostics. |
| 112 | +- [x] Canonicalize dependency identity used for cache-hit labels. |
| 113 | +- [x] Avoid using stale embedded package version as the user-facing resolved |
| 114 | + dependency version when the index resolution already knows the requested |
| 115 | + version. |
| 116 | +- [x] Validate with the local xlings checkout using the new mcpp binary. |
| 117 | +- [ ] Push a draft PR and use it as the multi-commit checkpoint. |
| 118 | + |
| 119 | +## Verification Plan |
| 120 | + |
| 121 | +- [x] Run targeted unit/e2e coverage in mcpp. |
| 122 | +- [x] Build mcpp itself. |
| 123 | +- [x] Run `mcpp build` in `/home/speak/test/tmp/xlings` with the new binary. |
| 124 | +- [x] Confirm auto-refresh no longer prints xlings `[N/M] index::path` lines. |
| 125 | +- [x] Confirm repeated xlings full prepare does not refresh the index again |
| 126 | + while the marker is inside TTL. |
| 127 | +- [x] Confirm cached dependencies display as `Cached` when their artifacts are |
| 128 | + staged. |
| 129 | +- [ ] Record CI status on the PR. |
| 130 | + |
| 131 | +## Dynamic Notes |
| 132 | + |
| 133 | +- `mcpp build` has a 0.01s fast path when `build.ninja` is newer than source |
| 134 | + files; the noisy path happens when full `prepare_build()` runs. |
| 135 | +- A no-change `ninja -C target/... -n` in the local xlings checkout reported |
| 136 | + `ninja: no work to do`, so the status-line issue is partly UI/cache identity |
| 137 | + rather than always an actual compiler invocation. |
| 138 | +- Added regression tests: |
| 139 | + - `tests/unit/test_xlings.cpp` now requires `.mcpp-index-updated` for a |
| 140 | + fresh default index. |
| 141 | + - `tests/e2e/53_namespaced_cache_label.sh` verifies quiet auto-refresh, |
| 142 | + marker creation, and canonical `Cached compat.widget v1.0.0` output. |
| 143 | +- Local mcpp verification: |
| 144 | + - `mcpp test -- --gtest_filter=XlingsIndexFreshness.*` passed; the command |
| 145 | + built and ran all 16 test binaries, with `test_xlings` covering the filter. |
| 146 | + - `mcpp build --no-cache` passed and produced |
| 147 | + `target/x86_64-linux-gnu/4d24c8b57fdbbbb4/bin/mcpp`. |
| 148 | + - `MCPP=.../bin/mcpp bash tests/e2e/49_bmi_cache_nested_custom_index.sh` |
| 149 | + passed. |
| 150 | + - `MCPP=.../bin/mcpp bash tests/e2e/52_local_path_namespaced_index.sh` |
| 151 | + passed. |
| 152 | + - `MCPP=.../bin/mcpp bash tests/e2e/53_namespaced_cache_label.sh` passed. |
| 153 | +- Local xlings verification with the new mcpp binary: |
| 154 | + - First `build --print-fingerprint`: exit `0`, displayed only |
| 155 | + `Updating package index (auto-refresh)` with no xlings `[N/M]` lines. |
| 156 | + - Second `build --print-fingerprint`: exit `0`, no index refresh line, and |
| 157 | + `mcpplibs.tinyhttps` / `mcpplibs.xpkg` displayed as `Cached`. |
| 158 | + - Marker was written at |
| 159 | + `~/.mcpp/registry/data/mcpplibs/.mcpp-index-updated`. |
0 commit comments