engine: extract world synthesis into nexum-world#440
Conversation
lgahdl
left a comment
There was a problem hiding this comment.
Clean extraction overall — nexum-world stays generic (no venue/cow types leak into it), comments are accurate throughout with no stale references, and the collision/malformed-manifest error paths are properly tested. Two things worth a look before merge, one architectural note that's non-blocking:
| } | ||
| dir = cur.parent(); | ||
| } | ||
| None |
There was a problem hiding this comment.
The old resolve_wit_packages (removed from nexum-macros) located one wit/ root by requiring it to contain nexum-host, then resolved every requested package under that same root. This version resolves each package independently, walking its own ancestor chain with no shared-root invariant.
Failure scenario: a crate that vendors wit/deps/pkg-a locally but not wit/deps/pkg-b will silently pull pkg-a from crate-local and pkg-b from a differently-versioned copy in some unrelated ancestor's wit/ — no error, no indication the resolved set is incoherent. The synthesize call sites always request multiple packages at once (["nexum-host", "videre-value-flow", ...]), which is exactly where this could manifest, and no test covers a multi-package case split across ancestor levels (the existing tests all pass a single-element package list).
Worth tracking the ancestor level each package resolves at and erroring if they disagree, plus a test with ≥2 packages resolving from different levels.
There was a problem hiding this comment.
Confirmed still valid at HEAD, not superseded: resolve_wit_packages (now in nexum-world) still resolves each package independently with no shared-root/level-coherence check, and every test passes a single-element package list. The split-repo layout co-locates packages under one wit/ root so it does not trigger today, but the guard and the multi-package cross-level test are absent. Tracked in #504.
| # per-namespace rows the module world synthesis emits beyond the core | ||
| # nexum:host table. Each row names the WIT import a `[capabilities]` | ||
| # declaration turns into and the package directories its resolve path | ||
| # needs, in dependency order. |
There was a problem hiding this comment.
This introduces a second, unrelated [extensions.<name>] table. docs/design/linker-extension-seam.md already reserves that exact heading for the opaque, runtime-loaded operator config living inside engine.toml (e.g. [extensions.cow] → orderbook_urls). This file's [extensions.client]/[extensions.cow-api] rows are a different schema (import/packages — WIT wiring) loaded at a different time (macro-expansion-time ancestor walk, not runtime config parsing).
Same section syntax, two unrelated files, nothing cross-referencing them — a reader who knows the engine.toml convention has no signal these aren't the same mechanism. Worth a distinct filename (wit-extensions.toml? capabilities.toml?) or a doc cross-reference in both places.
There was a problem hiding this comment.
Confirmed still valid at HEAD, not superseded: extensions.toml still carries [extensions.client], and linker-extension-seam.md still reserves [extensions.<name>] for the unrelated runtime operator config. No rename or cross-reference was added. Tracked in #505.
e2dc469 to
c68cd89
Compare
…e known table The capability table and per-module world synthesis move into a new plain nexum-world library carrying only the core nexum:host rows. Per-namespace rows come from the composition root's extensions.toml registry, parsed and passed in by the macro layer, so no host crate carries a downstream name; synthesis rejects a row that shadows a core capability or another registration. WIT packages resolve crate-locally (wit/deps, then wit/) with an ancestor fallback for the transitional monorepo layout.
ca81a60 to
230d417
Compare
Closes #379
What
Extracts module/venue world synthesis and the core capability table out of
nexum-macros::worldinto a new plain library,nexum-world. Removes the bakedclient(pool) andcow-apirows from the table; per-namespace rows now come from a composition root'sextensions.tomlregistry, passed intosynthesize. Rewrites WIT package resolution from a workspace-ancestor walk to crate-localwit//wit/depslookup (nexum_world::resolve_wit_packages), falling back through ancestors for the transitional monorepo layout.Why
The KNOWN table hardcoded a pool row and a
cow-apitoshepherd:cowrow, leaking venue and cow knowledge into the host-adjacent macro crate. Sourcing those rows from a registered-extension manifest instead, and moving the synthesis/table into their own venue-free library, gets the host layer to zero venue/cow knowledge per the Extension seam target.Testing
cargo test -p nexum-worldcargo test -p nexum-macrosAI Assistance
Implemented with Claude Code.
Closes #379