Move version compatibility to the consumer; name libdpm-core explicitly

dpm_require no longer takes a minimum version and applies no version
criterion of its own. A handle now means the module is valid, not that
it suits the caller. dpm_module_info_of is added alongside it, reporting
the name, version, description, and minimum-libdpm-core version read at
load, so a consuming module can judge a dependency's version for itself.
The one rule still enforced is the minimum-version handshake, where
libdpm-core is the host and refuses a module that demands a newer library
than the one running.

dpm_module_info_of joins the version script, so the exported surface is
now fourteen symbols under DPM_CORE_1.0.

Separately, the bare word "core" is gone from prose everywhere. It named
both the command-line tool and the library, so every use forced the
reader to guess which. Text now says "the dpm binary" or "libdpm-core".
Identifiers keep their spelling: libdpm-core, core.h, core.conf, the
"core" configuration namespace, dpm_core_version, core_min, DPM_CORE_1.0,
the dpmcore namespace, test_core, core_api.

Three user-visible strings changed with it: the load-refusal message now
reads "requires libdpm-core >= X, running libdpm-core is Y — update
libdpm-core", and the info module's description and help text name the
library. The test asserting on the refusal text was updated to match.

DESIGN.md's terminology line no longer defines "DPM Core" as the CLI,
which was the source of the ambiguity. OVERVIEW.md is restructured around
the three layers a reader meets DPM at — user, developer, filesystem —
so a code-level symbol never appears without saying whose layer it is.
MODULES.md describes the bundled info module as testing and demonstrating
full DPM system functionality rather than as a reference implementation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-10 00:38:21 -04:00
parent da35fe4758
commit c41adc2498
22 changed files with 327 additions and 243 deletions

View File

@@ -1,6 +1,6 @@
/**
* @file test_core.cpp
* @brief Core test binary: drives libdpm-core through its public C API
* @brief Test binary: drives libdpm-core through its public C API
*
* Exercises context lifecycle, configuration, the full load-time
* validation matrix against the fixture modules, versioned require,
@@ -105,41 +105,44 @@ int main(void)
/* ---- validation matrix: every broken fixture refused, precisely ---- */
{
CHECK(dpm_require(ctx, "missing_symbols", nullptr) == nullptr);
CHECK(dpm_require(ctx, "missing_symbols") == nullptr);
CHECK(error_contains(ctx, "missing required contract symbols"));
CHECK(error_contains(ctx, "dpm_module_execute"));
CHECK(dpm_require(ctx, "core_too_new", nullptr) == nullptr);
CHECK(error_contains(ctx, "update core"));
CHECK(dpm_require(ctx, "core_too_new") == nullptr);
CHECK(error_contains(ctx, "update libdpm-core"));
CHECK(dpm_require(ctx, "bad_version", nullptr) == nullptr);
CHECK(dpm_require(ctx, "bad_version") == nullptr);
CHECK(error_contains(ctx, "malformed version"));
CHECK(dpm_require(ctx, "lying_manifest", nullptr) == nullptr);
CHECK(dpm_require(ctx, "lying_manifest") == nullptr);
CHECK(error_contains(ctx, "does not resolve"));
CHECK(dpm_require(ctx, "bad_magic", nullptr) == nullptr);
CHECK(dpm_require(ctx, "bad_magic") == nullptr);
CHECK(error_contains(ctx, "magic"));
CHECK(dpm_require(ctx, "nonexistent", nullptr) == nullptr);
CHECK(dpm_require(ctx, "nonexistent") == nullptr);
CHECK(error_contains(ctx, "not found"));
}
/* ---- known-good module: require, versions, api, execute ---- */
{
dpm_module* good = dpm_require(ctx, "good", nullptr);
dpm_module* good = dpm_require(ctx, "good");
CHECK(good != nullptr);
/* loaded at most once per context */
CHECK(dpm_require(ctx, "good", nullptr) == good);
CHECK(dpm_require(ctx, "good") == good);
/* minimum-version negotiation */
CHECK(dpm_require(ctx, "good", "1.0.0") == good);
CHECK(dpm_require(ctx, "good", "1.2.3") == good);
CHECK(dpm_require(ctx, "good", "2.0.0") == nullptr);
CHECK(error_contains(ctx, "below required minimum"));
CHECK(dpm_require(ctx, "good", "not.a.version") == nullptr);
CHECK(error_contains(ctx, "malformed minimum version"));
/* libdpm-core reports what it saw; the caller judges compatibility */
dpm_module_info seen;
CHECK(dpm_module_info_of(ctx, good, &seen) == 0);
CHECK(std::strcmp(seen.name, "good") == 0);
CHECK(std::strcmp(seen.version, "1.2.3") == 0);
CHECK(std::strcmp(seen.core_min, "0.1.0") == 0);
CHECK(seen.description != nullptr && *seen.description);
CHECK(dpm_module_info_of(ctx, nullptr, &seen) != 0);
CHECK(dpm_module_info_of(ctx, good, nullptr) != 0);
/* typed access */
const void* table = dpm_get_api(ctx, good, "good", 1);