Skip to content

fix: skip Form B packages in template name resolution#266

Merged
Sunrisepeak merged 1 commit into
mcpp-community:mainfrom
xv1rcn:fix/template-form-b-filter
Jul 22, 2026
Merged

fix: skip Form B packages in template name resolution#266
Sunrisepeak merged 1 commit into
mcpp-community:mainfrom
xv1rcn:fix/template-form-b-filter

Conversation

@xv1rcn

@xv1rcn xv1rcn commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • fetch_template_package() now skips Form B packages whose manifest
    is synthesized from the descriptor (mcpp = { ... })
  • Uses existing mcpp::manifest::extract_mcpp_field() API, consistent
    with prepare.cppm Form A/B dispatch
  • 4 lines added in src/scaffold/create.cppm

Refs #265 (hardening — does not close it; see review comment below for the
verified root cause, which lands in a separate PR)

Test plan

  • bash tests/e2e/69_package_templates.sh — new Form B filter case
  • bash tests/e2e/02_new_build_run.sh — no regression
  • bash tests/e2e/12_add_command.sh — no regression
  • bash tests/e2e/27_namespace_dependencies.sh — no regression
  • CI: Linux / macOS / Windows

@Sunrisepeak

Copy link
Copy Markdown
Member

Thanks — reviewed and reproduced locally. The Form B filter is worth having, but it is not what makes #265 fail, so I changed Closes #265Refs #265.

What actually flips the resolution

Not "imgui.lua unavailable for some reason" — the index floor gate itself. check_index_floor() conflates report once with enforce (src/pm/index_contract.cppm:110), while its only caller uses the return value as the gate (src/pm/package_fetcher.cppm:593). So within one process the first lookup into a floor-violating index is blocked and every later one is silently let through.

fetch_template_package() looks up twice — ns="" then ns="compat":

lookup candidates result
ns="" imgui.lua, compat.imgui.lua blocked by floor (E0006 printed once) — imgui.lua never seen
ns="compat" compat.imgui.lua gate already "reported" → passes → Form B hit

Reproduced with the exact binary CI installs (0.0.100) against the real index (floor 0.0.102):

$ .../xim-x-mcpp/0.0.100/mcpp new abc1 --template imgui
error: index requires mcpp >= 0.0.102 but this is mcpp 0.0.100 [E0006]
error: package 'imgui@1.92.8' has no mcpp.toml        # byte-identical to CI

$ MCPP_INDEX_FLOOR=ignore .../0.0.100/mcpp new abc2 --template imgui
     Created abc2 (template imgui@0.0.6:window)       # same binary, same index

Same binary, same index, only the gate differs — so candidate ordering and Form A/B are not the cause. The leak also defeats the floor contract everywhere else (prepare.cppm uses the same gate), which is exactly what mcpp-index #107 raised the floor to prevent. Introduced in 53b6ead (0.0.85, #200), i.e. present since the feature landed.

With this PR applied the same CI step still exits 1 — just with template package 'imgui' not found in the index instead. A separate PR fixes the gate and will close #265.

On merging this

Fine to merge as hardening. Verified it cannot regress anything today: imgui.lua and templates.lua have no mcpp field at all (Absent), all 40 TableBody descriptors in the index are compat.* source packages, and a TableBody package could never have passed the root/mcpp.toml check anyway — so the skip only turns an unavoidable failure into a clearer message. It is also textually orthogonal to the gate fix.

Two things before merge:

  1. Status checks have not run on this fork PR — please let Linux / macOS / Windows CI go green first (the last box in your test plan).
  2. Consider a one-line comment at the continue stating why Form B can never provide templates, so the skip is not mistaken for the mcpp new --template imgui fails on all platforms: package 'imgui@1.92.8' has no mcpp.toml #265 fix later.

Form B packages (mcpp = { ... }) have no physical mcpp.toml or
templates/ directory — their manifest is synthesized from the
index descriptor. The template fetch path now detects this via
extract_mcpp_field() and skips to the next namespace candidate.

Refs mcpp-community#265 (hardening)
@xv1rcn
xv1rcn force-pushed the fix/template-form-b-filter branch from f7afd58 to 990ba17 Compare July 22, 2026 08:24
@Sunrisepeak
Sunrisepeak merged commit d571365 into mcpp-community:main Jul 22, 2026
7 checks passed
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.

2 participants