Skip to content

pkgs/web-gen-api-axum crate split #8965

Open

Description

@dezren39

pkgs/web-gen-api-axum crate split

Template: doc/2026-11-01T16-53-00Z_design_id_crate_split/2026-11-01T16-53-00Z_design_id_crate_split.md (design of record for the pkgs/id split, from #3195). Worked example: pkgs/id umbrella #3447, step issues #4403-#4411. Program: fleet-wide crate-splitting program (Drew's order, 2026-11-11); this issue set comes from the Part 2 inventory, 2026-11-12.

Current shape (inventory 2026-11-12)

Single crate, no workspace: package start-axum (edition 2021), lib (cdylib+rlib) + bin, 731 LOC in src, 0 tests. Leptos 0.8 starter-shape app (axum ssr / hydrate features, libsql). Files: src/app.rs 435, src/dark_mode.rs 109, src/error_template.rs 76, src/fileserv.rs 40, src/lib.rs 25, src/main.rs 46. No package.nix (only shell.nix); recent commits are dependency bumps only. Existing-issue check (2026-11-12): no pre-existing crate-split design or issue for pkgs/web-gen-api-axum.

Import-scan evidence

Real scan of pkgs/web-gen-api-axum/src — crate:: references counted per file, aggregated per top-level module (the id design's method):

  • Module graph (4 internal edges total): app -> dark_mode (app.rs: use crate::dark_mode::DarkModeToggle), app -> error_template (app.rs: use crate::error_template::{AppError, ErrorTemplate}), fileserv -> app (fileserv.rs line 14: use crate::app::App, inside the ssr file handler), lib -> app (lib.rs hydrate(): use crate::app::*).
  • Leaves: error_template (76 LOC: AppError enum + ErrorTemplate component) and dark_mode (109 LOC: ToggleDarkMode server fn + DarkModeToggle component) are each referenced only by app and reference nothing local — clean leaves.
  • The one upward-flavored edge is fileserv -> app: file serving is server glue that must render the app on error. Per the id template's seam rule (composition/server code belongs to the top crate), fileserv stays in the facade with main.rs (axum server) rather than dragging app down or inverting the edge.
  • app.rs internally mixes components (App, HomePage, SimpleCounter) with two libsql-backed server fns (AddVisitorData, GetVisitorRows, lines 312-325); the scan shows no internal boundary there, so app moves as one unit in this pass — a server-fn sub-split is explicitly out of scope.

Step sequence

One PR per step, in order:

Proposed crate map

pkgs/web-gen-api-axum becomes a Cargo workspace; members under crates/, shared versions pinned in [workspace.dependencies] from step 0. The facade keeps the package/lib name start-axum and re-exports the pre-split paths (start_axum::app, start_axum::dark_mode, start_axum::error_template, start_axum::fileserv) that lib.rs and main.rs use today.

crate contents (today's code) depends on
start-axum-error error_template.rs — AppError, ErrorTemplate (76 LOC) leaf, no internal deps
start-axum-ui dark_mode.rs (109) + app.rs (435: components + visitor server fns) start-axum-error
start-axum (facade) lib.rs (hydrate()), fileserv.rs, main.rs (axum server) + facade re-exports start-axum-ui, start-axum-error

Dependency rule: one-way, down the table; the facade's server glue (fileserv) depending on the ui crate is the correct direction — it is the consumer side of the relationship.

Scale note: 731 LOC — small, but it has a real 4-module graph with two clean leaves, so the extraction steps are mechanical and low-risk.

Acceptance discipline (from the id template; applies to every step):

  • One PR per step; no step bundles another step's extraction.
  • Full test suite green on that PR. Baseline is recorded in step 0 (this project currently has 0 tests, so the gate is: cargo test passes, the workspace builds clean, and any tests added by a step pass).
  • Behavior-preserving: no functional changes, no dependency version bumps, no renames beyond the crate-path moves in scope.
  • Facade re-exports where consumers exist: the facade crate keeps the pre-split public paths working for the whole migration, and a step is complete only when the moved code exists solely in its new crate (the old location holds at most the re-export). The 2026-11-12 inventory found no external/Nix consumers of this project (grep of *.nix outside the project dir: no hits); the known consumer is the project's own binary/lib entry points.
  • Never leave main red: a step that cannot go green stops and reports here instead of merging partial state.

Activity

  1. developing-today commented on Nov 12, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 13, 2026

    @dezren39
    MemberAuthor

    Step-0 baseline, recorded 2026-11-13 during the cross-project split pass (Part 2 of the pkgs/id split program). This project does not build in its current state, with any toolchain available here — so the extraction steps cannot meet the program's acceptance discipline (builds green per PR) and are blocked on a revival decision, not on split work.

    Evidence (laptop, this run):

    • Stable rustc 1.99, cargo build --features ssr: fails with E0554 — server_fn_macro uses #![feature]; the crate's leptos stack (leptos 0.8 / leptos_axum 0.4 / leptos_meta 0.4) is nightly-era.
    • RUSTC_BOOTSTRAP=1 on stable: fails — leptos_macro calls proc_macro::Span::source_file, an API removed from current rustc.
    • The pinned toolchain (rust-toolchain = nightly-2023-07-20, installed for this check): cannot read the current graph at all — Cargo.lock is format v4 (era cargo max v3), and after a local v3 downgrade experiment (reverted), era cargo rejects the Renovate-bumped dependency graph: "this version of Cargo is older than the 2024 edition". The bumps have dragged the deps years past the pin.
    • cargo test: 0 tests exist; nothing to preserve but source.

    The deadlock is structural: old toolchain vs new deps vs new rustc vs old macros. Reviving means a port (upgrade the leptos stack to a current release and fix API drift), a graph restore (pin deps back to 2023-era versions compatible with nightly-2023-07-20), or retiring the starter. That is a decision for Drew; the split steps (#8967, #8968, #8969) stay open and become straightforward once the crate builds again — the decomposition on this umbrella is import-scanned and ready. No source was changed by this pass.

  3. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged + escalated to Drew — task 18785 (lane code-a)

  4. added
    user/escalatedRequires a Drew decision or access
    queue/blockedQueue or user escalation state
    status/blockedQueue or user escalation state
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    kind/designA design proposal (design-architect): multi-step, phased, decision-bearing
    on Nov 17, 2026
  5. removed their assignment
    on Nov 20, 2026
  6. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Decided: Keep pkgs/web-gen-api-axum and port it to a supported current Leptos/toolchain combination before resuming the mechanical crate split.
    Why: The issue describes a small starter template whose planned split has three prepared steps; retiring it discards that reusable starter, while pinning a historical dependency graph preserves the known toolchain mismatch. A supported port keeps the intended project usable and makes the existing split steps actionable. The sibling starter triage also identifies porting as the preferred preservation path, though this decision is for #8965 only.
    Undo: A later explicit product decision can retire the starter or restore a compatible historical graph; otherwise the port can be revised in a follow-up PR without changing the split design.
    By: repo-worker-code, lane code-j

    Triage disposition: resolved the owner-decision gate by choosing the port path. The prerequisite is implementation work, not a person-wait condition; #8967–#8968 remain blocked until the crate builds, and the split can then resume under its existing step issues.

  7. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

  8. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · final workspace shape — recorded by lane lane-bp at the completion of step 3 (#8969, PR #12778, merge cd688f5566c842f5b0245fcb02a5cd8042d30f39).

    The split sequence is fully landed: step 0 #8966, step 1 #8967 (PR #12395), step 2 #8968 (PR #12617), step 3 #8969 (PR #12778).

    Final shape, as landed. It differs from the proposed crate map in one respect: the extracted crates are siblings under pkgs/, not under pkgs/web-gen-api-axum/crates/, and the graph is tied together by path dependencies from the facade, whose Cargo.lock covers all three crates (no separate [workspace] manifest was introduced).

    crate location contents depends on
    start-axum-error pkgs/start-axum-error src/lib.rs — AppError enum + ErrorTemplate component leaf (leptos, http, thiserror; no internal deps)
    start-axum-ui pkgs/start-axum-ui src/app.rs (App/HomePage/SimpleCounter components + visitor server fns + libsql static-db init), src/dark_mode.rs (ToggleDarkMode server fn + DarkModeToggle component), src/lib.rs (module declarations) start-axum-error
    start-axum (facade) pkgs/web-gen-api-axum src/lib.rs (hydrate()), src/fileserv.rs (file_and_error_handler; use crate::app::App via the facade re-export), src/main.rs (axum server wiring), one-line re-export shims src/app.rs / src/dark_mode.rs / src/error_template.rs, tests/facade_paths.rs (facade-contract test) start-axum-ui, start-axum-error

    Dependency direction is one-way, down the table; the facade's server glue (fileserv) consuming the ui crate through the facade's own re-export is the consumer side of the relationship, per the crate map. The pre-split public paths (start_axum::app, start_axum::dark_mode, start_axum::error_template, start_axum::fileserv) keep working and are now pinned by tests/facade_paths.rs (step gates: cargo check/test under ssr + hydrate check; baseline 0 tests → 1).

    One observation carried over from step 3: the facade Cargo.toml still lists direct deps only the extracted code uses (leptos_query, web-sys, libsql, serde, http, once_cell, hyper, and the feature-forwarded leptos_meta / leptos_router / tracing). Pruning them would change the facade's feature-forwarding surface, so step 3 deliberately left them; a future dep-slimming step can take it up as its own change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/sSmall: expected under 2 hours of workepic/crate-splitsEpic: crate-splits - all issues of this effort carry itkind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/normalOrdinary priority (the default)queue/blockedQueue or user escalation statestatus/blockedQueue or user escalation state

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions