@@ -61,7 +61,7 @@
6161 ?+ flow=(~(get by sub) which) `0/sub
6262 ~ [~[(pine which)] 0/(~(put by sub) which ~)]
6363 [~ ~] [~[(pine which)] 0/sub]
64− [~ ~ [* %& * *]] [~[(scry `+(aeon.u.u.flow) which)] 0/sub]
64+ [~ ~ [* %& * *]] [~[(pine which)] 0/sub]
6565 ==
6666 ++ quit (corl (lead %0) ~(del by sub)) :: Unsub from [ship dude path].
6767 ++ read :: See current subscribed states.
@@ -95,7 +95,7 @@
9595 [~ ~ *]
9696 =. stale.u.u.flow &
9797 :_ 0/(~(put by sub) current u.flow)
98− ~[(on-rock-poke current u.u.flow ~)]
98+ ~[(on-rock-poke fake=& current u.u.flow ~)]
9999 ::
100100 [~ ~]
101101 :_ 0/(~(del by sub) current) :_ ~
@@ -105,77 +105,53 @@
105105 [path ship dude]:current
106106 ==
107107 ==
108− :: :: Check if we're still interested
109− :: :: in a wave. If no, no-op.
110− :: :: If yes, scry.
111− ++ behn :: (See https://gist.github.com/belisarius222/7f8452bfea9b199c0ed717ab1778f35b)
112− |= [ship=term =dude aeon=term path=paths]
113− ^- (list card:agent:gall)
114− %- fall :_ ~ %- mole |.
115− =/ ship (slav %p ship)
116− =/ aeon (slav %ud aeon)
117− ?: (lte aeon aeon:(fall (~(got by sub) ship dude path) *flow)) ~
118− ~[(scry `aeon ship dude path)]
119− ::
120108 ++ apply :: Handle response from publisher.
121109 |= res=(response:poke lake paths)
122110 ^- (quip card:agent:gall subs)
123− %- fall :_ `0/sub %- mole |.
124111 =* current [src.bowl dude.res path.res]
125112 =/ old=flow (fall (~(got by sub) current) *flow)
126− ?- type.res
127− %tomb
113+ ?: ?=(%tomb what.res)
128114 =/ =flow old(stale &)
129115 :_ 0/(~(put by sub) current `flow) :_ ~
130− (on-rock-poke current flow ~)
131− ::
132− %yore
133− :_ 0/sub :_ ~
134− (pine src.bowl dude.res path.res)
116+ (on-rock-poke fake=& current flow ~)
135117 ::
136− %nigh
137− :_ 0/sub :_ ~
138− (behn-s25 [dude aeon path]:res)
139− ::
140− %scry
141− =/ [wave=(unit wave:lake) =flow]
142− ?- what.res
143− %rock ?> (gte aeon.res aeon.old)
144− [~ [aeon.res | | rock.res]]
145− %wave ?> =(aeon.res +(aeon.old))
146− [`wave.res [aeon.res | | (wash:lake rock.old wave.res)]]
147− ==
148− :_ 0/(~(put by sub) current `flow)
149− :~ (on-rock-poke current flow wave)
150− (scry `+(aeon.res) src.bowl dude.res path.res)
118+ =/ [wave=(unit wave:lake) new=(unit flow)]
119+ ?- what.res
120+ %rock ?: (lte aeon.res aeon.old) [~ ~]
121+ [~ `[aeon.res | | rock.res]]
122+ %wave ?: (lte aeon.res aeon.old) [~ ~]
123+ ?> =(aeon.res +(aeon.old))
124+ [`wave.res `[aeon.res | | (wash:lake rock.old wave.res)]]
151125 ==
152− ==
126+ ?~ new `0/sub
127+ :_ 0/(~(put by sub) current new) :_ ~
128+ (on-rock-poke fake=& current u.new wave)
129+ ::
130+ ++ handle-fake-on-rock
131+ |= =(on-rock:poke lake paths)
132+ ^- (list card:agent:gall)
133+ ?~ flow=(~(get by sub) [src from path]:on-rock) ~
134+ ?~ u.flow ~
135+ ?. =([stale fail rock]:u.u.flow [stale fail rock]:on-rock) ~
136+ ~[(on-rock-poke fake=| [src from path]:on-rock u.u.flow wave.on-rock)]
153137 ::
154138 :: Non-public facing arms below
155139 ::
156− ++ behn-s25
157− |= [=dude =aeon path=noun]
158− ^- card:agent:gall
159− :* %pass (zoom behn/(scot %p src.bowl)^dude^(scot %ud aeon)^path)
160− %arvo %b %wait (add ~s25 now.bowl)
161− ==
162− ++ pine |= [ship dude paths] (scry ~ +<)
163− ++ scry
164− |= [when=(unit aeon) who=ship which=dude where=paths]
140+ ++ pine
141+ |= [who=ship which=dude where=paths]
165142 ^- card:agent:gall
166− =/ when ?~ when ~ (scot %ud u.when)
167− :* %pass (zoom scry-request/(scot %p who)^which^when^where)
143+ :* %pass (zoom scry-request/(scot %p who)^which^where)
168144 %agent [who which]
169− %poke %sss-to-pub :- result-type ^- result
170− [where dap.bowl ^when]
145+ %poke sss-to-pub/[result-type `result`[where dap.bowl]]
171146 ==
172147 ++ on-rock-poke
173− |= [[=ship =dude path=paths] flow wave=(unit wave:lake)]
148+ |= [fake=? [=ship =dude path=paths] flow wave=(unit wave:lake)]
174149 ^- card:agent:gall
175− :* %pass (zoom on-rock/(scot %ud aeon)^(scot %p ship)^dude^path)
150+ :* %pass %+ zoom ?:(fake %fake %on-rock)
151+ (scot %ud aeon)^(scot %p ship)^dude^path
176152 %agent [our dap]:bowl
177− %poke %sss-on-rock on-rock-type ^- from
178− [path ship dude stale fail rock wave]
153+ %poke ?:(fake %sss-fake-on-rock %sss-on-rock)
154+ on-rock-type `from`[path ship dude stale fail rock wave]
179155 ==
180156 --
181157++ du :: Manage publications.
@@ -184,28 +160,78 @@
184160 |%
185161 +$ into (request:poke paths)
186162 +$ result (response:poke lake paths)
187− +$ rule [rocks=_1 waves=_5] :: Retention policy
163+ +$ rule $~ [`5 5]
164+ [horizon=(unit @ud) frequency=@ud] :: Retention policy
188165 +$ tide
189166 $: rok=((mop aeon rock:lake) gte)
190167 wav=((mop aeon wave:lake) lte)
191168 rul=rule
192− mem=(mip ship dude @da)
169+ mem=(jug ship dude)
193170 ==
194171 +$ buoy
195172 $: tid=$~(*tide $@(aeon tide))
196173 alo=(unit (set ship))
197174 ==
198− +$ pubs [%0 (map paths buoy)]
175+ ++ pubs
176+ =< $>(%1 versioned)
177+ |%
178+ ++ update
179+ |= =versioned
180+ ^- pubs
181+ ?- -.versioned
182+ %1 versioned
183+ %0
184+ :- %1
185+ %- ~(run by +.versioned)
186+ |= =buoy-0:^versioned
187+ ^- buoy
188+ %= buoy-0
189+ tid
190+ ?@ tid.buoy-0 tid.buoy-0
191+ ^- tide
192+ %= tid.buoy-0
193+ rocks.rul
194+ ?: =(waves.rul.tid.buoy-0 0) ~
195+ `(mul [+(rocks) waves]:rul.tid.buoy-0)
196+ ::
197+ mem
198+ ^- (jug ship dude)
199+ %- ~(run by mem.tid.buoy-0)
200+ |= =(map dude @da)
201+ ^- (set dude)
202+ ~(key by map)
203+ ==
204+ ==
205+ ==
206+ ++ versioned
207+ =< $% [%0 (map paths buoy-0)]
208+ [%1 (map paths buoy)]
209+ ==
210+ |%
211+ +$ buoy-0
212+ $: tid=$~(*tide-0 $@(aeon tide-0))
213+ alo=(unit (set ship))
214+ ==
215+ +$ tide-0
216+ $: rok=((mop aeon rock:lake) gte)
217+ wav=((mop aeon wave:lake) lte)
218+ rul=[rocks=@ud waves=@ud]
219+ mem=(mip ship dude @da)
220+ ==
221+ --
222+ --
199223 --
200− |= [pub=pubs =bowl:gall result-type=type]
201− => .(pub +.pub)
224+ |= [pub=versioned:pubs =bowl:gall result-type=type]
225+ => .(pub +:(update:pubs pub))
202226 =* rok ((on aeon rock:lake) gte)
203227 =* wav ((on aeon wave:lake) lte)
204228 |%
205229 ++ rule :: Set new retention policy.
206230 |= [path=paths =^rule]
207231 ^- pubs
208− :- %0
232+ :- %1
233+ %- fall :_ (~(put by pub) path %*(. *$<(aeon buoy) rul.tid rule))
234+ %- mole |.
209235 %+ ~(jab by pub) path
210236 |= =buoy
211237 ?@ tid.buoy buoy
@@ -214,11 +240,11 @@
214240 ++ wipe :: Create new rock and wipe rest.
215241 |= path=paths
216242 ^- pubs
217− :- %0
243+ :- %1
218244 %+ ~(jab by pub) path
219245 |= =buoy
220246 ?@ tid.buoy buoy
221− %* . buoy(tid (form tid.buoy(rul [0 1])))
247+ %* . buoy(tid (form tid.buoy(rul [`0 1])))
222248 rul.tid rul.tid.buoy
223249 wav.tid ~
224250 ==
@@ -227,23 +253,45 @@
227253 ^- (quip card:agent:gall pubs)
228254 ?~ ((soft ^path) path) ~| %need-path !!
229255 =/ buoy (~(gut by pub) path *buoy)
230− ?@ tide=tid.buoy ~| %dead-path !! ::TODO is this good behavior?
256+ =? buoy ?=(@ tid.buoy)
257+ %*(. buoy(tid *tide) rok.tid (put:rok ~ +(tid.buoy) *rock:lake))
258+ ?> ?=(^ tid.buoy)
259+ =* tide tid.buoy
231260 =/ next=aeon +((latest tide))
232− :- %+ murn ~(tap bi mem.tide)
233− |= [=ship =dude =@da]
234− ?: (lth da now.bowl) ~
235− `(send scry/wave/wave ship dude next path)
236− :- %0
261+ :- %- zing
262+ %+ turn ~(tap by mem.tide)
263+ |= [=ship =(set dude)]
264+ %+ turn ~(tap in set)
265+ |= =dude
266+ (send wave/[next wave] ship dude path)
267+ :- %1
237268 %+ ~(put by pub) path
238269 =/ last=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok)
239270 =. wav.tide (put:wav wav.tide next wave)
240− =. mem.tide (~(del by mem.tide) next)
241− ?. =(next (add aeon.last waves.rul.tide)) buoy
271+ =. mem.tide ~
272+ ?. =(next (add aeon.last frequency.rul.tide)) buoy
242273 buoy(tid (form tide))
243274 ::
275+ ++ fork :: Fork a pub into an empty path.
276+ |= [from=paths to=paths]
277+ ^- pubs
278+ :- %1
279+ ?< (~(has by pub) to)
280+ (~(put by pub) to (~(got by pub) from))
281+ ::
282+ ++ copy :: Fork a sub into an empty path.
283+ |= [sub=_(mk-subs lake *) from=[ship dude *] to=paths]
284+ ^- pubs
285+ :- %1
286+ ?< (~(has by pub) to)
287+ %+ ~(put by pub) to
288+ %* . *$<(aeon buoy)
289+ rok.tid (put:rok ~ [aeon rock]:(need (~(got by +:sub) from)))
290+ ==
291+ ::
244292 ++ perm :: Change permissions with gate.
245293 |= [where=(list paths) diff=$-((unit (set ship)) (unit (set ship)))]
246− ^- pubs
294+ ^- (quip card:agent:gall pubs)
247295 %+ edit where
248296 |= =buoy
249297 =/ new=_alo.buoy (diff alo.buoy)
@@ -252,21 +300,21 @@
252300 alo new
253301 mem.tid ?~ new mem.tid.buoy
254302 %. mem.tid.buoy
255− ~(int by (malt (turn ~(tap in u.new) (late *(map @ @)))))
303+ ~(int by (malt (turn ~(tap in u.new) (late *(set @)))))
256304 ==
257305 ++ public (curr perm _~) :: Make list of paths public.
258306 ++ secret (curr perm _`~) :: Make list of paths secret.
259307 :: :: Block ships from paths.
260308 ++ block :: No-ops on public paths.
261309 |= [who=(list ship) whence=(list paths)]
262− ^- pubs
310+ ^- (quip card:agent:gall pubs)
263311 %+ perm whence
264312 |= old=(unit (set ship))
265313 ?~ old ~ `(~(dif in u.old) (sy who))
266314 :: :: Allow ships to paths.
267315 ++ allow :: Any public paths will no-op.
268316 |= [who=(list ship) where=(list paths)]
269− ^- pubs
317+ ^- (quip card:agent:gall pubs)
270318 %+ perm where
271319 |= old=(unit (set ship))
272320 ?~ old ~ `(~(gas in u.old) who)
@@ -274,12 +322,6 @@
274322 ++ kill :: subs to not expect updates.
275323 (curr edit |=(=buoy buoy(tid (latest tid.buoy))))
276324 :: :: Reopen list of killed paths.
277− ++ live :: No-ops on live paths.
278− %+ curr edit
279− |= =buoy
280− ?^ tid.buoy buoy
281− %*(. buoy(tid *tide) rok.tid (put:rok ~ +(tid.buoy) *rock:lake))
282− ::
283325 ++ read :: See current published states.
284326 ^- (map paths [allowed=(unit (set ship)) =rock:lake])
285327 %- malt %+ murn ~(tap by pub)
@@ -299,37 +341,51 @@
299341 =/ =buoy (~(gut by pub) path.req *buoy)
300342 ?< &(?=(^ alo.buoy) !(~(has in u.alo.buoy) src.bowl))
301343 ?@ tid.buoy
302− :_ 0/pub :_ ~
303− (send tomb/~ src.bowl dude.req tid.buoy path.req)
304− ?~ when.req
305− =/ last (fall (pry:rok rok.tid.buoy) *[=key =val]:rok)
306− :_ 0/pub :_ ~
307− (send scry/rock/val.last src.bowl dude.req key.last path.req)
308− ?^ dat=(get:wav wav.tid.buoy u.when.req)
309− :_ 0/pub :_ ~
310− (send scry/wave/u.dat src.bowl [dude u.when path]:req)
311− ?: %+ lte u.when.req
312− key::(fall (ram:wav wav.tid.buoy) (pry:rok rok.tid.buoy) [=key val]:wav)
313− :_ 0/pub :_ ~
314− (send yore/~ src.bowl [dude u.when path]:req)
315− ?> =(u.when.req +((latest tid.buoy)))
316− :- ~[(send nigh/~ src.bowl [dude u.when path]:req)]
317− :- %0
318− %+ ~(put by pub) path.req
344+ :_ 1/pub :_ ~
345+ (send tomb/~ src.bowl dude.req path.req)
346+ :_ 1/pub :_ ~
347+ =/ last (fall (pry:rok rok.tid.buoy) *[=key =val]:rok)
348+ (send rock/last src.bowl dude.req path.req)
349+ ::
350+ ++ tell
351+ |= [[ship=term =dude aeon=term path=paths] =sign:agent:gall]
352+ ^- (quip card:agent:gall pubs)
353+ ?> ?=(%poke-ack -.sign)
354+ ?^ p.sign `1/pub
355+ =/ =buoy (~(gut by pub) path *buoy)
356+ ?< &(?=(^ alo.buoy) !(~(has in u.alo.buoy) src.bowl))
357+ ?@ tid.buoy
358+ :_ 1/pub :_ ~
359+ (send tomb/~ src.bowl dude path)
360+ ::
361+ => .(aeon +((slav %ud aeon)))
362+ ?^ dat=(get:wav wav.tid.buoy aeon)
363+ :_ 1/pub :_ ~
364+ (send wave/[aeon u.dat] src.bowl dude path)
365+ =/ last (fall (pry:rok rok.tid.buoy) [=key =val]:rok)
366+ ?: (lte aeon key.last)
367+ :_ 1/pub :_ ~
368+ (send rock/last src.bowl dude path)
369+ :- ~
370+ :- %1
371+ %+ ~(put by pub) path
319372 %= buoy
320− mem.tid (~(put bi mem.tid.buoy) src.bowl dude.req (add ~s25 now.bowl))
373+ mem.tid (~(put ju mem.tid.buoy) src.bowl dude)
321374 ==
322375 ::
323376 :: Non-public facing arms below
324377 ::
325378 ++ send
326− |= [payload=_|3:*(response:poke lake paths) =ship =dude =aeon path=paths]
379+ |= [payload=_|2:*(response:poke lake paths) =ship =dude path=paths]
327380 ^- card:agent:gall
328381 =* mark (cat 3 %sss- name:lake)
329− :* %pass (zoom scry-response/(scot %p ship)^dude^(scot %ud aeon)^path)
382+ =/ callback=^path
383+ ?: ?=(%tomb what.payload) (zoom tomb-response/(scot %p ship)^dude^path)
384+ (zoom scry-response/(scot %p ship)^dude^(scot %ud aeon.payload)^path)
385+ :* %pass callback
330386 %agent [ship dude]
331387 %poke mark result-type ^- (response:poke lake paths)
332− [path dap.bowl aeon payload]
388+ [path dap.bowl payload]
333389 ==
334390 ++ latest
335391 |= =$@(aeon tide)
@@ -340,31 +396,49 @@
340396 ::
341397 ++ edit
342398 |= [ps=(list paths) edit=$-(buoy buoy)]
343− ^- pubs
344− :- %0
399+ ^- (quip card:agent:gall pubs)
345400 %- ~(rep in (sy ps))
346− |= [path=paths =_pub]
347− %- fall :_ pub %- mole |.
348− (~(jab by pub) path edit)
401+ |= [path=paths caz=(list card:agent:gall) %1 =_pub]
402+ ?~ old=(~(get by pub) path) [caz 1/pub]
403+ =/ new=buoy (edit u.old)
404+ :_ 1/(~(put by pub) path new)
405+ %- weld :_ caz
406+ ^- (list card:agent:gall)
407+ ?@ tid.u.old ~
408+ ?@ tid.new
409+ %- zing
410+ %+ turn ~(tap by mem.tid.u.old)
411+ |= [=ship =(set dude)]
412+ (turn ~(tap in set) |=(=dude (send tomb/~ ship dude path)))
413+ ?~ alo.new ~
414+ =/ new-alo=(jug ship dude)
415+ (malt (turn ~(tap in u.alo.new) (late *(set @))))
416+ %- zing
417+ %+ turn ~(tap by (~(dif by mem.tid.u.old) new-alo))
418+ |= [=ship =(set dude)]
419+ (turn ~(tap in set) |=(=dude (send tomb/~ ship dude path)))
349420 ::
350421 ++ form
351422 |= =tide
352423 ^+ tide
353424 =/ max-rock=[=aeon =rock:lake] (fall (pry:rok rok.tide) *[key val]:rok)
354425 =/ max-wave (fall (bind (ram:wav wav.tide) head) 0)
355− =. rok.tide
356− %+ gas:rok +<-:gas:rok
357− %- tab:rok :_ [~ +(rocks.rul.tide)]
358− ?: ?| =(waves.rul.tide 0)
359− (lth max-wave (add aeon.max-rock waves.rul.tide))
360− ==
361− rok.tide
426+ =? rok.tide :: Create new rock.
427+ ?& !=(frequency.rul.tide 0)
428+ (gte max-wave (add aeon.max-rock frequency.rul.tide))
429+ ==
362430 %+ put:rok rok.tide
363431 %+ roll (tab:wav wav.tide `aeon.max-rock max-wave)
364432 |: [*[now=aeon =wave:lake] `[prev=aeon =rock:lake]`max-rock]
365433 ~| %aeon-awry
366434 ?> =(now +(prev))
367435 [now (wash:lake rock wave)]
436+ =. rok.tide
437+ ?~ horizon.rul.tide :: Only keep genesis and latest.
438+ (gas:rok ~ (murn ~[(ram:rok rok.tide) (pry:rok rok.tide)] same))
439+ %^ lot:rok rok.tide :: Delete beyond horizon.
440+ ~
441+ (mole |.((sub max-wave (max [u.horizon frequency]:rul.tide))))
368442 ~| %rock-zero
369443 tide(wav (lot:wav wav.tide (bind (ram:rok rok.tide) |=([r=@ *] (dec r))) ~))
370444 --