Skip to content

Split the Rust backend into a Cargo workspace - #1431

Draft
xintaofei wants to merge 80 commits into
mainfrom
task/641
Draft

xintaofei wants to merge 80 commits into
mainfrom
task/641

Conversation

@xintaofei

Copy link
Copy Markdown
Collaborator

Draft for CI: src-tauri becomes a Cargo workspace (root package codeg, lib still codeg_lib).

  • crates/codeg-base: paths, process, appimage_env, logging
  • crates/codeg-protocol: cross-process messages and values (CLI wire, delegation transport, computer/browser requests, AgentType, intern)
  • crates/codeg-db-schema: entities + migrations
  • crates/codeg-history: parsers, acp_transcript, turn_timings, message models
  • apps/codeg-cli, apps/codeg-mcp, apps/codeg-computer-helper: the three sidecars as packages (the cli-bin, mcp-bin, computer-helper features are gone)

Moved modules keep their paths and are re-exported from codeg_lib, so test names and log targets are unchanged. CI: new crates cell (+ dependency-boundary and tracing-target checks), cli cell removed, 8 integration targets merged into tests/it, Release gains a workflow_dispatch rehearsal mode that builds without publishing.

Not compiled locally; this PR is how it gets compiled.

🤖 Generated with Claude Code

Root package inherits version/edition/authors from [workspace.package];
[workspace.dependencies] mirrors the root's third-party deps (serde_json
with preserve_order and raw_value) plus path entries for the seven crates
that the following commits create. The cli-bin, mcp-bin and
computer-helper features and their [[bin]] targets are gone: those
programs become packages under apps/.
src/cli/ becomes the codeg_cli library (cli/mod.rs -> lib.rs) and
src/bin/codeg_cli.rs its src/main.rs. The cli_run wire, discovery, hello,
policy, output_schema, service and worktree items and runtime_lock it uses
now come from codeg_protocol at their mirrored paths.
The codeg-cli client is its own package now; the cli-bin feature that
gated it is gone.
…b-schema

The root crate re-exports both modules at codeg_lib::db::{entities, migration},
so existing crate::db::entities / crate::db::migration paths keep resolving.
…to codeg-base

The logging hub now takes a plain emit callback; the app registers its
event emitter through logging::attach_event_emitter, and
apply_persisted_level (which reads the database) stays in the app's
logging::init. absolutize moves from git_credential into paths and
CHILD_HIDDEN_ENV (with the three SRN variable names) from
srn::web::config into appimage_env; both old paths re-export them.
… codeg-mcp bin) on codeg-protocol and codeg-base
…tes/codeg-history

Pure renames; the edges are fixed in the following commits.
…deg into apps/codeg-computer-helper

The executor (computer/helper, the codeg-computer-helper bin) moves behind
the package's default exec feature; appident, procinfo, codesign,
launch_req, spawn, tcc and the pins of driver become its library, which
codeg re-exports at computer::* and links without exec. The binary-cache
half of driver (ensure/forget/list/locate) stays in codeg. helper_data_dir
moves from helper::driver_proc to driver so codeg can find the helper's
home without the executor.
…oth packages

The fingerprint algorithm moves to build_support/helper_fingerprint.rs,
included by codeg's build script and the helper package's new one. Both
hash the helper package's src/ and codeg-protocol's src/computer/, under
paths relative to the workspace root, so they compute the same value.
m20261125_000001_personal_agent keeps the default-face tables and the
uid-to-face algorithm, m20261130_000001_model_provider_protocols the
legacy provider reading (with the part of the Codex model config parse
it reads), and m20261201_000001_personal_agent_handoff the tab and
canvas cleanup the sidebar's delete does, so the schema crate needs
nothing from the app. Root tests check the frozen copies still agree
with the live code; a crate test pins the migration list and order.
The tab service's migration-only helper goes.
…se rehearsal mode

workflow_dispatch builds every artifact at the tauri.conf.json version
without creating, uploading to or publishing a release and without pushing
images: bundles and server archives become workflow artifacts and the
Docker image is built, loaded and started per architecture. Every job now
reads the tag from create-draft-release's tag output.
…sts/it

The companion test drives codeg_mcp::companion now. desktop_bundle_bins
checks that the sidecars are workspace packages of their own.
…g-protocol

codeg-protocol carries what codeg-cli, codeg-mcp and the computer-use
helper need from the app, at the paths it had there: cli_run wire,
discovery and hello with the client-side constants and checks of policy,
output_schema, worktree, service and runtime_lock; the delegation
transport, types, roster lines and is_codeg_mcp_tool; the value types of
the browser, computer-use, chat-authoring, question and session-info
tools; browser agent/console/capture/eval/types; computer
agent/keys/targets/types/protocol; models::agent with the assistant
snapshot, automation action and bot avatar; intern.

The app re-exports each at its old path and keeps the runtime parts.
SOURCE_FINGERPRINT stays in the app's computer::protocol. AgentType's
Display reaches the custom-agent registry through a resolver the
registry registers when it is created. BotAvatar's validate and
as_assistant become the app's BotAvatarExt, and InputPolicy::of becomes
ComputerToolsConfig::input_policy.
…t codeg-protocol

The committed agent bundle now lives under
src-tauri/crates/codeg-protocol/src/browser/js/, and the bot shapes the
frontend test compares against are in codeg-protocol's
models/personal_agent_bots.rs.
- codeg-history gets lib.rs, its Cargo.toml (test-utils feature), and the
  pure pieces of acp:: the parsers use: prompt blocks from acp::types, the
  tool-call/prompt formatting from acp::connection, registry_id_for, the
  TRAE sessions dir (the custom-agent check is a hook custom_registry
  registers when it hydrates), the bundled models.dev snapshot, the
  OpenCode XDG/config helpers, session titles, fork fingerprints and the
  rewind turn text, plus ConversationSummary/Detail and SessionStats.
- codeg_lib re-exports every moved module and item at its old path;
  parsers::antigravity::background stays here and imports what it took
  from its parent before.
- Moved code is pub instead of pub(crate)/pub(super), tracing calls keep
  their codeg_lib::… targets, and the integration tests use codeg_history.
# Conflicts:
#	src-tauri/src/computer/mod.rs
The tool-call formatting the parsers share reads AIR `_meta` through
air_meta_value, so the AIR contract moves whole (it needs only AgentType);
codex_context moves whole again with it.
Cargo.lock gains the seven workspace members (cargo update --workspace,
no other version moves). The root's lib tests get codeg-history's test
constructors through a dev-dependency, since the server cell runs them
without test-utils. codeg-history reads the Hermes and OpenCode stores
through sea-orm, so the boundary check allows it there as it does for
codeg-db-schema. Committed files no longer point at the gitignored plan.
The attachment cap is read by acp::prompt_hydration and
personal_agent::handoff, which sit below the HTTP handlers once the
crates split. web::handlers::files re-exports it.
…tings_store

load_system_proxy_settings and load_system_language_settings, with the
keys and normalize_proxy_settings they need, move to
commands::system_settings_store so network::proxy and the personal agent
can read them from below the settings commands. commands::system_settings
re-exports them; the proxy normalization tests move along.
acp::codex_catalog_commit and the SRN account read the device label too.
snapshot re-exports it; its tests move along.
officecli_agent_path_dir, resolve_officecli, is_office_path and
officecli_known_install_paths move out of the harness-level office_tools
so acp::connection and office_watch can use them. commands::officecli
also carries resolve_command_on_path, which commands::acp will re-export.
…sation_ops

Creating conversations (plain, check, chat), loading a folder conversation
with its delegation and approval meta, and the sidebar upsert move to
commands::conversation_ops for the agent runtime, the board, the personal
agent and token_usage to call from below. commands::conversations
re-exports everything; the tests of the moved code move along and keep
their log target.
…ss cache from backup::sections

MANAGED_SECTIONS stays in the root package (its live paths reach the
skill store and the plugins store), so the two tests in lower modules that
walk it move next to it: the MCP engine's copies-and-lock check whole, and
the section half of the Harness cache check. harness::cache keeps the half
that pins where the cache and its entries live.
…gh a bridge

acp::pa_bridge holds the PersonalAgentBridge trait (tool calls, owner prompt,
ask input, owner cancel), the ToolOutcome it answers with, and free functions
that forward to the installed bridge or answer as a process with no assistants
does. The delegation listener calls those. DbAssistantLookup, which reads the
personal agent's own rules, moves to personal_agent::assistant_lookup and keeps
implementing the delegation layer's AssistantLookup; app_state builds it from
there. personal_agent::bridge implements the hooks and installs them
(install_hooks).
…lay to work_task

work_task::acceptance_gates holds the merge/delivery gates and what they write
(rounds, delivered head, stale marks, Accepted -> Changed); they always run, and
only refreshing the running assistant's card and opening its re-review reminder
go through the new work_task::pa_hooks (WorkTaskPaHooks), as does telling it a
task connection opened. work_task::handoff_replay holds replay_blocks,
is_addition and their read-only render chain, with the owner-answered query and
the AskCard it reads. personal_agent::{acceptance, handoff, asks} re-export
what moved; the work-task engine names the new paths.
…tRow with the menu bar

TraySink moves from personal_agent::menubar to commands::windows, which installs
a maker for it (commands::windows::install_tray_sink) through the menu bar;
the engine host makes the sink from it where it made TraySink before, and
draws no tray when none is installed. TrayBotRow moves to personal_agent::menubar;
commands::windows re-exports it.
…::delegation_shape

ARGS_WRAPPER_KEYS, find_delegation_args, is_delegation_invocation and the
code-mode JS scanner they use (CodeModeCallSite, code_mode_call_site,
code_mode_delegation_code, the skip_js_*/matching_* helpers, ...) are pure
functions over strings and JSON; the history replay in
commands::conversation_ops (codeg-core) needs them. acp::lifecycle uses back
what its broker-key extraction still needs and re-exports
is_delegation_invocation and ARGS_WRAPPER_KEYS. The nine recognition-only
tests move with them; the key-extraction tests stay.
…items by their new core paths

personal_agent and work_task call commands::conversation_ops,
commands::system_settings_store and web::upload_limit (split out of
commands::conversations, commands::system_settings and web::handlers::files).
…nt-skill and task-board items; layering for delegation_shape
… handoff replay to work, forge target, tray sink
…ints; run the layering check in CI

The layering check (zero violations now) runs in the Linux crates cell; its
glob re-exports resolve now (they were skipped, which only blunted the
report's suggestions).
…, codeg-work, codeg-harness and codeg-personal-agent

Phase 3, wave 2: the mechanical move (generated from scripts/layering.txt).
Each module goes to the crate layering.txt names, at its mirrored path, with
git mv. A module with parts in several crates becomes a facade in the others:
its parts there, plus re-exports of the parts below (a glob of the module
itself where its own file is in a crate below). The moved code names its old
tracing target explicitly, `pub(crate)` widens to `pub`, file-relative
include paths follow the move, and each crate's manifest lists what its code
uses. codeg-acp computes CODEG_COMPUTER_SOURCE in a build script of its own.
…he new layer; drop the wave-1 layering check

The desktop and server cells test codeg and the five middle-layer crates in
one invocation each (codeg's features reach them through its forwarding), the
crates cell keeps the rest. check-crate-boundaries.sh also keeps the middle
layer's direction (work and harness apart, personal-agent without harness)
and the server build free of tauri. Cargo itself enforces the layering now, so
the text-level check and layering.txt go.
…under test-utils

Items a crate's tests share with the tests of the crates above it (the
provider-list clock, the registry hydrate guard, model-provider and assistant
fixtures, the linked-worktree fixture, the MCP engine's write hooks, the
token-usage serial lock, the matter undo token, the SRN mock, the hermetic
home variables, the connection manager's test connections) are compiled
under `test-utils` too, which the crates above turn on as a dev-dependency.
Only what another crate uses; the rest stays `cfg(test)`.
…kspace_file_search

They were pub(super), shared with a sibling module that stays in the root
package.
…es parity test reads commands/acp.rs at its new path
…nder test-utils

cfg(test) is per crate now: the root package's tests (and the other crates'
above) call into codeg-acp and codeg-harness built without it, so a backup
restore test reached the real ~/.codeg/locks/skills.lock. The skills lock,
the MCP engine's lock and backup root, the Harness MCP record and the plugin
store pick their temp-dir stand-ins under test-utils as well, which those
crates' test builds turn on through their dev-dependencies (release builds
never do). Integration tests now get them too, where they used the real home.
…t-list export)

The split's effect is measured: the macOS desktop cell's cold `cargo test`
went from still compiling at 94 min with 5.75 GiB of swap (monolith) to
36.5 min end to end with 0.46 GiB; the per-cell test lists match name for
name across the move.
One macOS runner: brotli q9 over the real out/ at opt-level 0 and 3, then a
full desktop release build with a placeholder frontend (--timings), then the
root crate rebuilt with the placeholder and with the real frontend. Runs only
when this file is pushed; removed once measured.
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