Parsers move with git mv and hand records to a Collector; the old browser/firefox runs them, and app now discovers Firefox. A profile without a usable key exports its logins instead of panicking, as RFC-008 now lists.
9.6 KiB
RFC-012: Migration Roadmap
One integration branch
The rewrite is built on the integration branch refactor/main-v2, cut from main, on the existing module path and with no v2. Every step is a pull request into that branch, squash-merged once CI is green, so each step becomes one commit whose title carries its PR number. main is frozen meanwhile — no Go changes and no bot commits land there — and keeps shipping v1.1.x from today's code.
When Phase 8 is done, a final pull request from refactor/main-v2 to main runs the full CI, and main is fast-forwarded to the branch, so every step commit keeps its order, its date, and its PR number. If main moved after all, the branch is first rebased onto it with --committer-date-is-author-date, building and testing every replayed commit. GitHub's "Rebase and merge" button is not used for that final step: it rewrites every commit's committer and date.
Inside the branch the rewrite is still incremental: new internal/ packages grow beside the current code, one base is wired end to end before the others follow, and old code is deleted only once its replacement is tested. Because the compatibility contract (RFC-000) freezes the CLI and the output, "stable" is checkable: at no commit does a command line, an output file, a keys.json, or an archive change outside the listed fixes. Every commit builds and passes the compatibility suite, so git bisect works across the whole rewrite once it is on main.
Phase order
Leaves first, bottom-up along the dependency arrows (RFC-002); then one vertical slice through the whole pipeline; then the rest of the browsers. A pure bottom-up order would first exercise the new stack end to end in its last phase, after weeks of adapters; the slice moves that moment to the middle.
Phase 0 — Scaffold and guardrails
- Make
rfcs/the one design record: the design RFCs (000–012) and the format and technique RFCs (013–021), indexed byrfcs/README.md; the RFCs they supersede are removed. - Add
tagliatelle(RFC-011), so every new record,keys.json, and manifest field keeps its snake_case wire name from day one. - Pin CI to Go
1.20.xand fail on anygodirective other than1.20or on atoolchainline. - Capture the compatibility goldens from today's code: the per-command CLI flag sets first; then output-parity fixtures for every format (with URLs that exercise JSON escaping), and sample
keys.jsonfiles and archives. - No behavior change. CLAUDE.md's "no
pkg/+internal/" note is updated to reflect theinternal/-only decision.
Phase 1 — Leaves
- Move the utility code into named homes:
utils/sqliteutil→sqlitex, the per-browser epoch helpers →timeconv,log→internal/log(name kept). - These have no project-internal dependencies beyond
log, so they move with mechanical refactors and their existing tests.
Phase 2 — category, record, and export
- Introduce
internal/category—Categorywith bare values numbered from 1, today'sString()values,AllandParse— andinternal/record:Login,Cookie, and the other record types with flatBrowser+Profilefields followed by today's field names and order, set throughrecord.Stamp(RFC-003). - Apply the naming in RFC-004 verbatim:
types.Category→category.Category,types.LoginEntry→record.Loginand every other…Entry→ its bare name, noCategoryprefix, noOwner/Originumbrella. - Move
outputtointernal/export—Writerand thecsv,json, andcookie-editorencoders — on the new record types (RFC-008). It depends only oncategory,record, andlog. - Move the row order out of the extractors into the exporter (RFC-008), so an extractor emits rows in source order. This lands the Firefox history order fix with its regression test.
- No other output change:
tagliatelleand the parity suite must stay green.
Phase 3 — crypto, masterkey, keychain, winapi
- Make
cryptopure primitives; move OS secret-store work intomasterkey— retrievers per OS,RetrieveAllwith first-key-wins per version and independent versions,Versionas a string type,DecryptDPAPI, thekeys.jsonDumpunchanged at version"2",ABEKind(RFC-006). No technique is rewritten — only the boundary is drawn. - Add
internal/keychain(macOS only): the login keychain handle, opened on first use and at most once per run. The macOSv10retriever reads through it from this phase, the Safari base when it is ported (Phase 6); today's separate password check and per-consumer keychain opens go away at the switch-over (Phase 7), once both read through it (RFC-006). - Fold
utils/{winapi,winutil}intointernal/winapi. The ABE unit —utils/injectorandcrypto/windows/with its C sources, generatedbootstrappackage, andpayloadembed package, plusMakefile.frag— stays where it is; only its importers change. Its move tointernal/abe/is DEFERRED (RFC-002).
Phase 4 — snapshot
- Build
internal/snapshot(RFC-007):Dir(Temp,Open,Unzip,Capture,Snapshot,Zip,Close) andSnapshot.Pathwith the per-file error contract, the copier with the Windows locked-file fallback and SQLite sidecars, user-data-dir IDs in the layout, and0700temp snapshot directories removed on every exit path. - Replace
otiai10/copywith the snapshot copier (RFC-010). archiveandrestoremove onto the snapshot; the archive-layout andkeys.jsoncompatibility tests guard both directions.
Phase 5 — Vertical slice: the Chromium base end to end
- Add the
browser.Deftable with the Chromium rows,browser.ProfileSnapshotand the per-dirMasterKeyscall-once inapp(with the run's login keychain added to theLocatoron macOS), the Chromium base package (Discover,Extractors,KeyLocator,ArchiveSources, the Yandex and Opera overrides), and theappstages —Validate,Discover,NewPlan,Execute,Report(RFC-001). - The new path runs beside today's; on the fixtures its output must equal the Phase 0 goldens byte for byte, and the Windows host compares it against the cookie/key baseline.
Phase 6 — Widen: Firefox and Safari
- Port the Firefox and Safari bases one category at a time, each with a
testdata/fixture and golden. - Land the remaining listed output fixes here — Firefox bookmark fields and Safari bookmark IDs — each with its regression test and as an expected diff in the parity suite.
- With the Firefox base, a profile whose key cannot be recovered exports its logins instead of stopping the run (RFC-008); the goldens do not change.
Phase 7 — Switch over
dump,dumpkeys,archive,restore, andlistrun on the pipeline.archivewrites the snapshotmanifest.jsonandrestorereads it as itsDiscovery(RFC-007): writer and reader land together, so the round trip is tested end to end, and every earlier archive stays byte-identical to today's.- Validate-first ordering,
--keychain-pw-stdinwith the new precedence, the-pfixes, the safe--ziporder, and therestorestamp fix (RFC-009).
Phase 8 — Delete & document
- Remove the superseded top-level packages —
browser/,crypto/except the ABE unit'scrypto/windows/,filemanager/,log/,masterkey/,output/,types/, andutils/exceptutils/injector— once nothing references them. - Move the compatibility tests out of
cmd/hack-browser-datainto the packages they cover — the export goldens intoexport,keys.jsonintomasterkey, the archive intosnapshot, the extract goldens intobrowser/chromium, andrestoreintoapp— each with its goldens in its owntestdata/;cmdkeeps only the flag-surface test, and the roottestdata/goes away. - Update CLAUDE.md (the new paths), the README (Safari, the
cookie-editorbehavior), and the root help text. - Bring the RFCs to their finished state: the format and technique RFCs (013–021) move from today's type names —
BrowserConfig,WindowsABE,winutil.Table,Hints, theRetrieversstruct — to the names in RFC-004; the design RFCs describe the code as it is instead of comparing it with today's; and this roadmap is removed. - Final
go mod tidyunder go@1.20; confirm thegodirective is still1.20andotiai10/copyandmintare gone.
Guardrails per phase
- Every phase keeps
go build ./cmd/hack-browser-data/green on Go 1.20.x across all three OSes. - Every phase keeps the compatibility suite green: the same flag sets, byte-identical output except for the listed fixes, and readable
keys.jsonand archives in both directions. - Every phase is one or more reviewable PRs into
refactor/main-v2, each with its own tests; no PR depends on a later one to compile. - The Windows ABE and locked-file smoke test runs at the end of Phases 3, 4, 5, and 7 — the phases that can affect key retrieval or acquisition — against the current cookie/key baseline, on the dedicated Windows host.
What ships when
Nothing from the rewrite ships before it reaches main. Until then main keeps releasing v1.1.x from today's code; after the fast-forward, the next release is cut from the rewritten tree. Because the CLI and the output are frozen, users see no difference except the listed fixes.