[{"data":1,"prerenderedAt":484},["ShallowReactive",2],{"blog-slat-19-en":3},{"number":4,"title":5,"summary":6,"parts":7,"toc":16,"minutes":483},19,"Migrating an existing codebase","You do not need a rewrite. SLAT is adopted in small pull requests that keep the application working the whole time, in an order that does not block other…",[8,11,14],{"kind":9,"html":10},"html","\u003Cp>You do not need a rewrite. SLAT is adopted in small pull requests that keep the application working the whole time, in an order that does not block other branches.\u003C\u002Fp>\n",{"kind":12,"name":13},"diagram","migration",{"kind":9,"html":15},"\u003Ch3 id=\"s19-1\">19.1. The order\u003C\u002Fh3>\n\u003Col>\n\u003Cli>\u003Cstrong>Measure.\u003C\u002Fstrong> Map the modules: lines per module, imports that point upward, files that use \u003Ccode>tauri::\u003C\u002Fcode>, number of \u003Ccode>#[tauri::command]\u003C\u002Fcode>, \u003Ccode>static\u003C\u002Fcode> with state, fields of the application state, \u003Ccode>#[cfg]\u003C\u002Fcode> for operating systems. Write it down in a plan in the repository. These numbers are your baselines.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Invert the upward dependencies.\u003C\u002Fstrong> Policies that live in the command layer but are called by lower layers move down to \u003Ccode>core\u002F&lt;policy&gt;\u002F\u003C\u002Fcode>. Types that the domain borrows from the entry layer (a line channel, an image type, a message string) move to the slice they belong to. The old path stays as a \u003Ccode>pub use\u003C\u002Fcode> until the migration ends.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Split \u003Ccode>app\u003C\u002Fcode> and \u003Ccode>core\u003C\u002Fcode>.\u003C\u002Fstrong> Create the workspace and a \u003Ccode>core\u003C\u002Fcode> crate without \u003Ccode>tauri\u003C\u002Fcode>. Code that knows Tauri stays in \u003Ccode>app\u003C\u002Fcode>; everything else moves with \u003Ccode>git mv\u003C\u002Fcode>. This is the most mechanical step.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Split out \u003Ccode>store\u003C\u002Fcode>, \u003Ccode>drivers\u003C\u002Fcode> and \u003Ccode>kit\u003C\u002Fcode>.\u003C\u002Fstrong> Only when their code is already clean. When you split \u003Ccode>drivers\u003C\u002Fcode>, move operating-system code into \u003Ccode>platform\u002F\u003C\u002Fcode>, and give the platform check its baseline.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Slice by slice.\u003C\u002Fstrong> One slice per pull request: commands into \u003Ccode>app\u002F&lt;s&gt;\u002F\u003C\u002Fcode>, logic into \u003Ccode>core\u002F&lt;s&gt;\u002F\u003C\u002Fcode> in the fixed layout. Start with the smallest and least shared.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>\u003Ccode>kit::Jobs\u003C\u002Fcode>.\u003C\u002Fstrong> The cancellation maps leave the application state.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Actors.\u003C\u002Fstrong> State from the application state and from \u003Ccode>static\u003C\u002Fcode> variables moves into actors, one flow per pull request, with \u003Ccode>update\u003C\u002Fcode> tests written first against the current behaviour.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Checks.\u003C\u002Fstrong> Each step switches on the check for its rule, with a baseline.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Ch3 id=\"s19-2\">19.2. Rules of migration\u003C\u002Fh3>\n\u003Cul>\n\u003Cli>\u003Cstrong>Moves do not change behaviour.\u003C\u002Fstrong> A pull request that moves code does not fix logic, and a pull request that fixes logic does not move code. When something breaks, you know which kind of change caused it.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Facades on old paths.\u003C\u002Fstrong> \u003Ccode>pub use new::place::*;\u003C\u002Fcode> at the old module path lets code you are not allowed to touch (or do not want to touch yet), and your existing tests, compile unchanged. A facade is removed when nothing imports it.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>One heavy build at a time.\u003C\u002Fstrong> Several parallel \u003Ccode>cargo\u003C\u002Fcode> builds of a large workspace can freeze a laptop. Migrate in one line.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Run the whole test suite after each step\u003C\u002Fstrong>, not after each commit. The suite is your proof that nothing moved in behaviour.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3 id=\"s19-3\">19.3. Layout first, a faster start\u003C\u002Fh3>\n\u003Cp>If findability is your biggest pain, you can reorder the work: first move \u003Cstrong>files\u003C\u002Fstrong> into slice folders inside the single existing crate, with no changes to their contents, and leave facades at the old paths. Git records these as renames, so other open branches still merge cleanly. You get the map (the folder of each feature) in a day or two, and the crate split, the layers inside each slice and the actors follow later on top of a layout that is already readable.\u003C\u002Fp>\n\u003Cp>Two things are not free even here. Files that use \u003Ccode>super::\u003C\u002Fcode> or \u003Ccode>pub(super)\u003C\u002Fcode> change their parent module when they move, so a few paths need small mechanical fixes. And moving commands out of a central file changes that file, which conflicts with branches that edit it, so it is better done as a separate second step.\u003C\u002Fp>\n\u003Ch3 id=\"s19-4\">19.4. What usually goes wrong\u003C\u002Fh3>\n\u003Cdiv class=\"table-wrap\">\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Problem\u003C\u002Fth>\n\u003Cth>What to do\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>Hundreds of tests import old paths\u003C\u002Ftd>\n\u003Ctd>Facades at the old paths. Do not move the tests in the same pull requests.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Parallel branches conflict with \u003Ccode>git mv\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>Do the crate splits when the fewest branches are open. Every move is its own pull request.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>pub(crate)\u003C\u002Fcode> items are needed from another crate after the split\u003C\u002Ftd>\n\u003Ctd>Widen them to \u003Ccode>pub\u003C\u002Fcode>. After the migration, review what can go back to \u003Ccode>pub(crate)\u003C\u002Fcode>.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Compile time grows with the number of crates\u003C\u002Ftd>\n\u003Ctd>At most six to eight crates. One heavy build at a time. Measure with \u003Ccode>cargo build --timings\u003C\u002Fcode> before and after each split (22.6).\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>A refactor quietly changes behaviour\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>update\u003C\u002Fcode> tests first, against today's behaviour. Moves and fixes in separate pull requests.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>A part of the code may not change at all (a critical feature, a frozen area)\u003C\u002Ftd>\n\u003Ctd>It stays where it is and reaches the new layout only through facades. Facades are additive code.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\u003C\u002Fdiv>\n",[17,35,39,43,47,67,91,107,127,151,155,163,195,199,223,227,251,287,291,311,331,347,383,431,479],{"id":18,"text":19,"depth":20,"children":21},"s1","1. Why SLAT exists",2,[22,27,31],{"id":23,"text":24,"depth":25,"children":26},"s1-1","1.1. Goals",3,[],{"id":28,"text":29,"depth":25,"children":30},"s1-2","1.2. Non-goals",[],{"id":32,"text":33,"depth":25,"children":34},"s1-3","1.3. Who should use it",[],{"id":36,"text":37,"depth":20,"children":38},"s2","2. SLAT on one page",[],{"id":40,"text":41,"depth":20,"children":42},"s3","3. Vocabulary",[],{"id":44,"text":45,"depth":20,"children":46},"s4","4. Where SLAT comes from",[],{"id":48,"text":49,"depth":20,"children":50},"s5","5. Tiers",[51,55,59,63],{"id":52,"text":53,"depth":25,"children":54},"s5-1","5.1. The compiler is the guard",[],{"id":56,"text":57,"depth":25,"children":58},"s5-2","5.2. How many crates to start with",[],{"id":60,"text":61,"depth":25,"children":62},"s5-3","5.3. When to split a tier",[],{"id":64,"text":65,"depth":25,"children":66},"s5-4","5.4. Compatibility exception",[],{"id":68,"text":69,"depth":20,"children":70},"s6","6. Slices",[71,75,79,83,87],{"id":72,"text":73,"depth":25,"children":74},"s6-1","6.1. A slice in core",[],{"id":76,"text":77,"depth":25,"children":78},"s6-2","6.2. A slice in app",[],{"id":80,"text":81,"depth":25,"children":82},"s6-3","6.3. A command, the reference shape",[],{"id":84,"text":85,"depth":25,"children":86},"s6-4","6.4. Registering commands",[],{"id":88,"text":89,"depth":25,"children":90},"s6-5","6.5. Naming slices",[],{"id":92,"text":93,"depth":20,"children":94},"s7","7. Who may import whom",[95,99,103],{"id":96,"text":97,"depth":25,"children":98},"s7-1","7.1. Inside a slice",[],{"id":100,"text":101,"depth":25,"children":102},"s7-2","7.2. Between slices",[],{"id":104,"text":105,"depth":25,"children":106},"s7-3","7.3. Why these particular lines",[],{"id":108,"text":109,"depth":20,"children":110},"s8","8. Data flows",[111,115,119,123],{"id":112,"text":113,"depth":25,"children":114},"s8-1","8.1. Query (a read)",[],{"id":116,"text":117,"depth":25,"children":118},"s8-2","8.2. Command (a change)",[],{"id":120,"text":121,"depth":25,"children":122},"s8-3","8.3. Event (backend → window)",[],{"id":124,"text":125,"depth":25,"children":126},"s8-4","8.4. High-volume streams",[],{"id":128,"text":129,"depth":20,"children":130},"s9","9. Actors: slices with state",[131,135,139,143,147],{"id":132,"text":133,"depth":25,"children":134},"s9-1","9.1. When to use an actor",[],{"id":136,"text":137,"depth":25,"children":138},"s9-2","9.2. Files",[],{"id":140,"text":141,"depth":25,"children":142},"s9-3","9.3. The contract",[],{"id":144,"text":145,"depth":25,"children":146},"s9-4","9.4. A complete small actor",[],{"id":148,"text":149,"depth":25,"children":150},"s9-5","9.5. Testing an actor",[],{"id":152,"text":153,"depth":20,"children":154},"s10","10. The variant explosion",[],{"id":156,"text":157,"depth":20,"children":158},"s11","11. AppState, the composition root",[159],{"id":160,"text":161,"depth":25,"children":162},"s11-1","11.1. kit::Jobs: one-shot background work",[],{"id":164,"text":165,"depth":20,"children":166},"s12","12. Platforms",[167,171,175,179,183,187,191],{"id":168,"text":169,"depth":25,"children":170},"s12-1","12.1. Layout",[],{"id":172,"text":173,"depth":25,"children":174},"s12-2","12.2. Contracts",[],{"id":176,"text":177,"depth":25,"children":178},"s12-3","12.3. What is forbidden outside platform\u002F",[],{"id":180,"text":181,"depth":25,"children":182},"s12-4","12.4. Paths, files and text",[],{"id":184,"text":185,"depth":25,"children":186},"s12-5","12.5. Platform tests",[],{"id":188,"text":189,"depth":25,"children":190},"s12-6","12.6. Enforcement",[],{"id":192,"text":193,"depth":25,"children":194},"s12-7","12.7. Porting to a new operating system",[],{"id":196,"text":197,"depth":20,"children":198},"s13","13. Errors",[],{"id":200,"text":201,"depth":20,"children":202},"s14","14. Testing by layer",[203,207,211,215,219],{"id":204,"text":205,"depth":25,"children":206},"s14-1","14.1. One integration binary",[],{"id":208,"text":209,"depth":25,"children":210},"s14-2","14.2. A fake driver without a trait",[],{"id":212,"text":213,"depth":25,"children":214},"s14-3","14.3. Mutants in the diff",[],{"id":216,"text":217,"depth":25,"children":218},"s14-4","14.4. Property tests for update",[],{"id":220,"text":221,"depth":25,"children":222},"s14-5","14.5. A test through the entry",[],{"id":224,"text":225,"depth":20,"children":226},"s15","15. Size limits",[],{"id":228,"text":229,"depth":20,"children":230},"s16","16. Enforcement",[231,235,239,243,247],{"id":232,"text":233,"depth":25,"children":234},"s16-1","16.1. A check with a baseline",[],{"id":236,"text":237,"depth":25,"children":238},"s16-2","16.2. A check must be able to fail",[],{"id":240,"text":241,"depth":25,"children":242},"s16-3","16.3. The platform job in CI",[],{"id":244,"text":245,"depth":25,"children":246},"s16-4","16.4. Checks for the whole set",[],{"id":248,"text":249,"depth":25,"children":250},"s16-5","16.5. Lints and bans before scripts",[],{"id":252,"text":253,"depth":20,"children":254},"s17","17. Recipes",[255,259,263,267,271,275,279,283],{"id":256,"text":257,"depth":25,"children":258},"s17-1","17.1. A new read (Query)",[],{"id":260,"text":261,"depth":25,"children":262},"s17-2","17.2. A new change without background state (Command)",[],{"id":264,"text":265,"depth":25,"children":266},"s17-3","17.3. A new slice",[],{"id":268,"text":269,"depth":25,"children":270},"s17-4","17.4. A new flow with state (actor)",[],{"id":272,"text":273,"depth":25,"children":274},"s17-5","17.5. A new driver (the outside world)",[],{"id":276,"text":277,"depth":25,"children":278},"s17-6","17.6. A new event for the window",[],{"id":280,"text":281,"depth":25,"children":282},"s17-7","17.7. A new platform",[],{"id":284,"text":285,"depth":25,"children":286},"s17-8","17.8. Where does this go? (decision tree)",[],{"id":288,"text":289,"depth":20,"children":290},"s18","18. Working with coding agents",[],{"id":292,"text":293,"depth":20,"children":294},"s19","19. Migrating an existing codebase",[295,299,303,307],{"id":296,"text":297,"depth":25,"children":298},"s19-1","19.1. The order",[],{"id":300,"text":301,"depth":25,"children":302},"s19-2","19.2. Rules of migration",[],{"id":304,"text":305,"depth":25,"children":306},"s19-3","19.3. Layout first, a faster start",[],{"id":308,"text":309,"depth":25,"children":310},"s19-4","19.4. What usually goes wrong",[],{"id":312,"text":313,"depth":20,"children":314},"s20","20. Case study: Quayside",[315,319,323,327],{"id":316,"text":317,"depth":25,"children":318},"s20-1","20.1. Before",[],{"id":320,"text":321,"depth":25,"children":322},"s20-2","20.2. Symptoms in the code",[],{"id":324,"text":325,"depth":25,"children":326},"s20-3","20.3. The migration, step by step",[],{"id":328,"text":329,"depth":25,"children":330},"s20-4","20.4. After",[],{"id":332,"text":333,"depth":20,"children":334},"s21","21. Adoption checklist and FAQ",[335,339,343],{"id":336,"text":337,"depth":25,"children":338},"s21-1","21.1. Checklist for a new project",[],{"id":340,"text":341,"depth":25,"children":342},"s21-2","21.2. Checklist for an existing project",[],{"id":344,"text":345,"depth":25,"children":346},"s21-3","21.3. Questions",[],{"id":348,"text":349,"depth":20,"children":350},"s22","22. Build and test time",[351,355,359,363,367,371,375,379],{"id":352,"text":353,"depth":25,"children":354},"s22-1","22.1. Where the time goes",[],{"id":356,"text":357,"depth":25,"children":358},"s22-2","22.2. Build settings",[],{"id":360,"text":361,"depth":25,"children":362},"s22-3","22.3. One set of features",[],{"id":364,"text":365,"depth":25,"children":366},"s22-4","22.4. Run what a change can affect",[],{"id":368,"text":369,"depth":25,"children":370},"s22-5","22.5. Many working copies",[],{"id":372,"text":373,"depth":25,"children":374},"s22-6","22.6. CI",[],{"id":376,"text":377,"depth":25,"children":378},"s22-7","22.7. What makes a build start over",[],{"id":380,"text":381,"depth":25,"children":382},"s22-8","22.8. Clean target\u002F",[],{"id":384,"text":385,"depth":20,"children":386},"s23","23. Plugins",[387,391,395,399,403,407,411,415,419,423,427],{"id":388,"text":389,"depth":25,"children":390},"s23-1","23.1. When a feature is a plugin",[],{"id":392,"text":393,"depth":25,"children":394},"s23-2","23.2. Layout",[],{"id":396,"text":397,"depth":25,"children":398},"s23-3","23.3. Direction",[],{"id":400,"text":401,"depth":25,"children":402},"s23-4","23.4. Extension points",[],{"id":404,"text":405,"depth":25,"children":406},"s23-5","23.5. On and off",[],{"id":408,"text":409,"depth":25,"children":410},"s23-6","23.6. Front-end",[],{"id":412,"text":413,"depth":25,"children":414},"s23-7","23.7. A plugin in its own crate",[],{"id":416,"text":417,"depth":25,"children":418},"s23-8","23.8. Testing",[],{"id":420,"text":421,"depth":25,"children":422},"s23-9","23.9. Turning an existing slice into a plugin",[],{"id":424,"text":425,"depth":25,"children":426},"s23-10","23.10. Enforcement",[],{"id":428,"text":429,"depth":25,"children":430},"s23-11","23.11. Plugins from outside",[],{"id":432,"text":433,"depth":20,"children":434},"s24","24. Plugin packages",[435,439,443,447,451,455,459,463,467,471,475],{"id":436,"text":437,"depth":25,"children":438},"s24-1","24.1. Built-in plugin or package",[],{"id":440,"text":441,"depth":25,"children":442},"s24-2","24.2. The process rule",[],{"id":444,"text":445,"depth":25,"children":446},"s24-3","24.3. Layout",[],{"id":448,"text":449,"depth":25,"children":450},"s24-4","24.4. The manifest",[],{"id":452,"text":453,"depth":25,"children":454},"s24-5","24.5. The protocol",[],{"id":456,"text":457,"depth":25,"children":458},"s24-6","24.6. Extension points for packages",[],{"id":460,"text":461,"depth":25,"children":462},"s24-7","24.7. Signing and the store",[],{"id":464,"text":465,"depth":25,"children":466},"s24-8","24.8. Life cycle",[],{"id":468,"text":469,"depth":25,"children":470},"s24-9","24.9. Permissions",[],{"id":472,"text":473,"depth":25,"children":474},"s24-10","24.10. Testing",[],{"id":476,"text":477,"depth":25,"children":478},"s24-11","24.11. Enforcement",[],{"id":480,"text":481,"depth":20,"children":482},"s25","25. Version history",[],77,1795449738257]