Skip to content

feat(rust): move stash save and restoration into the native client - #272

Merged
zkochan merged 2 commits into
rust-workspace-materializationfrom
rust-client-stash
Oct 17, 2026
Merged

zkochan merged 2 commits into
rust-workspace-materializationfrom
rust-client-stash

Conversation

@zkochan

@zkochan zkochan commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Moves stash save/s, list, and load/pop into the native client. Rust captures and persists detached Versions and file Sources, writes stash metadata, resets modified components, and removes included new components. Load restores saved new roots before merging tracked components against the detached Version's first parent, and consumes the stash only after success. Component heads and tracked bitmap versions stay unchanged.

The operation shares native checkout, dependency/import, configuration, package and removal engines. Harmony adapters supply registered environment/load/dependency facts and component-add/compile callbacks; source bodies, graph projection, serialization and VCS publication stay in Rust. No Node CLI sources changed and no documentation was added under docs/rust.

Parity preserves published Bit 2.2.94 behavior: lexical stash numbering, four-space metadata without a trailing newline, pre-allocation graph IDs and omitted graph Sources, existing-log restoration after modification checks, cached aspect facts during new-component cleanup, and pre-persistence rejection of unversioned dependencies. Retained source/repository/control/manifest proofs prevent stale publication. Metadata reads have byte and entry limits.

Missing existing version histories are persisted during status checks before selection, including no-op saves.

Strict released-CLI tests cover all 13 original stash cases plus aliases, messages, empty and malformed arguments, force/manual strategies, numbering rollover, binary/CRLF sources, dependency graphs, configured callbacks and startup errors, package/configuration/staged cleanup, embedded scopes, ID collisions and stale-source rejection. A dedicated Windows stash parity group repeats these cases.

Compatibility boundaries decline before publication: unsupported grammar, the published boolean pattern/empty-message quirks, unsafe or corrupt metadata, missing/re-added tracked components and canonical path recovery, unavailable dependencies and explicit resource limits.

Targets rust-workspace-materialization so it feeds into teambit#10813. Completes the stash chunk of #73; tracking/move/rename/deprecation, remaining command modes and safe TypeScript retirement remain open.

Validation: all seven required gates pass, plus focused export checks: 1,299 workspace tests (one existing ignored), 557 end-to-end tests including 26 stash oracles, 17 export package tests and five export callback tests. Release workspace build passes with warnings denied.

Complete-command measurements: 90 stash pairs (six workloads × five alternating pairs × non-TTY/TTY/CI) and 45 status/checkout/export regression pairs pass against the same release binary. Controlled Linux warm-metadata fixtures; no first-use or cross-platform speedup claim.

The checked-in records include binary/source/helper/fixture fingerprints and normalization details. They preserve exact history objects, package manifests, baseline backups and ordered backup reasons; only adjacent identical bitmap snapshots are deduplicated for the published same-second filename collision. Global builtin facts are validated and seeded identically outside timing. No broad cache or object exclusions.

Windows qualification fixes preserve exact Node CRLF bytes and check parent emptiness before deletion, including .DS_Store behavior. Stash retained state is boxed to avoid inflating every workspace session: the Windows lane-import stack overflow was reproduced on Linux with a 1 MiB limit and all three affected cases pass after the fix. Linux CI now enforces that limit.

The final 90 + 45 pairs use the fixed binary. Peak host CPU usage was 17.3%; contended samples are retained and explicitly excluded from speedup evidence. Rust medians were faster in all measured modes; new restoration remains near parity (1.01–1.08×).

@zkochan zkochan mentioned this pull request Oct 17, 2026
9 tasks done
@zkochan
zkochan merged commit 7fc635d into rust-workspace-materialization Oct 17, 2026
16 checks passed
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