Status: RFI complete, extraction execution pending. Issue: #2263 Linear parent: RMN-243
This spike is strictly no-behavior-change planning for the M4-5 workspace split.
Goals:
- capture reproducible compile baseline metrics
- define crate boundary and dependency contract
- define CI/feature-matrix impact and rollback posture
- define stacked PR slicing plan (XS/S/M)
Out of scope:
- broad API redesign
- feature additions bundled with structure work
- one-shot mega-PR extraction
scripts/ci/m4_5_rfi_baseline.sh /tmp/zeroclaw-m4rfi-targetBefore timing could run cleanly, two compile blockers were found:
src/gateway/mod.rs:2176:run_gateway_chat_with_toolscall missingsession_idargumentsrc/providers/cursor.rs:233:ChatResponseinitializer missingquota_metadata
RFI includes minimal compile-compat fixes for these two blockers so measurements are reproducible.
| Phase | real(s) | status |
|---|---|---|
A: cold cargo check --workspace --locked |
306.47 | pass |
B: cold-ish cargo build --workspace --locked |
219.07 | pass |
C: warm cargo check --workspace --locked |
0.84 | pass |
D: incremental cargo check after touching src/main.rs |
6.19 | pass |
Observations:
- cold check is the dominant iteration tax
- warm-check performance is excellent once target artifacts exist
- incremental behavior is acceptable but sensitive to wide root-crate coupling
Current workspace members:
.(zeroclawmonolith crate)crates/robot-kit
Code concentration still sits in the monolith. Large hotspots include:
src/config/schema.rssrc/channels/mod.rssrc/onboard/wizard.rssrc/agent/loop_.rssrc/gateway/mod.rs
Target crate topology for staged extraction:
crates/zeroclaw-types
- shared DTOs, enums, IDs, lightweight cross-domain traits
- no provider/channel/network dependencies
crates/zeroclaw-core
- config structs + validation, provider trait contracts, routing primitives, policy helpers
- depends on
zeroclaw-types
crates/zeroclaw-memory
- memory traits/backends + hygiene/snapshot plumbing
- depends on
zeroclaw-types,zeroclaw-corecontracts only where required
crates/zeroclaw-channels
- channel adapters + inbound normalization
- depends on
zeroclaw-types,zeroclaw-core,zeroclaw-memory
crates/zeroclaw-api
- gateway/webhook/http orchestration
- depends on
zeroclaw-types,zeroclaw-core,zeroclaw-memory,zeroclaw-channels
crates/zeroclaw-bin(or keep root binary package name stable)
- CLI entrypoints + wiring only
Dependency rules:
- no downward imports from foundational crates into higher layers
- channels must not depend on gateway/http crate
- keep provider-specific SDK deps out of
zeroclaw-types - maintain feature-flag parity at workspace root during migration
Required CI adjustments during migration:
- add workspace compile lane (
cargo check --workspace --locked) - add package-focused lanes for extracted crates (
-p zeroclaw-types,-p zeroclaw-core, etc.) - keep existing runtime behavior lanes (
test,sec-audit,codeql) unchanged until final convergence - update path filters so crate-local changes trigger only relevant crate tests plus contract smoke tests
Guardrails:
- changed-line strict-delta lint remains mandatory
- each extraction PR must include no-behavior-change assertion in PR body
- each step must include explicit rollback note
Per-step rollback (stack-safe):
- revert latest extraction PR only
- re-run workspace compile + existing CI matrix
- keep binary entrypoint and config contract untouched until final extraction stage
Abort criteria:
- unexpected runtime behavior drift
- CI lane expansion causes recurring queue stalls without signal gain
- feature-flag compatibility regressions
- add crate shells + workspace wiring (
types/core), no symbol moves - objective: establish scaffolding and CI package lanes
- extract low-churn shared types into
zeroclaw-types - add re-export shim layer to preserve existing import paths
- extract config/provider contracts into
zeroclaw-core - keep runtime call sites unchanged via compatibility re-exports
- extract memory subsystem crate and move wiring boundaries
- run full memory + gateway regression suite
- extract channels/api orchestration seams
- finalize package ownership and remove temporary re-export shims
Open first no-behavior-change extraction PR from this RFI baseline:
- scope: workspace crate scaffolding + CI package lanes only
- no runtime behavior changes
- explicit rollback command included in PR body