Skip to content

[Refactor]: establish Rust build hygiene and tracing baseline #136

@justinrayshort

Description

@justinrayshort

Summary

Establish a repository-owned Rust build hygiene and tracing baseline by tightening workspace build profiles, adding repeatable cargo xtask rust audit/cleanup/trace workflows, and closing the documented UI tracing bootstrap gap without changing intended product behavior.

Problem Statement

The workspace target/ directory can grow to tens of gigabytes during normal development, and the repository currently lacks a first-class, repo-owned way to audit artifact growth, perform targeted cleanup, or standardize tracing/debug launch workflows. The root workspace manifest also does not yet encode the intended lean dev / opt-in rich debugging / stripped release profile policy. Separately, ui/README.md documents that the browser site entrypoint still only installs the panic hook and that desktop_tauri does not yet install the native JSON tracing subscriber expected by the architecture. That leaves build hygiene and structured diagnostics partially manual and inconsistently discoverable.

Proposed Solution

Add root Cargo profile policy for lean daily development, extend xtask with a dedicated rust command group for repeatable audit/cleanup/trace workflows, and extend shared/telemetry with shared runtime/environment typing plus browser/native tracing bootstrap helpers. Wire the browser and desktop entrypoints to install tracing bootstrap while preserving existing visible warning paths in desktop_runtime until end-to-end parity is verified. Keep the work additive, deterministic, and repo-owned rather than introducing external cache tooling or ad hoc scripts.

Primary Architectural Plane

cross-layer

Architectural References

  • AGENTS.md
  • ARCHITECTURE.md
  • docs/architecture/layer-boundaries.md
  • xtask/AGENTS.md
  • ui/README.md
  • docs/process/github-workflow-migration.md
  • DEVELOPMENT_MODEL.md

Owning Subsystem

  • Root workspace Cargo policy
  • xtask repository-native tooling
  • shared/telemetry tracing bootstrap
  • ui/crates/site and ui/crates/desktop_tauri runtime entrypoints

Integration Boundaries

  • Allowed: root Cargo.toml, .cargo/config.toml, xtask/, shared/telemetry/, ui/crates/site/, ui/crates/desktop_tauri/, README.md, DEVELOPMENT_MODEL.md, ui/README.md, and matching plans/ execution artifacts.
  • Allowed: shared tracing/bootstrap helpers consumed through typed workspace crates only.
  • Non-goal: redesign runtime contracts or schema versions.
  • Non-goal: add direct UI coupling to services, workflows, or SurrealDB.
  • Non-goal: replace existing visible warning paths in desktop_runtime with tracing-only diagnostics before parity is verified.

Impacted Domains

  • Repository-native build and validation tooling
  • Shared telemetry / observability substrate
  • Browser and desktop UI bootstrap paths
  • Contributor workflow documentation

Affected Consistency Class

Not Applicable

Affected Risk Tier

high

Scope In

  • Add root workspace profile settings for lean dev, opt-in debugging, and stripped release.
  • Add cargo xtask rust audit|clean|trace plus matching cargo aliases.
  • Implement read-only artifact audit reporting, optional timings capture, and targeted cleanup planning/apply flows.
  • Implement trace launch presets for browser, desktop, and Cargo-focused debugging workflows.
  • Extend shared/telemetry with runtime/environment models and browser/native tracing bootstrap helpers.
  • Wire site and desktop_tauri to initialize tracing bootstrap and emit initial lifecycle events.
  • Update contributor docs and add matching plans/<issue-id>-<slug>/ execution artifacts.

Scope Out

  • External cache backend adoption such as sccache or remote artifact reuse.
  • Repository-wide conversion of all existing warning/error callsites to tracing.
  • Product-facing behavior changes unrelated to build hygiene or tracing bootstrap.
  • Contract/schema version redesign.

Acceptance Criteria

  • Root workspace profiles encode the lean dev / debugging / stripped release policy.
  • cargo xtask rust audit, cargo xtask rust clean, and cargo xtask rust trace exist with deterministic help and test coverage.
  • Audit output reports target usage, major subtree breakdowns, dependency duplication/features context, and build-script rerun hygiene; timings remain opt-in.
  • Cleanup defaults to dry-run and requires explicit apply for destructive removal.
  • site installs wasm-compatible tracing alongside the panic hook, and desktop_tauri installs the native JSON tracing subscriber before host startup.
  • Existing desktop_runtime visible warning paths remain intact in this change set.
  • Repository docs describe the new commands, profile policy, and tracing bootstrap status accurately.

Validation Requirements

  • cargo test -p xtask
  • cargo test -p telemetry
  • cargo check -p desktop_tauri
  • cargo xtask verify profile ui
  • cargo verify-repo
  • cargo xtask ui-hardening
  • Smoke cargo xtask rust audit, cargo xtask rust clean incremental, and cargo xtask rust trace desktop --dry-run

Validation Artifacts

  • Passing command output for the validation commands above
  • New xtask tests covering parsing/reporting/cleanup planning/trace presets
  • New telemetry tests covering environment parsing and bootstrap configuration
  • Committed task contract and execution plan under plans/<issue-id>-<slug>/

Rollback Considerations

Rollback should revert the workspace profile policy, xtask command surface, telemetry bootstrap, UI entrypoint wiring, docs, and execution artifacts together so the repository does not retain mismatched command/documentation or partially enabled tracing assumptions.

Rollback Path

Revert the issue branch commit set as one unit, restoring the prior root manifest, xtask help/aliases, telemetry crate, UI entrypoints, and docs. If rollback occurs after follow-on work begins, revert this issue before any dependent tracing-only callsite migrations so the repository returns to the previous visible-diagnostics-only baseline cleanly.

Technical Notes

  • tokio-console support should remain native-host only and opt-in behind the cargo xtask rust trace desktop --tokio-console path.
  • Audit and cleanup flows should stay on Cargo built-ins plus deterministic filesystem traversal; no external cleanup tool dependency should be added.
  • Report artifacts should follow existing xtask patterns and live under ignored output directories.

Related Issues

  • Follow the repo-local execution artifact protocol for multi-plane / high-risk work.
  • Shared observability alignment should remain compatible with the existing UI observability direction documented in ui/README.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumDefault delivery priority.type:refactorInternal design or structure improvement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions