Skip to content

fix(xim): an installed payload belongs to a package, not to a short name (2026.8.30.2) - #576

Merged
Sunrisepeak merged 2 commits into
mainfrom
fix/store-lookup-namespace-identity
Aug 30, 2026
Merged

Sunrisepeak merged 2 commits into
mainfrom
fix/store-lookup-namespace-identity

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

What

The install planner's fallback answer to "is this already installed" was keyed on node.name — a bare short name — while every other answer in this codebase is keyed on package identity. match.installed (catalog.cpp:302) stats <store>/<ns>-x-<name>/<version>; installation_state takes a namespace argument. installer.cpp's xvm fallback did not.

A short name is not an identity.

The failure, from the consumer side

Reported as mcpp#533. A source-build compat:libdrm pinned to the same upstream version as the xim:libdrm that Mesa pulls in was reported already-installed on the strength of Mesa's payload. Its install() never ran; the tree it was supposed to build did not exist; and the consumer's build then failed four layers away:

$ mcpp test
   Compiling compat.libdrm v2.4.123          <- looks resolved
error: build failed
failed: bin/libdrm.so
/bin/sh: 1: -shared: not found

The rule this silently imposed on index authors is that no package may share a <short name>@<version> with any package in any other namespace — which is not knowable when a descriptor is written, and which a real store already violates 20 short names wide (libpng, expat, zlib, cairo, fontconfig, linux-headers, nasm, ncurses, …).

The fix

coordinate_from_payload_path already knows the answer, and says so in its own header: the installer wrote that path, so <...>/xpkgs/<ns>-x-<package>/<version> is not evidence about the package, it is the package identity recorded at install time. payload_path_names_another_package reads it, and the fallback declines a DB entry it can prove belongs elsewhere.

This also removes a surviving answerer to the question install_state.cppm was written to consolidate — its own header notes there were four, and this fallback was a fifth.

Compatibility

The predicate is deliberately reject-shaped, not require-shaped. A record whose path does not parse as a store coordinate — a self-managed tool, a relocated payload, anything outside xpkgs/ — yields no coordinate and is accepted exactly as before. Behaviour changes only where different ownership is provable.

What this does NOT authorise

Publishing a colliding <name>@<version> to an index is still unsafe until this version is the floor: a client below it goes on skipping the install, silently. This fix is for the collisions people hit by accident, which per the numbers above is the common case.

Tests

tests/unit/test_xvm_owner.cpp, eight cases. Most assert a false: the predicate answers "can I prove this is someone else's", not "is this mine", and a version that only ever said yes would reinstall every superseded payload forever.

Verified by reverting the predicate to its previous answer and re-running — PayloadOwnership.SameShortNameInAnotherNamespaceIsAnotherPackage fails, so the tests discriminate rather than describe.

Local: mcpp build clean, mcpp test 50 passed / 0 failed.

…ame (2026.8.30.2)

The install planner's fallback answer to "is this already installed" was keyed
on `node.name` — a bare short name — while every other answer in the codebase
is keyed on package identity. `match.installed` (catalog.cpp) stats
`<store>/<ns>-x-<name>/<version>`; `installation_state` takes a namespace
argument. This one call site did not, and a short name is not an identity.

What that cost, from the consumer side (mcpp#533): a source-build
`compat:libdrm` at the same upstream version as the `xim:libdrm` that Mesa
pulls in was reported already-installed on the strength of Mesa's payload. Its
`install()` never ran, the tree it was supposed to build did not exist, and the
consumer's build failed four layers away in a linker command line that named
nothing to do with package identity. The rule it silently imposed on index
authors was that no package may share a `<short name>@<version>` with any
package in any other namespace — not knowable when a descriptor is written, and
already violated 20 short names wide on a real store.

The payload path is the answer, and `coordinate_from_payload_path` is the code
that already knows it: the installer wrote that path, so
`<...>/xpkgs/<ns>-x-<package>/<version>` is the package identity recorded at
install time. `payload_path_names_another_package` reads it, and the fallback
now declines a DB entry it can prove belongs elsewhere.

Compatibility is why the predicate rejects rather than requires. A record whose
path does not parse as a store coordinate — a self-managed tool, a relocated
payload, anything outside `xpkgs/` — yields no coordinate and is accepted
exactly as before. Behaviour changes only where different ownership is
provable.

Also note what this is NOT: publishing a colliding `<name>@<version>` to an
index is still unsafe until this version is the floor, because a client below
it goes on skipping the install silently. This fix is for the collisions people
hit by accident, which is the common case.

Tests: tests/unit/test_xvm_owner.cpp, eight cases. Most assert a *false* — the
predicate answers "can I prove this is someone else's", and a version that only
ever said yes would reinstall every superseded payload forever. Verified by
reverting the predicate to its previous answer and re-running:
SameShortNameInAnotherNamespaceIsAnotherPackage fails.
The TUI output contract (E2E-44 S6) governs U+26A0 and U+24D8 to
src/core/glyph.cppm — they are label glyphs the renderer owns, and a second
spelling anywhere in src/ is how a dead icon table in src/platform/ once
drifted from the real one. My two comment headers used one. The emphasis was
never the point; the sentence is.
@Sunrisepeak
Sunrisepeak merged commit f5a0775 into main Aug 30, 2026
8 checks passed
Sunrisepeak pushed a commit to mcpp-community/mcpp that referenced this pull request Aug 30, 2026
openxlings/xlings#576, released as v2026.8.30.2. Below this version xlings
answers "is this package already installed" from the xvm version database keyed
on the bare short name, so a package skips its own `install()` whenever any
other namespace holds the same `<name>@<version>`.

This is a FLOOR and not a preference, which is the whole reason the pin has the
shape it does. The mcpp side of #533 makes the resulting failure legible on any
client — the link unit is refused by name, and `.mcpp_ok` is withheld from a
directory holding nothing the package installed — but only a client at or above
this version INSTALLS correctly.

⚠️ This does NOT authorise an index change. Publishing a deliberately colliding
`<name>@<version>` stays unsafe until the floor is adopted, not merely
released, and .agents/docs/2026-08-30-cross-repo-fix-plan-532-533-534.md §6.2
recommends not doing it at all: the fix is for the collisions people hit by
accident, which is already 20 short names wide on a real store.

`src/xlings/xlings.cppm` is the source of truth; the seven copies under
.github/ follow it and `check_version_pins.sh` enforces the agreement.

Also records what landed against the plan (§12), including two things the plan
had wrong: the xlings anchor was 167 commits stale and the call site had moved,
and `⚠` is CI-governed in xlings while it is merely conventional here.
Sunrisepeak added a commit to mcpp-community/mcpp that referenced this pull request Aug 30, 2026
… empty link is refused (2026.8.30.1) (#536)

* fix(build): a package's generated inputs come before its compiles; an empty link is refused (2026.8.30.1)

Three defects, one change of mind about evidence. Each of them was a place
where something answered "is this ready?" from a proxy instead of from the
artifact.

── mcpp#534: `role = "source"` did not order a generated header ─────────────

The engine's own comment claimed ordering needed no special handling because
"a Source action's outputs ARE the compile edge's inputs". That is true of a
generated `.cpp` and false of a generated `.h`: a header is reached through
`-I`, never appears as an edge input, and the depfile that would record it does
not exist until a compile has already succeeded.

So an action whose outputs were all headers had a node in build.ninja that
nothing could reach — not `default` (Source outputs are excluded on purpose),
not the goal phony (objects and link outputs only), and no consuming edge. It
never ran. The issue was filed as an intermittent race; it is deterministic,
and five consecutive builds reproduce it identically. What made it look like a
race is that `prepare_actions` wrote a zero-byte placeholder for every declared
Source output, headers included — so the file was on disk whether or not the
generator had run.

  * `BuildAction` records the package that declared it, spelled the same way
    `CompileUnit::packageName` is (`qualified_package_name`, now exported so
    the two cannot drift).
  * Each package that declares a gating action gets one phony over its outputs,
    and every compile edge of that package takes it as an order-only
    prerequisite. Per package, not per build: `include_dir` colours only the
    declaring package's own TUs, and a build-wide edge would express a
    dependency that does not exist while landing on the critical path.
  * `check_action_ordering` scans the emitted manifest and fails the build if
    any such edge is missing one — including the denominator, because "every
    edge that should carry it does" is vacuously true when none does, which was
    exactly the previous state. Seven call sites append the string today; being
    careful at seven sites is not a mechanism.
  * `blocking` on a `check` now does what it has been documented to do since it
    was introduced. It was typed, emitted over the build-program protocol,
    parsed, documented in two languages and demonstrated in a shipped example —
    and read by nothing.
  * Placeholders are no longer written for outputs that are not translation
    units. The scan never reads a header, and the empty file only ever turned
    "the generator did not run" into "the header is empty".

── mcpp#533: an empty link unit, reported as a shell error ──────────────────

A dependency whose `install()` was skipped over a package-identity collision
left a version directory with no sources. mcpp planned its shared library
anyway and the user was shown `/bin/sh: 1: -shared: not found`.

  * A link unit with no inputs is refused at plan time, naming the target. The
    static case is why this is an error rather than a better linker message:
    `ar rcs` with no members exits 0 and writes an 8-byte archive, so the build
    REPORTED SUCCESS and every consumer failed later with undefined symbols.
  * `cc` is emitted unconditionally, for the reason `c_ldflags` twenty-six
    lines below already carried (mcpp#426). The rule had been written down for
    one variable of `c_link`/`c_shared` and not for the other.
  * `check_rule_commands_name_a_program` scans the manifest for the class: a
    rule's command must begin with a program. Deliberately not the more obvious
    "no undefined variables" — ninja's empty expansion is a feature several
    rules rely on (`$soname_flag`, `$unit_ldflags`), and that check would have
    needed an allowlist of exceptions.
  * `.mcpp_ok` is no longer written from the installer's exit code plus the
    existence of a directory the installer creates before doing any work. It
    now requires one entry that neither mcpp nor xlings wrote. Withheld rather
    than fatal, because a package may legitimately install no payload.
  * The same predicate runs on the fast path, so a store already poisoned by
    this bug heals on the next build instead of requiring the user to know
    which directory to delete.
  * The lib-root warning asked `has_lib_target` — "does this produce a library"
    — when the property it wants is "is this a C++ module library". A
    source-built C package warned that `src/<name>.cppm` was missing in every
    consumer's build.

── Tests ───────────────────────────────────────────────────────────────────

e2e 314 (a dependency generating its only header), 315 (blocking gates the
compile, non-blocking does not), 316 (empty shared AND static targets refused;
a populated one still builds). All three were run against the pre-fix binary
and all three fail there, so they discriminate rather than describe.

Unit: 14 new cases over the two emitter guards, the ordering denominator, and
the install-marker evidence — including the poisoned-store heal.

Analysis and cross-repo plan: .agents/docs/2026-08-30-*.md

Refs #533, #534

* chore(xlings): raise the floor to 2026.8.30.2 — the store-identity fix

openxlings/xlings#576, released as v2026.8.30.2. Below this version xlings
answers "is this package already installed" from the xvm version database keyed
on the bare short name, so a package skips its own `install()` whenever any
other namespace holds the same `<name>@<version>`.

This is a FLOOR and not a preference, which is the whole reason the pin has the
shape it does. The mcpp side of #533 makes the resulting failure legible on any
client — the link unit is refused by name, and `.mcpp_ok` is withheld from a
directory holding nothing the package installed — but only a client at or above
this version INSTALLS correctly.

⚠️ This does NOT authorise an index change. Publishing a deliberately colliding
`<name>@<version>` stays unsafe until the floor is adopted, not merely
released, and .agents/docs/2026-08-30-cross-repo-fix-plan-532-533-534.md §6.2
recommends not doing it at all: the fix is for the collisions people hit by
accident, which is already 20 short names wide on a real store.

`src/xlings/xlings.cppm` is the source of truth; the seven copies under
.github/ follow it and `check_version_pins.sh` enforces the agreement.

Also records what landed against the plan (§12), including two things the plan
had wrong: the xlings anchor was 167 commits stale and the call site had moved,
and `⚠` is CI-governed in xlings while it is merely conventional here.

---------

Co-authored-by: speak-agent <[email protected]>
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