%hawk
/app/gaia/hoon
:: gaia :: the heartbeat :: /+ dbug =- =/ trace %.n :: printfs :: =| heart =* state - ^- agent:gall %- agent:dbug |_ =bowl:gall +* this . dok [our.bowl %gaia] ++ on-init :: :_ this [%pass /init %agent dok %poke noun/!>(&)]~ :: ++ on-save :: !>(state) :: ++ on-load :: |= old-state=vase :_ this [%pass /init %agent dok %poke noun/!>(&)]~ :: ++ on-poke ::: |= [=mark =vase] ?+ mark %- (slog leaf+"gaia: unknown mark: {(trip mark)}" ~) `this %noun ?. !<(live=? vase) %- (slog 'gaia: stopped' ~) `this(next ~) ?~ next %- (slog 'gaia: reborn: %cycle-samsara' ~) =/ n (add now.bowl tick) :_ this(next `n) [%pass /set/[(scot %da n)] %arvo %b [%wait n]]~ %- (slog 'gaia: papancha' ~) `this %tick `this(tick !<(@dr vase)) :: == :: ++ on-watch :: |= =path `this :: ++ on-leave :: |= =path `this :: ++ on-peek :: |= =path ~ :: ++ on-agent |= [=wire =sign:agent:gall] ?: ?& ?=([%poke-ack *] sign) !=(~ p.sign) == %- (slog leaf+"{<wire>}" ~) %- (slog (fall p.sign ~['huh?'])) `this `this :: ++ on-arvo |= [=wire sign=sign-arvo] ?~ next %- (slog 'gaia: unborn: waiting to return.' ~) `this ?: =(wire /set/[(scot %da u.next)]) =/ n (add u.next tick) :_ this(next `n) :~ [%pass /set/[(scot %da n)] %arvo %b [%wait n]] [%pass /pulse %agent [our.bowl %hawk] %poke pulse/!>(/)] == %- (slog leaf+"gaia: confusion: {(spud wire)}" ~) `this :: ++ on-fail :: |= [=term =tang] %- (slog tang) `..on-init :: -- :: |% :: +$ heart $: next=(unit @da) tick=$~(~h1 @dr) == :: --