daemon/entry.bend relies on unsafe/foreign
raw source on the hub · import cswap-bend-cli@0.1.0.0/daemon/entry.bend as Entry
17 imports
import Base import ../fs.bend as Fs import ../act.bend as Act import ../clock.bend as Clock import ../store.bend as Store import ../cmd.bend as Cmd import ../store/base.bend as SBase import ../store/seq.bend as SSeq import ../swlive.bend as L import ./config.bend as Cfg import ../fmt/out.bend as O import ./live.bend as Lv import ../profflag.bend as Profflag import ./auto.bend as Auto import ../policy/types.bend as PT import ./pidlock.bend as Pid import ./shadowcli.bend as ShC
Definitions
def ActM source · line 23 · raw
@-A:Type -> Type
def ActM.pure source · line 26 · raw
@-A:Type -> @x:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(A)
def ActM.bind source · line 29 · raw
@-A:Type -> @-B:Type -> @m:0x0717344745a30ebad1f19045228e8f18/act.of(A) -> @f:(@_:A -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)) -> 0x0717344745a30ebad1f19045228e8f18/act.of(B)
def env_or source · line 32 · raw
@r:Result<&1, &1, Pair(U32, String), String> -> @+d:String -> String
def oracle_of source · line 39 · raw
@r:Result<&1, &1, Pair(U32, String), String> -> 0x0717344745a30ebad1f19045228e8f18/swlive.Oracle
def switch_opts source · line 49 · raw
@d:Result<&1, &1, Pair(U32, String), String> -> @o:Result<&1, &1, Pair(U32, String), String> -> 0x0717344745a30ebad1f19045228e8f18/swlive.Opts
How the daemon switches: the delay before the post-switch check ($CSWAP_SWITCH_VERIFY_DELAY_MS, default 2000) and where the ownership lookup goes ($CSWAP_SWITCH_ORACLE_FILE answers from a file; else the profile API).
def settings_text source · line 52 · raw
@r:0x0717344745a30ebad1f19045228e8f18/fs.Res(String) -> String
def settings_io source · line 59 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> IO(String)
def tick_body source · line 62 · raw
@+r:0x0717344745a30ebad1f19045228e8f18/daemon/auto.Run -> @+once:Bool -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def body source · line 66 · raw
@+r:0x0717344745a30ebad1f19045228e8f18/daemon/auto.Run -> @+once:Bool -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
The stream's first line, when the format has one (CSV: the header), then the ticks.
def flag_dry source · line 71 · raw
@+f:0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags -> Bool
def flag_fmt source · line 76 · raw
@+f:0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags -> 0x0717344745a30ebad1f19045228e8f18/fmt/out.Fmt
def flag_once source · line 81 · raw
@+f:0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags -> Bool
def started source · line 86 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+f:0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> @+cfg:0x0717344745a30ebad1f19045228e8f18/daemon/config.Cfg -> @+pid:U32 -> @+ts:String -> @+lv:0x0717344745a30ebad1f19045228e8f18/daemon/live.Live -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def go3 source · line 89 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+f:0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> @+text:String -> @+over:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def go2 source · line 96 · raw
@+bad:Maybe<&2, String> -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+f:0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> @+text:String -> @+over:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
A --profile that names nothing is a usage error.
def go source · line 103 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+f:0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> @+over:Maybe<&2, String> -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def with_flags source · line 108 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> @+over:Maybe<&2, String> -> @r:Result<&2, &2, String, 0x0717344745a30ebad1f19045228e8f18/daemon/config.Flags> -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def plain3 source · line 117 · raw
@+ok:Bool -> @+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> @+over:Maybe<&2, String> -> @+rest:List<&2, String> -> @+err:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
cswap auto ARGS (ARGS after the verb). state_dir is where the pid file,
status file and log live; pass the backup root when there is no better place.
def plain2 source · line 124 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> @+sp:0x0717344745a30ebad1f19045228e8f18/profflag.Split -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def plain source · line 129 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+args:List<&2, String> -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def routed source · line 132 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+sp:0x0717344745a30ebad1f19045228e8f18/daemon/shadowcli.Split -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def auto source · line 135 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+args:List<&2, String> -> @+state_dir:String -> @+opts:0x0717344745a30ebad1f19045228e8f18/swlive.Opts -> @+version:String -> 0x0717344745a30ebad1f19045228e8f18/act.of(U32)
def code_for source · line 141 · raw
@+code:U32 -> U32
2 for a usage error, 1 for everything else.
def finish source · line 144 · raw
@r:0x0717344745a30ebad1f19045228e8f18/fs.Res(U32) -> IO(Unit)
def cmd_of source · line 153 · raw
@r:0x0717344745a30ebad1f19045228e8f18/fs.Res(U32) -> IO(0x0717344745a30ebad1f19045228e8f18/cmd.Out)
The verb as a command result: events already went to stdout as they happened, so only the exit code (and a failure's message) remain.
def run2 source · line 160 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+args:List<&2, String> -> @+version:String -> @st:Result<&1, &1, Pair(U32, String), String> -> @d:Result<&1, &1, Pair(U32, String), String> -> @o:Result<&1, &1, Pair(U32, String), String> -> IO(0x0717344745a30ebad1f19045228e8f18/fs.Res(U32))
def run1 source · line 163 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+args:List<&2, String> -> @+version:String -> @st:Result<&1, &1, Pair(U32, String), String> -> @d:Result<&1, &1, Pair(U32, String), String> -> IO(0x0717344745a30ebad1f19045228e8f18/fs.Res(U32))
def run0 source · line 166 · raw
@+ctx:0x0717344745a30ebad1f19045228e8f18/store/base.Ctx -> @+args:List<&2, String> -> @+version:String -> @st:Result<&1, &1, Pair(U32, String), String> -> IO(0x0717344745a30ebad1f19045228e8f18/fs.Res(U32))
def run source · line 170 · raw
@+args:List<&2, String> -> @+version:String -> IO(0x0717344745a30ebad1f19045228e8f18/fs.Res(U32))
cswap auto ARGS reading $HOME, $CLAUDE_CONFIG_DIR and $CSWAP_STATE_DIR itself.
def auto_main source · line 174 · raw
@+args:List<&2, String> -> @+version:String -> IO(Unit)
The whole verb as an IO program that exits with the tick's code.
def auto_cmd source · line 178 · raw
@+args:List<&2, String> -> @+version:String -> IO(0x0717344745a30ebad1f19045228e8f18/cmd.Out)
The verb for the CLI dispatch (cswap auto ARGS).