From 3350be68d5c54a28d765ca71863d860c5e313d92 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 4 Apr 2017 00:14:06 +0200 Subject: [PATCH] Moved remotes and mirrors out of stories/tales and into global state. --- app/talk-agent.hoon | 69 ++++++++++++++++++++---------------------- app/talk-guardian.hoon | 52 ++++++++++++++++--------------- sur/talk.hoon | 6 ++-- 3 files changed, 65 insertions(+), 62 deletions(-) diff --git a/app/talk-agent.hoon b/app/talk-agent.hoon index 0e0b647bb..dfd0642bc 100644 --- a/app/talk-agent.hoon +++ b/app/talk-agent.hoon @@ -23,6 +23,8 @@ => |% :: data structures ++ chattel :: full state $: tales/(map knot tale) :: conversations + remotes/(map partner atlas) :: remote presences + mirrors/(map station config) :: remote configs folks/(map ship human) :: human identities nik/(map (set partner) char) :: bound station glyphs nak/(jug char (set partner)) :: station glyph lookup @@ -31,10 +33,9 @@ ++ tale :: user-facing story $: count/@ud :: (lent grams) grams/(list telegram) :: all history + ::TODO given remotes and mirrors, do we still need locals and shape? locals/atlas :: presence - remotes/(map partner atlas) :: remote presences shape/config :: configuration - mirrors/(map station config) :: remote configs known/(map serial @ud) :: messages heard == :: ++ shell :: console session @@ -146,7 +147,9 @@ $glyph (ra-diff-talk-lowdown-glyph +.low) $names (ra-diff-talk-lowdown-names +.low) $tales (ra-diff-talk-lowdown-tales +.low) + $remco (ra-diff-talk-lowdown-remco +.low) $precs (ra-diff-talk-lowdown-precs +.low) + $rempe (ra-diff-talk-lowdown-rempe +.low) $grams (ra-diff-talk-lowdown-grams +.low) == :: @@ -183,41 +186,45 @@ ?~ h ~ (some [s u.h]) == - :: :: + :: ++ ra-diff-talk-lowdown-tales ::x apply tale configs. :: - |= tals/(map knot (unit cabal)) + |= {man/knot cof/(unit config)} ^+ +> - ::TODO for every changed config, (sh-low-config oldconfig newconfig) + ::TODO for changed configs, (sh-low-config oldconfig newconfig) :: maybe something else for new/removed tales? - %= +> tales - %+ roll (~(tap by tals)) - |= {t/(pair knot (unit cabal)) tas/_tales} - ~& [%r-new-config-for p.t] - =. tas ?~(tas tales tas) ::x start with our current tales. - =+ tal=(fall (~(get by tas) p.t) *tale) - ?~ q.t (~(del by tas) p.t) - (~(put by tas) p.t tal(shape loc.u.q.t, mirrors ham.u.q.t)) - == + ~& [%r-new-config-for man] + ?~ cof +>(tales (~(del by tales) man)) + =+ tal=(fall (~(get by tales) man) *tale) + +>.$(tales (~(put by tales) man tal(shape u.cof))) + :: + ++ ra-diff-talk-lowdown-remco + |= cofs/(map station config) + ^+ +> + ::TODO ++sh arm for printing of remote configs. + +>(mirrors (~(uni by cofs) mirrors)) :: ++ ra-diff-talk-lowdown-precs ::x apply new presence. :: - |= {man/knot pes/atlas pas/(map partner atlas)} + |= {man/knot pes/atlas} ^+ +> =+ tal=(~(get by tales) man) ?~ tal ~&([%low-precs-know-no-tale man] +>.$) =+ nel=(~(uni by pes) locals.u.tal) - ::TODO make better ++sh arms for this. =. +>.$ ?: =(locals.u.tal nel) +>.$ - sh-abet:(~(sh-low-precs sh ~ cli man) [locals.u.tal ~] [nel ~]) - =+ ner=(~(uni by pas) remotes.u.tal) ::TODO better uni. - =. +>.$ - ?: =(remotes.u.tal ner) +>.$ - sh-abet:(~(sh-low-precs sh ~ cli man) [~ remotes.u.tal] [~ ner]) - +>.$(tales (~(put by tales) man u.tal(locals nel, remotes ner))) + sh-abet:(~(sh-low-precs sh ~ cli man) locals.u.tal nel) + +>.$(tales (~(put by tales) man u.tal(locals nel))) + :: + ++ ra-diff-talk-lowdown-rempe + |= pas/(map partner atlas) + ^+ +> + =+ ner=(~(uni by pas) remotes) ::TODO better uni. + ?: =(remotes ner) +>.$ + =. remotes ner + sh-abet:(~(sh-repo-group-there sh ~ cli (main our.hid)) remotes ner) :: ++ ra-diff-talk-lowdown-grams ::x apply new grams @@ -368,13 +375,6 @@ =. l ?~(l loc l) ::TODO =? (~(uni by l) q.r) +>.$(locals pres) - :: - ++ pa-cabal - ::x update the tale's config. - :: - |= {cuz/station con/config ham/(map station config)} - ^+ +> - +>(shape con) -- :: ++ sh :: per console @@ -912,13 +912,10 @@ ++ sh-low-precs ::x print presence changes :: - |= $: old/(pair atlas (map partner atlas)) - new/(pair atlas (map partner atlas)) - == + |= {old/atlas new/atlas} ^+ +> - =+ dif=(sh-repo-atlas-diff p.old p.new) - =. +>.$ (sh-repo-group-diff-here "" dif) - (sh-repo-group-there q.old q.new) + =+ dif=(sh-repo-atlas-diff old new) + (sh-repo-group-diff-here "" dif) :: ++ sh-low-gram ::x renders telegram: increase gram count and print the gram. @@ -1155,7 +1152,7 @@ ::TODO clever use of =< and . take note! ~& [%who-ing pan] =+ tal=(~(got by tales) man) - =< (sh-fact %mor (murn (sort (~(tap by remotes.tal) ~) aor) .)) + =< (sh-fact %mor (murn (sort (~(tap by remotes) ~) aor) .)) |= {pon/partner alt/atlas} ^- (unit sole-effect) ?. |(=(~ pan) (~(has in pan) pon)) ~ =- `[%tan rose+[", " `~]^- leaf+~(ta-full ta man pon) ~] diff --git a/app/talk-guardian.hoon b/app/talk-guardian.hoon index 246363ee7..f9e15ae39 100644 --- a/app/talk-guardian.hoon +++ b/app/talk-guardian.hoon @@ -31,6 +31,8 @@ => |% :: data structures ++ house :: $: stories/(map knot story) :: conversations + remotes/(map partner atlas) :: remote presence + mirrors/(map station config) :: remote config ::TODO rename to readers? general/(set bone) :: our message readers outbox/(pair @ud (map @ud thought)) :: urbit outbox @@ -43,8 +45,6 @@ $: count/@ud :: (lent grams) grams/(list telegram) :: all history locals/atlas :: local presence - remotes/(map partner atlas) :: remote presence - mirrors/(map station config) :: remote config sequence/(map partner @ud) :: partners heard shape/config :: configuration known/(map serial @ud) :: messages heard @@ -458,20 +458,30 @@ ++ ra-welcome ::x brings reader new up to date. :: + ::TODO just like weld somehow |= new/bone - =. +> %- ra-emil :~ - :* new %diff %talk-lowdown %tales - %- ~(gas in *(map knot (unit cabal))) - %+ turn (~(tap by stories)) - |=({a/knot b/story} [a `[shape.b mirrors.b]]) - == - [new %diff %talk-lowdown %glyph nak] - [new %diff %talk-lowdown %names (~(run by folks) some)] - == - %- ra-emil + =. +> %- ra-emil + %- zing %+ turn (~(tap by stories)) |= {k/knot s/story} - [new %diff %talk-lowdown %grams k count.s grams.s] + ^- (list move) + :~ ::x story configurations + [new %diff %talk-lowdown %tales k `shape.s] + ::x local presences + [new %diff %talk-lowdown %precs k locals.s] + ::x telegrams + [new %diff %talk-lowdown %grams k count.s grams.s] + == + %- ra-emil + :~ ::x remote configurations + [new %diff %talk-lowdown %remco mirrors] + ::x remote presences + [new %diff %talk-lowdown %rempe remotes] + ::x bound glyphs + [new %diff %talk-lowdown %glyph nak] + ::x nicknames + [new %diff %talk-lowdown %names (~(run by folks) some)] + == :: ++ ra-think :: publish+review ::x consumes each thought. @@ -643,11 +653,6 @@ |= vew/(set bone) (pa-report vew %group locals pa-remotes) :: - ++ pa-lowdown-precs - ::x build a presence lowdown, containing our different presence maps. - :: - (pa-inform %precs man locals pa-remotes) - :: ++ pa-report-cabal :: update config ::x a cabal report, containing our and remote configs, to all bones. :: @@ -663,9 +668,8 @@ =+ old=mirrors =. mirrors (~(put by mirrors) cuz con) ?: =(mirrors old) +>.$ - =. +>.$ (pa-inform %tales (strap man `[con ham])) + =. +>.$ (pa-inform %remco mirrors) (pa-report-cabal pa-followers) - :: ++ pa-diff-talk-report :: subscribed update ::x process a talk report from cuz. @@ -689,7 +693,7 @@ =. +> %. pa-followers pa-report-cabal(sources.shape (~(del in sources.shape) tay)) - (pa-inform %tales (strap man `[shape mirrors])) + (pa-inform %tales man `shape) :: ++ pa-sauce :: send backward ::x turns cards into moves, reverse order, prepend to existing moves. @@ -753,7 +757,7 @@ ::x partners we gained/lost, and send out an updated cabal report. :: |= cof/config - =. +>.$ (pa-inform %tales (strap man `[cof mirrors])) + =. +>.$ (pa-inform %tales man `cof) =+ ^= dif ^- (pair (list partner) (list partner)) =+ old=`(list partner)`(~(tap in sources.shape) ~) =+ new=`(list partner)`(~(tap in sources.cof) ~) @@ -777,7 +781,7 @@ ^+ +> =/ nol (~(put by locals) her saz) ?: =(nol locals) +>.$ - =< pa-lowdown-precs + =. +>.$ (pa-inform %precs man nol) (pa-report-group(locals nol) pa-followers) :: ++ pa-remind :: remote presence @@ -790,7 +794,7 @@ =/ buk (~(uni by remotes) rem) ::TODO drop? =. buk (~(put by buk) tay loc) ?: =(buk remotes) +>.$ - =< pa-lowdown-precs + =. +>.$ (pa-inform %rempe buk) (pa-report-group(remotes buk) pa-followers) :: ++ pa-start :: start stream diff --git a/sur/talk.hoon b/sur/talk.hoon index fe55f4a5a..015c259c4 100644 --- a/sur/talk.hoon +++ b/sur/talk.hoon @@ -63,9 +63,11 @@ {$names (map ship (unit human))} :: new identities ::TODO cabal, or merge its contents into tale's config :: basically we just want to merge the ship sets, right? - {$tales (map knot (unit cabal))} :: changed config + {$tales (pair knot (unit config))} :: changed config + {$remco (map station config)} :: remote configs ::TODO merge remote and local presences. - {$precs (pair knot register)} :: changed presence + {$precs (pair knot atlas)} :: changed presence + {$rempe (map partner atlas)} :: remote presences {$grams (pair knot (pair @ud (list telegram)))} :: new grams == :: ++ speech :: narrative action