 : bootstrap-factor ( path -- )
     [
         <process>
-            factor-path "-i=" my-boot-image-name append "-no-user-init" 3array >>command
+            factor-path "-i=" my-boot-image-name append "-no-user-init" 3array
+            os macosx = [ { "arch" "-x86_64" } prepend ] when
+                >>command
             +closed+ >>stdin
             "./bootstrap-log" >>stdout
             +stdout+ >>stderr

        [ try-process ] parallel-each
    ] with-directory ;

: build-new-factor ( branch/checksum -- )
    "factor" "factor" zealot-github-ensure drop

    [ "factor" "factor" zealot-github-clone-paths nip ] dip

        [ drop "factor" "factor" zealot-github-add-build-remote drop ]
        [ drop [ git-fetch-all* ] with-directory drop ]
        [ zealot-build-checkout drop ]
        [ ]
    } 2cleave ;

: bootstrap-new-factor ( path branch/checksum -- path branch/checksum )
    {
        [ "ZEALOT DOWNLOADING BOOT IMAGE" print flush download-my-boot-image ]
        [ "ZEALOT DOWNLOADING CHECKSUMS" print flush download-boot-checksums ]
        [ "ZEALOT COMPILING" print flush drop compile-factor ]
        [ "ZEALOT BOOTSTRAPPING" print flush drop bootstrap-factor ]
        [ ]
    } 2cleave ;

: test-new-factor ( path branch/checksum -- )
    {
        [ "ZEALOT LOADING ROOTS" print flush drop zealot-load-commands ]
        [ "ZEALOT TESTING ROOTS" print flush drop zealot-test-commands ]
    } 2cleave ;

: check-new-factor ( path branch/checksum cmd -- out )
    nip [ factor-path "-i=factor.image" ] dip "-e=%s" sprintf 3array
    "./test-bisect-log" zealot-test-command
    '[ _ utf8 [ read-contents ] with-process-reader ] with-directory ;

: build-new-factor ( branch/checksum -- )
    checkout-new-factor bootstrap-new-factor test-new-factor ;

: bisect-new-factor ( branch/checksum cmd -- out )
    [ checkout-new-factor bootstrap-new-factor ] dip check-new-factor ;

: factor-clean-branch ( -- str )
    os cpu [ name>> ] bi@ { { CHAR: . CHAR: - } } substitute
