Skip to content

producer: materialize re-exports + normalize rustdoc ids (APIDRIFT-21) - #10

Open
nixpt wants to merge 3 commits into
mainfrom
agent/opencode/APIDRIFT-21-reexport-materialization
Open

nixpt wants to merge 3 commits into
mainfrom
agent/opencode/APIDRIFT-21-reexport-materialization

Conversation

@nixpt

@nixpt nixpt commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Why

Two producer blindspots made the ledger unusable beyond the "does the consumer compile" fallback (found while gating zorro's 13-crate decomposition, ZORRA-1 step 4):

  1. pub use chains vanished — every shimmed path (zorro::io, zorro::kv_cache, zorro::pipeline::sampling, …) was reported as Removed even though it existed.
  2. rustdoc ids leaked into signatures — ids renumber on every rebuild and across a split, so structurally identical items showed up as SignatureChanged (“id-noise”).

What

Re-export materialization (producer.rs):

  • named item re-exports emit <parent>::<name>;
  • module aliases expand public contents, with a duplicate-segment collapse so pub use zorro_io as io maps to zorro::io::X, not zorro::io::io::X;
  • globs expand into the parent, including globs of private local modules (walked through the index tree, which paths cannot express);
  • local use chains resolve to the ultimate target;
  • aliases carry snapshot::RE_EXPORT_ATTR and a stable signature (target payload for in-crate targets, re-export of <path> for external ones).

Signature normalization:

  • resolved_path drops ids and uses the canonical defining path;
  • impls / implementations / items / fields / variants / links id lists become sorted stable labels (paths, local names, impl descriptors);
  • generic params become local:<name>;
  • after alias discovery, signature type paths prefer the shortest local re-export spelling (zorro_nn::backend::ComputeBackend → zorro::backend::ComputeBackend).

Classification / ledger:

  • signature changes on re-export-backed items are Warning (the defining crate owns the shape), not Breaking;
  • API_DRIFT_UPDATE=1 now rewrites an existing snapshot (it previously only handled the first record, so the documented recording command silently did nothing after init). Demo ledger regenerated.

Validation

  • cargo test --workspace --all-features green; new synthetic tests for named/module/glob/private-module/chain materialization and id churn (same shape + different ids → no diff).
  • cargo clippy --workspace --all-features --all-targets clean.
  • Validated against zorro: its current surface went 61 → 202 items, consumer compile stayed green, and the 15 remaining breaking signature changes are real cross-crate type-provenance moves (TensorIndex etc.), not ids.

Known limits (documented in the ticket)

rustdoc JSON's paths is a reference table, not a dependency index, so a dependency's flattened re-exports (zorro_io's pub use io::*) are only materialized where referenced. Full reconstruction needs ingesting dependency rustdoc JSON (filed as a follow-on).

Compatibility note

diff::Changed gains old_attrs/new_attrs (struct literal construction is affected; only internal call sites in this repo). New public items: snapshot::RE_EXPORT_ATTR, producer behavior. No crate version bump yet — this is for the next release.

Ticket: .jagent/planning/tickets/APIDRIFT-21-reexport-materialization.md.

nixpt added 3 commits October 22, 2026 06:22
Fixes the two blindspots that made the ZORRA-1 ledger noise:

1) `pub use` items are materialized:
   - named item re-exports -> one alias at parent::name
   - module aliases expand public contents; duplicate-segment collapse maps
     `pub use zorro_io as io` to `zorro::io::X` (not `::io::io::X`)
   - globs expand into the parent, including globs of private local modules
     (walked through the index tree, which `paths` cannot express)
   - local use chains resolved; aliases carry snapshot::RE_EXPORT_ATTR
2) Signatures are id-stable:
   - resolved_path drops ids and prefers the canonical defining path
   - impls/implementations/items/fields/variants/links id lists become sorted
     stable labels; generic params become local:<name>
   - after alias discovery, signature type paths prefer the shortest local
     re-export spelling (zorro_nn::backend::ComputeBackend ->
     zorro::backend::ComputeBackend)

classify: signature changes on re-export-backed items are Warning (the
defining crate owns the shape).

ledger: API_DRIFT_UPDATE=1 now rewrites an existing snapshot (was first-record
only). Demo ledger regenerated (one resolved_path.id removal).

Limits documented in the ticket: rustdoc's `paths` table is a reference table,
so a dependency's flattened re-exports are only materialized where referenced;
cross-crate type moves still read as genuine signature drift.

Tests: workspace all-features green; clippy clean; new synthetic coverage for
alias/glob/private-module/chain/id-churn; validated on zorro (surface 61->202).
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.

1 participant