From d42e7283d46e0536de9a14eb0c81aeee70f76580 Mon Sep 17 00:00:00 2001 From: Max G Date: Fri, 16 Jun 2017 02:31:07 -0400 Subject: [PATCH 001/184] Dragon4 hoon fix --- sys/hoon.hoon | 52 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index cf47c3945..5a937d7de 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -2006,13 +2006,10 @@ :: =+ m=(met 0 a.a) ?> |(s (gth m prc)) :: require precision - =+ ^= q - =+ ^= f :: reduce precision - ?: (gth m prc) (^sub m prc) 0 - =+ ^= g %- abs:si :: enforce min. exp - ?: =(den %i) --0 - ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0 - (max f g) + =+ ^= q %+ max + ?: (gth m prc) (^sub m prc) 0 :: reduce precision + %- abs:si ?: =(den %i) --0 :: enforce min. prec + ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0 =^ b a :- (end 0 q a.a) a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a)) :: @@ -2063,40 +2060,53 @@ ?: =(den %i) [%f & a] ?: =((cmp:si emx e.a) -1) [%i &] [%f & a] :: enforce max. exp :: - ++ drg :: dragon4; - ~/ %drg :: convert to decimal - |= {a/{e/@s a/@u}} ^- {@s @u} - ?< =(a.a 0) + ++ drg :: dragon4; get + ~/ %drg :: printable decimal; + |= {a/{e/@s a/@u}} ^- {@s @u} :: guaranteed accurate + ?< =(a.a 0) :: for rounded floats =. a (xpd a) =+ r=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) a.a) =+ s=(lsh 0 ?.((syn:si e.a) (abs:si e.a) 0) 1) - =+ m=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1) + =+ mn=(lsh 0 ?:((syn:si e.a) (abs:si e.a) 0) 1) + =+ mp=mn + => ?. + ?& =(a.a (bex (dec prc))) :: if next smallest + |(!=(e.a emn) =(den %i)) :: float is half ULP, + == :: tighten lower bound + . + %= . + mp (lsh 0 1 mp) + r (lsh 0 1 r) + s (lsh 0 1 s) + == =+ [k=--0 q=(^div (^add s 9) 10)] |- ?: (^lth r q) %= $ k (dif:si k --1) r (^mul r 10) - m (^mul m 10) + mn (^mul mn 10) + mp (^mul mp 10) == - |- ?: (gte (^add (^mul r 2) m) (^mul s 2)) + |- ?: (gte (^add (^mul r 2) mp) (^mul s 2)) $(s (^mul s 10), k (sum:si k --1)) =+ [u=0 o=0] - |- + |- :: r/s+o = a*10^-k =+ v=(dvr (^mul r 10) s) => %= . k (dif:si k --1) u p.v r q.v - m (^mul m 10) + mn (^mul mn 10) + mp (^mul mp 10) == - =+ l=(^lth (^mul r 2) m) - =+ ^= h - ?| (^lth (^mul s 2) m) - (gth (^mul r 2) (^sub (^mul s 2) m)) + =+ l=(^lth (^mul r 2) mn) :: in lower bound + =+ ^= h :: in upper bound + ?| (^lth (^mul s 2) mp) + (gth (^mul r 2) (^sub (^mul s 2) mp)) == ?: &(!l !h) $(o (^add (^mul o 10) u)) - =+ q=&(h |(!l (gte (^mul r 2) s))) + =+ q=&(h |(!l (gth (^mul r 2) s))) =. o (^add (^mul o 10) ?:(q +(u) u)) [k o] :: From e08a126c4b3ef2c3b0e5d83e0a0f575a0f030c98 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 14 Jul 2017 15:00:10 -0400 Subject: [PATCH 002/184] Comment typo --- sys/hoon.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index 5a937d7de..b091d6ee8 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -2008,7 +2008,7 @@ ?> |(s (gth m prc)) :: require precision =+ ^= q %+ max ?: (gth m prc) (^sub m prc) 0 :: reduce precision - %- abs:si ?: =(den %i) --0 :: enforce min. prec + %- abs:si ?: =(den %i) --0 :: enforce min. exp ?: =((cmp:si e.a emn) -1) (dif:si emn e.a) --0 =^ b a :- (end 0 q a.a) a(e (sum:si e.a (sun:si q)), a (rsh 0 q a.a)) From 96ed0dedfb64cc78d8aa969360daba7b3d896ee1 Mon Sep 17 00:00:00 2001 From: Paul Driver Date: Tue, 8 Aug 2017 16:10:30 -0700 Subject: [PATCH 003/184] correct an oversight in ++nest:ut (mismatch with jet) --- sys/hoon.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index cf47c3945..2ba0868e0 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -7651,7 +7651,7 @@ {$cell *} | {$core *} dext(ref repo(sut ref)) {$face *} dext(ref q.ref) - {$fork *} (levy ~(tap in p.ref) |=(span sint(ref +<))) + {$fork *} (levy ~(tap in p.ref) |=(span dext(ref +<))) {$hold *} ?: (~(has in reg) ref) & ?: (~(has in gil) [sut ref]) & %= dext From 326b602aaeb3a6e81e053ac99bd1d6b6774992f3 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sun, 24 Sep 2017 22:44:45 -0700 Subject: [PATCH 004/184] Port new-hoon.hoon and tests to master. --- gen/test.hoon | 838 +++++++++++++++++++++++++++ lib/new-hoon.hoon | 1406 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2244 insertions(+) create mode 100644 gen/test.hoon create mode 100644 lib/new-hoon.hoon diff --git a/gen/test.hoon b/gen/test.hoon new file mode 100644 index 000000000..845107275 --- /dev/null +++ b/gen/test.hoon @@ -0,0 +1,838 @@ +/+ new-hoon +|% +:: ---------------------------------------------------------------------- +:: Eventually should be in %/lib/tester/hoon. +:: ---------------------------------------------------------------------- +++ test-lib + |% + ++ init-test + |= {cookie/@uvJ} + ~(. tester `(list tape)`~ cookie 10 0) + :: + ++ tester-type _(init-test `@uvJ`0) + :: + ++ tester + |_ $: error-lines/(list tape) :: output messages + eny/@uvJ :: entropy + check-iterations/@u :: # of check trials + current-iteration/@u :: current iteration + == + :: + :: || %examples + :: + :: +| + ++ example !. + :: TODO: this doesn't deal with |*. + :: + :: specifies an example and its expected value. + :: + :: the examples in the hoon documentation used to go out of date very + :: quickly, since they were never compiled. so make compiling them a + :: test. + :: + :: source: a hoon expression + :: expected: the expected result of {source}. + |= {source/cord expected/cord} + ^+ +> + :: todo: deal with expected not compiling. + =+ exp=(slap !>(.) (ream expected)) + =+ run=(mule |.((slap !>(.) (ream source)))) + =/ result/vase ?- -.run + $| !>(p.run) + $& p.run + == + ?: =(q.result q.exp) + +>.$ + %= +>.$ + error-lines :* + "failure in '{(trip source)}':" + " actual: '{(noah result)}'" + " expected: '{(noah exp)}'" + error-lines + == + == + ++ examples + :: + |= a/(list {cord cord}) + ?~ a + +>.$ + =. +>.$ (example i.a) + $(a t.a) + :: + :: || %check + :: + :: +| + +- check + |* {generator/$-(@uvJ *) test/$-(* ?)} + |- :: why do i have to |-? + ^+ +>.$ + ?: (gth current-iteration check-iterations) + +>.$ + :: todo: wrap generator in mule so it can crash. + =+ sample=(generator eny) + :: todo: wrap test in mule so it can crash. + =+ test=(test sample) + ?: test + %= $ + eny (shaf %huh eny) :: xxx: better random? + current-iteration (add current-iteration 1) + == + =+ case=(add 1 current-iteration) + =+ case-plural=?:(=(case 1) "case" "cases") + %= +>.$ + error-lines :* + "falsified after {(noah !>(case))} {case-plural} by '{(noah !>(sample))}'" + error-lines + == + == + :: + :: todo: a generate function that takes an arbitrary span. + :: + ++ generate-range + |= {min/@ max/@} + |= c/@uvJ + ^- @ + (add min (~(rad og c) (sub max min))) + :: + :: || %test + :: + :: +| + :: todo: unit testing libraries have a lot more to them than just eq. + ++ expect-eq + |* {a/* b/* c/tape} + ^+ +> + ?: =(a b) + +>.$ + %= +>.$ + error-lines :* + "failure: '{c}'" + " actual: '{(noah !>(a))}'" + " expected: '{(noah !>(b))}'" + error-lines + == + == + :: + ++ results + :: returns results. + :: + :: returns the test run's identity cookie and the list of failures. + |. + ^- {@uvJ (list tape)} + [eny error-lines] + -- + -- +:: ---------------------------------------------------------------------- +:: Eventually should be in %/test/basic/hoon. +:: ---------------------------------------------------------------------- +++ test-core + |_ tester-type:test-lib + ++ example-add + %- examples :~ + ['(add 2 2)' '4'] + ['(add 1 1.000.000)' '1.000.001'] + ['(add 1.333 (mul 2 2))' '1.337'] + == + ++ example-dec + %- examples :~ + ['(dec 7)' '6'] + ['(dec 0)' '~[[%leaf p="decrement-underflow"]]'] + == + ++ check-decrement + %+ check + (generate-range 0 100) + |=(a/@ =(a (dec (add 2 a)))) + ++ test-decrement + (expect-eq (dec 5) 4 "decrement failure") + ++ test-freedom + (expect-eq (add 2 2) 4 "freedom is the freedom to say...") + ++ test-a-failure + (expect-eq (add 2 2) 5 "freedom is the freedom to say...") + ++ test-crash + !! + -- +:: ---------------------------------------------------------------------- +:: Eventually should be in %/test/basic/hoon. +:: ---------------------------------------------------------------------- +++ test-thr + =, thr:new-hoon + =/ data/(list (either @u tape)) [[%& 1] [%| "one"] [%& 2] [%| "two"] ~] + |_ tester-type:test-lib + ++ test-apply + %^ expect-eq + %^ apply + `(either @u tape)`[%| "one"] + |=(a/@u "left") + |=(b/tape "right") + "right" + "apply" + :: + ++ test-firsts + %^ expect-eq + (firsts data) + [1 2 ~] + "firsts" + :: + ++ test-seconds + %^ expect-eq + (seconds data) + ["one" "two" ~] + "seconds" + :: + ++ test-partition + %^ expect-eq + (partition data) + [[1 2 ~] ["one" "two" ~]] + "partition" + -- +++ test-myb + =, myb:new-hoon + |_ tester-type:test-lib + ++ test-from-list-null + (expect-eq (from-list ~) ~ "from-list") + :: + ++ test-from-list-real + (expect-eq (from-list [5 ~]) [~ 5] "from-list") + :: + ++ test-to-list-null + (expect-eq (to-list ~) ~ "to-list") + :: + ++ test-to-list-real + (expect-eq (to-list [~ 5]) [5 ~] "to-list") + :: + ++ test-concat-null + (expect-eq (concat ~) ~ "concat") + :: + ++ test-concat-real + :: wait, if i pull the cast out from below, the concat implementation + :: doesn't compile anymore? + (expect-eq (concat `(list (maybe @ud))`[~ [~ 1] ~ [~ 2] ~]) [1 2 ~] "concat") + :: + ++ test-transform + %^ expect-eq + %+ transform + [1 2 3 2 ~] + |=(a/@u ?:(=(2 a) [~ 2] ~)) + [2 2 ~] + "transform" + -- +++ test-ls + =, ls:new-hoon + |_ tester-type:test-lib + ++ test-head + (expect-eq (head [1 ~]) 1 "head") + :: + ++ test-last + (expect-eq (last:ls [1 2 ~]) 2 "last") + :: + ++ test-tail + (expect-eq (tail [1 2 3 ~]) [2 3 ~] "tail") + :: + ++ test-init + (expect-eq (init [1 2 3 ~]) [1 2 ~] "init") + :: + ++ test-size + (expect-eq (size ['a' 'b' 'c' ~]) 3 "size") + :: + ++ test-transform + (expect-eq (transform [1 2 ~] |=(a/@ (add 1 a))) [2 3 ~] "transform") + :: + ++ test-reverse + (expect-eq (reverse [1 2 3 ~]) [3 2 1 ~] "reverse") + :: + ++ test-intersperse + (expect-eq (intersperse 1 [5 5 5 ~]) [5 1 5 1 5 ~] "intersperse") + :: + ++ test-intercalate + %^ expect-eq + (intercalate "," ["one" "two" "three" ~]) + ["one,two,three"] + "intercalate" + :: + ++ test-transpose + %^ expect-eq + (transpose ~[~[1 2 3] ~[4 5 6]]) + ~[~[1 4] ~[2 5] ~[3 6]] + "transpose" + :: + ++ test-foldl + (expect-eq (foldl [1 2 3 ~] 3 |=({a/@ b/@} (add a b))) 9 "foldl") + :: + ++ test-foldr + (expect-eq (foldr [1 2 3 ~] 1 |=({a/@ b/@} (add a b))) 7 "foldr") + :: todo: ++concat goes here + ++ test-any-true + (expect-eq (any [1 2 3 ~] |=(a/@ =(a 2))) %.y "any true") + :: + ++ test-any-false + (expect-eq (any [1 2 3 ~] |=(a/@ =(a 8))) %.n "any false") + :: + ++ test-all-true + (expect-eq (all [1 1 1 ~] |=(a/@ =(a 1))) %.y "all true") + :: + ++ test-all-false + (expect-eq (all [1 3 1 ~] |=(a/@ =(a 1))) %.n "all false") + :: + ++ test-scanl + %^ expect-eq + (scanl ~[1 2 3] 0 |=({a/@ b/@} (add a b))) + ~[0 1 3 6] + "scanl" + :: + ++ test-scanl1 + %^ expect-eq + (scanl1 ~[1 2 3] |=({a/@ b/@} (add a b))) + ~[1 3 6] + "scanl1" + :: + ++ test-scanr + %^ expect-eq + (scanr ~[1 2 3] 0 |=({a/@ b/@} (add a b))) + ~[6 5 3 0] + "scanr" + :: + ++ test-scanr1 + %^ expect-eq + (scanr1 ~[1 2 3] |=({a/@ b/@} (add a b))) + ~[6 5 3] + "scanr1" + :: + ++ test-transform-foldl + %^ expect-eq + (transform-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) + [7 ~[2 3 5]] + "transform-foldl" + :: + ++ test-transform-foldr + %^ expect-eq + (transform-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) + [7 ~[7 5 2]] + "transform-foldr" + :: + ++ test-unfoldr + %^ expect-eq + (unfoldr 5 |=(a/@ ?:(=(a 0) ~ `[a (dec a)]))) + [5 4 3 2 1 ~] + "unfoldr" + :: + ++ test-take + %^ expect-eq + (take 3 ~[1 2 3 4 5]) + [1 2 3 ~] + "take" + :: + ++ test-drop + %^ expect-eq + (drop:ls 3 ~[1 2 3 4 5]) + [4 5 ~] + "drop" + :: + ++ test-split-at + %^ expect-eq + (split-at 3 ~[1 2 3 4 5]) + [[1 2 3 ~] [4 5 ~]] + "split-at" + :: + ++ test-take-while + %^ expect-eq + (take-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) + [1 2 ~] + "take-while" + :: + ++ test-drop-while + %^ expect-eq + (drop-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) + [3 4 5 ~] + "drop-while" + :: + ++ test-drop-while-end + %^ expect-eq + (drop-while-end ~[5 5 1 5 5] |=(a/@ =(a 5))) + [5 5 1 ~] + "drop-while-end" + :: + ++ test-split-on + %^ expect-eq + (split-on ~[1 2 3 4 1 2 3 4] |=(a/@ (lth a 3))) + [[1 2 ~] [3 4 1 2 3 4 ~]] + "split-on" + :: + ++ test-break + %^ expect-eq + (break ~[1 2 3 4 1 2 3 4] |=(a/@ (gth a 3))) + [[1 2 3 ~] [4 1 2 3 4 ~]] + "break" + :: + ++ test-strip-prefix + %^ expect-eq + (strip-prefix "foo" "foobar") + [~ "bar"] + "break" + :: + ++ test-is-prefix-of + %^ expect-eq + (is-prefix-of "foo" "foobar") + %.y + "is-prefix-of" + :: + ++ test-is-suffix-of + %^ expect-eq + (is-suffix-of "bar" "foobar") + %.y + "is-suffix-of" + :: TODO: Figure out why ++is-infix-of never terminates, but only on the + :: master branch. + :: ++ test-is-infix-of + :: %^ expect-eq + :: (is-infix-of "ob" "foobar") + :: %.y + :: "is-infix-of" + :: + ++ test-elem + %^ expect-eq + (elem 5 [1 2 3 4 5 ~]) + %.y + "elem" + :: + ++ test-lookup + %^ expect-eq + (lookup "two" [["one" 1] ["two" 2] ["three" 3] ~]) + [~ 2] + "lookup" + :: + ++ test-find + %^ expect-eq + (find:ls [3 2 1 5 1 2 3 ~] |=(a/@ (gth a 3))) + [~ 5] + "find" + :: + ++ test-filter + %^ expect-eq + (filter [1 2 1 2 1 ~] |=(a/@ =(a 2))) + [2 2 ~] + "filter" + :: + ++ test-partition + %^ expect-eq + (partition [1 2 1 2 1 ~] |=(a/@ =(a 2))) + [[2 2 ~] [1 1 1 ~]] + "partition" + :: + ++ test-elem-index + %^ expect-eq + (elem-index 2 [1 2 3 4 ~]) + `1 + "elem-index" + :: + ++ test-elem-indices + %^ expect-eq + (elem-indices 2 [1 2 1 2 ~]) + [1 3 ~] + "elem-indices" + :: + ++ test-find-index + %^ expect-eq + (find-index [1 2 3 ~] |=(a/@ =(a 2))) + `1 + "find-index" + :: + ++ test-find-indices + %^ expect-eq + (find-indices [1 2 1 2 ~] |=(a/@ =(a 2))) + [1 3 ~] + "find-indices" + :: + ++ test-unique + %^ expect-eq + (unique [1 2 3 1 2 3 ~]) + [1 2 3 ~] + "unique" + :: + ++ test-delete + %^ expect-eq + (delete 2 [1 2 3 2 ~]) + [1 3 2 ~] + "delete" + :: + ++ test-delete-firsts + %^ expect-eq + (delete-firsts [1 2 2 2 3 4 5 ~] [2 2 5 ~]) + [1 2 3 4 ~] + "delete-firsts" + :: + ++ test-union + %^ expect-eq + (union [1 2 3 ~] [4 2 5 ~]) + [1 2 3 4 5 ~] + "union" + :: + ++ test-intersect + %^ expect-eq + (intersect [5 6 6 7 8 ~] [9 8 8 6 ~]) + [6 6 8 ~] + "intersect" + -- +++ test-mp + =, mp:new-hoon + =+ four=(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] ~]) + =+ three=(from-list [[1 "one"] [2 "two"] [3 "three"] ~]) + |_ tester-type:test-lib + ++ test-empty + (expect-eq (empty four) %.n "empty") + :: + ++ test-size + (expect-eq (size four) 4 "size") + :: + ++ test-member + (expect-eq (member four 4) %.y "member") + :: + ++ test-insert-with + =+ ints=(from-list [["one" 1] ["two" 2] ["three" 3] ["four" 4] ~]) + %^ expect-eq + (insert-with ints "three" 2 add) + (from-list [["one" 1] ["two" 2] ["three" 5] ["four" 4] ~]) + "insert-with" + :: + ++ test-insert-with-key + %^ expect-eq + (insert-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) + (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~]) + "insert-with-key" + + :: + ++ test-delete + %^ expect-eq + (delete four 4) + three + "delete" + :: + ++ test-adjust + %^ expect-eq + %^ adjust + four + 3 + |=(a/tape (weld "this" a)) + (from-list [[1 "one"] [2 "two"] [3 "thisthree"] [4 "four"] ~]) + "adjust" + :: + ++ test-adjust-with-key + %^ expect-eq + %^ adjust-with-key + four + 3 + |=({a/@ud b/tape} (weld (scow %ud a) b)) + (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + "adjust-with-key" + :: + ++ test-update + %^ expect-eq + %^ update + four + 3 + |=(a/tape `(maybe tape)`~) + (from-list [[1 "one"] [2 "two"] [4 "four"] ~]) + "update" + :: + ++ test-update-with-key + %^ expect-eq + %^ update-with-key + four + 3 + |=({a/@u b/tape} `(maybe tape)`[~ (weld (scow %ud a) b)]) + (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + "update-with-key" + :: + ++ test-alter-as-add + %^ expect-eq + %^ alter + four + 5 + |=(a/(maybe tape) `(maybe tape)`[~ "five"]) + (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"] ~]) + "alter (as add)" + :: + ++ test-alter-as-delete + %^ expect-eq + %^ alter + four + 2 + |=(a/(maybe tape) `(maybe tape)`~) + (from-list [[1 "one"] [3 "three"] [4 "four"] ~]) + "alter (as delete)" + :: + ++ test-union + %^ expect-eq + %+ union + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + (from-list [[1 "left"] [2 "left"] [3 "right"] ~]) + "union" + :: + ++ test-union-with + %^ expect-eq + %^ union-with + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + |=({a/tape b/tape} (weld a b)) + (from-list [[1 "left"] [2 "leftright"] [3 "right"] ~]) + "union-with" + :: + ++ test-union-with-key + %^ expect-eq + %^ union-with-key + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + |=({a/@ud b/tape c/tape} :(weld `tape`(scow %ud a) b c)) + (from-list [[1 "left"] [2 "2leftright"] [3 "right"] ~]) + "union-with-key" + :: + ++ test-transform + %^ expect-eq + %+ transform + three + crip + (from-list [[1 'one'] [2 'two'] [3 'three'] ~]) + "transform" + :: + ++ test-transform-with-key + %^ expect-eq + %+ transform-with-key + three + |=({a/@u b/tape} (weld (scow %ud a) b)) + (from-list [[1 "1one"] [2 "2two"] [3 "3three"] ~]) + "transform-with-key" + :: + ++ test-transform-fold + %^ expect-eq + %^ transform-fold + three + "Everything: " + |= {accumulator/tape value/tape} + [(weld accumulator value) (weld value "X")] + :- "Everything: twoonethree" + (from-list [[1 "oneX"] [2 "twoX"] [3 "threeX"] ~]) + "transform-fold" + :: + ++ test-transform-keys + %^ expect-eq + %+ transform-keys + three + |= a/@u + (add a 10) + (from-list [[11 "one"] [12 "two"] [13 "three"] ~]) + "transform-keys" + :: + ++ test-transform-keys-with + %^ expect-eq + %^ transform-keys-with + three + |=(a/@u 42) + weld + (from-list [[42 "twothreeone"] ~]) + "transform-keys-with" + :: + ++ test-fold + %^ expect-eq + %^ fold + three + "Everything: " + :: todo: this works but replacing with just ++weld causes an out of loom. + |= {accumulator/tape value/tape} + ^- tape + (weld accumulator value) + "Everything: twoonethree" + "transform-fold" + :: + ++ test-fold-with-keys + %^ expect-eq + %^ fold-with-keys + three + "Everything: " + |= {accumulator/tape key/@u value/tape} + ^- tape + :(weld accumulator (scow %ud key) value) + "Everything: 2two1one3three" + "transform-fold-with-keys" + :: + ++ test-elems + %^ expect-eq + (elems three) + ["two" "three" "one" ~] + "elems" + :: + ++ test-keys + %^ expect-eq + (keys three) + [2 3 1 ~] + "keys" + :: + ++ test-keys-set + %^ expect-eq + (keys-set three) + (si:nl [2 3 1 ~]) + "keys-set" + :: + ++ test-from-set + %^ expect-eq + %+ from-set + (si:nl [1 2 3 ~]) + |= a/@u + (scow %ud a) + (from-list [[1 "1"] [2 "2"] [3 "3"] ~]) + "from-set" + :: + ++ test-from-list-with + %^ expect-eq + %+ from-list-with + [[1 1] [2 1] [2 1] [3 3] ~] + add + (from-list [[1 1] [2 2] [3 3] ~]) + "from-list-with" + + ++ test-filter + %^ expect-eq + %+ filter + (from-list [[1 1] [2 1] [3 2] [4 1] ~]) + |=(a/@u =(a 1)) + (from-list [[1 1] [2 1] [4 1] ~]) + "filter" + :: + ++ test-filter-with-key + %^ expect-eq + %+ filter-with-key + (from-list [[1 1] [2 1] [3 2] [4 1] ~]) + |=({a/@u b/@u} !=(a 2)) + (from-list [[1 1] [3 2] [4 1] ~]) + "filter-with-key" + :: + ++ test-restrict-keys + %^ expect-eq + %+ restrict-keys + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + (si:nl [1 3 5 ~]) + (from-list [[1 1] [3 3] [5 5] ~]) + "restrict-keys" + :: + ++ test-without-keys + %^ expect-eq + %+ without-keys + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + (si:nl [1 3 5 ~]) + (from-list [[2 2] [4 4] ~]) + "restrict-keys" + :: + ++ test-partition + %^ expect-eq + %+ partition + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=(a/@u |(=(a 1) =(a 3))) + :- (from-list [[1 1] [3 3] ~]) + (from-list [[2 2] [4 4] [5 5] ~]) + "partition" + :: + ++ test-transform-maybe + %^ expect-eq + %+ transform-maybe + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=(a/@u ?:(=(a 3) ~ `a)) + (from-list [[1 1] [2 2] [4 4] [5 5] ~]) + "transform-maybe" + :: + ++ test-transform-maybe-with-key + %^ expect-eq + %+ transform-maybe-with-key + (from-list [[1 2] [2 3] [3 4] [4 5] [5 6] ~]) + |=({k/@u v/@u} ?:(=(k 3) ~ `v)) + (from-list [[1 2] [2 3] [4 5] [5 6] ~]) + "transform-maybe-with-key" + :: + :: ++ test-is-submap + :: %^ expect-eq + :: %^ is-submap-by + :: (from-list [[1 1] [4 4] ~]) + :: (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + :: |=({a/* b/*} =(a b)) + :: %.y + :: "is-submap" + -- +:: ---------------------------------------------------------------------- +:: Stays in the generator. +:: ---------------------------------------------------------------------- +++ local + |% + ++ perform-test-suite + :: takes a testing core and executes all tests in it. + |= {name/tape v/vase eny/@uvJ} + ^- tang + =+ core-arms=(sort (sloe p.v) aor) + :: todo: work around mint-vain + =+ null-check=core-arms + ?~ null-check + [[%leaf :(weld "error: " name " is not a valid testing core.")] ~] + =| out/tang + |- + ?~ core-arms + out + %= $ + out (weld (perform-test-arm name i.core-arms v eny) out) + core-arms t.core-arms + == + :: + ++ perform-test-arm + :: performs a single test. + |= {suite-name/tape arm-name/term v/vase eny/@uvJ} + :: todo: terminal color on the output + ^- tang + =+ run=(run-arm-in-test-core arm-name v eny) + =+ full-name=:(weld suite-name "/" (trip arm-name)) + ?- -.run + $| :: the stack is already flopped for output? + ;: weld + p:run + `tang`[[%leaf (weld full-name " CRASHED")] ~] + == + $& :: todo: test the cookie to make sure it returned the same core. + ?: =(~ +.p:run) + [[%leaf (weld full-name " OK")] ~] + :: Create a welded list of all failures indented. + %- flop + ;: weld + `tang`[[%leaf (weld full-name " FAILED")] ~] + %+ turn +.p:run + |= {i/tape} + ^- tank + [%leaf (weld " " i)] + == + == + :: + ++ run-arm-in-test-core + :: runs a single arm. + :: + :: returns the output of `++mule` so that we can react to crashes + :: appropriately. + |= {arm-name/term v/vase eny/@uvJ} + ^- (each {@uvJ (list tape)} (list tank)) + =/ t (init-test:test-lib eny) + :: run the tests in the interpreter so we catch crashes. + %- mule |. + :: ~(t v arm-name) + =/ r (slap (slop !>(t) v) [%cnsg [arm-name ~] [%$ 3] [[%$ 2] ~]]) + :: return just the results or we will be here forever while we try to copy + :: the entire kernel. + ((hard {@uvJ (list tape)}) q:(slym (slap r [%limb %results]) r)) + -- +:: ---------------------------------------------------------------------- +-- +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + $~ + $~ + == +:- %tang +:: todo: right now, we hard code ++test-core. but eventually, we must instead +:: scry ford for the core from the hoon file. that doesn't exist yet. +::(perform-test-suite:local "test-core" !>(test-core) eny) + +:: (perform-test-suite:local "test-thr" !>(test-thr) eny) +:: (perform-test-suite:local "test-myb" !>(test-myb) eny) +::(perform-test-suite:local "test-ls" !>(test-ls) eny) +(perform-test-suite:local "test-mp" !>(test-mp) eny) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon new file mode 100644 index 000000000..086a97c95 --- /dev/null +++ b/lib/new-hoon.hoon @@ -0,0 +1,1406 @@ +:> basic containers +|% +:: +++ first + |* a/^ + -.a +:: +++ second + |* a/^ + +.a +:: +++ either |*({a/mold b/mold} $%({$& p/a} {$| p/b})) :: either +++ thr + |% + ++ apply + :> applies {b} {a} is first, or {b} to {a} is second. + |* {a/(either) b/$-(* *) c/$-(* *)} + ?- -.a + $& (b p.a) + $| (c p.a) + == + :: + ++ firsts + :> returns a list of all first elements in {a}. + |* a/(list (either)) + => .(a (homo a)) + |- + ?~ a + ~ + ?- -.i.a + $& [p.i.a $(a t.a)] + $| $(a t.a) + == + :: + ++ seconds + :> returns a list of all second elements in {a}. + |* a/(list (either)) + => .(a (homo a)) + |- + ?~ a + ~ + ?- -.i.a + $& $(a t.a) + $| [p.i.a $(a t.a)] + == + :: + ++ partition + :> splits the list of eithers into two lists based on first or second. + |* a/(list (either)) + => .(a (homo a)) + |- + :: todo: this cast is bad. how do i make it a list with the internal types + ^- {(list) (list)} + ?~ a + [~ ~] + =+ ret=$(a t.a) + ?- -.i.a + $& [[p.i.a -.ret] +.ret] + $| [-.ret [p.i.a +.ret]] + == + -- +++ maybe |*(a/mold $@($~ {$~ u/a})) :: maybe +++ myb + |% + ++ is-null + :> returns %.y if maybe is null. + :> + :> corresponds to {isJust} in haskell. + |* a/(maybe) + :> whether {a} is null. + ?~ a %.y + %.n + :: + ++ exists + :> returns %.y if maybe contains a real value. + :> + :> corresponds to {isNothing} in haskell. + |* a/(maybe) + :> whether {a} is not null. + ?~ a %.n + %.y + :: + ++ need + :> returns the value or crashes. + :> + :> corresponds to {fromJust} in haskell. + |* a/(maybe) + ?~ a ~>(%mean.[%leaf "need"] !!) + :> the value from the maybe. + u.a + :: + ++ default + :> returns the value in the maybe, or a default value on null. + :> + :> corresponds to {fromMaybe} in haskell. + |* {a/(maybe) b/*} + ?~(a b u.a) + :: + ++ from-list + :> returns the first value of the list, or null on empty list. + :> + :> corresponds to {listToMaybe} in haskell. + |* a/(list) + ^- (maybe _i.a) + ?~ a ~ + [~ i.a] + :: + ++ to-list + :> converts the maybe to a list. + :> + :> corresponds to {maybeToList} in haskell. + |* a/(maybe) + ^- (list _u.a) + ?~ a ~ + [u.a ~] + :: + ++ concat + :> converts a list of maybes to a list of non-null values. + :> + :> corresponds to {catMaybes} in haskell. + |* a/(list (maybe)) + => .(a (homo a)) + |- +:: ^- (list _u.i.a) + ^- (list _,.+.,.-.a) + ?~ a ~ + ?~ i.a + $(a t.a) + [u.i.a $(a t.a)] + :: + ++ transform + :> a version of transform that can throw out items. + :> + :> takes a list of items and a function of the type + :> + :> todo: while this was in Data.Maybe in haskell, this might better + :> logically be put in our list class? murn is. + :> + :> corresponds to {mapMaybes} in haskell. + |* {a/(list) b/$-(* (maybe))} + => .(a (homo a)) + |- + ^- (list _,.+:*b) + ?~ a ~ + =+ c=(b i.a) + ?~ c + $(a t.a) + :: todo: the span of c does not have the faces of a maybe. how do i either + :: force a resurface or act safely on the incoming? + [+.c $(a t.a)] + :: + ++ apply + :> applies {b} to {a}. + |* {a/(maybe) b/$-(* (maybe))} + ?~ a ~ + (b +.a) + :: + :: todo: bind, bond, both, flit, hunt, lift, mate, + :: + :: used in other files: bond, drop (but only once) + :: unusued: clap + -- +++ ls + :: we are back to a basic problem here: when we try to pass lists without + :: {i} and {t} faces, we have to use {-} and {+} to access the structure of + :: the list. but we then can't deal with incoming lists that do have faces, + :: as `+:[i="one" t=~]` is `t=~`, not `~`. + :: + :: what i really want is that the sapn outside a |* is `{"" 2 "" $~}`, but + :: inside, it is `(list $?(@ud tape))`. all of a sudden, you don't need + :: ++limo or ++homo, because you have the right span from the beginning! + :: those two functions really feel like they're working around the type + :: system instead of cooperating with it. + :: + :> list utilities + |% + :> # %basic + :> basic list manipulation + +| + :: + ++ head + :> returns the first item in the list, which must be non-empty. + |* a/(list) + :> the first item in the list. + ?~ a ~>(%mean.[%leaf "head"] !!) + i.a + :: + ++ last + :> returns the final item in the list, which must be non-empty. + |* a/(list) + :> the last item in a list. + ?~ a ~>(%mean.[%leaf "last"] !!) + ?~ t.a + i.a + $(a t.a) + :: + ++ tail + :> returns all items after the head of the list, which must be non-empty. + |* a/(list) + ?~ a ~>(%mean.[%leaf "tail"] !!) + t.a + :: + ++ init + :> returns all items in the list except the last one. must be non-empty. + |= a/(list) + => .(a (homo a)) + |- + ^+ a + ?~ a ~>(%mean.[%leaf "init"] !!) + |- + ?~ t.a + ~ + [i.a $(a t.a)] +:: :: +:: :: ommitted: uncons, null +:: :: + ++ size + :> returns the number of items in {a}. + :> + :> corresponds to {length} in haskell. + |= a/(list) + =| b/@u + ^- @u + |- + ?~ a + b + $(a t.a, b +(b)) + :: + :> # %transformations + :> functions which change a list into another list + +| + :: + ++ transform + :> applies a gate to each item in the list. + |* {a/(list) b/$-(* *)} + ^- (list _*b) + ?~ a ~ + [(b i.a) $(a t.a)] + :: + ++ reverse + :> reverses the order of the items in the list. + |* a/(list) + => .(a (homo a)) + ^+ a + =+ b=`_a`~ + |- + ?~ a b + $(a t.a, b [i.a b]) + :: + ++ intersperse + :> places {a} between each element in {b}. + |* {a/* b/(list)} + => .(b (homo b)) + |- + ^+ (homo [a b]) + ?~ b + ~ + =+ c=$(b t.b) + ?~ c + [i.b ~] + [i.b a c] + :: + ++ intercalate + :> places {a} between each list in {b}, and flatten to a single list. + |* {a/(list) b/(list (list))} +:: => .(b ^.(homo b)) + :: todo: this should homogenize with each sub-list in {b}, but right now, + :: i can't get the ++concat/++zang gate working. + ^+ (homo a) + ?~ b + ~ + =+ c=$(b t.b) + ?~ c + i.b + :(weld i.b a c) + :: + ++ transpose + :> transposes rows and columns of a 2d list structure. + |* input/(list (list)) + :: todo: this should homogenize with each sublist. + ^- (list (list)) + =/ items + %^ foldl input `{(list) (list (list))}`[~ ~] + |= :> current: the list of first items under construction. + :> remaining: the remaining item lists. + :> next: the next list in {input}. + {state/{current/(list) remaining/(list (list))} next/(list)} + ?~ next + state + ?~ t.next + [[i.next current.state] remaining.state] + [[i.next current.state] [t.next remaining.state]] + ?~ +.items + `(list (list))`[(reverse -.items) ~] + [(reverse -.items) $(input (reverse +.items))] + :: +:: :: ++ subsequences +:: :: |= a/(list) +:: :: ?~ a +:: :: ~ +:: :: :- -.a +:: :: %^ foldr +:: :: $(a +.a) +:: :: `(list)`~ +:: :: |= {ys/(list) r/(list)} +:: :: ~ ::[ys [-.a ys] r ~] +:: :: TODO: +:: :: ++subsequences +:: :: ++permutations + + :: + :> # %folds + :> functions which reduce a list to a value + +| + :: + ++ foldl + :> left associative fold + :> + :> this follows haskell giving an explicit starting value instead of {roll}. + |* {a/(list) b/* c/$-({* *} *)} + ^+ b + ?~ a + b + $(a t.a, b (c b i.a)) + :: + ++ foldr + :> right associative fold + |* {a/(list) b/* c/$-({* *} *)} + ^+ b + ?~ a + b + (c $(a t.a) i.a) + + +:: This is even worse; cgy's ++zang doesn't do concat on master either. +:: +:: ++ zang :: new promote +:: |* a/(list (list)) +:: => .(a ^.(homo a)) +:: |- ^+ i:-.a +:: ?~ a +:: ~ +:: (weld i.a $(a t.a)) +:: :: TODO: this hits the |* span issue. +:: :: +:: :: :> concatenate a list of lists into a single level. +:: :: ++ concat +:: :: |* a/(list (list)) +:: :: ?~ a +:: :: ~ +:: :: ?~ +.a +:: :: -.a +:: :: (homo (weld -.a $(a +.a))) + + :: + ++ any + :> returns yes if any element satisfies the predicate + |* {a/(list) b/$-(* ?)} + ?~ a + %.n + ?|((b i.a) $(a t.a)) + :: + ++ all + :> returns yes if all elements satisfy the predicate + |* {a/(list) b/$-(* ?)} + ?~ a + %.y + ?&((b i.a) $(a t.a)) + :: + :: haskell has a bunch of methods like sum or maximum which leverage type + :: classes, but I don't think they can be written generically in hoon. + :: + :: + :> # %building + :> functions which build lists + +| + ++ scanl + :> returns a list of successive reduced values from the left. + |* {a/(list) b/* c/$-({* *} *)} + => .(a (homo a)) + |- + ?~ a + [b ~] + [b $(a t.a, b (c b i.a))] + :: + ++ scanl1 + :> a variant of ++scanl that has no starting value. + |* {a/(list) c/$-({* *} *)} + => .(a (homo a)) + |- + ?~ a + ~ + ?~ t.a + ~ + (scanl t.a i.a c) + :: + ++ scanr + :> the right-to-left version of scanl. + |* {a/(list) b/* c/$-({* *} *)} + => .(a (homo a)) + |- + ^- (list _b) + ?~ a + [b ~] + =+ rest=$(a t.a) + ?> ?=(^ rest) + [(c i.a i.rest) rest] + :: + ++ scanr1 + :> a variant of ++scanr that has no starting value. + |* {a/(list) c/$-({* *} *)} + => .(a (homo a)) + |- + ^+ a + ?~ a + ~ + ?~ t.a + [i.a ~] + =+ rest=$(a t.a) + ?> ?=(^ rest) + [(c i.a i.rest) rest] + :: + ++ transform-foldl + :> performs both a ++transform and a ++foldl in one pass. + :> + :> corresponds to {mapAccumL} in haskell. + |* {a/(list) b/* c/$-({* *} {* *})} + ^- {_b (list _+:*c)} + ?~ a + [b ~] + =+ d=(c b i.a) + =+ recurse=$(a t.a, b -.d) + [-.recurse [+.d +.recurse]] + :: + ++ transform-foldr + :> performs both a ++transform and a ++foldr in one pass. + :> + :> corresponds to {mapAccumR} in haskell. + |* {a/(list) b/* c/$-({* *} {* *})} + ^- {_b (list _+:*c)} + ?~ a + [b ~] + =+ recurse=$(a t.a) + =+ d=(c -.recurse i.a) + [-.d [+.d +.recurse]] + :: + ++ unfoldr + :> generates a list from a seed value and a function. + |* {b/* c/$-(* (maybe {* *}))} + |- + ^- (list _b) + =+ current=(c b) + ?~ current + ~ + :: todo: the span of {c} is resurfaced to have a u. this might do funky + :: things with faces. + [-.+.current $(b +.+.current)] + :: + :> # %sublists + :> functions which return a portion of the list + +| + :: + ++ take + :> returns the first {a} elements of {b}. + |* {a/@ b/(list)} + => .(b (homo b)) + |- + ^+ b + ?: =(0 a) + ~ + ?~ b + ~ + [i.b $(a (dec a), b +.b)] + :: + ++ drop + :> returns {b} without the first {a} elements. + |* {a/@ b/(list)} + ?: =(0 a) + b + ?~ b + b + $(a (dec a), b +.b) + :: + ++ split-at + :> returns {b} split into two lists at the {a}th element. + |* {a/@ b/(list)} + => .(b (homo b)) + |- + ^+ [b b] + ?: =(0 a) + [~ b] + ?~ b + [~ b] + =+ d=$(a (dec a), b t.b) + [[i.b -.d] +.d] + :: + ++ take-while + :> returns elements from {a} until {b} returns %.no. + |* {a/(list) b/$-(* ?)} + => .(a (homo a)) + |- + ^+ a + ?~ a + ~ + ?. (b -.a) + ~ + [i.a $(a t.a)] + :: + ++ drop-while + :> returns elements form {a} once {b} returns %.no. + |* {a/(list) b/$-(* ?)} + => .(a (homo a)) + |- + ?~ a + ~ + ?. (b i.a) + a + $(a t.a) + :: + ++ drop-while-end + :> drops the largest suffix of {a} which matches {b}. + |* {a/(list) b/$-(* ?)} + => .(a (homo a)) + |- + ?~ a + ~ + =+ r=$(a t.a) + ?: ?&(=(r ~) (b i.a)) + ~ + [i.a r] + :: + ++ split-on + :> returns [the longest prefix of {b}, the rest of the list]. + :> + :> corresponds to {span} in haskell. renamed to not conflict with hoon. + |* {a/(list) b/$-(* ?)} + => .(a (homo a)) + |- + ^+ [a a] + ?~ a + [~ ~] + ?. (b i.a) + [~ a] + =+ d=$(a +.a) + [[i.a -.d] +.d] + :: + ++ break + :> like {split-on}, but reverses the return code of {b}. + |* {a/(list) b/$-(* ?)} + => .(a (homo a)) + |- + ^+ [a a] + ?~ a + [~ ~] + ?: (b i.a) + [~ a] + =+ d=$(a t.a) + [[i.a -.d] +.d] + :: + ++ strip-prefix + :> returns a {maybe} of {b} with the prefix {a} removed, or ~ if no match. + |* {a/(list) b/(list)} + ^- (maybe _b) + ?~ a + `b + ?~ b + ~ + $(a +.a, b +.b) + :: + :: todo: ++group + :: todo: ++inits + :: todo: ++tails + :: + + :> # %predicates + :> functions which compare lists + +| + :: + ++ is-prefix-of + :> returns %.y if the first list is a prefix of the second. + |* {a/(list) b/(list)} + ?~ a + %.y + ?~ b + %.n + ?. =(i.a i.b) + %.n + $(a t.a, b t.b) + :: + ++ is-suffix-of + :> returns %.y if the first list is the suffix of the second. + |* {a/(list) b/(list)} + :: todo: this is performant in haskell because of laziness but may not be + :: adequate in hoon. + (is-prefix-of (reverse a) (reverse b)) + :: + :: todo: figure out why ++is-infix-of never terminates, but only on the + :: master branch. + :: + :: ++ is-infix-of + :: :> returns %.y if the first list appears anywhere in the second. + :: |* {a/(list) b/(list)} + :: ?~ a + :: %.y + :: ?~ b + :: %.n + :: ?: (is-prefix-of a b) + :: %.y + :: $(b t.b) + :: + :: todo: ++is-subsequence-of + :: + :> # %searching + :> finding items in lists + :: + ++ elem + :> does {a} occur in list {b}? + |* {a/* b/(list)} + ?~ b + %.n + ?: =(a i.b) + %.y + $(b t.b) + :: + ++ lookup + :> looks up the key {a} in the association list {b} + |* {a/* b/(list (pair))} + ^- (maybe _+.-.b) + ?~ b + ~ + ?: =(a p.i.b) + [~ q.i.b] + $(b t.b) + :: + ++ find + :> returns the first element of {a} which matches predicate {b}. + |* {a/(list) b/$-(* ?)} + ^- (maybe _-.a) + ?~ a + ~ + ?: (b i.a) + [~ i.a] + $(a t.a) + :: + ++ filter + :> returns all items in {a} which match predicate {b}. + |* {a/(list) b/$-(* ?)} + => .(a (homo a)) + |- + ^+ a + ?~ a + ~ + ?: (b i.a) + [i.a $(a t.a)] + $(a t.a) + :: + ++ partition + :> returns two lists, one whose elements match {b}, the other which doesn't. + |* {a/(list) b/$-(* ?)} + => .(a (homo a)) + |- + ^+ [a a] + ?~ a + [~ ~] + =+ rest=$(a t.a) + ?: (b i.a) + [[i.a -.rest] +.rest] + [-.rest [i.a +.rest]] + :: + :> # %indexing + :> finding indices in lists + +| + :: + ++ elem-index + :> returns {maybe} the first occurrence of {a} occur in list {b}. + =| i/@u + |= {a/* b/(list)} + ^- (maybe @ud) + ?~ b + ~ + ?: =(a i.b) + `i + $(b t.b, i +(i)) + :: + ++ elem-indices + :> returns a list of indices of all occurrences of {a} in {b}. + =| i/@u + |= {a/* b/(list)} + ^- (list @ud) + ?~ b + ~ + ?: =(a i.b) + [i $(b t.b, i +(i))] + $(b t.b, i +(i)) + :: + ++ find-index + :> returns {maybe} the first occurrence which matches {b} in {a}. + =| i/@u + |* {a/(list) b/$-(* ?)} + ^- (maybe @ud) + ?~ a + ~ + ?: (b i.a) + `i + $(a t.a, i +(i)) + :: + ++ find-indices + :> returns a list of indices of all items in {a} which match {b}. + =| i/@u + |* {a/(list) b/$-(* ?)} + ^- (list @ud) + ?~ a + ~ + ?: (b i.a) + [i $(a t.a, i +(i))] + $(a t.a, i +(i)) + :: + :: can we do a full general zip without doing haskellesque zip3, zip4, etc? + :: todo: ++zip + :: + :> # %set + :> set operations on lists + +| + ++ unique + :> removes duplicates elements from {a} + :> + :> corresponds to {nub} in haskell. + |* a/(list) + => .(a (homo a)) + =| seen/(list) + ^+ a + |- + ?~ a + ~ + ?: (elem i.a seen) + $(a t.a) + [i.a $(seen [i.a seen], a t.a)] + :: + ++ delete + :> removes the first occurrence of {a} in {b} + |* {a/* b/(list)} + => .(b (homo b)) + ^+ b + |- + ?~ b + ~ + ?: =(a i.b) + t.b + [i.b $(b t.b)] + :: + ++ delete-firsts + :> deletes the first occurrence of each element in {b} from {a}. + |* {a/(list) b/(list)} + => .(a (homo a), b (homo b)) + |- + ^+ a + ?~ a + ~ + ?~ b + a + ?: (elem i.a b) + $(a t.a, b (delete i.a b)) + [i.a $(a t.a)] + :: + ++ union + :> the list union of {a} and {b}. + |* {a/(list) b/(list)} + => .(a (homo a), b (homo b)) + :: todo: this doesn't work on (weld [1 2 ~] ["one" "two" ~]) + :: ^+ (weld a b) + |- + ?~ a + b + ?~ b + ~ + [i.a $(a t.a, b (delete i.a b))] + :: + ++ intersect + :> the intersection of {a} and {b}. + |* {a/(list) b/(list)} + => .(a (homo a), b (homo b)) + ^+ a + |- + ?~ a + ~ + ?: (elem i.a b) + [i.a $(a t.a)] + $(a t.a) + :: + :: todo: everything about ++sort and ++sort-on needs more thought. the + :: haskell implementation uses the Ord typeclass to sort things by + :: default. ++sort as is is probably the correct thing to do. + :: + -- +++ mp + :: todo: why do hoon maps use double hash ordering? does this matter? + |% + :> # %query + :> looks up values in the map. + +| + ++ empty + :> is the map empty? + |* a/(map) + ?~ a %.y + %.n + :: + ++ size + :> returns the number of elements in {a}. + |= a/(map) + ^- @u + ?~ a 0 + :(add 1 $(a l.a) $(a r.a)) + :: + ++ member + :> returns %.y if {b} is a key in {a}. + |= {a/(map) key/*} + ^- ? + ?~ a %.n + ?|(=(key p.n.a) $(a l.a) $(a r.a)) + :: + ++ get + :> grab value by key. + |* {a/(map) key/*} + ^- (maybe _?>(?=(^ a) q.n.a)) + :: ^- {$@($~ {$~ u/_?>(?=(^ a) q.n.a)})} + ?~ a + ~ + ?: =(key p.n.a) + `q.n.a + ?: (gor key p.n.a) + $(a l.a) + $(a r.a) + :: +:: :: todo: is ++got the correct interface to have? Haskell has lookup which +:: :: returns a Maybe and a findWithDefault which passes in a default value. +:: ++ got +:: :> todo: move impl here. +:: :> todo: is there a way to make b/_<><>.a ? +:: |* {a/(map) key/*} +:: (~(got by a) key) + :: + :: todo: skipping several methods which rely on the the Ord typeclass, like + :: lookupLT. + :: + :> # %insertion + +| + ++ insert + :> inserts a new key/value pair, replacing the current value if it exists. + |* {a/(map) key/* value/*} + |- ^+ a + ?~ a + [[key value] ~ ~] + ?: =(key p.n.a) + ?: =(value q.n.a) + a + [[key value] l.a r.a] + ?: (gor key p.n.a) + =+ d=$(a l.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a d r.a] + [n.d l.d [n.a r.d r.a]] + =+ d=$(a r.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a l.a d] + [n.d [n.a l.a l.d] r.d] + :: + ++ insert-with + :> inserts {key}/{value}, applying {fun} if {key} already exists. + |* {a/(map) key/* value/* fun/$-({* *} *)} + |- ^+ a + ?~ a + [[key value] ~ ~] + ?: =(key p.n.a) + :: key already exists; use {fun} to resolve. + [[key (fun q.n.a value)] l.a r.a] + ?: (gor key p.n.a) + =+ d=$(a l.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a d r.a] + [n.d l.d [n.a r.d r.a]] + =+ d=$(a r.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a l.a d] + [n.d [n.a l.a l.d] r.d] + :: + ++ insert-with-key + :> inserts {key}/{value}, applying {fun} if {key} already exists. + |* {a/(map) key/* value/* fun/$-({* * *} *)} + |- ^+ a + ?~ a + [[key value] ~ ~] + ?: =(key p.n.a) + :: key already exists; use {fun} to resolve. + [[key (fun p.n.a q.n.a value)] l.a r.a] + ?: (gor key p.n.a) + =+ d=$(a l.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a d r.a] + [n.d l.d [n.a r.d r.a]] + =+ d=$(a r.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a l.a d] + [n.d [n.a l.a l.d] r.d] + :: + :: todo: there's something wrong with the span here. + :: +:: ++ insert-lookup-with-key +:: :> combines insertion with lookup in one pass. +:: |* {a/(map) key/* value/* fun/$-({* * *} *)} +:: :: todo: type should reference a. +:: |- ^+ {*(unit value) a} +:: :: |- ^+ a ::{*(unit value) a} +:: ?~ a +:: [~ [[key value] ~ ~]] +:: ?: =(key p.n.a) +:: :: key already exists; use {fun} to resolve. +:: :: [~ q.n.a] +:: [~ [[key (fun p.n.a q.n.a value)] l.a r.a]] +:: ?: (gor key p.n.a) +:: =+ d=$(a l.a) +:: ~! d +:: ?> ?=(^ d) +:: ?: (vor p.n.a p.n.d) +:: [~ [n.a d r.a]] +:: [~ [n.d l.d [n.a r.d r.a]]] +:: =+ d=$(a r.a) +:: ~! d +:: ?> ?=(^ d) +:: ?: (vor p.n.a p.n.d) +:: [~ [n.a l.a d]] +:: [~ [n.d [n.a l.a l.d] r.d]] + :: + :> # %delete-update + +| + :: + ++ delete + :> deletes entry at {key}. + |* {a/(map) key/*} + |- ^+ a + ?~ a + ~ + ?. =(key p.n.a) + ?: (gor key p.n.a) + [n.a $(a l.a) r.a] + [n.a l.a $(a r.a)] + |- ^- {$?($~ _a)} + ?~ l.a r.a + ?~ r.a l.a + ?: (vor p.n.l.a p.n.r.a) + [n.l.a l.l.a $(l.a r.l.a)] + [n.r.a $(r.a l.r.a) r.r.a] + :: + ++ adjust + :> updates a value at {key} by passing the value to {fun}. + |* {a/(map) key/* fun/$-(* *)} + |- ^+ a + ?~ a + ~ + ?: =(key p.n.a) + [[key (fun q.n.a)] l.a r.a] + ?: (gor key p.n.a) + =+ d=$(a l.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a d r.a] + [n.d l.d [n.a r.d r.a]] + =+ d=$(a r.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a l.a d] + [n.d [n.a l.a l.d] r.d] + :: + ++ adjust-with-key + :> updates a value at {key} by passing the key/value pair to {fun}. + |* {a/(map) key/* fun/$-({* *} *)} + |- ^+ a + ?~ a + ~ + ?: =(key p.n.a) + [[key (fun key q.n.a)] l.a r.a] + ?: (gor key p.n.a) + =+ d=$(a l.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a d r.a] + [n.d l.d [n.a r.d r.a]] + =+ d=$(a r.a) + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [n.a l.a d] + [n.d [n.a l.a l.d] r.d] + :: + ++ update + :> adjusts or deletes the value at {key} by {fun}. + |* {a/(map) key/* fun/$-(* (maybe *))} + |- ^+ a + :: todo: this implementation is inefficient and traverses the tree multiple + :: times, when it can be done in O(log n). this should be solved in a jet? + =+ val=(get a key) + ?~ val + a + =+ ret=(fun u.val) + ?~ ret + (delete a key) + (insert a key u.ret) + :: + ++ update-with-key + :> adjusts or deletes the value at {key} by {fun}. + |* {a/(map) key/* fun/$-({* *} (maybe *))} + |- ^+ a + :: todo: this implementation is inefficient and traverses the tree multiple + :: times, when it can be done in O(log n). this should be solved in a jet? + =+ val=(get a key) + ?~ val + a + =+ ret=(fun key u.val) + ?~ ret + (delete a key) + (insert a key u.ret) + :: todo: + :: ++update-lookup-with-key + :: + ++ alter + :> inserts, deletes, or updates a value by {fun}. + |* {a/(map) key/* fun/$-(* (maybe *))} + :: todo: this implementation is inefficient and traverses the tree multiple + :: times, when it can be done in O(log n). this should be solved in a jet? + =+ ret=(fun (get a key)) + ?~ ret + (delete a key) + (insert a key u.ret) + :: + :> # %combine + +| + :: + ++ union + :> returns the union of {a} and {b}, preferring the value from {a} if dupe + |* {a/(map) b/(map)} + |- ^+ a + ?~ b + a + ?~ a + b + ?: (vor p.n.a p.n.b) + ?: =(p.n.b p.n.a) + [n.a $(a l.a, b l.b) $(a r.a, b r.b)] + ?: (gor p.n.b p.n.a) + $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b) + $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b) + ?: =(p.n.a p.n.b) + [n.b $(b l.b, a l.a) $(b r.b, a r.a)] + ?: (gor p.n.a p.n.b) + $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a) + $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a) + :: + ++ union-with + :> returns the union of {a} and {b}, running {fun} to resolve duplicates. + |* {a/(map) b/(map) fun/$-({* *} *)} + |- ^+ a + ?~ b + a + ?~ a + b + ?: (vor p.n.a p.n.b) + ?: =(p.n.b p.n.a) + [[p.n.a (fun q.n.a q.n.b)] $(a l.a, b l.b) $(a r.a, b r.b)] + ?: (gor p.n.b p.n.a) + $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b) + $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b) + ?: =(p.n.a p.n.b) + [n.b $(b l.b, a l.a) $(b r.b, a r.a)] + ?: (gor p.n.a p.n.b) + $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a) + $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a) + :: + ++ union-with-key + :> returns the union of {a} and {b}, running {fun} to resolve duplicates. + |* {a/(map) b/(map) fun/$-({* * *} *)} + |- ^+ a + ?~ b + a + ?~ a + b + ?: (vor p.n.a p.n.b) + ?: =(p.n.b p.n.a) + [[p.n.a (fun p.n.a q.n.a q.n.b)] $(a l.a, b l.b) $(a r.a, b r.b)] + ?: (gor p.n.b p.n.a) + $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b) + $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b) + ?: =(p.n.a p.n.b) + [n.b $(b l.b, a l.a) $(b r.b, a r.a)] + ?: (gor p.n.a p.n.b) + $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a) + $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a) + :: + :: TODO: this is untested; move it. +:: :: +:: ++ difference +:: :: todo: move real implementation here. +:: :> returns elements in {a} that don't exist in {b}. +:: |* {a/(map) b/(map)} +:: (~(dif by a) b) +:: :: +:: :: todo: +:: :: ++difference-with +:: :: ++difference-with-key +:: :: +:: ++ intersection +:: :: todo: move real implementation here. +:: :> returns elements in {a} that exist in {b}. +:: |* {a/(map) b/(map)} +:: (~(int by a) b) +:: :: +:: :: todo: +:: :: ++intersection-with +:: :: ++intersection-with-key + :: + :> # %traversal + +| + :: + ++ transform + :> applies {fun} to each value in {a}. + |* {a/(map) fun/$-(* *)} + ^- (map _,.-.,.-.a fun) + ?~ a + ~ + [[p.n.a (fun q.n.a)] $(a l.a) $(a r.a)] + :: + ++ transform-with-key + :> applies {fun} to each value in {a}. + |* {a/(map) fun/$-({* *} *)} + ^- (map _,.-.,.-.a _*fun) + ?~ a + ~ + [[p.n.a (fun p.n.a q.n.a)] $(a l.a) $(a r.a)] + :: + ++ transform-fold + :> performs a fold on all the values in {a}. + :> + :> lists have an order, but maps are treaps. this means there isn't a + :> horizontal ordering, and thus the distinction between left and right + :> folding isn't relevant. your accumulator function will be called in + :> treap order. + :> + :> corresponds to {mapAccum} in haskell. + |* {a/(map) b/* fun/$-({* *} {* *})} + ^- {_b (map _,.-.,.-.a _+:*fun)} + ?~ a + [b ~] + =+ d=(fun b q.n.a) + =. q.n.a +.d + =+ e=$(a l.a, b -.d) + =+ f=$(a r.a, b -.e) + [-.f [n.a +.e +.f]] + :: + ++ transform-keys + :> applies {fun} to all keys. + :: todo: the haskell version specifies that the "greatest" original key + :: wins in case of duplicates. this is currently unhandled. maybe i just + :: shouldn't have this gate. + |* {a/(map) fun/$-(* *)} + =+ l=(to-list a) + %- from-list + %+ transform:ls l + |= item/_,.-.a + [(fun p.item) q.item] + :: + ++ transform-keys-with + :> applies {fun} to all keys, creating a new value with {combine} on dupes. + |* {a/(map) fun/$-(* *) combine/$-({* *} *)} + ^- (map _*fun _,.+.,.-.a) + =+ l=(to-list a) + =/ new-list + %+ transform:ls l + |= item/_,.-.a + [(fun p.item) q.item] + %^ foldl:ls new-list + `(map _*fun _,.+.,.-.a)`~ + |= {m/(map _*fun _,.+.,.-.a) p/_,.-.new-list} + (insert-with m -.p +.p combine) + :: + ++ fold + :> performs a fold on all the values in {a}. + :> + :> lists have an order, but maps are treaps. this means there isn't a + :> horizontal ordering, and thus the distinction between left and right + :> folding isn't relevant. your accumulator function will be called in + :> treap order. + |* {a/(map) b/* fun/$-({* *} *)} + ^- _b + ?~ a + b + =+ d=(fun b q.n.a) + =+ e=$(a l.a, b d) + $(a r.a, b e) + :: + ++ fold-with-keys + :> performs a fold on all the values in {a}, passing keys too. + |* {a/(map) b/* fun/$-({* * *} *)} + ^+ b + ?~ a + b + =+ d=(fun b p.n.a q.n.a) + =+ e=$(a l.a, b d) + $(a r.a, b e) + :: + ++ any + :> returns yes if any element satisfies the predicate + |* {a/(map) b/$-(* ?)} + ^- ? + ?~ a + %.n + ?|((b q.n.a) $(a l.a) $(a r.a)) + :: + ++ any-with-key + :> returns yes if any element satisfies the predicate + |* {a/(map) b/$-({* *} ?)} + ^- ? + ?~ a + %.n + ?|((b p.n.a q.n.a) $(a l.a) $(a r.a)) + :: + ++ all + :> returns yes if all elements satisfy the predicate + |* {a/(map) b/$-(* ?)} + ^- ? + ?~ a + %.y + ?&((b q.n.a) $(a l.a) $(a r.a)) + :: + ++ all-with-key + :> returns yes if all elements satisfy the predicate + |* {a/(map) b/$-({* *} ?)} + ^- ? + ?~ a + %.y + ?&((b p.n.a q.n.a) $(a l.a) $(a r.a)) + :: + :> # %conversion + +| + ++ elems + :> return all values in the map. + |* a/(map) + %+ turn (to-list a) second + :: + ++ keys + :> returns all keys in the map. + |* a/(map) + %+ turn (to-list a) first + :: + :: todo: ++assocs probably doesn't make sense when we have ++to-list and + :: when there's no general noun ordering. + :: + ++ keys-set + :> returns all keys as a set. + |* a/(map) + (si:nl (keys a)) + :: + ++ from-set + :> computes a map by running {fun} on every value in a set. + |* {a/(set) fun/$-(* *)} + ^- (map _,.-.a _*fun) + ?~ a + ~ + [[n.a (fun n.a)] $(a l.a) $(a r.a)] + :: + :> # %lists + +| + :: + ++ to-list + :> todo: copy over or something. + |* a/(map) + ~(tap by a) + :: + ++ from-list + :> todo: name or something + malt + :: + ++ from-list-with + :> creates a map from a list, with {fun} resolving duplicates. + |* {a/(list (pair)) fun/$-(* *)} + %^ foldl:ls a + `(map _*fun _,.+.,.-.a)`~ + |* {m/(map _*fun _,.+.,.-.a) p/_,.-.a} + (insert-with m -.p +.p fun) + :: + :: todo: without a natural ordering, association lists and gates to operate + :: on them probably don't make sense. i'm skipping them for now. + :: + :> # %filters + +| + ++ filter + :> returns a map of all values that satisfy {fun}. + |* {a/(map) fun/$-(* ?)} + :: todo: the runtime on this is bogus. does a better version go here or a + :: jet? + %- from-list + %+ filter:ls (to-list a) + |= p/_,.-.a + (fun q.p) + :: + ++ filter-with-key + :> returns a map of all values that satisfy {fun}. + :: todo: the runtime on this is bogus. does a better version go here or a + :: jet? + |* {a/(map) fun/$-({* *} ?)} + %- from-list + %+ filter:ls (to-list a) fun + :: + ++ restrict-keys + :> returns a map where the only allowable keys are {keys}. + |* {a/(map) keys/(set)} + :: todo: the runtime on this is bogus. does a better version go here or a + :: jet? + %- from-list + %+ filter:ls (to-list a) + |= p/_,.-.a + :: todo: replace this with a call to our set library when we advance that + :: far. + (~(has in keys) p.p) + :: + ++ without-keys + :> returns a map where the only allowable keys are not in {keys}. + |* {a/(map) keys/(set)} + :: todo: the runtime on this is bogus. does a better version go here or a + :: jet? + %- from-list + %+ filter:ls (to-list a) + |= p/_,.-.a + :: todo: replace this with a call to our set library when we advance that + :: far. + !(~(has in keys) p.p) + :: + ++ partition + :> returns two lists, one whose elements match {fun}, the other doesn't. + |* {a/(map) fun/$-(* ?)} + =/ data + %+ partition:ls (to-list a) + |= p/_,.-.a + (fun q.p) + [(from-list -.data) (from-list +.data)] + :: + :: todo: ++partition-with-key once ++partition works. + :: + :: i'm going to ignore all the Antitone functions; they don't seem to be + :: useful without ordering on the map. + :: + ++ transform-maybe + :> a version of transform that can throw out items. + |* {a/(map) fun/$-(* (maybe))} + ^- (map _,.-.,.-.a _+:*fun) + ?~ a ~ + =+ res=(fun q.n.a) + ?~ res + :: todo: runtime wise, I can do better than a union on delete? + (union $(a l.a) $(a r.a)) + [[p.n.a +.res] $(a l.a) $(a r.a)] + :: + ++ transform-maybe-with-key + :> a version of transform that can throw out items. + |* {a/(map) fun/$-({* *} (maybe))} + ^- (map _,.-.,.-.a _+:*fun) + ?~ a ~ + =+ res=(fun n.a) + ?~ res + :: todo: runtime wise, I can do better than a union on delete? + (union $(a l.a) $(a r.a)) + [[p.n.a +.res] $(a l.a) $(a r.a)] + :: + :: todo: ++transform-either is another case where the inability to decompose + :: doesn't work. same with ++transform-either-with-key + :: + :: ++split, ++split-lookup and ++split-root do not make sense without + :: ordinal keys. + :: + :: todo: is-submap no longer nest fails. it now goes into an infinite loop + :: like ++is-infix-of does. + :: ++ is-submap + :: :> returns %.y if every element in {a} exists in {b} with the same value. + :: |* {a/(map) b/(map)} + :: (is-submap-by a b |=({a/* b/*} =(a b))) + :: :: + :: ++ is-submap-by + :: :> returns %.y if every element in {a} exists in {b} with the same value. + :: |* {a/(map) b/(map) fun/$-({* *} ?)} + :: ^- ? + :: ?~ a %.y + :: ?~ b %.n + :: ~! b + :: ~! p.n.a + :: =+ x=(get b p.n.a) + :: ?~ x %.n + :: |((fun q.n.a u.x) $(a l.a) $(a r.a)) + :: + :: all indexed methods do not make sense when keys aren't ordered. + :: + :: all the -min, -max methods are O(log n) on ordered keys, but would be + :: O(n) with treaps. i can't think of what they're useful for, either. + -- +-- From 21926968aeb0e56fbba5cbfc239c65ab61ada512 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 25 Sep 2017 15:54:41 -0700 Subject: [PATCH 005/184] Clean out lots of todos. --- gen/test.hoon | 79 ++++++++++++++----- lib/new-hoon.hoon | 196 +++++++++++++++++++++++++--------------------- 2 files changed, 166 insertions(+), 109 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 845107275..e5342e816 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -259,7 +259,10 @@ :: ++ test-foldr (expect-eq (foldr [1 2 3 ~] 1 |=({a/@ b/@} (add a b))) 7 "foldr") - :: todo: ++concat goes here + :: + ++ test-concat + (expect-eq (concat ~[~[1 2] ~[3 4]]) ~[1 2 3 4] "concat") + :: ++ test-any-true (expect-eq (any [1 2 3 ~] |=(a/@ =(a 2))) %.y "any true") :: @@ -379,13 +382,12 @@ (is-suffix-of "bar" "foobar") %.y "is-suffix-of" - :: TODO: Figure out why ++is-infix-of never terminates, but only on the - :: master branch. - :: ++ test-is-infix-of - :: %^ expect-eq - :: (is-infix-of "ob" "foobar") - :: %.y - :: "is-infix-of" + :: + ++ test-is-infix-of + %^ expect-eq + (is-infix-of "ob" "foobar") + %.y + "is-infix-of" :: ++ test-elem %^ expect-eq @@ -497,7 +499,17 @@ (insert-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~]) "insert-with-key" - + :: + ++ test-insert-lookup-with-key + %^ expect-eq + %- insert-lookup-with-key :^ + four + 4 + "five" + |=({key/@ud old/tape new/tape} new) + :- `"four" + (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "five"] ~]) + "insert-lookup-with-key" :: ++ test-delete %^ expect-eq @@ -687,7 +699,7 @@ add (from-list [[1 1] [2 2] [3 3] ~]) "from-list-with" - + :: ++ test-filter %^ expect-eq %+ filter @@ -745,14 +757,38 @@ (from-list [[1 2] [2 3] [4 5] [5 6] ~]) "transform-maybe-with-key" :: - :: ++ test-is-submap - :: %^ expect-eq - :: %^ is-submap-by - :: (from-list [[1 1] [4 4] ~]) - :: (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - :: |=({a/* b/*} =(a b)) - :: %.y - :: "is-submap" + ++ test-transform-either + %^ expect-eq + %+ transform-either + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |= value/@u + ?: =(0 (mod value 2)) + [%& "even"] + [%| 1] + :- (from-list [[2 "even"] [4 "even"] ~]) + (from-list [[1 1] [3 1] [5 1] ~]) + "transform-either" + :: + ++ test-transform-either-with-key + %^ expect-eq + %+ transform-either-with-key + (from-list [[1 1] [2 1] [3 1] [4 1] [5 1] ~]) + |= {key/@u value/@u} + ?: =(0 (mod key 2)) + [%& "even"] + [%| 1] + :- (from-list [[2 "even"] [4 "even"] ~]) + (from-list [[1 1] [3 1] [5 1] ~]) + "transform-either" + :: + ++ test-is-submap + %^ expect-eq + %^ is-submap-by + (from-list [[1 1] [4 4] ~]) + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=({a/* b/*} =(a b)) + %.y + "is-submap" -- :: ---------------------------------------------------------------------- :: Stays in the generator. @@ -822,6 +858,7 @@ -- :: ---------------------------------------------------------------------- -- + :- %say |= $: {now/@da eny/@uvJ bec/beak} $~ @@ -832,7 +869,7 @@ :: scry ford for the core from the hoon file. that doesn't exist yet. ::(perform-test-suite:local "test-core" !>(test-core) eny) -:: (perform-test-suite:local "test-thr" !>(test-thr) eny) +:: (perform-test-suite:local "test-thr" !>(test-thr) eny) :: (perform-test-suite:local "test-myb" !>(test-myb) eny) -::(perform-test-suite:local "test-ls" !>(test-ls) eny) -(perform-test-suite:local "test-mp" !>(test-mp) eny) +(perform-test-suite:local "test-ls" !>(test-ls) eny) +::(perform-test-suite:local "test-mp" !>(test-mp) eny) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 086a97c95..8561303e6 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -10,6 +10,7 @@ +.a :: ++ either |*({a/mold b/mold} $%({$& p/a} {$| p/b})) :: either +:: ++ thr |% ++ apply @@ -49,8 +50,7 @@ |* a/(list (either)) => .(a (homo a)) |- - :: todo: this cast is bad. how do i make it a list with the internal types - ^- {(list) (list)} + ^- {(list _?>(?=({{%& *} *} a) p.i.a)) (list _?>(?=({{%| *} *} a) p.i.a))} ?~ a [~ ~] =+ ret=$(a t.a) @@ -263,10 +263,9 @@ ++ intercalate :> places {a} between each list in {b}, and flatten to a single list. |* {a/(list) b/(list (list))} -:: => .(b ^.(homo b)) - :: todo: this should homogenize with each sub-list in {b}, but right now, - :: i can't get the ++concat/++zang gate working. - ^+ (homo a) + => .(a ^.(homo a), b ^.(homo b)) + |- + ^+ (concat [a b]) ?~ b ~ =+ c=$(b t.b) @@ -330,28 +329,15 @@ ?~ a b (c $(a t.a) i.a) - - -:: This is even worse; cgy's ++zang doesn't do concat on master either. -:: -:: ++ zang :: new promote -:: |* a/(list (list)) -:: => .(a ^.(homo a)) -:: |- ^+ i:-.a -:: ?~ a -:: ~ -:: (weld i.a $(a t.a)) -:: :: TODO: this hits the |* span issue. -:: :: -:: :: :> concatenate a list of lists into a single level. -:: :: ++ concat -:: :: |* a/(list (list)) -:: :: ?~ a -:: :: ~ -:: :: ?~ +.a -:: :: -.a -:: :: (homo (weld -.a $(a +.a))) - + :: + ++ concat + :> concatenate a list of lists into a single level. + |* a/(list (list)) + => .(a ^.(homo a)) + |- ^+ (homo i:-.a) + ?~ a + ~ + (weld (homo i.a) $(a t.a)) :: ++ any :> returns yes if any element satisfies the predicate @@ -579,6 +565,9 @@ ++ is-prefix-of :> returns %.y if the first list is a prefix of the second. |* {a/(list) b/(list)} + => .(a (homo a), b (homo b)) + |- + ^- ? ?~ a %.y ?~ b @@ -590,23 +579,25 @@ ++ is-suffix-of :> returns %.y if the first list is the suffix of the second. |* {a/(list) b/(list)} + => .(a (homo a), b (homo b)) + ^- ? :: todo: this is performant in haskell because of laziness but may not be :: adequate in hoon. (is-prefix-of (reverse a) (reverse b)) :: - :: todo: figure out why ++is-infix-of never terminates, but only on the - :: master branch. - :: - :: ++ is-infix-of - :: :> returns %.y if the first list appears anywhere in the second. - :: |* {a/(list) b/(list)} - :: ?~ a - :: %.y - :: ?~ b - :: %.n - :: ?: (is-prefix-of a b) - :: %.y - :: $(b t.b) + ++ is-infix-of + :> returns %.y if the first list appears anywhere in the second. + |* {a/(list) b/(list)} + => .(a (homo a), b (homo b)) + |- + ^- ? + ?~ a + %.y + ?~ b + %.n + ?: (is-prefix-of a b) + %.y + $(b t.b) :: :: todo: ++is-subsequence-of :: @@ -908,33 +899,28 @@ [n.a l.a d] [n.d [n.a l.a l.d] r.d] :: - :: todo: there's something wrong with the span here. - :: -:: ++ insert-lookup-with-key -:: :> combines insertion with lookup in one pass. -:: |* {a/(map) key/* value/* fun/$-({* * *} *)} -:: :: todo: type should reference a. -:: |- ^+ {*(unit value) a} -:: :: |- ^+ a ::{*(unit value) a} -:: ?~ a -:: [~ [[key value] ~ ~]] -:: ?: =(key p.n.a) -:: :: key already exists; use {fun} to resolve. -:: :: [~ q.n.a] -:: [~ [[key (fun p.n.a q.n.a value)] l.a r.a]] -:: ?: (gor key p.n.a) -:: =+ d=$(a l.a) -:: ~! d -:: ?> ?=(^ d) -:: ?: (vor p.n.a p.n.d) -:: [~ [n.a d r.a]] -:: [~ [n.d l.d [n.a r.d r.a]]] -:: =+ d=$(a r.a) -:: ~! d -:: ?> ?=(^ d) -:: ?: (vor p.n.a p.n.d) -:: [~ [n.a l.a d]] -:: [~ [n.d [n.a l.a l.d] r.d]] + ++ insert-lookup-with-key + :> combines insertion with lookup in one pass. + |* {a/(map) key/* value/* fun/$-({* * *} *)} + |- ^- {(maybe _value) _a} + ?~ a + [~ [[key value] ~ ~]] + ?: =(key p.n.a) + :: key already exists; use {fun} to resolve. + [`q.n.a [[key (fun p.n.a q.n.a value)] l.a r.a]] + ?: (gor key p.n.a) + =+ rec=$(a l.a) + =+ d=+.rec + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [-.rec [n.a d r.a]] + [-.rec [n.d l.d [n.a r.d r.a]]] + =+ rec=$(a r.a) + =+ d=+.rec + ?> ?=(^ d) + ?: (vor p.n.a p.n.d) + [-.rec [n.a l.a d]] + [-.rec [n.d [n.a l.a l.d] r.d]] :: :> # %delete-update +| @@ -1373,30 +1359,64 @@ (union $(a l.a) $(a r.a)) [[p.n.a +.res] $(a l.a) $(a r.a)] :: - :: todo: ++transform-either is another case where the inability to decompose - :: doesn't work. same with ++transform-either-with-key + ++ transform-either + :> splits the map in two on a gate that returns an either. + |* {a/(map) fun/$-(* (either))} + |- + ^- $: (map _,.-.,.-.a _?>(?=({{%& *} *} *fun) +:*fun)) + (map _,.-.,.-.a _?>(?=({{%| *} *} *fun) +:*fun)) + == + ?~ a + [~ ~] + :: todo: runtime wise, can I do better than recursive unions? + =+ lr=$(a l.a) + =+ rr=$(a r.a) + =+ x=(fun q.n.a) + ?- -.x + $& [(insert (union -.lr -.rr) p.n.a +.x) (union +.lr +.rr)] + $| [(union -.lr -.rr) (insert (union +.lr +.rr) p.n.a +.x)] + == + :: + ++ transform-either-with-key + :> splits the map in two on a gate that returns an either. + |* {a/(map) fun/$-({* *} (either))} + |- + ^- $: (map _,.-.,.-.a _?>(?=({{%& *} *} *fun) +:*fun)) + (map _,.-.,.-.a _?>(?=({{%| *} *} *fun) +:*fun)) + == + ?~ a + [~ ~] + :: todo: runtime wise, can I do better than recursive unions? + =+ lr=$(a l.a) + =+ rr=$(a r.a) + =+ x=(fun n.a) + ~! x + ?- -.x + $& [(insert (union -.lr -.rr) p.n.a +.x) (union +.lr +.rr)] + $| [(union -.lr -.rr) (insert (union +.lr +.rr) p.n.a +.x)] + == :: :: ++split, ++split-lookup and ++split-root do not make sense without :: ordinal keys. :: - :: todo: is-submap no longer nest fails. it now goes into an infinite loop - :: like ++is-infix-of does. - :: ++ is-submap - :: :> returns %.y if every element in {a} exists in {b} with the same value. - :: |* {a/(map) b/(map)} - :: (is-submap-by a b |=({a/* b/*} =(a b))) - :: :: - :: ++ is-submap-by - :: :> returns %.y if every element in {a} exists in {b} with the same value. - :: |* {a/(map) b/(map) fun/$-({* *} ?)} - :: ^- ? - :: ?~ a %.y - :: ?~ b %.n - :: ~! b - :: ~! p.n.a - :: =+ x=(get b p.n.a) - :: ?~ x %.n - :: |((fun q.n.a u.x) $(a l.a) $(a r.a)) + ++ is-submap + :> returns %.y if every element in {a} exists in {b} with the same value. + |* {a/(map) b/(map)} + ^- ? + (is-submap-by a b |=({a/* b/*} =(a b))) + :: + ++ is-submap-by + :> returns %.y if every element in {a} exists in {b} with the same value. + |* {a/(map) b/(map) fun/$-({* *} ?)} + |- + ^- ? + ?~ a %.y + ?~ b %.n + ~! b + ~! p.n.a + =+ x=(get b p.n.a) + ?~ x %.n + |((fun q.n.a u.x) $(a l.a) $(a r.a)) :: :: all indexed methods do not make sense when keys aren't ordered. :: From 843c902bf288d86d951b885d34767c912e5fdc8a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 25 Sep 2017 23:25:58 -0700 Subject: [PATCH 006/184] Remove most usage of , to strip faces. Use the face itself instead. --- lib/new-hoon.hoon | 62 ++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 8561303e6..65dff7362 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -121,8 +121,7 @@ |* a/(list (maybe)) => .(a (homo a)) |- -:: ^- (list _u.i.a) - ^- (list _,.+.,.-.a) + ^- (list _u.+.i.-.a) ?~ a ~ ?~ i.a $(a t.a) @@ -153,7 +152,7 @@ :> applies {b} to {a}. |* {a/(maybe) b/$-(* (maybe))} ?~ a ~ - (b +.a) + (b u.a) :: :: todo: bind, bond, both, flit, hunt, lift, mate, :: @@ -1113,7 +1112,7 @@ ++ transform :> applies {fun} to each value in {a}. |* {a/(map) fun/$-(* *)} - ^- (map _,.-.,.-.a fun) + ^- (map _p.-.n.-.a fun) ?~ a ~ [[p.n.a (fun q.n.a)] $(a l.a) $(a r.a)] @@ -1121,7 +1120,7 @@ ++ transform-with-key :> applies {fun} to each value in {a}. |* {a/(map) fun/$-({* *} *)} - ^- (map _,.-.,.-.a _*fun) + ^- (map _p.-.n.-.a _*fun) ?~ a ~ [[p.n.a (fun p.n.a q.n.a)] $(a l.a) $(a r.a)] @@ -1136,7 +1135,7 @@ :> :> corresponds to {mapAccum} in haskell. |* {a/(map) b/* fun/$-({* *} {* *})} - ^- {_b (map _,.-.,.-.a _+:*fun)} + ^- {_b (map _p.-.n.-.a _+:*fun)} ?~ a [b ~] =+ d=(fun b q.n.a) @@ -1151,24 +1150,22 @@ :: wins in case of duplicates. this is currently unhandled. maybe i just :: shouldn't have this gate. |* {a/(map) fun/$-(* *)} - =+ l=(to-list a) %- from-list - %+ transform:ls l - |= item/_,.-.a + %+ transform:ls (to-list a) + |= item/_n.-.a [(fun p.item) q.item] :: ++ transform-keys-with :> applies {fun} to all keys, creating a new value with {combine} on dupes. |* {a/(map) fun/$-(* *) combine/$-({* *} *)} - ^- (map _*fun _,.+.,.-.a) - =+ l=(to-list a) + ^- (map _*fun _q.+.n.-.a) =/ new-list - %+ transform:ls l - |= item/_,.-.a + %+ transform:ls (to-list a) + |= item/_n.-.a [(fun p.item) q.item] %^ foldl:ls new-list - `(map _*fun _,.+.,.-.a)`~ - |= {m/(map _*fun _,.+.,.-.a) p/_,.-.new-list} + `(map _*fun _q.+.n.-.a)`~ + |= {m/(map _*fun _q.+.n.-.a) p/_i.-.new-list} (insert-with m -.p +.p combine) :: ++ fold @@ -1251,7 +1248,7 @@ ++ from-set :> computes a map by running {fun} on every value in a set. |* {a/(set) fun/$-(* *)} - ^- (map _,.-.a _*fun) + ^- (map _n.-.a _*fun) ?~ a ~ [[n.a (fun n.a)] $(a l.a) $(a r.a)] @@ -1265,15 +1262,20 @@ ~(tap by a) :: ++ from-list - :> todo: name or something - malt + :> creates a tree from a list. + |* a/(list (pair)) + |- + %^ foldl:ls a + `(map _p.-.i.-.a _q.+.i.-.a)`~ + |= {m/(map _p.-.i.-.a _q.+.i.-.a) p/_i.-.a} + (insert m p) :: ++ from-list-with :> creates a map from a list, with {fun} resolving duplicates. |* {a/(list (pair)) fun/$-(* *)} %^ foldl:ls a - `(map _*fun _,.+.,.-.a)`~ - |* {m/(map _*fun _,.+.,.-.a) p/_,.-.a} + `(map _*fun _q.+.i.-.a)`~ + |= {m/(map _*fun _q.+.i.-.a) p/_i.-.a} (insert-with m -.p +.p fun) :: :: todo: without a natural ordering, association lists and gates to operate @@ -1288,7 +1290,7 @@ :: jet? %- from-list %+ filter:ls (to-list a) - |= p/_,.-.a + |= p/_n.-.a (fun q.p) :: ++ filter-with-key @@ -1306,7 +1308,7 @@ :: jet? %- from-list %+ filter:ls (to-list a) - |= p/_,.-.a + |= p/_n.-.a :: todo: replace this with a call to our set library when we advance that :: far. (~(has in keys) p.p) @@ -1318,7 +1320,7 @@ :: jet? %- from-list %+ filter:ls (to-list a) - |= p/_,.-.a + |= p/_n.-.a :: todo: replace this with a call to our set library when we advance that :: far. !(~(has in keys) p.p) @@ -1328,7 +1330,7 @@ |* {a/(map) fun/$-(* ?)} =/ data %+ partition:ls (to-list a) - |= p/_,.-.a + |= p/_n.-.a (fun q.p) [(from-list -.data) (from-list +.data)] :: @@ -1340,7 +1342,7 @@ ++ transform-maybe :> a version of transform that can throw out items. |* {a/(map) fun/$-(* (maybe))} - ^- (map _,.-.,.-.a _+:*fun) + ^- (map _p.-.n.-.a _+:*fun) ?~ a ~ =+ res=(fun q.n.a) ?~ res @@ -1351,7 +1353,7 @@ ++ transform-maybe-with-key :> a version of transform that can throw out items. |* {a/(map) fun/$-({* *} (maybe))} - ^- (map _,.-.,.-.a _+:*fun) + ^- (map _p.-.n.-.a _+:*fun) ?~ a ~ =+ res=(fun n.a) ?~ res @@ -1363,8 +1365,8 @@ :> splits the map in two on a gate that returns an either. |* {a/(map) fun/$-(* (either))} |- - ^- $: (map _,.-.,.-.a _?>(?=({{%& *} *} *fun) +:*fun)) - (map _,.-.,.-.a _?>(?=({{%| *} *} *fun) +:*fun)) + ^- $: (map _p.-.n.-.a _?>(?=({{%& *} *} *fun) +:*fun)) + (map _p.-.n.-.a _?>(?=({{%| *} *} *fun) +:*fun)) == ?~ a [~ ~] @@ -1381,8 +1383,8 @@ :> splits the map in two on a gate that returns an either. |* {a/(map) fun/$-({* *} (either))} |- - ^- $: (map _,.-.,.-.a _?>(?=({{%& *} *} *fun) +:*fun)) - (map _,.-.,.-.a _?>(?=({{%| *} *} *fun) +:*fun)) + ^- $: (map _p.-.n.-.a _?>(?=({{%& *} *} *fun) +:*fun)) + (map _p.-.n.-.a _?>(?=({{%| *} *} *fun) +:*fun)) == ?~ a [~ ~] From 0d2b14f4b7f94556b6f4c147cfcfd87b1576115b Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 27 Sep 2017 21:18:02 -0700 Subject: [PATCH 007/184] Weld should work on differently typed lists. --- gen/test.hoon | 3 +++ lib/new-hoon.hoon | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index e5342e816..715bfe8b6 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -263,6 +263,9 @@ ++ test-concat (expect-eq (concat ~[~[1 2] ~[3 4]]) ~[1 2 3 4] "concat") :: + ++ test-weld + (expect-eq (weld:ls ~[1 2 3] ~["one" "two"]) ~[1 2 3 "one" "two"] "weld") + :: ++ test-any-true (expect-eq (any [1 2 3 ~] |=(a/@ =(a 2))) %.y "any true") :: diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 65dff7362..47b3246a0 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -338,6 +338,14 @@ ~ (weld (homo i.a) $(a t.a)) :: + ++ weld + :> combine two lists, possibly of different types. + |* {a/(list) b/(list)} + => .(a ^.(homo a), b ^.(homo b)) + |- ^- (list $?(_i.-.a _i.-.b)) + ?~ a b + [i.a $(a t.a)] + :: ++ any :> returns yes if any element satisfies the predicate |* {a/(list) b/$-(* ?)} @@ -756,9 +764,8 @@ :> the list union of {a} and {b}. |* {a/(list) b/(list)} => .(a (homo a), b (homo b)) - :: todo: this doesn't work on (weld [1 2 ~] ["one" "two" ~]) - :: ^+ (weld a b) |- + ^+ (weld a b) ?~ a b ?~ b @@ -769,8 +776,8 @@ :> the intersection of {a} and {b}. |* {a/(list) b/(list)} => .(a (homo a), b (homo b)) - ^+ a |- + ^+ a ?~ a ~ ?: (elem i.a b) From 3b007e389cec623e452d1ba0aeb969fc60659c02 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 27 Sep 2017 21:20:32 -0700 Subject: [PATCH 008/184] Fix the runtime of ++alter and family. Previous runtime was pretty nutty and walked the tree multiple times. --- gen/test.hoon | 14 ++++- lib/new-hoon.hoon | 140 +++++++++++++++++++++++----------------------- 2 files changed, 81 insertions(+), 73 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 715bfe8b6..539f07d6f 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -574,6 +574,15 @@ (from-list [[1 "one"] [3 "three"] [4 "four"] ~]) "alter (as delete)" :: + ++ test-alter-as-change + %^ expect-eq + %^ alter + four + 2 + |=(a/(maybe tape) `(maybe tape)`[~ "dos"]) + (from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~]) + "alter (as change)" + :: ++ test-union %^ expect-eq %+ union @@ -861,7 +870,6 @@ -- :: ---------------------------------------------------------------------- -- - :- %say |= $: {now/@da eny/@uvJ bec/beak} $~ @@ -874,5 +882,5 @@ :: (perform-test-suite:local "test-thr" !>(test-thr) eny) :: (perform-test-suite:local "test-myb" !>(test-myb) eny) -(perform-test-suite:local "test-ls" !>(test-ls) eny) -::(perform-test-suite:local "test-mp" !>(test-mp) eny) +::(perform-test-suite:local "test-ls" !>(test-ls) eny) +(perform-test-suite:local "test-mp" !>(test-mp) eny) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 47b3246a0..152eff2fe 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -790,7 +790,6 @@ :: -- ++ mp - :: todo: why do hoon maps use double hash ordering? does this matter? |% :> # %query :> looks up values in the map. @@ -941,92 +940,83 @@ ?: (gor key p.n.a) [n.a $(a l.a) r.a] [n.a l.a $(a r.a)] - |- ^- {$?($~ _a)} - ?~ l.a r.a - ?~ r.a l.a - ?: (vor p.n.l.a p.n.r.a) - [n.l.a l.l.a $(l.a r.l.a)] - [n.r.a $(r.a l.r.a) r.r.a] + (pop-top a) :: ++ adjust :> updates a value at {key} by passing the value to {fun}. |* {a/(map) key/* fun/$-(* *)} - |- ^+ a - ?~ a - ~ - ?: =(key p.n.a) - [[key (fun q.n.a)] l.a r.a] - ?: (gor key p.n.a) - =+ d=$(a l.a) - ?> ?=(^ d) - ?: (vor p.n.a p.n.d) - [n.a d r.a] - [n.d l.d [n.a r.d r.a]] - =+ d=$(a r.a) - ?> ?=(^ d) - ?: (vor p.n.a p.n.d) - [n.a l.a d] - [n.d [n.a l.a l.d] r.d] + %^ alter-with-key a key + |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + ^- (maybe _q.+.n.-.a) + ?~ value ~ + [~ (fun u.value)] :: ++ adjust-with-key :> updates a value at {key} by passing the key/value pair to {fun}. |* {a/(map) key/* fun/$-({* *} *)} - |- ^+ a - ?~ a - ~ - ?: =(key p.n.a) - [[key (fun key q.n.a)] l.a r.a] - ?: (gor key p.n.a) - =+ d=$(a l.a) - ?> ?=(^ d) - ?: (vor p.n.a p.n.d) - [n.a d r.a] - [n.d l.d [n.a r.d r.a]] - =+ d=$(a r.a) - ?> ?=(^ d) - ?: (vor p.n.a p.n.d) - [n.a l.a d] - [n.d [n.a l.a l.d] r.d] + %^ alter-with-key a key + |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + ^- (maybe _q.+.n.-.a) + ?~ value ~ + [~ (fun key u.value)] :: ++ update :> adjusts or deletes the value at {key} by {fun}. |* {a/(map) key/* fun/$-(* (maybe *))} - |- ^+ a - :: todo: this implementation is inefficient and traverses the tree multiple - :: times, when it can be done in O(log n). this should be solved in a jet? - =+ val=(get a key) - ?~ val - a - =+ ret=(fun u.val) - ?~ ret - (delete a key) - (insert a key u.ret) + %^ alter-with-key a key + |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + ^- (maybe _q.+.n.-.a) + ?~ value ~ + (fun u.value) :: ++ update-with-key :> adjusts or deletes the value at {key} by {fun}. |* {a/(map) key/* fun/$-({* *} (maybe *))} - |- ^+ a - :: todo: this implementation is inefficient and traverses the tree multiple - :: times, when it can be done in O(log n). this should be solved in a jet? - =+ val=(get a key) - ?~ val - a - =+ ret=(fun key u.val) - ?~ ret - (delete a key) - (insert a key u.ret) + %^ alter-with-key a key + |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + ^- (maybe _q.+.n.-.a) + ?~ value ~ + (fun key u.value) + :: :: todo: :: ++update-lookup-with-key :: ++ alter :> inserts, deletes, or updates a value by {fun}. - |* {a/(map) key/* fun/$-(* (maybe *))} - :: todo: this implementation is inefficient and traverses the tree multiple - :: times, when it can be done in O(log n). this should be solved in a jet? - =+ ret=(fun (get a key)) - ?~ ret - (delete a key) - (insert a key u.ret) + |* {a/(map) key/* fun/$-((maybe *) (maybe *))} + %^ alter-with-key a key + |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + (fun value) + :: + ++ alter-with-key + :> inserts, deletes, or updates a value by {fun}. + |* {a/(map) key/* fun/$-({* (maybe *)} (maybe *))} + |- ^+ a + ?~ a + =+ ret=(fun key ~) + ?~ ret + ~ + [[key u.ret] ~ ~] + ?: =(key p.n.a) + =+ ret=(fun key `q.n.a) + ?~ ret + (pop-top a) + ?: =(u.ret q.n.a) + a + [[key u.ret] l.a r.a] + ?: (gor key p.n.a) + =+ d=$(a l.a) + ?~ d + [n.a ~ r.a] + ?: (vor p.n.a p.n.d) + [n.a d r.a] + [n.d l.d [n.a r.d r.a]] + =+ d=$(a r.a) + ?~ d + [n.a l.a ~] + ?: (vor p.n.a p.n.d) + [n.a l.a d] + [n.d [n.a l.a l.d] r.d] :: :> # %combine +| @@ -1427,9 +1417,19 @@ ?~ x %.n |((fun q.n.a u.x) $(a l.a) $(a r.a)) :: - :: all indexed methods do not make sense when keys aren't ordered. - :: - :: all the -min, -max methods are O(log n) on ordered keys, but would be - :: O(n) with treaps. i can't think of what they're useful for, either. + :> # %impl + :> implementation details + +| + ++ pop-top + :> removes the head of the tree and rebalances the tree below. + |* a/(map) + ^- {$?($~ _a)} + ?~ a ~ + |- + ?~ l.a r.a + ?~ r.a l.a + ?: (vor p.n.l.a p.n.r.a) + [n.l.a l.l.a $(l.a r.l.a)] + [n.r.a $(r.a l.r.a) r.r.a] -- -- From 1d8614f2ee40b9bb2931c925dc11e6d0a4ec0231 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 27 Sep 2017 21:55:35 -0700 Subject: [PATCH 009/184] Don't repeat ++transform-either's implementation. --- lib/new-hoon.hoon | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 152eff2fe..4c6c4d01c 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -1361,20 +1361,9 @@ ++ transform-either :> splits the map in two on a gate that returns an either. |* {a/(map) fun/$-(* (either))} - |- - ^- $: (map _p.-.n.-.a _?>(?=({{%& *} *} *fun) +:*fun)) - (map _p.-.n.-.a _?>(?=({{%| *} *} *fun) +:*fun)) - == - ?~ a - [~ ~] - :: todo: runtime wise, can I do better than recursive unions? - =+ lr=$(a l.a) - =+ rr=$(a r.a) - =+ x=(fun q.n.a) - ?- -.x - $& [(insert (union -.lr -.rr) p.n.a +.x) (union +.lr +.rr)] - $| [(union -.lr -.rr) (insert (union +.lr +.rr) p.n.a +.x)] - == + %+ transform-either-with-key a + |= {key/* value/_q.+.n.-.a} + (fun value) :: ++ transform-either-with-key :> splits the map in two on a gate that returns an either. From 37f65c099da4c1d6a861930099cf57d573513c3b Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 27 Sep 2017 22:08:40 -0700 Subject: [PATCH 010/184] Inline ++to-list. --- lib/new-hoon.hoon | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 4c6c4d01c..ccf6e7fee 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -1254,9 +1254,14 @@ +| :: ++ to-list - :> todo: copy over or something. + :> creates a list of pairs from the tree. |* a/(map) - ~(tap by a) + =| b/(list _n.-.a) + |- + ^+ b + ?~ a + b + $(a r.a, b [n.a $(a l.a)]) :: ++ from-list :> creates a tree from a list. From 1157710c743d890293d8ee4fcb848f27bbe4507d Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 27 Sep 2017 23:10:45 -0700 Subject: [PATCH 011/184] Fix the semantics and runtime of ++filter. --- gen/test.hoon | 10 +++++----- lib/new-hoon.hoon | 48 ++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 539f07d6f..2d8cf869f 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -413,7 +413,7 @@ ++ test-filter %^ expect-eq (filter [1 2 1 2 1 ~] |=(a/@ =(a 2))) - [2 2 ~] + [1 1 1 ~] "filter" :: ++ test-partition @@ -716,7 +716,7 @@ %^ expect-eq %+ filter (from-list [[1 1] [2 1] [3 2] [4 1] ~]) - |=(a/@u =(a 1)) + |=(a/@u !=(a 1)) (from-list [[1 1] [2 1] [4 1] ~]) "filter" :: @@ -724,7 +724,7 @@ %^ expect-eq %+ filter-with-key (from-list [[1 1] [2 1] [3 2] [4 1] ~]) - |=({a/@u b/@u} !=(a 2)) + |=({a/@u b/@u} =(a 2)) (from-list [[1 1] [3 2] [4 1] ~]) "filter-with-key" :: @@ -882,5 +882,5 @@ :: (perform-test-suite:local "test-thr" !>(test-thr) eny) :: (perform-test-suite:local "test-myb" !>(test-myb) eny) -::(perform-test-suite:local "test-ls" !>(test-ls) eny) -(perform-test-suite:local "test-mp" !>(test-mp) eny) +(perform-test-suite:local "test-ls" !>(test-ls) eny) +::(perform-test-suite:local "test-mp" !>(test-mp) eny) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index ccf6e7fee..3487bb57b 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -641,14 +641,14 @@ $(a t.a) :: ++ filter - :> returns all items in {a} which match predicate {b}. + :> filter all items in {a} which match predicate {b}. |* {a/(list) b/$-(* ?)} => .(a (homo a)) |- ^+ a ?~ a ~ - ?: (b i.a) + ?. (b i.a) [i.a $(a t.a)] $(a t.a) :: @@ -1286,50 +1286,46 @@ :> # %filters +| ++ filter - :> returns a map of all values that satisfy {fun}. + :> filters a map of all values that satisfy {fun}. |* {a/(map) fun/$-(* ?)} - :: todo: the runtime on this is bogus. does a better version go here or a - :: jet? - %- from-list - %+ filter:ls (to-list a) - |= p/_n.-.a - (fun q.p) + %+ filter-with-key a + |= {key/* value/_q.+.n.-.a} + (fun value) :: ++ filter-with-key - :> returns a map of all values that satisfy {fun}. - :: todo: the runtime on this is bogus. does a better version go here or a - :: jet? + :> filters a map of all values that satisfy {fun}. |* {a/(map) fun/$-({* *} ?)} - %- from-list - %+ filter:ls (to-list a) fun + |- + ^+ a + ?~ a ~ + ?: (fun n.a) + =. l.a $(a l.a) + =. r.a $(a r.a) + (pop-top a) + [n.a $(a l.a) $(a r.a)] :: ++ restrict-keys :> returns a map where the only allowable keys are {keys}. |* {a/(map) keys/(set)} - :: todo: the runtime on this is bogus. does a better version go here or a - :: jet? - %- from-list - %+ filter:ls (to-list a) - |= p/_n.-.a + %+ filter-with-key a + |= {key/_p.-.n.-.a value/*} :: todo: replace this with a call to our set library when we advance that :: far. - (~(has in keys) p.p) + !(~(has in keys) key) :: ++ without-keys :> returns a map where the only allowable keys are not in {keys}. |* {a/(map) keys/(set)} - :: todo: the runtime on this is bogus. does a better version go here or a - :: jet? - %- from-list - %+ filter:ls (to-list a) - |= p/_n.-.a + %+ filter-with-key a + |= {key/_p.-.n.-.a value/*} :: todo: replace this with a call to our set library when we advance that :: far. - !(~(has in keys) p.p) + (~(has in keys) key) :: ++ partition :> returns two lists, one whose elements match {fun}, the other doesn't. |* {a/(map) fun/$-(* ?)} + :: todo: is the runtime on this is bogus? =/ data %+ partition:ls (to-list a) |= p/_n.-.a From fc651af8aa26dca2d9a71492dbb392e3109a7950 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Wed, 27 Sep 2017 23:23:12 -0700 Subject: [PATCH 012/184] Minor runtime fix to ++transform-maybe. --- lib/new-hoon.hoon | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 3487bb57b..278b6d54f 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -1340,13 +1340,9 @@ ++ transform-maybe :> a version of transform that can throw out items. |* {a/(map) fun/$-(* (maybe))} - ^- (map _p.-.n.-.a _+:*fun) - ?~ a ~ - =+ res=(fun q.n.a) - ?~ res - :: todo: runtime wise, I can do better than a union on delete? - (union $(a l.a) $(a r.a)) - [[p.n.a +.res] $(a l.a) $(a r.a)] + %+ transform-maybe-with-key a + |= {key/* value/_q.+.n.-.a} + (fun value) :: ++ transform-maybe-with-key :> a version of transform that can throw out items. @@ -1355,8 +1351,9 @@ ?~ a ~ =+ res=(fun n.a) ?~ res - :: todo: runtime wise, I can do better than a union on delete? - (union $(a l.a) $(a r.a)) + =. l.a $(a l.a) + =. r.a $(a r.a) + (pop-top a) [[p.n.a +.res] $(a l.a) $(a r.a)] :: ++ transform-either From 08962cfd63c0b9109e6c43da8b7dedc8573d0192 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 28 Sep 2017 23:05:23 -0700 Subject: [PATCH 013/184] First quickcheck test. Test that the ++alter:mp family is a ++valid treap after a large number of random actions. --- gen/test.hoon | 57 +++++++++++++++++++++++++++++++++++++++++++---- lib/new-hoon.hoon | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 2d8cf869f..ea7a49f77 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -71,8 +71,8 @@ :: todo: wrap generator in mule so it can crash. =+ sample=(generator eny) :: todo: wrap test in mule so it can crash. - =+ test=(test sample) - ?: test + =+ ret=(test sample) + ?: ret %= $ eny (shaf %huh eny) :: xxx: better random? current-iteration (add current-iteration 1) @@ -94,6 +94,22 @@ ^- @ (add min (~(rad og c) (sub max min))) :: + ++ generate-map + :> generator which will produce a map with {count} random pairs. + |= count/@u + :> generate a map with entropy {c}. + |= c/@uvJ + =/ gen (random:new-hoon c) + =| i/@u + =| m/(map @ud @ud) + |- + ^- (map @ud @ud) + ?: =(i count) + m + =^ first gen (rads:gen 100) + =^ second gen (rads:gen 100) + $(m (insert:mp:new-hoon m first second), i +(i)) + :: :: || %test :: :: +| @@ -583,6 +599,33 @@ (from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~]) "alter (as change)" :: + ++ check-alter + :: check random maps of 50 items with 40 random operations done on them + :: for validity. + %+ check + (generate-map 50) + |= a/(map @ud @ud) + :: this is dumb, but use {a} as entropy? + =/ gen (random:new-hoon (jam a)) + =| i/@u + |- + ?: =(i 40) + %.y + =^ key gen (rads:gen 100) + =^ value gen (rads:gen 100) + =. a %^ alter-with-key a key + |= {key/@ud current/(maybe @ud)} + ^- (maybe @ud) + =+ action=(mod key 2) + ?: =(action 0) :: return nothing + ~ + ?: =(action 1) :: add/set value + `value + ~ :: impossible + ?. (valid a) + %.n + $(i +(i)) + :: ++ test-union %^ expect-eq %+ union @@ -801,6 +844,12 @@ |=({a/* b/*} =(a b)) %.y "is-submap" + :: + ++ test-valid + %^ expect-eq + (valid (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9] ~])) + %.y + "valid" -- :: ---------------------------------------------------------------------- :: Stays in the generator. @@ -882,5 +931,5 @@ :: (perform-test-suite:local "test-thr" !>(test-thr) eny) :: (perform-test-suite:local "test-myb" !>(test-myb) eny) -(perform-test-suite:local "test-ls" !>(test-ls) eny) -::(perform-test-suite:local "test-mp" !>(test-mp) eny) +::(perform-test-suite:local "test-ls" !>(test-ls) eny) +(perform-test-suite:local "test-mp" !>(test-mp) eny) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 278b6d54f..3d086eead 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -1418,5 +1418,53 @@ ?: (vor p.n.l.a p.n.r.a) [n.l.a l.l.a $(l.a r.l.a)] [n.r.a $(r.a l.r.a) r.r.a] + :: + ++ valid + :> returns %.y if {a} is a valid treap map. + |* a/(map) + =| {l/(unit) r/(unit)} + |- ^- ? + ?~ a & + ?& ?~(l & (gor p.n.a u.l)) + ?~(r & (gor u.r p.n.a)) + ?~(l.a & ?&((vor p.n.a p.n.l.a) $(a l.a, l `p.n.a))) + ?~(r.a & ?&((vor p.n.a p.n.r.a) $(a r.a, r `p.n.a))) + == + -- +++ random + :> produces a core which produces random numbers. + :: todo: think hard about whether this interface really makes any sense; + :: this is marginally better than ++og for rads usage, but still isn't good. + |= a/@ + :: note: interior was copied verbatim from ++og. + |% + ++ rad :: random in range + |= b/@ ^- @ + =+ c=(raw (met 0 b)) + ?:((lth c b) c $(a +(a))) + :: + ++ rads :: random continuation + |= b/@ + =+ r=(rad b) + [r +>.$(a (shas %og-s (mix a r)))] + :: + ++ raw :: random bits + :: ~/ %raw + |= b/@ ^- @ + %+ can + 0 + =+ c=(shas %og-a (mix b a)) + |- ^- (list {@ @}) + ?: =(0 b) + ~ + =+ d=(shas %og-b (mix b (mix a c))) + ?: (lth b 256) + [[b (end 0 b d)] ~] + [[256 d] $(c d, b (sub b 256))] + :: + ++ raws :: random bits + |= b/@ :: continuation + =+ r=(raw b) + [r +>.$(a (shas %og-s (mix a r)))] -- -- From 7d46bccdfc7cbcaaaf1dd5a8abb90ab76d16712a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 29 Sep 2017 21:26:50 -0700 Subject: [PATCH 014/184] Change the interface for random numbers. --- gen/test.hoon | 12 ++++---- lib/new-hoon.hoon | 71 ++++++++++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index ea7a49f77..476393f2d 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -92,7 +92,9 @@ |= {min/@ max/@} |= c/@uvJ ^- @ - (add min (~(rad og c) (sub max min))) + =+ gen=(random:new-hoon c) + =^ num gen (range:gen min max) + num :: ++ generate-map :> generator which will produce a map with {count} random pairs. @@ -106,8 +108,8 @@ ^- (map @ud @ud) ?: =(i count) m - =^ first gen (rads:gen 100) - =^ second gen (rads:gen 100) + =^ first gen (range:gen 0 100) + =^ second gen (range:gen 0 100) $(m (insert:mp:new-hoon m first second), i +(i)) :: :: || %test @@ -611,8 +613,8 @@ |- ?: =(i 40) %.y - =^ key gen (rads:gen 100) - =^ value gen (rads:gen 100) + =^ key gen (range:gen 0 100) + =^ value gen (range:gen 0 100) =. a %^ alter-with-key a key |= {key/@ud current/(maybe @ud)} ^- (maybe @ud) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 3d086eead..e12957e43 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -1432,38 +1432,51 @@ == -- ++ random - :> produces a core which produces random numbers. - :: todo: think hard about whether this interface really makes any sense; - :: this is marginally better than ++og for rads usage, but still isn't good. + :> produces a core which produces random numbers. + :> + :> random numbers are generated through repeated sha-256 operations. + :> + :> this design forces implementation details to be hidden, forces users to + :> go through =^. this should be less error prone for pulling out multiple + :> random numbers, at the cost of making getting a single random number + :> slightly more cumbersome. + :> + :> =+ gen=(random eny) + :> =^ first gen (range:gen 0 10) + :> =^ second gen (range:gen 0 10) |= a/@ - :: note: interior was copied verbatim from ++og. - |% - ++ rad :: random in range - |= b/@ ^- @ - =+ c=(raw (met 0 b)) - ?:((lth c b) c $(a +(a))) + => |% + ++ raw :: random bits + |= b/@ ^- @ + %+ can + 0 + =+ c=(shas %og-a (mix b a)) + |- ^- (list {@ @}) + ?: =(0 b) + ~ + =+ d=(shas %og-b (mix b (mix a c))) + ?: (lth b 256) + [[b (end 0 b d)] ~] + [[256 d] $(c d, b (sub b 256))] + :: + ++ rad :: random in range + |= b/@ ^- @ + =+ c=(raw (met 0 b)) + ?:((lth c b) c $(a +(a))) + -- + ^? |% + ++ range + :> returns a random number in the range [start, end], and generator. + |= {start/@ end/@} + ?: (gte start end) + ~_(leaf+"invalid range" !!) + =+ offset=(sub end start) + =+ r=(rad offset) + [(add start r) +>.$(a (shas %og-s (mix a r)))] :: - ++ rads :: random continuation + ++ bits + :> returns {b} bits in the range, and generator. |= b/@ - =+ r=(rad b) - [r +>.$(a (shas %og-s (mix a r)))] - :: - ++ raw :: random bits - :: ~/ %raw - |= b/@ ^- @ - %+ can - 0 - =+ c=(shas %og-a (mix b a)) - |- ^- (list {@ @}) - ?: =(0 b) - ~ - =+ d=(shas %og-b (mix b (mix a c))) - ?: (lth b 256) - [[b (end 0 b d)] ~] - [[256 d] $(c d, b (sub b 256))] - :: - ++ raws :: random bits - |= b/@ :: continuation =+ r=(raw b) [r +>.$(a (shas %og-s (mix a r)))] -- From 25accb9eba9c8f96ce3db49a3d511fd96528610e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 6 Oct 2017 20:52:33 -0700 Subject: [PATCH 015/184] Add real unicode uppercasing. Place UnicodeData.txt in %/lib/unicode-data/txt. The +capitalize generator should then capitalize any unicode tape, including characters outside lower ASCII. --- gen/capitalize.hoon | 52 ++++++++++++ mar/unicode-data.hoon | 179 ++++++++++++++++++++++++++++++++++++++++++ sur/unicode-data.hoon | 130 ++++++++++++++++++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 gen/capitalize.hoon create mode 100644 mar/unicode-data.hoon create mode 100644 sur/unicode-data.hoon diff --git a/gen/capitalize.hoon b/gen/capitalize.hoon new file mode 100644 index 000000000..3b755d633 --- /dev/null +++ b/gen/capitalize.hoon @@ -0,0 +1,52 @@ +:: +:: part 1: parse the file into {uppers} +:: +/- unicode-data +:: +:: while this works, it'd be better to build range based data structures like +:: golang does. golang uses flat tables that it binary searches over. storage +:: as a binary tree? +:: +/= uppers + /; |= a/(list line:unicode-data) + =| ret/(map @c @c) + |- + ^- (map @c @c) + ?~ a + ret + ?~ up.i.a + $(a t.a) + $(a t.a, ret (~(put by ret) code.i.a u.up.i.a)) + /: /===/lib/unicode-data /&unicode-data&/txt/ +:: +:: part 2: utility core +:: +|% +++ transform + |= {a/tape fun/$-(@c @c)} + %- tufa + (turn (tuba a) fun) +:: +++ to-upper + |= a/@c + ^- @c + :: special case ascii to not perform map lookup. + ?: (lte a max-ascii) + ?: &((gte a 'a') (lte a 'z')) + (sub a 32) + a + =+ x=(~(get by uppers) a) + (fall x a) +:: +++ max-ascii `@c`0x7f +-- +:: +:: part 3: generator +:: +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + {n/tape $~} + $~ + == +:- %noun +(transform n to-upper) diff --git a/mar/unicode-data.hoon b/mar/unicode-data.hoon new file mode 100644 index 000000000..3367f2e0b --- /dev/null +++ b/mar/unicode-data.hoon @@ -0,0 +1,179 @@ +/- unicode-data +=, eyre +=, format + +:: ok, so we can currently slurp the data in. we're having problems getting it +:: back out. ++txt:grow is probably the next logical step here. + +|_ all/(list line:unicode-data) +++ grow + :> converts from unicode-data to mark. + |% + :: ++ txt + :: ^- wain + :: %+ turn all + :: |= line:unicode-data + :: ;: weld + :: ";" + :: name + :: ";" + -- +:: +++ grab + :> converts from mark to unicode-data. + |% + ++ mime |=({* a/octs} (txt (to-wain q.a))) :: XX mark translation + ++ txt + |^ |= a/wain + ^+ all + %+ turn a + |= b/cord + ^- line:unicode-data + (rash b line) + :: + :> parses a single line of the unicode data file. + ++ line + ;~ (glue sem) + hex + name-string + general-category + (bass 10 (plus sid:ab)) + bidi-category + decomposition-mapping + string-number + string-number + string-number + yes-or-no + name-string + name-string + optional-hex + optional-hex + optional-hex + == + :: + :> parses a single name or comment string. + ++ name-string + %+ cook + |=(a/tape a) + (star ;~(less sem prn)) +:: (star ;~(pose hig low nud hep ace gal gar pel per)) + :: + :> parses a unicode general category abbreviation to symbol + ++ general-category + ;~ pose + (cold %lu (jest 'Lu')) + (cold %ll (jest 'Ll')) + (cold %lt (jest 'Lt')) + (cold %mn (jest 'Mn')) + (cold %mc (jest 'Mc')) + (cold %me (jest 'Me')) + (cold %nd (jest 'Nd')) + (cold %nl (jest 'Nl')) + (cold %no (jest 'No')) + (cold %zs (jest 'Zs')) + (cold %zl (jest 'Zl')) + (cold %zp (jest 'Zp')) + (cold %cc (jest 'Cc')) + (cold %cf (jest 'Cf')) + (cold %cs (jest 'Cs')) + (cold %co (jest 'Co')) + (cold %cn (jest 'Cn')) + (cold %lm (jest 'Lm')) + (cold %lo (jest 'Lo')) + (cold %pc (jest 'Pc')) + (cold %pd (jest 'Pd')) + (cold %ps (jest 'Ps')) + (cold %pe (jest 'Pe')) + (cold %pi (jest 'Pi')) + (cold %pf (jest 'Pf')) + (cold %po (jest 'Po')) + (cold %sm (jest 'Sm')) + (cold %sc (jest 'Sc')) + (cold %sk (jest 'Sk')) + (cold %so (jest 'So')) + == + :: + :> parses a bidirectional category abbreviation to symbol. + ++ bidi-category + ;~ pose + (cold %fsi (jest 'FSI')) + (cold %lre (jest 'LRE')) + (cold %lri (jest 'LRI')) + (cold %lro (jest 'LRO')) + (cold %nsm (jest 'NSM')) + (cold %pdf (jest 'PDF')) + (cold %pdi (jest 'PDI')) + (cold %rle (jest 'RLE')) + (cold %rli (jest 'RLI')) + (cold %rlo (jest 'RLO')) + (cold %al (jest 'AL')) + (cold %an (jest 'AN')) + (cold %bn (jest 'BN')) + (cold %cs (jest 'CS')) + (cold %en (jest 'EN')) + (cold %es (jest 'ES')) + (cold %et (jest 'ET')) + (cold %on (jest 'ON')) + (cold %ws (jest 'WS')) + (cold %b (jest 'B')) + (cold %l (jest 'L')) + (cold %r (jest 'R')) + (cold %s (jest 'S')) + == + :: + :: TODO: This seems to be where the nest-fail is. There's an extra @ here? + ++ decomposition-mapping + ;~ pose + :: a tag and a list of characters to decompose to + %+ stag ~ + ;~ plug + ;~ pose + (stag ~ (ifix [gal ;~(plug gar ace)] decomp-tag)) + (easy ~) + == + (cook |=(a/(list @c) a) (most ace hex)) + == + :: no decomposition information + (easy ~) + == + :: + ++ decomp-tag + ;~ pose + (cold %font (jest 'font')) + (cold %no-break (jest 'noBreak')) + (cold %initial (jest 'initial')) + (cold %medial (jest 'medial')) + (cold %final (jest 'final')) + (cold %isolated (jest 'isolated')) + (cold %circle (jest 'circle')) + (cold %super (jest 'super')) + (cold %sub (jest 'sub')) + (cold %vertical (jest 'vertical')) + (cold %wide (jest 'wide')) + (cold %narrow (jest 'narrow')) + (cold %small (jest 'small')) + (cold %square (jest 'square')) + (cold %fraction (jest 'fraction')) + (cold %compat (jest 'compat')) + == + :: + ++ string-number + %+ cook + |=(a/tape a) + (star ;~(pose nud fas hep)) + :: + ++ yes-or-no + ;~ pose + (cold %.y (jest 'Y')) + (cold %.n (jest 'N')) + == + :: + ++ optional-hex + ;~ pose + (stag ~ hex) + (easy ~) + == + -- + -- +++ grad %txt +-- diff --git a/sur/unicode-data.hoon b/sur/unicode-data.hoon new file mode 100644 index 000000000..88e2e51dc --- /dev/null +++ b/sur/unicode-data.hoon @@ -0,0 +1,130 @@ +|% +++ line + :> an individual codepoint definition + :> + :> code: the codepoint in hexadecimal format + :> name: the character name + :> gen: the type of character this is + :> can: the canonical combining class for ordering algorithms + :> bidi: the bidirectional category of this character + :> de: the character decomposition mapping + :> decimal: the decimal digit value (or ~) + :> digit: the digit value, covering non decimal radix forms + :> numeric: the numeric value, including fractions + :> mirrored: whether char is mirrored in bidirectional text + :> old-name: unicode 1.0 compatibility name + :> iso: iso 10646 comment field + :> up: uppercase mapping codepoint + :> low: lowercase mapping codepoint + :> title: titlecase mapping codepoint + :> + $: code/@c + name/tape + gen/general + can/@ud + bi/bidi + de/decomp + :: todo: decimal/digit/numeric need to be parsed. + decimal/tape + digit/tape + numeric/tape + mirrored/? + old-name/tape + iso/tape + up/(unit @c) + low/(unit @c) + title/(unit @c) + == +:: +++ general + :> one of the normative or informative unicode general categories + :> + :> these abbreviations are as found in the unicode standard, except + :> lowercased as to be valid symbols. + $? $lu :< letter, uppercase + $ll :< letter, lowercase + $lt :< letter, titlecase + $mn :< mark, non-spacing + $mc :< mark, spacing combining + $me :< mark, enclosing + $nd :< number, decimal digit + $nl :< number, letter + $no :< number, other + $zs :< separator, space + $zl :< separator, line + $zp :< separator, paragraph + $cc :< other, control + $cf :< other, format + $cs :< other, surrogate + $co :< other, private use + $cn :< other, not assigned + :: + $lm :< letter, modifier + $lo :< letter, other + $pc :< punctuation, connector + $pd :< punctuation, dash + $ps :< punctuation, open + $pe :< punctuation, close + $pi :< punctuation, initial quote + $pf :< punctuation, final quote + $po :< punctuation, other + $sm :< symbol, math + $sc :< symbol, currency + $sk :< symbol, modifier + $so :< symbol, other + == +:: +++ bidi + :> bidirectional category of a unicode character + $? $l :< left-to-right + $lre :< left-to-right embedding + $lri :< left-to-right isolate + $lro :< left-to-right override + $fsi :< first strong isolate + $r :< right-to-left + $al :< right-to-left arabic + $rle :< right-to-left embedding + $rli :< right-to-left isolate + $rlo :< right-to-left override + $pdf :< pop directional format + $pdi :< pop directional isolate + $en :< european number + $es :< european number separator + $et :< european number terminator + $an :< arabic number + $cs :< common number separator + $nsm :< non-spacing mark + $bn :< boundary neutral + $b :< paragraph separator + $s :< segment separator + $ws :< whitespace + $on :< other neutrals + == +:: +++ decomp + :> character decomposition mapping. + :> + :> tag: type of decomposition. + :> c: a list of codepoints this decomposes into. + (unit {tag/(unit decomp-tag) c/(list @c)}) +:: +++ decomp-tag + :> tag that describes the type of a character decomposition. + $? $font :< a font variant + $no-break :< a no-break version of a space or hyphen + $initial :< an initial presentation form (arabic) + $medial :< a medial presentation form (arabic) + $final :< a final presentation form (arabic) + $isolated :< an isolated presentation form (arabic) + $circle :< an encircled form + $super :< a superscript form + $sub :< a subscript form + $vertical :< a vertical layout presentation form + $wide :< a wide (or zenkaku) compatibility character + $narrow :< a narrow (or hankaku) compatibility character + $small :< a small variant form (cns compatibility) + $square :< a cjk squared font variant + $fraction :< a vulgar fraction form + $compat :< otherwise unspecified compatibility character + == +-- From ccfb11bda9030601f6679d474d0f7fde87b28bd9 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 12 Oct 2017 22:55:45 -0700 Subject: [PATCH 016/184] Complete prototype for a unicode aware ++to-{upper,lower}. This uses a mark to parse UnicodeData.txt, and some ford runes to change this into a binary search tree data structure for quick lookups, along with the optimizations found in golang's unicode table to record ranges instead of individual characters. --- gen/capitalize.hoon | 266 +++++++++++++++++++++++++++++++++++++++--- mar/unicode-data.hoon | 19 +-- sur/unicode-data.hoon | 35 ++++++ 3 files changed, 284 insertions(+), 36 deletions(-) diff --git a/gen/capitalize.hoon b/gen/capitalize.hoon index 3b755d633..49303d2dc 100644 --- a/gen/capitalize.hoon +++ b/gen/capitalize.hoon @@ -2,21 +2,203 @@ :: part 1: parse the file into {uppers} :: /- unicode-data -:: -:: while this works, it'd be better to build range based data structures like -:: golang does. golang uses flat tables that it binary searches over. storage -:: as a binary tree? -:: -/= uppers +/+ new-hoon +/= case-table /; |= a/(list line:unicode-data) - =| ret/(map @c @c) - |- - ^- (map @c @c) - ?~ a - ret - ?~ up.i.a - $(a t.a) - $(a t.a, ret (~(put by ret) code.i.a u.up.i.a)) + =, new-hoon + |^ %- build-tree + %- flop + (build-case-nodes a) + :: + :> # + :> # %case-nodes + :> # + :> transforms raw unicode data into sequential case nodes. + +| + ++ build-case-nodes + :> raw list of unicode data lines to a compact list of chardata + |= a/(list line:unicode-data) + ^- (list case-node:unicode-data) + =< out + :: + :: todo: we don't have the final case range in the output of this + :: gate. this is because this algorithm doesn't work when the last + :: char is part of a range. this doesn't happen with the real one, + :: only the excerpts i was using for testing. + :: + %^ foldl:ls a *case-fold + |= {c/case-fold l/line:unicode-data} + ^+ c + =+ state=(line-to-case-state l) + ?: (is-adjacent state prev.c) + c(prev state) + =. c (add-range c) + %= c + start + ?: &(!=(case.state %missing) !=(case.state %none)) + `state + ~ + prev state + == + :: + ++ line-to-case-state + :> creates an easy to merge form. + |= line:unicode-data + ^- case-state + =/ out/case-state + [code %none [%none ~] [%none ~] [%none ~]] + ?: =(code `@c`0) + =. case.out %missing + out + =. case.out + ?+ gen %none + $lu %upper + $ll %lower + $lt %title + == + :: + :: several characters aren't described as $lu or $ll but have lower or + :: upper state, such as u+2161. detect this and fix it up. + :: + =? case.out &(=(case.out %none) !=(low ~)) %upper + =? case.out &(=(case.out %none) !=(up ~)) %lower + :: + :: calculate offsets + :: + =? upper.out !=(up ~) (calculate-offset (need up) code) + =? lower.out !=(low ~) + (calculate-offset (need low) code) + =? title.out !=(title ~) (calculate-offset (need title) code) + out + :: + ++ calculate-offset + |= {src/@c dst/@c} + ^- case-offset:unicode-data + ?: =(src dst) + [%none ~] + ?: (gth src dst) + [%add (sub src dst)] + [%sub (sub dst src)] + :: + ++ is-adjacent + :> is {rhs} a continuation of {lhs}? + |= {lhs/case-state rhs/case-state} + ^- ? + ?: (lth point.rhs point.lhs) + $(lhs rhs, rhs lhs) + ?: !=(point.rhs +(point.lhs)) + %.n + ?: !=(case.rhs case.lhs) + (upper-lower-adjacent lhs rhs) + ?: =(case.lhs %none) + %.n + ?: =(case.lhs %missing) + %.n + ?: !=(upper.lhs upper.rhs) + %.n + ?: !=(lower.lhs lower.rhs) + %.n + ?: !=(title.lhs title.rhs) + %.n + %.y + :: + ++ upper-lower-adjacent + :> detects %upper-lower spans. + :> + :> is {lhs} the same as {rhs}, but with opposite case? + |= {lhs/case-state rhs/case-state} + ?: &(=(case.lhs %upper) !=(case.rhs %lower)) + %.n + ?: &(=(case.lhs %lower) !=(case.rhs %upper)) + %.n + :: + :: to simplify detection, if things are in the opposite order, redo + :: things flipped. + :: + ?: =(case.lhs %lower) + $(lhs rhs, rhs lhs) + ?& (is-upper-lower lhs) + (is-lower-upper rhs) + == + :: + ++ is-upper-lower + |= i/case-state + =(+.+.i [[%none ~] [%add 1] [%none ~]]) + :: + ++ is-lower-upper + |= i/case-state + =(+.+.i [[%sub 1] [%none ~] [%sub 1]]) + :: + ++ is-none + |= i/case-state + =(+.+.i [[%none ~] [%none ~] [%none ~]]) + :: + ++ add-range + |= c/case-fold + ^+ c + ?~ start.c + c + ?: (is-none u.start.c) + c + ?: ?& (gth point.prev.c point.u.start.c) + (is-upper-lower u.start.c) + == + =/ node/case-node:unicode-data + [`@ux`point.u.start.c `@ux`point.prev.c [%uplo ~] [%uplo ~] [%uplo ~]] + c(out [node out.c]) + =/ node/case-node:unicode-data + [`@ux`point.u.start.c `@ux`point.prev.c +.+.u.start.c] + c(out [node out.c]) + :: + ++ case-fold + :> state that's part of the fold which generates the list of case-nodes + $: :> resulting data to pass to treeify. + out/(list case-node:unicode-data) + :> the start of a run of characters; ~ for not active. + start/(unit case-state) + :> previous character state + prev/case-state + == + :: + ++ case-state + :> a temporary model which we compress later in a second pass. + $: point/@c + case/case-class + upper/case-offset:unicode-data + lower/case-offset:unicode-data + title/case-offset:unicode-data + == + :: + ++ case-class + :> classification of an individual character. + $? $upper + $lower + $title + $none + $missing + == + :: + :> # + :> # %tree-building + :> # + :> builds a binary search tree out of the list + +| + ++ build-tree + |= a/(list case-node:unicode-data) + ^- case-tree:unicode-data + :: there's probably a bottom up approach that doesn't require walking + :: a list over and over again. + ?~ a + ~ + =+ len=(lent a) + =+ [lhs rhs]=(split-at:ls (div len 2) a) + ?~ rhs + ?~ lhs + ~ + [i.lhs ~ ~] + =+ x=[i.rhs $(a lhs) $(a t.rhs)] + x + -- /: /===/lib/unicode-data /&unicode-data&/txt/ :: :: part 2: utility core @@ -28,6 +210,7 @@ (turn (tuba a) fun) :: ++ to-upper + :> returns the uppercase of unicode codepoint {a} |= a/@c ^- @c :: special case ascii to not perform map lookup. @@ -35,8 +218,56 @@ ?: &((gte a 'a') (lte a 'z')) (sub a 32) a - =+ x=(~(get by uppers) a) - (fall x a) + (apply-table a case-table %upper) +:: +++ to-lower + :> returns the lowercase of unicode codepoint {a} + |= a/@c + ^- @c + ?: (lte a max-ascii) + ?: &((get a 'A') (lte a 'Z')) + (add 32 a) + a + (apply-table a case-table %lower) +:: +++ apply-table + :> searches {table} and apples applies {type} to {a}. + :> + :> this recursively walks the case tree {table}. if it finds an entry which + :> matches on {a}, it will apply the offset. otherwise, returns {a}. + |= {a/@c table/case-tree:unicode-data type/?($upper $lower $title)} + ^- @c + ?~ table + a + ?: (lth a start.n.table) + $(table l.table) + ?: (gth a end.n.table) + $(table r.table) + ?. &((lte start.n.table a) (lte a end.n.table)) + a + %^ apply-offset a type + ?- type + $upper upper.n.table + $lower lower.n.table + $title title.n.table + == +:: +++ apply-offset + :> applies an character offset to {a}. + |= {a/@c type/?($upper $lower $title) offset/case-offset:unicode-data} + ^- @c + ?- offset + {$add *} (add a a.offset) + {$sub *} (sub a s.offset) + {$none *} a + :: + {$uplo *} + ?- type + $upper (sub a 1) + $lower (add a 1) + $title (sub a 1) + == + == :: ++ max-ascii `@c`0x7f -- @@ -48,5 +279,4 @@ {n/tape $~} $~ == -:- %noun -(transform n to-upper) +:- %tape (transform n to-upper) diff --git a/mar/unicode-data.hoon b/mar/unicode-data.hoon index 3367f2e0b..e3b8e3ba3 100644 --- a/mar/unicode-data.hoon +++ b/mar/unicode-data.hoon @@ -1,24 +1,8 @@ /- unicode-data =, eyre =, format - -:: ok, so we can currently slurp the data in. we're having problems getting it -:: back out. ++txt:grow is probably the next logical step here. - -|_ all/(list line:unicode-data) -++ grow - :> converts from unicode-data to mark. - |% - :: ++ txt - :: ^- wain - :: %+ turn all - :: |= line:unicode-data - :: ;: weld - :: ";" - :: name - :: ";" - -- :: +|_ all/(list line:unicode-data) ++ grab :> converts from mark to unicode-data. |% @@ -56,7 +40,6 @@ %+ cook |=(a/tape a) (star ;~(less sem prn)) -:: (star ;~(pose hig low nud hep ace gal gar pel per)) :: :> parses a unicode general category abbreviation to symbol ++ general-category diff --git a/sur/unicode-data.hoon b/sur/unicode-data.hoon index 88e2e51dc..ac3ea2cd5 100644 --- a/sur/unicode-data.hoon +++ b/sur/unicode-data.hoon @@ -1,4 +1,7 @@ |% +:> # %unicode-data +:> types to represent UnicdoeData.txt. ++| ++ line :> an individual codepoint definition :> @@ -127,4 +130,36 @@ $fraction :< a vulgar fraction form $compat :< otherwise unspecified compatibility character == +:: +:> # +:> # %case-map +:> # +:> types to represent fast lookups of case data ++| +++ case-offset + :> case offsets can be in either direction + $% :> add {a} to get the new character + {$add a/@u} + :> subtract {a} to get the new character + {$sub s/@u} + :> take no action; return self + {$none $~} + :> represents series of alternating uppercase/lowercase characters + {$uplo $~} + == +:: +++ case-node + :> a node in a case-tree. + :> + :> represents a range of + $: start/@ux + end/@ux + upper/case-offset + lower/case-offset + title/case-offset + == +:: +++ case-tree + :> a binary search tree of ++case-node items, sorted on span. + (tree case-node) -- From 40050a490e51388979f945f13ec70ae0bc57d3e0 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 13 Oct 2017 09:47:38 -0700 Subject: [PATCH 017/184] WIP simplify parsing constants to ++soft, comment placement --- mar/unicode-data.hoon | 147 ++++++++++-------------------------------- sur/unicode-data.hoon | 49 +++++--------- 2 files changed, 50 insertions(+), 146 deletions(-) diff --git a/mar/unicode-data.hoon b/mar/unicode-data.hoon index e3b8e3ba3..a1f6b35e3 100644 --- a/mar/unicode-data.hoon +++ b/mar/unicode-data.hoon @@ -15,24 +15,28 @@ ^- line:unicode-data (rash b line) :: - :> parses a single line of the unicode data file. + :> parses a single character information line of the unicode data file. ++ line ;~ (glue sem) - hex - name-string - general-category - (bass 10 (plus sid:ab)) - bidi-category - decomposition-mapping - string-number - string-number - string-number - yes-or-no - name-string - name-string - optional-hex - optional-hex - optional-hex + hex :: code/@c codepoint in hex format + name-string :: name/tape character name + general-category :: gen/general type of character + (bass 10 (plus dit)) :: can/@ud canonical combining class + bidi-category :: bi/bidi bidirectional category + decomposition-mapping :: de/decomp decomposition mapping + :: + :: todo: decimal/digit/numeric need to be parsed. + :: + string-number :: decimal/tape decimal digit value (or ~) + string-number :: digit/tape digit value, even if non-decimal + string-number :: numeric/tape numeric value, including fractions + :: + (flag 'Y' 'N') :: mirrored/? is char mirrored in bidi text? + name-string :: old-name/tape unicode 1.0 compatibility name + name-string :: iso/tape iso 10646 comment field + (punt hex) :: up/(unit @c) uppercase mapping codepoint + (punt hex) :: low/(unit @c) lowercase mapping codepoint + (punt hex) :: title/(unit @c) titlecase mapping codepoint == :: :> parses a single name or comment string. @@ -40,122 +44,37 @@ %+ cook |=(a/tape a) (star ;~(less sem prn)) + :: (star ;~(pose alp (mask " <>()"))) :: :> parses a unicode general category abbreviation to symbol ++ general-category - ;~ pose - (cold %lu (jest 'Lu')) - (cold %ll (jest 'Ll')) - (cold %lt (jest 'Lt')) - (cold %mn (jest 'Mn')) - (cold %mc (jest 'Mc')) - (cold %me (jest 'Me')) - (cold %nd (jest 'Nd')) - (cold %nl (jest 'Nl')) - (cold %no (jest 'No')) - (cold %zs (jest 'Zs')) - (cold %zl (jest 'Zl')) - (cold %zp (jest 'Zp')) - (cold %cc (jest 'Cc')) - (cold %cf (jest 'Cf')) - (cold %cs (jest 'Cs')) - (cold %co (jest 'Co')) - (cold %cn (jest 'Cn')) - (cold %lm (jest 'Lm')) - (cold %lo (jest 'Lo')) - (cold %pc (jest 'Pc')) - (cold %pd (jest 'Pd')) - (cold %ps (jest 'Ps')) - (cold %pe (jest 'Pe')) - (cold %pi (jest 'Pi')) - (cold %pf (jest 'Pf')) - (cold %po (jest 'Po')) - (cold %sm (jest 'Sm')) - (cold %sc (jest 'Sc')) - (cold %sk (jest 'Sk')) - (cold %so (jest 'So')) - == + %+ sear (soft general:unicode-data) + :(cook crip cass ;~(plug hig low (easy ~))) :: :> parses a bidirectional category abbreviation to symbol. ++ bidi-category - ;~ pose - (cold %fsi (jest 'FSI')) - (cold %lre (jest 'LRE')) - (cold %lri (jest 'LRI')) - (cold %lro (jest 'LRO')) - (cold %nsm (jest 'NSM')) - (cold %pdf (jest 'PDF')) - (cold %pdi (jest 'PDI')) - (cold %rle (jest 'RLE')) - (cold %rli (jest 'RLI')) - (cold %rlo (jest 'RLO')) - (cold %al (jest 'AL')) - (cold %an (jest 'AN')) - (cold %bn (jest 'BN')) - (cold %cs (jest 'CS')) - (cold %en (jest 'EN')) - (cold %es (jest 'ES')) - (cold %et (jest 'ET')) - (cold %on (jest 'ON')) - (cold %ws (jest 'WS')) - (cold %b (jest 'B')) - (cold %l (jest 'L')) - (cold %r (jest 'R')) - (cold %s (jest 'S')) - == + %+ sear (soft bidi:unicode-data) + :(cook crip cass (star hig)) :: :: TODO: This seems to be where the nest-fail is. There's an extra @ here? ++ decomposition-mapping - ;~ pose - :: a tag and a list of characters to decompose to - %+ stag ~ - ;~ plug - ;~ pose - (stag ~ (ifix [gal ;~(plug gar ace)] decomp-tag)) - (easy ~) - == - (cook |=(a/(list @c) a) (most ace hex)) - == - :: no decomposition information - (easy ~) + %- punt :: optional + :: a tag and a list of characters to decompose to + ;~ plug + (punt (ifix [gal ;~(plug gar ace)] decomp-tag)) + (cook |=(a/(list @c) a) (most ace hex)) == :: ++ decomp-tag - ;~ pose - (cold %font (jest 'font')) - (cold %no-break (jest 'noBreak')) - (cold %initial (jest 'initial')) - (cold %medial (jest 'medial')) - (cold %final (jest 'final')) - (cold %isolated (jest 'isolated')) - (cold %circle (jest 'circle')) - (cold %super (jest 'super')) - (cold %sub (jest 'sub')) - (cold %vertical (jest 'vertical')) - (cold %wide (jest 'wide')) - (cold %narrow (jest 'narrow')) - (cold %small (jest 'small')) - (cold %square (jest 'square')) - (cold %fraction (jest 'fraction')) - (cold %compat (jest 'compat')) - == + %+ sear (soft decomp-tag:unicode-data) + %+ cook |=(a/term ?+(a a $nobreak %no-break)) ::REVIEW or just change the type + :(cook crip cass (star alf)) :: ++ string-number %+ cook |=(a/tape a) (star ;~(pose nud fas hep)) :: - ++ yes-or-no - ;~ pose - (cold %.y (jest 'Y')) - (cold %.n (jest 'N')) - == - :: - ++ optional-hex - ;~ pose - (stag ~ hex) - (easy ~) - == -- -- ++ grad %txt diff --git a/sur/unicode-data.hoon b/sur/unicode-data.hoon index ac3ea2cd5..6b4345c47 100644 --- a/sur/unicode-data.hoon +++ b/sur/unicode-data.hoon @@ -5,38 +5,23 @@ ++ line :> an individual codepoint definition :> - :> code: the codepoint in hexadecimal format - :> name: the character name - :> gen: the type of character this is - :> can: the canonical combining class for ordering algorithms - :> bidi: the bidirectional category of this character - :> de: the character decomposition mapping - :> decimal: the decimal digit value (or ~) - :> digit: the digit value, covering non decimal radix forms - :> numeric: the numeric value, including fractions - :> mirrored: whether char is mirrored in bidirectional text - :> old-name: unicode 1.0 compatibility name - :> iso: iso 10646 comment field - :> up: uppercase mapping codepoint - :> low: lowercase mapping codepoint - :> title: titlecase mapping codepoint - :> - $: code/@c - name/tape - gen/general - can/@ud - bi/bidi - de/decomp - :: todo: decimal/digit/numeric need to be parsed. - decimal/tape - digit/tape - numeric/tape - mirrored/? - old-name/tape - iso/tape - up/(unit @c) - low/(unit @c) - title/(unit @c) + $: code/@c :< codepoint in hexadecimal format + name/tape :< character name + gen/general :< type of character this is + :> canonical combining class for ordering algorithms + can/@ud + bi/bidi :< bidirectional category of this character + de/decomp :< character decomposition mapping + :: todo: decimal/digit/numeric need to be parsed. + decimal/tape :< decimal digit value (or ~) + digit/tape :< digit value, covering non decimal radix forms + numeric/tape :< numeric value, including fractions + mirrored/? :< whether char is mirrored in bidirectional text + old-name/tape :< unicode 1.0 compatibility name + iso/tape :< iso 10646 comment field + up/(unit @c) :< uppercase mapping codepoint + low/(unit @c) :< lowercase mapping codepoint + title/(unit @c) :< titlecase mapping codepoint == :: ++ general From 5e2f544a13eba09915336c90fa5234457b76c973 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 13 Oct 2017 23:09:01 -0700 Subject: [PATCH 018/184] Change the name of ++map to ++dict so 'map' can be used for 'transform'. --- gen/test.hoon | 26 +++---- lib/new-hoon.hoon | 177 ++++++++++++++++++++++++---------------------- 2 files changed, 107 insertions(+), 96 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 476393f2d..95be5afe8 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -96,21 +96,21 @@ =^ num gen (range:gen min max) num :: - ++ generate-map - :> generator which will produce a map with {count} random pairs. + ++ generate-dict + :> generator which will produce a dict with {count} random pairs. |= count/@u - :> generate a map with entropy {c}. + :> generate a dict with entropy {c}. |= c/@uvJ =/ gen (random:new-hoon c) =| i/@u - =| m/(map @ud @ud) + =| m/(dict:new-hoon @ud @ud) |- - ^- (map @ud @ud) + ^- (dict:new-hoon @ud @ud) ?: =(i count) m =^ first gen (range:gen 0 100) =^ second gen (range:gen 0 100) - $(m (insert:mp:new-hoon m first second), i +(i)) + $(m (insert:dct:new-hoon m first second), i +(i)) :: :: || %test :: @@ -495,7 +495,7 @@ "intersect" -- ++ test-mp - =, mp:new-hoon + =, dct:new-hoon =+ four=(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] ~]) =+ three=(from-list [[1 "one"] [2 "two"] [3 "three"] ~]) |_ tester-type:test-lib @@ -602,11 +602,11 @@ "alter (as change)" :: ++ check-alter - :: check random maps of 50 items with 40 random operations done on them + :: check random dicts of 50 items with 40 random operations done on them :: for validity. %+ check - (generate-map 50) - |= a/(map @ud @ud) + (generate-dict 50) + |= a/(dict @ud @ud) :: this is dumb, but use {a} as entropy? =/ gen (random:new-hoon (jam a)) =| i/@u @@ -838,14 +838,14 @@ (from-list [[1 1] [3 1] [5 1] ~]) "transform-either" :: - ++ test-is-submap + ++ test-is-subdict %^ expect-eq - %^ is-submap-by + %^ is-subdict-by (from-list [[1 1] [4 4] ~]) (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) |=({a/* b/*} =(a b)) %.y - "is-submap" + "is-subdict" :: ++ test-valid %^ expect-eq diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index e12957e43..72129e5a4 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -789,34 +789,45 @@ :: default. ++sort as is is probably the correct thing to do. :: -- -++ mp +:: +++ dict + :> a dictionary mapping keys of {a} to values of {b}. + :> + :> a dictionary is treap ordered; it builds a treap out of the hashed key + :> values. + |* {a/mold b/mold} + %+ cork (tree (pair a b)) + |= c/(tree (pair a b)) ^+ c + ?.((valid:dct c) ~ c) +:: +++ dct |% :> # %query - :> looks up values in the map. + :> looks up values in the dict. +| ++ empty - :> is the map empty? - |* a/(map) + :> is the dict empty? + |* a/(dict) ?~ a %.y %.n :: ++ size :> returns the number of elements in {a}. - |= a/(map) + |= a/(dict) ^- @u ?~ a 0 :(add 1 $(a l.a) $(a r.a)) :: ++ member :> returns %.y if {b} is a key in {a}. - |= {a/(map) key/*} + |= {a/(dict) key/*} ^- ? ?~ a %.n ?|(=(key p.n.a) $(a l.a) $(a r.a)) :: ++ get :> grab value by key. - |* {a/(map) key/*} + |* {a/(dict) key/*} ^- (maybe _?>(?=(^ a) q.n.a)) :: ^- {$@($~ {$~ u/_?>(?=(^ a) q.n.a)})} ?~ a @@ -832,7 +843,7 @@ :: ++ got :: :> todo: move impl here. :: :> todo: is there a way to make b/_<><>.a ? -:: |* {a/(map) key/*} +:: |* {a/(dict) key/*} :: (~(got by a) key) :: :: todo: skipping several methods which rely on the the Ord typeclass, like @@ -842,7 +853,7 @@ +| ++ insert :> inserts a new key/value pair, replacing the current value if it exists. - |* {a/(map) key/* value/*} + |* {a/(dict) key/* value/*} |- ^+ a ?~ a [[key value] ~ ~] @@ -864,7 +875,7 @@ :: ++ insert-with :> inserts {key}/{value}, applying {fun} if {key} already exists. - |* {a/(map) key/* value/* fun/$-({* *} *)} + |* {a/(dict) key/* value/* fun/$-({* *} *)} |- ^+ a ?~ a [[key value] ~ ~] @@ -885,7 +896,7 @@ :: ++ insert-with-key :> inserts {key}/{value}, applying {fun} if {key} already exists. - |* {a/(map) key/* value/* fun/$-({* * *} *)} + |* {a/(dict) key/* value/* fun/$-({* * *} *)} |- ^+ a ?~ a [[key value] ~ ~] @@ -906,7 +917,7 @@ :: ++ insert-lookup-with-key :> combines insertion with lookup in one pass. - |* {a/(map) key/* value/* fun/$-({* * *} *)} + |* {a/(dict) key/* value/* fun/$-({* * *} *)} |- ^- {(maybe _value) _a} ?~ a [~ [[key value] ~ ~]] @@ -932,7 +943,7 @@ :: ++ delete :> deletes entry at {key}. - |* {a/(map) key/*} + |* {a/(dict) key/*} |- ^+ a ?~ a ~ @@ -944,7 +955,7 @@ :: ++ adjust :> updates a value at {key} by passing the value to {fun}. - |* {a/(map) key/* fun/$-(* *)} + |* {a/(dict) key/* fun/$-(* *)} %^ alter-with-key a key |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} ^- (maybe _q.+.n.-.a) @@ -953,7 +964,7 @@ :: ++ adjust-with-key :> updates a value at {key} by passing the key/value pair to {fun}. - |* {a/(map) key/* fun/$-({* *} *)} + |* {a/(dict) key/* fun/$-({* *} *)} %^ alter-with-key a key |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} ^- (maybe _q.+.n.-.a) @@ -962,7 +973,7 @@ :: ++ update :> adjusts or deletes the value at {key} by {fun}. - |* {a/(map) key/* fun/$-(* (maybe *))} + |* {a/(dict) key/* fun/$-(* (maybe *))} %^ alter-with-key a key |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} ^- (maybe _q.+.n.-.a) @@ -971,7 +982,7 @@ :: ++ update-with-key :> adjusts or deletes the value at {key} by {fun}. - |* {a/(map) key/* fun/$-({* *} (maybe *))} + |* {a/(dict) key/* fun/$-({* *} (maybe *))} %^ alter-with-key a key |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} ^- (maybe _q.+.n.-.a) @@ -983,14 +994,14 @@ :: ++ alter :> inserts, deletes, or updates a value by {fun}. - |* {a/(map) key/* fun/$-((maybe *) (maybe *))} + |* {a/(dict) key/* fun/$-((maybe *) (maybe *))} %^ alter-with-key a key |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} (fun value) :: ++ alter-with-key :> inserts, deletes, or updates a value by {fun}. - |* {a/(map) key/* fun/$-({* (maybe *)} (maybe *))} + |* {a/(dict) key/* fun/$-({* (maybe *)} (maybe *))} |- ^+ a ?~ a =+ ret=(fun key ~) @@ -1023,7 +1034,7 @@ :: ++ union :> returns the union of {a} and {b}, preferring the value from {a} if dupe - |* {a/(map) b/(map)} + |* {a/(dict) b/(dict)} |- ^+ a ?~ b a @@ -1043,7 +1054,7 @@ :: ++ union-with :> returns the union of {a} and {b}, running {fun} to resolve duplicates. - |* {a/(map) b/(map) fun/$-({* *} *)} + |* {a/(dict) b/(dict) fun/$-({* *} *)} |- ^+ a ?~ b a @@ -1063,7 +1074,7 @@ :: ++ union-with-key :> returns the union of {a} and {b}, running {fun} to resolve duplicates. - |* {a/(map) b/(map) fun/$-({* * *} *)} + |* {a/(dict) b/(dict) fun/$-({* * *} *)} |- ^+ a ?~ b a @@ -1086,7 +1097,7 @@ :: ++ difference :: :: todo: move real implementation here. :: :> returns elements in {a} that don't exist in {b}. -:: |* {a/(map) b/(map)} +:: |* {a/(dict) b/(dict)} :: (~(dif by a) b) :: :: :: :: todo: @@ -1096,7 +1107,7 @@ :: ++ intersection :: :: todo: move real implementation here. :: :> returns elements in {a} that exist in {b}. -:: |* {a/(map) b/(map)} +:: |* {a/(dict) b/(dict)} :: (~(int by a) b) :: :: :: :: todo: @@ -1108,16 +1119,16 @@ :: ++ transform :> applies {fun} to each value in {a}. - |* {a/(map) fun/$-(* *)} - ^- (map _p.-.n.-.a fun) + |* {a/(dict) fun/$-(* *)} + ^- (dict _p.-.n.-.a fun) ?~ a ~ [[p.n.a (fun q.n.a)] $(a l.a) $(a r.a)] :: ++ transform-with-key :> applies {fun} to each value in {a}. - |* {a/(map) fun/$-({* *} *)} - ^- (map _p.-.n.-.a _*fun) + |* {a/(dict) fun/$-({* *} *)} + ^- (dict _p.-.n.-.a _*fun) ?~ a ~ [[p.n.a (fun p.n.a q.n.a)] $(a l.a) $(a r.a)] @@ -1125,14 +1136,14 @@ ++ transform-fold :> performs a fold on all the values in {a}. :> - :> lists have an order, but maps are treaps. this means there isn't a + :> lists have an order, but dicts are treaps. this means there isn't a :> horizontal ordering, and thus the distinction between left and right :> folding isn't relevant. your accumulator function will be called in :> treap order. :> :> corresponds to {mapAccum} in haskell. - |* {a/(map) b/* fun/$-({* *} {* *})} - ^- {_b (map _p.-.n.-.a _+:*fun)} + |* {a/(dict) b/* fun/$-({* *} {* *})} + ^- {_b (dict _p.-.n.-.a _+:*fun)} ?~ a [b ~] =+ d=(fun b q.n.a) @@ -1146,7 +1157,7 @@ :: todo: the haskell version specifies that the "greatest" original key :: wins in case of duplicates. this is currently unhandled. maybe i just :: shouldn't have this gate. - |* {a/(map) fun/$-(* *)} + |* {a/(dict) fun/$-(* *)} %- from-list %+ transform:ls (to-list a) |= item/_n.-.a @@ -1154,25 +1165,25 @@ :: ++ transform-keys-with :> applies {fun} to all keys, creating a new value with {combine} on dupes. - |* {a/(map) fun/$-(* *) combine/$-({* *} *)} - ^- (map _*fun _q.+.n.-.a) + |* {a/(dict) fun/$-(* *) combine/$-({* *} *)} + ^- (dict _*fun _q.+.n.-.a) =/ new-list %+ transform:ls (to-list a) |= item/_n.-.a [(fun p.item) q.item] %^ foldl:ls new-list - `(map _*fun _q.+.n.-.a)`~ - |= {m/(map _*fun _q.+.n.-.a) p/_i.-.new-list} + `(dict _*fun _q.+.n.-.a)`~ + |= {m/(dict _*fun _q.+.n.-.a) p/_i.-.new-list} (insert-with m -.p +.p combine) :: ++ fold :> performs a fold on all the values in {a}. :> - :> lists have an order, but maps are treaps. this means there isn't a + :> lists have an order, but dicts are treaps. this means there isn't a :> horizontal ordering, and thus the distinction between left and right :> folding isn't relevant. your accumulator function will be called in :> treap order. - |* {a/(map) b/* fun/$-({* *} *)} + |* {a/(dict) b/* fun/$-({* *} *)} ^- _b ?~ a b @@ -1182,7 +1193,7 @@ :: ++ fold-with-keys :> performs a fold on all the values in {a}, passing keys too. - |* {a/(map) b/* fun/$-({* * *} *)} + |* {a/(dict) b/* fun/$-({* * *} *)} ^+ b ?~ a b @@ -1192,7 +1203,7 @@ :: ++ any :> returns yes if any element satisfies the predicate - |* {a/(map) b/$-(* ?)} + |* {a/(dict) b/$-(* ?)} ^- ? ?~ a %.n @@ -1200,7 +1211,7 @@ :: ++ any-with-key :> returns yes if any element satisfies the predicate - |* {a/(map) b/$-({* *} ?)} + |* {a/(dict) b/$-({* *} ?)} ^- ? ?~ a %.n @@ -1208,7 +1219,7 @@ :: ++ all :> returns yes if all elements satisfy the predicate - |* {a/(map) b/$-(* ?)} + |* {a/(dict) b/$-(* ?)} ^- ? ?~ a %.y @@ -1216,7 +1227,7 @@ :: ++ all-with-key :> returns yes if all elements satisfy the predicate - |* {a/(map) b/$-({* *} ?)} + |* {a/(dict) b/$-({* *} ?)} ^- ? ?~ a %.y @@ -1225,13 +1236,13 @@ :> # %conversion +| ++ elems - :> return all values in the map. - |* a/(map) + :> return all values in the dict. + |* a/(dict) %+ turn (to-list a) second :: ++ keys - :> returns all keys in the map. - |* a/(map) + :> returns all keys in the dict. + |* a/(dict) %+ turn (to-list a) first :: :: todo: ++assocs probably doesn't make sense when we have ++to-list and @@ -1239,13 +1250,13 @@ :: ++ keys-set :> returns all keys as a set. - |* a/(map) + |* a/(dict) (si:nl (keys a)) :: ++ from-set - :> computes a map by running {fun} on every value in a set. + :> computes a dict by running {fun} on every value in a set. |* {a/(set) fun/$-(* *)} - ^- (map _n.-.a _*fun) + ^- (dict _n.-.a _*fun) ?~ a ~ [[n.a (fun n.a)] $(a l.a) $(a r.a)] @@ -1255,7 +1266,7 @@ :: ++ to-list :> creates a list of pairs from the tree. - |* a/(map) + |* a/(dict) =| b/(list _n.-.a) |- ^+ b @@ -1268,16 +1279,16 @@ |* a/(list (pair)) |- %^ foldl:ls a - `(map _p.-.i.-.a _q.+.i.-.a)`~ - |= {m/(map _p.-.i.-.a _q.+.i.-.a) p/_i.-.a} + `(dict _p.-.i.-.a _q.+.i.-.a)`~ + |= {m/(dict _p.-.i.-.a _q.+.i.-.a) p/_i.-.a} (insert m p) :: ++ from-list-with - :> creates a map from a list, with {fun} resolving duplicates. + :> creates a dict from a list, with {fun} resolving duplicates. |* {a/(list (pair)) fun/$-(* *)} %^ foldl:ls a - `(map _*fun _q.+.i.-.a)`~ - |= {m/(map _*fun _q.+.i.-.a) p/_i.-.a} + `(dict _*fun _q.+.i.-.a)`~ + |= {m/(dict _*fun _q.+.i.-.a) p/_i.-.a} (insert-with m -.p +.p fun) :: :: todo: without a natural ordering, association lists and gates to operate @@ -1286,15 +1297,15 @@ :> # %filters +| ++ filter - :> filters a map of all values that satisfy {fun}. - |* {a/(map) fun/$-(* ?)} + :> filters a dict of all values that satisfy {fun}. + |* {a/(dict) fun/$-(* ?)} %+ filter-with-key a |= {key/* value/_q.+.n.-.a} (fun value) :: ++ filter-with-key - :> filters a map of all values that satisfy {fun}. - |* {a/(map) fun/$-({* *} ?)} + :> filters a dict of all values that satisfy {fun}. + |* {a/(dict) fun/$-({* *} ?)} |- ^+ a ?~ a ~ @@ -1305,8 +1316,8 @@ [n.a $(a l.a) $(a r.a)] :: ++ restrict-keys - :> returns a map where the only allowable keys are {keys}. - |* {a/(map) keys/(set)} + :> returns a dict where the only allowable keys are {keys}. + |* {a/(dict) keys/(set)} %+ filter-with-key a |= {key/_p.-.n.-.a value/*} :: todo: replace this with a call to our set library when we advance that @@ -1314,8 +1325,8 @@ !(~(has in keys) key) :: ++ without-keys - :> returns a map where the only allowable keys are not in {keys}. - |* {a/(map) keys/(set)} + :> returns a dict where the only allowable keys are not in {keys}. + |* {a/(dict) keys/(set)} %+ filter-with-key a |= {key/_p.-.n.-.a value/*} :: todo: replace this with a call to our set library when we advance that @@ -1324,7 +1335,7 @@ :: ++ partition :> returns two lists, one whose elements match {fun}, the other doesn't. - |* {a/(map) fun/$-(* ?)} + |* {a/(dict) fun/$-(* ?)} :: todo: is the runtime on this is bogus? =/ data %+ partition:ls (to-list a) @@ -1335,19 +1346,19 @@ :: todo: ++partition-with-key once ++partition works. :: :: i'm going to ignore all the Antitone functions; they don't seem to be - :: useful without ordering on the map. + :: useful without ordering on the dict. :: ++ transform-maybe :> a version of transform that can throw out items. - |* {a/(map) fun/$-(* (maybe))} + |* {a/(dict) fun/$-(* (maybe))} %+ transform-maybe-with-key a |= {key/* value/_q.+.n.-.a} (fun value) :: ++ transform-maybe-with-key :> a version of transform that can throw out items. - |* {a/(map) fun/$-({* *} (maybe))} - ^- (map _p.-.n.-.a _+:*fun) + |* {a/(dict) fun/$-({* *} (maybe))} + ^- (dict _p.-.n.-.a _+:*fun) ?~ a ~ =+ res=(fun n.a) ?~ res @@ -1357,18 +1368,18 @@ [[p.n.a +.res] $(a l.a) $(a r.a)] :: ++ transform-either - :> splits the map in two on a gate that returns an either. - |* {a/(map) fun/$-(* (either))} + :> splits the dict in two on a gate that returns an either. + |* {a/(dict) fun/$-(* (either))} %+ transform-either-with-key a |= {key/* value/_q.+.n.-.a} (fun value) :: ++ transform-either-with-key - :> splits the map in two on a gate that returns an either. - |* {a/(map) fun/$-({* *} (either))} + :> splits the dict in two on a gate that returns an either. + |* {a/(dict) fun/$-({* *} (either))} |- - ^- $: (map _p.-.n.-.a _?>(?=({{%& *} *} *fun) +:*fun)) - (map _p.-.n.-.a _?>(?=({{%| *} *} *fun) +:*fun)) + ^- $: (dict _p.-.n.-.a _?>(?=({{%& *} *} *fun) +:*fun)) + (dict _p.-.n.-.a _?>(?=({{%| *} *} *fun) +:*fun)) == ?~ a [~ ~] @@ -1385,15 +1396,15 @@ :: ++split, ++split-lookup and ++split-root do not make sense without :: ordinal keys. :: - ++ is-submap + ++ is-subdict :> returns %.y if every element in {a} exists in {b} with the same value. - |* {a/(map) b/(map)} + |* {a/(dict) b/(dict)} ^- ? - (is-submap-by a b |=({a/* b/*} =(a b))) + (is-subdict-by a b |=({a/* b/*} =(a b))) :: - ++ is-submap-by + ++ is-subdict-by :> returns %.y if every element in {a} exists in {b} with the same value. - |* {a/(map) b/(map) fun/$-({* *} ?)} + |* {a/(dict) b/(dict) fun/$-({* *} ?)} |- ^- ? ?~ a %.y @@ -1409,7 +1420,7 @@ +| ++ pop-top :> removes the head of the tree and rebalances the tree below. - |* a/(map) + |* a/(dict) ^- {$?($~ _a)} ?~ a ~ |- @@ -1420,8 +1431,8 @@ [n.r.a $(r.a l.r.a) r.r.a] :: ++ valid - :> returns %.y if {a} is a valid treap map. - |* a/(map) + :> returns %.y if {a} if this tree is a valid treap dict. + |* a/(tree (pair * *)) =| {l/(unit) r/(unit)} |- ^- ? ?~ a & From 22dca3032f5b1c743bd4b7514665cccc5c6d27d8 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 13 Oct 2017 23:13:15 -0700 Subject: [PATCH 019/184] Remove 'transform' and use 'map'. --- gen/test.hoon | 80 +++++++++++++++++++++++------------------------ lib/new-hoon.hoon | 46 +++++++++++++-------------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 95be5afe8..c7ed8baa9 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -225,13 +225,13 @@ :: doesn't compile anymore? (expect-eq (concat `(list (maybe @ud))`[~ [~ 1] ~ [~ 2] ~]) [1 2 ~] "concat") :: - ++ test-transform + ++ test-map %^ expect-eq - %+ transform + %+ map:myb [1 2 3 2 ~] |=(a/@u ?:(=(2 a) [~ 2] ~)) [2 2 ~] - "transform" + "map" -- ++ test-ls =, ls:new-hoon @@ -251,8 +251,8 @@ ++ test-size (expect-eq (size ['a' 'b' 'c' ~]) 3 "size") :: - ++ test-transform - (expect-eq (transform [1 2 ~] |=(a/@ (add 1 a))) [2 3 ~] "transform") + ++ test-map + (expect-eq (map:ls [1 2 ~] |=(a/@ (add 1 a))) [2 3 ~] "map") :: ++ test-reverse (expect-eq (reverse [1 2 3 ~]) [3 2 1 ~] "reverse") @@ -320,17 +320,17 @@ ~[6 5 3] "scanr1" :: - ++ test-transform-foldl + ++ test-map-foldl %^ expect-eq - (transform-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) + (map-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) [7 ~[2 3 5]] - "transform-foldl" + "map-foldl" :: - ++ test-transform-foldr + ++ test-map-foldr %^ expect-eq - (transform-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) + (map-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) [7 ~[7 5 2]] - "transform-foldr" + "map-foldr" :: ++ test-unfoldr %^ expect-eq @@ -654,50 +654,50 @@ (from-list [[1 "left"] [2 "2leftright"] [3 "right"] ~]) "union-with-key" :: - ++ test-transform + ++ test-map %^ expect-eq - %+ transform + %+ map:dct three crip (from-list [[1 'one'] [2 'two'] [3 'three'] ~]) - "transform" + "map" :: - ++ test-transform-with-key + ++ test-map-with-key %^ expect-eq - %+ transform-with-key + %+ map-with-key three |=({a/@u b/tape} (weld (scow %ud a) b)) (from-list [[1 "1one"] [2 "2two"] [3 "3three"] ~]) - "transform-with-key" + "map-with-key" :: - ++ test-transform-fold + ++ test-map-fold %^ expect-eq - %^ transform-fold + %^ map-fold three "Everything: " |= {accumulator/tape value/tape} [(weld accumulator value) (weld value "X")] :- "Everything: twoonethree" (from-list [[1 "oneX"] [2 "twoX"] [3 "threeX"] ~]) - "transform-fold" + "map-fold" :: - ++ test-transform-keys + ++ test-map-keys %^ expect-eq - %+ transform-keys + %+ map-keys three |= a/@u (add a 10) (from-list [[11 "one"] [12 "two"] [13 "three"] ~]) - "transform-keys" + "map-keys" :: - ++ test-transform-keys-with + ++ test-map-keys-with %^ expect-eq - %^ transform-keys-with + %^ map-keys-with three |=(a/@u 42) weld (from-list [[42 "twothreeone"] ~]) - "transform-keys-with" + "map-keys-with" :: ++ test-fold %^ expect-eq @@ -709,7 +709,7 @@ ^- tape (weld accumulator value) "Everything: twoonethree" - "transform-fold" + "map-fold" :: ++ test-fold-with-keys %^ expect-eq @@ -720,7 +720,7 @@ ^- tape :(weld accumulator (scow %ud key) value) "Everything: 2two1one3three" - "transform-fold-with-keys" + "map-fold-with-keys" :: ++ test-elems %^ expect-eq @@ -798,25 +798,25 @@ (from-list [[2 2] [4 4] [5 5] ~]) "partition" :: - ++ test-transform-maybe + ++ test-map-maybe %^ expect-eq - %+ transform-maybe + %+ map-maybe (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) |=(a/@u ?:(=(a 3) ~ `a)) (from-list [[1 1] [2 2] [4 4] [5 5] ~]) - "transform-maybe" + "map-maybe" :: - ++ test-transform-maybe-with-key + ++ test-map-maybe-with-key %^ expect-eq - %+ transform-maybe-with-key + %+ map-maybe-with-key (from-list [[1 2] [2 3] [3 4] [4 5] [5 6] ~]) |=({k/@u v/@u} ?:(=(k 3) ~ `v)) (from-list [[1 2] [2 3] [4 5] [5 6] ~]) - "transform-maybe-with-key" + "map-maybe-with-key" :: - ++ test-transform-either + ++ test-map-either %^ expect-eq - %+ transform-either + %+ map-either (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) |= value/@u ?: =(0 (mod value 2)) @@ -824,11 +824,11 @@ [%| 1] :- (from-list [[2 "even"] [4 "even"] ~]) (from-list [[1 1] [3 1] [5 1] ~]) - "transform-either" + "map-either" :: - ++ test-transform-either-with-key + ++ test-map-either-with-key %^ expect-eq - %+ transform-either-with-key + %+ map-either-with-key (from-list [[1 1] [2 1] [3 1] [4 1] [5 1] ~]) |= {key/@u value/@u} ?: =(0 (mod key 2)) @@ -836,7 +836,7 @@ [%| 1] :- (from-list [[2 "even"] [4 "even"] ~]) (from-list [[1 1] [3 1] [5 1] ~]) - "transform-either" + "map-either" :: ++ test-is-subdict %^ expect-eq diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 72129e5a4..9fb2cd582 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -127,8 +127,8 @@ $(a t.a) [u.i.a $(a t.a)] :: - ++ transform - :> a version of transform that can throw out items. + ++ map + :> a version of map that can throw out items. :> :> takes a list of items and a function of the type :> @@ -225,11 +225,11 @@ b $(a t.a, b +(b)) :: - :> # %transformations + :> # %mappings :> functions which change a list into another list +| :: - ++ transform + ++ map :> applies a gate to each item in the list. |* {a/(list) b/$-(* *)} ^- (list _*b) @@ -413,8 +413,8 @@ ?> ?=(^ rest) [(c i.a i.rest) rest] :: - ++ transform-foldl - :> performs both a ++transform and a ++foldl in one pass. + ++ map-foldl + :> performs both a ++map and a ++foldl in one pass. :> :> corresponds to {mapAccumL} in haskell. |* {a/(list) b/* c/$-({* *} {* *})} @@ -425,8 +425,8 @@ =+ recurse=$(a t.a, b -.d) [-.recurse [+.d +.recurse]] :: - ++ transform-foldr - :> performs both a ++transform and a ++foldr in one pass. + ++ map-foldr + :> performs both a ++map and a ++foldr in one pass. :> :> corresponds to {mapAccumR} in haskell. |* {a/(list) b/* c/$-({* *} {* *})} @@ -1117,7 +1117,7 @@ :> # %traversal +| :: - ++ transform + ++ map :> applies {fun} to each value in {a}. |* {a/(dict) fun/$-(* *)} ^- (dict _p.-.n.-.a fun) @@ -1125,7 +1125,7 @@ ~ [[p.n.a (fun q.n.a)] $(a l.a) $(a r.a)] :: - ++ transform-with-key + ++ map-with-key :> applies {fun} to each value in {a}. |* {a/(dict) fun/$-({* *} *)} ^- (dict _p.-.n.-.a _*fun) @@ -1133,7 +1133,7 @@ ~ [[p.n.a (fun p.n.a q.n.a)] $(a l.a) $(a r.a)] :: - ++ transform-fold + ++ map-fold :> performs a fold on all the values in {a}. :> :> lists have an order, but dicts are treaps. this means there isn't a @@ -1152,23 +1152,23 @@ =+ f=$(a r.a, b -.e) [-.f [n.a +.e +.f]] :: - ++ transform-keys + ++ map-keys :> applies {fun} to all keys. :: todo: the haskell version specifies that the "greatest" original key :: wins in case of duplicates. this is currently unhandled. maybe i just :: shouldn't have this gate. |* {a/(dict) fun/$-(* *)} %- from-list - %+ transform:ls (to-list a) + %+ map:ls (to-list a) |= item/_n.-.a [(fun p.item) q.item] :: - ++ transform-keys-with + ++ map-keys-with :> applies {fun} to all keys, creating a new value with {combine} on dupes. |* {a/(dict) fun/$-(* *) combine/$-({* *} *)} ^- (dict _*fun _q.+.n.-.a) =/ new-list - %+ transform:ls (to-list a) + %+ map:ls (to-list a) |= item/_n.-.a [(fun p.item) q.item] %^ foldl:ls new-list @@ -1348,15 +1348,15 @@ :: i'm going to ignore all the Antitone functions; they don't seem to be :: useful without ordering on the dict. :: - ++ transform-maybe - :> a version of transform that can throw out items. + ++ map-maybe + :> a version of map that can throw out items. |* {a/(dict) fun/$-(* (maybe))} - %+ transform-maybe-with-key a + %+ map-maybe-with-key a |= {key/* value/_q.+.n.-.a} (fun value) :: - ++ transform-maybe-with-key - :> a version of transform that can throw out items. + ++ map-maybe-with-key + :> a version of map that can throw out items. |* {a/(dict) fun/$-({* *} (maybe))} ^- (dict _p.-.n.-.a _+:*fun) ?~ a ~ @@ -1367,14 +1367,14 @@ (pop-top a) [[p.n.a +.res] $(a l.a) $(a r.a)] :: - ++ transform-either + ++ map-either :> splits the dict in two on a gate that returns an either. |* {a/(dict) fun/$-(* (either))} - %+ transform-either-with-key a + %+ map-either-with-key a |= {key/* value/_q.+.n.-.a} (fun value) :: - ++ transform-either-with-key + ++ map-either-with-key :> splits the dict in two on a gate that returns an either. |* {a/(dict) fun/$-({* *} (either))} |- From c2b8d61fa2350af58ae02b461c0e4d25427c7ce1 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Fri, 13 Oct 2017 23:28:11 -0700 Subject: [PATCH 020/184] insert -> put --- gen/test.hoon | 20 ++++++++++---------- lib/new-hoon.hoon | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index c7ed8baa9..2e54e4b55 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -110,7 +110,7 @@ m =^ first gen (range:gen 0 100) =^ second gen (range:gen 0 100) - $(m (insert:dct:new-hoon m first second), i +(i)) + $(m (put:dct:new-hoon m first second), i +(i)) :: :: || %test :: @@ -508,29 +508,29 @@ ++ test-member (expect-eq (member four 4) %.y "member") :: - ++ test-insert-with + ++ test-put-with =+ ints=(from-list [["one" 1] ["two" 2] ["three" 3] ["four" 4] ~]) %^ expect-eq - (insert-with ints "three" 2 add) + (put-with ints "three" 2 add) (from-list [["one" 1] ["two" 2] ["three" 5] ["four" 4] ~]) - "insert-with" + "put-with" :: - ++ test-insert-with-key + ++ test-put-with-key %^ expect-eq - (insert-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) + (put-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~]) - "insert-with-key" + "put-with-key" :: - ++ test-insert-lookup-with-key + ++ test-put-lookup-with-key %^ expect-eq - %- insert-lookup-with-key :^ + %- put-lookup-with-key :^ four 4 "five" |=({key/@ud old/tape new/tape} new) :- `"four" (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "five"] ~]) - "insert-lookup-with-key" + "put-lookup-with-key" :: ++ test-delete %^ expect-eq diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 9fb2cd582..3c253cb71 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -851,7 +851,7 @@ :: :> # %insertion +| - ++ insert + ++ put :> inserts a new key/value pair, replacing the current value if it exists. |* {a/(dict) key/* value/*} |- ^+ a @@ -873,7 +873,7 @@ [n.a l.a d] [n.d [n.a l.a l.d] r.d] :: - ++ insert-with + ++ put-with :> inserts {key}/{value}, applying {fun} if {key} already exists. |* {a/(dict) key/* value/* fun/$-({* *} *)} |- ^+ a @@ -894,7 +894,7 @@ [n.a l.a d] [n.d [n.a l.a l.d] r.d] :: - ++ insert-with-key + ++ put-with-key :> inserts {key}/{value}, applying {fun} if {key} already exists. |* {a/(dict) key/* value/* fun/$-({* * *} *)} |- ^+ a @@ -915,7 +915,7 @@ [n.a l.a d] [n.d [n.a l.a l.d] r.d] :: - ++ insert-lookup-with-key + ++ put-lookup-with-key :> combines insertion with lookup in one pass. |* {a/(dict) key/* value/* fun/$-({* * *} *)} |- ^- {(maybe _value) _a} @@ -1174,7 +1174,7 @@ %^ foldl:ls new-list `(dict _*fun _q.+.n.-.a)`~ |= {m/(dict _*fun _q.+.n.-.a) p/_i.-.new-list} - (insert-with m -.p +.p combine) + (put-with m -.p +.p combine) :: ++ fold :> performs a fold on all the values in {a}. @@ -1281,7 +1281,7 @@ %^ foldl:ls a `(dict _p.-.i.-.a _q.+.i.-.a)`~ |= {m/(dict _p.-.i.-.a _q.+.i.-.a) p/_i.-.a} - (insert m p) + (put m p) :: ++ from-list-with :> creates a dict from a list, with {fun} resolving duplicates. @@ -1289,7 +1289,7 @@ %^ foldl:ls a `(dict _*fun _q.+.i.-.a)`~ |= {m/(dict _*fun _q.+.i.-.a) p/_i.-.a} - (insert-with m -.p +.p fun) + (put-with m -.p +.p fun) :: :: todo: without a natural ordering, association lists and gates to operate :: on them probably don't make sense. i'm skipping them for now. @@ -1389,8 +1389,8 @@ =+ x=(fun n.a) ~! x ?- -.x - $& [(insert (union -.lr -.rr) p.n.a +.x) (union +.lr +.rr)] - $| [(union -.lr -.rr) (insert (union +.lr +.rr) p.n.a +.x)] + $& [(put (union -.lr -.rr) p.n.a +.x) (union +.lr +.rr)] + $| [(union -.lr -.rr) (put (union +.lr +.rr) p.n.a +.x)] == :: :: ++split, ++split-lookup and ++split-root do not make sense without From 1541a8df752450c5dad6b2c0b314620a0e56df80 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sun, 5 Nov 2017 15:44:37 -0800 Subject: [PATCH 021/184] A few more gates / minor changes. --- gen/test.hoon | 27 ++++++++++++--- lib/new-hoon.hoon | 87 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 97 insertions(+), 17 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 2e54e4b55..bcc933095 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -392,6 +392,18 @@ [~ "bar"] "break" :: + ++ test-inits + %^ expect-eq + (inits "abc") + ["a" "ab" "abc" ~] + "inits" + :: + ++ test-tails + %^ expect-eq + (tails "abc") + ["abc" "bc" "c" ~] + "tails" + :: ++ test-is-prefix-of %^ expect-eq (is-prefix-of "foo" "foobar") @@ -464,6 +476,12 @@ [1 3 ~] "find-indices" :: + ++ test-zip + %^ expect-eq + (zip [[1 2 3 ~] [4 5 6 ~] [7 8 9 ~] ~]) + [[1 4 7 ~] [2 5 8 ~] [3 6 9 ~] ~] + "zip" + :: ++ test-unique %^ expect-eq (unique [1 2 3 1 2 3 ~]) @@ -930,8 +948,7 @@ :: todo: right now, we hard code ++test-core. but eventually, we must instead :: scry ford for the core from the hoon file. that doesn't exist yet. ::(perform-test-suite:local "test-core" !>(test-core) eny) - -:: (perform-test-suite:local "test-thr" !>(test-thr) eny) -:: (perform-test-suite:local "test-myb" !>(test-myb) eny) -::(perform-test-suite:local "test-ls" !>(test-ls) eny) -(perform-test-suite:local "test-mp" !>(test-mp) eny) +::(perform-test-suite:local "test-thr" !>(test-thr) eny) +::(perform-test-suite:local "test-myb" !>(test-myb) eny) +(perform-test-suite:local "test-ls" !>(test-ls) eny) +::(perform-test-suite:local "test-mp" !>(test-mp) eny) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 3c253cb71..4a6215d0d 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -180,6 +180,7 @@ ++ head :> returns the first item in the list, which must be non-empty. |* a/(list) + => .(a (homo a)) :> the first item in the list. ?~ a ~>(%mean.[%leaf "head"] !!) i.a @@ -196,12 +197,13 @@ ++ tail :> returns all items after the head of the list, which must be non-empty. |* a/(list) + ^+ a ?~ a ~>(%mean.[%leaf "tail"] !!) t.a :: ++ init :> returns all items in the list except the last one. must be non-empty. - |= a/(list) + |* a/(list) => .(a (homo a)) |- ^+ a @@ -225,7 +227,7 @@ b $(a t.a, b +(b)) :: - :> # %mappings + :> # %transformations :> functions which change a list into another list +| :: @@ -561,10 +563,27 @@ $(a +.a, b +.b) :: :: todo: ++group - :: todo: ++inits - :: todo: ++tails :: - + ++ inits + :> returns all initial segments in reverse order. + :> + :> unlike haskell, this does not return the empty list as the first + :> element, as hoon uses null as the list terminator. + |* a/(list) + => .(a (homo a)) + %- flop + |- + ?~ a ~ + [a $(a (init a))] + :: + ++ tails + :> returns all final segments, longest first. + |* a/(list) + => .(a (homo a)) + |- + ?~ a ~ + [a $(a t.a)] + :: :> # %predicates :> functions which compare lists +| @@ -713,8 +732,44 @@ [i $(a t.a, i +(i))] $(a t.a, i +(i)) :: - :: can we do a full general zip without doing haskellesque zip3, zip4, etc? - :: todo: ++zip + ++ zip + :> takes a list of lists, returning a list of each first items. + |* a/(list (list)) + => .(a (multi-homo a)) + |^ ^+ a + ?~ a ~ + ?. valid + ~ + =+ h=heads + ?~ h ~ + [heads $(a tails)] + :: + ++ valid + %+ all a + |= {next/(list)} + ?~ a %.n + %.y + :: + ++ heads + ^+ (homo i:-.a) + |- + ?~ a ~ + ?~ i.a ~ + [i.i.a $(a t.a)] + :: + ++ tails + ^+ a + |- + ?~ a ~ + ?~ i.a ~ + [t.i.a $(a t.a)] + -- + ++ multi-homo + |* a/(list (list)) + ^+ =< $ + |% +- $ ?:(*? ~ [i=(homo (snag 0 a)) t=$]) + -- + a :: :> # %set :> set operations on lists @@ -852,7 +907,9 @@ :> # %insertion +| ++ put - :> inserts a new key/value pair, replacing the current value if it exists. + :> inserts a new key/value pair, replacing the current value if it exists. + :> + :> corresponds to {insert} in haskell. |* {a/(dict) key/* value/*} |- ^+ a ?~ a @@ -874,7 +931,9 @@ [n.d [n.a l.a l.d] r.d] :: ++ put-with - :> inserts {key}/{value}, applying {fun} if {key} already exists. + :> inserts {key}/{value}, applying {fun} if {key} already exists. + :> + :> corresponds to {insertWith} in haskell. |* {a/(dict) key/* value/* fun/$-({* *} *)} |- ^+ a ?~ a @@ -895,7 +954,9 @@ [n.d [n.a l.a l.d] r.d] :: ++ put-with-key - :> inserts {key}/{value}, applying {fun} if {key} already exists. + :> inserts {key}/{value}, applying {fun} if {key} already exists. + :> + :> corresponds to {insertWithKey} in haskell. |* {a/(dict) key/* value/* fun/$-({* * *} *)} |- ^+ a ?~ a @@ -916,7 +977,9 @@ [n.d [n.a l.a l.d] r.d] :: ++ put-lookup-with-key - :> combines insertion with lookup in one pass. + :> combines insertion with lookup in one pass. + :> + :> corresponds to {insertLookupWithKey} in haskell. |* {a/(dict) key/* value/* fun/$-({* * *} *)} |- ^- {(maybe _value) _a} ?~ a @@ -1433,7 +1496,7 @@ ++ valid :> returns %.y if {a} if this tree is a valid treap dict. |* a/(tree (pair * *)) - =| {l/(unit) r/(unit)} + =| {l/(maybe) r/(maybe)} |- ^- ? ?~ a & ?& ?~(l & (gor p.n.a u.l)) From 8976775ff0e7521a396c69ca037fcbf790ae5ed9 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 9 Nov 2017 22:34:27 -0800 Subject: [PATCH 022/184] Update |= and |* twigs to %143 format. --- lib/new-hoon.hoon | 302 +++++++++++++++++++++++----------------------- 1 file changed, 151 insertions(+), 151 deletions(-) diff --git a/lib/new-hoon.hoon b/lib/new-hoon.hoon index 4a6215d0d..3354b7b49 100644 --- a/lib/new-hoon.hoon +++ b/lib/new-hoon.hoon @@ -2,20 +2,20 @@ |% :: ++ first - |* a/^ + |* a=^ -.a :: ++ second - |* a/^ + |* a=^ +.a :: -++ either |*({a/mold b/mold} $%({$& p/a} {$| p/b})) :: either +++ either |*([a=mold b=mold] $%({$& p/a} {$| p/b})) :: either :: ++ thr |% ++ apply :> applies {b} {a} is first, or {b} to {a} is second. - |* {a/(either) b/$-(* *) c/$-(* *)} + |* [a=(either) b=$-(* *) c=$-(* *)] ?- -.a $& (b p.a) $| (c p.a) @@ -23,7 +23,7 @@ :: ++ firsts :> returns a list of all first elements in {a}. - |* a/(list (either)) + |* a=(list (either)) => .(a (homo a)) |- ?~ a @@ -35,7 +35,7 @@ :: ++ seconds :> returns a list of all second elements in {a}. - |* a/(list (either)) + |* a=(list (either)) => .(a (homo a)) |- ?~ a @@ -47,7 +47,7 @@ :: ++ partition :> splits the list of eithers into two lists based on first or second. - |* a/(list (either)) + |* a=(list (either)) => .(a (homo a)) |- ^- {(list _?>(?=({{%& *} *} a) p.i.a)) (list _?>(?=({{%| *} *} a) p.i.a))} @@ -59,14 +59,14 @@ $| [-.ret [p.i.a +.ret]] == -- -++ maybe |*(a/mold $@($~ {$~ u/a})) :: maybe +++ maybe |*(a=mold $@($~ {$~ u/a})) :: maybe ++ myb |% ++ is-null :> returns %.y if maybe is null. :> :> corresponds to {isJust} in haskell. - |* a/(maybe) + |* a=(maybe) :> whether {a} is null. ?~ a %.y %.n @@ -75,7 +75,7 @@ :> returns %.y if maybe contains a real value. :> :> corresponds to {isNothing} in haskell. - |* a/(maybe) + |* a=(maybe) :> whether {a} is not null. ?~ a %.n %.y @@ -84,7 +84,7 @@ :> returns the value or crashes. :> :> corresponds to {fromJust} in haskell. - |* a/(maybe) + |* a=(maybe) ?~ a ~>(%mean.[%leaf "need"] !!) :> the value from the maybe. u.a @@ -93,14 +93,14 @@ :> returns the value in the maybe, or a default value on null. :> :> corresponds to {fromMaybe} in haskell. - |* {a/(maybe) b/*} + |* [a=(maybe) b=*] ?~(a b u.a) :: ++ from-list :> returns the first value of the list, or null on empty list. :> :> corresponds to {listToMaybe} in haskell. - |* a/(list) + |* a=(list) ^- (maybe _i.a) ?~ a ~ [~ i.a] @@ -109,7 +109,7 @@ :> converts the maybe to a list. :> :> corresponds to {maybeToList} in haskell. - |* a/(maybe) + |* a=(maybe) ^- (list _u.a) ?~ a ~ [u.a ~] @@ -118,7 +118,7 @@ :> converts a list of maybes to a list of non-null values. :> :> corresponds to {catMaybes} in haskell. - |* a/(list (maybe)) + |* a=(list (maybe)) => .(a (homo a)) |- ^- (list _u.+.i.-.a) @@ -136,7 +136,7 @@ :> logically be put in our list class? murn is. :> :> corresponds to {mapMaybes} in haskell. - |* {a/(list) b/$-(* (maybe))} + |* [a=(list) b=$-(* (maybe))] => .(a (homo a)) |- ^- (list _,.+:*b) @@ -150,7 +150,7 @@ :: ++ apply :> applies {b} to {a}. - |* {a/(maybe) b/$-(* (maybe))} + |* [a=(maybe) b=$-(* (maybe))] ?~ a ~ (b u.a) :: @@ -179,7 +179,7 @@ :: ++ head :> returns the first item in the list, which must be non-empty. - |* a/(list) + |* a=(list) => .(a (homo a)) :> the first item in the list. ?~ a ~>(%mean.[%leaf "head"] !!) @@ -187,7 +187,7 @@ :: ++ last :> returns the final item in the list, which must be non-empty. - |* a/(list) + |* a=(list) :> the last item in a list. ?~ a ~>(%mean.[%leaf "last"] !!) ?~ t.a @@ -196,14 +196,14 @@ :: ++ tail :> returns all items after the head of the list, which must be non-empty. - |* a/(list) + |* a=(list) ^+ a ?~ a ~>(%mean.[%leaf "tail"] !!) t.a :: ++ init :> returns all items in the list except the last one. must be non-empty. - |* a/(list) + |* a=(list) => .(a (homo a)) |- ^+ a @@ -219,8 +219,8 @@ :> returns the number of items in {a}. :> :> corresponds to {length} in haskell. - |= a/(list) - =| b/@u + |= a=(list) + =| b=@u ^- @u |- ?~ a @@ -233,14 +233,14 @@ :: ++ map :> applies a gate to each item in the list. - |* {a/(list) b/$-(* *)} + |* [a=(list) b=$-(* *)] ^- (list _*b) ?~ a ~ [(b i.a) $(a t.a)] :: ++ reverse :> reverses the order of the items in the list. - |* a/(list) + |* a=(list) => .(a (homo a)) ^+ a =+ b=`_a`~ @@ -250,7 +250,7 @@ :: ++ intersperse :> places {a} between each element in {b}. - |* {a/* b/(list)} + |* [a=* b=(list)] => .(b (homo b)) |- ^+ (homo [a b]) @@ -263,7 +263,7 @@ :: ++ intercalate :> places {a} between each list in {b}, and flatten to a single list. - |* {a/(list) b/(list (list))} + |* [a=(list) b=(list (list))] => .(a ^.(homo a), b ^.(homo b)) |- ^+ (concat [a b]) @@ -276,7 +276,7 @@ :: ++ transpose :> transposes rows and columns of a 2d list structure. - |* input/(list (list)) + |* input=(list (list)) :: todo: this should homogenize with each sublist. ^- (list (list)) =/ items @@ -295,14 +295,14 @@ [(reverse -.items) $(input (reverse +.items))] :: :: :: ++ subsequences -:: :: |= a/(list) +:: :: |= a=(list) :: :: ?~ a :: :: ~ :: :: :- -.a :: :: %^ foldr :: :: $(a +.a) :: :: `(list)`~ -:: :: |= {ys/(list) r/(list)} +:: :: |= [ys=(list) r=(list)] :: :: ~ ::[ys [-.a ys] r ~] :: :: TODO: :: :: ++subsequences @@ -317,7 +317,7 @@ :> left associative fold :> :> this follows haskell giving an explicit starting value instead of {roll}. - |* {a/(list) b/* c/$-({* *} *)} + |* [a=(list) b=* c=$-({* *} *)] ^+ b ?~ a b @@ -325,7 +325,7 @@ :: ++ foldr :> right associative fold - |* {a/(list) b/* c/$-({* *} *)} + |* [a=(list) b=* c=$-({* *} *)] ^+ b ?~ a b @@ -333,7 +333,7 @@ :: ++ concat :> concatenate a list of lists into a single level. - |* a/(list (list)) + |* a=(list (list)) => .(a ^.(homo a)) |- ^+ (homo i:-.a) ?~ a @@ -342,7 +342,7 @@ :: ++ weld :> combine two lists, possibly of different types. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] => .(a ^.(homo a), b ^.(homo b)) |- ^- (list $?(_i.-.a _i.-.b)) ?~ a b @@ -350,14 +350,14 @@ :: ++ any :> returns yes if any element satisfies the predicate - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] ?~ a %.n ?|((b i.a) $(a t.a)) :: ++ all :> returns yes if all elements satisfy the predicate - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] ?~ a %.y ?&((b i.a) $(a t.a)) @@ -371,7 +371,7 @@ +| ++ scanl :> returns a list of successive reduced values from the left. - |* {a/(list) b/* c/$-({* *} *)} + |* [a=(list) b=* c=$-({* *} *)] => .(a (homo a)) |- ?~ a @@ -380,7 +380,7 @@ :: ++ scanl1 :> a variant of ++scanl that has no starting value. - |* {a/(list) c/$-({* *} *)} + |* [a=(list) c=$-({* *} *)] => .(a (homo a)) |- ?~ a @@ -391,7 +391,7 @@ :: ++ scanr :> the right-to-left version of scanl. - |* {a/(list) b/* c/$-({* *} *)} + |* [a=(list) b=* c=$-({* *} *)] => .(a (homo a)) |- ^- (list _b) @@ -403,7 +403,7 @@ :: ++ scanr1 :> a variant of ++scanr that has no starting value. - |* {a/(list) c/$-({* *} *)} + |* [a=(list) c=$-({* *} *)] => .(a (homo a)) |- ^+ a @@ -419,7 +419,7 @@ :> performs both a ++map and a ++foldl in one pass. :> :> corresponds to {mapAccumL} in haskell. - |* {a/(list) b/* c/$-({* *} {* *})} + |* [a=(list) b=* c=$-({* *} {* *})] ^- {_b (list _+:*c)} ?~ a [b ~] @@ -431,7 +431,7 @@ :> performs both a ++map and a ++foldr in one pass. :> :> corresponds to {mapAccumR} in haskell. - |* {a/(list) b/* c/$-({* *} {* *})} + |* [a=(list) b=* c=$-({* *} {* *})] ^- {_b (list _+:*c)} ?~ a [b ~] @@ -441,7 +441,7 @@ :: ++ unfoldr :> generates a list from a seed value and a function. - |* {b/* c/$-(* (maybe {* *}))} + |* [b=* c=$-(* (maybe {* *}))] |- ^- (list _b) =+ current=(c b) @@ -457,7 +457,7 @@ :: ++ take :> returns the first {a} elements of {b}. - |* {a/@ b/(list)} + |* [a=@ b=(list)] => .(b (homo b)) |- ^+ b @@ -469,7 +469,7 @@ :: ++ drop :> returns {b} without the first {a} elements. - |* {a/@ b/(list)} + |* [a=@ b=(list)] ?: =(0 a) b ?~ b @@ -478,7 +478,7 @@ :: ++ split-at :> returns {b} split into two lists at the {a}th element. - |* {a/@ b/(list)} + |* [a=@ b=(list)] => .(b (homo b)) |- ^+ [b b] @@ -491,7 +491,7 @@ :: ++ take-while :> returns elements from {a} until {b} returns %.no. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] => .(a (homo a)) |- ^+ a @@ -503,7 +503,7 @@ :: ++ drop-while :> returns elements form {a} once {b} returns %.no. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] => .(a (homo a)) |- ?~ a @@ -514,7 +514,7 @@ :: ++ drop-while-end :> drops the largest suffix of {a} which matches {b}. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] => .(a (homo a)) |- ?~ a @@ -528,7 +528,7 @@ :> returns [the longest prefix of {b}, the rest of the list]. :> :> corresponds to {span} in haskell. renamed to not conflict with hoon. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] => .(a (homo a)) |- ^+ [a a] @@ -541,7 +541,7 @@ :: ++ break :> like {split-on}, but reverses the return code of {b}. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] => .(a (homo a)) |- ^+ [a a] @@ -554,7 +554,7 @@ :: ++ strip-prefix :> returns a {maybe} of {b} with the prefix {a} removed, or ~ if no match. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] ^- (maybe _b) ?~ a `b @@ -569,7 +569,7 @@ :> :> unlike haskell, this does not return the empty list as the first :> element, as hoon uses null as the list terminator. - |* a/(list) + |* a=(list) => .(a (homo a)) %- flop |- @@ -578,7 +578,7 @@ :: ++ tails :> returns all final segments, longest first. - |* a/(list) + |* a=(list) => .(a (homo a)) |- ?~ a ~ @@ -590,7 +590,7 @@ :: ++ is-prefix-of :> returns %.y if the first list is a prefix of the second. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] => .(a (homo a), b (homo b)) |- ^- ? @@ -604,7 +604,7 @@ :: ++ is-suffix-of :> returns %.y if the first list is the suffix of the second. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] => .(a (homo a), b (homo b)) ^- ? :: todo: this is performant in haskell because of laziness but may not be @@ -613,7 +613,7 @@ :: ++ is-infix-of :> returns %.y if the first list appears anywhere in the second. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] => .(a (homo a), b (homo b)) |- ^- ? @@ -632,7 +632,7 @@ :: ++ elem :> does {a} occur in list {b}? - |* {a/* b/(list)} + |* [a=* b=(list)] ?~ b %.n ?: =(a i.b) @@ -641,7 +641,7 @@ :: ++ lookup :> looks up the key {a} in the association list {b} - |* {a/* b/(list (pair))} + |* [a=* b=(list (pair))] ^- (maybe _+.-.b) ?~ b ~ @@ -651,7 +651,7 @@ :: ++ find :> returns the first element of {a} which matches predicate {b}. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] ^- (maybe _-.a) ?~ a ~ @@ -661,7 +661,7 @@ :: ++ filter :> filter all items in {a} which match predicate {b}. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] => .(a (homo a)) |- ^+ a @@ -673,7 +673,7 @@ :: ++ partition :> returns two lists, one whose elements match {b}, the other which doesn't. - |* {a/(list) b/$-(* ?)} + |* [a=(list) b=$-(* ?)] => .(a (homo a)) |- ^+ [a a] @@ -690,8 +690,8 @@ :: ++ elem-index :> returns {maybe} the first occurrence of {a} occur in list {b}. - =| i/@u - |= {a/* b/(list)} + =| i=@u + |= [a=* b=(list)] ^- (maybe @ud) ?~ b ~ @@ -702,7 +702,7 @@ ++ elem-indices :> returns a list of indices of all occurrences of {a} in {b}. =| i/@u - |= {a/* b/(list)} + |= [a=* b=(list)] ^- (list @ud) ?~ b ~ @@ -712,8 +712,8 @@ :: ++ find-index :> returns {maybe} the first occurrence which matches {b} in {a}. - =| i/@u - |* {a/(list) b/$-(* ?)} + =| i=@u + |* [a=(list) b=$-(* ?)] ^- (maybe @ud) ?~ a ~ @@ -723,8 +723,8 @@ :: ++ find-indices :> returns a list of indices of all items in {a} which match {b}. - =| i/@u - |* {a/(list) b/$-(* ?)} + =| i=@u + |* [a=(list) b=$-(* ?)] ^- (list @ud) ?~ a ~ @@ -734,7 +734,7 @@ :: ++ zip :> takes a list of lists, returning a list of each first items. - |* a/(list (list)) + |* a=(list (list)) => .(a (multi-homo a)) |^ ^+ a ?~ a ~ @@ -746,7 +746,7 @@ :: ++ valid %+ all a - |= {next/(list)} + |= next=(list) ?~ a %.n %.y :: @@ -765,7 +765,7 @@ [t.i.a $(a t.a)] -- ++ multi-homo - |* a/(list (list)) + |* a=(list (list)) ^+ =< $ |% +- $ ?:(*? ~ [i=(homo (snag 0 a)) t=$]) -- @@ -778,7 +778,7 @@ :> removes duplicates elements from {a} :> :> corresponds to {nub} in haskell. - |* a/(list) + |* a=(list) => .(a (homo a)) =| seen/(list) ^+ a @@ -791,7 +791,7 @@ :: ++ delete :> removes the first occurrence of {a} in {b} - |* {a/* b/(list)} + |* [a=* b=(list)] => .(b (homo b)) ^+ b |- @@ -803,7 +803,7 @@ :: ++ delete-firsts :> deletes the first occurrence of each element in {b} from {a}. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] => .(a (homo a), b (homo b)) |- ^+ a @@ -817,7 +817,7 @@ :: ++ union :> the list union of {a} and {b}. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] => .(a (homo a), b (homo b)) |- ^+ (weld a b) @@ -829,7 +829,7 @@ :: ++ intersect :> the intersection of {a} and {b}. - |* {a/(list) b/(list)} + |* [a=(list) b=(list)] => .(a (homo a), b (homo b)) |- ^+ a @@ -850,7 +850,7 @@ :> :> a dictionary is treap ordered; it builds a treap out of the hashed key :> values. - |* {a/mold b/mold} + |* [a=mold b=mold] %+ cork (tree (pair a b)) |= c/(tree (pair a b)) ^+ c ?.((valid:dct c) ~ c) @@ -862,27 +862,27 @@ +| ++ empty :> is the dict empty? - |* a/(dict) + |* a=(dict) ?~ a %.y %.n :: ++ size :> returns the number of elements in {a}. - |= a/(dict) + |= a=(dict) ^- @u ?~ a 0 :(add 1 $(a l.a) $(a r.a)) :: ++ member :> returns %.y if {b} is a key in {a}. - |= {a/(dict) key/*} + |= [a=(dict) key=*] ^- ? ?~ a %.n ?|(=(key p.n.a) $(a l.a) $(a r.a)) :: ++ get :> grab value by key. - |* {a/(dict) key/*} + |* [a=(dict) key=*] ^- (maybe _?>(?=(^ a) q.n.a)) :: ^- {$@($~ {$~ u/_?>(?=(^ a) q.n.a)})} ?~ a @@ -898,7 +898,7 @@ :: ++ got :: :> todo: move impl here. :: :> todo: is there a way to make b/_<><>.a ? -:: |* {a/(dict) key/*} +:: |* [a=(dict) key=*] :: (~(got by a) key) :: :: todo: skipping several methods which rely on the the Ord typeclass, like @@ -910,7 +910,7 @@ :> inserts a new key/value pair, replacing the current value if it exists. :> :> corresponds to {insert} in haskell. - |* {a/(dict) key/* value/*} + |* [a=(dict) key=* value=*] |- ^+ a ?~ a [[key value] ~ ~] @@ -934,7 +934,7 @@ :> inserts {key}/{value}, applying {fun} if {key} already exists. :> :> corresponds to {insertWith} in haskell. - |* {a/(dict) key/* value/* fun/$-({* *} *)} + |* [a=(dict) key=* value=* fun=$-({* *} *)] |- ^+ a ?~ a [[key value] ~ ~] @@ -957,7 +957,7 @@ :> inserts {key}/{value}, applying {fun} if {key} already exists. :> :> corresponds to {insertWithKey} in haskell. - |* {a/(dict) key/* value/* fun/$-({* * *} *)} + |* [a=(dict) key=* value=* fun=$-({* * *} *)] |- ^+ a ?~ a [[key value] ~ ~] @@ -980,7 +980,7 @@ :> combines insertion with lookup in one pass. :> :> corresponds to {insertLookupWithKey} in haskell. - |* {a/(dict) key/* value/* fun/$-({* * *} *)} + |* [a=(dict) key=* value=* fun=$-({* * *} *)] |- ^- {(maybe _value) _a} ?~ a [~ [[key value] ~ ~]] @@ -1006,7 +1006,7 @@ :: ++ delete :> deletes entry at {key}. - |* {a/(dict) key/*} + |* [a=(dict) key=*] |- ^+ a ?~ a ~ @@ -1018,36 +1018,36 @@ :: ++ adjust :> updates a value at {key} by passing the value to {fun}. - |* {a/(dict) key/* fun/$-(* *)} + |* [a=(dict) key=* fun=$-(* *)] %^ alter-with-key a key - |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + |= [key=_p.-.n.-.a value=(maybe _q.+.n.-.a)] ^- (maybe _q.+.n.-.a) ?~ value ~ [~ (fun u.value)] :: ++ adjust-with-key :> updates a value at {key} by passing the key/value pair to {fun}. - |* {a/(dict) key/* fun/$-({* *} *)} + |* [a=(dict) key=* fun=$-({* *} *)] %^ alter-with-key a key - |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + |= [key=_p.-.n.-.a value=(maybe _q.+.n.-.a)] ^- (maybe _q.+.n.-.a) ?~ value ~ [~ (fun key u.value)] :: ++ update :> adjusts or deletes the value at {key} by {fun}. - |* {a/(dict) key/* fun/$-(* (maybe *))} + |* [a=(dict) key=* fun=$-(* (maybe *))] %^ alter-with-key a key - |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + |= [key=_p.-.n.-.a value=(maybe _q.+.n.-.a)] ^- (maybe _q.+.n.-.a) ?~ value ~ (fun u.value) :: ++ update-with-key :> adjusts or deletes the value at {key} by {fun}. - |* {a/(dict) key/* fun/$-({* *} (maybe *))} + |* [a=(dict) key=* fun=$-({* *} (maybe *))] %^ alter-with-key a key - |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + |= [key=_p.-.n.-.a value=(maybe _q.+.n.-.a)] ^- (maybe _q.+.n.-.a) ?~ value ~ (fun key u.value) @@ -1057,14 +1057,14 @@ :: ++ alter :> inserts, deletes, or updates a value by {fun}. - |* {a/(dict) key/* fun/$-((maybe *) (maybe *))} + |* [a=(dict) key=* fun=$-((maybe *) (maybe *))] %^ alter-with-key a key - |= {key/_p.-.n.-.a value/(maybe _q.+.n.-.a)} + |= [key=_p.-.n.-.a value=(maybe _q.+.n.-.a)] (fun value) :: ++ alter-with-key :> inserts, deletes, or updates a value by {fun}. - |* {a/(dict) key/* fun/$-({* (maybe *)} (maybe *))} + |* [a=(dict) key=* fun=$-({* (maybe *)} (maybe *))] |- ^+ a ?~ a =+ ret=(fun key ~) @@ -1097,7 +1097,7 @@ :: ++ union :> returns the union of {a} and {b}, preferring the value from {a} if dupe - |* {a/(dict) b/(dict)} + |* [a=(dict) b=(dict)] |- ^+ a ?~ b a @@ -1117,7 +1117,7 @@ :: ++ union-with :> returns the union of {a} and {b}, running {fun} to resolve duplicates. - |* {a/(dict) b/(dict) fun/$-({* *} *)} + |* [a=(dict) b=(dict) fun=$-({* *} *)] |- ^+ a ?~ b a @@ -1137,7 +1137,7 @@ :: ++ union-with-key :> returns the union of {a} and {b}, running {fun} to resolve duplicates. - |* {a/(dict) b/(dict) fun/$-({* * *} *)} + |* [a=(dict) b=(dict) fun=$-({* * *} *)] |- ^+ a ?~ b a @@ -1160,7 +1160,7 @@ :: ++ difference :: :: todo: move real implementation here. :: :> returns elements in {a} that don't exist in {b}. -:: |* {a/(dict) b/(dict)} +:: |* [a=(dict) b=(dict)] :: (~(dif by a) b) :: :: :: :: todo: @@ -1170,7 +1170,7 @@ :: ++ intersection :: :: todo: move real implementation here. :: :> returns elements in {a} that exist in {b}. -:: |* {a/(dict) b/(dict)} +:: |* [a=(dict) b=(dict)] :: (~(int by a) b) :: :: :: :: todo: @@ -1182,7 +1182,7 @@ :: ++ map :> applies {fun} to each value in {a}. - |* {a/(dict) fun/$-(* *)} + |* [a=(dict) fun=$-(* *)] ^- (dict _p.-.n.-.a fun) ?~ a ~ @@ -1190,7 +1190,7 @@ :: ++ map-with-key :> applies {fun} to each value in {a}. - |* {a/(dict) fun/$-({* *} *)} + |* [a=(dict) fun=$-({* *} *)] ^- (dict _p.-.n.-.a _*fun) ?~ a ~ @@ -1205,7 +1205,7 @@ :> treap order. :> :> corresponds to {mapAccum} in haskell. - |* {a/(dict) b/* fun/$-({* *} {* *})} + |* [a=(dict) b=* fun=$-({* *} {* *})] ^- {_b (dict _p.-.n.-.a _+:*fun)} ?~ a [b ~] @@ -1220,7 +1220,7 @@ :: todo: the haskell version specifies that the "greatest" original key :: wins in case of duplicates. this is currently unhandled. maybe i just :: shouldn't have this gate. - |* {a/(dict) fun/$-(* *)} + |* [a=(dict) fun=$-(* *)] %- from-list %+ map:ls (to-list a) |= item/_n.-.a @@ -1228,7 +1228,7 @@ :: ++ map-keys-with :> applies {fun} to all keys, creating a new value with {combine} on dupes. - |* {a/(dict) fun/$-(* *) combine/$-({* *} *)} + |* [a=(dict) fun=$-(* *) combine=$-({* *} *)] ^- (dict _*fun _q.+.n.-.a) =/ new-list %+ map:ls (to-list a) @@ -1236,7 +1236,7 @@ [(fun p.item) q.item] %^ foldl:ls new-list `(dict _*fun _q.+.n.-.a)`~ - |= {m/(dict _*fun _q.+.n.-.a) p/_i.-.new-list} + |= [m=(dict _*fun _q.+.n.-.a) p=_i.-.new-list] (put-with m -.p +.p combine) :: ++ fold @@ -1246,7 +1246,7 @@ :> horizontal ordering, and thus the distinction between left and right :> folding isn't relevant. your accumulator function will be called in :> treap order. - |* {a/(dict) b/* fun/$-({* *} *)} + |* [a=(dict) b=* fun=$-({* *} *)] ^- _b ?~ a b @@ -1256,7 +1256,7 @@ :: ++ fold-with-keys :> performs a fold on all the values in {a}, passing keys too. - |* {a/(dict) b/* fun/$-({* * *} *)} + |* [a=(dict) b=* fun=$-({* * *} *)] ^+ b ?~ a b @@ -1266,7 +1266,7 @@ :: ++ any :> returns yes if any element satisfies the predicate - |* {a/(dict) b/$-(* ?)} + |* [a=(dict) b=$-(* ?)] ^- ? ?~ a %.n @@ -1274,7 +1274,7 @@ :: ++ any-with-key :> returns yes if any element satisfies the predicate - |* {a/(dict) b/$-({* *} ?)} + |* [a=(dict) b=$-({* *} ?)] ^- ? ?~ a %.n @@ -1282,7 +1282,7 @@ :: ++ all :> returns yes if all elements satisfy the predicate - |* {a/(dict) b/$-(* ?)} + |* [a=(dict) b=$-(* ?)] ^- ? ?~ a %.y @@ -1290,7 +1290,7 @@ :: ++ all-with-key :> returns yes if all elements satisfy the predicate - |* {a/(dict) b/$-({* *} ?)} + |* [a=(dict) b=$-({* *} ?)] ^- ? ?~ a %.y @@ -1300,12 +1300,12 @@ +| ++ elems :> return all values in the dict. - |* a/(dict) + |* a=(dict) %+ turn (to-list a) second :: ++ keys :> returns all keys in the dict. - |* a/(dict) + |* a=(dict) %+ turn (to-list a) first :: :: todo: ++assocs probably doesn't make sense when we have ++to-list and @@ -1313,12 +1313,12 @@ :: ++ keys-set :> returns all keys as a set. - |* a/(dict) + |* a=(dict) (si:nl (keys a)) :: ++ from-set :> computes a dict by running {fun} on every value in a set. - |* {a/(set) fun/$-(* *)} + |* [a=(set) fun=$-(* *)] ^- (dict _n.-.a _*fun) ?~ a ~ @@ -1329,8 +1329,8 @@ :: ++ to-list :> creates a list of pairs from the tree. - |* a/(dict) - =| b/(list _n.-.a) + |* a=(dict) + =| b=(list _n.-.a) |- ^+ b ?~ a @@ -1339,19 +1339,19 @@ :: ++ from-list :> creates a tree from a list. - |* a/(list (pair)) + |* a=(list (pair)) |- %^ foldl:ls a `(dict _p.-.i.-.a _q.+.i.-.a)`~ - |= {m/(dict _p.-.i.-.a _q.+.i.-.a) p/_i.-.a} + |= [m=(dict _p.-.i.-.a _q.+.i.-.a) p=_i.-.a] (put m p) :: ++ from-list-with :> creates a dict from a list, with {fun} resolving duplicates. - |* {a/(list (pair)) fun/$-(* *)} + |* [a=(list (pair)) fun=$-(* *)] %^ foldl:ls a `(dict _*fun _q.+.i.-.a)`~ - |= {m/(dict _*fun _q.+.i.-.a) p/_i.-.a} + |= [m=(dict _*fun _q.+.i.-.a) p=_i.-.a] (put-with m -.p +.p fun) :: :: todo: without a natural ordering, association lists and gates to operate @@ -1361,14 +1361,14 @@ +| ++ filter :> filters a dict of all values that satisfy {fun}. - |* {a/(dict) fun/$-(* ?)} + |* [a=(dict) fun=$-(* ?)] %+ filter-with-key a - |= {key/* value/_q.+.n.-.a} + |= [key=* value=_q.+.n.-.a] (fun value) :: ++ filter-with-key :> filters a dict of all values that satisfy {fun}. - |* {a/(dict) fun/$-({* *} ?)} + |* [a=(dict) fun=$-({* *} ?)] |- ^+ a ?~ a ~ @@ -1380,25 +1380,25 @@ :: ++ restrict-keys :> returns a dict where the only allowable keys are {keys}. - |* {a/(dict) keys/(set)} + |* [a=(dict) keys=(set)] %+ filter-with-key a - |= {key/_p.-.n.-.a value/*} + |= [key=_p.-.n.-.a value=*] :: todo: replace this with a call to our set library when we advance that :: far. !(~(has in keys) key) :: ++ without-keys :> returns a dict where the only allowable keys are not in {keys}. - |* {a/(dict) keys/(set)} + |* [a=(dict) keys=(set)] %+ filter-with-key a - |= {key/_p.-.n.-.a value/*} + |= [key=_p.-.n.-.a value=*] :: todo: replace this with a call to our set library when we advance that :: far. (~(has in keys) key) :: ++ partition :> returns two lists, one whose elements match {fun}, the other doesn't. - |* {a/(dict) fun/$-(* ?)} + |* [a=(dict) fun=$-(* ?)] :: todo: is the runtime on this is bogus? =/ data %+ partition:ls (to-list a) @@ -1413,14 +1413,14 @@ :: ++ map-maybe :> a version of map that can throw out items. - |* {a/(dict) fun/$-(* (maybe))} + |* [a=(dict) fun=$-(* (maybe))] %+ map-maybe-with-key a - |= {key/* value/_q.+.n.-.a} + |= [key=* value=_q.+.n.-.a] (fun value) :: ++ map-maybe-with-key :> a version of map that can throw out items. - |* {a/(dict) fun/$-({* *} (maybe))} + |* [a=(dict) fun=$-({* *} (maybe))] ^- (dict _p.-.n.-.a _+:*fun) ?~ a ~ =+ res=(fun n.a) @@ -1432,14 +1432,14 @@ :: ++ map-either :> splits the dict in two on a gate that returns an either. - |* {a/(dict) fun/$-(* (either))} + |* [a=(dict) fun=$-(* (either))] %+ map-either-with-key a - |= {key/* value/_q.+.n.-.a} + |= [key=* value=_q.+.n.-.a] (fun value) :: ++ map-either-with-key :> splits the dict in two on a gate that returns an either. - |* {a/(dict) fun/$-({* *} (either))} + |* [a=(dict) fun=$-({* *} (either))] |- ^- $: (dict _p.-.n.-.a _?>(?=({{%& *} *} *fun) +:*fun)) (dict _p.-.n.-.a _?>(?=({{%| *} *} *fun) +:*fun)) @@ -1461,13 +1461,13 @@ :: ++ is-subdict :> returns %.y if every element in {a} exists in {b} with the same value. - |* {a/(dict) b/(dict)} + |* [a=(dict) b=(dict)] ^- ? - (is-subdict-by a b |=({a/* b/*} =(a b))) + (is-subdict-by a b |=([a=* b=*] =(a b))) :: ++ is-subdict-by :> returns %.y if every element in {a} exists in {b} with the same value. - |* {a/(dict) b/(dict) fun/$-({* *} ?)} + |* [a=(dict) b=(dict) fun=$-({* *} ?)] |- ^- ? ?~ a %.y @@ -1483,7 +1483,7 @@ +| ++ pop-top :> removes the head of the tree and rebalances the tree below. - |* a/(dict) + |* a=(dict) ^- {$?($~ _a)} ?~ a ~ |- @@ -1495,8 +1495,8 @@ :: ++ valid :> returns %.y if {a} if this tree is a valid treap dict. - |* a/(tree (pair * *)) - =| {l/(maybe) r/(maybe)} + |* a=(tree (pair * *)) + =| [l=(maybe) r=(maybe)] |- ^- ? ?~ a & ?& ?~(l & (gor p.n.a u.l)) @@ -1518,10 +1518,10 @@ :> =+ gen=(random eny) :> =^ first gen (range:gen 0 10) :> =^ second gen (range:gen 0 10) - |= a/@ + |= a=@ => |% ++ raw :: random bits - |= b/@ ^- @ + |= b=@ ^- @ %+ can 0 =+ c=(shas %og-a (mix b a)) @@ -1534,14 +1534,14 @@ [[256 d] $(c d, b (sub b 256))] :: ++ rad :: random in range - |= b/@ ^- @ + |= b=@ ^- @ =+ c=(raw (met 0 b)) ?:((lth c b) c $(a +(a))) -- ^? |% ++ range :> returns a random number in the range [start, end], and generator. - |= {start/@ end/@} + |= [start=@ end=@] ?: (gte start end) ~_(leaf+"invalid range" !!) =+ offset=(sub end start) @@ -1550,7 +1550,7 @@ :: ++ bits :> returns {b} bits in the range, and generator. - |= b/@ + |= b=@ =+ r=(raw b) [r +>.$(a (shas %og-s (mix a r)))] -- From fa10e2fdb217bd61ab615674f821089c476eed0a Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 13 Nov 2017 16:43:39 -0800 Subject: [PATCH 023/184] Code review on test stuff with Anton. - Deletes old unused example stuff - Nicer null check - Make dynamic compiling an order of magnitude faster - Lift the !> out of mule. - Make it a stack of cores instead of one core. --- gen/test.hoon | 85 ++++++++++++++------------------------------------- 1 file changed, 23 insertions(+), 62 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index bcc933095..c8b2bbf7b 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -1,3 +1,4 @@ +:: todo: think about using horns to import all tests in %/tests? /+ new-hoon |% :: ---------------------------------------------------------------------- @@ -5,6 +6,11 @@ :: ---------------------------------------------------------------------- ++ test-lib |% + ++ init-test-vase + |= {cookie/@uvJ} + ^- vase + !>((init-test cookie)) + :: ++ init-test |= {cookie/@uvJ} ~(. tester `(list tape)`~ cookie 10 0) @@ -17,48 +23,6 @@ check-iterations/@u :: # of check trials current-iteration/@u :: current iteration == - :: - :: || %examples - :: - :: +| - ++ example !. - :: TODO: this doesn't deal with |*. - :: - :: specifies an example and its expected value. - :: - :: the examples in the hoon documentation used to go out of date very - :: quickly, since they were never compiled. so make compiling them a - :: test. - :: - :: source: a hoon expression - :: expected: the expected result of {source}. - |= {source/cord expected/cord} - ^+ +> - :: todo: deal with expected not compiling. - =+ exp=(slap !>(.) (ream expected)) - =+ run=(mule |.((slap !>(.) (ream source)))) - =/ result/vase ?- -.run - $| !>(p.run) - $& p.run - == - ?: =(q.result q.exp) - +>.$ - %= +>.$ - error-lines :* - "failure in '{(trip source)}':" - " actual: '{(noah result)}'" - " expected: '{(noah exp)}'" - error-lines - == - == - ++ examples - :: - |= a/(list {cord cord}) - ?~ a - +>.$ - =. +>.$ (example i.a) - $(a t.a) - :: :: || %check :: :: +| @@ -134,27 +98,17 @@ :: returns results. :: :: returns the test run's identity cookie and the list of failures. - |. ^- {@uvJ (list tape)} [eny error-lines] -- -- +-- +|% :: ---------------------------------------------------------------------- :: Eventually should be in %/test/basic/hoon. :: ---------------------------------------------------------------------- ++ test-core |_ tester-type:test-lib - ++ example-add - %- examples :~ - ['(add 2 2)' '4'] - ['(add 1 1.000.000)' '1.000.001'] - ['(add 1.333 (mul 2 2))' '1.337'] - == - ++ example-dec - %- examples :~ - ['(dec 7)' '6'] - ['(dec 0)' '~[[%leaf p="decrement-underflow"]]'] - == ++ check-decrement %+ check (generate-range 0 100) @@ -168,6 +122,8 @@ ++ test-crash !! -- +-- +|% :: ---------------------------------------------------------------------- :: Eventually should be in %/test/basic/hoon. :: ---------------------------------------------------------------------- @@ -202,6 +158,8 @@ [[1 2 ~] ["one" "two" ~]] "partition" -- +-- +|% ++ test-myb =, myb:new-hoon |_ tester-type:test-lib @@ -233,6 +191,8 @@ [2 2 ~] "map" -- +-- +|% ++ test-ls =, ls:new-hoon |_ tester-type:test-lib @@ -512,6 +472,8 @@ [6 6 8 ~] "intersect" -- +-- +|% ++ test-mp =, dct:new-hoon =+ four=(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] ~]) @@ -623,7 +585,7 @@ :: check random dicts of 50 items with 40 random operations done on them :: for validity. %+ check - (generate-dict 50) + (generate-dict 50) |= a/(dict @ud @ud) :: this is dumb, but use {a} as entropy? =/ gen (random:new-hoon (jam a)) @@ -871,6 +833,8 @@ %.y "valid" -- +-- +|% :: ---------------------------------------------------------------------- :: Stays in the generator. :: ---------------------------------------------------------------------- @@ -881,9 +845,7 @@ |= {name/tape v/vase eny/@uvJ} ^- tang =+ core-arms=(sort (sloe p.v) aor) - :: todo: work around mint-vain - =+ null-check=core-arms - ?~ null-check + ?: =(~ core-arms) [[%leaf :(weld "error: " name " is not a valid testing core.")] ~] =| out/tang |- @@ -928,14 +890,13 @@ :: appropriately. |= {arm-name/term v/vase eny/@uvJ} ^- (each {@uvJ (list tape)} (list tank)) - =/ t (init-test:test-lib eny) + =/ t (init-test-vase:test-lib eny) :: run the tests in the interpreter so we catch crashes. %- mule |. - :: ~(t v arm-name) - =/ r (slap (slop !>(t) v) [%cnsg [arm-name ~] [%$ 3] [[%$ 2] ~]]) + =/ r (slap (slop t v) [%cnsg [arm-name ~] [%$ 3] [[%$ 2] ~]]) :: return just the results or we will be here forever while we try to copy :: the entire kernel. - ((hard {@uvJ (list tape)}) q:(slym (slap r [%limb %results]) r)) + ((hard {@uvJ (list tape)}) q:(slap r [%limb %results])) -- :: ---------------------------------------------------------------------- -- From d0a0d6cf510af16f6fdfec83a1c7349fc72d74fd Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 15 Nov 2017 17:33:08 +0100 Subject: [PATCH 024/184] Expanded on existing Github code by adding commit and repository marks. --- lib/gh-parse.hoon | 37 +++++++++++++++++++++++++++++++++++++ mar/gh/commit.hoon | 11 +++++++++++ mar/gh/repository.hoon | 11 +++++++++++ sur/gh.hoon | 25 +++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 mar/gh/commit.hoon create mode 100644 mar/gh/repository.hoon diff --git a/lib/gh-parse.hoon b/lib/gh-parse.hoon index 025dcdbb7..6e07cc323 100644 --- a/lib/gh-parse.hoon +++ b/lib/gh-parse.hoon @@ -79,6 +79,19 @@ 'watchers'^ni 'default_branch'^so == +++ commit + ^- $-(json (unit commit:gh)) + =+ jo + %- ot :~ + 'sha'^so + 'url'^so + 'author'^author + 'committer'^author + 'message'^so + 'tree'^point + 'parents'^(ar point) + 'verification'^verification + == ++ user ^- $-(json (unit user:gh)) =+ jo @@ -128,6 +141,30 @@ 'closed_at'^(mu so) 'body'^so == +++ author + ^- $-(json (unit author:gh)) + =+ jo + %- ot :~ + 'date'^so + 'name'^so + 'email'^so + == +++ point + ^- $-(json (unit point:gh)) + =+ jo + %- ot :~ + 'url'^so + 'sha'^so + == +++ verification + ^- $-(json (unit verification:gh)) + =+ jo + %- ot :~ + 'verified'^bo + 'reason'^so + 'signature'^(mu so) + 'payload'^(mu so) + == ++ label ^- $-(json (unit label:gh)) =+ jo diff --git a/mar/gh/commit.hoon b/mar/gh/commit.hoon new file mode 100644 index 000000000..f64c0eac2 --- /dev/null +++ b/mar/gh/commit.hoon @@ -0,0 +1,11 @@ +/- gh +/+ gh-parse, httr-to-json, old-zuse +=, old-zuse +|_ commit/commit:gh +++ grab + |% + ++ noun commit:gh + ++ httr (cork httr-to-json json) + ++ json commit:gh-parse + -- +-- diff --git a/mar/gh/repository.hoon b/mar/gh/repository.hoon new file mode 100644 index 000000000..d8e5d505f --- /dev/null +++ b/mar/gh/repository.hoon @@ -0,0 +1,11 @@ +/- gh +/+ gh-parse, httr-to-json, old-zuse +=, old-zuse +|_ repo/repository:gh +++ grab + |% + ++ noun repository:gh + ++ httr (cork httr-to-json json) + ++ json repository:gh-parse + -- +-- diff --git a/sur/gh.hoon b/sur/gh.hoon index d76ee9461..2b7d9299e 100644 --- a/sur/gh.hoon +++ b/sur/gh.hoon @@ -77,6 +77,16 @@ watchers/@ud default-branch/@t == +++ commit + $: sha/@t + url/@t + author/author + committer/author + message/@t + tree/point + parents/(list point) + verification/verification + == ++ user $: login/@t id/id @@ -118,6 +128,21 @@ closed-at/(unit time) body/@t == +++ author + $: date/@t + name/@t + email/@t + == +++ point + $: url/@t + sha/@t + == +++ verification + $: verified/? + reason/@t + signature/(unit @t) + payload/(unit @t) + == ++ label $: url/@t name/@t From 05f803d96b69850696ddadf8383830bd94cbe8dd Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 15 Nov 2017 17:33:28 +0100 Subject: [PATCH 025/184] /mar/gh/issue can now convert from httr. --- mar/gh/issue.hoon | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mar/gh/issue.hoon b/mar/gh/issue.hoon index 84df6402a..5cb3df446 100644 --- a/mar/gh/issue.hoon +++ b/mar/gh/issue.hoon @@ -1,11 +1,13 @@ /- gh -/+ gh-parse, old-zuse +/+ gh-parse, httr-to-json, old-zuse =, mimes:html =, old-zuse |_ issue/issue:gh ++ grab |% ++ noun issue:gh + ++ httr (cork httr-to-json json) + ++ json issue:gh-parse -- ++ grow |% From 4029cc0bb132ffcea65fcbd1c865e659177eb0fd Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sun, 26 Nov 2017 15:41:49 -0800 Subject: [PATCH 026/184] Experiment moving the tests and tester into their own file. --- gen/test.hoon | 182 +++++------------------------------------------- lib/tester.hoon | 98 ++++++++++++++++++++++++++ tests/thr.hoon | 32 +++++++++ 3 files changed, 148 insertions(+), 164 deletions(-) create mode 100644 lib/tester.hoon create mode 100644 tests/thr.hoon diff --git a/gen/test.hoon b/gen/test.hoon index c8b2bbf7b..4f779aa1c 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -1,168 +1,22 @@ :: todo: think about using horns to import all tests in %/tests? -/+ new-hoon -|% -:: ---------------------------------------------------------------------- -:: Eventually should be in %/lib/tester/hoon. -:: ---------------------------------------------------------------------- -++ test-lib - |% - ++ init-test-vase - |= {cookie/@uvJ} - ^- vase - !>((init-test cookie)) - :: - ++ init-test - |= {cookie/@uvJ} - ~(. tester `(list tape)`~ cookie 10 0) - :: - ++ tester-type _(init-test `@uvJ`0) - :: - ++ tester - |_ $: error-lines/(list tape) :: output messages - eny/@uvJ :: entropy - check-iterations/@u :: # of check trials - current-iteration/@u :: current iteration - == - :: || %check - :: - :: +| - +- check - |* {generator/$-(@uvJ *) test/$-(* ?)} - |- :: why do i have to |-? - ^+ +>.$ - ?: (gth current-iteration check-iterations) - +>.$ - :: todo: wrap generator in mule so it can crash. - =+ sample=(generator eny) - :: todo: wrap test in mule so it can crash. - =+ ret=(test sample) - ?: ret - %= $ - eny (shaf %huh eny) :: xxx: better random? - current-iteration (add current-iteration 1) - == - =+ case=(add 1 current-iteration) - =+ case-plural=?:(=(case 1) "case" "cases") - %= +>.$ - error-lines :* - "falsified after {(noah !>(case))} {case-plural} by '{(noah !>(sample))}'" - error-lines - == - == - :: - :: todo: a generate function that takes an arbitrary span. - :: - ++ generate-range - |= {min/@ max/@} - |= c/@uvJ - ^- @ - =+ gen=(random:new-hoon c) - =^ num gen (range:gen min max) - num - :: - ++ generate-dict - :> generator which will produce a dict with {count} random pairs. - |= count/@u - :> generate a dict with entropy {c}. - |= c/@uvJ - =/ gen (random:new-hoon c) - =| i/@u - =| m/(dict:new-hoon @ud @ud) - |- - ^- (dict:new-hoon @ud @ud) - ?: =(i count) - m - =^ first gen (range:gen 0 100) - =^ second gen (range:gen 0 100) - $(m (put:dct:new-hoon m first second), i +(i)) - :: - :: || %test - :: - :: +| - :: todo: unit testing libraries have a lot more to them than just eq. - ++ expect-eq - |* {a/* b/* c/tape} - ^+ +> - ?: =(a b) - +>.$ - %= +>.$ - error-lines :* - "failure: '{c}'" - " actual: '{(noah !>(a))}'" - " expected: '{(noah !>(b))}'" - error-lines - == - == - :: - ++ results - :: returns results. - :: - :: returns the test run's identity cookie and the list of failures. - ^- {@uvJ (list tape)} - [eny error-lines] - -- - -- --- -|% +:: +:: i should be able to use /: ? +/+ new-hoon, tester + +:: random thought: should I lift most of test execution into the build system? +:: trade off: if you do a wide ranging change and then only want to run one +:: test, you must pay the execution time for all tests, while otherwise, you +:: only pay the compile time. +// /===/tests/thr +[test-thr=. +] + :: ---------------------------------------------------------------------- :: Eventually should be in %/test/basic/hoon. :: ---------------------------------------------------------------------- -++ test-core - |_ tester-type:test-lib - ++ check-decrement - %+ check - (generate-range 0 100) - |=(a/@ =(a (dec (add 2 a)))) - ++ test-decrement - (expect-eq (dec 5) 4 "decrement failure") - ++ test-freedom - (expect-eq (add 2 2) 4 "freedom is the freedom to say...") - ++ test-a-failure - (expect-eq (add 2 2) 5 "freedom is the freedom to say...") - ++ test-crash - !! - -- --- -|% -:: ---------------------------------------------------------------------- -:: Eventually should be in %/test/basic/hoon. -:: ---------------------------------------------------------------------- -++ test-thr - =, thr:new-hoon - =/ data/(list (either @u tape)) [[%& 1] [%| "one"] [%& 2] [%| "two"] ~] - |_ tester-type:test-lib - ++ test-apply - %^ expect-eq - %^ apply - `(either @u tape)`[%| "one"] - |=(a/@u "left") - |=(b/tape "right") - "right" - "apply" - :: - ++ test-firsts - %^ expect-eq - (firsts data) - [1 2 ~] - "firsts" - :: - ++ test-seconds - %^ expect-eq - (seconds data) - ["one" "two" ~] - "seconds" - :: - ++ test-partition - %^ expect-eq - (partition data) - [[1 2 ~] ["one" "two" ~]] - "partition" - -- --- |% ++ test-myb =, myb:new-hoon - |_ tester-type:test-lib + |_ tester-type:tester ++ test-from-list-null (expect-eq (from-list ~) ~ "from-list") :: @@ -195,7 +49,7 @@ |% ++ test-ls =, ls:new-hoon - |_ tester-type:test-lib + |_ tester-type:tester ++ test-head (expect-eq (head [1 ~]) 1 "head") :: @@ -478,7 +332,7 @@ =, dct:new-hoon =+ four=(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] ~]) =+ three=(from-list [[1 "one"] [2 "two"] [3 "three"] ~]) - |_ tester-type:test-lib + |_ tester-type:tester ++ test-empty (expect-eq (empty four) %.n "empty") :: @@ -846,6 +700,7 @@ ^- tang =+ core-arms=(sort (sloe p.v) aor) ?: =(~ core-arms) + ~& p.v [[%leaf :(weld "error: " name " is not a valid testing core.")] ~] =| out/tang |- @@ -890,7 +745,7 @@ :: appropriately. |= {arm-name/term v/vase eny/@uvJ} ^- (each {@uvJ (list tape)} (list tank)) - =/ t (init-test-vase:test-lib eny) + =/ t (init-test-vase:tester eny) :: run the tests in the interpreter so we catch crashes. %- mule |. =/ r (slap (slop t v) [%cnsg [arm-name ~] [%$ 3] [[%$ 2] ~]]) @@ -908,8 +763,7 @@ :- %tang :: todo: right now, we hard code ++test-core. but eventually, we must instead :: scry ford for the core from the hoon file. that doesn't exist yet. -::(perform-test-suite:local "test-core" !>(test-core) eny) -::(perform-test-suite:local "test-thr" !>(test-thr) eny) +(perform-test-suite:local "test-thr" !>(test-thr) eny) ::(perform-test-suite:local "test-myb" !>(test-myb) eny) -(perform-test-suite:local "test-ls" !>(test-ls) eny) +::(perform-test-suite:local "test-ls" !>(test-ls) eny) ::(perform-test-suite:local "test-mp" !>(test-mp) eny) diff --git a/lib/tester.hoon b/lib/tester.hoon new file mode 100644 index 000000000..5dd0e2138 --- /dev/null +++ b/lib/tester.hoon @@ -0,0 +1,98 @@ +:: common testing library. +|% +++ init-test-vase + |= {cookie/@uvJ} + ^- vase + !>((init-test cookie)) +:: +++ init-test + |= {cookie/@uvJ} + ~(. tester `(list tape)`~ cookie 10 0) +:: +++ tester-type _(init-test `@uvJ`0) +:: +++ tester + |_ $: error-lines/(list tape) :: output messages + eny/@uvJ :: entropy + check-iterations/@u :: # of check trials + current-iteration/@u :: current iteration + == + :: || %check + :: + :: +| + +- check + |* {generator/$-(@uvJ *) test/$-(* ?)} + |- :: why do i have to |-? + ^+ +>.$ + ?: (gth current-iteration check-iterations) + +>.$ + :: todo: wrap generator in mule so it can crash. + =+ sample=(generator eny) + :: todo: wrap test in mule so it can crash. + =+ ret=(test sample) + ?: ret + %= $ + eny (shaf %huh eny) :: xxx: better random? + current-iteration (add current-iteration 1) + == + =+ case=(add 1 current-iteration) + =+ case-plural=?:(=(case 1) "case" "cases") + %= +>.$ + error-lines :* + "falsified after {(noah !>(case))} {case-plural} by '{(noah !>(sample))}'" + error-lines + == + == + :: + :: todo: a generate function that takes an arbitrary span. + :: + ++ generate-range + |= {min/@ max/@} + |= c/@uvJ + ^- @ + =+ gen=(random:new-hoon c) + =^ num gen (range:gen min max) + num + :: + ++ generate-dict + :> generator which will produce a dict with {count} random pairs. + |= count/@u + :> generate a dict with entropy {c}. + |= c/@uvJ + =/ gen (random:new-hoon c) + =| i/@u + =| m/(dict:new-hoon @ud @ud) + |- + ^- (dict:new-hoon @ud @ud) + ?: =(i count) + m + =^ first gen (range:gen 0 100) + =^ second gen (range:gen 0 100) + $(m (put:dct:new-hoon m first second), i +(i)) + :: + :: || %test + :: + :: +| + :: todo: unit testing libraries have a lot more to them than just eq. + ++ expect-eq + |* {a/* b/* c/tape} + ^+ +> + ?: =(a b) + +>.$ + %= +>.$ + error-lines :* + "failure: '{c}'" + " actual: '{(noah !>(a))}'" + " expected: '{(noah !>(b))}'" + error-lines + == + == + :: + ++ results + :: returns results. + :: + :: returns the test run's identity cookie and the list of failures. + ^- {@uvJ (list tape)} + [eny error-lines] + -- +-- diff --git a/tests/thr.hoon b/tests/thr.hoon new file mode 100644 index 000000000..a17cf67a9 --- /dev/null +++ b/tests/thr.hoon @@ -0,0 +1,32 @@ +:: tests for the either core. +/+ new-hoon, tester +=, thr:new-hoon +=/ data/(list (either @u tape)) [[%& 1] [%| "one"] [%& 2] [%| "two"] ~] +|_ tester-type:tester +++ test-apply + %^ expect-eq + %^ apply + `(either @u tape)`[%| "one"] + |=(a/@u "left") + |=(b/tape "right") + "right" + "apply" +:: +++ test-firsts + %^ expect-eq + (firsts data) + [1 2 ~] + "firsts" +:: +++ test-seconds + %^ expect-eq + (seconds data) + ["one" "two" ~] + "seconds" +:: +++ test-partition + %^ expect-eq + (partition data) + [[1 2 ~] ["one" "two" ~]] + "partition" +-- From 97fd7b1ac5f1948817ec87312ed11cc763b23464 Mon Sep 17 00:00:00 2001 From: Joseph Bryan Date: Fri, 3 Mar 2017 14:56:06 -0500 Subject: [PATCH 027/184] updates ++boil:ap to crash if a book has pages with the same tag --- sys/hoon.hoon | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index a173a3ce1..5beecf8fb 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -6772,12 +6772,21 @@ [%axil %void] ?~ t.p.gen boil(gen i.p.gen) - =+ :* def=bile(gen i.p.gen) - ^= end ^- (list line) - ~_ leaf+"book-foul" - %+ turn `(list hoon)`t.p.gen - |=(a/hoon =+(bile(gen a) ?>(?=($& -<) ->))) - == + =/ def bile(gen i.p.gen) + =| tag/(set term) + =? tag ?=($& -.def) (~(put in tag) `@tas`q.p.p.def) + =/ end + =| lit/(list line) + |- ^+ lit + =/ tar bile(gen i.t.p.gen) + ?. ?=($& -.tar) + ~_(leaf+"book-foul" !!) + =/ hed `@tas`q.p.p.tar + ?: (~(has in tag) hed) + ~_(leaf+"book-dup-page: {}" !!) + =. lit [+.tar lit] + ?~ t.t.p.gen lit + $(tag (~(put in tag) hed), t.p.gen t.t.p.gen) ?- -.def $& [%kelp p.def end] $| ?~(end p.def [%fern p.def [%kelp end] ~]) From 264f1bcacc09fb3904712539774bf8f14d6630e7 Mon Sep 17 00:00:00 2001 From: Joseph Bryan Date: Thu, 30 Nov 2017 19:48:41 -0500 Subject: [PATCH 028/184] restructures ++sign:able:xmas to avoid duplicate tag --- sys/zuse.hoon | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/zuse.hoon b/sys/zuse.hoon index ec8fef14f..432561b21 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -1165,9 +1165,10 @@ $% {$west p/ship q/path r/*} :: network request == :: ++ sign :: in response $-< - $% {$g $rend p/path q/*} :: network request - {$g $mack p/(unit tang)} :: message ack - == :: + $: $g :: + $% {$rend p/path q/*} :: network request + {$mack p/(unit tang)} :: message ack + == == :: ++ note :: out request $-> $% {$c $west p/ship q/path r/*} :: to %clay {$e $west p/ship q/path r/*} :: to %eyre From dd3a6c3066e7dfe57d1b09501b5f559794295504 Mon Sep 17 00:00:00 2001 From: Joseph Bryan Date: Wed, 19 Jul 2017 16:47:25 -0400 Subject: [PATCH 029/184] update :twit ++peek interface, fixes bugs in :twit|as and +twit/feed --- app/twit.hoon | 20 ++++++++++---------- gen/twit/as.hoon | 2 +- gen/twit/feed.hoon | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/twit.hoon b/app/twit.hoon index 450b6c638..0dbaa4726 100644 --- a/app/twit.hoon +++ b/app/twit.hoon @@ -29,7 +29,7 @@ $% {$quit $~} :: terminate {$diff gilt} :: send data == -++ gilt +++ gilt $% {$twit-feed p/(list stat)} :: posts in feed {$twit-post p/stat} :: tweet accepted {$ares term (list tank)} :: error @@ -97,7 +97,7 @@ |= {pax/path mof/(list move)} ^+ done =^ tym ran (dely pax) :_ +>.$ - ?~ tym + ?~ tym :: ~& no-wait/ran mof :: ~& will-wait/u.tym @@ -124,7 +124,7 @@ pus=(~(gas ju *(jug path bone)) (turn ~(tap by sup) .)) ?~ (~(get ju pus) pax) ~ - ~& peer-again+[pax ran] + ~& peer-again+[pax ran] (pear | `~. pax) ::(user-from-path pax)) :: ++ sigh-recoverable-error :: Rate-limit @@ -195,11 +195,11 @@ |= {usr/(unit user:eyre) req/(unit user:eyre)} ?~(req & =(usr req)) :: -:: .^(twit-feed %gx /=twit=/~/home/urbit_test) -:: .^(twit-stat %gx /=twit=/~./post/0vv0old.0post.hash0.0000) -++ peek - |= {ren/care:clay pax/path} ^- (unit (unit gilt)) - ?> ?=($x ren) :: others unsupported +:: /+ twitter +:: .^((list post:twitter) %gx /=twit=/home/urbit_test/twit-feed) +:: .^(post:twitter %gx /=twit=/post/0vv0old.0post.hash0.0000/twit-feed) +++ peek-x + |= pax/path ^- (unit (unit gilt)) =+ usr=`~. :: =^ usr pax (user-from-path pax) ?. ?=(twit-path pax) ~|([%missed-path pax] !!) @@ -213,7 +213,7 @@ ++ peer-scry-x |= pax/path ^+ done :_ +> - =+ pek=(peek %x pax) + =+ pek=(peek-x pax) ?^ pek ?~ u.pek ~|(bad-scry+x+pax !!) ~[[ost %diff u.u.pek] [ost %quit ~]] @@ -223,7 +223,7 @@ =+ hiz=(pear-hiss pax) ?~ hiz ~ :: already in flight ::?> (compat usr -.u.hiz) :: XX better auth - [ost %hiss scry+pax usr +.u.hiz]~ + [ost %hiss scry+pax usr +.u.hiz]~ :: ++ peer |=(pax/path :_(+> (pear & `~. pax))) :: accept subscription ++ pear :: poll, possibly returning current data diff --git a/gen/twit/as.hoon b/gen/twit/as.hoon index 1cfb39bc4..1d48ec8de 100644 --- a/gen/twit/as.hoon +++ b/gen/twit/as.hoon @@ -11,4 +11,4 @@ |= $: {now/@da eny/@uvJ bec/beak} {{who/knot msg/cord $~} $~} == -[%twit-do [who %post eny msg]] +[%twit-do [who %post `@uvI`(rsh 8 1 eny) msg]] diff --git a/gen/twit/feed.hoon b/gen/twit/feed.hoon index a22ce7a00..f3aaf966f 100644 --- a/gen/twit/feed.hoon +++ b/gen/twit/feed.hoon @@ -13,7 +13,7 @@ |= $: {now/@da eny/@uvJ bek/beak} {{who/iden $~} typ/?($user $home)} == -=+ pax=/(scot %p p.bek)/twit/(scot %da now)/[typ]/[who] +=+ pax=/(scot %p p.bek)/twit/(scot %da now)/[typ]/[who]/twit-feed :- %tang %+ turn (flop .^((list post:twitter) %gx pax)) |= post:twitter ^- tank From 713efa46846283b239be32c14344aadff428cfe4 Mon Sep 17 00:00:00 2001 From: Joseph Bryan Date: Thu, 20 Jul 2017 17:20:56 -0400 Subject: [PATCH 030/184] fixes newline parsing bug in lib/twitter --- lib/twitter.hoon | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/twitter.hoon b/lib/twitter.hoon index 83d71e263..547541584 100644 --- a/lib/twitter.hoon +++ b/lib/twitter.hoon @@ -20,7 +20,7 @@ |= {a/char b/(list @t)} ^- @t %+ rap 3 ?~ b ~ - |-(?~(t.b b [i.b a $(b t.b)])) + |-(?~(t.b b [i.b a $(b t.b)])) :: ++ valve :: produce request |= {med/?($get $post) pax/path quy/quay} @@ -87,9 +87,10 @@ :~ id+ni user+(ot (fasp screen-name+(su user)) ~) (fasp created-at+(cu year (ci stud so))) - text+(cu crip (su (star escp:de-xml))) :: parse html escapes + :: parse html escapes and newlines + text+(cu crip (su (star ;~(pose (just `@`10) escp:de-xml)))) == - ++ usel + ++ usel =, ^?(dejs) %+ ce (list who/@ta) =- (ot users+(ar -) ~) @@ -119,12 +120,12 @@ (valve med (cowl pax +.a b)) :: ++ lutt |=(@u `@t`(rsh 3 2 (scot %ui +<))) - ++ llsc + ++ llsc :: => args:reqs |= a/$@(scr (list scr)) ^- @t ?@(a `@t`a (join ',' a)) :: - ++ llst + ++ llst |= a/$@(@t (list @t)) ^- @t ?@(a `@t`a (join ',' a)) :: @@ -135,7 +136,7 @@ ?@(a (lutt a) (join ',' (turn `(list tid)`a lutt))) :: ++ cowl :: handle parameters - |= $: pax/path + |= $: pax/path ban/(list param) quy/quay == From f2928f52125550afec4e3b217d52fcc9b952702b Mon Sep 17 00:00:00 2001 From: Joseph Bryan Date: Tue, 5 Dec 2017 21:12:16 -0500 Subject: [PATCH 031/184] corrects typo in oauth content-type header --- lib/oauth1.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oauth1.hoon b/lib/oauth1.hoon index de2714b4a..35a47dc90 100644 --- a/lib/oauth1.hoon +++ b/lib/oauth1.hoon @@ -55,7 +55,7 @@ |= {a/purl b/quay} ^- hiss =. b (quay:hep-to-cab b) =- [a %post - ?~(b ~ (some (as-octt +:(tail:en-purl:html b))))] - (my content-type+['application/x-www-form-en-urlt:htmlncoded']~ ~) + (my content-type+['application/x-www-form-urlencoded']~ ~) :: :: ++ mean-wall !. From 5a412016dbd2950a6a8b1d23b288bc331f77bf4d Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 8 Dec 2017 15:56:33 -0800 Subject: [PATCH 032/184] use github .deb release instead of pinned CI binary --- .travis.yml | 9 +++------ .travis/get-or-build-pill.sh | 2 +- .travis/pin-urbit-release.url | 1 - .travis/test.ls | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) delete mode 100644 .travis/pin-urbit-release.url diff --git a/.travis.yml b/.travis.yml index 0c4d36153..562205f66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,10 @@ language: node_js # ish, mainly used as an entry point node_js: - 4 before_install: - - cd .travis # keep main directory clear + - wget https://github.com/urbit/urbit/releases/download/v0.5.1/urbit_0.5-1_amd64.deb + - sudo apt install ./urbit_0.5-1_amd64.deb - - > - wget $(cat ./pin-urbit-release.url)/urbit -O ./urbit && - chmod +x ./urbit; - echo "FIXME downloaded raw urbit binary releaseinstead of .deb"; - echo "FIXME used full pinned url instead of tag name" + - cd .travis # keep main directory clear before_script: bash get-or-build-pill.sh diff --git a/.travis/get-or-build-pill.sh b/.travis/get-or-build-pill.sh index 76b9d78d8..f5ad1df57 100644 --- a/.travis/get-or-build-pill.sh +++ b/.travis/get-or-build-pill.sh @@ -45,7 +45,7 @@ do require! <[ stream-snitch once recursive-copy wait-on ]> pty = require \pty.js - urbit = pty.spawn './urbit' <[-FI zod prev/zod]> + urbit = pty.spawn 'urbit' <[-FI zod prev/zod]> .on \data -> process.stdout.write it on-next = (re,cb)-> diff --git a/.travis/pin-urbit-release.url b/.travis/pin-urbit-release.url deleted file mode 100644 index 9ff2d562b..000000000 --- a/.travis/pin-urbit-release.url +++ /dev/null @@ -1 +0,0 @@ -https://github.com/urbit/urbit/releases/download/redefault-0.5.1 diff --git a/.travis/test.ls b/.travis/test.ls index 016773b07..6836ceab1 100644 --- a/.travis/test.ls +++ b/.travis/test.ls @@ -3,7 +3,7 @@ pty = require \pty.js urbit = # TODO abort on failure - pty.spawn './urbit' <[-B urbit.pill -A .. -cFI zod zod]> + pty.spawn 'urbit' <[-B urbit.pill -A .. -cFI zod zod]> .on \data -> process.stdout.write it urbit.on \exit (code)-> From 9ca88b9a06c3df359a9c58643adf70b33c0f1cc3 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 8 Dec 2017 16:08:29 -0800 Subject: [PATCH 033/184] move .deb download to .travis so it doesn't get synced in --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 562205f66..ad3883422 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,11 @@ language: node_js # ish, mainly used as an entry point node_js: - 4 before_install: + - cd .travis # keep main directory clear + - wget https://github.com/urbit/urbit/releases/download/v0.5.1/urbit_0.5-1_amd64.deb - sudo apt install ./urbit_0.5-1_amd64.deb - - cd .travis # keep main directory clear before_script: bash get-or-build-pill.sh From 93794ce853cd575a944c0a01d32df9b193d6139a Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 11 Dec 2017 23:18:37 +0100 Subject: [PATCH 034/184] Revert talk's ++prep back to normal. --- app/talk.hoon | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 5983323da..cdba5c834 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -118,12 +118,6 @@ ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - =* o u.old - =. count.o (lent grams.o) - =+ %+ reel grams.o - |= {t/telegram c/@ud k/(map serial @ud)} - [+(c) (~(put by k) uid.t c)] - =. known.o k [~ ..prep(+<+ u.old)] :: ::> || From 5147d7de48e31a836d61eadd737215035d027d82 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 11 Dec 2017 18:26:44 -0800 Subject: [PATCH 035/184] send real &womb-invite's from :ask "reference" field was missing --- app/ask.hoon | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/ask.hoon b/app/ask.hoon index 8d390342c..dba60eb13 100644 --- a/app/ask.hoon +++ b/app/ask.hoon @@ -7,7 +7,7 @@ |% ++ card $% {$diff $sole-effect sole-effect} - {$poke wire {ship $hood} $womb-invite {cord:hood-womb invite:hood-womb}} + {$poke wire {ship $hood} $womb-invite ,=,(hood-womb {cord reference invite})} == ++ invited ?($new $sent $ignored) ++ email @t @@ -154,7 +154,8 @@ ^- card :^ %poke /invite/(scot %t ask) [(need wom) %hood] :- %womb-invite - ^- [cord:hood-womb invite:hood-womb] + =, hood-womb + ^- [cord reference invite] =+ inv=(scot %uv (end 7 1 eny.bow)) - [inv [ask 1 0 "You have been invited to Urbit: {(trip inv)}" ""]] + [inv ~ [ask 1 0 "You have been invited to Urbit: {(trip inv)}" ""]] -- From 77d03383b4688c46b374de89022157e3199891f1 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 12 Dec 2017 13:58:02 +0100 Subject: [PATCH 036/184] Hall can now perform customizable filtering on incoming messages. Uses a `|=(telegram ...)` supplied by /app/hall/filter.hoon --- app/hall.hoon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/hall.hoon b/app/hall.hoon index 0e8096dfa..b13d5ed5e 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -11,6 +11,11 @@ /- hall :: structures /+ hall, hall-legacy :: libraries /= seed /~ !>(.) +/= filter-gram + /^ $-(telegram:hall telegram:hall) + /| /: /%/filter /!noun/ + /~ |=(t/telegram:hall t) + == :: :::: :: @@ -1292,6 +1297,7 @@ ?. (so-admire aut.gam) +> :: clean up the message to conform to our rules. =. sep.gam (so-sane sep.gam) + =. gam (filter-gram gam) :: if we already have it, ignore. =+ old=(~(get by known) uid.gam) ?. &(?=(^ old) =(gam (snag u.old grams))) From 627c94a9b79c6a65ee334a467ee7f89338fbd5a0 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 12 Dec 2017 16:04:51 +0100 Subject: [PATCH 037/184] Fix #479 for people who are experiencing it. --- app/talk.hoon | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index cdba5c834..f0ee9ddf2 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -63,6 +63,7 @@ $% {$diff lime} :: {$poke wire dock pear} :: {$peer wire dock path} :: + {$pull wire dock $~} :: == :: ++ work ::> interface action $% :: circle management :: @@ -118,7 +119,8 @@ ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - [~ ..prep(+<+ u.old)] + :_ ..prep(+<+ u.old) + [[ost.bol %pull / server ~] ~] :: ::> || ::> || %utility From c5ea0cc028fb6186c1e3d20046b9fc3c0c0772db Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 12 Dec 2017 16:54:33 +0100 Subject: [PATCH 038/184] Expand filter with bowl data. --- app/hall.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index b13d5ed5e..2c217c593 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -12,9 +12,9 @@ /+ hall, hall-legacy :: libraries /= seed /~ !>(.) /= filter-gram - /^ $-(telegram:hall telegram:hall) + /^ $-({telegram:hall bowl:gall} telegram:hall) /| /: /%/filter /!noun/ - /~ |=(t/telegram:hall t) + /~ |=({t/telegram:hall bowl:gall} t) == :: :::: @@ -1297,7 +1297,7 @@ ?. (so-admire aut.gam) +> :: clean up the message to conform to our rules. =. sep.gam (so-sane sep.gam) - =. gam (filter-gram gam) + =. gam (filter-gram gam bol) :: if we already have it, ignore. =+ old=(~(get by known) uid.gam) ?. &(?=(^ old) =(gam (snag u.old grams))) From 2b1caa2b01fb3bd19c657f990b7b627b711d557b Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 12 Dec 2017 21:23:00 +0100 Subject: [PATCH 039/184] Add generators for easier webship ops. --- app/hood.hoon | 2 ++ gen/hood/tlon/add-stream.hoon | 9 +++++++++ gen/hood/tlon/init-web.hoon | 9 +++++++++ lib/hood/helm.hoon | 35 ++++++++++++++++++++++++++++++++++- 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 gen/hood/tlon/add-stream.hoon create mode 100644 gen/hood/tlon/init-web.hoon diff --git a/app/hood.hoon b/app/hood.hoon index 0dfdbd226..5e6e3a869 100644 --- a/app/hood.hoon +++ b/app/hood.hoon @@ -164,6 +164,8 @@ ++ poke-helm-nuke (wrap poke-nuke):from-helm ++ poke-helm-begin (wrap poke-begin):from-helm ++ poke-helm-spawn (wrap poke-spawn):from-helm +++ poke-helm-tlon-add-stream (wrap poke-tlon-add-stream):from-helm +++ poke-helm-tlon-init-web (wrap poke-tlon-init-web):from-helm ++ poke-hood-sync (wrap poke-sync):from-kiln ++ poke-hood-init-sync (wrap poke-init-sync):from-kiln ++ poke-kiln-commit (wrap poke-commit):from-kiln diff --git a/gen/hood/tlon/add-stream.hoon b/gen/hood/tlon/add-stream.hoon new file mode 100644 index 000000000..5bb110998 --- /dev/null +++ b/gen/hood/tlon/add-stream.hoon @@ -0,0 +1,9 @@ +:: tlon: add stream to local urbit-meta +:: +:::: /gen/hood/tlon/add-stream/hoon + :: +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + {{web/ship $~} $~} + == +[%helm-tlon-add-stream web] diff --git a/gen/hood/tlon/init-web.hoon b/gen/hood/tlon/init-web.hoon new file mode 100644 index 000000000..8cf44c1f7 --- /dev/null +++ b/gen/hood/tlon/init-web.hoon @@ -0,0 +1,9 @@ +:: tlon: configure web ship +:: +:::: /gen/hood/tlon/init-web/hoon + :: +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + {{met/ship $~} $~} + == +[%helm-tlon-init-web met] diff --git a/lib/hood/helm.hoon b/lib/hood/helm.hoon index 9ae46687a..fd5e3584e 100644 --- a/lib/hood/helm.hoon +++ b/lib/hood/helm.hoon @@ -2,7 +2,7 @@ :::: /hoon/helm/hood/lib :: :: :: :: :: /? 310 :: version -/- sole +/- sole, hall [. sole] :: :: :: :::: :: :: @@ -60,6 +60,8 @@ $% {$hood-unsync desk ship desk} :: {$ask-mail cord} :: {$helm-hi cord} :: + {$drum-start well:gall} :: + {$hall-action action:hall} :: == :: -- |_ moz/(list move) @@ -238,4 +240,35 @@ ++ take-woot :: result of %want |= {way/wire her/ship cop/coop} =< abet (emit %flog ~ %text "woot: {<[way cop]>}") +:: +++ poke-tlon-init-web + |= met/ship =< abet + %- emil + %- flop + :~ ^- card + :^ %poke /helm/web/fora [our %hood] + [%drum-start q.byk %fora] + :: + :^ %poke /helm/web/stream/create [our %hall] + :- %hall-action + :- %create + [%stream 'stream relay channel' %channel] + :: + :^ %poke /helm/web/stream/filter [our %hall] + :- %hall-action + :- %filter + [%stream | |] + :: + :^ %poke /helm/web/stream/source [our %hall] + :- %hall-action + :- %source + [%stream & [[[met %urbit-meta] `[da+(sub now ~d1) ~]] ~ ~]] + == +:: +++ poke-tlon-add-stream + |= web/ship =< abet + %- emit + :^ %poke /helm/web/stream/source [our %hall] + :+ %hall-action %source + [%urbit-meta & [[[web %stream] `[da+now ~]] ~ ~]] -- From 0f63eda82a86730e0b32146a07858e2052d9583a Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 12 Dec 2017 22:28:56 +0100 Subject: [PATCH 040/184] More succinct source range parsing. --- lib/hall-json.hoon | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/hall-json.hoon b/lib/hall-json.hoon index 78065687c..c8484fe7f 100644 --- a/lib/hall-json.hoon +++ b/lib/hall-json.hoon @@ -31,29 +31,20 @@ ++ circ ::> circle ;~((glue fas) ;~(pfix sig fed:ag) urt:ab) :: - ++ rang ::> range - =/ pont - ;~ pose - (stag %ud dim:ag) - %+ stag %da - %+ sear - |= a/coin - ^- (unit @da) - ?. ?=({$$ $da @da} a) ~ - `q.p.a - nuck:so - == - =+ ;~ pose - (cook some ;~(pfix fas pont)) - (easy ~) + ++ pont + ;~ pfix fas + %+ sear + |= a/coin + ^- (unit place) + ?+ a ~ + {$$ $da @da} `p.a + {$$ $ud @ud} `p.a == - ;~ pose - (cook some ;~(plug ;~(pfix fas pont) -)) - (easy ~) + nuck:so == :: - ++ sorc ::> source - ;~(plug circ rang) + ++ sorc + ;~(plug circ (punt ;~(plug pont (punt pont)))) -- :: ++ enjs ::> sur to json From c70035af84e6d36d8b14f8f4a534146656b8ba01 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 12 Dec 2017 22:34:04 +0100 Subject: [PATCH 041/184] Rename ++our to ++self. --- app/talk.hoon | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 5983323da..3efe4c161 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -132,12 +132,12 @@ ::> small utility functions. ::+| :: -++ our +++ self (true-self our.bol) :: ++ server ::< our hall instance ^- dock - [our %hall] + [self %hall] :: ++ inbox ::< client's circle name ::> produces the name of the circle used by this @@ -148,7 +148,7 @@ ++ incir ::< client's circle ::> ++inbox, except a full circle. ^- circle - [our inbox] + [self inbox] :: ++ renum ::< gram i# by serial ::> find the grams list index for gram with serial. @@ -600,8 +600,8 @@ ++ circ ::< circle ;~ pose (cold incir col) - ;~(pfix cen (stag our sym)) - ;~(pfix fas (stag (sein:title our) sym)) + ;~(pfix cen (stag self sym)) + ;~(pfix fas (stag (sein:title self) sym)) :: %+ cook |= {a/@p b/(unit term)} @@ -1036,7 +1036,7 @@ :: ^- vase !> ^- {our/@p now/@da eny/@uvI} - [our now.bol (shas %eny eny.bol)] + [self now.bol (shas %eny eny.bol)] :: ::> || ::> || %circle-management @@ -1074,7 +1074,7 @@ ^+ ..sh-work =. ..sh-work (sh-act %create nom txt sec) - (join [[[our nom] ~] ~ ~]) + (join [[[self nom] ~] ~ ~]) :: ++ delete ::< %delete ::> deletes our circle {nom}, after optionally @@ -1576,7 +1576,7 @@ ?~ lis +>.$ %+ sh-fact %mor %+ turn `(list tape)`lis - =+ nom=(scag 7 (cite:title our)) + =+ nom=(scag 7 (cite:title self)) |= t/tape ?. ?& (~(has in settings.she) %notify) ?=(^ (find nom (slag 15 t))) @@ -1733,8 +1733,8 @@ |= two/circle ^- ? :: the circle that's ours is better. - ?: =(our hos.one) - ?. =(our hos.two) & + ?: =(self hos.one) + ?. =(self hos.two) & ?< =(nom.one nom.two) :: if both circles are ours, the main story is better. ?: =(%inbox nom.one) & @@ -1742,7 +1742,7 @@ :: if neither are, pick the "larger" one. (lth nom.one nom.two) :: if one isn't ours but two is, two is better. - ?: =(our hos.two) | + ?: =(self hos.two) | ?: =(hos.one hos.two) :: if they're from the same ship, pick the "larger" one. (lth nom.one nom.two) @@ -1793,14 +1793,14 @@ ::> "/channel" for parent circle. :: ^- tape - ?: =(hos.one our) + ?: =(hos.one self) ?: =(nom.one inbox) ":" ['%' (trip nom.one)] =+ wun=(cite:title hos.one) ?: =(nom.one %inbox) wun - ?: =(hos.one (sein:title our)) + ?: =(hos.one (sein:title self)) ['/' (trip nom.one)] :(welp wun "/" (trip nom.one)) :: @@ -1892,7 +1892,7 @@ ::> returns true if circle is a mailbox of ours. :: |= cir/circle ^- ? - ?& =(hos.cir our) + ?& =(hos.cir self) =+ sot=(~(get by mirrors) cir) &(?=(^ sot) ?=($mailbox sec.con.u.sot)) == @@ -2132,7 +2132,7 @@ ?: pat.sep " " =- (weld - q:(fall pre [p=| q=" "])) %~ ar-glyf ar - ?: =(who our) aud + ?: =(who self) aud (~(del in aud) [who %inbox]) == =. wyd (sub wyd (min (div wyd 2) (lent pef))) From 12262410c448bcdefe15ef1731f4ec1038685f77 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 13 Dec 2017 02:08:52 +0100 Subject: [PATCH 042/184] Work around runtime error caused by _example behavior. --- app/hall.hoon | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 0e8096dfa..8eda9ef23 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -345,9 +345,16 @@ |= {c/circle m/(jug ship naem)} (~(put ju m) hos.c nom.c) =? ..ta-action (~(has by cic) our.bol) - %- ~(rep in (~(get ju cic) our.bol)) - |= {n/naem _ta} :: beware, urbit/arvo#447 - (affect n %status [our.bol n] our.bol dif) + =+ nos=~(tap in (~(get ju cic) our.bol)) + |- ^+ ..ta-action + ?~ nos ..ta-action + =. ..ta-action + (affect i.nos %status [our.bol i.nos] our.bol dif) + $(nos t.nos) + ::TODO runtime error + ::%- ~(rep in (~(get ju cic) our.bol)) + ::|= {n/naem _ta} :: beware, urbit/arvo#447 + ::(affect n %status [our.bol n] our.bol dif) =. cic (~(del by cic) our.bol) %- ta-deltas %- ~(rep by cic) From 032132252a352aa532001bef80baccb868d3b9bb Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 13 Dec 2017 15:32:09 +0100 Subject: [PATCH 043/184] Add debug printfs to generic ++quit arm in hall --- app/hall.hoon | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/hall.hoon b/app/hall.hoon index 8eda9ef23..ed22c6575 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2620,7 +2620,10 @@ |= wir/wire ^- (quip move _+>) :_ +> - ?. =(src.bol our.bol) ~ + ?. =(src.bol our.bol) + ~& [%kicked-by src.bol wir] + ~ + ~& [%self-quit--resubbing wir] [(wire-to-peer wir) ~] :: ++ quit-circle From 9cd3a41a16ef5f002548672003218b2903669794 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 00:05:39 +0100 Subject: [PATCH 044/184] Always attempt to resubscribe on ++quit. --- app/hall.hoon | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index ed22c6575..8bf68deba 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2619,12 +2619,7 @@ :: |= wir/wire ^- (quip move _+>) - :_ +> - ?. =(src.bol our.bol) - ~& [%kicked-by src.bol wir] - ~ - ~& [%self-quit--resubbing wir] - [(wire-to-peer wir) ~] + [[(wire-to-peer wir) ~] +>] :: ++ quit-circle :> dropped circle sub @@ -2636,9 +2631,6 @@ %+ etch-circle [%circle wir] |= {nom/naem src/source} %- pre-bake - :: when we got kicked, don't resub, remove source. - ?. =(src.bol our.bol) - ta-done:(ta-action:ta %source nom | [src ~ ~]) ta-done:(ta-resub:ta nom src) :: ++ coup-repeat From 1e82b54c8555a424558a6a93c1ad380cb2c0d024 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 00:07:35 +0100 Subject: [PATCH 045/184] Pretty-print peer and poke nacks as hall messages. --- app/hall.hoon | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 8bf68deba..cd3890d19 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -174,13 +174,27 @@ |= des/(list delta) %_(+> deltas (welp (flop des) deltas)) :: - ++ ta-note - :> sends {msg} as an %app message to the user's inbox. + ++ ta-speak + :> sends {sep} as an %app message to the user's inbox. :: - |= msg/tape + |= sep/speech %+ ta-action %phrase :- [[our.bol %inbox] ~ ~] - [%app dap.bol %lin | (crip msg)]~ + [%app dap.bol sep]~ + :: + ++ ta-grieve + :> sends a stack trace to the user's inbox. + :: + |= {msg/tape fal/tang} + %^ ta-speak %fat + [%name 'stack trace' %tank fal] + [%lin | (crip msg)] + :: + ++ ta-note + :> sends {msg} to the user's inbox. + :: + |= msg/tape + (ta-speak %lin | (crip msg)) :: ++ ta-evil :> tracing printf and crash. @@ -641,10 +655,12 @@ :: |= {who/circle ses/(list serial) fal/(unit tang)} ^+ +> - ~? ?=(^ fal) u.fal - =- (ta-delta %done who ses -) - ?~ fal %accepted - ~>(%slog.[0 u.fal] %rejected) + ?~ fal + (ta-delta %done who ses %accepted) + =. +> (ta-delta %done who ses %rejected) + =- (ta-grieve - u.fal) + %+ weld "{(scow %ud (lent ses))} message(s) " + "rejected by {(scow %p hos.who)}/{(trip nom.who)}" :: ++ ta-resub :> subscription dropped @@ -1296,6 +1312,12 @@ |= {src/circle gam/telegram} ^+ +> :: check for write permissions. + ::TODO we want to !! instead of silently failing, + :: so that ++coup-repeat of the caller gets + :: an error. but the caller may not be the + :: author. if we check for that to be true, + :: can we guarantee it's not an older message + :: getting resent? does that matter? think. ?. (so-admire aut.gam) +> :: clean up the message to conform to our rules. =. sep.gam (so-sane sep.gam) @@ -2607,10 +2629,14 @@ ?~ fal %- pre-bake ta-done:(ta-greet:ta nom src) - =. u.fal [>%failed-subscribe nom src< u.fal] - %- (slog (flop u.fal)) %- pre-bake - ta-done:(ta-leave:ta nom src) + =< ta-done + =- (ta-grieve:(ta-leave:ta nom src) - u.fal) + =+ (wire-to-target wir) + %+ weld "failed (re)subscribe to {(scow %p p)} on " + %+ roll q + |= {a/@ta b/tape} + :(weld b "/" (trip a)) :: ++ quit :> dropped subscription From ed8e30bcf34df57dbab5d372aa1dfd67b7642661 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 00:11:34 +0100 Subject: [PATCH 046/184] Disabled %cake-woot-bad printf in ames. --- sys/vane/ames.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vane/ames.hoon b/sys/vane/ames.hoon index ef74aa235..43fd6810f 100644 --- a/sys/vane/ames.hoon +++ b/sys/vane/ames.hoon @@ -1599,7 +1599,7 @@ == :: %cake - ~? ?=(^ r.bon) [%cake-woot-bad hen r.bon] + :: ~? ?=(^ r.bon) [%cake-woot-bad hen r.bon] :_ fox :~ [s.bon %give %woot q.p.bon r.bon] == From 6a1d2fcbba4e09e05679259105cf3e9a4be2a696 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 00:11:46 +0100 Subject: [PATCH 047/184] Always remove the old source when we resub a dropped /circle subscription. --- app/hall.hoon | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index cd3890d19..47fbf6f80 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -1150,6 +1150,15 @@ |= src/source ^+ +> =+ seq=(~(get by sequence) cir.src) + =/ ner/range + ?~ seq ran.src + =- `[[%ud u.seq] -] + ?~ ran.src ~ + tal.u.ran.src + :: if our subscription changes or ends, remove + :: the original source. + =? +>.$ !=(ner ran.src) + (so-delta-our %config so-cir %source | src) :: if we're past the range, don't resubscribe. ?: ?& ?=(^ ran.src) ?=(^ tal.u.ran.src) @@ -1161,13 +1170,8 @@ == == == - (so-delta-our %follow | [src ~ ~]) - =- (so-delta-our %follow & [[cir.src -] ~ ~]) - ^- range - ?~ seq ran.src - =- `[[%ud u.seq] -] - ?~ ran.src ~ - tal.u.ran.src + +>.$ + (so-delta-our %follow & [[cir.src -] ~ ~]) :: ++ so-first-grams :> beginning of stream From 50a46c0e17bd9acf552f3eb6af33f056d354f233 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 00:12:35 +0100 Subject: [PATCH 048/184] Revert talk's ++prep to baseline. --- app/talk.hoon | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index f0ee9ddf2..8b236c3c0 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -119,8 +119,7 @@ ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - :_ ..prep(+<+ u.old) - [[ost.bol %pull / server ~] ~] + [~ ..prep(+<+ u.old)] :: ::> || ::> || %utility From e1a0bdc3c988afcddcf92a83758b861466691d6b Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 00:40:33 +0100 Subject: [PATCH 049/184] Notify of all peer fails using hall messages, not just /circle ones. --- app/hall.hoon | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 47fbf6f80..14c4795f5 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2624,18 +2624,18 @@ :: |= {wir/wire fal/(unit tang)} ^- (quip move _+>) - ?. ?=($circle -.wir) - ?~ fal [~ +>] - ~| reap-fail+wir - (mean u.fal) - %+ etch-circle wir - |= {nom/naem src/source} - ?~ fal - %- pre-bake - ta-done:(ta-greet:ta nom src) %- pre-bake + %+ welp + ?. ?=({$circle *} wir) ~ + =+ wer=(etch wir) + ?> ?=($circle -.wer) + =< ta-done + %. [nom.wer src.wer] + ?~ fal ta-greet:ta + ta-leave:ta + ?~ fal ~ =< ta-done - =- (ta-grieve:(ta-leave:ta nom src) - u.fal) + =- (ta-grieve:ta - u.fal) =+ (wire-to-target wir) %+ weld "failed (re)subscribe to {(scow %p p)} on " %+ roll q From 835dae731779db700937f1423dfb2a9a30b7a4f8 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 01:30:06 +0100 Subject: [PATCH 050/184] ;join now loads only a day's worth of backlog by default. --- app/talk.hoon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/talk.hoon b/app/talk.hoon index 8b236c3c0..4ae70c68a 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -1047,6 +1047,11 @@ =+ pas=~(key by pos) =. ..sh-work sh-prod(active.she pas) + :: default to a day of backlog + =. pos + %- ~(run by pos) + |= r/range + ?~(r `[da+(sub now.bol ~d1) ~] r) (sh-act %source inbox & pos) :: ++ leave ::< %leave From 19eb437f9c1cf641dc84f63ac89135fda04861f8 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 01:32:39 +0100 Subject: [PATCH 051/184] ;leave now removes *all* inbox subscriptions to the specified circles. --- app/talk.hoon | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 4ae70c68a..e6dd96df1 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -1060,9 +1060,17 @@ :: |= pas/(set circle) ^+ ..sh-work + :: remove *all* sources relating to {pas}. =/ pos - %- ~(run in pas) - |=(p/circle [p ~]) + %- ~(gas in *(set ^source)) + %- zing + =/ sos + =- ~(tap in src:-) + (fall (~(get by mirrors) incir) *config) + %+ turn ~(tap in pas) + |= c/circle + %+ skim sos + |=(s/^source =(cir.s c)) =. ..sh-work (sh-act %source inbox | pos) (sh-act %notify pas ~) From 36b91c6425106a132646091945c5fdf5172dbb0d Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 01:36:02 +0100 Subject: [PATCH 052/184] Add ;sources command for displaying the active sources of circles. --- app/talk.hoon | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/talk.hoon b/app/talk.hoon index e6dd96df1..ee5c0794d 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -89,6 +89,7 @@ {$number $@(@ud {@u @ud})} ::< relative/absolute {$who audience} ::< presence {$what (unit $@(char audience))} ::< show bound glyph + {$sources circle} ::< show active sources :: ui settings :: {$bind char (unit audience)} ::< bind glyph {$unbind char (unit audience)} ::< unbind glyph @@ -783,6 +784,8 @@ (easy ~) == == + :: + ;~((glue ace) (perk %sources ~) circ) :: ;~((glue ace) (perk %show ~) circ) :: @@ -954,6 +957,7 @@ $number (number +.job) $who (who +.job) $what (what +.job) + $sources (list-sources +.job) :: ui settings $bind (bind +.job) $unbind (unbind +.job) @@ -1254,6 +1258,24 @@ (activate (snag (sub count +(msg)) grams)) (sh-lame "…{(reap p.num '0')}{(scow %ud q.num)}: no such telegram") :: + ++ list-sources ::< %sources + ::> display the active sources for our circle. + :: + |= cir/circle + ^+ ..sh-work + %+ sh-fact %mor + %+ turn + :: make sure to exclude {nom} itself. + =- ~(tap in (~(del in src:-) [cir ~])) + (fall (~(get by mirrors) cir) *config) + |= s/^source + ^- sole-effect + :- %txt + %+ weld ~(cr-phat cr cir.s) + %+ roll (range-to-path ran.s) + |= {a/@ta b/tape} + :(weld b "/" (trip a)) + :: ::> || ::> || %ui-settings ::> || From d5a44067705a132d2e5596c6af3bc872d5185fe5 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 01:36:28 +0100 Subject: [PATCH 053/184] Force talk to reconnect to hall on-update. New subscriptions are made using bone 0, as they're supposed to. --- app/talk.hoon | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index ee5c0794d..0bd70891e 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -120,7 +120,12 @@ ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - [~ ..prep(+<+ u.old)] + :_ ..prep(+<+ u.old) + :~ [ost.bol %pull /server/client server ~] + [ost.bol %pull /server/inbox server ~] + peer-client + peer-inbox + == :: ::> || ::> || %utility @@ -190,7 +195,7 @@ :: ++ peer-client ::< ui state peer move ^- move - :* ost.bol + :* 0 %peer /server/client server @@ -199,7 +204,7 @@ :: ++ peer-inbox ^- move - :* ost.bol + :* 0 %peer /server/inbox server From 56519a6b56be381096919186aa69c86213d6339c Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 01:55:33 +0100 Subject: [PATCH 054/184] More temporary debug pokes. --- app/hall.hoon | 25 ++++++++++++++++++++++++- app/talk.hoon | 13 ++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 14c4795f5..7b3532031 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2795,10 +2795,12 @@ == :: ::TODO for debug purposes. remove eventually. +:: users beware, here be dragons. ++ poke-noun |= a/@t ^- (quip move _+>) - ?: =(a 'debug') + ?: =(a 'check') + ~& 'verifying message reference integrity...' =- ~&(- [~ +>.$]) %- ~(urn by stories) |= {n/naem s/story} @@ -2818,6 +2820,7 @@ known=k mismatch=m ?: =(a 'rebuild') + ~& 'rebuilding message references...' =- [~ +>.$(stories -)] %- ~(urn by stories) |= {nom/naem soy/story} @@ -2831,5 +2834,25 @@ %+ ~(put by s) src [c (fall (~(get by s) src) ~)] soy(count c, known k, sourced s) + ?: =(a 'refederate') + ~& 'refederating. may take a while...' + :_ +> + =+ bov=(above our.bol) + ?: =(bov our.bol) ~ + :~ [0 %pull /burden [bov dap.bol] ~] + (wire-to-peer /burden) + == + ?: =(a 'incoming') + ~& 'incoming subscriptions (ignoring circle subs):' + ~& %+ skip ~(tap by sup.bol) + |= {bone (pair ship path)} + &(?=({$circle *} q) !?=({$circle $inbox *} q)) + [~ +>] + ?: =(a 'sources') + ~& 'sources per story:' + ~& %- ~(urn by stories) + |= {n/naem s/story} + [n src.shape.s] + [~ +>] [~ +>] -- diff --git a/app/talk.hoon b/app/talk.hoon index 0bd70891e..a408b2cd7 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -2245,10 +2245,12 @@ ta-done:(ta-sole:ta act) :: ::TODO for debug purposes. remove eventually. +:: users beware, here be dragons. ++ poke-noun |= a/@t ^- (quip move _+>) - ?: =(a 'debug') + ?: =(a 'check') + ~& 'verifying message reference integrity...' =- ~&(- [~ +>.$]) =+ %- ~(rep by known) |= {{u/serial a/@ud} k/@ud m/@ud} @@ -2259,10 +2261,19 @@ lent=(lent grams) [known=k mismatch=m] ?: =(a 'rebuild') + ~& 'rebuilding message references...' =+ %+ reel grams |= {t/telegram c/@ud k/(map serial @ud)} [+(c) (~(put by k) uid.t c)] [~ +>.$(count c, known k)] + ?: =(a 'reconnect') + ~& 'disconnecting and reconnecting to hall...' + :_ +> + :~ [0 %pull /server/client server ~] + [0 %pull /server/inbox server ~] + peer-client + peer-inbox + == [~ +>] :: ++ coup-client-action ::< accept n/ack From 74b5a9c6f4ecb825c94327d803129419e439b898 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 16:57:18 +0100 Subject: [PATCH 055/184] Revising a previously heard message no longer just deletes it. --- app/talk.hoon | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index a408b2cd7..d8349bd18 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -460,7 +460,10 @@ |= {num/@ud gam/telegram} =+ old=(snag num grams) ?: =(gam old) +>.$ :: no change - =. grams (oust [num 1] grams) + =. grams + %+ welp + (scag num grams) + [gam (slag +(num) grams)] ?: =(sep.gam sep.old) +>.$ :: no worthy change =< sh-done (~(sh-gram sh cli) gam) From bd46499dab8c40802942c1843670769661027fce Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 16:58:21 +0100 Subject: [PATCH 056/184] Force full rebuild of talk's message state. --- app/talk.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index d8349bd18..3e7902a40 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -120,7 +120,7 @@ ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - :_ ..prep(+<+ u.old) + :_ ..prep(+<+ u.old(grams ~, known ~, count 0)) :~ [ost.bol %pull /server/client server ~] [ost.bol %pull /server/inbox server ~] peer-client From 55715fcd5ded27bc523399eb2eed48470e7a83ac Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 14 Dec 2017 16:58:51 +0100 Subject: [PATCH 057/184] Changed debug poke 'check' to always give some information. --- app/talk.hoon | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 3e7902a40..540ebd580 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -2255,13 +2255,12 @@ ?: =(a 'check') ~& 'verifying message reference integrity...' =- ~&(- [~ +>.$]) + ~& [%count--lent count (lent grams)] =+ %- ~(rep by known) |= {{u/serial a/@ud} k/@ud m/@ud} :- ?:((gth a k) a k) ?: =(u uid:(snag (sub count +(a)) grams)) m +(m) - :^ %check-talk - count=count - lent=(lent grams) + :- %check-talk [known=k mismatch=m] ?: =(a 'rebuild') ~& 'rebuilding message references...' From 980319038954c7b9fed6f8916006c5834fc27580 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 15 Dec 2017 20:22:55 +0100 Subject: [PATCH 058/184] Reset talk's ++prep back to baseline. --- app/talk.hoon | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 540ebd580..905d38341 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -120,12 +120,7 @@ ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - :_ ..prep(+<+ u.old(grams ~, known ~, count 0)) - :~ [ost.bol %pull /server/client server ~] - [ost.bol %pull /server/inbox server ~] - peer-client - peer-inbox - == + [~ ..prep(+<+ u.old)] :: ::> || ::> || %utility From 6bb176e938ddce96c0a51e5a6dacd944a0fedbc5 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 15 Dec 2017 20:24:00 +0100 Subject: [PATCH 059/184] More talk debug pokes. 'reset' to rebuild message state. 'screw' to trigger legacy issue. --- app/talk.hoon | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/talk.hoon b/app/talk.hoon index 905d38341..e2a7910da 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -2271,6 +2271,18 @@ peer-client peer-inbox == + ?: =(a 'reset') + ~& 'full reset incoming, hold on to your cli...' + :_ +>(grams ~, known ~, count 0) + :~ [0 %pull /server/client server ~] + [0 %pull /server/inbox server ~] + peer-client + peer-inbox + == + ?: =(a 'screw') + ~& 'screwing things up...' + :- ~ + +>(grams (oust [(div (lent grams) 2) 1] grams)) [~ +>] :: ++ coup-client-action ::< accept n/ack From 1022d21014adf56239944e2780fc9d33da3d95dd Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 15 Dec 2017 20:48:01 +0100 Subject: [PATCH 060/184] Always delete the first gram in 'screw' debug poke. And comment for warning. --- app/talk.hoon | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index e2a7910da..0636c0289 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -2279,10 +2279,13 @@ peer-client peer-inbox == + :: this deletes a message from your backlog, and may + :: make talk throw stack traces. + :: **aka don't run this!** ?: =(a 'screw') ~& 'screwing things up...' :- ~ - +>(grams (oust [(div (lent grams) 2) 1] grams)) + +>(grams (oust [0 1] grams)) [~ +>] :: ++ coup-client-action ::< accept n/ack From 0c02b4a0b1b4adf4be530f6d81a2c5f2ea667ff0 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 16 Dec 2017 16:26:55 +0100 Subject: [PATCH 061/184] Add json conversions to &hall-command. --- mar/hall/command.hoon | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mar/hall/command.hoon b/mar/hall/command.hoon index 3e7106db8..1df81ddba 100644 --- a/mar/hall/command.hoon +++ b/mar/hall/command.hoon @@ -11,5 +11,30 @@ ++ grab :: convert from |% ++ noun command :: from %noun + ++ json :: from %json + => [. dejs:hall-json] ::TODO =, + =, dejs-soft:format + |= a/json + ^- command:hall + =- (need ((of -) a)) + :~ publish+(ar thot) + present+(ot nos+(as so) dif+disa ~) + :: bearing not needed + == + -- +:: +++ grow :: convert to + |% + ++ json :: to %json + => [. enjs:hall-json] ::TODO =, + =, enjs:format + %+ frond -.cod + :: only %publish has just a single piece of data. + ?: ?=($publish -.cod) a+(turn tos.cod thot) + %- pairs + ?+ -.cod !! + $present ~[nos+(sa nos.cod cord:enjs:hall-json) dif+(disa dif.cod)] + :: bearing nto needed + == -- -- From e5ed1662d640f04a2c9d9a3f444f27fced8bef8a Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 16 Dec 2017 16:37:49 +0100 Subject: [PATCH 062/184] Include urbit/talk#41 --- web/talk/main.js | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/web/talk/main.js b/web/talk/main.js index f1a451d04..38bde4875 100644 --- a/web/talk/main.js +++ b/web/talk/main.js @@ -1212,7 +1212,7 @@ module.exports = recl({ return; } if (this.props['audience-lock'] != null) { - audi = _.union(audi, ["~" + window.urb.ship + "/" + this.props.station]); + audi = ["~" + window.urb.ship + "/" + this.props.station]; } audi = this.addCC(audi); txt = this.$message.text().trim().replace(/\xa0/g, ' '); @@ -1542,18 +1542,12 @@ TreeActions.registerComponent("talk-station", StationComponent); },{"./actions/StationActions.coffee":2,"./components/MessageListComponent.coffee":6,"./components/StationComponent.coffee":7,"./components/WritingComponent.coffee":8,"./util.coffee":15}],11:[function(require,module,exports){ -var send, util; +var util; util = require('../util.coffee'); window.urb.appl = "hall"; -send = function(data, cb) { - return window.urb.send(data, { - mark: "hall-action" - }, cb); -}; - module.exports = function(arg) { var MessageActions; MessageActions = arg.MessageActions; @@ -1624,15 +1618,31 @@ module.exports = function(arg) { }); }, sendMessage: function(message, cb) { - return send({ - convey: [message] - }, function(err, res) { - console.log('sent'); - console.log(arguments); - if (cb) { - return cb(err, res); - } - }); + if (window.urb.user === window.urb.ship) { + return window.urb.send({ + convey: [message] + }, { + mark: "hall-action" + }, function(err, res) { + console.log('sent local'); + console.log(arguments); + if (cb) { + return cb(err, res); + } + }); + } else { + return window.urb.send({ + publish: [message] + }, { + mark: "hall-command" + }, function(err, res) { + console.log('sent remote'); + console.log(arguments); + if (cb) { + return cb(err, res); + } + }); + } } }; }; From 84c0e6013f01502c09a7cdd3773deb1dfe60fd5a Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 17 Dec 2017 20:59:00 +0100 Subject: [PATCH 063/184] Bind a glyph for every inbox source, regardless of range. Closes urbit/arvo#505. --- app/talk.hoon | 1 - 1 file changed, 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index cdef99e8c..1e16ea01e 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -347,7 +347,6 @@ ?& ?=($source -.dif.rum) add.dif.rum =(cir.rum incir) - ?=($~ ran.src.dif.rum) == =* cir cir.src.dif.rum =+ ren=~(cr-phat cr cir) From 06b3355556cfa541cc98395f7a7b1c0b380aed0b Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 18 Dec 2017 14:20:45 +0100 Subject: [PATCH 064/184] Renamed ++naem to ++name. --- app/hall.hoon | 112 +++++++++++++++++++++++++------------------------- app/talk.hoon | 36 ++++++++-------- sur/hall.hoon | 33 ++++++++------- 3 files changed, 90 insertions(+), 91 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 9be186c73..b534198c9 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -30,9 +30,9 @@ :> state data structures +| ++ state :> application state - $: stories/(map naem story) :< conversations + $: stories/(map name story) :< conversations outbox/(map serial tracking) :< sent messages - log/(map naem @ud) :< logged to clay + log/(map name @ud) :< logged to clay nicks/(map ship nick) :< local nicknames binds/(jug char audience) :< circle glyph lookup public/(set circle) :< publicly member of @@ -68,13 +68,13 @@ {$glyph diff-glyph} :< un/bound glyph {$nick diff-nick} :< changed nickname :: story state :: - {$story nom/naem det/delta-story} :< change to story + {$story nom/name det/delta-story} :< change to story :: side-effects :: {$init $~} :< initialize {$observe who/ship} :< watch burden bearer $: $present :> send %present cmd hos/ship :: - nos/(set naem) :: + nos/(set name) :: dif/diff-status :: == :: == :: @@ -108,7 +108,7 @@ == :: ++ weir :> parsed wire $% {$repeat cir/circle ses/(list serial)} :< messaging wire - {$circle nom/naem src/source} :< subscription wire + {$circle nom/name src/source} :< subscription wire == :: -- :: @@ -221,7 +221,7 @@ :> {nom} exists, calls the gate with a story core. :> if it doesn't, does nothing. :: - |= nom/naem + |= nom/name |= fun/$-(_so _ta) ^+ +>+> =+ pur=(~(get by stories) nom) @@ -243,11 +243,11 @@ :: :: create default circles. => %+ roll - ^- (list {security naem cord}) + ^- (list {security name cord}) :~ [%mailbox %inbox 'default home'] [%journal %public 'visible activity'] == - |= {{typ/security nom/naem des/cord} _ta} + |= {{typ/security nom/name des/cord} _ta} (ta-action [%create nom des typ]) %- ta-deltas :: if needed, subscribe to our parent's /burden. @@ -283,7 +283,7 @@ :> sets status for the indicated stories, :> but only if they have write permission there. :: - |= {who/ship nos/(set naem) dif/diff-status} + |= {who/ship nos/(set name) dif/diff-status} ^+ +> =+ nol=~(tap in nos) |- @@ -340,7 +340,7 @@ :> store a delta about a story. if the story :> does not exist, crash. :: - |= {nom/naem det/delta-story} + |= {nom/name det/delta-story} ?: (~(has by stories) nom) (impact nom det) (ta-evil (crip "no story {(trip nom)}")) @@ -350,7 +350,7 @@ :> :> Store a delta about a story. :: - |= {nom/naem det/delta-story} + |= {nom/name det/delta-story} (ta-delta %story nom det) :: ++ present @@ -359,9 +359,9 @@ |= {aud/audience dif/diff-status} ^+ ..ta-action =/ cic - ^- (jug ship naem) + ^- (jug ship name) %- ~(rep in aud) - |= {c/circle m/(jug ship naem)} + |= {c/circle m/(jug ship name)} (~(put ju m) hos.c nom.c) =? ..ta-action (~(has by cic) our.bol) =+ nos=~(tap in (~(get ju cic) our.bol)) @@ -372,12 +372,12 @@ $(nos t.nos) ::TODO runtime error ::%- ~(rep in (~(get ju cic) our.bol)) - ::|= {n/naem _ta} :: beware, urbit/arvo#447 + ::|= {n/name _ta} :: beware, urbit/arvo#447 ::(affect n %status [our.bol n] our.bol dif) =. cic (~(del by cic) our.bol) %- ta-deltas %- ~(rep by cic) - |= {{h/ship s/(set naem)} l/(list delta)} + |= {{h/ship s/(set name)} l/(list delta)} :_ l [%present h s dif] :: @@ -386,7 +386,7 @@ ++ action-create :> creates a story with the specified parameters. :: - |= {nom/naem des/cord typ/security} + |= {nom/name des/cord typ/security} ^+ ..ta-action ?. (~(has in stories) nom) %^ impact nom %new @@ -405,7 +405,7 @@ :> delete story {nom}, optionally announcing the :> event with message {mes}. :: - |= {nom/naem mes/(unit cord)} + |= {nom/name mes/(unit cord)} ^+ ..ta-action =? ..ta-action ?=(^ mes) %+ action-phrase @@ -416,7 +416,7 @@ ++ action-depict :> change description of story {nom} to {des}. :: - |= {nom/naem cap/cord} + |= {nom/name cap/cord} (affect nom %config [our.bol nom] %caption cap) :: ++ action-filter @@ -425,13 +425,13 @@ :> replaces the story's current filter with the :> specified one. :: - |= {nom/naem fit/filter} + |= {nom/name fit/filter} (affect nom %config [our.bol nom] %filter fit) :: ++ action-permit :> invite to/banish from story {nom} all {sis}. :: - |= {nom/naem inv/? sis/(set ship)} + |= {nom/name inv/? sis/(set ship)} =+ soy=(~(get by stories) nom) ?~ soy (ta-evil (crip "no story {(trip nom)}")) @@ -440,7 +440,7 @@ ++ action-source :> add/remove {pos} as sources for story {nom}. :: - |= {nom/naem sub/? srs/(set source)} + |= {nom/name sub/? srs/(set source)} =+ soy=(~(get by stories) nom) ?~ soy (ta-evil (crip "no story {(trip nom)}")) @@ -557,7 +557,7 @@ :> :> store a started subscription as source. :: - |= {nom/naem src/source} + |= {nom/name src/source} %- (ta-know nom) |= sor/_so =< so-done (so-greet:sor src) :: @@ -566,7 +566,7 @@ :> :> removes {src} from story {nom}'s sources. :: - |= {nom/naem src/source} + |= {nom/name src/source} %- (ta-know nom) |= sor/_so =< so-done (so-leave:sor src) :: @@ -599,7 +599,7 @@ $(sos t.sos) ::TODO runtime error ::%+ roll ~(tap by sos.piz) - ::|= {{n/naem b/burden} _..ta-take} + ::|= {{n/name b/burden} _..ta-take} ::=+ (fall (~(get by stories) n) *story) ::so-done:(~(so-bear so n ~ -) b) :: @@ -673,7 +673,7 @@ :> when a subscription gets dropped by gall, we :> resubscribe. :: - |= {nom/naem src/source} + |= {nom/name src/source} ^+ +> %- (ta-know nom) |= sor/_so =< so-done (so-resub:sor src) @@ -730,7 +730,7 @@ :> :> add or update telegram {gam} in story {nom}. :: - |= {nom/naem gam/telegram} + |= {nom/name gam/telegram} %- (ta-know nom) |= sor/_so =< so-done (so-learn:sor [our.bol nom] gam) :: @@ -754,7 +754,7 @@ :> acs: hall actions issued due to changes. :: story is faceless to ease data access. :: - $: nom/naem + $: nom/name acs/(list action) story == @@ -1458,7 +1458,7 @@ ++ da-present :> send %present cmd :: - |= {hos/ship nos/(set naem) dif/diff-status} + |= {hos/ship nos/(set name) dif/diff-status} ^+ +> %- da-emit :* ost.bol @@ -1611,7 +1611,7 @@ :> in case of a new or deleted story, specialized :> arms are called. :: - |= {nom/naem det/delta-story} + |= {nom/name det/delta-story} ^+ +> ?+ -.det =< sa-done @@ -1629,7 +1629,7 @@ :> :> creates story {nom} with config {con}. :: - |= {nom/naem cof/config} + |= {nom/name cof/config} ^+ +> =< sa-done %- ~(sa-change sa nom *story) @@ -1640,7 +1640,7 @@ :> :> calls the story core to delete story {nom}. :: - |= nom/naem + |= nom/name ^+ +> =. +> %- da-emil @@ -1655,7 +1655,7 @@ |_ :> nom: story name in {stories}. :: story is faceless to ease data access. :: - $: nom/naem + $: nom/name story == :> # %resolve @@ -1979,7 +1979,7 @@ :> constructs a /circle %peer path for subscribing :> {nom} to a source. :: - |= {nom/naem wat/(list circle-data) source} + |= {nom/name wat/(list circle-data) source} ^- wire ;: weld /circle/[nom]/(scot %p hos.cir)/[nom.cir] @@ -2050,7 +2050,7 @@ :: |= $: wir/wire $= fun - $- {nom/naem src/source} + $- {nom/name src/source} {(list move) _.} == =+ wer=(etch wir) @@ -2088,7 +2088,7 @@ ?. =(who our.bol) [bon %quit ~]~ %- zing %+ turn ~(tap in ~(key by stories)) - |= n/naem + |= n/name ^- (list move) :~ :^ 0 %poke / :+ [our.bol dap.bol] %hall-action @@ -2144,10 +2144,10 @@ :: $circles =- ``[%circles -] - %- ~(gas in *(set naem)) + %- ~(gas in *(set name)) %+ murn ~(tap by stories) - |= {n/naem s/story} - ^- (unit naem) + |= {n/name s/story} + ^- (unit name) ?:((~(so-visible so:ta n ~ s) who.qer) `n ~) :: $public @@ -2156,10 +2156,10 @@ $burden :+ ~ ~ :- %burden - %- ~(gas in *(map naem burden)) + %- ~(gas in *(map name burden)) %+ murn ~(tap by stories) - |= {n/naem s/story} - ^- (unit (pair naem burden)) + |= {n/name s/story} + ^- (unit (pair name burden)) :: only auto-federate channels for now. ?. ?=($channel sec.con.shape.s) ~ :+ ~ n @@ -2209,7 +2209,7 @@ :> modify a %story diff to make it about their ship :> instead of ours. :: - |= {who/ship nom/naem det/delta-story} + |= {who/ship nom/name det/delta-story} ^- rumor-story ?+ -.det det :: @@ -2251,7 +2251,7 @@ :> for a given story. assumes both story and :> telegram are known. :: - |= {nom/naem gam/telegram} + |= {nom/name gam/telegram} ^- envelope :_ gam %. uid.gam @@ -2261,7 +2261,7 @@ :: |= $: wer/(unit circle) wat/(set circle-data) - nom/naem + nom/name det/delta-story == ^- ? @@ -2665,7 +2665,7 @@ |= wir/wire ^- (quip move _+>) %+ etch-circle [%circle wir] - |= {nom/naem src/source} + |= {nom/name src/source} %- pre-bake ta-done:(ta-resub:ta nom src) :: @@ -2694,7 +2694,7 @@ :> to be re-loaded by ++poke-hall-load. ::TODO maybe update to also store sourced list. :: - |= nom/naem + |= nom/name ^- (quip move _+>) =/ paf/path /(scot %p our.bol)/home/(scot %da now.bol)/hall/[nom]/hall-telegrams @@ -2711,7 +2711,7 @@ ++ poke-load-legacy :> loads legacy messages into the story {nom}. :: - |= nom/naem + |= nom/name ^- (quip move _+>) =/ jams/json .^ json @@ -2731,7 +2731,7 @@ :> loads the telegrams of story {nom} into our state, :> as saved in ++poke-hall-save. :: - |= nom/naem + |= nom/name ^- (quip move _+>) =/ grams .^ (list telegram) @@ -2746,7 +2746,7 @@ ++ poke-hall-log :> starts logging story {nom}'s messages. :: - |= nom/naem + |= nom/name ^- (quip move _+>) :- [(log-to-file nom) ~] %= +>.$ @@ -2758,7 +2758,7 @@ ++ poke-hall-unlog :> stops logging story {nom}'s messages. :: - |= nom/naem + |= nom/name ^- (quip move _+>) :- ~ +>.$(log (~(del by log) nom)) @@ -2773,11 +2773,11 @@ :_ %_ . log %- ~(urn by log) - |= {nom/naem len/@ud} + |= {nom/name len/@ud} count:(~(got by stories) nom) == %+ murn ~(tap by log) - |= {nom/naem len/@ud} + |= {nom/name len/@ud} ^- (unit move) ?: (gte len count:(~(got by stories) nom)) ~ @@ -2786,7 +2786,7 @@ ++ log-to-file :> logs all grams of story {nom} to a file. :: - |= nom/naem + |= nom/name ^- move =+ ^- paf/path =+ day=(year %*(. (yore now.bol) +.t +:*tarp)) @@ -2809,7 +2809,7 @@ ~& 'verifying message reference integrity...' =- ~&(- [~ +>.$]) %- ~(urn by stories) - |= {n/naem s/story} + |= {n/name s/story} =+ %- ~(rep by known.s) |= {{u/serial a/@ud} k/@ud m/@ud} :- ?:((gth a k) a k) @@ -2829,7 +2829,7 @@ ~& 'rebuilding message references...' =- [~ +>.$(stories -)] %- ~(urn by stories) - |= {nom/naem soy/story} + |= {nom/name soy/story} =+ %+ roll grams.soy |= {t/telegram c/@ud k/(map serial @ud) s/(map circle (list @ud))} :+ +(c) (~(put by k) uid.t c) @@ -2857,7 +2857,7 @@ ?: =(a 'sources') ~& 'sources per story:' ~& %- ~(urn by stories) - |= {n/naem s/story} + |= {n/name s/story} [n src.shape.s] [~ +>] [~ +>] diff --git a/app/talk.hoon b/app/talk.hoon index 1e16ea01e..f18ec6663 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -69,14 +69,14 @@ $% :: circle management :: {$join (map circle range)} ::< subscribe to {$leave audience} ::< unsubscribe from - {$create security naem cord} ::< create circle - {$delete naem (unit cord)} ::< delete circle - {$depict naem cord} ::< change description - {$filter naem ? ?} ::< change message rules - {$invite naem (set ship)} ::< give permission - {$banish naem (set ship)} ::< deny permission - {$source naem (map circle range)} ::< add source - {$unsource naem (map circle range)} ::< remove source + {$create security name cord} ::< create circle + {$delete name (unit cord)} ::< delete circle + {$depict name cord} ::< change description + {$filter name ? ?} ::< change message rules + {$invite name (set ship)} ::< give permission + {$banish name (set ship)} ::< deny permission + {$source name (map circle range)} ::< add source + {$unsource name (map circle range)} ::< remove source :: personal metadata :: {$attend audience (unit presence)} ::< set our presence {$name audience human} ::< set our name @@ -138,7 +138,7 @@ ++ inbox ::< client's circle name ::> produces the name of the circle used by this ::> client for all its operations - ^- naem + ^- name %inbox :: ++ incir ::< client's circle @@ -727,7 +727,7 @@ == :: ;~ plug (perk %delete ~) - ;~(pfix ;~(plug ace cen) sym) + ;~(pfix ace cire) ;~ pose (cook some ;~(pfix ace qut)) (easy ~) @@ -949,7 +949,7 @@ $unsource (source | +.job) :: personal metadata $attend (attend +.job) - $name (name +.job) + $name (set-name +.job) :: messaging $say (say +.job) $eval (eval +.job) @@ -1084,7 +1084,7 @@ ++ create ::< %create ::> creates circle {nom} with specified config. :: - |= {sec/security nom/naem txt/cord} + |= {sec/security nom/name txt/cord} ^+ ..sh-work =. ..sh-work (sh-act %create nom txt sec) @@ -1094,14 +1094,14 @@ ::> deletes our circle {nom}, after optionally ::> sending a last announce message {say}. :: - |= {nom/naem say/(unit cord)} + |= {nom/name say/(unit cord)} ^+ ..sh-work (sh-act %delete nom say) :: ++ depict ::< %depict ::> changes the description of {nom} to {txt}. :: - |= {nom/naem txt/cord} + |= {nom/name txt/cord} ^+ ..sh-work (sh-act %depict nom txt) :: @@ -1109,19 +1109,19 @@ ::> invites or banishes {sis} to/from our ::> circle {nom}. :: - |= {inv/? nom/naem sis/(set ship)} + |= {inv/? nom/name sis/(set ship)} ^+ ..sh-work (sh-act %permit nom inv sis) :: ++ filter - |= {nom/naem cus/? utf/?} + |= {nom/name cus/? utf/?} ^+ ..sh-work (sh-act %filter nom cus utf) :: ++ source ::< %source ::> adds {pas} to {nom}'s src. :: - |= {sub/? nom/naem pos/(map circle range)} + |= {sub/? nom/name pos/(map circle range)} ^+ ..sh-work (sh-act %source nom sub pos) :: @@ -1137,7 +1137,7 @@ ^+ ..sh-work (sh-act %notify aud pec) :: - ++ name ::< set our name + ++ set-name ::< set our name ::> sets our name to {man} for {aud}. :: |= {aud/audience man/human} diff --git a/sur/hall.hoon b/sur/hall.hoon index 6887c3291..192e9ff0e 100644 --- a/sur/hall.hoon +++ b/sur/hall.hoon @@ -13,8 +13,7 @@ ::> wrapper molds, for semantic clarity. ::+| :: -::TODO rename -++ naem term ::< circle name +++ name term ::< circle name ++ nick cord ::< local nickname :: ::> || @@ -27,11 +26,11 @@ $% {$client $~} ::< shared ui state {$circles who/ship} ::< readable circles {$public $~} ::< public memberships - {$burden who/ship} ::TODO eventually, nom/naem. ::< duties to share + {$burden who/ship} ::TODO eventually, nom/name. ::< duties to share {$report $~} ::< duty reports - {$peers nom/naem} ::< readers of story + {$peers nom/name} ::< readers of story $: $circle ::> story query - nom/naem ::< circle name + nom/name ::< circle name wer/(unit circle) ::< from source wat/(set circle-data) ::< data to get ran/range ::< query duration @@ -57,9 +56,9 @@ == :: ++ prize ::> query result $% {$client prize-client} ::< /client - {$circles cis/(set naem)} ::< /circles + {$circles cis/(set name)} ::< /circles {$public cis/(set circle)} ::< /public - {$burden sos/(map naem burden)} ::< /burden + {$burden sos/(map name burden)} ::< /burden {$report $~} ::< /report {$peers pes/(jar ship query)} ::< /peers {$circle package} ::< /circle @@ -70,9 +69,9 @@ == :: ++ rumor ::> query result change $% {$client rum/rumor-client} ::< /client - {$circles add/? cir/naem} ::< /circles + {$circles add/? cir/name} ::< /circles {$public add/? cir/circle} ::< /public - {$burden nom/naem rum/rumor-story} ::< /burden + {$burden nom/name rum/rumor-story} ::< /burden {$peers add/? who/ship qer/query} ::< /peers {$circle rum/rumor-story} ::< /circle == :: @@ -135,12 +134,12 @@ :: ++ action ::> user action $% :: circle configuration :: - {$create nom/naem des/cord sec/security} ::< create circle - {$delete nom/naem why/(unit cord)} ::< delete + announce - {$depict nom/naem des/cord} ::< change description - {$filter nom/naem fit/filter} ::< change message rules - {$permit nom/naem inv/? sis/(set ship)} ::< invite/banish - {$source nom/naem sub/? srs/(set source)} ::< un/sub to/from src + {$create nom/name des/cord sec/security} ::< create circle + {$delete nom/name why/(unit cord)} ::< delete + announce + {$depict nom/name des/cord} ::< change description + {$filter nom/name fit/filter} ::< change message rules + {$permit nom/name inv/? sis/(set ship)} ::< invite/banish + {$source nom/name sub/? srs/(set source)} ::< un/sub to/from src :: messaging :: {$convey tos/(list thought)} ::< post exact {$phrase aud/audience ses/(list speech)} ::< post easy @@ -162,7 +161,7 @@ :: ++ command ::> effect on story $% {$publish tos/(list thought)} ::< deliver - {$present nos/(set naem) dif/diff-status} ::< status update + {$present nos/(set name) dif/diff-status} ::< status update {$bearing $~} ::< prompt to listen == :: :: @@ -172,7 +171,7 @@ ::> messaging targets and their metadata. ::+| :: -++ circle {hos/ship nom/naem} ::< native target +++ circle {hos/ship nom/name} ::< native target :: circle configurations. :: ++ lobby {loc/config rem/(map circle config)} ::< our & srcs configs ++ config ::> circle config From 31e1c73aede0bb607d7ac299cdf28a1dcf65162e Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 18 Dec 2017 14:21:52 +0100 Subject: [PATCH 065/184] Made ++name a knot rather than a term. --- app/talk.hoon | 6 +++--- lib/hall-json.hoon | 2 +- sur/hall.hoon | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index f18ec6663..6643390ed 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -593,13 +593,13 @@ (most ;~(plug com (star ace)) ship) :: ++ cire ::< local circle - ;~(pfix cen sym) + ;~(pfix cen urs:ab) :: ++ circ ::< circle ;~ pose (cold incir col) - ;~(pfix cen (stag self sym)) - ;~(pfix fas (stag (sein:title self) sym)) + ;~(pfix cen (stag self urs:ab)) + ;~(pfix fas (stag (sein:title self) urs:ab)) :: %+ cook |= {a/@p b/(unit term)} diff --git a/lib/hall-json.hoon b/lib/hall-json.hoon index c8484fe7f..bcdb7697d 100644 --- a/lib/hall-json.hoon +++ b/lib/hall-json.hoon @@ -29,7 +29,7 @@ ++ de-tape ::> tape to sur (parse) |% ++ circ ::> circle - ;~((glue fas) ;~(pfix sig fed:ag) urt:ab) + ;~((glue fas) ;~(pfix sig fed:ag) urs:ab) :: ++ pont ;~ pfix fas diff --git a/sur/hall.hoon b/sur/hall.hoon index 192e9ff0e..7d6516c56 100644 --- a/sur/hall.hoon +++ b/sur/hall.hoon @@ -13,7 +13,7 @@ ::> wrapper molds, for semantic clarity. ::+| :: -++ name term ::< circle name +++ name knot ::< circle name ++ nick cord ::< local nickname :: ::> || From a3dcca66e44f714c3cd80249d4d92efed4faacf1 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 18 Dec 2017 17:03:18 +0100 Subject: [PATCH 066/184] Talk no longer accepts peers from moons, they should run a local client. Also actually crash on invalid subscription. --- app/talk.hoon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 6643390ed..333bc2700 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -2213,12 +2213,12 @@ :: |= pax/path ^- (quip move _+>) - ?. (team:title src.bol our.bol) - ~& [%peer-talk-stranger src.bol] - [~ +>] + ?. =(src.bol our.bol) + ~! [%peer-talk-stranger src.bol] + !! ?. ?=({$sole *} pax) - ~& [%peer-talk-strange pax] - [~ +>] + ~! [%peer-talk-strange pax] + !! ta-done:ta-console:ta :: ++ diff-hall-prize ::< accept query answer From 4268f30d4bb15b77c282a189efd8734c34dd0b7c Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 18 Dec 2017 18:32:59 +0100 Subject: [PATCH 067/184] Now show the original's message number when showing reply-to details. --- app/talk.hoon | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 333bc2700..6c562a1ea 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -2051,12 +2051,15 @@ mor+~[txt+"# {(trip exp.sep)}" tan+res.sep] :: $ire - =+ gam=(recall top.sep) - ?~ gam $(sep sep.sep) + =+ num=(~(get by known) top.sep) + ?~ num $(sep sep.sep) + =+ gam=(snag (sub count +(u.num)) grams) =- mor+[tan+- $(sep sep.sep) ~] %- flop %+ weld - [%leaf "in reply to: {(cite:title aut.u.gam)}: "]~ - %+ turn (~(tr-text tr sef u.gam) width.cli) + :_ ~ :- %leaf + %+ weld "in reply to: {(cite:title aut.gam)}: " + "[{(scow %ud u.num)}]" + %+ turn (~(tr-text tr sef gam) width.cli) |=(t/tape [%leaf t]) :: $fat From a5ef94150596d7e2d6f1cc7ac0877f5f15471042 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 18 Dec 2017 15:53:59 -0800 Subject: [PATCH 068/184] Enables more doccords in hall and talk. --- app/hall.hoon | 14 +- app/talk.hoon | 1180 ++++++++++++++++++++++++++++--------------------- sur/hall.hoon | 388 ++++++++-------- 3 files changed, 865 insertions(+), 717 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 9be186c73..1d6962d07 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -265,15 +265,15 @@ |= {src/ship cod/command} ^+ +> ?- -.cod - ::> %publish commands prompt us (as a circle host) - ::> to verify and distribute messages. + :: %publish commands prompt us (as a circle host) + :: to verify and distribute messages. $publish (ta-think | src +.cod) - ::> %present commands are used to ask us to set - ::> someone's status in the indicated stories. + :: %present commands are used to ask us to set + :: someone's status in the indicated stories. $present (ta-present src +.cod) - ::> %bearing commands are used by our children to - ::> let us know they're bearing our /burden. we - ::> need to watch them to allow changes to go up. + :: %bearing commands are used by our children to + :: let us know they're bearing our /burden. we + :: need to watch them to allow changes to go up. $bearing (ta-observe src) ::TODO isn't this redundant with ta-subscribe? == :: diff --git a/app/talk.hoon b/app/talk.hoon index 0636c0289..37259d3e4 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -7,114 +7,118 @@ ::TODO [type query] => [press tab to cycle search results, newest-first] :: => [escape to clear] :: -::> This client implementation makes use of the %inbox -::> for all its subscriptions and messaging. All -::> rumors received are exclusively about the %inbox, -::> since that's the only thing the client ever -::> subscribes to. +:: This client implementation makes use of the %inbox +:: for all its subscriptions and messaging. All +:: rumors received are exclusively about the %inbox, +:: since that's the only thing the client ever +:: subscribes to. :: -/- hall, sole ::< structures -/+ hall, sole ::< libraries +/- hall, sole :: structures +/+ hall, sole :: libraries /= seed /~ !>(.) :: :::: :: =, hall =, sole -=> ::> || - ::> || %arch - ::> || - ::> data structures +=> :> # + :> # %arch + :> # + :> data structures :: |% - ++ state ::> application state + ++ state :> application state $: :: messaging state :: - count/@ud ::< (lent grams) - grams/(list telegram) ::< all history - known/(map serial @ud) ::< messages heard - sources/(set circle) ::< our subscriptions + count/@ud :< (lent grams) + grams/(list telegram) :< all history + known/(map serial @ud) :< messages heard + sources/(set circle) :< our subscriptions :: circle details :: - remotes/(map circle group) ::< remote presences - mirrors/(map circle config) ::< remote configs + remotes/(map circle group) :< remote presences + mirrors/(map circle config) :< remote configs :: ui state :: - nicks/(map ship nick) ::< human identities - bound/(map audience char) ::< bound circle glyphs - binds/(jug char audience) ::< circle glyph lookup - cli/shell ::< interaction state + nicks/(map ship nick) :< human identities + bound/(map audience char) :< bound circle glyphs + binds/(jug char audience) :< circle glyph lookup + cli/shell :< interaction state == :: - ++ shell ::> console session - $: id/bone ::< identifier - latest/@ud ::< latest shown msg num - say/sole-share ::< console state - active/audience ::< active targets - settings/(set term) ::< frontend settings - width/@ud ::< display width - timez/(pair ? @ud) ::< timezone adjustment + ++ shell :> console session + $: id/bone :< identifier + latest/@ud :< latest shown msg num + say/sole-share :< console state + active/audience :< active targets + settings/(set term) :< frontend settings + width/@ud :< display width + timez/(pair ? @ud) :< timezone adjustment == :: - ++ move (pair bone card) ::< all actions - ++ lime ::> diff fruit + ++ move (pair bone card) :< all actions + ++ lime :> diff fruit $% {$sole-effect sole-effect} :: == :: - ++ pear ::> poke fruit + ++ pear :> poke fruit $% {$hall-command command} :: {$hall-action action} :: == :: - ++ card ::> general card + ++ card :> general card $% {$diff lime} :: {$poke wire dock pear} :: {$peer wire dock path} :: {$pull wire dock $~} :: == :: - ++ work ::> interface action + ++ work :> interface action $% :: circle management :: - {$join (map circle range)} ::< subscribe to - {$leave audience} ::< unsubscribe from - {$create security naem cord} ::< create circle - {$delete naem (unit cord)} ::< delete circle - {$depict naem cord} ::< change description - {$filter naem ? ?} ::< change message rules - {$invite naem (set ship)} ::< give permission - {$banish naem (set ship)} ::< deny permission - {$source naem (map circle range)} ::< add source - {$unsource naem (map circle range)} ::< remove source + {$join (map circle range)} :< subscribe to + {$leave audience} :< unsubscribe from + {$create security naem cord} :< create circle + {$delete naem (unit cord)} :< delete circle + {$depict naem cord} :< change description + {$filter naem ? ?} :< change message rules + {$invite naem (set ship)} :< give permission + {$banish naem (set ship)} :< deny permission + {$source naem (map circle range)} :< add source + {$unsource naem (map circle range)} :< remove source :: personal metadata :: - {$attend audience (unit presence)} ::< set our presence - {$name audience human} ::< set our name + {$attend audience (unit presence)} :< set our presence + {$name audience human} :< set our name :: messaging :: - {$say (list speech)} ::< send message - {$eval cord hoon} ::< send #-message - {$target p/audience q/(unit work)} ::< set active targets - {$reply $@(@ud {@u @ud}) (list speech)} ::< reply to + {$say (list speech)} :< send message + {$eval cord hoon} :< send #-message + {$target p/audience q/(unit work)} :< set active targets + {$reply $@(@ud {@u @ud}) (list speech)} :< reply to :: displaying info :: - {$number $@(@ud {@u @ud})} ::< relative/absolute - {$who audience} ::< presence - {$what (unit $@(char audience))} ::< show bound glyph - {$sources circle} ::< show active sources + {$number $@(@ud {@u @ud})} :< relative/absolute + {$who audience} :< presence + {$what (unit $@(char audience))} :< show bound glyph + {$sources circle} :< show active sources :: ui settings :: - {$bind char (unit audience)} ::< bind glyph - {$unbind char (unit audience)} ::< unbind glyph - {$nick (unit ship) (unit cord)} ::< un/set/show nick - {$set term} ::< enable setting - {$unset term} ::< disable setting - {$width @ud} ::< change display width - {$timez ? @ud} ::< adjust shown times + {$bind char (unit audience)} :< bind glyph + {$unbind char (unit audience)} :< unbind glyph + {$nick (unit ship) (unit cord)} :< un/set/show nick + {$set term} :< enable setting + {$unset term} :< disable setting + {$width @ud} :< change display width + {$timez ? @ud} :< adjust shown times :: miscellaneous :: - {$show circle} ::< show membership - {$hide circle} ::< hide membership - {$help $~} ::< print usage info + {$show circle} :< show membership + {$hide circle} :< hide membership + {$help $~} :< print usage info == :: - ++ glyphs `wall`~[">=+-" "}),." "\"'`^" "$%&@"] ::< circle char pool ' + ++ glyphs `wall`~[">=+-" "}),." "\"'`^" "$%&@"] :< circle char pool ' -- :: -::> || -::> || %work -::> || -::> functional cores and arms. +:> # +:> # %work +:> # +:> functional cores and arms. :: |_ {bol/bowl:gall state} :: -++ prep ::< prepare state - ::> adapts state. +:> # %transition +:> prep transition ++| +:: +++ prep + :> adapts state :: |= old/(unit state) ^- (quip move _..prep) @@ -122,49 +126,56 @@ ta-done:ta-init:ta [~ ..prep(+<+ u.old)] :: -::> || -::> || %utility -::> || -::> small utility functions. -::+| +:> # +:> # %utility +:> # +:> small utility functions. ++| :: ++ our (true-self our.bol) :: -++ server ::< our hall instance +++ server + :> our hall instance ^- dock [our %hall] :: -++ inbox ::< client's circle name - ::> produces the name of the circle used by this - ::> client for all its operations +++ inbox + :> client's circle name + :> + :> produces the name of the circle used by this + :> client for all its operations ^- naem %inbox :: -++ incir ::< client's circle - ::> ++inbox, except a full circle. +++ incir + :> client's circle + :> + :> ++inbox, except a full circle. ^- circle [our inbox] :: -++ renum ::< gram i# by serial - ::> find the grams list index for gram with serial. +++ renum + :> find the grams list index for gram with serial. |= ser/serial ^- (unit @ud) =+ num=(~(get by known) ser) ?~ num ~ `(sub count +(u.num)) :: -++ recall ::< gram by serial - ::> find a known gram with serial {ser}. +++ recall + :> find a known gram with serial {ser}. |= ser/serial ^- (unit telegram) =+ num=(renum ser) ?~ num ~ `(snag u.num grams) :: -++ bound-from-binds ::< bound from binds - ::> using a mapping of character to audiences, create - ::> a mapping of audience to character. +++ bound-from-binds + :> bound from binds + :> + :> using a mapping of character to audiences, create + :> a mapping of audience to character. :: |= bin/_binds ^+ bound @@ -174,8 +185,8 @@ |= {a/char b/(set audience)} (turn ~(tap by b) |=(c/audience [c a])) :: -++ glyph ::< grab a glyph - ::> finds a new glyph for assignment. +++ glyph + :> finds a new glyph for assignment. :: |= idx/@ =< cha @@ -188,7 +199,8 @@ ole [new num] :: -++ peer-client ::< ui state peer move +++ peer-client + :> ui state peer move ^- move :* 0 %peer @@ -206,29 +218,36 @@ /circle/[inbox]/grams/config/group/(scot %ud count) == :: -::> || -::> || %engines -::> || -::> main cores. -::+| +:> # +:> # %engines +:> # +:> main cores. ++| :: -++ ta :: per transaction - ::> for every transaction/event (poke, peer etc.) - ::> talk receives, the ++ta transaction core is - ::> called. - ::> in processing transactions, ++ta may modify app - ::> state, or create moves. these moves get produced - ::> upon finalizing the core's with with ++ta-done. - ::> when making changes to the shell, the ++sh core is - ::> used. +++ ta + :> per transaction + :> + :> for every transaction/event (poke, peer etc.) + :> talk receives, the ++ta transaction core is + :> called. + :> in processing transactions, ++ta may modify app + :> state, or create moves. these moves get produced + :> upon finalizing the core's with with ++ta-done. + :> when making changes to the shell, the ++sh core is + :> used. :: - |_ ::> moves: moves created by core operations. + |_ :> moves: moves created by core operations. :: moves/(list move) :: - ++ ta-done ::< resolve core - ::> produces the moves stored in ++ta's moves. - ::> %sole-effect moves get squashed into a %mor. + :> # %resolve + +| + :: + ++ ta-done + :> resolve core + :> + :> produces the moves stored in ++ta's moves. + :> %sole-effect moves get squashed into a %mor. :: ^+ [*(list move) +>] :_ +> @@ -246,47 +265,49 @@ =+ moz=(flop p.yop) =/ foc/(unit sole-effect) ?~ q.yop ~ - ?~ t.q.yop `i.q.yop ::< single sole-effect - `[%mor (flop q.yop)] ::< more sole-effects + ?~ t.q.yop `i.q.yop :: single sole-effect + `[%mor (flop q.yop)] :: more sole-effects :: produce moves or sole-effects and moves. ?~ foc moz ?~ id.cli ~&(%client-no-sole moz) [[id.cli %diff %sole-effect u.foc] moz] :: - ::> || - ::> || %emitters - ::> || - ::> arms that create outward changes. - ::+| + :> # + :> # %emitters + :> # + :> arms that create outward changes. + +| :: - ++ ta-emil ::< emit move list - ::> adds multiple moves to the core's list. - ::> flops to emulate ++ta-emit. + ++ ta-emil + :> emit move list + :> + :> adds multiple moves to the core's list. + :> flops to emulate ++ta-emit. :: |= mol/(list move) %_(+> moves (welp (flop mol) moves)) :: - ++ ta-emit ::< emit a move - ::> adds a move to the core's list. + ++ ta-emit + :> adds a move to the core's list. :: |= mov/move %_(+> moves [mov moves]) :: - ::> || - ::> || %interaction-events - ::> || - ::> arms that apply events we received. - ::+| + :> # + :> # %interaction-events + :> # + :> arms that apply events we received. + +| :: - ++ ta-init ::< initialize app - ::> subscribes to our hall. + ++ ta-init + :> subscribes to our hall. :: %- ta-emil ^- (list move) ~[peer-client peer-inbox] :: - ++ ta-take ::< accept prize - ::> + ++ ta-take + :> accept prize :: |= piz/prize ^+ +> @@ -307,8 +328,8 @@ == == :: - ++ ta-hear ::< apply change - ::> + ++ ta-hear + :> apply change :: |= rum/rumor ^+ +> @@ -326,8 +347,8 @@ (ta-change-circle rum.rum) == :: - ++ ta-change-circle ::< apply circle change - ::> + ++ ta-change-circle + :> apply circle change :: |= rum/rumor-story ^+ +> @@ -394,8 +415,8 @@ == == :: - ++ ta-change-glyph ::< apply changed glyphs - ::> applies new set of glyph bindings. + ++ ta-change-glyph + :> applies new set of glyph bindings. :: |= {bin/? gyf/char aud/audience} ^+ +> @@ -405,40 +426,44 @@ =. bound (bound-from-binds nek) sh-done:~(sh-prod sh cli) :: - ::> || - ::> || %messages - ::> || - ::> storing and updating messages. - ::+| + :> # + :> # %messages + :> # + :> storing and updating messages. + +| :: - ++ ta-unpack ::< open envelopes - ::> the client currently doesn't care about nums. + ++ ta-unpack + :> open envelopes + :> + :> the client currently doesn't care about nums. :: |= nes/(list envelope) ^+ +> (ta-lesson (turn nes tail)) :: - ++ ta-lesson ::< learn messages - ::> learn all telegrams in a list. + ++ ta-lesson + :> learn all telegrams in a list. :: |= gaz/(list telegram) ^+ +> ?~ gaz +> $(gaz t.gaz, +> (ta-learn i.gaz)) :: - ++ ta-learn ::< save/update message - ::> store an incoming telegram, updating if it - ::> already exists. + ++ ta-learn + :> save/update message + :> + :> store an incoming telegram, updating if it + :> already exists. :: |= gam/telegram ^+ +> =+ old=(renum uid.gam) ?~ old - (ta-append gam) ::< add - (ta-revise u.old gam) ::< modify + (ta-append gam) :: add + (ta-revise u.old gam) :: modify :: - ++ ta-append ::< append message - ::> store a new telegram. + ++ ta-append + :> store a new telegram. :: |= gam/telegram ^+ +> @@ -449,8 +474,8 @@ =< sh-done (~(sh-gram sh cli) gam) :: - ++ ta-revise ::< revise message - ::> modify a telegram we know. + ++ ta-revise + :> modify a telegram we know. :: |= {num/@ud gam/telegram} =+ old=(snag num grams) @@ -463,22 +488,22 @@ =< sh-done (~(sh-gram sh cli) gam) :: - ::> || - ::> || %console - ::> || - ::> arms for shell functionality. - ::+| + :> # + :> # %console + :> # + :> arms for shell functionality. + +| :: - ++ ta-console ::< initialize shell - ::> initialize the shell of this client. + ++ ta-console + :> initialize the shell of this client. :: ^+ . =/ she/shell %*(. *shell id ost.bol, active (sy incir ~), width 80) sh-done:~(sh-prod sh she) :: - ++ ta-sole ::< apply sole input - ::> applies sole-action. + ++ ta-sole + :> apply sole input :: |= act/sole-action ^+ +> @@ -486,38 +511,42 @@ ~&(%strange-sole !!) sh-done:(~(sh-sole sh cli) act) :: - ++ sh ::< per console - ::> shell core, responsible for handling user input - ::> and the related actions, and outputting changes - ::> to the cli. + ++ sh + :> per console + :> + :> shell core, responsible for handling user input + :> and the related actions, and outputting changes + :> to the cli. :: - |_ $: ::> she: console state. - ::> man: our mailbox + |_ $: :> she: console state. :: she/shell == :: - ++ sh-done ::< resolve core - ::> stores changes to the cli. + :> # %resolve + +| + :: + ++ sh-done + :> stores changes to the cli. :: ^+ +> +>(cli she) :: - ::> || - ::> || %emitters - ::> || - ::> arms that create outward changes. - ::+| + :> # + :> # %emitters + :> # + :> arms that create outward changes. + +| :: - ++ sh-fact ::< send console effect - ::> adds a console effect to ++ta's moves. + ++ sh-fact + :> adds a console effect to ++ta's moves. :: |= fec/sole-effect ^+ +> +>(moves [[id.she %diff %sole-effect fec] moves]) :: - ++ sh-act ::< send action - ::> adds an action to ++ta's moves. + ++ sh-act + :> adds an action to ++ta's moves. :: |= act/action ^+ +> @@ -532,14 +561,14 @@ == == :: - ::> || - ::> || %cli-interaction - ::> || - ::> processing user input as it happens. - ::+| + :> # + :> # %cli-interaction + :> # + :> processing user input as it happens. + +| :: - ++ sh-sole ::< apply edit - ::> applies sole action. + ++ sh-sole + :> applies sole action. :: |= act/sole-action ^+ +> @@ -549,9 +578,11 @@ $ret sh-obey == :: - ++ sh-edit ::< apply sole edit - ::> called when typing into the cli prompt. - ::> applies the change and does sanitizing. + ++ sh-edit + :> apply sole edit + :> + :> called when typing into the cli prompt. + :> applies the change and does sanitizing. :: |= cal/sole-change ^+ +> @@ -567,36 +598,40 @@ +>.$ (sh-slug fix) :: - ++ sh-read ::< command parser - ::> parses the command line buffer. produces work - ::> items which can be executed by ++sh-work. + ++ sh-read + :> command parser + :> + :> parses the command line buffer. produces work + :> items which can be executed by ++sh-work. :: =< work - ::> || %parsers - ::> various parsers for command line input. + :> # %parsers + :> various parsers for command line input. |% - ++ expr ::< [cord hoon] + ++ expr + :> [cord hoon] |= tub/nail %. tub %+ stag (crip q.tub) wide:(vang & [&1:% &2:% (scot %da now.bol) |3:%]) :: - ++ dare ::< @dr + ++ dare + :> @dr %+ sear |= a/coin ?. ?=({$$ $dr @} a) ~ (some `@dr`+>.a) nuck:so :: - ++ ship ;~(pfix sig fed:ag) ::< ship - ++ shiz ::< ship set + ++ ship ;~(pfix sig fed:ag) :< ship + ++ shiz :< ship set %+ cook |=(a/(list ^ship) (~(gas in *(set ^ship)) a)) (most ;~(plug com (star ace)) ship) :: - ++ cire ::< local circle + ++ cire :< local circle ;~(pfix cen sym) :: - ++ circ ::< circle + ++ circ :< circle ;~ pose (cold incir col) ;~(pfix cen (stag our sym)) @@ -611,7 +646,7 @@ == == :: - ++ circles-flat ::< collapse mixed list + ++ circles-flat :< collapse mixed list |= a/(list (each circle (set circle))) ^- (set circle) ?~ a ~ @@ -620,13 +655,15 @@ $| (~(uni in $(a t.a)) p.i.a) == :: - ++ cirs ::< non-empty circles + ++ cirs :< non-empty circles %+ cook circles-flat %+ most ;~(plug com (star ace)) (^pick circ (sear sh-glyf glyph)) :: - ++ drat ::< @da or @dr - ::> pas: whether @dr's are in the past or not. + ++ drat + :> @da or @dr + :> + :> pas: whether @dr's are in the past or not. |= pas/? =- ;~(pfix sig (sear - crub:so)) |= a/^dime @@ -638,8 +675,8 @@ ?:(pas sub add) == :: - ++ pont ::< point for range - ::> hed: whether this is the head or tail point. + ++ pont :< point for range + :> hed: whether this is the head or tail point. |= hed/? ;~ pose (cold [%da now.bol] (jest 'now')) @@ -647,7 +684,7 @@ (stag %ud dem:ag) == :: - ++ rang ::< subscription range + ++ rang :< subscription range =+ ;~ pose (cook some ;~(pfix fas (pont |))) (easy ~) @@ -657,14 +694,14 @@ (easy ~) == :: - ++ sorz ::< non-empty sources + ++ sorz :< non-empty sources %+ cook ~(gas by *(map circle range)) (most ;~(plug com (star ace)) ;~(plug circ rang)) :: - ++ pick ::< message reference + ++ pick :< message reference ;~(pose nump (cook lent (star sem))) :: - ++ nump ::< number reference + ++ nump :< number reference ;~ pose ;~(pfix hep dem:ag) ;~ plug @@ -674,22 +711,22 @@ (stag 0 dem:ag) == :: - ++ pore ::< security + ++ pore :< security (perk %channel %village %journal %mailbox ~) :: - ++ lobe ::< y/n loob + ++ lobe :< y/n loob ;~ pose (cold %& ;~(pose (jest 'y') (jest '&') (just 'true'))) (cold %| ;~(pose (jest 'n') (jest '|') (just 'false'))) == :: - ++ message ::< exp, lin or url msg + ++ message :< exp, lin or url msg ;~ pose ;~(plug (cold %eval hax) expr) (stag %say speeches) == :: - ++ speeches ::< lin or url msgs + ++ speeches :< lin or url msgs %+ most (jest '•') ;~ pose (stag %url aurf:de-purl:html) @@ -697,20 +734,20 @@ :(stag %lin | ;~(less sem hax text)) == :: - ++ text ::< msg without break + ++ text :< msg without break %+ cook crip (plus ;~(less (jest '•') next)) :: - ++ nick (cook crip (plus next)) ::< nickname - ++ glyph (mask "/\\\{( parses cli prompt input using ++sh-read and - ::> sanitizes when invalid. + ++ sh-sane + :> sanitize input + :> + :> parses cli prompt input using ++sh-read and + :> sanitizes when invalid. :: |= {inv/sole-edit buf/(list @c)} ^- {lit/(list sole-edit) err/(unit @u)} @@ -878,8 +917,8 @@ ?~(q.wok ~ $(wok u.q.wok)) == :: - ++ sh-slug ::< edit to sanity - ::> corrects invalid prompt input. + ++ sh-slug + :> corrects invalid prompt input. :: |= {lit/(list sole-edit) err/(unit @u)} ^+ +> @@ -888,12 +927,14 @@ (~(transmit sole say.she) `sole-edit`?~(t.lit i.lit [%mor lit])) (sh-fact [%mor [%det lic] ?~(err ~ [%err u.err]~)]) :: - ++ sh-obey ::< apply result - ::> called upon hitting return in the prompt. if - ::> input is invalid, ++sh-slug is called. - ::> otherwise, the appropriate work is done and - ::> the entered command (if any) gets displayed - ::> to the user. + ++ sh-obey + :> apply result + :> + :> called upon hitting return in the prompt. if + :> input is invalid, ++sh-slug is called. + :> otherwise, the appropriate work is done and + :> the entered command (if any) gets displayed + :> to the user. :: =+ fix=(sh-sane [%nop ~] buf.say.she) ?^ lit.fix @@ -914,28 +955,31 @@ [%txt (runt [14 '-'] `tape`['|' ' ' (tufa `(list @)`buf)])] == :: - ::> || - ::> || %user-action - ::> || - ::> processing user actions. - ::+| + :> # + :> # %user-action + :> # + :> processing user actions. + +| :: - ++ sh-work ::< do work - ::> implements worker arms for different talk - ::> commands. - ::> worker arms must produce updated state. + ++ sh-work + :> do work + :> + :> implements worker arms for different talk + :> commands. + :> worker arms must produce updated state. :: |= job/work ^+ +> =< work |% :: - ::> || - ::> || %helpers - ::> || - ::+| + :> # + :> # %helpers + :> # + +| :: - ++ work ::< call correct worker + ++ work + :> call correct worker ?- -.job :: circle management $join (join +.job) @@ -975,8 +1019,8 @@ $help help == :: - ++ activate ::< from %number - ::> prints message details. + ++ activate + :> prints message details. :: |= gam/telegram ^+ ..sh-work @@ -984,8 +1028,8 @@ =. ..sh-work (sh-fact tr-fact:tay) sh-prod(active.she aud.gam) :: - ++ deli ::< find number - ::> gets absolute message number from relative. + ++ deli + :> gets absolute message number from relative. :: |= {max/@ud nul/@u fin/@ud} ^- @ud @@ -994,9 +1038,11 @@ =- ?:((lte - max) - (sub - dog)) (add fin (sub max (mod max dog))) :: - ++ set-glyph ::< new glyph binding - ::> applies glyph binding to our state and sends - ::> an action. + ++ set-glyph + :> new glyph binding + :> + :> applies glyph binding to our state and sends + :> an action. :: |= {cha/char aud/audience} =: bound (~(put by bound) aud cha) @@ -1004,9 +1050,11 @@ == sh-prod:(sh-act %glyph cha aud &) :: - ++ unset-glyph ::< old glyph binding - ::> removes either {aud} or all bindings on a - ::> glyph and sends an action. + ++ unset-glyph + :> remote old glyph binding + :> + :> removes either {aud} or all bindings on a + :> glyph and sends an action. :: |= {cha/char aud/(unit audience)} =/ ole/(set audience) @@ -1022,8 +1070,8 @@ binds (~(del ju binds) cha n.ole) == :: - ++ reverse-nicks ::< find by handle - ::> finds all ships whose handle matches {nym}. + ++ reverse-nicks + :> finds all ships whose handle matches {nym}. :: |= nym/^nick ^- (list ship) @@ -1032,22 +1080,26 @@ ?. =(q nym) ~ [~ u=p] :: - ++ hoon-head ::< eval data - ::> makes a vase of environment data to evaluate - ::> against (for #-messages). + ++ hoon-head + :> eval data + :> + :> makes a vase of environment data to evaluate + :> against (for #-messages). :: ^- vase !> ^- {our/@p now/@da eny/@uvI} [our now.bol (shas %eny eny.bol)] :: - ::> || - ::> || %circle-management - ::> || - ::+| + :> # + :> # %circle-management + :> # + +| :: - ++ join ::< %join - ::> change local mailbox config to include - ::> subscriptions to {pas}. + ++ join + :> %join + :> + :> change local mailbox config to include + :> subscriptions to {pas}. :: |= pos/(map circle range) ^+ ..sh-work @@ -1061,9 +1113,11 @@ ?~(r `[da+(sub now.bol ~d1) ~] r) (sh-act %source inbox & pos) :: - ++ leave ::< %leave - ::> change local mailbox config to exclude - ::> subscriptions to {pas}. + ++ leave + :> %leave + :> + :> change local mailbox config to exclude + :> subscriptions to {pas}. :: |= pas/(set circle) ^+ ..sh-work @@ -1082,8 +1136,10 @@ (sh-act %source inbox | pos) (sh-act %notify pas ~) :: - ++ create ::< %create - ::> creates circle {nom} with specified config. + ++ create + :> %create + :> + :> creates circle {nom} with specified config. :: |= {sec/security nom/naem txt/cord} ^+ ..sh-work @@ -1091,24 +1147,30 @@ (sh-act %create nom txt sec) (join [[[our nom] ~] ~ ~]) :: - ++ delete ::< %delete - ::> deletes our circle {nom}, after optionally - ::> sending a last announce message {say}. + ++ delete + :> %delete + :> + :> deletes our circle {nom}, after optionally + :> sending a last announce message {say}. :: |= {nom/naem say/(unit cord)} ^+ ..sh-work (sh-act %delete nom say) :: - ++ depict ::< %depict - ::> changes the description of {nom} to {txt}. + ++ depict + :> %depict + :> + :> changes the description of {nom} to {txt}. :: |= {nom/naem txt/cord} ^+ ..sh-work (sh-act %depict nom txt) :: - ++ permit ::< %invite / %banish - ::> invites or banishes {sis} to/from our - ::> circle {nom}. + ++ permit + :> %invite / %banish + :> + :> invites or banishes {sis} to/from our + :> circle {nom}. :: |= {inv/? nom/naem sis/(set ship)} ^+ ..sh-work @@ -1119,63 +1181,71 @@ ^+ ..sh-work (sh-act %filter nom cus utf) :: - ++ source ::< %source - ::> adds {pas} to {nom}'s src. + ++ source + :> %source + :> + :> adds {pas} to {nom}'s src. :: |= {sub/? nom/naem pos/(map circle range)} ^+ ..sh-work (sh-act %source nom sub pos) :: - ::> || - ::> || %personal-metadata - ::> || - ::+| + :> # + :> # %personal-metadata + :> # + +| :: - ++ attend ::< set our presence - ::> sets our presence to {pec} for {aud}. + ++ attend + :> sets our presence to {pec} for {aud}. :: |= {aud/audience pec/(unit presence)} ^+ ..sh-work (sh-act %notify aud pec) :: - ++ name ::< set our name - ::> sets our name to {man} for {aud}. + ++ name + :> sets our name to {man} for {aud}. :: |= {aud/audience man/human} ^+ ..sh-work (sh-act %naming aud man) :: - ::> || - ::> || %messaging - ::> || - ::+| + :> # + :> # %messaging + :> # + +| :: - ++ say ::< publish - ::> sends message. + ++ say + :> sends message. :: |= sep/(list speech) ^+ ..sh-work (sh-act %phrase active.she sep) :: - ++ eval ::< run - ::> executes {exe} and sends both its code and - ::> result. + ++ eval + :> run + :> + :> executes {exe} and sends both its code and + :> result. :: |= {txt/cord exe/hoon} => |.([(sell (slap (slop hoon-head seed) exe))]~) =+ tan=p:(mule .) (say [%exp txt tan] ~) :: - ++ target ::< %target - ::> sets messaging target, then execute {woe}. + ++ target + :> %target + :> + :> sets messaging target, then execute {woe}. :: |= {aud/audience woe/(unit ^work)} ^+ ..sh-work =. ..sh-pact (sh-pact aud) ?~(woe ..sh-work work(job u.woe)) :: - ++ reply ::< %reply - ::> send a reply to the selected message. + ++ reply + :> %reply + :> + :> send a reply to the selected message. :: |= {num/$@(@ud {p/@u q/@ud}) sep/(list speech)} ^+ ..sh-work @@ -1191,13 +1261,15 @@ uid:(snag (sub count +(msg)) grams) (say (turn sep |=(s/speech [%ire ser s]))) :: - ::> || - ::> || %displaying-info - ::> || - ::+| + :> # + :> # %displaying-info + :> # + +| :: - ++ who ::< %who - ::> prints presence lists for {cis} or all. + ++ who + :> %who + :> + :> prints presence lists for {cis} or all. :: |= cis/(set circle) ^+ ..sh-work =< (sh-fact %mor (murn (sort ~(tap by remotes) aor) .)) @@ -1216,8 +1288,10 @@ $talk `leaf+:(weld "talk " (scow %p a) " " (trip (fall han.c ''))) == :: - ++ what ::< %what - ::> prints binding details. goes both ways. + ++ what + :> %what + :> + :> prints binding details. goes both ways. :: |= qur/(unit $@(char audience)) ^+ ..sh-work @@ -1242,8 +1316,10 @@ ^- (list sole-effect) [%txt [gyf ' ' ~(ar-phat ar a)]]~ :: - ++ number ::< %number - ::> finds selected message, expand it. + ++ number + :> %number + :> + :> finds selected message, expand it. :: |= num/$@(@ud {p/@u q/@ud}) ^+ ..sh-work @@ -1261,8 +1337,10 @@ (activate (snag (sub count +(msg)) grams)) (sh-lame "…{(reap p.num '0')}{(scow %ud q.num)}: no such telegram") :: - ++ list-sources ::< %sources - ::> display the active sources for our circle. + ++ list-sources + :> %sources + :> + :> display the active sources for our circle. :: |= cir/circle ^+ ..sh-work @@ -1279,13 +1357,15 @@ |= {a/@ta b/tape} :(weld b "/" (trip a)) :: - ::> || - ::> || %ui-settings - ::> || - ::+| + :> # + :> # %ui-settings + :> # + +| :: - ++ bind ::< %bind - ::> binds targets {aud} to the glyph {cha}. + ++ bind + :> %bind + :> + :> binds targets {aud} to the glyph {cha}. :: |= {cha/char aud/(unit audience)} ^+ ..sh-work @@ -1295,8 +1375,10 @@ %. "bound {} {}" sh-note:sh-prod:(set-glyph cha u.aud) :: - ++ unbind ::< %unbind - ::> unbinds targets {aud} to glyph {cha}. + ++ unbind + :> %unbind + :> + :> unbinds targets {aud} to glyph {cha}. :: |= {cha/char aud/(unit audience)} ^+ ..sh-work @@ -1307,27 +1389,29 @@ %. "unbound {}" sh-note:sh-prod:(unset-glyph cha aud) :: - ++ nick ::< %nick - ::> either shows, sets or unsets nicknames - ::> depending on arguments. + ++ nick + :> %nick + :> + :> either shows, sets or unsets nicknames + :> depending on arguments. :: |= {her/(unit ship) nym/(unit ^nick)} ^+ ..sh-work - ::> no arguments, show all + :: no arguments, show all ?: ?=({$~ $~} +<) %+ sh-fact %mor %+ turn ~(tap by nicks) |= {p/ship q/^nick} :- %txt "{

}: {}" - ::> show her nick + :: show her nick ?~ nym ?> ?=(^ her) =+ asc=(~(get by nicks) u.her) %+ sh-fact %txt ?~ asc "{} unbound" "{}: {}" - ::> show nick ship + :: show nick ship ?~ her %+ sh-fact %mor %+ turn (reverse-nicks u.nym) @@ -1337,14 +1421,16 @@ %= sh-act nicks ?~ u.nym - ::> unset nickname + :: unset nickname (~(del by nicks) u.her) - ::> set nickname + :: set nickname (~(put by nicks) u.her u.nym) == :: - ++ wo-set ::< %set - ::> enables ui setting flag. + ++ wo-set + :> %set + :> + :> enables ui setting flag. :: |= seg/term ^+ ..sh-work @@ -1357,8 +1443,10 @@ settings.she (~(put in settings.she) seg) == :: - ++ unset ::< %unset - ::> disables ui setting flag. + ++ unset + :> %unset + :> + :> disables ui setting flag. :: |= neg/term ^+ ..sh-work @@ -1366,63 +1454,77 @@ settings.she (~(del in settings.she) neg) == :: - ++ width ::< ;set width - ::> change the display width in cli. + ++ width + :> ;set width + :> + :> change the display width in cli. :: |= wid/@ud ^+ ..sh-work ..sh-work(width.she (max 30 wid)) :: - ++ timez ::< ;set timezone - ::> adjust the displayed timestamp. + ++ timez + :> ;set timezone + :> + :> adjust the displayed timestamp. :: |= tim/(pair ? @ud) ^+ ..sh-work ..sh-work(timez.she tim) :: - ::> || - ::> || %miscellaneous - ::> || - ::+| + :> # + :> # %miscellaneous + :> # + +| :: - ++ public ::< show/hide membership - ::> adds or removes the circle from the public - ::> membership list. + ++ public + :> show/hide membership + :> + :> adds or removes the circle from the public + :> membership list. :: |= {add/? cir/circle} (sh-act %public add cir) :: - ++ help ::< %help - ::> prints help message + ++ help + :> %help + :> + :> prints help message :: (sh-fact %txt "see http://urbit.org/docs/using/messaging/") -- :: - ++ sh-pact ::< update active aud - ::> change currently selected audience to {aud} - ::> and update the prompt. + ++ sh-pact + :> update active aud + :> + :> change currently selected audience to {aud} + :> and update the prompt. :: |= aud/audience ^+ +> - ::> ensure we can see what we send. + :: ensure we can see what we send. =+ act=(sh-pare aud) ?: =(active.she act) +>.$ sh-prod(active.she act) :: - ++ sh-pare ::< adjust target list - ::> if the audience {aud} does not contain a - ::> circle we're subscribed to, add our mailbox - ::> to the audience (so that we can see our own - ::> message). + ++ sh-pare + :> adjust target list + :> + :> if the audience {aud} does not contain a + :> circle we're subscribed to, add our mailbox + :> to the audience (so that we can see our own + :> message). :: |= aud/audience ?: (sh-pear aud) aud (~(put in aud) incir) :: - ++ sh-pear ::< hearback - ::> produces true if any circle is included in - ::> our subscriptions, meaning, we hear messages - ::> sent to {aud}. + ++ sh-pear + :> hearback + :> + :> produces true if any circle is included in + :> our subscriptions, meaning, we hear messages + :> sent to {aud}. :: |= aud/audience ?~ aud | @@ -1431,33 +1533,37 @@ $(aud r.aud) == :: - ++ sh-glyf ::< decode glyph - ::> finds the circle(s) that match a glyph. + ++ sh-glyf + :> decode glyph + :> + :> finds the circle(s) that match a glyph. :: |= cha/char ^- (unit audience) =+ lax=(~(get ju binds) cha) - ::> no circle. + :: no circle. ?: =(~ lax) ~ - ::> single circle. + :: single circle. ?: ?=({* $~ $~} lax) `n.lax - ::> in case of multiple audiences, pick the most recently active one. + :: in case of multiple audiences, pick the most recently active one. |- ^- (unit audience) ?~ grams ~ - ::> get first circle from a telegram's audience. + :: get first circle from a telegram's audience. =+ pan=(silt ~(tap in aud.i.grams)) ?: (~(has in lax) pan) `pan $(grams t.grams) :: - ::> || - ::> || %differs - ::> || - ::> arms that calculate differences between datasets. - ::+| + :> # + :> # %differs + :> # + :> arms that calculate differences between datasets. + +| :: - ++ sh-group-diff ::< group diff parts - ::> calculates the difference between two presence - ::> lists, producing lists of removed, added and - ::> changed presences. + ++ sh-group-diff + :> group diff parts + :> + :> calculates the difference between two presence + :> lists, producing lists of removed, added and + :> changed presences. :: |= {one/group two/group} =| $= ret @@ -1492,10 +1598,12 @@ ret ret :: - ++ sh-rempe-diff ::< remotes diff - ::> calculates the difference between two remote - ::> presence maps, producing a list of removed, - ::> added and changed presences maps. + ++ sh-rempe-diff + :> remotes diff + :> + :> calculates the difference between two remote + :> presence maps, producing a list of removed, + :> added and changed presences maps. :: |= {one/(map circle group) two/(map circle group)} =| $= ret @@ -1524,10 +1632,12 @@ ret(new [i.owt new.ret]) ret :: - ++ sh-remco-diff ::< config diff parts - ::> calculates the difference between two config - ::> maps, producing lists of removed, added and - ::> changed configs. + ++ sh-remco-diff + :> config diff parts + :> + :> calculates the difference between two config + :> maps, producing lists of removed, added and + :> changed configs. :: |= {one/(map circle config) two/(map circle config)} =| $= ret @@ -1556,28 +1666,34 @@ ret(new [i.owt new.ret]) ret :: - ++ sh-set-diff ::< set diff - ::> calculates the difference between two sets, - ::> procuding lists of removed and added items. + ++ sh-set-diff + :> set diff + :> + :> calculates the difference between two sets, + :> procuding lists of removed and added items. :: |* {one/(set *) two/(set *)} :- ^= old ~(tap in (~(dif in one) two)) ^= new ~(tap in (~(dif in two) one)) :: - ::> || - ::> || %printers - ::> || - ::> arms for printing data to the cli. - ::+| + :> # + :> # %printers + :> # + :> arms for printing data to the cli. + +| :: - ++ sh-lame ::< send error - ::> just puts some text into the cli as-is. + ++ sh-lame + :> send error + :> + :> just puts some text into the cli as-is. :: |= txt/tape (sh-fact [%txt txt]) :: - ++ sh-note ::< shell message - ::> left-pads {txt} with heps and prints it. + ++ sh-note + :> shell message + :> + :> left-pads {txt} with heps and prints it. :: |= txt/tape ^+ +> @@ -1585,9 +1701,11 @@ %+ runt [14 '-'] `tape`['|' ' ' (scag (sub width.she 16) txt)] :: - ++ sh-prod ::< show prompt - ::> makes and stores a move to modify the cli - ::> prompt to display the current audience. + ++ sh-prod + :> show prompt + :> + :> makes and stores a move to modify the cli + :> prompt to display the current audience. :: ^+ . %+ sh-fact %pro @@ -1600,8 +1718,8 @@ =+ por=~(ar-prom ar q.rew) (weld `tape`[p.p.rew por] `tape`[q.p.rew ' ' ~]) :: - ++ sh-rend ::< print telegram - ::> prints a telegram as rendered by ++tr-rend. + ++ sh-rend + :> prints a telegram as rendered by ++tr-rend. :: |= gam/telegram ^+ +> @@ -1617,8 +1735,8 @@ [%txt t] [%mor [%txt t] [%bel ~] ~] :: - ++ sh-numb ::< print msg number - ::> prints a message number, left-padded by heps. + ++ sh-numb + :> prints a message number, left-padded by heps. :: |= num/@ud ^+ +> @@ -1626,22 +1744,24 @@ %+ sh-fact %txt (runt [(sub 13 (lent bun)) '-'] "[{bun}]") :: - ++ sh-cure ::< readable security - ::> renders a security kind. + ++ sh-cure + :> renders a security kind. :: |= a/security ^- tape (scow %tas a) :: - ++ sh-scis ::< render status - ::> gets the presence of {saz} as a tape. + ++ sh-scis + :> render status + :> + :> gets the presence of {saz} as a tape. :: |= sat/status ^- tape ['%' (trip pec.sat)] :: - ++ sh-show-status ::< print status diff - ::> prints presence changes to the cli. + ++ sh-show-status + :> prints presence changes to the cli. :: |= {cir/circle who/ship cur/status dif/diff-status} ^+ +> @@ -1671,8 +1791,8 @@ "bye {(scow %p who)}" == :: - ++ sh-show-config ::< show config - ::> prints config changes to the cli. + ++ sh-show-config + :> prints config changes to the cli. :: |= {cir/circle cur/config dif/diff-config} ^+ +> @@ -1719,9 +1839,11 @@ (weld t (cite:title s)) == :: - ++ sh-gram ::< show telegram - ::> prints the telegram. every fifth message, - ::> print the message number also. + ++ sh-gram + :> show telegram + :> + :> prints the telegram. every fifth message, + :> print the message number also. :: |= gam/telegram ^+ +> @@ -1735,8 +1857,8 @@ (sh-numb num) (sh-rend(latest.she num) gam) :: - ++ sh-grams ::< do show telegrams - ::> prints multiple telegrams. + ++ sh-grams + :> prints multiple telegrams. :: |= gaz/(list telegram) ^+ +> @@ -1746,22 +1868,26 @@ -- -- :: -::> || -::> || %renderers -::> || -::> rendering cores. -::+| +:> # +:> # %renderers +:> # +:> rendering cores. ++| :: -++ cr ::< circle renderer - ::> used in both circle and ship rendering. +++ cr + :> circle renderer + :> + :> used in both circle and ship rendering. :: - |_ ::> one: the circle. + |_ :> one: the circle. :: one/circle :: - ++ cr-beat ::< {one} more relevant? - ::> returns true if one is better to show, false - ::> otherwise. prioritizes: our > main > size. + ++ cr-beat + :> {one} more relevant? + :> + :> returns true if one is better to show, false + :> otherwise. prioritizes: our > main > size. :: |= two/circle ^- ? @@ -1782,25 +1908,27 @@ :: if they're from different ships, neither ours, pick hierarchically. (lth (xeb hos.one) (xeb hos.two)) :: - ++ cr-best ::< get most relevant - ::> returns the most relevant circle. + ++ cr-best + :> returns the most relevant circle. :: |= two/circle ?:((cr-beat two) one two) :: - ++ cr-curt ::< render name in 14 - ::> prints a ship name in 14 characters. left-pads - ::> with spaces. {mup} signifies "are there other - ::> targets besides this one?" + ++ cr-curt + :> prints a ship name in 14 characters. + :> + :> left-pads with spaces. {mup} signifies + :> "are there other targets besides this one?" :: |= mup/? ^- tape =+ raw=(cite:title hos.one) (runt [(sub 14 (lent raw)) ' '] raw) :: - ++ cr-nick ::< nick or name in 14 - ::> get nick for ship, or shortname if no nick. - ::> left-pads with spaces. + ++ cr-nick + :> get nick for ship, or shortname if no nick. + :> + :> left-pads with spaces. :: |= aud/audience ^- tape @@ -1818,6 +1946,9 @@ =+ len=(sub 14 (lent raw)) (weld (reap len ' ') raw) :: + :: todo: figure out why enabling the doccord causes a nest fail, even when + :: attached to the arm instead of the product. + :: ++ cr-phat ::< render accurately ::> prints a circle fully, but still taking ::> "shortcuts" where possible: @@ -1837,12 +1968,12 @@ ['/' (trip nom.one)] :(welp wun "/" (trip nom.one)) :: - ++ cr-full (cr-show ~) ::< render full width + ++ cr-full (cr-show ~) :< render full width :: - ++ cr-show ::< render circle - ::> renders a circle as text. - :: - ::> moy: multiple circles in audience? + ++ cr-show + :> renders a circle as text. + :> + :> moy: multiple circles in audience? |= moy/(unit ?) ^- tape :: render circle (as glyph if we can). @@ -1853,16 +1984,18 @@ (~(cr-curt cr one) u.moy) -- :: -++ ar ::< audience renderer - ::> used for representing audiences (sets of circles) - ::> as tapes. +++ ar + :> audience renderer + :> + :> used for representing audiences (sets of circles) + :> as tapes. :: - |_ ::> aud: members of the audience. + |_ :> aud: members of the audience. :: aud/audience :: - ++ ar-best ::< most relevant - ::> find the most relevant circle in the set. + ++ ar-best + :> find the most relevant circle in the set. :: ^- (unit circle) ?~ aud ~ @@ -1874,22 +2007,24 @@ =? n.aud ?=(^ rit) (~(cr-best cr n.aud) u.rit) n.aud :: - ++ ar-deaf ::< except for self - ::> remove ourselves from the audience. + ++ ar-deaf + :> remove ourselves from the audience. :: ^+ . .(aud (~(del in aud) `circle`incir)) :: - ++ ar-maud ::< multiple audience - ::> checks if there's multiple circles in the - ::> audience via pattern matching. + ++ ar-maud + :> multiple audience + :> + :> checks if there's multiple circles in the + :> audience via pattern matching. :: ^- ? =. . ar-deaf !?=($@($~ {* $~ $~}) aud) :: - ++ ar-phat ::< render full-size - ::> render all circles, no glyphs. + ++ ar-phat + :> render all circles, no glyphs. :: ^- tape %- ~(rep in aud) @@ -1898,8 +2033,8 @@ (weld t ", ") (weld t ~(cr-phat cr c)) :: - ++ ar-prom ::< render targets - ::> render all circles, ordered by relevance. + ++ ar-prom + :> render all circles, ordered by relevance. :: ^- tape =. . ar-deaf @@ -1916,13 +2051,13 @@ $(all t.all, fir |) == :: - ++ ar-whom ::< render sender - ::> render sender as the most relevant circle. + ++ ar-whom + :> render sender as the most relevant circle. :: (~(cr-show cr (need ar-best)) ~ ar-maud) :: - ++ ar-dire ::< direct message - ::> returns true if circle is a mailbox of ours. + ++ ar-dire + :> returns true if circle is a mailbox of ours. :: |= cir/circle ^- ? ?& =(hos.cir our) @@ -1930,7 +2065,11 @@ &(?=(^ sot) ?=($mailbox sec.con.u.sot)) == :: - ++ ar-glyf ::< audience glyph + ++ ar-glyf + :: todo: another place where doccords break things. + :: + ::> audience glyph + ::> ::> get the glyph that corresponds to the audience. ::> for mailbox messages and complex audiences, use ::> reserved "glyphs". @@ -1945,21 +2084,19 @@ ";" -- :: -++ tr ::< telegram renderer - ::> responsible for converting telegrams and - ::> everything relating to them to text to be - ::> displayed in the cli. +++ tr + :> telegram renderer + :> + :> responsible for converting telegrams and + :> everything relating to them to text to be + :> displayed in the cli. :: - |_ $: ::> sef: settings flags. - ::> \ telegram - ::> who: author. - ::> \ thought - ::> sen: unique identifier. - ::> aud: audience. - ::> \ statement - ::> wen: timestamp. - ::> bou: complete aroma. - ::> sep: message contents. + |_ $: :> sef: settings flags. + :> who: author. + :> sen: unique identifier. + :> aud: audience. + :> wen: timestamp. + :> sep: message contents. :: sef/(set term) who/ship @@ -1969,17 +2106,20 @@ sep/speech == :: - ++ tr-fact ::< activate effect - ::> produces sole-effect for printing message - ::> details. + ++ tr-fact + :> activate effect + :> + :> produces sole-effect for printing message + :> details. :: ^- sole-effect ~[%mor [%tan tr-meta] tr-body] :: - ++ tr-rend ::< render telegram - ::> renders a telegram. - ::> the first line will contain the author and - ::> optional timestamp. + ++ tr-rend + :> renders a telegram + :> + :> the first line will contain the author and + :> optional timestamp. :: ^- (list tape) =/ wyd @@ -2023,9 +2163,11 @@ ?~ l [:(weld nom t tam) ~] [(weld den t) l] :: - ++ tr-meta ::< metadata - ::> builds string that display metadata, including - ::> message serial, timestamp, author and audience. + ++ tr-meta + :> metadata + :> + :> builds string that display metadata, including + :> message serial, timestamp, author and audience. :: ^- tang =. wen (sub wen (mod wen (div wen ~s0..0001))) :: round @@ -2036,9 +2178,11 @@ leaf+~(cr-full cr a) [%rose [" " ~ ~] [hed >who< [%rose [", " "to " ~] cis] ~]]~ :: - ++ tr-body ::< message content - ::> long-form display of message contents, specific - ::> to each speech type. + ++ tr-body + :> message content + :> + :> long-form display of message contents, specific + :> to each speech type. :: |- ^- sole-effect ?- -.sep @@ -2077,8 +2221,8 @@ [%mor tan+~[leaf+"[{(trip app.sep)}]: "] $(sep sep.sep) ~] == :: - ++ tr-tach ::< attachment - ::> renders an attachment. + ++ tr-tach + :> renders an attachment. :: |= a/attache ^- tang @@ -2088,10 +2232,12 @@ $text (turn (flop +.a) |=(b/cord leaf+(trip b))) == :: - ++ tr-chow ::< truncate - ::> truncates the {txt} to be of max {len} - ::> characters. if it does truncate, indicates it - ::> did so by appending _ or …. + ++ tr-chow + :> truncate + :> + :> truncates the {txt} to be of max {len} + :> characters. if it does truncate, indicates it + :> did so by appending _ or …. :: |= {len/@u txt/tape} ^- tape @@ -2108,13 +2254,15 @@ ?~ t.txt "…" [i.txt $(txt t.txt)] :: - ++ tr-text ::< compact contents - ::> renders just the most important data of the - ::> message. if possible, these stay within a single - ::> line. + ++ tr-text + :> compact contents + :> + :> renders just the most important data of the + :> message. if possible, these stay within a single + :> line. + :> + :> pre: replace/append line prefix ::TODO this should probably be redone someday. - :: - ::> pre: replace/append line prefix =| pre/(unit (pair ? tape)) |= wyd/@ud ^- (list tape) @@ -2194,10 +2342,10 @@ == -- :: -::> || -::> || %events -::> || -::+| +:> # +:> # %events +:> # ++| :: ++ quit-server-client |= wir/wire @@ -2209,8 +2357,8 @@ ^- (quip move _+>) [[peer-inbox]~ +>] :: -++ peer ::< accept subscription - ::> incoming subscription on pax. +++ peer + :> incoming subscription on pax. :: |= pax/path ^- (quip move _+>) @@ -2222,22 +2370,22 @@ [~ +>] ta-done:ta-console:ta :: -++ diff-hall-prize ::< accept query answer - ::> +++ diff-hall-prize + :> accept query answer :: |= {way/wire piz/prize} ^- (quip move _+>) ta-done:(ta-take:ta piz) :: -++ diff-hall-rumor ::< accept query change - ::> +++ diff-hall-rumor + :> accept query change :: |= {way/wire rum/rumor} ^- (quip move _+>) ta-done:(ta-hear:ta rum) :: -++ poke-sole-action ::< accept console - ::> incoming sole action. process it. +++ poke-sole-action + :> incoming sole action. process it. :: |= act/sole-action ta-done:(ta-sole:ta act) @@ -2288,8 +2436,8 @@ +>(grams (oust [0 1] grams)) [~ +>] :: -++ coup-client-action ::< accept n/ack - ::> +++ coup-client-action + :> accept n/ack :: |= {wir/wire fal/(unit tang)} ^- (quip move _+>) diff --git a/sur/hall.hoon b/sur/hall.hoon index 6887c3291..25442a9b9 100644 --- a/sur/hall.hoon +++ b/sur/hall.hoon @@ -7,253 +7,253 @@ ::TODO rename det/delta in most place? they may be (different kinds of) deltas, :: but location in control flow already indicates delta-ness. :: -::> || -::> || %wrappers -::> || -::> wrapper molds, for semantic clarity. -::+| +:> # +:> # %wrappers +:> # +:> wrapper molds, for semantic clarity. ++| :: ::TODO rename -++ naem term ::< circle name -++ nick cord ::< local nickname +++ naem term :< circle name +++ nick cord :< local nickname :: -::> || -::> || %query-models -::> || -::> models relating to queries, their results and updates. -::+| +:> # +:> # %query-models +:> # +:> models relating to queries, their results and updates. ++| :: -++ query ::> query paths - $% {$client $~} ::< shared ui state - {$circles who/ship} ::< readable circles - {$public $~} ::< public memberships - {$burden who/ship} ::TODO eventually, nom/naem. ::< duties to share - {$report $~} ::< duty reports - {$peers nom/naem} ::< readers of story - $: $circle ::> story query - nom/naem ::< circle name - wer/(unit circle) ::< from source - wat/(set circle-data) ::< data to get - ran/range ::< query duration +++ query :> query paths + $% {$client $~} :< shared ui state + {$circles who/ship} :< readable circles + {$public $~} :< public memberships + {$burden who/ship} ::TODO eventually, nom/naem. :< duties to share + {$report $~} :< duty reports + {$peers nom/naem} :< readers of story + $: $circle :> story query + nom/naem :< circle name + wer/(unit circle) :< from source + wat/(set circle-data) :< data to get + ran/range :< query duration == :: ::TODO in the future, we may want much more :: :: detailed querying abilities. :: == :: -++ circle-data ::> kinds of circle data - $? $grams ::< messages - $group-l ::< local presence - $group-r ::< remote presences - $config-l ::< local config - $config-r ::< remote configs +++ circle-data :> kinds of circle data + $? $grams :< messages + $group-l :< local presence + $group-r :< remote presences + $config-l :< local config + $config-r :< remote configs == :: -++ range ::> inclusive msg range - %- unit ::< ~ means everything - $: hed/place ::< start of range - tal/(unit place) ::< opt end of range +++ range :> inclusive msg range + %- unit :< ~ means everything + $: hed/place :< start of range + tal/(unit place) :< opt end of range == :: -++ place ::> range indicators - $% {$da @da} ::< date - {$ud @ud} ::< message number +++ place :> range indicators + $% {$da @da} :< date + {$ud @ud} :< message number == :: -++ prize ::> query result - $% {$client prize-client} ::< /client - {$circles cis/(set naem)} ::< /circles - {$public cis/(set circle)} ::< /public - {$burden sos/(map naem burden)} ::< /burden - {$report $~} ::< /report - {$peers pes/(jar ship query)} ::< /peers - {$circle package} ::< /circle +++ prize :> query result + $% {$client prize-client} :< /client + {$circles cis/(set naem)} :< /circles + {$public cis/(set circle)} :< /public + {$burden sos/(map naem burden)} :< /burden + {$report $~} :< /report + {$peers pes/(jar ship query)} :< /peers + {$circle package} :< /circle == :: -++ prize-client ::> shared ui state - $: gys/(jug char audience) ::< glyph bindings - nis/(map ship nick) ::< local nicknames +++ prize-client :> shared ui state + $: gys/(jug char audience) :< glyph bindings + nis/(map ship nick) :< local nicknames == :: -++ rumor ::> query result change - $% {$client rum/rumor-client} ::< /client - {$circles add/? cir/naem} ::< /circles - {$public add/? cir/circle} ::< /public - {$burden nom/naem rum/rumor-story} ::< /burden - {$peers add/? who/ship qer/query} ::< /peers - {$circle rum/rumor-story} ::< /circle +++ rumor :> query result change + $% {$client rum/rumor-client} :< /client + {$circles add/? cir/naem} :< /circles + {$public add/? cir/circle} :< /public + {$burden nom/naem rum/rumor-story} :< /burden + {$peers add/? who/ship qer/query} :< /peers + {$circle rum/rumor-story} :< /circle == :: -++ rumor-client ::> changed ui state - $% {$glyph diff-glyph} ::< un/bound glyph - {$nick diff-nick} ::< changed nickname +++ rumor-client :> changed ui state + $% {$glyph diff-glyph} :< un/bound glyph + {$nick diff-nick} :< changed nickname == :: -++ shipment ::> standard payload - $: cos/lobby ::< loc & rem configs - pes/crowd ::< loc & rem presences +++ shipment :> standard payload + $: cos/lobby :< loc & rem configs + pes/crowd :< loc & rem presences == :: -++ burden ::> full story state - $: gaz/(list telegram) ::< all messages - shipment ::< metadata +++ burden :> full story state + $: gaz/(list telegram) :< all messages + shipment :< metadata == :: -++ package ::> story state - $: nes/(list envelope) ::< messages - shipment ::< metadata +++ package :> story state + $: nes/(list envelope) :< messages + shipment :< metadata == :: -++ diff-glyph {bin/? gyf/char aud/audience} ::< un/bound glyph -++ diff-nick {who/ship nic/nick} ::< changed nickname -++ diff-story ::> story change - $% {$new cof/config} ::< new story - {$bear bur/burden} ::< new inherited story - {$peer add/? who/ship qer/query} ::< gain/lose subscriber - {$config cir/circle dif/diff-config} ::< new/changed config - {$status cir/circle who/ship dif/diff-status} ::< new/changed status - {$remove $~} ::< removed story +++ diff-glyph {bin/? gyf/char aud/audience} :< un/bound glyph +++ diff-nick {who/ship nic/nick} :< changed nickname +++ diff-story :> story change + $% {$new cof/config} :< new story + {$bear bur/burden} :< new inherited story + {$peer add/? who/ship qer/query} :< gain/lose subscriber + {$config cir/circle dif/diff-config} :< new/changed config + {$status cir/circle who/ship dif/diff-status} :< new/changed status + {$remove $~} :< removed story == :: -++ rumor-story ::> story rumor - $? diff-story ::< both in & outward - $% {$gram src/circle nev/envelope} ::< new/changed message +++ rumor-story :> story rumor + $? diff-story :< both in & outward + $% {$gram src/circle nev/envelope} :< new/changed message == == :: -++ diff-config ::> config change - $% {$full cof/config} ::< set w/o side-effects - {$source add/? src/source} ::< add/rem sources - {$caption cap/cord} ::< changed description - {$filter fit/filter} ::< changed filter - {$secure sec/security} ::< changed security - {$permit add/? sis/(set ship)} ::< add/rem to b/w-list - {$remove $~} ::< removed config +++ diff-config :> config change + $% {$full cof/config} :< set w/o side-effects + {$source add/? src/source} :< add/rem sources + {$caption cap/cord} :< changed description + {$filter fit/filter} :< changed filter + {$secure sec/security} :< changed security + {$permit add/? sis/(set ship)} :< add/rem to b/w-list + {$remove $~} :< removed config == :: -++ diff-status ::> status change - $% {$full sat/status} ::< fully changed status - {$presence pec/presence} ::< changed presence - {$human dif/diff-human} ::< changed name - {$remove $~} ::< removed status +++ diff-status :> status change + $% {$full sat/status} :< fully changed status + {$presence pec/presence} :< changed presence + {$human dif/diff-human} :< changed name + {$remove $~} :< removed status == :: -++ diff-human ::> name change - $% {$full man/human} ::< fully changed name - {$handle han/(unit cord)} ::< changed handle - {$true tru/(unit truename)} ::< changed true name +++ diff-human :> name change + $% {$full man/human} :< fully changed name + {$handle han/(unit cord)} :< changed handle + {$true tru/(unit truename)} :< changed true name == :: :: -::> || -::> || %client-communication -::> || -::> hall interfaces for clients. -::+| +:> # +:> # %client-communication +:> # +:> hall interfaces for clients. ++| :: -++ action ::> user action +++ action :> user action $% :: circle configuration :: - {$create nom/naem des/cord sec/security} ::< create circle - {$delete nom/naem why/(unit cord)} ::< delete + announce - {$depict nom/naem des/cord} ::< change description - {$filter nom/naem fit/filter} ::< change message rules - {$permit nom/naem inv/? sis/(set ship)} ::< invite/banish - {$source nom/naem sub/? srs/(set source)} ::< un/sub to/from src + {$create nom/naem des/cord sec/security} :< create circle + {$delete nom/naem why/(unit cord)} :< delete + announce + {$depict nom/naem des/cord} :< change description + {$filter nom/naem fit/filter} :< change message rules + {$permit nom/naem inv/? sis/(set ship)} :< invite/banish + {$source nom/naem sub/? srs/(set source)} :< un/sub to/from src :: messaging :: - {$convey tos/(list thought)} ::< post exact - {$phrase aud/audience ses/(list speech)} ::< post easy + {$convey tos/(list thought)} :< post exact + {$phrase aud/audience ses/(list speech)} :< post easy :: personal metadata :: - {$notify aud/audience pes/(unit presence)} ::< our presence update - {$naming aud/audience man/human} ::< our name update + {$notify aud/audience pes/(unit presence)} :< our presence update + {$naming aud/audience man/human} :< our name update :: changing shared ui :: - {$glyph gyf/char aud/audience bin/?} ::< un/bind a glyph - {$nick who/ship nic/nick} ::< new identity + {$glyph gyf/char aud/audience bin/?} :< un/bind a glyph + {$nick who/ship nic/nick} :< new identity :: misc changes :: - {$public add/? cir/circle} ::< show/hide membership + {$public add/? cir/circle} :< show/hide membership == :: :: -::> || -::> || %hall-communication -::> || -::> structures for communicating between halls. -::+| +:> # +:> # %hall-communication +:> # +:> structures for communicating between halls. ++| :: -++ command ::> effect on story - $% {$publish tos/(list thought)} ::< deliver - {$present nos/(set naem) dif/diff-status} ::< status update - {$bearing $~} ::< prompt to listen +++ command :> effect on story + $% {$publish tos/(list thought)} :< deliver + {$present nos/(set naem) dif/diff-status} :< status update + {$bearing $~} :< prompt to listen == :: :: -::> || -::> || %circles -::> || -::> messaging targets and their metadata. -::+| +:> # +:> # %circles +:> # +:> messaging targets and their metadata. ++| :: -++ circle {hos/ship nom/naem} ::< native target +++ circle {hos/ship nom/naem} :< native target :: circle configurations. :: -++ lobby {loc/config rem/(map circle config)} ::< our & srcs configs -++ config ::> circle config - $: src/(set source) ::< active sources - cap/cord ::< description - fit/filter ::< message rules - con/control ::< restrictions +++ lobby {loc/config rem/(map circle config)} :< our & srcs configs +++ config :> circle config + $: src/(set source) :< active sources + cap/cord :< description + fit/filter :< message rules + con/control :< restrictions == :: -++ source {cir/circle ran/range} ::< subscription target -++ filter ::> content filters - $: cas/? ::< dis/allow capitals - utf/? ::< dis/allow non-ascii +++ source {cir/circle ran/range} :< subscription target +++ filter :> content filters + $: cas/? :< dis/allow capitals + utf/? :< dis/allow non-ascii ::TODO maybe message length == :: -++ control {sec/security sis/(set ship)} ::< access control -++ security ::> security mode - $? $channel ::< blacklist - $village ::< whitelist - $journal ::< pub r, whitelist w - $mailbox ::< our r, blacklist w +++ control {sec/security sis/(set ship)} :< access control +++ security :> security mode + $? $channel :< blacklist + $village :< whitelist + $journal :< pub r, whitelist w + $mailbox :< our r, blacklist w == :: :: participant metadata. :: -++ crowd {loc/group rem/(map circle group)} ::< our & srcs presences -++ group (map ship status) ::< presence map -++ status {pec/presence man/human} ::< participant -++ presence ::> status type - $? $gone ::< absent - $idle ::< idle - $hear ::< present - $talk ::< typing +++ crowd {loc/group rem/(map circle group)} :< our & srcs presences +++ group (map ship status) :< presence map +++ status {pec/presence man/human} :< participant +++ presence :> status type + $? $gone :< absent + $idle :< idle + $hear :< present + $talk :< typing == :: -++ human ::> human identifier - $: han/(unit cord) ::< handle - tru/(unit truename) ::< true name +++ human :> human identifier + $: han/(unit cord) :< handle + tru/(unit truename) :< true name == :: -++ truename {fir/cord mid/(unit cord) las/cord} ::< real-life name +++ truename {fir/cord mid/(unit cord) las/cord} :< real-life name :: -::> || -::> || %message-data -::> || -::> structures for containing main message data. -::+| +:> # +:> # %message-data +:> # +:> structures for containing main message data. ++| :: ::TODO some structure for extra message state :: local (to clients): delivery state, read flags :: remote (to halls): sequence nr -++ envelope {num/@ud gam/telegram} ::< outward message -++ telegram {aut/ship thought} ::< whose message -++ thought ::> inner message - $: uid/serial ::< unique identifier - aud/audience ::< destinations - wen/@da ::< timestamp - sep/speech ::< content +++ envelope {num/@ud gam/telegram} :< outward message +++ telegram {aut/ship thought} :< whose message +++ thought :> inner message + $: uid/serial :< unique identifier + aud/audience :< destinations + wen/@da :< timestamp + sep/speech :< content == :: -++ speech ::> content body - $% {$lin pat/? msg/cord} ::< no/@ text line - {$url url/purf:eyre} ::< parsed url - {$exp exp/cord res/(list tank)} ::< hoon line - {$ire top/serial sep/speech} ::< in reply to - {$fat tac/attache sep/speech} ::< attachment - {$app app/term sep/speech} ::< app message - {$inv inv/? cir/circle} ::< inv/ban for circle +++ speech :> content body + $% {$lin pat/? msg/cord} :< no/@ text line + {$url url/purf:eyre} :< parsed url + {$exp exp/cord res/(list tank)} :< hoon line + {$ire top/serial sep/speech} :< in reply to + {$fat tac/attache sep/speech} :< attachment + {$app app/term sep/speech} :< app message + {$inv inv/? cir/circle} :< inv/ban for circle == :: -++ attache ::> attachment - $% {$name nom/cord tac/attache} ::< named attachment - {$text (list cord)} ::< text lines - {$tank (list tank)} ::< tank list +++ attache :> attachment + $% {$name nom/cord tac/attache} :< named attachment + {$text (list cord)} :< text lines + {$tank (list tank)} :< tank list == :: :: -::> || -::> || %message-metadata -::> || -:: structures for containing message metadata. -::+| +:> # +:> # %message-metadata +:> # +:> structures for containing message metadata. ++| :: -++ serial @uvH ::< unique identifier -++ audience (set circle) ::< destinations -++ tracking (map circle delivery) ::> delivery per target -++ delivery ::> delivery state - $? $pending ::< undelivered - $accepted ::< received - $rejected ::< denied +++ serial @uvH :< unique identifier +++ audience (set circle) :< destinations +++ tracking (map circle delivery) :> delivery per target +++ delivery :> delivery state + $? $pending :< undelivered + $accepted :< received + $rejected :< denied == :: -- From 7dda8f12b31b73724044e793c6488cb62869f3d0 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 19 Dec 2017 14:43:49 +0100 Subject: [PATCH 069/184] Reject status changes if the new nickname is a valid ship name. --- app/hall.hoon | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index b534198c9..7bdd341a5 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -365,15 +365,7 @@ (~(put ju m) hos.c nom.c) =? ..ta-action (~(has by cic) our.bol) =+ nos=~(tap in (~(get ju cic) our.bol)) - |- ^+ ..ta-action - ?~ nos ..ta-action - =. ..ta-action - (affect i.nos %status [our.bol i.nos] our.bol dif) - $(nos t.nos) - ::TODO runtime error - ::%- ~(rep in (~(get ju cic) our.bol)) - ::|= {n/name _ta} :: beware, urbit/arvo#447 - ::(affect n %status [our.bol n] our.bol dif) + (ta-present our.bol (~(get ju cic) our.bol) dif) =. cic (~(del by cic) our.bol) %- ta-deltas %- ~(rep by cic) @@ -1024,12 +1016,19 @@ ^+ +> :: only have presence if you have write permission. ?. |((so-admire who) ?=($remove -.dif)) +> - :: ignore if it won't result in change. + :: ignore if it won't result in change, + :: or if it sets an impersonating handle. ?. ?: ?=($remove -.dif) (~(has by locals) who) ?| !(~(has by locals) who) :: - =+ (~(got by locals) who) - !=(- (change-status - dif)) + =+ old=(~(got by locals) who) + =+ new=(change-status - dif) + ?& !=(old new) + :: + ?= $~ + (rush (fall han.man.new '') ;~(pfix sig fed:ag)) + ::TODO %+ syntax errors? + == == +> (so-delta-our %status so-cir who dif) From 78c285ce1e54fd5e7ece7461592f4b794a4960ef Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 19 Dec 2017 16:19:06 +0100 Subject: [PATCH 070/184] Fixed issue that caused talk to not receive config and status updates if the inbox hadn't yet received any messages. Closes #511. --- app/talk.hoon | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index e8c321af2..4795163b0 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -215,7 +215,9 @@ %peer /server/inbox server - /circle/[inbox]/grams/config/group/(scot %ud count) + :: + %+ welp /circle/[inbox]/grams/config/group + ?:(=(0 count) ~ [(scot %ud count) ~]) == :: :> # From 13c2d0156d8f29394eac923d012f17c11b5ac73f Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 19 Dec 2017 20:50:00 +0100 Subject: [PATCH 071/184] Talk notifications now wrap properly. Pulled line wrapping logic out into the lib. Closes #468. --- app/talk.hoon | 40 +++++++++++++++++++--------------------- lib/hall.hoon | 13 +++++++++++++ 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 4795163b0..f10d7ed79 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -945,15 +945,12 @@ %. u.jub =< sh-work =+ buf=buf.say.she + =? ..sh-obey &(?=({$';' *} buf) !?=($reply -.u.jub)) + (sh-note (tufa `(list @)`buf)) =^ cal say.she (~(transmit sole say.she) [%set ~]) - %- sh-fact - :* %mor - [%nex ~] + %+ sh-fact %mor + :~ [%nex ~] [%det cal] - ?. ?=({$';' *} buf) ~ - ?: ?=($reply -.u.jub) ~ - :_ ~ - [%txt (runt [14 '-'] `tape`['|' ' ' (tufa `(list @)`buf)])] == :: :> # @@ -1698,9 +1695,12 @@ :: |= txt/tape ^+ +> - %+ sh-fact %txt - %+ runt [14 '-'] - `tape`['|' ' ' (scag (sub width.she 16) txt)] + =+ lis=(simple-wrap txt (sub width.she 16)) + %+ sh-fact %mor + =+ ?:((gth (lent lis) 0) (snag 0 lis) "") + :- txt+(runt [14 '-'] '|' ' ' -) + %+ turn (slag 1 lis) + |=(a/tape txt+(runt [14 ' '] '|' ' ' a)) :: ++ sh-prod :> show prompt @@ -2320,17 +2320,15 @@ ?: =(who self) aud (~(del in aud) [who %inbox]) == - =. wyd (sub wyd (min (div wyd 2) (lent pef))) - =/ txt (tuba (trip msg.sep)) - |- ^- (list tape) - ?~ txt ~ - =+ ^- {end/@ud nex/?} - ?: (lte (lent txt) wyd) [(lent txt) &] - =+ ace=(find " " (flop (scag +(wyd) `(list @c)`txt))) - ?~ ace [wyd |] - [(sub wyd u.ace) &] - :- (weld pef (tufa (scag end `(list @c)`txt))) - $(txt (slag ?:(nex +(end) end) `(list @c)`txt), pef (reap (lent pef) ' ')) + =/ lis/(list tape) + %+ simple-wrap + `tape``(list @)`(tuba (trip msg.sep)) + (sub wyd (min (div wyd 2) (lent pef))) + =+ lef=(lent pef) + =+ ?:((gth (lent lis) 0) (snag 0 lis) "") + :- (weld pef -) + %+ turn (slag 1 lis) + |=(a/tape (runt [lef ' '] a)) :: $inv :_ ~ diff --git a/lib/hall.hoon b/lib/hall.hoon index 69cc0c6d2..a543d882c 100644 --- a/lib/hall.hoon +++ b/lib/hall.hoon @@ -44,6 +44,19 @@ ^- {serial _eny.bol} [(shaf %serial eny.bol) (shax eny.bol)] :: +::TODO add to zuse? +++ simple-wrap + |= {txt/tape wyd/@ud} + ^- (list tape) + ?~ txt ~ + =+ ^- {end/@ud nex/?} + ?: (lte (lent txt) wyd) [(lent txt) &] + =+ ace=(find " " (flop (scag +(wyd) `tape`txt))) + ?~ ace [wyd |] + [(sub wyd u.ace) &] + :- (tufa (scag end `(list @)`txt)) + $(txt (slag ?:(nex +(end) end) `tape`txt)) +:: ++ range-to-path :> msg range to path :> From 962d96cff2d01a27c66effa312c2d7c274869648 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 20 Dec 2017 00:06:52 +0100 Subject: [PATCH 072/184] Bring webtalk up to speed. Also see urbit/talk#43. --- web/talk/main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/talk/main.js b/web/talk/main.js index 38bde4875..256beac4b 100644 --- a/web/talk/main.js +++ b/web/talk/main.js @@ -363,6 +363,7 @@ module.exports = recl({ key: "speech" }, url); case !exp: + exp.res = exp.res || ["evaluating..."]; return div({}, exp.exp, div({ className: "fat" }, pre({}, exp.res.join("\n")))); @@ -1351,6 +1352,9 @@ module.exports = recl({ if (valid === true) { stan = $('#audience .input').text() || util.mainStationPath(window.urb.user); stan = (stan.split(/\ +/)).map(function(v) { + if (v.indexOf("/") === -1) { + v = v + "/inbox"; + } if (v[0] === "~") { return v; } else { @@ -1596,6 +1600,7 @@ module.exports = function(arg) { var path; end = window.urb.util.numDot(end); start = window.urb.util.numDot(start); + console.log('getting grams from ' + end + ' to ' + start); path = util.talkPath('circle', station, 'grams', end, start); return window.urb.bind(path, function(err, res) { var ref, ref1; From 390062e296cb23dfa2be93efd81a9e0a26095052 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Tue, 19 Dec 2017 16:06:11 -0800 Subject: [PATCH 073/184] Update galaxy table for changes committed only in jael. --- sys/vane/ames.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/vane/ames.hoon b/sys/vane/ames.hoon index 43fd6810f..c7c27c195 100644 --- a/sys/vane/ames.hoon +++ b/sys/vane/ames.hoon @@ -163,8 +163,8 @@ 0w0 :: 46, ~hex, James Torre 0w0 :: 47, ~feb, urbit.org 0wK.GoKEY.rMjfn.ZcvFQ.n4BmX :: 48, ~pyl, Michael Hartl (oldkey) - 0w0 :: 49, ~dul, Curtis Yarvin - 0w0 :: 50, ~het, Curtis Yarvin + 0w0 :: 49, ~dul, Galen Wolfe-Pauly + 0w0 :: 50, ~het, Galen Wolfe-Pauly 0w0 :: 51, ~mev, Curtis Yarvin 0w0 :: 52, ~rut, Curtis Yarvin 0w2L.M6-o5.DDTFL.R4sFL.7Zuay :: 53, ~tyl, Tlon Investor 11 (oldkey) @@ -177,7 +177,7 @@ 0w0 :: 60, ~bur, Galen Wolfe-Pauly 0w0 :: 61, ~der, Galen Wolfe-Pauly 0w0 :: 62, ~nep, Galen Wolfe-Pauly - 0w0 :: 63, ~pur, Curtis Yarvin + 0w0 :: 63, ~pur, Paul Driver 0w30.VtXvV.S~xIV.iMCL~.j9zTC :: 64, ~rys, Charlie Cummings (oldkey) 0w0 :: 65, ~reb, Curtis Yarvin 0wp.LslIa.IFSM9.mIp-z.KBIBh :: 66, ~den, Michael Hartl (oldkey) From 7ebb3055abcb0671a7cc814bb67d587bb9350d4c Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 19 Dec 2017 16:16:23 -0800 Subject: [PATCH 074/184] restore pin-urbit-relese.url --- .travis.yml | 4 ++-- .travis/pin-urbit-release.url | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .travis/pin-urbit-release.url diff --git a/.travis.yml b/.travis.yml index ad3883422..4da03fd5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ node_js: before_install: - cd .travis # keep main directory clear - - wget https://github.com/urbit/urbit/releases/download/v0.5.1/urbit_0.5-1_amd64.deb - - sudo apt install ./urbit_0.5-1_amd64.deb + - wget -i pin-urbit-release.url -O ./urbit.deb + - sudo apt install ./urbit.deb before_script: bash get-or-build-pill.sh diff --git a/.travis/pin-urbit-release.url b/.travis/pin-urbit-release.url new file mode 100644 index 000000000..560ece0e3 --- /dev/null +++ b/.travis/pin-urbit-release.url @@ -0,0 +1 @@ +https://github.com/urbit/urbit/releases/download/v0.5.1/urbit_0.5-1_amd64.deb From 6a0385eeeb97f3cdafad66319e21d4935f2ae228 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 21 Dec 2017 22:44:17 +0100 Subject: [PATCH 075/184] Reverted accidentally renamed jael tag. --- sys/vane/jael.hoon | 4 ++-- sys/zuse.hoon | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/vane/jael.hoon b/sys/vane/jael.hoon index bef03ab83..f4570b7e9 100644 --- a/sys/vane/jael.hoon +++ b/sys/vane/jael.hoon @@ -913,9 +913,9 @@ ?- -.tac :: :: destroy promises - :: {$ktsg p/ship q/safe} + :: {$burn p/ship q/safe} :: - $ktsg + $burn (cure abet:abet:(deal:(burb our) p.tac [~ q.tac])) :: :: remote update diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 71bdee364..3df9b6a1c 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -936,7 +936,7 @@ :: and change subscriptions. :: :: change tasks are designed to match high-level - :: operations - for instance, we have %ktsg, %mint, + :: operations - for instance, we have %burn, %mint, :: and %move, not just a single delta operation. :: more of these operations will probably be added, :: and invariants enforced at transaction end. @@ -1008,7 +1008,7 @@ action :: change :: += task :: in request ->$ - $% [%ktsg p=ship q=safe] :: destroy rights + $% [%burn p=ship q=safe] :: destroy rights [%hail p=ship q=remote] :: remote update [%init p=@pG q=arms] :: initialize urbit [%meet p=(unit (unit ship)) q=farm] :: integrate pki from From b2030e47f38930628b208289a25c7095b830d2d1 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 19 Dec 2017 15:16:40 -0800 Subject: [PATCH 076/184] Fix gall scry cf. aaa9267, fixes #512 --- sys/vane/gall.hoon | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/vane/gall.hoon b/sys/vane/gall.hoon index 7f5689dff..eca5f2e99 100644 --- a/sys/vane/gall.hoon +++ b/sys/vane/gall.hoon @@ -1333,24 +1333,26 @@ == :: ++ scry - |= {fur/(unit (set monk)) ren/@tas who/ship syd/desk lot/coin tyl/path} + |= {fur/(unit (set monk)) ren/@tas why/shop syd/desk lot/coin tyl/path} ^- (unit (unit cage)) + ?. ?=($& -.why) ~ + =* his p.why ?: ?& =(%u ren) =(~ tyl) =([%$ %da now] lot) - (~(has by pol.all) who) - (~(has by bum:(~(got by pol.all) who)) syd) + (~(has by pol.all) his) + (~(has by bum:(~(got by pol.all) his)) syd) == ``[%null !>(~)] - ?. (~(has by pol.all) who) + ?. (~(has by pol.all) his) ~ ?. =([%$ %da now] lot) ~ - ?. (~(has by bum:(~(got by pol.all) who)) syd) + ?. (~(has by bum:(~(got by pol.all) his)) syd) [~ ~] ?. ?=(^ tyl) ~ - (mo-peek:(mo-abed:mo who *duct) syd high+`who ren tyl) + (mo-peek:(mo-abed:mo his *duct) syd high+`his ren tyl) :: ++ stay :: save w+o cache `axle`all From 90608339ccce9d7805e03f03d06fc42d00f0c58b Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 22 Dec 2017 01:14:07 +0100 Subject: [PATCH 077/184] Only send presence when sourcing from targets for an indefinite amount of time. --- app/talk.hoon | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index f10d7ed79..8a5218ac0 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -375,16 +375,20 @@ =+ ren=~(cr-phat cr cir) =+ gyf=(~(get by bound) [cir ~ ~]) =< sh-done - => :_ . - %- ~(sh-act sh cli) - [%notify [cir ~ ~] `%hear] + =/ sho + :: only present if we're here indefinitely. + =* ran ran.src.dif.rum + ?. |(?=($~ ran) ?=($~ tal.u.ran)) + ~(. sh cli) + %- ~(sh-act sh cli) + [%notify [cir ~ ~] `%hear] ?^ gyf - (sh-note "has glyph {[u.gyf ~]} for {ren}") + (sh-note:sho "has glyph {[u.gyf ~]} for {ren}") :: we use the rendered circle name to determine :: the glyph for higher glyph consistency when :: federating. =+ cha=(glyph (mug ren)) - (sh-work %bind cha `[cir ~ ~]) + (sh-work:sho %bind cha `[cir ~ ~]) %= +>.$ sources ?. &(?=($source -.dif.rum) =(cir.rum incir)) From c61ada5f3e13b6f6df6f4410f5c8f1590b85fe82 Mon Sep 17 00:00:00 2001 From: Fang Date: Sat, 23 Dec 2017 17:07:56 +0100 Subject: [PATCH 078/184] Fix off-by-one error in message selection. Closes #516. --- app/talk.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index 8a5218ac0..bfde631d7 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -1331,7 +1331,7 @@ (sh-lame "{(scow %s (new:si | +(num)))}: no such telegram") =. ..sh-fact (sh-fact %txt "? {(scow %s (new:si | +(num)))}") (activate (snag num grams)) - ?. (gth q.num count) + ?. (gte q.num count) ?: =(count 0) (sh-lame "0: no messages") =+ msg=(deli (dec count) num) From e6dc49a4d2324f61037bf1f6669557d4274870dd Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Tue, 26 Dec 2017 13:03:47 -0800 Subject: [PATCH 079/184] Separate out all tests into files. This moves the remaining test suites into their own test files, however, we are still not autogenerating a list of tests. --- gen/test.hoon | 820 ++++--------------------------------------------- tests/ls.hoon | 280 +++++++++++++++++ tests/mp.hoon | 360 ++++++++++++++++++++++ tests/myb.hoon | 32 ++ 4 files changed, 740 insertions(+), 752 deletions(-) create mode 100644 tests/ls.hoon create mode 100644 tests/mp.hoon create mode 100644 tests/myb.hoon diff --git a/gen/test.hoon b/gen/test.hoon index 4f779aa1c..ec215e3a6 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -3,758 +3,74 @@ :: i should be able to use /: ? /+ new-hoon, tester -:: random thought: should I lift most of test execution into the build system? -:: trade off: if you do a wide ranging change and then only want to run one -:: test, you must pay the execution time for all tests, while otherwise, you -:: only pay the compile time. -// /===/tests/thr -[test-thr=. +] +:: ok, doing this as a list first. then do it automated. is there an equivalent +:: to /_ which works on an arbitrary directory? +/= test-thr /: /===/tests/thr /!noun/ +/= test-myb /: /===/tests/myb /!noun/ +/= test-ls /: /===/tests/ls /!noun/ +/= test-mp /: /===/tests/mp /!noun/ -:: ---------------------------------------------------------------------- -:: Eventually should be in %/test/basic/hoon. -:: ---------------------------------------------------------------------- |% -++ test-myb - =, myb:new-hoon - |_ tester-type:tester - ++ test-from-list-null - (expect-eq (from-list ~) ~ "from-list") +++ perform-test-suite + :: takes a testing core and executes all tests in it. + |= {name/tape v/vase eny/@uvJ} + ^- tang + =+ core-arms=(sort (sloe p.v) aor) + ?: =(~ core-arms) + ~& p.v + [[%leaf :(weld "error: " name " is not a valid testing core.")] ~] + =| out/tang + |- + ?~ core-arms + out + %= $ + out (weld (perform-test-arm name i.core-arms v eny) out) + core-arms t.core-arms + == +:: +++ perform-test-arm + :: performs a single test. + |= {suite-name/tape arm-name/term v/vase eny/@uvJ} + :: todo: terminal color on the output + ^- tang + =+ run=(run-arm-in-test-core arm-name v eny) + =+ full-name=:(weld suite-name "/" (trip arm-name)) + ?- -.run + $| :: the stack is already flopped for output? + ;: weld + p:run + `tang`[[%leaf (weld full-name " CRASHED")] ~] + == + $& :: todo: test the cookie to make sure it returned the same core. + ?: =(~ +.p:run) + [[%leaf (weld full-name " OK")] ~] + :: Create a welded list of all failures indented. + %- flop + ;: weld + `tang`[[%leaf (weld full-name " FAILED")] ~] + %+ turn +.p:run + |= {i/tape} + ^- tank + [%leaf (weld " " i)] + == + == +:: +++ run-arm-in-test-core + :: runs a single arm. :: - ++ test-from-list-real - (expect-eq (from-list [5 ~]) [~ 5] "from-list") - :: - ++ test-to-list-null - (expect-eq (to-list ~) ~ "to-list") - :: - ++ test-to-list-real - (expect-eq (to-list [~ 5]) [5 ~] "to-list") - :: - ++ test-concat-null - (expect-eq (concat ~) ~ "concat") - :: - ++ test-concat-real - :: wait, if i pull the cast out from below, the concat implementation - :: doesn't compile anymore? - (expect-eq (concat `(list (maybe @ud))`[~ [~ 1] ~ [~ 2] ~]) [1 2 ~] "concat") - :: - ++ test-map - %^ expect-eq - %+ map:myb - [1 2 3 2 ~] - |=(a/@u ?:(=(2 a) [~ 2] ~)) - [2 2 ~] - "map" - -- --- -|% -++ test-ls - =, ls:new-hoon - |_ tester-type:tester - ++ test-head - (expect-eq (head [1 ~]) 1 "head") - :: - ++ test-last - (expect-eq (last:ls [1 2 ~]) 2 "last") - :: - ++ test-tail - (expect-eq (tail [1 2 3 ~]) [2 3 ~] "tail") - :: - ++ test-init - (expect-eq (init [1 2 3 ~]) [1 2 ~] "init") - :: - ++ test-size - (expect-eq (size ['a' 'b' 'c' ~]) 3 "size") - :: - ++ test-map - (expect-eq (map:ls [1 2 ~] |=(a/@ (add 1 a))) [2 3 ~] "map") - :: - ++ test-reverse - (expect-eq (reverse [1 2 3 ~]) [3 2 1 ~] "reverse") - :: - ++ test-intersperse - (expect-eq (intersperse 1 [5 5 5 ~]) [5 1 5 1 5 ~] "intersperse") - :: - ++ test-intercalate - %^ expect-eq - (intercalate "," ["one" "two" "three" ~]) - ["one,two,three"] - "intercalate" - :: - ++ test-transpose - %^ expect-eq - (transpose ~[~[1 2 3] ~[4 5 6]]) - ~[~[1 4] ~[2 5] ~[3 6]] - "transpose" - :: - ++ test-foldl - (expect-eq (foldl [1 2 3 ~] 3 |=({a/@ b/@} (add a b))) 9 "foldl") - :: - ++ test-foldr - (expect-eq (foldr [1 2 3 ~] 1 |=({a/@ b/@} (add a b))) 7 "foldr") - :: - ++ test-concat - (expect-eq (concat ~[~[1 2] ~[3 4]]) ~[1 2 3 4] "concat") - :: - ++ test-weld - (expect-eq (weld:ls ~[1 2 3] ~["one" "two"]) ~[1 2 3 "one" "two"] "weld") - :: - ++ test-any-true - (expect-eq (any [1 2 3 ~] |=(a/@ =(a 2))) %.y "any true") - :: - ++ test-any-false - (expect-eq (any [1 2 3 ~] |=(a/@ =(a 8))) %.n "any false") - :: - ++ test-all-true - (expect-eq (all [1 1 1 ~] |=(a/@ =(a 1))) %.y "all true") - :: - ++ test-all-false - (expect-eq (all [1 3 1 ~] |=(a/@ =(a 1))) %.n "all false") - :: - ++ test-scanl - %^ expect-eq - (scanl ~[1 2 3] 0 |=({a/@ b/@} (add a b))) - ~[0 1 3 6] - "scanl" - :: - ++ test-scanl1 - %^ expect-eq - (scanl1 ~[1 2 3] |=({a/@ b/@} (add a b))) - ~[1 3 6] - "scanl1" - :: - ++ test-scanr - %^ expect-eq - (scanr ~[1 2 3] 0 |=({a/@ b/@} (add a b))) - ~[6 5 3 0] - "scanr" - :: - ++ test-scanr1 - %^ expect-eq - (scanr1 ~[1 2 3] |=({a/@ b/@} (add a b))) - ~[6 5 3] - "scanr1" - :: - ++ test-map-foldl - %^ expect-eq - (map-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) - [7 ~[2 3 5]] - "map-foldl" - :: - ++ test-map-foldr - %^ expect-eq - (map-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) - [7 ~[7 5 2]] - "map-foldr" - :: - ++ test-unfoldr - %^ expect-eq - (unfoldr 5 |=(a/@ ?:(=(a 0) ~ `[a (dec a)]))) - [5 4 3 2 1 ~] - "unfoldr" - :: - ++ test-take - %^ expect-eq - (take 3 ~[1 2 3 4 5]) - [1 2 3 ~] - "take" - :: - ++ test-drop - %^ expect-eq - (drop:ls 3 ~[1 2 3 4 5]) - [4 5 ~] - "drop" - :: - ++ test-split-at - %^ expect-eq - (split-at 3 ~[1 2 3 4 5]) - [[1 2 3 ~] [4 5 ~]] - "split-at" - :: - ++ test-take-while - %^ expect-eq - (take-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) - [1 2 ~] - "take-while" - :: - ++ test-drop-while - %^ expect-eq - (drop-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) - [3 4 5 ~] - "drop-while" - :: - ++ test-drop-while-end - %^ expect-eq - (drop-while-end ~[5 5 1 5 5] |=(a/@ =(a 5))) - [5 5 1 ~] - "drop-while-end" - :: - ++ test-split-on - %^ expect-eq - (split-on ~[1 2 3 4 1 2 3 4] |=(a/@ (lth a 3))) - [[1 2 ~] [3 4 1 2 3 4 ~]] - "split-on" - :: - ++ test-break - %^ expect-eq - (break ~[1 2 3 4 1 2 3 4] |=(a/@ (gth a 3))) - [[1 2 3 ~] [4 1 2 3 4 ~]] - "break" - :: - ++ test-strip-prefix - %^ expect-eq - (strip-prefix "foo" "foobar") - [~ "bar"] - "break" - :: - ++ test-inits - %^ expect-eq - (inits "abc") - ["a" "ab" "abc" ~] - "inits" - :: - ++ test-tails - %^ expect-eq - (tails "abc") - ["abc" "bc" "c" ~] - "tails" - :: - ++ test-is-prefix-of - %^ expect-eq - (is-prefix-of "foo" "foobar") - %.y - "is-prefix-of" - :: - ++ test-is-suffix-of - %^ expect-eq - (is-suffix-of "bar" "foobar") - %.y - "is-suffix-of" - :: - ++ test-is-infix-of - %^ expect-eq - (is-infix-of "ob" "foobar") - %.y - "is-infix-of" - :: - ++ test-elem - %^ expect-eq - (elem 5 [1 2 3 4 5 ~]) - %.y - "elem" - :: - ++ test-lookup - %^ expect-eq - (lookup "two" [["one" 1] ["two" 2] ["three" 3] ~]) - [~ 2] - "lookup" - :: - ++ test-find - %^ expect-eq - (find:ls [3 2 1 5 1 2 3 ~] |=(a/@ (gth a 3))) - [~ 5] - "find" - :: - ++ test-filter - %^ expect-eq - (filter [1 2 1 2 1 ~] |=(a/@ =(a 2))) - [1 1 1 ~] - "filter" - :: - ++ test-partition - %^ expect-eq - (partition [1 2 1 2 1 ~] |=(a/@ =(a 2))) - [[2 2 ~] [1 1 1 ~]] - "partition" - :: - ++ test-elem-index - %^ expect-eq - (elem-index 2 [1 2 3 4 ~]) - `1 - "elem-index" - :: - ++ test-elem-indices - %^ expect-eq - (elem-indices 2 [1 2 1 2 ~]) - [1 3 ~] - "elem-indices" - :: - ++ test-find-index - %^ expect-eq - (find-index [1 2 3 ~] |=(a/@ =(a 2))) - `1 - "find-index" - :: - ++ test-find-indices - %^ expect-eq - (find-indices [1 2 1 2 ~] |=(a/@ =(a 2))) - [1 3 ~] - "find-indices" - :: - ++ test-zip - %^ expect-eq - (zip [[1 2 3 ~] [4 5 6 ~] [7 8 9 ~] ~]) - [[1 4 7 ~] [2 5 8 ~] [3 6 9 ~] ~] - "zip" - :: - ++ test-unique - %^ expect-eq - (unique [1 2 3 1 2 3 ~]) - [1 2 3 ~] - "unique" - :: - ++ test-delete - %^ expect-eq - (delete 2 [1 2 3 2 ~]) - [1 3 2 ~] - "delete" - :: - ++ test-delete-firsts - %^ expect-eq - (delete-firsts [1 2 2 2 3 4 5 ~] [2 2 5 ~]) - [1 2 3 4 ~] - "delete-firsts" - :: - ++ test-union - %^ expect-eq - (union [1 2 3 ~] [4 2 5 ~]) - [1 2 3 4 5 ~] - "union" - :: - ++ test-intersect - %^ expect-eq - (intersect [5 6 6 7 8 ~] [9 8 8 6 ~]) - [6 6 8 ~] - "intersect" - -- --- -|% -++ test-mp - =, dct:new-hoon - =+ four=(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] ~]) - =+ three=(from-list [[1 "one"] [2 "two"] [3 "three"] ~]) - |_ tester-type:tester - ++ test-empty - (expect-eq (empty four) %.n "empty") - :: - ++ test-size - (expect-eq (size four) 4 "size") - :: - ++ test-member - (expect-eq (member four 4) %.y "member") - :: - ++ test-put-with - =+ ints=(from-list [["one" 1] ["two" 2] ["three" 3] ["four" 4] ~]) - %^ expect-eq - (put-with ints "three" 2 add) - (from-list [["one" 1] ["two" 2] ["three" 5] ["four" 4] ~]) - "put-with" - :: - ++ test-put-with-key - %^ expect-eq - (put-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) - (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~]) - "put-with-key" - :: - ++ test-put-lookup-with-key - %^ expect-eq - %- put-lookup-with-key :^ - four - 4 - "five" - |=({key/@ud old/tape new/tape} new) - :- `"four" - (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "five"] ~]) - "put-lookup-with-key" - :: - ++ test-delete - %^ expect-eq - (delete four 4) - three - "delete" - :: - ++ test-adjust - %^ expect-eq - %^ adjust - four - 3 - |=(a/tape (weld "this" a)) - (from-list [[1 "one"] [2 "two"] [3 "thisthree"] [4 "four"] ~]) - "adjust" - :: - ++ test-adjust-with-key - %^ expect-eq - %^ adjust-with-key - four - 3 - |=({a/@ud b/tape} (weld (scow %ud a) b)) - (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) - "adjust-with-key" - :: - ++ test-update - %^ expect-eq - %^ update - four - 3 - |=(a/tape `(maybe tape)`~) - (from-list [[1 "one"] [2 "two"] [4 "four"] ~]) - "update" - :: - ++ test-update-with-key - %^ expect-eq - %^ update-with-key - four - 3 - |=({a/@u b/tape} `(maybe tape)`[~ (weld (scow %ud a) b)]) - (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) - "update-with-key" - :: - ++ test-alter-as-add - %^ expect-eq - %^ alter - four - 5 - |=(a/(maybe tape) `(maybe tape)`[~ "five"]) - (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"] ~]) - "alter (as add)" - :: - ++ test-alter-as-delete - %^ expect-eq - %^ alter - four - 2 - |=(a/(maybe tape) `(maybe tape)`~) - (from-list [[1 "one"] [3 "three"] [4 "four"] ~]) - "alter (as delete)" - :: - ++ test-alter-as-change - %^ expect-eq - %^ alter - four - 2 - |=(a/(maybe tape) `(maybe tape)`[~ "dos"]) - (from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~]) - "alter (as change)" - :: - ++ check-alter - :: check random dicts of 50 items with 40 random operations done on them - :: for validity. - %+ check - (generate-dict 50) - |= a/(dict @ud @ud) - :: this is dumb, but use {a} as entropy? - =/ gen (random:new-hoon (jam a)) - =| i/@u - |- - ?: =(i 40) - %.y - =^ key gen (range:gen 0 100) - =^ value gen (range:gen 0 100) - =. a %^ alter-with-key a key - |= {key/@ud current/(maybe @ud)} - ^- (maybe @ud) - =+ action=(mod key 2) - ?: =(action 0) :: return nothing - ~ - ?: =(action 1) :: add/set value - `value - ~ :: impossible - ?. (valid a) - %.n - $(i +(i)) - :: - ++ test-union - %^ expect-eq - %+ union - (from-list [[1 "left"] [2 "left"] ~]) - (from-list [[2 "right"] [3 "right"] ~]) - (from-list [[1 "left"] [2 "left"] [3 "right"] ~]) - "union" - :: - ++ test-union-with - %^ expect-eq - %^ union-with - (from-list [[1 "left"] [2 "left"] ~]) - (from-list [[2 "right"] [3 "right"] ~]) - |=({a/tape b/tape} (weld a b)) - (from-list [[1 "left"] [2 "leftright"] [3 "right"] ~]) - "union-with" - :: - ++ test-union-with-key - %^ expect-eq - %^ union-with-key - (from-list [[1 "left"] [2 "left"] ~]) - (from-list [[2 "right"] [3 "right"] ~]) - |=({a/@ud b/tape c/tape} :(weld `tape`(scow %ud a) b c)) - (from-list [[1 "left"] [2 "2leftright"] [3 "right"] ~]) - "union-with-key" - :: - ++ test-map - %^ expect-eq - %+ map:dct - three - crip - (from-list [[1 'one'] [2 'two'] [3 'three'] ~]) - "map" - :: - ++ test-map-with-key - %^ expect-eq - %+ map-with-key - three - |=({a/@u b/tape} (weld (scow %ud a) b)) - (from-list [[1 "1one"] [2 "2two"] [3 "3three"] ~]) - "map-with-key" - :: - ++ test-map-fold - %^ expect-eq - %^ map-fold - three - "Everything: " - |= {accumulator/tape value/tape} - [(weld accumulator value) (weld value "X")] - :- "Everything: twoonethree" - (from-list [[1 "oneX"] [2 "twoX"] [3 "threeX"] ~]) - "map-fold" - :: - ++ test-map-keys - %^ expect-eq - %+ map-keys - three - |= a/@u - (add a 10) - (from-list [[11 "one"] [12 "two"] [13 "three"] ~]) - "map-keys" - :: - ++ test-map-keys-with - %^ expect-eq - %^ map-keys-with - three - |=(a/@u 42) - weld - (from-list [[42 "twothreeone"] ~]) - "map-keys-with" - :: - ++ test-fold - %^ expect-eq - %^ fold - three - "Everything: " - :: todo: this works but replacing with just ++weld causes an out of loom. - |= {accumulator/tape value/tape} - ^- tape - (weld accumulator value) - "Everything: twoonethree" - "map-fold" - :: - ++ test-fold-with-keys - %^ expect-eq - %^ fold-with-keys - three - "Everything: " - |= {accumulator/tape key/@u value/tape} - ^- tape - :(weld accumulator (scow %ud key) value) - "Everything: 2two1one3three" - "map-fold-with-keys" - :: - ++ test-elems - %^ expect-eq - (elems three) - ["two" "three" "one" ~] - "elems" - :: - ++ test-keys - %^ expect-eq - (keys three) - [2 3 1 ~] - "keys" - :: - ++ test-keys-set - %^ expect-eq - (keys-set three) - (si:nl [2 3 1 ~]) - "keys-set" - :: - ++ test-from-set - %^ expect-eq - %+ from-set - (si:nl [1 2 3 ~]) - |= a/@u - (scow %ud a) - (from-list [[1 "1"] [2 "2"] [3 "3"] ~]) - "from-set" - :: - ++ test-from-list-with - %^ expect-eq - %+ from-list-with - [[1 1] [2 1] [2 1] [3 3] ~] - add - (from-list [[1 1] [2 2] [3 3] ~]) - "from-list-with" - :: - ++ test-filter - %^ expect-eq - %+ filter - (from-list [[1 1] [2 1] [3 2] [4 1] ~]) - |=(a/@u !=(a 1)) - (from-list [[1 1] [2 1] [4 1] ~]) - "filter" - :: - ++ test-filter-with-key - %^ expect-eq - %+ filter-with-key - (from-list [[1 1] [2 1] [3 2] [4 1] ~]) - |=({a/@u b/@u} =(a 2)) - (from-list [[1 1] [3 2] [4 1] ~]) - "filter-with-key" - :: - ++ test-restrict-keys - %^ expect-eq - %+ restrict-keys - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - (si:nl [1 3 5 ~]) - (from-list [[1 1] [3 3] [5 5] ~]) - "restrict-keys" - :: - ++ test-without-keys - %^ expect-eq - %+ without-keys - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - (si:nl [1 3 5 ~]) - (from-list [[2 2] [4 4] ~]) - "restrict-keys" - :: - ++ test-partition - %^ expect-eq - %+ partition - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |=(a/@u |(=(a 1) =(a 3))) - :- (from-list [[1 1] [3 3] ~]) - (from-list [[2 2] [4 4] [5 5] ~]) - "partition" - :: - ++ test-map-maybe - %^ expect-eq - %+ map-maybe - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |=(a/@u ?:(=(a 3) ~ `a)) - (from-list [[1 1] [2 2] [4 4] [5 5] ~]) - "map-maybe" - :: - ++ test-map-maybe-with-key - %^ expect-eq - %+ map-maybe-with-key - (from-list [[1 2] [2 3] [3 4] [4 5] [5 6] ~]) - |=({k/@u v/@u} ?:(=(k 3) ~ `v)) - (from-list [[1 2] [2 3] [4 5] [5 6] ~]) - "map-maybe-with-key" - :: - ++ test-map-either - %^ expect-eq - %+ map-either - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |= value/@u - ?: =(0 (mod value 2)) - [%& "even"] - [%| 1] - :- (from-list [[2 "even"] [4 "even"] ~]) - (from-list [[1 1] [3 1] [5 1] ~]) - "map-either" - :: - ++ test-map-either-with-key - %^ expect-eq - %+ map-either-with-key - (from-list [[1 1] [2 1] [3 1] [4 1] [5 1] ~]) - |= {key/@u value/@u} - ?: =(0 (mod key 2)) - [%& "even"] - [%| 1] - :- (from-list [[2 "even"] [4 "even"] ~]) - (from-list [[1 1] [3 1] [5 1] ~]) - "map-either" - :: - ++ test-is-subdict - %^ expect-eq - %^ is-subdict-by - (from-list [[1 1] [4 4] ~]) - (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) - |=({a/* b/*} =(a b)) - %.y - "is-subdict" - :: - ++ test-valid - %^ expect-eq - (valid (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9] ~])) - %.y - "valid" - -- --- -|% -:: ---------------------------------------------------------------------- -:: Stays in the generator. -:: ---------------------------------------------------------------------- -++ local - |% - ++ perform-test-suite - :: takes a testing core and executes all tests in it. - |= {name/tape v/vase eny/@uvJ} - ^- tang - =+ core-arms=(sort (sloe p.v) aor) - ?: =(~ core-arms) - ~& p.v - [[%leaf :(weld "error: " name " is not a valid testing core.")] ~] - =| out/tang - |- - ?~ core-arms - out - %= $ - out (weld (perform-test-arm name i.core-arms v eny) out) - core-arms t.core-arms - == - :: - ++ perform-test-arm - :: performs a single test. - |= {suite-name/tape arm-name/term v/vase eny/@uvJ} - :: todo: terminal color on the output - ^- tang - =+ run=(run-arm-in-test-core arm-name v eny) - =+ full-name=:(weld suite-name "/" (trip arm-name)) - ?- -.run - $| :: the stack is already flopped for output? - ;: weld - p:run - `tang`[[%leaf (weld full-name " CRASHED")] ~] - == - $& :: todo: test the cookie to make sure it returned the same core. - ?: =(~ +.p:run) - [[%leaf (weld full-name " OK")] ~] - :: Create a welded list of all failures indented. - %- flop - ;: weld - `tang`[[%leaf (weld full-name " FAILED")] ~] - %+ turn +.p:run - |= {i/tape} - ^- tank - [%leaf (weld " " i)] - == - == - :: - ++ run-arm-in-test-core - :: runs a single arm. - :: - :: returns the output of `++mule` so that we can react to crashes - :: appropriately. - |= {arm-name/term v/vase eny/@uvJ} - ^- (each {@uvJ (list tape)} (list tank)) - =/ t (init-test-vase:tester eny) - :: run the tests in the interpreter so we catch crashes. - %- mule |. - =/ r (slap (slop t v) [%cnsg [arm-name ~] [%$ 3] [[%$ 2] ~]]) - :: return just the results or we will be here forever while we try to copy - :: the entire kernel. - ((hard {@uvJ (list tape)}) q:(slap r [%limb %results])) - -- -:: ---------------------------------------------------------------------- + :: returns the output of `++mule` so that we can react to crashes + :: appropriately. + |= {arm-name/term v/vase eny/@uvJ} + ^- (each {@uvJ (list tape)} (list tank)) + =/ t (init-test-vase:tester eny) + :: run the tests in the interpreter so we catch crashes. + %- mule |. + =/ r (slap (slop t v) [%cnsg [arm-name ~] [%$ 3] [[%$ 2] ~]]) + :: return just the results or we will be here forever while we try to copy + :: the entire kernel. + ((hard {@uvJ (list tape)}) q:(slap r [%limb %results])) -- +:: :- %say |= $: {now/@da eny/@uvJ bec/beak} $~ @@ -763,7 +79,7 @@ :- %tang :: todo: right now, we hard code ++test-core. but eventually, we must instead :: scry ford for the core from the hoon file. that doesn't exist yet. -(perform-test-suite:local "test-thr" !>(test-thr) eny) -::(perform-test-suite:local "test-myb" !>(test-myb) eny) -::(perform-test-suite:local "test-ls" !>(test-ls) eny) -::(perform-test-suite:local "test-mp" !>(test-mp) eny) +::(perform-test-suite "test-thr" !>(test-thr) eny) +::(perform-test-suite "test-myb" !>(test-myb) eny) +::(perform-test-suite "test-ls" !>(test-ls) eny) +(perform-test-suite "test-mp" !>(test-mp) eny) diff --git a/tests/ls.hoon b/tests/ls.hoon new file mode 100644 index 000000000..e334bc4c6 --- /dev/null +++ b/tests/ls.hoon @@ -0,0 +1,280 @@ +/+ new-hoon, tester +=, ls:new-hoon +|_ tester-type:tester +++ test-head + (expect-eq (head [1 ~]) 1 "head") +:: +++ test-last + (expect-eq (last:ls [1 2 ~]) 2 "last") +:: +++ test-tail + (expect-eq (tail [1 2 3 ~]) [2 3 ~] "tail") +:: +++ test-init + (expect-eq (init [1 2 3 ~]) [1 2 ~] "init") +:: +++ test-size + (expect-eq (size ['a' 'b' 'c' ~]) 3 "size") +:: +++ test-map + (expect-eq (map:ls [1 2 ~] |=(a/@ (add 1 a))) [2 3 ~] "map") +:: +++ test-reverse + (expect-eq (reverse [1 2 3 ~]) [3 2 1 ~] "reverse") +:: +++ test-intersperse + (expect-eq (intersperse 1 [5 5 5 ~]) [5 1 5 1 5 ~] "intersperse") +:: +++ test-intercalate + %^ expect-eq + (intercalate "," ["one" "two" "three" ~]) + ["one,two,three"] + "intercalate" +:: +++ test-transpose + %^ expect-eq + (transpose ~[~[1 2 3] ~[4 5 6]]) + ~[~[1 4] ~[2 5] ~[3 6]] + "transpose" +:: +++ test-foldl + (expect-eq (foldl [1 2 3 ~] 3 |=({a/@ b/@} (add a b))) 9 "foldl") +:: +++ test-foldr + (expect-eq (foldr [1 2 3 ~] 1 |=({a/@ b/@} (add a b))) 7 "foldr") +:: +++ test-concat + (expect-eq (concat ~[~[1 2] ~[3 4]]) ~[1 2 3 4] "concat") +:: +++ test-weld + (expect-eq (weld:ls ~[1 2 3] ~["one" "two"]) ~[1 2 3 "one" "two"] "weld") +:: +++ test-any-true + (expect-eq (any [1 2 3 ~] |=(a/@ =(a 2))) %.y "any true") +:: +++ test-any-false + (expect-eq (any [1 2 3 ~] |=(a/@ =(a 8))) %.n "any false") +:: +++ test-all-true + (expect-eq (all [1 1 1 ~] |=(a/@ =(a 1))) %.y "all true") +:: +++ test-all-false + (expect-eq (all [1 3 1 ~] |=(a/@ =(a 1))) %.n "all false") +:: +++ test-scanl + %^ expect-eq + (scanl ~[1 2 3] 0 |=({a/@ b/@} (add a b))) + ~[0 1 3 6] + "scanl" +:: +++ test-scanl1 + %^ expect-eq + (scanl1 ~[1 2 3] |=({a/@ b/@} (add a b))) + ~[1 3 6] + "scanl1" +:: +++ test-scanr + %^ expect-eq + (scanr ~[1 2 3] 0 |=({a/@ b/@} (add a b))) + ~[6 5 3 0] + "scanr" +:: +++ test-scanr1 + %^ expect-eq + (scanr1 ~[1 2 3] |=({a/@ b/@} (add a b))) + ~[6 5 3] + "scanr1" +:: +++ test-map-foldl + %^ expect-eq + (map-foldl ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) + [7 ~[2 3 5]] + "map-foldl" +:: +++ test-map-foldr + %^ expect-eq + (map-foldr ~[1 2 3] 1 |=({a/@ b/@} [(add a b) (add 1 a)])) + [7 ~[7 5 2]] + "map-foldr" +:: +++ test-unfoldr + %^ expect-eq + (unfoldr 5 |=(a/@ ?:(=(a 0) ~ `[a (dec a)]))) + [5 4 3 2 1 ~] + "unfoldr" +:: +++ test-take + %^ expect-eq + (take 3 ~[1 2 3 4 5]) + [1 2 3 ~] + "take" +:: +++ test-drop + %^ expect-eq + (drop:ls 3 ~[1 2 3 4 5]) + [4 5 ~] + "drop" +:: +++ test-split-at + %^ expect-eq + (split-at 3 ~[1 2 3 4 5]) + [[1 2 3 ~] [4 5 ~]] + "split-at" +:: +++ test-take-while + %^ expect-eq + (take-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) + [1 2 ~] + "take-while" +:: +++ test-drop-while + %^ expect-eq + (drop-while ~[1 2 3 4 5] |=(a/@ (lth a 3))) + [3 4 5 ~] + "drop-while" +:: +++ test-drop-while-end + %^ expect-eq + (drop-while-end ~[5 5 1 5 5] |=(a/@ =(a 5))) + [5 5 1 ~] + "drop-while-end" +:: +++ test-split-on + %^ expect-eq + (split-on ~[1 2 3 4 1 2 3 4] |=(a/@ (lth a 3))) + [[1 2 ~] [3 4 1 2 3 4 ~]] + "split-on" +:: +++ test-break + %^ expect-eq + (break ~[1 2 3 4 1 2 3 4] |=(a/@ (gth a 3))) + [[1 2 3 ~] [4 1 2 3 4 ~]] + "break" +:: +++ test-strip-prefix + %^ expect-eq + (strip-prefix "foo" "foobar") + [~ "bar"] + "break" +:: +++ test-inits + %^ expect-eq + (inits "abc") + ["a" "ab" "abc" ~] + "inits" +:: +++ test-tails + %^ expect-eq + (tails "abc") + ["abc" "bc" "c" ~] + "tails" +:: +++ test-is-prefix-of + %^ expect-eq + (is-prefix-of "foo" "foobar") + %.y + "is-prefix-of" +:: +++ test-is-suffix-of + %^ expect-eq + (is-suffix-of "bar" "foobar") + %.y + "is-suffix-of" +:: +++ test-is-infix-of + %^ expect-eq + (is-infix-of "ob" "foobar") + %.y + "is-infix-of" +:: +++ test-elem + %^ expect-eq + (elem 5 [1 2 3 4 5 ~]) + %.y + "elem" +:: +++ test-lookup + %^ expect-eq + (lookup "two" [["one" 1] ["two" 2] ["three" 3] ~]) + [~ 2] + "lookup" +:: +++ test-find + %^ expect-eq + (find:ls [3 2 1 5 1 2 3 ~] |=(a/@ (gth a 3))) + [~ 5] + "find" +:: +++ test-filter + %^ expect-eq + (filter [1 2 1 2 1 ~] |=(a/@ =(a 2))) + [1 1 1 ~] + "filter" +:: +++ test-partition + %^ expect-eq + (partition [1 2 1 2 1 ~] |=(a/@ =(a 2))) + [[2 2 ~] [1 1 1 ~]] + "partition" +:: +++ test-elem-index + %^ expect-eq + (elem-index 2 [1 2 3 4 ~]) + `1 + "elem-index" +:: +++ test-elem-indices + %^ expect-eq + (elem-indices 2 [1 2 1 2 ~]) + [1 3 ~] + "elem-indices" +:: +++ test-find-index + %^ expect-eq + (find-index [1 2 3 ~] |=(a/@ =(a 2))) + `1 + "find-index" +:: +++ test-find-indices + %^ expect-eq + (find-indices [1 2 1 2 ~] |=(a/@ =(a 2))) + [1 3 ~] + "find-indices" +:: +++ test-zip + %^ expect-eq + (zip [[1 2 3 ~] [4 5 6 ~] [7 8 9 ~] ~]) + [[1 4 7 ~] [2 5 8 ~] [3 6 9 ~] ~] + "zip" +:: +++ test-unique + %^ expect-eq + (unique [1 2 3 1 2 3 ~]) + [1 2 3 ~] + "unique" +:: +++ test-delete + %^ expect-eq + (delete 2 [1 2 3 2 ~]) + [1 3 2 ~] + "delete" +:: +++ test-delete-firsts + %^ expect-eq + (delete-firsts [1 2 2 2 3 4 5 ~] [2 2 5 ~]) + [1 2 3 4 ~] + "delete-firsts" +:: +++ test-union + %^ expect-eq + (union [1 2 3 ~] [4 2 5 ~]) + [1 2 3 4 5 ~] + "union" +:: +++ test-intersect + %^ expect-eq + (intersect [5 6 6 7 8 ~] [9 8 8 6 ~]) + [6 6 8 ~] + "intersect" +-- + diff --git a/tests/mp.hoon b/tests/mp.hoon new file mode 100644 index 000000000..af75fdb9e --- /dev/null +++ b/tests/mp.hoon @@ -0,0 +1,360 @@ +/+ new-hoon, tester +=, dct:new-hoon +=+ four=(from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] ~]) +=+ three=(from-list [[1 "one"] [2 "two"] [3 "three"] ~]) +|_ tester-type:tester +++ test-empty + (expect-eq (empty four) %.n "empty") +:: +++ test-size + (expect-eq (size four) 4 "size") +:: +++ test-member + (expect-eq (member four 4) %.y "member") +:: +++ test-put-with + =+ ints=(from-list [["one" 1] ["two" 2] ["three" 3] ["four" 4] ~]) + %^ expect-eq + (put-with ints "three" 2 add) + (from-list [["one" 1] ["two" 2] ["three" 5] ["four" 4] ~]) + "put-with" +:: +++ test-put-with-key + %^ expect-eq + (put-with-key four 4 "four" |=({a/@ud b/tape c/tape} (weld (scow %ud a) b))) + (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "4four"] ~]) + "put-with-key" +:: +++ test-put-lookup-with-key + %^ expect-eq + %- put-lookup-with-key :^ + four + 4 + "five" + |=({key/@ud old/tape new/tape} new) + :- `"four" + (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "five"] ~]) + "put-lookup-with-key" +:: +++ test-delete + %^ expect-eq + (delete four 4) + three + "delete" +:: +++ test-adjust + %^ expect-eq + %^ adjust + four + 3 + |=(a/tape (weld "this" a)) + (from-list [[1 "one"] [2 "two"] [3 "thisthree"] [4 "four"] ~]) + "adjust" +:: +++ test-adjust-with-key + %^ expect-eq + %^ adjust-with-key + four + 3 + |=({a/@ud b/tape} (weld (scow %ud a) b)) + (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + "adjust-with-key" +:: +++ test-update + %^ expect-eq + %^ update + four + 3 + |=(a/tape `(maybe tape)`~) + (from-list [[1 "one"] [2 "two"] [4 "four"] ~]) + "update" +:: +++ test-update-with-key + %^ expect-eq + %^ update-with-key + four + 3 + |=({a/@u b/tape} `(maybe tape)`[~ (weld (scow %ud a) b)]) + (from-list [[1 "one"] [2 "two"] [3 "3three"] [4 "four"] ~]) + "update-with-key" +:: +++ test-alter-as-add + %^ expect-eq + %^ alter + four + 5 + |=(a/(maybe tape) `(maybe tape)`[~ "five"]) + (from-list [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"] ~]) + "alter (as add)" +:: +++ test-alter-as-delete + %^ expect-eq + %^ alter + four + 2 + |=(a/(maybe tape) `(maybe tape)`~) + (from-list [[1 "one"] [3 "three"] [4 "four"] ~]) + "alter (as delete)" +:: +++ test-alter-as-change + %^ expect-eq + %^ alter + four + 2 + |=(a/(maybe tape) `(maybe tape)`[~ "dos"]) + (from-list [[1 "one"] [2 "dos"] [3 "three"] [4 "four"] ~]) + "alter (as change)" +:: +++ check-alter + :: check random dicts of 50 items with 40 random operations done on them + :: for validity. + %+ check + (generate-dict 50) + |= a/(dict @ud @ud) + :: this is dumb, but use {a} as entropy? + =/ gen (random:new-hoon (jam a)) + =| i/@u + |- + ?: =(i 40) + %.y + =^ key gen (range:gen 0 100) + =^ value gen (range:gen 0 100) + =. a %^ alter-with-key a key + |= {key/@ud current/(maybe @ud)} + ^- (maybe @ud) + =+ action=(mod key 2) + ?: =(action 0) :: return nothing + ~ + ?: =(action 1) :: add/set value + `value + ~ :: impossible + ?. (valid a) + %.n + $(i +(i)) +:: +++ test-union + %^ expect-eq + %+ union + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + (from-list [[1 "left"] [2 "left"] [3 "right"] ~]) + "union" +:: +++ test-union-with + %^ expect-eq + %^ union-with + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + |=({a/tape b/tape} (weld a b)) + (from-list [[1 "left"] [2 "leftright"] [3 "right"] ~]) + "union-with" +:: +++ test-union-with-key + %^ expect-eq + %^ union-with-key + (from-list [[1 "left"] [2 "left"] ~]) + (from-list [[2 "right"] [3 "right"] ~]) + |=({a/@ud b/tape c/tape} :(weld `tape`(scow %ud a) b c)) + (from-list [[1 "left"] [2 "2leftright"] [3 "right"] ~]) + "union-with-key" +:: +++ test-map + %^ expect-eq + %+ map:dct + three + crip + (from-list [[1 'one'] [2 'two'] [3 'three'] ~]) + "map" +:: +++ test-map-with-key + %^ expect-eq + %+ map-with-key + three + |=({a/@u b/tape} (weld (scow %ud a) b)) + (from-list [[1 "1one"] [2 "2two"] [3 "3three"] ~]) + "map-with-key" +:: +++ test-map-fold + %^ expect-eq + %^ map-fold + three + "Everything: " + |= {accumulator/tape value/tape} + [(weld accumulator value) (weld value "X")] + :- "Everything: twoonethree" + (from-list [[1 "oneX"] [2 "twoX"] [3 "threeX"] ~]) + "map-fold" +:: +++ test-map-keys + %^ expect-eq + %+ map-keys + three + |= a/@u + (add a 10) + (from-list [[11 "one"] [12 "two"] [13 "three"] ~]) + "map-keys" +:: +++ test-map-keys-with + %^ expect-eq + %^ map-keys-with + three + |=(a/@u 42) + weld + (from-list [[42 "twothreeone"] ~]) + "map-keys-with" +:: +++ test-fold + %^ expect-eq + %^ fold + three + "Everything: " + :: todo: this works but replacing with just ++weld causes an out of loom. + |= {accumulator/tape value/tape} + ^- tape + (weld accumulator value) + "Everything: twoonethree" + "map-fold" +:: +++ test-fold-with-keys + %^ expect-eq + %^ fold-with-keys + three + "Everything: " + |= {accumulator/tape key/@u value/tape} + ^- tape + :(weld accumulator (scow %ud key) value) + "Everything: 2two1one3three" + "map-fold-with-keys" +:: +++ test-elems + %^ expect-eq + (elems three) + ["two" "three" "one" ~] + "elems" +:: +++ test-keys + %^ expect-eq + (keys three) + [2 3 1 ~] + "keys" +:: +++ test-keys-set + %^ expect-eq + (keys-set three) + (si:nl [2 3 1 ~]) + "keys-set" +:: +++ test-from-set + %^ expect-eq + %+ from-set + (si:nl [1 2 3 ~]) + |= a/@u + (scow %ud a) + (from-list [[1 "1"] [2 "2"] [3 "3"] ~]) + "from-set" +:: +++ test-from-list-with + %^ expect-eq + %+ from-list-with + [[1 1] [2 1] [2 1] [3 3] ~] + add + (from-list [[1 1] [2 2] [3 3] ~]) + "from-list-with" +:: +++ test-filter + %^ expect-eq + %+ filter + (from-list [[1 1] [2 1] [3 2] [4 1] ~]) + |=(a/@u !=(a 1)) + (from-list [[1 1] [2 1] [4 1] ~]) + "filter" +:: +++ test-filter-with-key + %^ expect-eq + %+ filter-with-key + (from-list [[1 1] [2 1] [3 2] [4 1] ~]) + |=({a/@u b/@u} =(a 2)) + (from-list [[1 1] [3 2] [4 1] ~]) + "filter-with-key" +:: +++ test-restrict-keys + %^ expect-eq + %+ restrict-keys + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + (si:nl [1 3 5 ~]) + (from-list [[1 1] [3 3] [5 5] ~]) + "restrict-keys" +:: +++ test-without-keys + %^ expect-eq + %+ without-keys + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + (si:nl [1 3 5 ~]) + (from-list [[2 2] [4 4] ~]) + "restrict-keys" +:: +++ test-partition + %^ expect-eq + %+ partition + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=(a/@u |(=(a 1) =(a 3))) + :- (from-list [[1 1] [3 3] ~]) + (from-list [[2 2] [4 4] [5 5] ~]) + "partition" +:: +++ test-map-maybe + %^ expect-eq + %+ map-maybe + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=(a/@u ?:(=(a 3) ~ `a)) + (from-list [[1 1] [2 2] [4 4] [5 5] ~]) + "map-maybe" +:: +++ test-map-maybe-with-key + %^ expect-eq + %+ map-maybe-with-key + (from-list [[1 2] [2 3] [3 4] [4 5] [5 6] ~]) + |=({k/@u v/@u} ?:(=(k 3) ~ `v)) + (from-list [[1 2] [2 3] [4 5] [5 6] ~]) + "map-maybe-with-key" +:: +++ test-map-either + %^ expect-eq + %+ map-either + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |= value/@u + ?: =(0 (mod value 2)) + [%& "even"] + [%| 1] + :- (from-list [[2 "even"] [4 "even"] ~]) + (from-list [[1 1] [3 1] [5 1] ~]) + "map-either" +:: +++ test-map-either-with-key + %^ expect-eq + %+ map-either-with-key + (from-list [[1 1] [2 1] [3 1] [4 1] [5 1] ~]) + |= {key/@u value/@u} + ?: =(0 (mod key 2)) + [%& "even"] + [%| 1] + :- (from-list [[2 "even"] [4 "even"] ~]) + (from-list [[1 1] [3 1] [5 1] ~]) + "map-either" +:: +++ test-is-subdict + %^ expect-eq + %^ is-subdict-by + (from-list [[1 1] [4 4] ~]) + (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] ~]) + |=({a/* b/*} =(a b)) + %.y + "is-subdict" +:: +++ test-valid + %^ expect-eq + (valid (from-list [[1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8] [9 9] ~])) + %.y + "valid" +-- + diff --git a/tests/myb.hoon b/tests/myb.hoon new file mode 100644 index 000000000..90ce805a3 --- /dev/null +++ b/tests/myb.hoon @@ -0,0 +1,32 @@ +/+ new-hoon, tester +=, myb:new-hoon +|_ tester-type:tester +++ test-from-list-null + (expect-eq (from-list ~) ~ "from-list") +:: +++ test-from-list-real + (expect-eq (from-list [5 ~]) [~ 5] "from-list") +:: +++ test-to-list-null + (expect-eq (to-list ~) ~ "to-list") +:: +++ test-to-list-real + (expect-eq (to-list [~ 5]) [5 ~] "to-list") +:: +++ test-concat-null + (expect-eq (concat ~) ~ "concat") +:: +++ test-concat-real + :: wait, if i pull the cast out from below, the concat implementation + :: doesn't compile anymore? + (expect-eq (concat `(list (maybe @ud))`[~ [~ 1] ~ [~ 2] ~]) [1 2 ~] "concat") +:: +++ test-map + %^ expect-eq + %+ map:myb + [1 2 3 2 ~] + |=(a/@u ?:(=(2 a) [~ 2] ~)) + [2 2 ~] + "map" +-- + From bd6736b6cf50a1610193e05d7da7b53e4c5cdfab Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sat, 30 Dec 2017 22:37:49 -0800 Subject: [PATCH 080/184] Rebuild the test runner. The test runner now has a notion of tests being part of a hierarchical path, and allows running what were multiple suites in one run. --- gen/test.hoon | 111 +++++++++++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 47 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index ec215e3a6..4b385d651 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -10,65 +10,76 @@ /= test-ls /: /===/tests/ls /!noun/ /= test-mp /: /===/tests/mp /!noun/ +=, new-hoon |% -++ perform-test-suite - :: takes a testing core and executes all tests in it. - |= {name/tape v/vase eny/@uvJ} +:> # %models ++| ++= tests + :> a hierarchical structure of tests + :> + :> an alphabetically sorted recursive association list + :> mapping a part of a path to either a test trap or a + :> sublist of the same type. + (list (pair term (either (trap (list tape)) tests))) +:: +:> # %traps ++| +++ gen-tests + :> creates a {tests} list out of a vase of a test suite + |= [v=vase eny=@uvJ] + ^- tests + =+ arms=(sort (sloe p.v) aor) + =+ context=(slop (init-test-vase:tester eny) v) + %+ map:ls arms + |= arm/term + :- arm + :- %& + |. + :: todo: pull out the entropy from the result interface. + =/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]]) + +:((hard {@uvJ (list tape)}) q:(slap r [%limb %results])) +:: +++ test-runner + :> run all tests in {a}. + :: + :: todo: pass in a path to filter on. + =| pax/path + |= a/tests ^- tang + %- concat:ls + %+ map:ls a + |= b/(pair term (either (trap (list tape)) tests)) ^- tang - =+ core-arms=(sort (sloe p.v) aor) - ?: =(~ core-arms) - ~& p.v - [[%leaf :(weld "error: " name " is not a valid testing core.")] ~] - =| out/tang - |- - ?~ core-arms - out - %= $ - out (weld (perform-test-arm name i.core-arms v eny) out) - core-arms t.core-arms + ?- -.q.b + %& (run-test [p.b pax] p.q.b) + %| ^$(pax [p.b pax], a p.q.b) == :: -++ perform-test-arm - :: performs a single test. - |= {suite-name/tape arm-name/term v/vase eny/@uvJ} - :: todo: terminal color on the output +++ run-test + :> executes an individual test. + |= {pax/path test/(trap (list tape))} ^- tang - =+ run=(run-arm-in-test-core arm-name v eny) - =+ full-name=:(weld suite-name "/" (trip arm-name)) + =+ name=(spud (reverse:ls pax)) + =+ run=(mule test) + ~! run ?- -.run $| :: the stack is already flopped for output? ;: weld p:run - `tang`[[%leaf (weld full-name " CRASHED")] ~] + `tang`[[%leaf (weld name " CRASHED")] ~] == - $& :: todo: test the cookie to make sure it returned the same core. - ?: =(~ +.p:run) - [[%leaf (weld full-name " OK")] ~] + $& ?: =(~ p:run) + [[%leaf (weld name " OK")] ~] :: Create a welded list of all failures indented. %- flop ;: weld - `tang`[[%leaf (weld full-name " FAILED")] ~] - %+ turn +.p:run + `tang`[[%leaf (weld name " FAILED")] ~] + ~! p:run + %+ turn p:run |= {i/tape} ^- tank [%leaf (weld " " i)] == == -:: -++ run-arm-in-test-core - :: runs a single arm. - :: - :: returns the output of `++mule` so that we can react to crashes - :: appropriately. - |= {arm-name/term v/vase eny/@uvJ} - ^- (each {@uvJ (list tape)} (list tank)) - =/ t (init-test-vase:tester eny) - :: run the tests in the interpreter so we catch crashes. - %- mule |. - =/ r (slap (slop t v) [%cnsg [arm-name ~] [%$ 3] [[%$ 2] ~]]) - :: return just the results or we will be here forever while we try to copy - :: the entire kernel. - ((hard {@uvJ (list tape)}) q:(slap r [%limb %results])) -- :: :- %say @@ -77,9 +88,15 @@ $~ == :- %tang -:: todo: right now, we hard code ++test-core. but eventually, we must instead -:: scry ford for the core from the hoon file. that doesn't exist yet. -::(perform-test-suite "test-thr" !>(test-thr) eny) -::(perform-test-suite "test-myb" !>(test-myb) eny) -::(perform-test-suite "test-ls" !>(test-ls) eny) -(perform-test-suite "test-mp" !>(test-mp) eny) +%- test-runner +^- tests +:~ + :: todo: for now, this is manually constructed. later, this should + :: be generated from the contents of %/tests, without addressing the + :: files individually. if possible, lift the call to ++gen-tests into + :: the build steps for caching. + ['ls' [%| (gen-tests !>(test-ls) eny)]] + ['mp' [%| (gen-tests !>(test-mp) eny)]] + ['myb' [%| (gen-tests !>(test-myb) eny)]] + ['thr' [%| (gen-tests !>(test-thr) eny)]] +== From f764db7145f652b16b24ac9cbf83bf1f75fcbdb3 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sat, 30 Dec 2017 22:41:01 -0800 Subject: [PATCH 081/184] Don't pass the entropy back as part of the results. --- gen/test.hoon | 3 +-- lib/tester.hoon | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index 4b385d651..bff86ea8f 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -35,9 +35,8 @@ :- arm :- %& |. - :: todo: pull out the entropy from the result interface. =/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]]) - +:((hard {@uvJ (list tape)}) q:(slap r [%limb %results])) + ((hard (list tape)) q:(slap r [%limb %results])) :: ++ test-runner :> run all tests in {a}. diff --git a/lib/tester.hoon b/lib/tester.hoon index 5dd0e2138..2edded433 100644 --- a/lib/tester.hoon +++ b/lib/tester.hoon @@ -90,9 +90,7 @@ :: ++ results :: returns results. - :: - :: returns the test run's identity cookie and the list of failures. - ^- {@uvJ (list tape)} - [eny error-lines] + ^- (list tape) + error-lines -- -- From 4e5e48d0b2ee2a843d16af05ad6e8d720c85a595 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sat, 30 Dec 2017 23:23:54 -0800 Subject: [PATCH 082/184] Add an optional filter to the +test generator. Now that we are running multiple suites, make the generator take an optional path so you can run just a single suite or even a single test. --- gen/test.hoon | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index bff86ea8f..a2be7380e 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -22,7 +22,7 @@ :> sublist of the same type. (list (pair term (either (trap (list tape)) tests))) :: -:> # %traps +:> # %test +| ++ gen-tests :> creates a {tests} list out of a vase of a test suite @@ -39,15 +39,17 @@ ((hard (list tape)) q:(slap r [%limb %results])) :: ++ test-runner - :> run all tests in {a}. - :: - :: todo: pass in a path to filter on. + :> run all tests in {a} with a filter. =| pax/path - |= a/tests ^- tang + |= {filter/path a/tests} + ^- tang %- concat:ls %+ map:ls a |= b/(pair term (either (trap (list tape)) tests)) ^- tang + =^ matches filter (match-filter filter p.b) + ?. matches + ~ ?- -.q.b %& (run-test [p.b pax] p.q.b) %| ^$(pax [p.b pax], a p.q.b) @@ -79,15 +81,25 @@ [%leaf (weld " " i)] == == +:: +++ match-filter + :> checks to see if {name} matches the head of {filter}. + |= {filter/path name/term} + ^- {? path} + ?~ filter + :: when there's no filter, we always match. + [%.y ~] + [=(i.filter name) t.filter] -- :: :- %say |= $: {now/@da eny/@uvJ bec/beak} - $~ + {filter/$?($~ {pax/path $~})} $~ == :- %tang -%- test-runner +%+ test-runner +?~ filter ~ pax.filter ^- tests :~ :: todo: for now, this is manually constructed. later, this should From 437f205ef76f5b23913ab360162db5032e4c1c7e Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sun, 31 Dec 2017 10:41:01 -0800 Subject: [PATCH 083/184] %143-ification. --- gen/test.hoon | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gen/test.hoon b/gen/test.hoon index a2be7380e..4991c7aac 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -40,12 +40,12 @@ :: ++ test-runner :> run all tests in {a} with a filter. - =| pax/path - |= {filter/path a/tests} + =| pax=path + |= [filter=path a=tests] ^- tang %- concat:ls %+ map:ls a - |= b/(pair term (either (trap (list tape)) tests)) + |= b=(pair term (either (trap (list tape)) tests)) ^- tang =^ matches filter (match-filter filter p.b) ?. matches @@ -57,7 +57,7 @@ :: ++ run-test :> executes an individual test. - |= {pax/path test/(trap (list tape))} + |= [pax=path test=(trap (list tape))] ^- tang =+ name=(spud (reverse:ls pax)) =+ run=(mule test) @@ -84,8 +84,8 @@ :: ++ match-filter :> checks to see if {name} matches the head of {filter}. - |= {filter/path name/term} - ^- {? path} + |= [filter=path name=term] + ^- [? path] ?~ filter :: when there's no filter, we always match. [%.y ~] @@ -93,8 +93,8 @@ -- :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {filter/$?($~ {pax/path $~})} +|= $: [now=@da eny=@uvJ bec=beak] + [filter=$?($~ [pax=path $~])] $~ == :- %tang From 625959a004595db26c335cbec68993a57681e0b0 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Mon, 1 Jan 2018 11:03:40 -0800 Subject: [PATCH 084/184] Minor cleanup and %143-ization to tester.hoon --- lib/tester.hoon | 59 ++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/lib/tester.hoon b/lib/tester.hoon index 2edded433..cc1723e2b 100644 --- a/lib/tester.hoon +++ b/lib/tester.hoon @@ -12,17 +12,19 @@ ++ tester-type _(init-test `@uvJ`0) :: ++ tester - |_ $: error-lines/(list tape) :: output messages - eny/@uvJ :: entropy - check-iterations/@u :: # of check trials - current-iteration/@u :: current iteration + |_ $: error-lines=(list tape) :< output messages + eny=@uvJ :< entropy + check-iterations=@u :< # of check trials + current-iteration=@u :< current iteration == - :: || %check - :: - :: +| + :> # + :> # %check + :> # + :> gates for quick check style tests. + +| +- check - |* {generator/$-(@uvJ *) test/$-(* ?)} - |- :: why do i have to |-? + |* [generator=$-(@uvJ *) test=$-(* ?)] + |- ^+ +>.$ ?: (gth current-iteration check-iterations) +>.$ @@ -47,8 +49,8 @@ :: todo: a generate function that takes an arbitrary span. :: ++ generate-range - |= {min/@ max/@} - |= c/@uvJ + |= [min=@ max=@] + |= c=@uvJ ^- @ =+ gen=(random:new-hoon c) =^ num gen (range:gen min max) @@ -56,26 +58,32 @@ :: ++ generate-dict :> generator which will produce a dict with {count} random pairs. - |= count/@u + |= count=@u :> generate a dict with entropy {c}. - |= c/@uvJ + |= c=@uvJ + :> + :> gen: stateful random number generator + :> out: resulting map + :> i: loop counter + :> =/ gen (random:new-hoon c) - =| i/@u - =| m/(dict:new-hoon @ud @ud) + =| out=(dict:new-hoon @ud @ud) + =| i=@u |- ^- (dict:new-hoon @ud @ud) ?: =(i count) - m + out =^ first gen (range:gen 0 100) =^ second gen (range:gen 0 100) - $(m (put:dct:new-hoon m first second), i +(i)) - :: - :: || %test - :: - :: +| + $(out (put:dct:new-hoon out first second), i +(i)) + :> # + :> # %test + :> # + :> assertions on state + +| :: todo: unit testing libraries have a lot more to them than just eq. ++ expect-eq - |* {a/* b/* c/tape} + |* [a=* b=* c=tape] ^+ +> ?: =(a b) +>.$ @@ -88,8 +96,13 @@ == == :: + :> # + :> # %output + :> # + :> called by the test harness after test completion + :: ++ results - :: returns results. + :> returns results. ^- (list tape) error-lines -- From 4e33264230b47480230254b9e73b1f270d48cbd4 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 3 Jan 2018 18:30:49 +0100 Subject: [PATCH 085/184] Can now query hall for own circles. Talk code depends on #522. Closes #503. --- app/hall.hoon | 11 ++++++++++- app/talk.hoon | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 7f21ff708..c6e17f32c 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2131,6 +2131,15 @@ ::[:(welp m mos (affection d)) +>.^$] :: ++ peek + |= pax/path + ?> ?=({$x *} pax) :: others unsupported. + ^- (unit (unit (pair mark prize))) + =+ piz=(look (path-to-query t.pax)) + ?~ piz ~ + ?~ u.piz [~ ~] + ``[%hall-prize u.u.piz] +:: +++ look :> query on state :> :> find the result (if any) for a given query. @@ -2597,7 +2606,7 @@ %- pre-bake ta-done:(ta-subscribe:ta src.bol qer) :_ +>.$ - =+ piz=(peek qer) + =+ piz=(look qer) ?~ piz ~&([%query-unavailable pax] mos) ?~ u.piz ~&([%query-invalid pax] mos) :_ mos diff --git a/app/talk.hoon b/app/talk.hoon index bfde631d7..c695479cd 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -89,7 +89,8 @@ {$number $@(@ud {@u @ud})} :< relative/absolute {$who audience} :< presence {$what (unit $@(char audience))} :< show bound glyph - {$sources circle} :< show active sources + {$circles $~} :< show our circles + {$sources circle} :< show active sources :: ui settings :: {$bind char (unit audience)} :< bind glyph {$unbind char (unit audience)} :< unbind glyph @@ -829,6 +830,8 @@ (easy ~) == == + :: + ;~(plug (perk %circles ~) (easy ~)) :: ;~((glue ace) (perk %sources ~) circ) :: @@ -1006,6 +1009,7 @@ $number (number +.job) $who (who +.job) $what (what +.job) + $circles circles $sources (list-sources +.job) :: ui settings $bind (bind +.job) @@ -1339,6 +1343,21 @@ (activate (snag (sub count +(msg)) grams)) (sh-lame "…{(reap p.num '0')}{(scow %ud q.num)}: no such telegram") :: + ++ circles + :> %circles + :> + :> list all local circles. + :: + ^+ ..sh-work + =/ piz + =- .^(prize %gx -) + %+ weld /(scot %p our.bol)/hall/(scot %da now.bol) + /circles/(scot %p our.bol)/hall-prize + ?> ?=($circles -.piz) + %+ sh-fact %mor + %+ turn (sort ~(tap in cis.piz) lth) + |= a/name [%txt "%{(trip a)}"] + :: ++ list-sources :> %sources :> @@ -1869,7 +1888,6 @@ ^+ +> ?~ gaz +> $(gaz t.gaz, +> (sh-gram i.gaz)) - :: -- -- :: From bd712a8547d8b7c735e62f65c26153e9b2368281 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 3 Jan 2018 21:10:47 +0100 Subject: [PATCH 086/184] Clarified TODO. --- app/hall.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/hall.hoon b/app/hall.hoon index c6e17f32c..2a7e2ad21 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -1027,7 +1027,7 @@ :: ?= $~ (rush (fall han.man.new '') ;~(pfix sig fed:ag)) - ::TODO %+ syntax errors? + ::TODO calling with %+ gives syntax error == == +> From 6169a6311a51b75c9e21a4ae59dd44b4653d317f Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Wed, 3 Jan 2018 16:29:59 -0800 Subject: [PATCH 087/184] adapt changes to ++rove from commit 180751aa8223cdd66648ccc4e685fde784328585 --- sys/vane/clay.hoon | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index b39de8dd3..7f70fe749 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -161,10 +161,6 @@ gon/(each (set path) (pair term (list tank))) :: return value == :: :: -:: Like a ++mood, except with a cache of the state at the starting version. -:: -++ moot {p/case q/case r/path s/(map path lobe)} :: stored change range -:: :: New desk data. :: :: Sent to other ships to update them about a particular desk. Includes a map @@ -277,7 +273,7 @@ ++ rove :: stored request $% {$sing p/mood} :: single request {$next p/mood q/(unit (each cage lobe))} :: next version - {$many p/? q/moot} :: change range + {$many p/? q/moat r/(map path lobe)} :: change range == :: :: :: Foreign desk data. @@ -686,9 +682,8 @@ $sing ~ $next ?~ (case-to-aeon:ze q.p.rov) ~ - %- ~(rep by qyx) - |= {{a/rove *} b/(list rove)} ^+ b - =- ?.(- b [a b]) + %+ skim ~(tap in ~(key by qyx)) + |= a=rove ^- ? ?& ?=($next -.a) =(p.a p.rov(q q.p.a)) ?=(^ (case-to-aeon:ze q.p.a)) @@ -696,9 +691,8 @@ :: $many ?~ (case-to-aeon:ze p.q.rov) ~ - %- ~(rep by qyx) - |= {{a/rove *} b/(list rove)} ^+ b - =- ?.(- b [a b]) + %+ skim ~(tap in ~(key by qyx)) + |= a=rove ^- ? ?& ?=($many -.a) =(a rov(p.q p.q.a)) ?=(^ (case-to-aeon:ze p.q.a)) @@ -818,7 +812,7 @@ =+ nab=(case-to-aeon:ze p.q.rav) ?~ nab ?> =(~ (case-to-aeon:ze q.q.rav)) - (duce (rive rav)) + (duce [- p q ~]:rav) =+ huy=(case-to-aeon:ze q.q.rav) ?: &(?=(^ huy) |((lth u.huy u.nab) &(=(0 u.huy) =(0 u.nab)))) (blub hen) @@ -830,7 +824,7 @@ (blub hen) =+ ^= ptr ^- case [%ud +(let.dom)] - (duce `rove`[%many p.rav ptr q.q.rav r.q.rav ear]) + (duce `rove`[%many p.rav [ptr q.q.rav r.q.rav] ear]) == :: :: Print a summary of changes to dill. @@ -1644,14 +1638,9 @@ ?- -.rov $sing rov $next [- p]:rov - $many [%many p.rov p.q.rov q.q.rov r.q.rov] + $many [- p q]:rov == :: - ++ rive - |= rav/{$many p/? q/moat} - ^- rove - [%many p.rav p.q.rav q.q.rav r.q.rav ~] - :: :: Loop through open subscriptions and check if we can fill any of them. :: ++ wake :: update subscribers @@ -1705,7 +1694,8 @@ $(xiq t.xiq, ..wake (blab-all q.i.xiq mun u.u.var)) :: $many - =+ mot=`moot`q.p.i.xiq + =+ mot=`moat`q.p.i.xiq + =* sav r.p.i.xiq =+ nab=(case-to-aeon:ze p.mot) ?~ nab $(xiq t.xiq, xaq [i.xiq xaq]) @@ -1717,7 +1707,7 @@ xaq [i.xiq(q.p mot) xaq] ..wake =+ ^= ear (lobes-at-path:ze let.dom r.mot) - ?: =(s.mot ear) ..wake + ?: =(sav ear) ..wake (bleb-all q.i.xiq let.dom ?:(p.p.i.xiq ~ `[u.nab let.dom])) == %= $ @@ -1725,7 +1715,7 @@ ..wake =- (blub-all:- q.i.xiq ~) =+ ^= ear (lobes-at-path:ze u.huy r.mot) - ?: =(s.mot ear) (blub-all q.i.xiq ~) + ?: =(sav ear) (blub-all q.i.xiq ~) (bleb-all q.i.xiq +(u.nab) ?:(p.p.i.xiq ~ `[u.nab u.huy])) == == From 845696a3a6a4f08be7b420f022b085dd6cf79df2 Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Wed, 3 Jan 2018 16:37:44 -0800 Subject: [PATCH 088/184] Fix Clay %next revision adapted from commit 852997ac16a751c69775489c61ae8e5b650c9a50 --- sys/vane/clay.hoon | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 7f70fe749..b79b86b28 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -1683,15 +1683,16 @@ ?~ u.ver $(xiq t.xiq, ..wake (blub-all q.i.xiq ~)) $(xiq t.xiq, xaq [i.xiq(q.p u.ver) xaq]) - =+ var=(aver mun(q [%ud let.dom])) + =/ muc mun(q [%ud let.dom]) :: current mood + =+ var=(aver muc) ?~ var - ~& [%oh-noes mood=mun letdom=let.dom] + ~& [%oh-noes old=mun mood=muc letdom=let.dom] $(xiq t.xiq) ?~ u.var - $(xiq t.xiq, ..wake (blab-all q.i.xiq mun %& %null [%atom %n ~] ~)) + $(xiq t.xiq, ..wake (blab-all q.i.xiq muc %& %null [%atom %n ~] ~)) ?: (equivalent-data:ze u.q.p.i.xiq u.u.var) $(xiq t.xiq, xaq [i.xiq xaq]) - $(xiq t.xiq, ..wake (blab-all q.i.xiq mun u.u.var)) + $(xiq t.xiq, ..wake (blab-all q.i.xiq muc u.u.var)) :: $many =+ mot=`moat`q.p.i.xiq From 942956c8c026da27cd447d62aede1c74bf6f88cb Mon Sep 17 00:00:00 2001 From: Steven Dee <_@wholezero.org> Date: Fri, 5 Jan 2018 09:15:03 -0500 Subject: [PATCH 089/184] New key for ~tyr Also put on an n in compliance with current Steven Dee naming conventions (and various government IDs.) --- sys/vane/ames.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vane/ames.hoon b/sys/vane/ames.hoon index c7c27c195..06ce563d2 100644 --- a/sys/vane/ames.hoon +++ b/sys/vane/ames.hoon @@ -267,7 +267,7 @@ 0w2g.gLmg4.MtrHQ.A5VmH.WPk6G :: 150, ~ryg, Dan Haffey (oldkey) 0w0 :: 151, ~ryx, Tlon 0w0 :: 152, ~fep, Tlon - 0w2j.T1u2s.BfXjV.ldOGR.aiZrQ :: 153, ~tyr, Steve Dee (oldkey) + 0w3x.y5stk.FMmvV.LQo3X.OCXkI :: 153, ~tyr, Steven Dee 0w0 :: 154, ~tus, Tlon 0w0 :: 155, ~tyc, Tlon 0w0 :: 156, ~leg, Tlon From f5628c1dad7ec9f669e2b354bcf1dd9f9d7d291c Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 5 Jan 2018 20:19:34 +0100 Subject: [PATCH 090/184] Separate the Tlon ops generators to allow more granular control over stream & fora sources. --- app/hood.hoon | 3 ++- gen/hood/tlon/add-fora.hoon | 11 +++++++++++ gen/hood/tlon/add-stream.hoon | 2 ++ gen/hood/tlon/init-stream.hoon | 12 ++++++++++++ gen/hood/tlon/init-web.hoon | 9 --------- lib/hood/helm.hoon | 24 ++++++++++++++++++++---- 6 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 gen/hood/tlon/add-fora.hoon create mode 100644 gen/hood/tlon/init-stream.hoon delete mode 100644 gen/hood/tlon/init-web.hoon diff --git a/app/hood.hoon b/app/hood.hoon index 5e6e3a869..a729cb382 100644 --- a/app/hood.hoon +++ b/app/hood.hoon @@ -164,8 +164,9 @@ ++ poke-helm-nuke (wrap poke-nuke):from-helm ++ poke-helm-begin (wrap poke-begin):from-helm ++ poke-helm-spawn (wrap poke-spawn):from-helm +++ poke-helm-tlon-add-fora (wrap poke-tlon-add-fora):from-helm ++ poke-helm-tlon-add-stream (wrap poke-tlon-add-stream):from-helm -++ poke-helm-tlon-init-web (wrap poke-tlon-init-web):from-helm +++ poke-helm-tlon-init-stream (wrap poke-tlon-init-stream):from-helm ++ poke-hood-sync (wrap poke-sync):from-kiln ++ poke-hood-init-sync (wrap poke-init-sync):from-kiln ++ poke-kiln-commit (wrap poke-commit):from-kiln diff --git a/gen/hood/tlon/add-fora.hoon b/gen/hood/tlon/add-fora.hoon new file mode 100644 index 000000000..2ce32b8fb --- /dev/null +++ b/gen/hood/tlon/add-fora.hoon @@ -0,0 +1,11 @@ +:: tlon: add fora notifications to local urbit-meta +:: +:: make the local urbit-meta pull from {for}'s fora notification channels. +:: +:::: /gen/hood/tlon/add-fora/hoon + :: +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + {{for/ship $~} $~} + == +[%helm-tlon-add-fora for] diff --git a/gen/hood/tlon/add-stream.hoon b/gen/hood/tlon/add-stream.hoon index 5bb110998..dbc29448d 100644 --- a/gen/hood/tlon/add-stream.hoon +++ b/gen/hood/tlon/add-stream.hoon @@ -1,5 +1,7 @@ :: tlon: add stream to local urbit-meta :: +:: make the local urbit-meta pull from {web}'s stream. +:: :::: /gen/hood/tlon/add-stream/hoon :: :- %say diff --git a/gen/hood/tlon/init-stream.hoon b/gen/hood/tlon/init-stream.hoon new file mode 100644 index 000000000..3d1be720d --- /dev/null +++ b/gen/hood/tlon/init-stream.hoon @@ -0,0 +1,12 @@ +:: tlon: configure stream ship +:: +:: create a local stream channel and have it pull from +:: {met}'s urbit-meta. +:: +:::: /gen/hood/tlon/init-stream/hoon + :: +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + {{met/ship $~} $~} + == +[%helm-tlon-init-stream met] diff --git a/gen/hood/tlon/init-web.hoon b/gen/hood/tlon/init-web.hoon deleted file mode 100644 index 8cf44c1f7..000000000 --- a/gen/hood/tlon/init-web.hoon +++ /dev/null @@ -1,9 +0,0 @@ -:: tlon: configure web ship -:: -:::: /gen/hood/tlon/init-web/hoon - :: -:- %say -|= $: {now/@da eny/@uvJ bec/beak} - {{met/ship $~} $~} - == -[%helm-tlon-init-web met] diff --git a/lib/hood/helm.hoon b/lib/hood/helm.hoon index fd5e3584e..127547184 100644 --- a/lib/hood/helm.hoon +++ b/lib/hood/helm.hoon @@ -241,14 +241,13 @@ |= {way/wire her/ship cop/coop} =< abet (emit %flog ~ %text "woot: {<[way cop]>}") :: -++ poke-tlon-init-web +++ poke-tlon-init-stream + :: creates stream channel and makes it pull from + :: urbit-meta on {met}. |= met/ship =< abet %- emil %- flop :~ ^- card - :^ %poke /helm/web/fora [our %hood] - [%drum-start q.byk %fora] - :: :^ %poke /helm/web/stream/create [our %hall] :- %hall-action :- %create @@ -265,7 +264,24 @@ [%stream & [[[met %urbit-meta] `[da+(sub now ~d1) ~]] ~ ~]] == :: +++ poke-tlon-add-fora + :: makes the local urbit-meta pull from {for}'s fora + :: notification channels. + |= for/ship =< abet + %- emil + :~ :^ %poke /helm/web/fora/source [our %hall] + :- %hall-action + :- %source + [%urbit-meta & [[[for %fora-posts] `[da+now ~]] ~ ~]] + :: + :^ %poke /helm/web/fora/source [our %hall] + :- %hall-action + :- %source + [%urbit-meta & [[[for %fora-comments] `[da+now ~]] ~ ~]] + == +:: ++ poke-tlon-add-stream + :: makes the local urbit-meta pull from {web}'s stream. |= web/ship =< abet %- emit :^ %poke /helm/web/stream/source [our %hall] From 48585d2b2f56d6cffec9c8e1f92f7835e017dba0 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sat, 6 Jan 2018 22:51:52 -0800 Subject: [PATCH 091/184] +test now deals with recursive directory structures. +test now offloads creation of the test tree into a renderer. this should help with caching. using a renderer also lets us deal with hierarchical directory structures, leading to better organization. --- gen/test.hoon | 72 ++++++++--------------------------- lib/tester.hoon | 64 ++++++++++++++++++++++++++++++- ren/test-tree.hoon | 10 +++++ tests/{ => new-hoon}/ls.hoon | 0 tests/{ => new-hoon}/mp.hoon | 0 tests/{ => new-hoon}/myb.hoon | 0 tests/{ => new-hoon}/thr.hoon | 0 7 files changed, 87 insertions(+), 59 deletions(-) create mode 100644 ren/test-tree.hoon rename tests/{ => new-hoon}/ls.hoon (100%) rename tests/{ => new-hoon}/mp.hoon (100%) rename tests/{ => new-hoon}/myb.hoon (100%) rename tests/{ => new-hoon}/thr.hoon (100%) diff --git a/gen/test.hoon b/gen/test.hoon index 4991c7aac..df4c279ff 100644 --- a/gen/test.hoon +++ b/gen/test.hoon @@ -1,67 +1,35 @@ -:: todo: think about using horns to import all tests in %/tests? -:: -:: i should be able to use /: ? /+ new-hoon, tester - -:: ok, doing this as a list first. then do it automated. is there an equivalent -:: to /_ which works on an arbitrary directory? -/= test-thr /: /===/tests/thr /!noun/ -/= test-myb /: /===/tests/myb /!noun/ -/= test-ls /: /===/tests/ls /!noun/ -/= test-mp /: /===/tests/mp /!noun/ - +/= all-tests + /^ (map @ta tests:tester) + /: /===/tests + /_ /test-tree/ +:: =, new-hoon |% -:> # %models -+| -+= tests - :> a hierarchical structure of tests - :> - :> an alphabetically sorted recursive association list - :> mapping a part of a path to either a test trap or a - :> sublist of the same type. - (list (pair term (either (trap (list tape)) tests))) -:: -:> # %test -+| -++ gen-tests - :> creates a {tests} list out of a vase of a test suite - |= [v=vase eny=@uvJ] - ^- tests - =+ arms=(sort (sloe p.v) aor) - =+ context=(slop (init-test-vase:tester eny) v) - %+ map:ls arms - |= arm/term - :- arm - :- %& - |. - =/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]]) - ((hard (list tape)) q:(slap r [%limb %results])) :: ++ test-runner :> run all tests in {a} with a filter. =| pax=path - |= [filter=path a=tests] + |= [filter=path eny=@uvJ a=tests:tester] ^- tang %- concat:ls - %+ map:ls a - |= b=(pair term (either (trap (list tape)) tests)) + %+ turn a + |= b=instance:tester ^- tang =^ matches filter (match-filter filter p.b) ?. matches ~ ?- -.q.b - %& (run-test [p.b pax] p.q.b) + %& (run-test [p.b pax] eny p.q.b) %| ^$(pax [p.b pax], a p.q.b) == :: ++ run-test :> executes an individual test. - |= [pax=path test=(trap (list tape))] + |= [pax=path eny=@uvJ test=$-(@uvJ (list tape))] ^- tang - =+ name=(spud (reverse:ls pax)) - =+ run=(mule test) - ~! run + =+ name=(spud (flop pax)) + =+ run=(mule |.((test eny))) ?- -.run $| :: the stack is already flopped for output? ;: weld @@ -74,7 +42,6 @@ %- flop ;: weld `tang`[[%leaf (weld name " FAILED")] ~] - ~! p:run %+ turn p:run |= {i/tape} ^- tank @@ -98,16 +65,7 @@ $~ == :- %tang -%+ test-runner +%^ test-runner ?~ filter ~ pax.filter -^- tests -:~ - :: todo: for now, this is manually constructed. later, this should - :: be generated from the contents of %/tests, without addressing the - :: files individually. if possible, lift the call to ++gen-tests into - :: the build steps for caching. - ['ls' [%| (gen-tests !>(test-ls) eny)]] - ['mp' [%| (gen-tests !>(test-mp) eny)]] - ['myb' [%| (gen-tests !>(test-myb) eny)]] - ['thr' [%| (gen-tests !>(test-thr) eny)]] -== +eny +(test-map-to-test-list:tester all-tests) diff --git a/lib/tester.hoon b/lib/tester.hoon index cc1723e2b..80714ba84 100644 --- a/lib/tester.hoon +++ b/lib/tester.hoon @@ -1,5 +1,65 @@ +/+ new-hoon :: common testing library. |% +:> # %models ++| ++= tests + :> a hierarchical structure of tests + :> + :> an alphabetically sorted recursive association list + :> mapping a part of a path to either a test trap or a + :> sublist of the same type. + (list instance) +:: ++= instance + :> a mapping between a term and part of a test tree. + :> + (pair term (each $-(@uvJ (list tape)) tests)) +:: +:> # %generate +:> utilities for generating models. ++| +++ merge-base-and-recur + :> combine the current file and subdirectory. + :> + :> this merges the file {base} with its child files {recur}. + |= [base=vase recur=(map @ta tests:tester)] + ^- tests + =+ a=(gen-tests base) + =+ b=(test-map-to-test-list recur) + :: todo: why does ++weld not work here? {a} and {b} are cast and have the + :: correct faces. + (welp a b) +:: +++ test-map-to-test-list + :> translates ford output to something we can work with. + :> + :> ford gives us a `(map @ta tests:tester)`, but we actually + :> want something like ++tests. + |= a=(map @ta tests:tester) + :: todo: i'd like to sort this, but ++sort has -find.a problems much like + :: ++weld does above!? + ^- tests + %+ turn + (to-list:dct:new-hoon a) + |= {key/@ta value/tests:tester} + [key [%| value]] + +:: +++ gen-tests + :> creates a {tests} list out of a vase of a test suite + |= v=vase :: eny=@uvJ] + ^- tests + =+ arms=(sort (sloe p.v) aor) + %+ turn arms + |= arm/term + :- arm + :- %& + |= eny=@uvJ + =+ context=(slop (init-test-vase:tester eny) v) + =/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]]) + ((hard (list tape)) q:(slap r [%limb %results])) +:: ++ init-test-vase |= {cookie/@uvJ} ^- vase @@ -79,7 +139,7 @@ :> # :> # %test :> # - :> assertions on state + :> test expectation functions +| :: todo: unit testing libraries have a lot more to them than just eq. ++ expect-eq @@ -99,7 +159,7 @@ :> # :> # %output :> # - :> called by the test harness after test completion + :> called by the test harness :: ++ results :> returns results. diff --git a/ren/test-tree.hoon b/ren/test-tree.hoon new file mode 100644 index 000000000..57d0ec80d --- /dev/null +++ b/ren/test-tree.hoon @@ -0,0 +1,10 @@ +/+ tester +/= base /| /!noun/ + /~ ~ + == +/= recur /^ (map @ta tests:tester) + /| /_ /test-tree/ + /~ ~ + == +:: +(merge-base-and-recur:tester !>(base) recur) diff --git a/tests/ls.hoon b/tests/new-hoon/ls.hoon similarity index 100% rename from tests/ls.hoon rename to tests/new-hoon/ls.hoon diff --git a/tests/mp.hoon b/tests/new-hoon/mp.hoon similarity index 100% rename from tests/mp.hoon rename to tests/new-hoon/mp.hoon diff --git a/tests/myb.hoon b/tests/new-hoon/myb.hoon similarity index 100% rename from tests/myb.hoon rename to tests/new-hoon/myb.hoon diff --git a/tests/thr.hoon b/tests/new-hoon/thr.hoon similarity index 100% rename from tests/thr.hoon rename to tests/new-hoon/thr.hoon From b0876bd4e6f979f432de72e9aa03a9bde9beab94 Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 7 Jan 2018 16:28:22 +0100 Subject: [PATCH 092/184] Burden prize may contains no more than 2k messages, for performance reasons. --- app/hall.hoon | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/hall.hoon b/app/hall.hoon index 2a7e2ad21..7750b17de 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -921,6 +921,8 @@ :: |= {gaz/(list telegram) cos/lobby pes/crowd} ^+ +> + ~? (gth (lent gaz) 2.000) + [%unexpected-scrollback-length nom (lent gaz)] =* self +> :: local config =. self @@ -2171,7 +2173,9 @@ :: only auto-federate channels for now. ?. ?=($channel sec.con.shape.s) ~ :+ ~ n - :+ grams.s + :: share no more than 2k messages at once, for performance reasons. + :+ ?: (lte count.s 2.000) grams.s + (slag (sub count.s 2.000) grams.s) [shape.s mirrors.s] [locals.s remotes.s] :: From b772818ef30c37dc1c87728cf85cdd26a9688f82 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Sun, 7 Jan 2018 15:55:44 -0800 Subject: [PATCH 093/184] Minor cleanups. --- lib/tester.hoon | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/tester.hoon b/lib/tester.hoon index 80714ba84..16ba5c21c 100644 --- a/lib/tester.hoon +++ b/lib/tester.hoon @@ -1,23 +1,22 @@ /+ new-hoon -:: common testing library. +:: +:> testing utilities |% :> # %models +| += tests :> a hierarchical structure of tests :> - :> an alphabetically sorted recursive association list - :> mapping a part of a path to either a test trap or a - :> sublist of the same type. + :> a recursive association list mapping a part of a path + :> to either a test trap or a sublist of the same type. (list instance) :: += instance - :> a mapping between a term and part of a test tree. - :> + :> a mapping between a term and part of a test tree. (pair term (each $-(@uvJ (list tape)) tests)) :: :> # %generate -:> utilities for generating models. +:> utilities for generating ++tests from files and directories. +| ++ merge-base-and-recur :> combine the current file and subdirectory. @@ -44,11 +43,10 @@ (to-list:dct:new-hoon a) |= {key/@ta value/tests:tester} [key [%| value]] - :: ++ gen-tests :> creates a {tests} list out of a vase of a test suite - |= v=vase :: eny=@uvJ] + |= v=vase ^- tests =+ arms=(sort (sloe p.v) aor) %+ turn arms @@ -56,14 +54,12 @@ :- arm :- %& |= eny=@uvJ - =+ context=(slop (init-test-vase:tester eny) v) + =+ context=(slop !>((init-test eny)) v) =/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]]) ((hard (list tape)) q:(slap r [%limb %results])) :: -++ init-test-vase - |= {cookie/@uvJ} - ^- vase - !>((init-test cookie)) +:> # %per-test +:> data initialized on a per-test basis. :: ++ init-test |= {cookie/@uvJ} From 62b531069539f77a3da9636f53f83eb8c5806288 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 8 Jan 2018 22:24:43 +0100 Subject: [PATCH 094/184] Consider passing bone 0 in cards invalid. --- sys/vane/gall.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vane/gall.hoon b/sys/vane/gall.hoon index 7f5689dff..f25edf46f 100644 --- a/sys/vane/gall.hoon +++ b/sys/vane/gall.hoon @@ -782,7 +782,7 @@ ?^ -.q.vax :_(+>.$ [%| (ap-suck "move: invalid move (bone)")]) ?@ +.q.vax :_(+>.$ [%| (ap-suck "move: invalid move (card)")]) =+ hun=(~(get by r.zam) -.q.vax) - ?. (~(has by r.zam) -.q.vax) + ?. &((~(has by r.zam) -.q.vax) !=(0 -.q.vax)) :_(+>.$ [%| (ap-suck "move: invalid card (bone {<-.q.vax>})")]) =^ pec vel (~(spot wa vel) 3 vax) =^ cav vel (~(slot wa vel) 3 pec) From 3f9223094a76a0fc6bc125191faecee0395cab57 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 10 Jan 2018 16:09:40 -0800 Subject: [PATCH 095/184] add state adapter for %many refactoring --- sys/vane/clay.hoon | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index b79b86b28..5903787f7 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3243,7 +3243,7 @@ :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: =| :: instrument state - $: $1 :: vane version + $: $2 :: vane version ruf/raft :: revision tree == :: |= {now/@da eny/@ ski/sley} :: activate @@ -3449,32 +3449,38 @@ :: ++ load => |% - ++ cult-0 (map duct rove) - ++ dojo-0 (cork dojo |=(a/dojo a(qyx *cult-0))) - ++ rede-0 (cork rede |=(a/rede a(qyx *cult-0))) - ++ room-0 (cork room |=(a/room a(dos (~(run by dos.a) dojo-0)))) - ++ rung-0 (cork rung |=(a/rung a(rus (~(run by rus.a) rede-0)))) - ++ raft-0 + += rove-1 ?(rove [%many p=? q=case r=case s=path t=(map path lobe)]) + ++ cult-1 (jug rove-1 duct) + ++ dojo-1 (cork dojo |=(a/dojo a(qyx *cult-1))) + ++ rede-1 (cork rede |=(a/rede a(qyx *cult-1))) + ++ room-1 (cork room |=(a/room a(dos (~(run by dos.a) dojo-1)))) + ++ rung-1 (cork rung |=(a/rung a(rus (~(run by rus.a) rede-1)))) + ++ raft-1 %+ cork raft - |=(a/raft a(fat (~(run by fat.a) room-0), hoy (~(run by hoy.a) rung-0))) - ++ axle $%({$0 ruf/raft-0} {$1 ruf/raft}) + |=(a/raft a(fat (~(run by fat.a) room-1), hoy (~(run by hoy.a) rung-1))) + ++ axle $%({$1 ruf/raft-1} {$2 ruf/raft}) -- |= old/axle ^+ ..^$ ?- -.old - $1 ..^$(ruf ruf.old) - $0 =/ cul - |= a/cult-0 ^- cult - %- ~(gas ju *cult) - (turn ~(tap by a) |=({p/duct q/rove} [q p])) + $2 ..^$(ruf ruf.old) + $1 =/ rov + |= a/rove-1 ^- rove + ?+ a a + [%many @ [@ @] *] [%many p.a [q.a r.a s.a] t.a] + == + =/ cul + |= a/cult-1 ^- cult + %- ~(gas by *cult) + (turn ~(tap by a) |=({p/rove-1 q/(set duct)} [(rov p) q])) =/ rom - =+ doj=|=(a/dojo-0 a(qyx (cul qyx.a))) - |=(a/room-0 a(dos (~(run by dos.a) doj))) + =+ doj=|=(a/dojo-1 a(qyx (cul qyx.a))) + |=(a/room-1 a(dos (~(run by dos.a) doj))) =/ run - =+ red=|=(a/rede-0 a(qyx (cul qyx.a))) - |=(a/rung-0 a(rus (~(run by rus.a) red))) + =+ red=|=(a/rede-1 a(qyx (cul qyx.a))) + |=(a/rung-1 a(rus (~(run by rus.a) red))) =+ r=ruf.old - $(old [%1 r(fat (~(run by fat.r) rom), hoy (~(run by hoy.r) run))]) + $(old [%2 r(fat (~(run by fat.r) rom), hoy (~(run by hoy.r) run))]) == :: ++ scry :: inspect @@ -3498,7 +3504,7 @@ ?: ?=($& -.u.u.-) ``p.u.u.- ~ :: -++ stay [%1 ruf] +++ stay [%2 ruf] ++ take :: accept response |= {tea/wire hen/duct hin/(hypo sign)} ^+ [p=*(list move) q=..^$] From b2669ed2ed8b4a8fa1026afb22757583acc11add Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 15 Jan 2018 20:09:38 +0100 Subject: [PATCH 096/184] Add a %mult rave to the clay interface. Add a %wris gift to support its output. %mult acts like %next, except it watches multiple paths. If any of them change, it sends all changes to the watched files in a %wris. --- sys/vane/clay.hoon | 111 ++++++++++++++++++++++++++++++++++++++++++++- sys/zuse.hoon | 2 + 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 5903787f7..4e2a7e17d 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -270,9 +270,15 @@ :: Like a ++rave but with caches of current versions for %next and %many. :: Generally used when we store a request in our state somewhere. :: +++ cach (unit (each cage lobe)) :: cached result ++ rove :: stored request $% {$sing p/mood} :: single request {$next p/mood q/(unit (each cage lobe))} :: next version + $: $mult :: next version of any + p/care :: + q/(jug case spur) :: + r/(map case (map spur cach)) :: + == :: {$many p/? q/moat r/(map path lobe)} :: change range == :: :: @@ -318,6 +324,7 @@ {$note p/@tD q/tank} :: debug message {$ogre p/@tas} :: delete mount point {$writ p/riot} :: response + {$wris p/(set rant)} :: responses == :: ++ note :: out request $-> $% $: $a :: to %ames @@ -587,6 +594,16 @@ %f %exec our ~ [her syd q.mun] (lobe-to-silk:ze r.mun p.dat) == :: + ++ blas + |= {hen/duct das/(map mood (each cage lobe))} + ^+ +> + =- (emit hen %give %wris -) + %- ~(run in das) + |= {mun/mood dat/(each cage lobe)} + ~| %lobe-unsupported-tmp + ?> ?=($& -.dat) + [[p.mun q.mun syd] r.mun p.dat] + :: :: Give next step in a subscription. :: ++ bleb @@ -621,6 +638,7 @@ :: ++ blub-all (duct-lift |=({a/duct $~} (blub a))) :: lifted ++blub ++ blab-all (duct-lift blab) :: lifted ++blab + ++ blas-all (duct-lift blas) :: lifted ++blas ++ balk-all (duct-lift balk) :: lifted ++balk ++ bleb-all (duct-lift bleb) :: lifted ++bleb :: @@ -688,6 +706,25 @@ =(p.a p.rov(q q.p.a)) ?=(^ (case-to-aeon:ze q.p.a)) == + :: + $mult + =+ %+ roll ~(tap in q.rov) + |= {{c/case s/(set spur)} sus/(jug aeon spur) val/?} + ?. val [~ |] + =+ a=(case-to-aeon:ze c) + ?~ a [~ |] + [(~(put by sus) u.a s) &] + ?. val ~ + %+ skim ~(tap in ~(key by qyx)) + |= a=rove ^- ? + ?. ?=($mult -.a) | + ?. =(~(wyt by q.a) ~(wyt by q.rov)) | + =- val %- ~(rep in q.a) + |= {{c/case s/(set spur)} val/?} + ?. val | + =+ a=(case-to-aeon:ze c) + ?~ a | + =((~(get by sus) u.a) `s) :: $many ?~ (case-to-aeon:ze p.q.rov) ~ @@ -807,6 +844,30 @@ ?: (equivalent-data:ze u.u.ver u.u.var) $(yon +(yon)) (blab hen p.rav u.u.var) + :: + $mult + :: check to make sure that the request doesn't contain any historic or + :: foreign targets. + ?: %+ lien ~(tap by q.rav) + |= {c/case s/(set spur)} + =+ (case-to-aeon:ze c) + &(?=(^ -) (lth u.- let.dom)) + (blub hen) + :: considering targets in the past are invalid, always store request. + =- (duce -.rav p.rav q.rav -) + %- ~(gas by *(map case (map spur cach))) + %+ turn ~(tap by q.rav) + |= {c/case s/(set spur)} + ^- (pair case (map spur cach)) + :- c + =+ aey=(case-to-aeon:ze c) + ?~ aey ~ :: case in the future. + %- ~(gas by *(map spur cach)) + %+ turn ~(tap in s) + |= p/spur + =+ (aver p.rav c p) + ~| [%unexpected-async p.rav c p] + ?>(?=(^ -) [p u.-]) :: $many =+ nab=(case-to-aeon:ze p.q.rav) @@ -1622,6 +1683,9 @@ `p.q.p.rov :: $next ~ + :: + $mult ~ + :: $many %^ hunt lth ?. ?=($da -.p.q.rov) ~ @@ -1638,6 +1702,7 @@ ?- -.rov $sing rov $next [- p]:rov + $mult [- p q]:rov $many [- p q]:rov == :: @@ -1645,7 +1710,7 @@ :: ++ wake :: update subscribers ^+ . - =+ xiq=~(tap by qyx) + =+ xiq=~(tap by qyx) :: (list (pair rove (set duct))) =| xaq/(list {p/rove q/(set duct)}) |- ^+ ..wake ?~ xiq @@ -1693,6 +1758,50 @@ ?: (equivalent-data:ze u.q.p.i.xiq u.u.var) $(xiq t.xiq, xaq [i.xiq xaq]) $(xiq t.xiq, ..wake (blab-all q.i.xiq muc u.u.var)) + :: + $mult + =* rov p.i.xiq + =- ?^ res + $(xiq t.xiq, ..wake (blas-all q.i.xiq res)) + $(xiq t.xiq, xaq [i.xiq(r.p (~(uni by r.rov) cac)) xaq]) + %+ roll ~(tap by q.rov) + |= $: {cas/case sus/(set spur)} + cac/(map case (map spur cach)) + res/(map mood (each cage lobe)) + == + ^+ [cac res] + =+ hav=(~(got by r.rov) cas) + :: if we don't have an existing cache, try to build it. + ?~ hav + =- ?~ - [cac res] + [(~(put by cac) cas -) res] + =+ aey=(case-to-aeon:ze cas) + ?~ aey ~ :: case in the future. + %- ~(gas by *(map spur cach)) + %+ turn ~(tap in sus) + |= s/spur + ^- (pair spur cach) + =+ (aver p.rov [%ud let.dom] s) + ~| [%unexpected-async p.rov cas s] + ?>(?=(^ -) [s u.-]) + :: if we have an existing cache, compare it to current data. + :- cac + %- ~(gas by res) + %+ murn ~(tap in sus) + |= s/spur + ^- (unit (pair mood (each cage lobe))) + =+ o=(~(got by `(map spur cach)`hav) s) + =+ n=(aver p.rov [%ud let.dom] s) + ~| [%unexpected-async p.rov let.dom s] + ?> ?=(^ n) + =+ m=[p.rov [%ud let.dom] s] + ?~ o + ?~ u.n ~ :: not added + `[m u.u.n] :: added + ?~ u.n + `[m [%& %null [%atom %n ~] ~]] :: deleted + ?: (equivalent-data:ze u.u.n u.o) ~ :: unchanged + `[m u.u.n] :: changed :: $many =+ mot=`moat`q.p.i.xiq diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 71bdee364..c529e4890 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -391,6 +391,7 @@ {$ogre p/@tas} :: delete mount point {$send p/lane:ames q/@} :: transmit packet {$writ p/riot} :: response + {$wris p/(set rant)} :: responses == :: ++ task :: in request ->$ $% {$boat $~} :: pier rebooted @@ -488,6 +489,7 @@ ++ rave :: general request $% {$sing p/mood} :: single request {$next p/mood} :: await next version + {$mult p/care q/(jug case spur)} :: next version of any {$many p/? q/moat} :: track range == :: ++ riff {p/desk q/(unit rave)} :: request+desist From 307b86bb3bcac10f53825af72df98fb66a6a8179 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 15 Jan 2018 20:10:33 +0100 Subject: [PATCH 097/184] Clay state adapter. --- sys/vane/clay.hoon | 50 ++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 4e2a7e17d..1e06702d4 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3352,7 +3352,7 @@ :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: =| :: instrument state - $: $2 :: vane version + $: $3 :: vane version ruf/raft :: revision tree == :: |= {now/@da eny/@ ski/sley} :: activate @@ -3558,38 +3558,40 @@ :: ++ load => |% - += rove-1 ?(rove [%many p=? q=case r=case s=path t=(map path lobe)]) - ++ cult-1 (jug rove-1 duct) - ++ dojo-1 (cork dojo |=(a/dojo a(qyx *cult-1))) - ++ rede-1 (cork rede |=(a/rede a(qyx *cult-1))) - ++ room-1 (cork room |=(a/room a(dos (~(run by dos.a) dojo-1)))) - ++ rung-1 (cork rung |=(a/rung a(rus (~(run by rus.a) rede-1)))) - ++ raft-1 + += rove-2 + $% {$sing p/mood} + {$next p/mood q/(unit (each cage lobe))} + {$many p/? q/moat r/(map path lobe)} + == + ++ cult-2 (jug rove-2 duct) + ++ dojo-2 (cork dojo |=(a/dojo a(qyx *cult-2))) + ++ rede-2 (cork rede |=(a/rede a(qyx *cult-2))) + ++ room-2 (cork room |=(a/room a(dos (~(run by dos.a) dojo-2)))) + ++ rung-2 (cork rung |=(a/rung a(rus (~(run by rus.a) rede-2)))) + ++ raft-2 %+ cork raft - |=(a/raft a(fat (~(run by fat.a) room-1), hoy (~(run by hoy.a) rung-1))) - ++ axle $%({$1 ruf/raft-1} {$2 ruf/raft}) + |=(a/raft a(fat (~(run by fat.a) room-2), hoy (~(run by hoy.a) rung-2))) + ++ axle $%({$2 ruf/raft-2} {$3 ruf/raft}) -- |= old/axle ^+ ..^$ ?- -.old - $2 ..^$(ruf ruf.old) - $1 =/ rov - |= a/rove-1 ^- rove - ?+ a a - [%many @ [@ @] *] [%many p.a [q.a r.a s.a] t.a] - == + $3 ..^$(ruf ruf.old) + $2 =/ rov + |= a/rove-2 ^- rove + a =/ cul - |= a/cult-1 ^- cult + |= a/cult-2 ^- cult %- ~(gas by *cult) - (turn ~(tap by a) |=({p/rove-1 q/(set duct)} [(rov p) q])) + (turn ~(tap by a) |=({p/rove-2 q/(set duct)} [(rov p) q])) =/ rom - =+ doj=|=(a/dojo-1 a(qyx (cul qyx.a))) - |=(a/room-1 a(dos (~(run by dos.a) doj))) + =+ doj=|=(a/dojo-2 a(qyx (cul qyx.a))) + |=(a/room-2 a(dos (~(run by dos.a) doj))) =/ run - =+ red=|=(a/rede-1 a(qyx (cul qyx.a))) - |=(a/rung-1 a(rus (~(run by rus.a) red))) + =+ red=|=(a/rede-2 a(qyx (cul qyx.a))) + |=(a/rung-2 a(rus (~(run by rus.a) red))) =+ r=ruf.old - $(old [%2 r(fat (~(run by fat.r) rom), hoy (~(run by hoy.r) run))]) + $(old [%3 r(fat (~(run by fat.r) rom), hoy (~(run by hoy.r) run))]) == :: ++ scry :: inspect @@ -3613,7 +3615,7 @@ ?: ?=($& -.u.u.-) ``p.u.u.- ~ :: -++ stay [%2 ruf] +++ stay [%3 ruf] ++ take :: accept response |= {tea/wire hen/duct hin/(hypo sign)} ^+ [p=*(list move) q=..^$] From d4b0b408cf1ff23ec08ce949616cd0970d2fd5e5 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 15 Jan 2018 23:45:33 +0100 Subject: [PATCH 098/184] Fix %next to not cancel the subscription if the watched file doesn't yet exist. Instead, register file creation as a change. --- sys/vane/clay.hoon | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 1e06702d4..b3dfdddac 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -273,7 +273,7 @@ ++ cach (unit (each cage lobe)) :: cached result ++ rove :: stored request $% {$sing p/mood} :: single request - {$next p/mood q/(unit (each cage lobe))} :: next version + {$next p/mood q/(unit cach)} :: next version $: $mult :: next version of any p/care :: q/(jug case spur) :: @@ -827,14 +827,11 @@ :: $next =+ ver=(aver p.rav) - ?~ ver - (duce [- p ~]:rav) - ?~ u.ver - (blub hen) + ?. ?=({$~ $~ *} ver) (duce -.rav p.rav ver) =+ yon=+((need (case-to-aeon:ze q.p.rav))) |- ^+ +>.^$ ?: (gth yon let.dom) - (duce -.rav p.rav u.ver) + (duce -.rav p.rav ver) =+ var=(aver p.rav(q [%ud yon])) ?~ var ~& [%oh-no rave=rav aeon=yon letdom=let.dom] @@ -1740,24 +1737,29 @@ :: $next =* mun p.p.i.xiq - :: =* dat q.p.i.xiq XX can't fuse right now - ?~ q.p.i.xiq + =* dat q.p.i.xiq + =; nex/(each _..wake _xaq) + ?: ?=($& -.nex) + $(xiq t.xiq, ..wake p.nex) + $(xiq t.xiq, xaq p.nex) + ?~ dat + :- %| =+ ver=(aver mun) - ?~ ver - $(xiq t.xiq, xaq [i.xiq xaq]) - ?~ u.ver - $(xiq t.xiq, ..wake (blub-all q.i.xiq ~)) - $(xiq t.xiq, xaq [i.xiq(q.p u.ver) xaq]) - =/ muc mun(q [%ud let.dom]) :: current mood + ?~ ver [i.xiq xaq] + [i.xiq(q.p ver) xaq] + =/ muc mun(q [%ud let.dom]) =+ var=(aver muc) ?~ var ~& [%oh-noes old=mun mood=muc letdom=let.dom] - $(xiq t.xiq) + |+xaq + ?~ u.dat + ?~ u.var |+[i.xiq xaq] :: not added + &+(blab-all q.i.xiq muc u.u.var) :: added ?~ u.var - $(xiq t.xiq, ..wake (blab-all q.i.xiq muc %& %null [%atom %n ~] ~)) - ?: (equivalent-data:ze u.q.p.i.xiq u.u.var) - $(xiq t.xiq, xaq [i.xiq xaq]) - $(xiq t.xiq, ..wake (blab-all q.i.xiq muc u.u.var)) + &+(blab-all q.i.xiq muc %& %null [%atom %n ~] ~):: deleted + ?: (equivalent-data:ze u.u.dat u.u.var) + |+[i.xiq xaq] :: unchanged + &+(blab-all q.i.xiq muc u.u.var) :: changed :: $mult =* rov p.i.xiq @@ -3579,7 +3581,11 @@ $3 ..^$(ruf ruf.old) $2 =/ rov |= a/rove-2 ^- rove - a + ?+ -.a a + $next + ?~ q.a a + a(q `q.a) + == =/ cul |= a/cult-2 ^- cult %- ~(gas by *cult) From d2cc5a5658edcb50135058f11e4c596530838e76 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 17 Jan 2018 00:20:34 +0100 Subject: [PATCH 099/184] Fixed weird code for updating /circles subscriptions. No longer incorrectly uses the subscriber's ship name when getting the affected story. --- app/hall.hoon | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 7750b17de..2f89c5c99 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2323,17 +2323,25 @@ ::REVIEW this could be considered leaky, since it :: doesn't check if {who} ever knew of {nom}, :: but does that matter? can't really check.. + :: if the story got deleted, remove it from the circles listing. ?: ?=($remove -.det.det) `| - =+ soy=(~(got by stories) who.qer) - ?. ?| ?=($new -.det.det) - ?& ?=($config -.det.det) - ?=($permit -.dif.det.det) - ?=(?($channel $village) sec.con.shape.soy) - (~(has in sis.dif.det.det) who.qer) - == + =+ soy=(~(got by stories) nom.det) + :: if the story got created, or something about the read permissions set + :: for the subscriber changed, update the circles listing. + =; dif/? + ?. dif ~ + =+ (~(so-visible so:ta nom.det ~ soy) who.qer) + :: if the story just got created, don't send a remove rumor, because it + :: never showed up in the first place. + ?:(?=($new -.det.det) ?:(- `- ~) `-) + ?| ?=($new -.det.det) + :: + ?& ?=($config -.det.det) + ?=($permit -.dif.det.det) + ?=(?($channel $village) sec.con.shape.soy) + (~(has in sis.dif.det.det) who.qer) == - ~ - `(~(so-visible so:ta nom.det ~ soy) who.qer) + == :: $public ?. ?=($public -.det) ~ From 9f2d841b248f45d7b6083deef8b9d522e9bac6de Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 17 Jan 2018 14:30:50 +0100 Subject: [PATCH 100/184] Always show all circles to their owner. Even if they banned themselves. --- app/hall.hoon | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 2f89c5c99..af486f93f 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2330,10 +2330,12 @@ :: for the subscriber changed, update the circles listing. =; dif/? ?. dif ~ - =+ (~(so-visible so:ta nom.det ~ soy) who.qer) :: if the story just got created, don't send a remove rumor, because it :: never showed up in the first place. - ?:(?=($new -.det.det) ?:(- `- ~) `-) + =- ?:(&(?=($new -.det.det) !-) ~ `-) + ?| (team:title our.bol who.qer) + (~(so-visible so:ta nom.det ~ soy) who.qer) + == ?| ?=($new -.det.det) :: ?& ?=($config -.det.det) From 0d1b98852ea356d52fd0a00635eb7c6dbbe20592 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 17 Jan 2018 15:57:25 +0100 Subject: [PATCH 101/184] Comments and cleanup based on feedback. --- sys/vane/clay.hoon | 71 +++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index b3dfdddac..2be8586ab 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -825,8 +825,12 @@ (blub hen) (blab hen p.rav u.u.ver) :: + :: for %next, get the data at the specified case, then go forward in time + :: until we find a change. if we find no change, store request for later. $next =+ ver=(aver p.rav) + :: if we know nothing, or we know the file doesn't exist right now, + :: store the request for later answering. ?. ?=({$~ $~ *} ver) (duce -.rav p.rav ver) =+ yon=+((need (case-to-aeon:ze q.p.rav))) |- ^+ +>.^$ @@ -1707,7 +1711,7 @@ :: ++ wake :: update subscribers ^+ . - =+ xiq=~(tap by qyx) :: (list (pair rove (set duct))) + =+ xiq=~(tap by qyx) =| xaq/(list {p/rove q/(set duct)}) |- ^+ ..wake ?~ xiq @@ -1737,29 +1741,30 @@ :: $next =* mun p.p.i.xiq - =* dat q.p.i.xiq + =* old q.p.i.xiq + :: we either update the state (to include a response to send), + :: or add the request back into the waiting list. =; nex/(each _..wake _xaq) ?: ?=($& -.nex) $(xiq t.xiq, ..wake p.nex) $(xiq t.xiq, xaq p.nex) - ?~ dat - :- %| - =+ ver=(aver mun) - ?~ ver [i.xiq xaq] - [i.xiq(q.p ver) xaq] - =/ muc mun(q [%ud let.dom]) - =+ var=(aver muc) - ?~ var - ~& [%oh-noes old=mun mood=muc letdom=let.dom] + :: if we don't have an existing cache of the old version, + :: try to get it now. + ?~ old + |+[i.xiq(q.p (aver mun)) xaq] + =/ mod mun(q [%ud let.dom]) + =+ new=(aver mod) + ?~ new + ~& [%oh-noes old=mun mood=mod letdom=let.dom] |+xaq - ?~ u.dat - ?~ u.var |+[i.xiq xaq] :: not added - &+(blab-all q.i.xiq muc u.u.var) :: added - ?~ u.var - &+(blab-all q.i.xiq muc %& %null [%atom %n ~] ~):: deleted - ?: (equivalent-data:ze u.u.dat u.u.var) + ?~ u.old + ?~ u.new |+[i.xiq xaq] :: not added + &+(blab-all q.i.xiq mod u.u.new) :: added + ?~ u.new + &+(blab-all q.i.xiq mod %& %null [%atom %n ~] ~):: deleted + ?: (equivalent-data:ze u.u.old u.u.new) |+[i.xiq xaq] :: unchanged - &+(blab-all q.i.xiq muc u.u.var) :: changed + &+(blab-all q.i.xiq mod u.u.new) :: changed :: $mult =* rov p.i.xiq @@ -1772,9 +1777,9 @@ res/(map mood (each cage lobe)) == ^+ [cac res] - =+ hav=(~(got by r.rov) cas) + =+ ole=(~(got by r.rov) cas) :: if we don't have an existing cache, try to build it. - ?~ hav + ?~ ole =- ?~ - [cac res] [(~(put by cac) cas -) res] =+ aey=(case-to-aeon:ze cas) @@ -1790,20 +1795,20 @@ :- cac %- ~(gas by res) %+ murn ~(tap in sus) - |= s/spur + |= sup/spur ^- (unit (pair mood (each cage lobe))) - =+ o=(~(got by `(map spur cach)`hav) s) - =+ n=(aver p.rov [%ud let.dom] s) - ~| [%unexpected-async p.rov let.dom s] - ?> ?=(^ n) - =+ m=[p.rov [%ud let.dom] s] - ?~ o - ?~ u.n ~ :: not added - `[m u.u.n] :: added - ?~ u.n - `[m [%& %null [%atom %n ~] ~]] :: deleted - ?: (equivalent-data:ze u.u.n u.o) ~ :: unchanged - `[m u.u.n] :: changed + =+ old=(~(got by `(map spur cach)`ole) sup) + =+ new=(aver p.rov [%ud let.dom] sup) + ~| [%unexpected-async p.rov let.dom sup] + ?> ?=(^ new) + =+ mod=[p.rov [%ud let.dom] sup] + ?~ old + ?~ u.new ~ :: not added + `[mod u.u.new] :: added + ?~ u.new + `[mod [%& %null [%atom %n ~] ~]] :: deleted + ?: (equivalent-data:ze u.u.new u.old) ~ :: unchanged + `[mod u.u.new] :: changed :: $many =+ mot=`moat`q.p.i.xiq From 5840c496c76d655d6edd6fe3e825575bfd16dee4 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 17 Jan 2018 16:49:16 +0100 Subject: [PATCH 102/184] Fixed the ++start-request for next to properly take non-existing files into account when checking through older versions. --- sys/vane/clay.hoon | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 2be8586ab..eb953b5be 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -828,23 +828,25 @@ :: for %next, get the data at the specified case, then go forward in time :: until we find a change. if we find no change, store request for later. $next - =+ ver=(aver p.rav) - :: if we know nothing, or we know the file doesn't exist right now, - :: store the request for later answering. - ?. ?=({$~ $~ *} ver) (duce -.rav p.rav ver) + =+ old=(aver p.rav) + :: if we know nothing now, store the request for later answering. + ?: ?=($~ old) (duce -.rav p.rav old) =+ yon=+((need (case-to-aeon:ze q.p.rav))) |- ^+ +>.^$ ?: (gth yon let.dom) - (duce -.rav p.rav ver) - =+ var=(aver p.rav(q [%ud yon])) - ?~ var + (duce -.rav p.rav old) + =+ new=(aver p.rav(q [%ud yon])) + ?~ new ~& [%oh-no rave=rav aeon=yon letdom=let.dom] +>.^$ - ?~ u.var - (blab hen p.rav %& %null [%atom %n ~] ~) :: only her %x - ?: (equivalent-data:ze u.u.ver u.u.var) - $(yon +(yon)) - (blab hen p.rav u.u.var) + ?~ u.old + ?~ u.new $(yon +(yon)) :: not added + (blab hen p.rav u.u.new) :: added + ?~ u.new + (blab hen p.rav %& %null [%atom %n ~] ~) :: removed, only her %x + ?: (equivalent-data:ze u.u.old u.u.new) + $(yon +(yon)) :: unchanged + (blab hen p.rav u.u.new) :: changed :: $mult :: check to make sure that the request doesn't contain any historic or From 70ad73e8ba2644dfc440cbe5a811cfd64ae1d155 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 17 Jan 2018 23:55:12 +0100 Subject: [PATCH 103/184] Modified %mult to support past revisions, but with only a single case for all files. --- sys/vane/clay.hoon | 197 +++++++++++++++++++++++++++------------------ sys/zuse.hoon | 3 +- 2 files changed, 120 insertions(+), 80 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index eb953b5be..46b430f92 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -275,10 +275,11 @@ $% {$sing p/mood} :: single request {$next p/mood q/(unit cach)} :: next version $: $mult :: next version of any - p/care :: - q/(jug case spur) :: - r/(map case (map spur cach)) :: - == :: + p/mool :: original request + q/(unit aeon) :: checking for change + r/(map spur (unit cach)) :: old version + s/(map spur (unit cach)) :: new version + == {$many p/? q/moat r/(map path lobe)} :: change range == :: :: @@ -708,23 +709,13 @@ == :: $mult - =+ %+ roll ~(tap in q.rov) - |= {{c/case s/(set spur)} sus/(jug aeon spur) val/?} - ?. val [~ |] - =+ a=(case-to-aeon:ze c) - ?~ a [~ |] - [(~(put by sus) u.a s) &] - ?. val ~ + ?~ (case-to-aeon:ze q.p.rov) ~ %+ skim ~(tap in ~(key by qyx)) |= a=rove ^- ? - ?. ?=($mult -.a) | - ?. =(~(wyt by q.a) ~(wyt by q.rov)) | - =- val %- ~(rep in q.a) - |= {{c/case s/(set spur)} val/?} - ?. val | - =+ a=(case-to-aeon:ze c) - ?~ a | - =((~(get by sus) u.a) `s) + ?& ?=($mult -.a) + =(p.a p.rov(q q.p.a)) + ?=(^ (case-to-aeon:ze q.p.a)) + == :: $many ?~ (case-to-aeon:ze p.q.rov) ~ @@ -849,28 +840,51 @@ (blab hen p.rav u.u.new) :: changed :: $mult - :: check to make sure that the request doesn't contain any historic or - :: foreign targets. - ?: %+ lien ~(tap by q.rav) - |= {c/case s/(set spur)} - =+ (case-to-aeon:ze c) - &(?=(^ -) (lth u.- let.dom)) - (blub hen) - :: considering targets in the past are invalid, always store request. - =- (duce -.rav p.rav q.rav -) - %- ~(gas by *(map case (map spur cach))) - %+ turn ~(tap by q.rav) - |= {c/case s/(set spur)} - ^- (pair case (map spur cach)) - :- c - =+ aey=(case-to-aeon:ze c) - ?~ aey ~ :: case in the future. - %- ~(gas by *(map spur cach)) - %+ turn ~(tap in s) - |= p/spur - =+ (aver p.rav c p) - ~| [%unexpected-async p.rav c p] - ?>(?=(^ -) [p u.-]) + =+ aey=(case-to-aeon:ze q.p.rav) + :: if the requested case is in the future, we can't know anything yet. + ?~ aey (duce -.rav p.rav ~ ~ ~) + =/ old + %- ~(gas by *(map spur (unit cach))) + %+ turn ~(tap by r.p.rav) + |= s/spur + ^- (pair spur (unit cach)) + [s (aver p.p.rav q.p.rav s)] + =+ hav=|=({s/spur c/(unit cach)} ?=(^ c)) + =+ yon=+((need (case-to-aeon:ze q.p.rav))) + |- ^+ +>.^$ + :: if we're need future revisions to look for change, wait. + ?: (gth yon let.dom) + (duce -.rav p.rav `yon old ~) + =/ new + %- ~(gas by *(map spur (unit cach))) + %+ turn ~(tap by r.p.rav) + |= s/spur + ^- (pair spur (unit cach)) + [s (aver p.p.rav q.p.rav s)] + :: if we don't know everything now, store the request for later. + ?. &((levy ~(tap by old) hav) (levy ~(tap by new) hav)) + (duce -.rav p.rav `yon old new) + :: if we do know everything now, compare old and new. + :: if there are differences, send response. if not, try next aeon. + =; res + ?~ res $(old new, yon +(yon)) + (blas hen res) + %+ roll ~(tap by old) + |= $: {sup/spur ole/(unit cach)} + res/(map mood (each cage lobe)) + == + =+ neu=(~(got by new) sup) + ?< |(?=($~ ole) ?=($~ neu)) + =- ?~(- res (~(put by res) u.-)) + ^- (unit (pair mood (each cage lobe))) + =+ mod=[p.p.rav [%ud yon] sup] + ?~ u.ole + ?~ u.neu ~ :: not added + `[mod u.u.neu] :: added + ?~ u.neu + `[mod [%& %null [%atom %n ~] ~]] :: deleted + ?: (equivalent-data:ze u.u.neu u.u.ole) ~ :: unchanged + `[mod u.u.neu] :: changed :: $many =+ nab=(case-to-aeon:ze p.q.rav) @@ -1705,7 +1719,7 @@ ?- -.rov $sing rov $next [- p]:rov - $mult [- p q]:rov + $mult [- p]:rov $many [- p q]:rov == :: @@ -1769,48 +1783,73 @@ &+(blab-all q.i.xiq mod u.u.new) :: changed :: $mult + :: because %mult requests need to wait on multiple files for each + :: revision that needs to be checked for changes, we keep two cache maps. + :: {old} is the revision at {(dec yon)}, {new} is the revision at {yon}. + :: if we have no {yon} yet, that means it was still unknown last time + :: we checked. =* rov p.i.xiq - =- ?^ res - $(xiq t.xiq, ..wake (blas-all q.i.xiq res)) - $(xiq t.xiq, xaq [i.xiq(r.p (~(uni by r.rov) cac)) xaq]) - %+ roll ~(tap by q.rov) - |= $: {cas/case sus/(set spur)} - cac/(map case (map spur cach)) + =* mol p.rov + =* yon q.rov + =* old r.rov + =* new s.rov + :: we will either respond, or store the maybe updated request. + =; res/(each (map mood (each cage lobe)) rove) + ?: ?=($& -.res) + $(xiq t.xiq, ..wake (blas-all q.i.xiq p.res)) + $(xiq t.xiq, xaq [i.xiq(p p.res) xaq]) + |- :: so that we can retry for the next aeon if possible/needed. + :: if we don't have an aeon yet, see if we have one now. + ?~ yon + =+ aey=(case-to-aeon:ze q.mol) + :: if we still don't, wait. + ?~ aey |+rov + :: if we do, update the request and retry. + $(rov [-.rov mol `+(u.aey) ~ ~]) + =+ hav=|=({s/spur c/(unit cach)} ?=(^ c)) + :: create a gate that tries to fill the unknown data into a cache map. + =/ fill + =/ d :: for easier iteraton. + %- ~(gas by *(map spur (unit cach))) + (turn ~(tap in r.mol) |=(s/spur [s ~])) + |= {m/(map spur (unit cach)) c/case} + %- ~(urn by ?~(m d m)) + |= {s/spur o/(unit cach)} + ?^(o o (aver p.mol c s)) + :: if old isn't complete, try fillin in the gaps. + =? old |(?=($~ old) !(levy ~(tap by `(map spur (unit cach))`old) hav)) + (fill old [%ud (dec u.yon)]) + :: if the next aeon we want to compare is in the future, wait again. + =+ aey=(case-to-aeon:ze [%ud u.yon]) + ?~ aey |+rov + :: if new isn't complete, try filling in the gaps. + =? new |(?=($~ new) !(levy ~(tap by `(map spur (unit cach))`new) hav)) + (fill new [%ud u.yon]) + :: if they're still not both complete, wait again. + ?. ?& (levy ~(tap by old) hav) + (levy ~(tap by new) hav) + == + |+rov + :: if there are any changes, send response. if none, move onto next aeon. + =; res + ?^ res &+res + $(rov [-.rov mol `+(u.yon) new ~]) + %+ roll ~(tap by old) + |= $: {sup/spur ole/(unit cach)} res/(map mood (each cage lobe)) == - ^+ [cac res] - =+ ole=(~(got by r.rov) cas) - :: if we don't have an existing cache, try to build it. - ?~ ole - =- ?~ - [cac res] - [(~(put by cac) cas -) res] - =+ aey=(case-to-aeon:ze cas) - ?~ aey ~ :: case in the future. - %- ~(gas by *(map spur cach)) - %+ turn ~(tap in sus) - |= s/spur - ^- (pair spur cach) - =+ (aver p.rov [%ud let.dom] s) - ~| [%unexpected-async p.rov cas s] - ?>(?=(^ -) [s u.-]) - :: if we have an existing cache, compare it to current data. - :- cac - %- ~(gas by res) - %+ murn ~(tap in sus) - |= sup/spur + =+ neu=(~(got by new) sup) + ?< |(?=($~ ole) ?=($~ neu)) + =- ?~(- res (~(put by res) u.-)) ^- (unit (pair mood (each cage lobe))) - =+ old=(~(got by `(map spur cach)`ole) sup) - =+ new=(aver p.rov [%ud let.dom] sup) - ~| [%unexpected-async p.rov let.dom sup] - ?> ?=(^ new) - =+ mod=[p.rov [%ud let.dom] sup] - ?~ old - ?~ u.new ~ :: not added - `[mod u.u.new] :: added - ?~ u.new + =+ mod=[p.mol [%ud u.yon] sup] + ?~ u.ole + ?~ u.neu ~ :: not added + `[mod u.u.neu] :: added + ?~ u.neu `[mod [%& %null [%atom %n ~] ~]] :: deleted - ?: (equivalent-data:ze u.u.new u.old) ~ :: unchanged - `[mod u.u.new] :: changed + ?: (equivalent-data:ze u.u.neu u.u.ole) ~ :: unchanged + `[mod u.u.neu] :: changed :: $many =+ mot=`moat`q.p.i.xiq diff --git a/sys/zuse.hoon b/sys/zuse.hoon index c529e4890..7fe68c676 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -467,6 +467,7 @@ ++ moat {p/case q/case r/path} :: change range ++ mode (list {path (unit mime)}) :: external files ++ mood {p/care q/case r/path} :: request in desk + ++ mool {p/care q/case r/(set spur)} :: requests in desk ++ nori :: repository action $% {$& p/soba} :: delta {$| p/@tas} :: label @@ -489,7 +490,7 @@ ++ rave :: general request $% {$sing p/mood} :: single request {$next p/mood} :: await next version - {$mult p/care q/(jug case spur)} :: next version of any + {$mult p/mool} :: next version of any {$many p/? q/moat} :: track range == :: ++ riff {p/desk q/(unit rave)} :: request+desist From 4671526a3e654ea217c34c9b6d2ef0cdda4a5999 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 18 Jan 2018 01:23:31 +0100 Subject: [PATCH 104/184] Make use of alias types more consistent. --- sys/vane/clay.hoon | 62 +++++++++++++++++++++++----------------------- sys/zuse.hoon | 4 +-- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 46b430f92..8f7c09d9e 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -277,8 +277,8 @@ $: $mult :: next version of any p/mool :: original request q/(unit aeon) :: checking for change - r/(map spur (unit cach)) :: old version - s/(map spur (unit cach)) :: new version + r/(map path (unit cach)) :: old version + s/(map path (unit cach)) :: new version == {$many p/? q/moat r/(map path lobe)} :: change range == :: @@ -844,23 +844,23 @@ :: if the requested case is in the future, we can't know anything yet. ?~ aey (duce -.rav p.rav ~ ~ ~) =/ old - %- ~(gas by *(map spur (unit cach))) + %- ~(gas by *(map path (unit cach))) %+ turn ~(tap by r.p.rav) - |= s/spur - ^- (pair spur (unit cach)) - [s (aver p.p.rav q.p.rav s)] - =+ hav=|=({s/spur c/(unit cach)} ?=(^ c)) + |= p/path + ^- (pair path (unit cach)) + [p (aver p.p.rav q.p.rav p)] + =+ hav=|=({p/path c/(unit cach)} ?=(^ c)) =+ yon=+((need (case-to-aeon:ze q.p.rav))) |- ^+ +>.^$ :: if we're need future revisions to look for change, wait. ?: (gth yon let.dom) (duce -.rav p.rav `yon old ~) =/ new - %- ~(gas by *(map spur (unit cach))) + %- ~(gas by *(map path (unit cach))) %+ turn ~(tap by r.p.rav) - |= s/spur - ^- (pair spur (unit cach)) - [s (aver p.p.rav q.p.rav s)] + |= p/path + ^- (pair path (unit cach)) + [p (aver p.p.rav q.p.rav p)] :: if we don't know everything now, store the request for later. ?. &((levy ~(tap by old) hav) (levy ~(tap by new) hav)) (duce -.rav p.rav `yon old new) @@ -870,14 +870,14 @@ ?~ res $(old new, yon +(yon)) (blas hen res) %+ roll ~(tap by old) - |= $: {sup/spur ole/(unit cach)} + |= $: {pax/path ole/(unit cach)} res/(map mood (each cage lobe)) == - =+ neu=(~(got by new) sup) + =+ neu=(~(got by new) pax) ?< |(?=($~ ole) ?=($~ neu)) =- ?~(- res (~(put by res) u.-)) ^- (unit (pair mood (each cage lobe))) - =+ mod=[p.p.rav [%ud yon] sup] + =+ mod=[p.p.rav [%ud yon] pax] ?~ u.ole ?~ u.neu ~ :: not added `[mod u.u.neu] :: added @@ -1758,29 +1758,29 @@ $next =* mun p.p.i.xiq =* old q.p.i.xiq + =/ mod mun(q [%ud let.dom]) :: we either update the state (to include a response to send), :: or add the request back into the waiting list. - =; nex/(each _..wake _xaq) + =; nex/(each (each lobe cage) _xaq) ?: ?=($& -.nex) - $(xiq t.xiq, ..wake p.nex) + $(xiq t.xiq, ..wake (blab-all q.i.xiq mod p.nex)) $(xiq t.xiq, xaq p.nex) :: if we don't have an existing cache of the old version, :: try to get it now. ?~ old |+[i.xiq(q.p (aver mun)) xaq] - =/ mod mun(q [%ud let.dom]) =+ new=(aver mod) ?~ new ~& [%oh-noes old=mun mood=mod letdom=let.dom] |+xaq ?~ u.old ?~ u.new |+[i.xiq xaq] :: not added - &+(blab-all q.i.xiq mod u.u.new) :: added + &+u.u.new :: added ?~ u.new - &+(blab-all q.i.xiq mod %& %null [%atom %n ~] ~):: deleted + &+[%& %null [%atom %n ~] ~] :: deleted ?: (equivalent-data:ze u.u.old u.u.new) |+[i.xiq xaq] :: unchanged - &+(blab-all q.i.xiq mod u.u.new) :: changed + &+u.u.new :: changed :: $mult :: because %mult requests need to wait on multiple files for each @@ -1806,24 +1806,24 @@ ?~ aey |+rov :: if we do, update the request and retry. $(rov [-.rov mol `+(u.aey) ~ ~]) - =+ hav=|=({s/spur c/(unit cach)} ?=(^ c)) + =+ hav=|=({p/path c/(unit cach)} ?=(^ c)) :: create a gate that tries to fill the unknown data into a cache map. =/ fill =/ d :: for easier iteraton. - %- ~(gas by *(map spur (unit cach))) - (turn ~(tap in r.mol) |=(s/spur [s ~])) - |= {m/(map spur (unit cach)) c/case} + %- ~(gas by *(map path (unit cach))) + (turn ~(tap in r.mol) |=(p/path [p ~])) + |= {m/(map path (unit cach)) c/case} %- ~(urn by ?~(m d m)) - |= {s/spur o/(unit cach)} - ?^(o o (aver p.mol c s)) + |= {p/path o/(unit cach)} + ?^(o o (aver p.mol c p)) :: if old isn't complete, try fillin in the gaps. - =? old |(?=($~ old) !(levy ~(tap by `(map spur (unit cach))`old) hav)) + =? old |(?=($~ old) !(levy ~(tap by `(map path (unit cach))`old) hav)) (fill old [%ud (dec u.yon)]) :: if the next aeon we want to compare is in the future, wait again. =+ aey=(case-to-aeon:ze [%ud u.yon]) ?~ aey |+rov :: if new isn't complete, try filling in the gaps. - =? new |(?=($~ new) !(levy ~(tap by `(map spur (unit cach))`new) hav)) + =? new |(?=($~ new) !(levy ~(tap by `(map path (unit cach))`new) hav)) (fill new [%ud u.yon]) :: if they're still not both complete, wait again. ?. ?& (levy ~(tap by old) hav) @@ -1835,14 +1835,14 @@ ?^ res &+res $(rov [-.rov mol `+(u.yon) new ~]) %+ roll ~(tap by old) - |= $: {sup/spur ole/(unit cach)} + |= $: {pax/path ole/(unit cach)} res/(map mood (each cage lobe)) == - =+ neu=(~(got by new) sup) + =+ neu=(~(got by new) pax) ?< |(?=($~ ole) ?=($~ neu)) =- ?~(- res (~(put by res) u.-)) ^- (unit (pair mood (each cage lobe))) - =+ mod=[p.mol [%ud u.yon] sup] + =+ mod=[p.mol [%ud u.yon] pax] ?~ u.ole ?~ u.neu ~ :: not added `[mod u.u.neu] :: added diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 7fe68c676..881bbf8ba 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -467,7 +467,7 @@ ++ moat {p/case q/case r/path} :: change range ++ mode (list {path (unit mime)}) :: external files ++ mood {p/care q/case r/path} :: request in desk - ++ mool {p/care q/case r/(set spur)} :: requests in desk + ++ mool {p/care q/case r/(set path)} :: requests in desk ++ nori :: repository action $% {$& p/soba} :: delta {$| p/@tas} :: label @@ -483,7 +483,7 @@ lat/(map lobe blob) :: data == :: ++ rant :: response to request - $: p/{p/care q/case r/@tas} :: clade release book + $: p/{p/care q/case r/desk} :: clade release book q/path :: spur r/cage :: data == :: From e2b056eff9be5d8c5a1947dc354f36ae5dd28886 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 18 Jan 2018 01:25:58 +0100 Subject: [PATCH 105/184] Rewrite ++dedupe to roll instead of skim, and fix issue where it wasn't accounting for different cases correctly. ie, it wasn't making sure that the found case was *actually* before the new request's case. --- sys/vane/clay.hoon | 66 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 8f7c09d9e..18bf3d127 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -696,35 +696,61 @@ :: ++ dedupe :: find existing alias |= rov/rove ^- rove - =; ros/(list rove) ?+(ros rov {^ $~} i.ros) + =; ron/(unit rove) (fall ron rov) ?- -.rov $sing ~ $next - ?~ (case-to-aeon:ze q.p.rov) ~ - %+ skim ~(tap in ~(key by qyx)) - |= a=rove ^- ? - ?& ?=($next -.a) - =(p.a p.rov(q q.p.a)) - ?=(^ (case-to-aeon:ze q.p.a)) + =+ aey=(case-to-aeon:ze q.p.rov) + ?~ aey ~ + %+ roll ~(tap in ~(key by qyx)) + |= {hav/rove res/(unit rove)} + ?^ res res + =- ?:(- `hav ~) + ?& ?=($next -.hav) + =(p.hav p.rov(q q.p.hav)) + :: + :: only a match if this request is before + :: or at our starting case. + =+ hay=(case-to-aeon:ze q.p.hav) + ?~(hay | (lte u.hay u.aey)) == :: $mult - ?~ (case-to-aeon:ze q.p.rov) ~ - %+ skim ~(tap in ~(key by qyx)) - |= a=rove ^- ? - ?& ?=($mult -.a) - =(p.a p.rov(q q.p.a)) - ?=(^ (case-to-aeon:ze q.p.a)) + =+ aey=(case-to-aeon:ze q.p.rov) + ?~ aey ~ + %+ roll ~(tap in ~(key by qyx)) + |= {hav/rove res/(unit rove)} + ?^ res res + =- ?:(- `hav ~) + ?& ?=($mult -.hav) + =(p.hav p.rov(q q.p.hav)) + :: + :: only a match if this request is before + :: or at our starting case, and it has been + :: tested at least that far. + =+ hay=(case-to-aeon:ze q.p.hav) + ?& ?=(^ hay) + (lte u.hay u.aey) + ?=(^ q.hav) + (gte u.q.hav u.aey) + == == :: $many - ?~ (case-to-aeon:ze p.q.rov) ~ - %+ skim ~(tap in ~(key by qyx)) - |= a=rove ^- ? - ?& ?=($many -.a) - =(a rov(p.q p.q.a)) - ?=(^ (case-to-aeon:ze p.q.a)) - == + =+ aey=(case-to-aeon:ze p.q.rov) + ?~ aey ~ + %+ roll ~(tap in ~(key by qyx)) + |= {hav/rove res/(unit rove)} + ?^ res res + =- ?:(- `hav ~) + ?& ?=($many -.hav) + =(hav rov(p.q p.q.hav)) + :: + :: only a match if this request is before + :: or at our starting case. + =+ hay=(case-to-aeon:ze p.q.hav) + ?~(hay | (lte u.hay u.aey)) + == == :: :: Takes a list of changed paths and finds those paths that are inside a From 5bb364636dc8a818a92c57ef555301cb5d785f87 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 18 Jan 2018 01:54:24 +0100 Subject: [PATCH 106/184] Fix an oopsie that was part of a change "lightly refactor ++wake %next" that accidentally made it into 4671526a. --- sys/vane/clay.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 18bf3d127..dac4034d9 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -1787,7 +1787,7 @@ =/ mod mun(q [%ud let.dom]) :: we either update the state (to include a response to send), :: or add the request back into the waiting list. - =; nex/(each (each lobe cage) _xaq) + =; nex/(each (each cage lobe) _xaq) ?: ?=($& -.nex) $(xiq t.xiq, ..wake (blab-all q.i.xiq mod p.nex)) $(xiq t.xiq, xaq p.nex) From 6f2160589d4e894e5c1237d3504b23b9f66f2534 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 18 Jan 2018 15:37:18 +0100 Subject: [PATCH 107/184] Updates webtalk. See urbit/talk#47. --- web/talk/main.css | 22 +++++++++++----------- web/talk/main.js | 5 +++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/web/talk/main.css b/web/talk/main.css index 3366239f2..13eed6635 100644 --- a/web/talk/main.css +++ b/web/talk/main.css @@ -79,6 +79,17 @@ div.gram.same:hover div.meta { position: absolute; z-index: 1; margin-left: 1.875rem; } + .speech .fat { + max-height: 0; + transition: max-height .1s ease-in-out; + overflow: hidden; } + .speech .fat pre { + color: #fff; } + .speech:hover .fat { + max-height: 16rem; + overflow: scroll; + background-color: #000; + color: #fff; } .exp { font-family: 'scp'; @@ -90,17 +101,6 @@ div.gram.same:hover div.meta { color: #fff; background-color: #000; padding: .3rem; } - .exp .fat { - max-height: 0; - transition: max-height .1s ease-in-out; - overflow: hidden; } - .exp .fat pre { - color: #fff; } - .exp:hover .fat { - max-height: 16rem; - overflow: scroll; - background-color: #000; - color: #fff; } .comment .speech a.btn { background-color: transparent; diff --git a/web/talk/main.js b/web/talk/main.js index 256beac4b..47a8a8b2a 100644 --- a/web/talk/main.js +++ b/web/talk/main.js @@ -866,7 +866,7 @@ module.exports = recl({ return indexOf.call(src, s) < 0 && indexOf.call(s, "/") >= 0 && s[0] === "~" && s.length >= 5; }, onKeyUp: function(e) { - var $input, v; + var $input, d, v; $('.menu.depth-1 .add').removeClass('valid-false'); if (e.keyCode === 13) { $input = $(e.target); @@ -875,6 +875,8 @@ module.exports = recl({ v = "~" + v; } if (this.validateSource(v)) { + d = new Date(new Date() - 24 * 3600 * 1000); + v = v + "/" + window.urb.util.toDate(d); StationActions.addSources(this.state.station, [v]); $input.val(''); return $input.blur(); @@ -1600,7 +1602,6 @@ module.exports = function(arg) { var path; end = window.urb.util.numDot(end); start = window.urb.util.numDot(start); - console.log('getting grams from ' + end + ' to ' + start); path = util.talkPath('circle', station, 'grams', end, start); return window.urb.bind(path, function(err, res) { var ref, ref1; From 7044ee543bd7c8c2a2710185d845a356551a7e61 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 18 Jan 2018 19:07:57 +0100 Subject: [PATCH 108/184] Fix erroneous indentation. --- sys/vane/clay.hoon | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index dac4034d9..bbf4f7a4d 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -737,20 +737,20 @@ == :: $many - =+ aey=(case-to-aeon:ze p.q.rov) - ?~ aey ~ - %+ roll ~(tap in ~(key by qyx)) - |= {hav/rove res/(unit rove)} - ?^ res res - =- ?:(- `hav ~) - ?& ?=($many -.hav) - =(hav rov(p.q p.q.hav)) - :: - :: only a match if this request is before - :: or at our starting case. - =+ hay=(case-to-aeon:ze p.q.hav) - ?~(hay | (lte u.hay u.aey)) - == + =+ aey=(case-to-aeon:ze p.q.rov) + ?~ aey ~ + %+ roll ~(tap in ~(key by qyx)) + |= {hav/rove res/(unit rove)} + ?^ res res + =- ?:(- `hav ~) + ?& ?=($many -.hav) + =(hav rov(p.q p.q.hav)) + :: + :: only a match if this request is before + :: or at our starting case. + =+ hay=(case-to-aeon:ze p.q.hav) + ?~(hay | (lte u.hay u.aey)) + == == :: :: Takes a list of changed paths and finds those paths that are inside a From e3cbbd31a2fe888cd3a728febe3462ed7c83b22a Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 19 Jan 2018 01:54:41 +0100 Subject: [PATCH 109/184] Consolidates the logic for %next and %mult. Not thoroughly tested yet. --- sys/vane/clay.hoon | 196 ++++++++++++++++++++++++--------------------- 1 file changed, 103 insertions(+), 93 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index bbf4f7a4d..768751525 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -842,59 +842,30 @@ (blub hen) (blab hen p.rav u.u.ver) :: - :: for %next, get the data at the specified case, then go forward in time - :: until we find a change. if we find no change, store request for later. - $next - =+ old=(aver p.rav) - :: if we know nothing now, store the request for later answering. - ?: ?=($~ old) (duce -.rav p.rav old) - =+ yon=+((need (case-to-aeon:ze q.p.rav))) - |- ^+ +>.^$ - ?: (gth yon let.dom) - (duce -.rav p.rav old) - =+ new=(aver p.rav(q [%ud yon])) - ?~ new - ~& [%oh-no rave=rav aeon=yon letdom=let.dom] - +>.^$ - ?~ u.old - ?~ u.new $(yon +(yon)) :: not added - (blab hen p.rav u.u.new) :: added - ?~ u.new - (blab hen p.rav %& %null [%atom %n ~] ~) :: removed, only her %x - ?: (equivalent-data:ze u.u.old u.u.new) - $(yon +(yon)) :: unchanged - (blab hen p.rav u.u.new) :: changed - :: - $mult + :: for %mult and %next, get the data at the specified case, then go forward + :: in time until we find a change (as long as we have no unknowns). + :: if we find no change, store request for later. + :: %next is just %mult with one path, so we pretend %next = %mult here. + ?($next $mult) + |^ =+ aey=(case-to-aeon:ze q.p.rav) :: if the requested case is in the future, we can't know anything yet. - ?~ aey (duce -.rav p.rav ~ ~ ~) - =/ old - %- ~(gas by *(map path (unit cach))) - %+ turn ~(tap by r.p.rav) - |= p/path - ^- (pair path (unit cach)) - [p (aver p.p.rav q.p.rav p)] - =+ hav=|=({p/path c/(unit cach)} ?=(^ c)) + ?~ aey (store ~ ~ ~) + =+ old=(read-all-at q.p.rav) =+ yon=+((need (case-to-aeon:ze q.p.rav))) - |- ^+ +>.^$ - :: if we're need future revisions to look for change, wait. + |- ^+ ..start-request + :: if we need future revisions to look for change, wait. ?: (gth yon let.dom) - (duce -.rav p.rav `yon old ~) - =/ new - %- ~(gas by *(map path (unit cach))) - %+ turn ~(tap by r.p.rav) - |= p/path - ^- (pair path (unit cach)) - [p (aver p.p.rav q.p.rav p)] + (store `yon old ~) + =+ new=(read-all-at [%ud yon]) :: if we don't know everything now, store the request for later. - ?. &((levy ~(tap by old) hav) (levy ~(tap by new) hav)) - (duce -.rav p.rav `yon old new) + ?. &((levy ~(tap by old) know) (levy ~(tap by new) know)) + (store `yon old new) :: if we do know everything now, compare old and new. :: if there are differences, send response. if not, try next aeon. =; res - ?~ res $(old new, yon +(yon)) - (blas hen res) + ?~ res $(yon +(yon)) + (respond res) %+ roll ~(tap by old) |= $: {pax/path ole/(unit cach)} res/(map mood (each cage lobe)) @@ -911,6 +882,41 @@ `[mod [%& %null [%atom %n ~] ~]] :: deleted ?: (equivalent-data:ze u.u.neu u.u.ole) ~ :: unchanged `[mod u.u.neu] :: changed + :: + ++ store :: check again later + |= $: nex/(unit aeon) + old/(map path (unit cach)) + new/(map path (unit cach)) + == + ^+ ..start-request + ?: ?=($mult -.rav) + (duce -.rav p.rav nex old new) + %^ duce -.rav p.rav + =+ ole=~(tap by old) + ?> (lte (lent ole) 1) + ?~ ole ~ + q:(snag 0 `(list (pair path (unit cach)))`ole) + :: + ++ respond :: send changes + |= res/(map mood (each cage lobe)) + ^+ ..start-request + ?: ?=($mult -.rav) (blas hen res) + ?> ?=({* $~ $~} res) + (blab hen n.res) + :: + ++ know |=({p/path c/(unit cach)} ?=(^ c)) :: know awout file + :: + ++ read-all-at :: initialize cache + |= cas/case + %- ~(gas by *(map path (unit cach))) + =/ pax/(set path) + ?: ?=($mult -.rav) r.p.rav + [r.p.rav ~ ~] + %+ turn ~(tap by pax) + |= p/path + ^- (pair path (unit cach)) + [p (aver p.p.rav cas p)] + -- :: $many =+ nab=(case-to-aeon:ze p.q.rav) @@ -1781,40 +1787,24 @@ $(xiq t.xiq, xaq [i.xiq xaq]) $(xiq t.xiq, ..wake (balk-all q.i.xiq u.vid p.p.i.xiq)) :: - $next - =* mun p.p.i.xiq - =* old q.p.i.xiq - =/ mod mun(q [%ud let.dom]) - :: we either update the state (to include a response to send), - :: or add the request back into the waiting list. - =; nex/(each (each cage lobe) _xaq) - ?: ?=($& -.nex) - $(xiq t.xiq, ..wake (blab-all q.i.xiq mod p.nex)) - $(xiq t.xiq, xaq p.nex) - :: if we don't have an existing cache of the old version, - :: try to get it now. - ?~ old - |+[i.xiq(q.p (aver mun)) xaq] - =+ new=(aver mod) - ?~ new - ~& [%oh-noes old=mun mood=mod letdom=let.dom] - |+xaq - ?~ u.old - ?~ u.new |+[i.xiq xaq] :: not added - &+u.u.new :: added - ?~ u.new - &+[%& %null [%atom %n ~] ~] :: deleted - ?: (equivalent-data:ze u.u.old u.u.new) - |+[i.xiq xaq] :: unchanged - &+u.u.new :: changed - :: - $mult + :: %next is just %mult with one path, so we pretend %next = %mult here. + ?($next $mult) :: because %mult requests need to wait on multiple files for each :: revision that needs to be checked for changes, we keep two cache maps. :: {old} is the revision at {(dec yon)}, {new} is the revision at {yon}. :: if we have no {yon} yet, that means it was still unknown last time :: we checked. - =* rov p.i.xiq + =* vor p.i.xiq + |^ + =/ rov/rove + ?: ?=($mult -.vor) vor + :* %mult + p.vor(r [r.p.vor ~ ~]) + `let.dom + [[r.p.vor q.vor] ~ ~] + ~ + == + ?> ?=($mult -.rov) =* mol p.rov =* yon q.rov =* old r.rov @@ -1822,8 +1812,8 @@ :: we will either respond, or store the maybe updated request. =; res/(each (map mood (each cage lobe)) rove) ?: ?=($& -.res) - $(xiq t.xiq, ..wake (blas-all q.i.xiq p.res)) - $(xiq t.xiq, xaq [i.xiq(p p.res) xaq]) + (respond p.res) + (store p.res) |- :: so that we can retry for the next aeon if possible/needed. :: if we don't have an aeon yet, see if we have one now. ?~ yon @@ -1832,34 +1822,24 @@ ?~ aey |+rov :: if we do, update the request and retry. $(rov [-.rov mol `+(u.aey) ~ ~]) - =+ hav=|=({p/path c/(unit cach)} ?=(^ c)) - :: create a gate that tries to fill the unknown data into a cache map. - =/ fill - =/ d :: for easier iteraton. - %- ~(gas by *(map path (unit cach))) - (turn ~(tap in r.mol) |=(p/path [p ~])) - |= {m/(map path (unit cach)) c/case} - %- ~(urn by ?~(m d m)) - |= {p/path o/(unit cach)} - ?^(o o (aver p.mol c p)) :: if old isn't complete, try fillin in the gaps. - =? old |(?=($~ old) !(levy ~(tap by `(map path (unit cach))`old) hav)) - (fill old [%ud (dec u.yon)]) + =? old |(?=($~ old) !(levy ~(tap by `(map path (unit cach))`old) know)) + (read-unknown mol(q [%ud (dec u.yon)]) old) :: if the next aeon we want to compare is in the future, wait again. =+ aey=(case-to-aeon:ze [%ud u.yon]) ?~ aey |+rov :: if new isn't complete, try filling in the gaps. - =? new |(?=($~ new) !(levy ~(tap by `(map path (unit cach))`new) hav)) - (fill new [%ud u.yon]) + =? new |(?=($~ new) !(levy ~(tap by `(map path (unit cach))`new) know)) + (read-unknown mol(q [%ud u.yon]) new) :: if they're still not both complete, wait again. - ?. ?& (levy ~(tap by old) hav) - (levy ~(tap by new) hav) + ?. ?& (levy ~(tap by old) know) + (levy ~(tap by new) know) == |+rov :: if there are any changes, send response. if none, move onto next aeon. =; res ?^ res &+res - $(rov [-.rov mol `+(u.yon) new ~]) + $(rov [-.rov mol `+(u.yon) old ~]) %+ roll ~(tap by old) |= $: {pax/path ole/(unit cach)} res/(map mood (each cage lobe)) @@ -1876,6 +1856,36 @@ `[mod [%& %null [%atom %n ~] ~]] :: deleted ?: (equivalent-data:ze u.u.neu u.u.ole) ~ :: unchanged `[mod u.u.neu] :: changed + :: + ++ store :: check again later + |= rov/rove + ^+ ..wake + =- ^^$(xiq t.xiq, xaq [i.xiq(p -) xaq]) + ?> ?=($mult -.rov) + ?: ?=($mult -.vor) rov + ?> ?=({* $~ $~} r.rov) + [%next p.rov(r p.n.r.rov) q.n.r.rov] + :: + ++ respond :: send changes + |= res/(map mood (each cage lobe)) + ^+ ..wake + ::NOTE want to use =-, but compiler bug? + ?: ?=($mult -.vor) + ^^$(xiq t.xiq, ..wake (blas-all q.i.xiq res)) + ?> ?=({* $~ $~} res) + ^^$(xiq t.xiq, ..wake (blab-all q.i.xiq n.res)) + :: + ++ know |=({p/path c/(unit cach)} ?=(^ c)) :: know awout file + :: + ++ read-unknown :: fill in the blanks + |= {mol/mool hav/(map path (unit cach))} + %. |= {p/path o/(unit cach)} + ?^(o o (aver p.mol q.mol p)) + =- ~(urn by -) + ?^ hav hav + %- ~(gas by *(map path (unit cach))) + (turn ~(tap in r.mol) |=(p/path [p ~])) + -- :: $many =+ mot=`moat`q.p.i.xiq From 2b35142c79987babc1e00be94703f5d6f66ac5be Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 18 Jan 2018 21:19:53 -0800 Subject: [PATCH 110/184] Add documentation for testing. --- web/testing.umd | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 web/testing.umd diff --git a/web/testing.umd b/web/testing.umd new file mode 100644 index 000000000..d7bf405ca --- /dev/null +++ b/web/testing.umd @@ -0,0 +1,52 @@ +:- ~[comments+&] +;> + +# Writing Unit Tests + +Urbit comes with a built in system for writing tests. Like hoon files with a +certain shape go in `%/app` or `%/gen` or `%/mar`, hoon files with a certain +shape can go in `%/tests` and then are exposed to a system wide test runner. + +Say you put a test suite in `%/tests/new-hoon/thr.hoon`: + + > +ls %/tests + new-hoon/ + > +ls %/tests/new-hoon + ls/hoon mp/hoon myb/hoon thr/hoon + +You can then just run that individual test suite (and not the ones that are beside it in the `%/tests/new-hoon` directory) with: + + > +tests /new-hoon/thr + /new-hoon/thr/test-seconds OK + /new-hoon/thr/test-partition OK + /new-hoon/thr/test-firsts OK + /new-hoon/thr/test-apply OK + +## The test file + +So what is the structure of these test files? They contain a door, with arms starting with `++test-` or `++check-`. At minimum: + + /+ tester + |_ tester-type:tester + ++ test-some-test + (expect-eq 4 4 "trivial") + -- + +All of the utilities you need to write tests are in the tester library. Also, like other hoon files, you can stack cores for models and utility functions with only the final core being inspected for test arms. + +## Some Details + +So internally, how does this work? + +The `+test` generator depends on each file/directory in `%/tests/` through a renderer. Each node in the filesystem tree is rendered by `%/ren/test-tree.hoon`, which calls itself recursively for subdirectories. + +This means all compiling of test cases happens inside ford, which can cache work and not recompile tests whose dependencies haven't changed. At runtime, all the `+test` generator does is filter and execute tests from the tree. + +I would like to get to a place where any direct scrying of the filesystem is discouraged, and almost everything flows through the functional reactive build system. This is what it is here for. + +### Future distribution of hoon libraries + +Implicit in having a standard way to write tests and a standard `+test` runner is the idea that all functionality on the current desk should be tested. + +Let's say I'm shipping a program on Urbit and I use multiple third-party libraries. Each of those libraries should have their own test suites placed in `%/tests/`. When I `|merge` their desks into my application desk, having a standard test runner means that all their tests and all my application tests get run. If you're depending on a library, you want to make sure that the tests for your dependencies run when you test your application. + From b285b324cd1df8e3cbc2fa26a32df4a3c6bc5450 Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 18 Jan 2018 22:19:48 -0800 Subject: [PATCH 111/184] %143-ize the capitalization code. --- gen/capitalize.hoon | 60 +++++++++++++++++++++---------------------- mar/unicode-data.hoon | 19 +++++++------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/gen/capitalize.hoon b/gen/capitalize.hoon index 49303d2dc..b31c5e1eb 100644 --- a/gen/capitalize.hoon +++ b/gen/capitalize.hoon @@ -4,7 +4,7 @@ /- unicode-data /+ new-hoon /= case-table - /; |= a/(list line:unicode-data) + /; |= a=(list line:unicode-data) =, new-hoon |^ %- build-tree %- flop @@ -17,7 +17,7 @@ +| ++ build-case-nodes :> raw list of unicode data lines to a compact list of chardata - |= a/(list line:unicode-data) + |= a=(list line:unicode-data) ^- (list case-node:unicode-data) =< out :: @@ -27,7 +27,7 @@ :: only the excerpts i was using for testing. :: %^ foldl:ls a *case-fold - |= {c/case-fold l/line:unicode-data} + |= [c=case-fold l=line:unicode-data] ^+ c =+ state=(line-to-case-state l) ?: (is-adjacent state prev.c) @@ -45,7 +45,7 @@ :> creates an easy to merge form. |= line:unicode-data ^- case-state - =/ out/case-state + =/ out=case-state [code %none [%none ~] [%none ~] [%none ~]] ?: =(code `@c`0) =. case.out %missing @@ -72,7 +72,7 @@ out :: ++ calculate-offset - |= {src/@c dst/@c} + |= [src=@c dst=@c] ^- case-offset:unicode-data ?: =(src dst) [%none ~] @@ -82,7 +82,7 @@ :: ++ is-adjacent :> is {rhs} a continuation of {lhs}? - |= {lhs/case-state rhs/case-state} + |= [lhs=case-state rhs=case-state] ^- ? ?: (lth point.rhs point.lhs) $(lhs rhs, rhs lhs) @@ -106,7 +106,7 @@ :> detects %upper-lower spans. :> :> is {lhs} the same as {rhs}, but with opposite case? - |= {lhs/case-state rhs/case-state} + |= [lhs=case-state rhs=case-state] ?: &(=(case.lhs %upper) !=(case.rhs %lower)) %.n ?: &(=(case.lhs %lower) !=(case.rhs %upper)) @@ -122,19 +122,19 @@ == :: ++ is-upper-lower - |= i/case-state + |= i=case-state =(+.+.i [[%none ~] [%add 1] [%none ~]]) :: ++ is-lower-upper - |= i/case-state + |= i=case-state =(+.+.i [[%sub 1] [%none ~] [%sub 1]]) :: ++ is-none - |= i/case-state + |= i=case-state =(+.+.i [[%none ~] [%none ~] [%none ~]]) :: ++ add-range - |= c/case-fold + |= c=case-fold ^+ c ?~ start.c c @@ -143,30 +143,30 @@ ?: ?& (gth point.prev.c point.u.start.c) (is-upper-lower u.start.c) == - =/ node/case-node:unicode-data + =/ node=case-node:unicode-data [`@ux`point.u.start.c `@ux`point.prev.c [%uplo ~] [%uplo ~] [%uplo ~]] c(out [node out.c]) - =/ node/case-node:unicode-data + =/ node=case-node:unicode-data [`@ux`point.u.start.c `@ux`point.prev.c +.+.u.start.c] c(out [node out.c]) :: ++ case-fold :> state that's part of the fold which generates the list of case-nodes $: :> resulting data to pass to treeify. - out/(list case-node:unicode-data) + out=(list case-node:unicode-data) :> the start of a run of characters; ~ for not active. - start/(unit case-state) + start=(unit case-state) :> previous character state - prev/case-state + prev=case-state == :: ++ case-state :> a temporary model which we compress later in a second pass. - $: point/@c - case/case-class - upper/case-offset:unicode-data - lower/case-offset:unicode-data - title/case-offset:unicode-data + $: point=@c + case=case-class + upper=case-offset:unicode-data + lower=case-offset:unicode-data + title=case-offset:unicode-data == :: ++ case-class @@ -184,7 +184,7 @@ :> builds a binary search tree out of the list +| ++ build-tree - |= a/(list case-node:unicode-data) + |= a=(list case-node:unicode-data) ^- case-tree:unicode-data :: there's probably a bottom up approach that doesn't require walking :: a list over and over again. @@ -205,13 +205,13 @@ :: |% ++ transform - |= {a/tape fun/$-(@c @c)} + |= [a=tape fun=$-(@c @c)] %- tufa (turn (tuba a) fun) :: ++ to-upper :> returns the uppercase of unicode codepoint {a} - |= a/@c + |= a=@c ^- @c :: special case ascii to not perform map lookup. ?: (lte a max-ascii) @@ -222,10 +222,10 @@ :: ++ to-lower :> returns the lowercase of unicode codepoint {a} - |= a/@c + |= a=@c ^- @c ?: (lte a max-ascii) - ?: &((get a 'A') (lte a 'Z')) + ?: &((gte a 'A') (lte a 'Z')) (add 32 a) a (apply-table a case-table %lower) @@ -235,7 +235,7 @@ :> :> this recursively walks the case tree {table}. if it finds an entry which :> matches on {a}, it will apply the offset. otherwise, returns {a}. - |= {a/@c table/case-tree:unicode-data type/?($upper $lower $title)} + |= [a=@c table=case-tree:unicode-data type=?($upper $lower $title)] ^- @c ?~ table a @@ -254,7 +254,7 @@ :: ++ apply-offset :> applies an character offset to {a}. - |= {a/@c type/?($upper $lower $title) offset/case-offset:unicode-data} + |= [a=@c type=?($upper $lower $title) offset=case-offset:unicode-data] ^- @c ?- offset {$add *} (add a a.offset) @@ -275,8 +275,8 @@ :: part 3: generator :: :- %say -|= $: {now/@da eny/@uvJ bec/beak} - {n/tape $~} +|= $: [now=@da eny=@uvJ bec=beak] + [n=tape $~] $~ == :- %tape (transform n to-upper) diff --git a/mar/unicode-data.hoon b/mar/unicode-data.hoon index e3b8e3ba3..3d965dfa9 100644 --- a/mar/unicode-data.hoon +++ b/mar/unicode-data.hoon @@ -6,14 +6,15 @@ ++ grab :> converts from mark to unicode-data. |% - ++ mime |=({* a/octs} (txt (to-wain q.a))) :: XX mark translation + ++ mime |=([* a=octs] (txt (to-wain q.a))) :: XX mark translation ++ txt - |^ |= a/wain + |^ |= a=wain ^+ all - %+ turn a - |= b/cord - ^- line:unicode-data - (rash b line) + %+ murn a + |= b=cord + ^- (unit line:unicode-data) + ?~ b ~ + `(rash b line) :: :> parses a single line of the unicode data file. ++ line @@ -38,7 +39,7 @@ :> parses a single name or comment string. ++ name-string %+ cook - |=(a/tape a) + |=(a=tape a) (star ;~(less sem prn)) :: :> parses a unicode general category abbreviation to symbol @@ -114,7 +115,7 @@ (stag ~ (ifix [gal ;~(plug gar ace)] decomp-tag)) (easy ~) == - (cook |=(a/(list @c) a) (most ace hex)) + (cook |=(a=(list @c) a) (most ace hex)) == :: no decomposition information (easy ~) @@ -142,7 +143,7 @@ :: ++ string-number %+ cook - |=(a/tape a) + |=(a=tape a) (star ;~(pose nud fas hep)) :: ++ yes-or-no From 58900d30f7eb77fb28c59fa3f189b644cc73014c Mon Sep 17 00:00:00 2001 From: Elliot Glaysher Date: Thu, 18 Jan 2018 22:40:24 -0800 Subject: [PATCH 112/184] Further %143-ization and general cleanup. --- gen/capitalize.hoon | 3 +++ mar/unicode-data.hoon | 5 +---- sur/unicode-data.hoon | 52 +++++++++++++++++++++---------------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/gen/capitalize.hoon b/gen/capitalize.hoon index b31c5e1eb..f5bff918d 100644 --- a/gen/capitalize.hoon +++ b/gen/capitalize.hoon @@ -1,3 +1,6 @@ +:: to use, download UnicdoeData.txt and place it in `%/lib/unicode-data/txt`. +:: +:::: :: :: part 1: parse the file into {uppers} :: diff --git a/mar/unicode-data.hoon b/mar/unicode-data.hoon index 7a24846eb..61564ffa7 100644 --- a/mar/unicode-data.hoon +++ b/mar/unicode-data.hoon @@ -22,7 +22,7 @@ hex :: code/@c codepoint in hex format name-string :: name/tape character name general-category :: gen/general type of character - (bass 10 (plus dit)) :: can/@ud canonical combining class + (bass 10 (plus dit)) :: can/@ud canonical combining class bidi-category :: bi/bidi bidirectional category decomposition-mapping :: de/decomp decomposition mapping :: @@ -45,7 +45,6 @@ %+ cook |=(a=tape a) (star ;~(less sem prn)) - :: (star ;~(pose alp (mask " <>()"))) :: :> parses a unicode general category abbreviation to symbol ++ general-category @@ -57,7 +56,6 @@ %+ sear (soft bidi:unicode-data) :(cook crip cass (star hig)) :: - :: TODO: This seems to be where the nest-fail is. There's an extra @ here? ++ decomposition-mapping %- punt :: optional :: a tag and a list of characters to decompose to @@ -68,7 +66,6 @@ :: ++ decomp-tag %+ sear (soft decomp-tag:unicode-data) - %+ cook |=(a=term ?+(a a $nobreak %no-break)) ::REVIEW or just change the type :(cook crip cass (star alf)) :: ++ string-number diff --git a/sur/unicode-data.hoon b/sur/unicode-data.hoon index 6b4345c47..a333455c8 100644 --- a/sur/unicode-data.hoon +++ b/sur/unicode-data.hoon @@ -5,23 +5,23 @@ ++ line :> an individual codepoint definition :> - $: code/@c :< codepoint in hexadecimal format - name/tape :< character name - gen/general :< type of character this is + $: code=@c :< codepoint in hexadecimal format + name=tape :< character name + gen=general :< type of character this is :> canonical combining class for ordering algorithms - can/@ud - bi/bidi :< bidirectional category of this character - de/decomp :< character decomposition mapping - :: todo: decimal/digit/numeric need to be parsed. - decimal/tape :< decimal digit value (or ~) - digit/tape :< digit value, covering non decimal radix forms - numeric/tape :< numeric value, including fractions - mirrored/? :< whether char is mirrored in bidirectional text - old-name/tape :< unicode 1.0 compatibility name - iso/tape :< iso 10646 comment field - up/(unit @c) :< uppercase mapping codepoint - low/(unit @c) :< lowercase mapping codepoint - title/(unit @c) :< titlecase mapping codepoint + can=@ud + bi=bidi :< bidirectional category of this character + de=decomp :< character decomposition mapping + :: todo: decimal/digit/numeric need to be parsed. + decimal=tape :< decimal digit value (or ~) + digit=tape :< digit value, covering non decimal radix forms + numeric=tape :< numeric value, including fractions + mirrored=? :< whether char is mirrored in bidirectional text + old-name=tape :< unicode 1.0 compatibility name + iso=tape :< iso 10646 comment field + up=(unit @c) :< uppercase mapping codepoint + low=(unit @c) :< lowercase mapping codepoint + title=(unit @c) :< titlecase mapping codepoint == :: ++ general @@ -99,7 +99,7 @@ ++ decomp-tag :> tag that describes the type of a character decomposition. $? $font :< a font variant - $no-break :< a no-break version of a space or hyphen + $nobreak :< a no-break version of a space or hyphen $initial :< an initial presentation form (arabic) $medial :< a medial presentation form (arabic) $final :< a final presentation form (arabic) @@ -124,24 +124,24 @@ ++ case-offset :> case offsets can be in either direction $% :> add {a} to get the new character - {$add a/@u} + [%add a=@u] :> subtract {a} to get the new character - {$sub s/@u} + [%sub s=@u] :> take no action; return self - {$none $~} + [%none $~] :> represents series of alternating uppercase/lowercase characters - {$uplo $~} + [%uplo $~] == :: ++ case-node :> a node in a case-tree. :> :> represents a range of - $: start/@ux - end/@ux - upper/case-offset - lower/case-offset - title/case-offset + $: start=@ux + end=@ux + upper=case-offset + lower=case-offset + title=case-offset == :: ++ case-tree From ebc95233a8e04e9d16e7edbb05ba712c0a7ad775 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Fri, 19 Jan 2018 13:42:50 -0800 Subject: [PATCH 113/184] Update hoon.hoon Fix #95 per request to just patch it on master --- sys/hoon.hoon | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index 4c7f7b24b..0b63fc9be 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -273,8 +273,11 @@ ++ mold :> normalizing gate :> - :> actually a type alias for gate. - gate + :> a gate that accepts any noun, and validates its shape, producing the + :> input if it fits or a default value if it doesn't. + :> + :> examples: * @ud ,[p=time q=?(%a %b)] + _|=(* +<) :: ++ pair :> dual tuple From 635d235cd721a2507dfc4f03691b149f49398217 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 22 Jan 2018 15:54:37 +0100 Subject: [PATCH 114/184] Made %mult requests produce only a case and set of paths. It now works the way %next should. --- sys/vane/clay.hoon | 15 ++++++--------- sys/zuse.hoon | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 768751525..8d95bf7f3 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -596,14 +596,11 @@ == :: ++ blas - |= {hen/duct das/(map mood (each cage lobe))} + |= {hen/duct das/(set mood)} ^+ +> - =- (emit hen %give %wris -) - %- ~(run in das) - |= {mun/mood dat/(each cage lobe)} - ~| %lobe-unsupported-tmp - ?> ?=($& -.dat) - [[p.mun q.mun syd] r.mun p.dat] + ?> ?=(^ das) + =- (emit hen %give %wris q.n.das -) + (~(run in `(set mood)`das) |=(m/mood r.m)) :: :: Give next step in a subscription. :: @@ -900,7 +897,7 @@ ++ respond :: send changes |= res/(map mood (each cage lobe)) ^+ ..start-request - ?: ?=($mult -.rav) (blas hen res) + ?: ?=($mult -.rav) (blas hen ~(key by res)) ?> ?=({* $~ $~} res) (blab hen n.res) :: @@ -1871,7 +1868,7 @@ ^+ ..wake ::NOTE want to use =-, but compiler bug? ?: ?=($mult -.vor) - ^^$(xiq t.xiq, ..wake (blas-all q.i.xiq res)) + ^^$(xiq t.xiq, ..wake (blas-all q.i.xiq ~(key by res))) ?> ?=({* $~ $~} res) ^^$(xiq t.xiq, ..wake (blab-all q.i.xiq n.res)) :: diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 881bbf8ba..03c8098cc 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -391,7 +391,7 @@ {$ogre p/@tas} :: delete mount point {$send p/lane:ames q/@} :: transmit packet {$writ p/riot} :: response - {$wris p/(set rant)} :: responses + {$wris p/case p/(set path)} :: responses == :: ++ task :: in request ->$ $% {$boat $~} :: pier rebooted From d9409e8dff752f34ee325b800e8c60bcc260e480 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 22 Jan 2018 16:01:00 +0100 Subject: [PATCH 115/184] Clean up ++cach. --- sys/vane/clay.hoon | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 8d95bf7f3..dd0422f91 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -270,15 +270,15 @@ :: Like a ++rave but with caches of current versions for %next and %many. :: Generally used when we store a request in our state somewhere. :: -++ cach (unit (each cage lobe)) :: cached result +++ cach (unit (unit (each cage lobe))) :: cached result ++ rove :: stored request $% {$sing p/mood} :: single request - {$next p/mood q/(unit cach)} :: next version + {$next p/mood q/cach} :: next version $: $mult :: next version of any p/mool :: original request q/(unit aeon) :: checking for change - r/(map path (unit cach)) :: old version - s/(map path (unit cach)) :: new version + r/(map path cach) :: old version + s/(map path cach) :: new version == {$many p/? q/moat r/(map path lobe)} :: change range == :: @@ -864,7 +864,7 @@ ?~ res $(yon +(yon)) (respond res) %+ roll ~(tap by old) - |= $: {pax/path ole/(unit cach)} + |= $: {pax/path ole/cach} res/(map mood (each cage lobe)) == =+ neu=(~(got by new) pax) @@ -882,8 +882,8 @@ :: ++ store :: check again later |= $: nex/(unit aeon) - old/(map path (unit cach)) - new/(map path (unit cach)) + old/(map path cach) + new/(map path cach) == ^+ ..start-request ?: ?=($mult -.rav) @@ -892,7 +892,7 @@ =+ ole=~(tap by old) ?> (lte (lent ole) 1) ?~ ole ~ - q:(snag 0 `(list (pair path (unit cach)))`ole) + q:(snag 0 `(list (pair path cach))`ole) :: ++ respond :: send changes |= res/(map mood (each cage lobe)) @@ -901,17 +901,17 @@ ?> ?=({* $~ $~} res) (blab hen n.res) :: - ++ know |=({p/path c/(unit cach)} ?=(^ c)) :: know awout file + ++ know |=({p/path c/cach} ?=(^ c)) :: know about file :: - ++ read-all-at :: initialize cache + ++ read-all-at :: files at case, maybe |= cas/case - %- ~(gas by *(map path (unit cach))) + %- ~(gas by *(map path cach)) =/ pax/(set path) ?: ?=($mult -.rav) r.p.rav [r.p.rav ~ ~] %+ turn ~(tap by pax) |= p/path - ^- (pair path (unit cach)) + ^- (pair path cach) [p (aver p.p.rav cas p)] -- :: @@ -1819,14 +1819,14 @@ ?~ aey |+rov :: if we do, update the request and retry. $(rov [-.rov mol `+(u.aey) ~ ~]) - :: if old isn't complete, try fillin in the gaps. - =? old |(?=($~ old) !(levy ~(tap by `(map path (unit cach))`old) know)) + :: if old isn't complete, try filling in the gaps. + =? old |(?=($~ old) !(levy ~(tap by `(map path cach)`old) know)) (read-unknown mol(q [%ud (dec u.yon)]) old) :: if the next aeon we want to compare is in the future, wait again. =+ aey=(case-to-aeon:ze [%ud u.yon]) ?~ aey |+rov :: if new isn't complete, try filling in the gaps. - =? new |(?=($~ new) !(levy ~(tap by `(map path (unit cach))`new) know)) + =? new |(?=($~ new) !(levy ~(tap by `(map path cach)`new) know)) (read-unknown mol(q [%ud u.yon]) new) :: if they're still not both complete, wait again. ?. ?& (levy ~(tap by old) know) @@ -1838,7 +1838,7 @@ ?^ res &+res $(rov [-.rov mol `+(u.yon) old ~]) %+ roll ~(tap by old) - |= $: {pax/path ole/(unit cach)} + |= $: {pax/path ole/cach} res/(map mood (each cage lobe)) == =+ neu=(~(got by new) pax) @@ -1872,15 +1872,15 @@ ?> ?=({* $~ $~} res) ^^$(xiq t.xiq, ..wake (blab-all q.i.xiq n.res)) :: - ++ know |=({p/path c/(unit cach)} ?=(^ c)) :: know awout file + ++ know |=({p/path c/cach} ?=(^ c)) :: know about file :: ++ read-unknown :: fill in the blanks - |= {mol/mool hav/(map path (unit cach))} - %. |= {p/path o/(unit cach)} + |= {mol/mool hav/(map path cach)} + %. |= {p/path o/cach} ?^(o o (aver p.mol q.mol p)) =- ~(urn by -) ?^ hav hav - %- ~(gas by *(map path (unit cach))) + %- ~(gas by *(map path cach)) (turn ~(tap in r.mol) |=(p/path [p ~])) -- :: From 7a0e2f216bb35b8828da09f5c0b6cc5124d09ca5 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 23 Jan 2018 17:35:12 +0100 Subject: [PATCH 116/184] Change %mult interface to allow different/multiple cares per path. --- sys/vane/clay.hoon | 96 +++++++++++++++++++++++++--------------------- sys/zuse.hoon | 4 +- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index dd0422f91..12540f767 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -277,9 +277,9 @@ $: $mult :: next version of any p/mool :: original request q/(unit aeon) :: checking for change - r/(map path cach) :: old version - s/(map path cach) :: new version - == + r/(map (pair care path) cach) :: old version + s/(map (pair care path) cach) :: new version + == :: {$many p/? q/moat r/(map path lobe)} :: change range == :: :: @@ -600,7 +600,7 @@ ^+ +> ?> ?=(^ das) =- (emit hen %give %wris q.n.das -) - (~(run in `(set mood)`das) |=(m/mood r.m)) + (~(run in `(set mood)`das) |=(m/mood [p.m r.m])) :: :: Give next step in a subscription. :: @@ -713,19 +713,19 @@ == :: $mult - =+ aey=(case-to-aeon:ze q.p.rov) + =+ aey=(case-to-aeon:ze p.p.rov) ?~ aey ~ %+ roll ~(tap in ~(key by qyx)) |= {hav/rove res/(unit rove)} ?^ res res =- ?:(- `hav ~) ?& ?=($mult -.hav) - =(p.hav p.rov(q q.p.hav)) + =(p.hav p.rov(p p.p.hav)) :: :: only a match if this request is before :: or at our starting case, and it has been :: tested at least that far. - =+ hay=(case-to-aeon:ze q.p.hav) + =+ hay=(case-to-aeon:ze p.p.hav) ?& ?=(^ hay) (lte u.hay u.aey) ?=(^ q.hav) @@ -845,11 +845,12 @@ :: %next is just %mult with one path, so we pretend %next = %mult here. ?($next $mult) |^ - =+ aey=(case-to-aeon:ze q.p.rav) + =+ cas=?:(?=($next -.rav) q.p.rav p.p.rav) + =+ aey=(case-to-aeon:ze cas) :: if the requested case is in the future, we can't know anything yet. ?~ aey (store ~ ~ ~) - =+ old=(read-all-at q.p.rav) - =+ yon=+((need (case-to-aeon:ze q.p.rav))) + =+ old=(read-all-at cas) + =+ yon=+((need (case-to-aeon:ze cas))) |- ^+ ..start-request :: if we need future revisions to look for change, wait. ?: (gth yon let.dom) @@ -864,14 +865,14 @@ ?~ res $(yon +(yon)) (respond res) %+ roll ~(tap by old) - |= $: {pax/path ole/cach} + |= $: {{car/care pax/path} ole/cach} res/(map mood (each cage lobe)) == - =+ neu=(~(got by new) pax) + =+ neu=(~(got by new) car pax) ?< |(?=($~ ole) ?=($~ neu)) =- ?~(- res (~(put by res) u.-)) ^- (unit (pair mood (each cage lobe))) - =+ mod=[p.p.rav [%ud yon] pax] + =+ mod=[car [%ud yon] pax] ?~ u.ole ?~ u.neu ~ :: not added `[mod u.u.neu] :: added @@ -882,8 +883,8 @@ :: ++ store :: check again later |= $: nex/(unit aeon) - old/(map path cach) - new/(map path cach) + old/(map (pair care path) cach) + new/(map (pair care path) cach) == ^+ ..start-request ?: ?=($mult -.rav) @@ -892,7 +893,7 @@ =+ ole=~(tap by old) ?> (lte (lent ole) 1) ?~ ole ~ - q:(snag 0 `(list (pair path cach))`ole) + q:(snag 0 `(list (pair (pair care path) cach))`ole) :: ++ respond :: send changes |= res/(map mood (each cage lobe)) @@ -901,18 +902,18 @@ ?> ?=({* $~ $~} res) (blab hen n.res) :: - ++ know |=({p/path c/cach} ?=(^ c)) :: know about file + ++ know |=({(pair care path) c/cach} ?=(^ c)) :: know about file :: ++ read-all-at :: files at case, maybe |= cas/case - %- ~(gas by *(map path cach)) - =/ pax/(set path) - ?: ?=($mult -.rav) r.p.rav - [r.p.rav ~ ~] - %+ turn ~(tap by pax) - |= p/path - ^- (pair path cach) - [p (aver p.p.rav cas p)] + %- ~(gas by *(map (pair care path) cach)) + =/ req/(set (pair care path)) + ?: ?=($mult -.rav) q.p.rav + [[p.p.rav r.p.rav] ~ ~] + %+ turn ~(tap by req) + |= {c/care p/path} + ^- (pair (pair care path) cach) + [[c p] (aver c cas p)] -- :: $many @@ -1796,9 +1797,9 @@ =/ rov/rove ?: ?=($mult -.vor) vor :* %mult - p.vor(r [r.p.vor ~ ~]) + [q.p.vor [[p.p.vor r.p.vor] ~ ~]] `let.dom - [[r.p.vor q.vor] ~ ~] + [[[p.p.vor r.p.vor] q.vor] ~ ~] ~ == ?> ?=($mult -.rov) @@ -1814,23 +1815,23 @@ |- :: so that we can retry for the next aeon if possible/needed. :: if we don't have an aeon yet, see if we have one now. ?~ yon - =+ aey=(case-to-aeon:ze q.mol) + =+ aey=(case-to-aeon:ze p.mol) :: if we still don't, wait. ?~ aey |+rov :: if we do, update the request and retry. $(rov [-.rov mol `+(u.aey) ~ ~]) :: if old isn't complete, try filling in the gaps. - =? old |(?=($~ old) !(levy ~(tap by `(map path cach)`old) know)) - (read-unknown mol(q [%ud (dec u.yon)]) old) + =? old !(complete old) + (read-unknown mol(p [%ud (dec u.yon)]) old) :: if the next aeon we want to compare is in the future, wait again. =+ aey=(case-to-aeon:ze [%ud u.yon]) ?~ aey |+rov :: if new isn't complete, try filling in the gaps. - =? new |(?=($~ new) !(levy ~(tap by `(map path cach)`new) know)) - (read-unknown mol(q [%ud u.yon]) new) + =? new !(complete new) + (read-unknown mol(p [%ud u.yon]) new) :: if they're still not both complete, wait again. - ?. ?& (levy ~(tap by old) know) - (levy ~(tap by new) know) + ?. ?& (complete old) + (complete new) == |+rov :: if there are any changes, send response. if none, move onto next aeon. @@ -1838,14 +1839,14 @@ ?^ res &+res $(rov [-.rov mol `+(u.yon) old ~]) %+ roll ~(tap by old) - |= $: {pax/path ole/cach} + |= $: {{car/care pax/path} ole/cach} res/(map mood (each cage lobe)) == - =+ neu=(~(got by new) pax) + =+ neu=(~(got by new) car pax) ?< |(?=($~ ole) ?=($~ neu)) =- ?~(- res (~(put by res) u.-)) ^- (unit (pair mood (each cage lobe))) - =+ mod=[p.mol [%ud u.yon] pax] + =+ mod=[car [%ud u.yon] pax] ?~ u.ole ?~ u.neu ~ :: not added `[mod u.u.neu] :: added @@ -1861,7 +1862,8 @@ ?> ?=($mult -.rov) ?: ?=($mult -.vor) rov ?> ?=({* $~ $~} r.rov) - [%next p.rov(r p.n.r.rov) q.n.r.rov] + =* one n.r.rov + [%next [p.p.one p.p.rov q.p.one] q.one] :: ++ respond :: send changes |= res/(map mood (each cage lobe)) @@ -1872,16 +1874,22 @@ ?> ?=({* $~ $~} res) ^^$(xiq t.xiq, ..wake (blab-all q.i.xiq n.res)) :: - ++ know |=({p/path c/cach} ?=(^ c)) :: know about file + ++ complete :: no unknowns + |= hav/(map (pair care path) cach) + ?& ?=(^ hav) + (levy ~(tap by `(map (pair care path) cach)`hav) know) + == + :: + ++ know |=({(pair care path) c/cach} ?=(^ c)) :: know about file :: ++ read-unknown :: fill in the blanks - |= {mol/mool hav/(map path cach)} - %. |= {p/path o/cach} - ?^(o o (aver p.mol q.mol p)) + |= {mol/mool hav/(map (pair care path) cach)} + %. |= {{c/care p/path} o/cach} + ?^(o o (aver c p.mol p)) =- ~(urn by -) ?^ hav hav - %- ~(gas by *(map path cach)) - (turn ~(tap in r.mol) |=(p/path [p ~])) + %- ~(gas by *(map (pair care path) cach)) + (turn ~(tap in q.mol) |=({c/care p/path} [[c p] ~])) -- :: $many diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 03c8098cc..96061e3b7 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -391,7 +391,7 @@ {$ogre p/@tas} :: delete mount point {$send p/lane:ames q/@} :: transmit packet {$writ p/riot} :: response - {$wris p/case p/(set path)} :: responses + {$wris p/case p/(set (pair care path))} :: many changes == :: ++ task :: in request ->$ $% {$boat $~} :: pier rebooted @@ -467,7 +467,7 @@ ++ moat {p/case q/case r/path} :: change range ++ mode (list {path (unit mime)}) :: external files ++ mood {p/care q/case r/path} :: request in desk - ++ mool {p/care q/case r/(set path)} :: requests in desk + ++ mool {p/case q/(set (pair care path))} :: requests in desk ++ nori :: repository action $% {$& p/soba} :: delta {$| p/@tas} :: label From 8a1da39aac90c857b870feb02db1bbd2e4640300 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 23 Jan 2018 17:38:13 +0100 Subject: [PATCH 117/184] Remove ++gift copy from internal clay structures. --- sys/vane/clay.hoon | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 12540f767..b3d341401 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -315,18 +315,6 @@ -- => |% ++ move {p/duct q/(wind note gift:able)} :: local move -++ gift :: out result <-$ - $% {$dirk p/@tas} :: mark mount dirty - {$ergo p/@tas q/mode} :: version update - {$hill p/(list @tas)} :: mount points - {$mack p/(unit tang)} :: ack - {$mass p/mass} :: memory usage - {$mere p/(each (set path) (pair term tang))} :: merge result - {$note p/@tD q/tank} :: debug message - {$ogre p/@tas} :: delete mount point - {$writ p/riot} :: response - {$wris p/(set rant)} :: responses - == :: ++ note :: out request $-> $% $: $a :: to %ames $% {$want p/sock q/path r/*} :: From 2e364287d7bca4d3cc05c245e1313aeb0156e13a Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 23 Jan 2018 22:52:31 +0100 Subject: [PATCH 118/184] Clay permissions interface proposal. --- sys/vane/clay.hoon | 15 +++++++++------ sys/zuse.hoon | 12 ++++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index dd0422f91..06fcd307e 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -43,13 +43,13 @@ :: :: Type of request. :: -:: %d produces a set of desks, %u checks for existence, %v produces a ++dome of -:: all desk data, %w with a time or label case gets the aeon at that case, %w -:: with a number case is not recommended, %x gets file contents, %y gets a -:: directory listing, and %z gets a recursive hash of the file contents and -:: children. +:: %d produces a set of desks, %p gets file permissions, %u checks for +:: existence, %v produces a ++dome of all desk data, %w with a time or label +:: case gets the aeon at that case, %w with a number case is not recommended, +:: %x gets file contents, %y gets a directory listing, and %z gets a recursive +:: hash of the file contents and children. :: -:: ++ care ?($d $u $v $w $x $y $z) +:: ++ care ?($d $p $u $v $w $x $y $z) :: :: Keeps track of subscribers. :: @@ -78,6 +78,7 @@ :: ++ dome $: ank/ankh :: state + per/(map path rule) :: permissions by path let/aeon :: top id hit/(map aeon tako) :: versions by id lab/(map @tas aeon) :: labels @@ -183,6 +184,7 @@ :: -- `mon` is a collection of mount points (mount point name to urbit :: location). :: -- `hez` is the unix duct that %ergo's should be sent to. +:: -- `cez` is a collection of named permission groups. :: ++ raft :: filesystem $: fat/(map ship room) :: domestic @@ -190,6 +192,7 @@ ran/rang :: hashes mon/(map term beam) :: mount points hez/(unit duct) :: sync duct + cez/(map @ta crew) :: permission groups == :: :: :: Object store. diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 66b88e51d..6c2b4341e 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -381,7 +381,8 @@ ++ able ^? |% ++ gift :: out result <-$ - $% {$dirk p/@tas} :: mark mount dirty + $% {$cruz cez/(map @tas crew)} :: permission groups + {$dirk p/@tas} :: mark mount dirty {$ergo p/@tas q/mode} :: version update {$hill p/(list @tas)} :: mount points {$mack p/(unit tang)} :: ack @@ -389,12 +390,15 @@ {$mere p/(each (set path) (pair term tang))} :: merge result {$note p/@tD q/tank} :: debug message {$ogre p/@tas} :: delete mount point + {$rule own/? rul/rule} :: node permission {$send p/lane:ames q/@} :: transmit packet {$writ p/riot} :: response {$wris p/case p/(set path)} :: responses == :: ++ task :: in request ->$ $% {$boat $~} :: pier rebooted + {$crew $~} :: permission groups + {$cred nom/@ta cew/crew} :: set permission group {$drop p/@p q/desk} :: cancel pending merge {$info p/@p q/desk r/nori} :: internal edit {$init p/@p} :: report install @@ -403,6 +407,7 @@ {$mont p/desk q/beam} :: mount to unix {$dirk p/desk} :: mark mount dirty {$ogre p/$@(desk beam)} :: delete mount point + {$perm des/desk pax/path rul/(unit rule)} :: change permissions {$warp p/sock q/riff} :: file request {$wegh $~} :: report memory {$went p/sack q/path r/@ud s/coop} :: response confirm @@ -423,13 +428,14 @@ $% {$delta p/lobe q/{p/mark q/lobe} r/page} :: delta on q {$direct p/lobe q/page} :: immediate == :: - ++ care ?($d $u $v $w $x $y $z) :: clay submode + ++ care ?($d $p $u $v $w $x $y $z) :: clay submode ++ case :: ship desk case spur $% {$da p/@da} :: date {$tas p/@tas} :: label {$ud p/@ud} :: number == :: ++ coop (unit ares) :: e2e ack + ++ crew (set ship) :: permissions group ++ dome :: project state $: ank/ankh :: state let/@ud :: top id @@ -495,6 +501,7 @@ == :: ++ riff {p/desk q/(unit rave)} :: request+desist ++ riot (unit rant) :: response+complete + ++ rule {mod/?($black $white) who/(set whom)} :: node permission ++ rump {p/care q/case r/@tas s/path} :: relative path ++ saba {p/ship q/@tas r/moar s/dome} :: patch+merge ++ soba (list {p/path q/miso}) :: delta @@ -507,6 +514,7 @@ {$| p/(list a) q/(list a)} :: p -> q[chunk] == :: ++ urge |*(a/mold (list (unce a))) :: list change + ++ whom (each ship @ta) :: ship or named crew ++ yaki :: commit $: p/(list tako) :: parents q/(map path lobe) :: namespace From a4f552cb8f7885d71b508759cfab807f1294a343 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 24 Jan 2018 14:30:58 +0100 Subject: [PATCH 119/184] Update clay permissions interface to always supply the source of a node's rule. --- sys/zuse.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/zuse.hoon b/sys/zuse.hoon index d4153fdc0..753e32813 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -390,7 +390,7 @@ {$mere p/(each (set path) (pair term tang))} :: merge result {$note p/@tD q/tank} :: debug message {$ogre p/@tas} :: delete mount point - {$rule own/? rul/rule} :: node permission + {$rule src/path rul/rule} :: node permission {$send p/lane:ames q/@} :: transmit packet {$writ p/riot} :: response {$wris p/case p/(set (pair care path))} :: many changes From 39f11b7ccdcbff7e801f0f7dda1540c1364495c6 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 24 Jan 2018 16:33:41 +0100 Subject: [PATCH 120/184] Updates interface to include support for write permissions. --- sys/vane/clay.hoon | 3 ++- sys/zuse.hoon | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 38efb8474..75c73c537 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -78,7 +78,8 @@ :: ++ dome $: ank/ankh :: state - per/(map path rule) :: permissions by path + per/(map path rule) :: read perms per path + pew/(map path rule) :: write perms per path let/aeon :: top id hit/(map aeon tako) :: versions by id lab/(map @tas aeon) :: labels diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 753e32813..8f8e8dd3e 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -390,7 +390,7 @@ {$mere p/(each (set path) (pair term tang))} :: merge result {$note p/@tD q/tank} :: debug message {$ogre p/@tas} :: delete mount point - {$rule src/path rul/rule} :: node permission + {$rule red/dict wit/dict} :: node r+w permissions {$send p/lane:ames q/@} :: transmit packet {$writ p/riot} :: response {$wris p/case p/(set (pair care path))} :: many changes @@ -407,7 +407,12 @@ {$mont p/desk q/beam} :: mount to unix {$dirk p/desk} :: mark mount dirty {$ogre p/$@(desk beam)} :: delete mount point - {$perm des/desk pax/path rul/(unit rule)} :: change permissions + $: $perm :: change permissions + des/desk :: target desk + pax/path :: target node + rit/rite :: read, write or both + rul/(unit rule) :: new rule + == :: {$warp p/sock q/riff} :: file request {$wegh $~} :: report memory {$went p/sack q/path r/@ud s/coop} :: response confirm @@ -436,6 +441,7 @@ == :: ++ coop (unit ares) :: e2e ack ++ crew (set ship) :: permissions group + ++ dict {src/path rul/rule} :: effective permission ++ dome :: project state $: ank/ankh :: state let/@ud :: top id @@ -500,6 +506,7 @@ {$many p/? q/moat} :: track range == :: ++ riff {p/desk q/(unit rave)} :: request+desist + ++ rite ?($r $w $rw) :: permission for ++ riot (unit rant) :: response+complete ++ rule {mod/?($black $white) who/(set whom)} :: node permission ++ rump {p/care q/case r/@tas s/path} :: relative path From c1dda042a8d5c218ac851b075582b6b699b853cb Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 25 Jan 2018 00:09:46 +0100 Subject: [PATCH 121/184] Finalizing interface. --- sys/zuse.hoon | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 8f8e8dd3e..e6c4b0029 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -397,8 +397,8 @@ == :: ++ task :: in request ->$ $% {$boat $~} :: pier rebooted - {$crew $~} :: permission groups {$cred nom/@ta cew/crew} :: set permission group + {$crew $~} :: permission groups {$drop p/@p q/desk} :: cancel pending merge {$info p/@p q/desk r/nori} :: internal edit {$init p/@p} :: report install @@ -407,12 +407,7 @@ {$mont p/desk q/beam} :: mount to unix {$dirk p/desk} :: mark mount dirty {$ogre p/$@(desk beam)} :: delete mount point - $: $perm :: change permissions - des/desk :: target desk - pax/path :: target node - rit/rite :: read, write or both - rul/(unit rule) :: new rule - == :: + {$perm des/desk pax/path rit/rite} :: change permissions {$warp p/sock q/riff} :: file request {$wegh $~} :: report memory {$went p/sack q/path r/@ud s/coop} :: response confirm @@ -506,7 +501,11 @@ {$many p/? q/moat} :: track range == :: ++ riff {p/desk q/(unit rave)} :: request+desist - ++ rite ?($r $w $rw) :: permission for + ++ rite :: new permissions + $% {$r red/(unit rule)} :: for read + {$w wit/(unit rule)} :: for write + {$rw red/(unit rule) wit/(unit rule)} :: for read and write + == :: ++ riot (unit rant) :: response+complete ++ rule {mod/?($black $white) who/(set whom)} :: node permission ++ rump {p/care q/case r/@tas s/path} :: relative path From a6a6081b0b0ba4949fa4001aea32d6829f2f3050 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 25 Jan 2018 16:15:01 +0100 Subject: [PATCH 122/184] Update state structures and related code. --- sys/vane/clay.hoon | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 75c73c537..28532e1cc 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -61,13 +61,15 @@ :: Domestic desk state. :: :: Includes subscriber list, dome (desk content), possible commit state (for -:: local changes), and possible merge state (for incoming merges). +:: local changes), possible merge state (for incoming merges), and permissions. :: ++ dojo $: qyx/cult :: subscribers dom/dome :: desk state dok/(unit dork) :: commit state mer/(unit mery) :: merge state + per/(map path rule) :: read perms per path + pew/(map path rule) :: write perms per path == :: :: Desk state. @@ -78,8 +80,6 @@ :: ++ dome $: ank/ankh :: state - per/(map path rule) :: read perms per path - pew/(map path rule) :: write perms per path let/aeon :: top id hit/(map aeon tako) :: versions by id lab/(map @tas aeon) :: labels @@ -242,6 +242,8 @@ dom/dome :: revision state dok/(unit dork) :: outstanding diffs mer/(unit mery) :: outstanding merges + per/(map path rule) :: read perms per path + pew/(map path rule) :: write perms per path == :: :: :: Foreign request manager. @@ -425,6 +427,8 @@ dom=*dome dok=~ mer=~ + per=~ + pew=~ == :- `hun.u.rom =+ jod=(fall (~(get by dos.u.rom) syd) *dojo) @@ -434,6 +438,8 @@ dom=dom.jod dok=dok.jod mer=mer.jod + per=per.jod + pew=pew.jod == =* red -> =| mow/(list move) @@ -444,7 +450,7 @@ ?~ rom =+ rug=(~(put by rus:(fall (~(get by hoy.ruf) her) *rung)) syd red) ruf(hoy (~(put by hoy.ruf) her rug)) - =+ dos=(~(put by dos.u.rom) syd [qyx dom dok mer]) + =+ dos=(~(put by dos.u.rom) syd [qyx dom dok mer per pew]) ruf(fat (~(put by fat.ruf) her [(need hun) dos])) (flop mow) :: From 72d9a6abd4eee823b4a2bcd431e751fc15787d8e Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 25 Jan 2018 17:22:29 +0100 Subject: [PATCH 123/184] Add new clay cards to gall. --- sys/vane/gall.hoon | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/vane/gall.hoon b/sys/vane/gall.hoon index ef8052251..32d58674c 100644 --- a/sys/vane/gall.hoon +++ b/sys/vane/gall.hoon @@ -1225,6 +1225,8 @@ ~ $cash `%a $conf `%g + $cred `%c + $crew `%c $deal `%g $exec `%f $flog `%d @@ -1234,6 +1236,7 @@ $mont `%c $nuke `%a $ogre `%c + $perm `%c $serv `%e $them `%e $wait `%b From 2b08d7fbd9b9ed00ecd2bf3678a55787ace016b3 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 25 Jan 2018 19:03:22 +0100 Subject: [PATCH 124/184] Make hall and talk always use ost.bol instead of bone 0, which gall now disallows. --- app/hall.hoon | 10 +++++----- app/talk.hoon | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index af486f93f..04ec09826 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -1931,7 +1931,7 @@ %^ circle-wire nom ~[%grams %config-l %group-l] [cir ran] - [0 %pull wir [hos.cir dap.bol] ~] + [ost.bol %pull wir [hos.cir dap.bol] ~] :: ++ sa-eject :> removes ships {sis} from {followers}. @@ -1996,7 +1996,7 @@ |= wir/wire ^- move =+ tar=(wire-to-target wir) - [0 %peer wir [p.tar dap.bol] q.tar] + [ost.bol %peer wir [p.tar dap.bol] q.tar] :: ++ wire-to-target :> ship+path from wire @@ -2091,12 +2091,12 @@ %+ turn ~(tap in ~(key by stories)) |= n/name ^- (list move) - :~ :^ 0 %poke / + :~ :^ ost.bol %poke / :+ [our.bol dap.bol] %hall-action :^ %source n | [[[our.bol nom.qer] ran.qer] ~ ~] :: - :^ 0 %pull + :^ ost.bol %pull %^ circle-wire n ~(tap in wat.qer) [[our.bol nom.qer] ran.qer] [[our.bol dap.bol] ~] @@ -2867,7 +2867,7 @@ :_ +> =+ bov=(above our.bol) ?: =(bov our.bol) ~ - :~ [0 %pull /burden [bov dap.bol] ~] + :~ [ost.bol %pull /burden [bov dap.bol] ~] (wire-to-peer /burden) == ?: =(a 'incoming') diff --git a/app/talk.hoon b/app/talk.hoon index c695479cd..28c007bf2 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -203,7 +203,7 @@ ++ peer-client :> ui state peer move ^- move - :* 0 + :* ost.bol %peer /server/client server @@ -212,7 +212,7 @@ :: ++ peer-inbox ^- move - :* 0 + :* ost.bol %peer /server/inbox server @@ -2438,16 +2438,16 @@ ?: =(a 'reconnect') ~& 'disconnecting and reconnecting to hall...' :_ +> - :~ [0 %pull /server/client server ~] - [0 %pull /server/inbox server ~] + :~ [ost.bol %pull /server/client server ~] + [ost.bol %pull /server/inbox server ~] peer-client peer-inbox == ?: =(a 'reset') ~& 'full reset incoming, hold on to your cli...' :_ +>(grams ~, known ~, count 0) - :~ [0 %pull /server/client server ~] - [0 %pull /server/inbox server ~] + :~ [ost.bol %pull /server/client server ~] + [ost.bol %pull /server/inbox server ~] peer-client peer-inbox == From 68809ff6e8f656bd856c4f8cc1261adc5b0b837a Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 26 Jan 2018 16:24:25 +0100 Subject: [PATCH 125/184] Proposal for accessing request source. --- sys/vane/clay.hoon | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 28532e1cc..7805da841 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -412,9 +412,9 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |% ++ de :: per desk - |= {now/@da hen/duct raft} + |= {now/@da hen/duct src/(unit ship) raft} |= {{our/@p her/@p} syd/desk} - =* ruf +>+<+> + =* ruf +>+<+>+ =+ ^- {hun/(unit duct) rede} =+ rom=(~(get by fat.ruf) her) ?~ rom @@ -3463,6 +3463,12 @@ ((hard task:able) q.hic) == ^+ [p=*(list move) q=..^$] + =/ src/(unit ship) + %+ roll hen + |= {wir/wire src/(unit ship)} + ?^ src src + ?. ?=({$a @ @ *} wir) ~ + `(slav %p i.t.t.wir) ?- -.q.hic $boat :_ ..^$ @@ -3470,7 +3476,7 @@ :: $drop =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen src ruf) [. .]:p.q.hic q.q.hic) abet:drop-me:den [mos ..^$] :: @@ -3478,7 +3484,7 @@ ?: =(%$ q.q.hic) [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen src ruf) [. .]:p.q.hic q.q.hic) abet:(edit:den now r.q.hic) [mos ..^$] :: @@ -3532,7 +3538,7 @@ ?: =(%$ q.q.hic) [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen src ruf) [. .]:p.q.hic q.q.hic) abet:abet:(start:(me:ze:den [r.q.hic s.q.hic] ~ &) t.q.hic u.q.hic) [mos ..^$] :: @@ -3551,7 +3557,7 @@ ?~ dos [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.q.hic q.q.q.hic) + =+ den=((de now hen src ruf) [. .]:p.q.q.hic q.q.q.hic) abet:(mont:den p.q.hic q.q.hic) [mos ..^$] :: @@ -3588,7 +3594,7 @@ :: $warp =^ mos ruf - =+ den=((de now hen ruf) p.q.hic p.q.q.hic) + =+ den=((de now hen src ruf) p.q.hic p.q.q.hic) :: =- ~? ?=([~ %sing %w *] q.q.q.hic) :: :* %someones-warping :: rav=u.q.q.q.hic @@ -3619,7 +3625,7 @@ =+ syd=(slav %tas i.t.q.q.hic) =+ inx=(slav %ud i.t.t.q.q.hic) =^ mos ruf - =+ den=((de now hen ruf) p.q.hic syd) + =+ den=((de now hen src ruf) p.q.hic syd) abet:(take-foreign-update:den inx ((hard (unit rand)) r.q.hic)) [[[hen %give %mack ~] mos] ..^$] :: @@ -3699,7 +3705,7 @@ [~ ~] =+ run=((soft care) ren) ?~ run [~ ~] - =+ den=((de now [/scryduct ~] ruf) [. .]:his syd) + =+ den=((de now [/scryduct ~] `his ruf) [. .]:his syd) =+ (aver:den u.run u.luk tyl) ?~ - - ?~ u.- - @@ -3725,7 +3731,7 @@ |= dojo dom =^ mos ruf - =+ den=((de now hen ruf) [. .]:our syd) + =+ den=((de now hen ~ ruf) [. .]:our syd) abet:abet:(route:(me:ze:den [her sud] kan |) sat dat) [mos ..^$] ?: ?=({$blab care @ @ *} tea) @@ -3756,7 +3762,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ruf) [. .]:our syd) + =+ den=((de now hen ~ ruf) [. .]:our syd) abet:(take-inserting:den wen q.q.hin) [mos ..^$] :: @@ -3766,7 +3772,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ruf) [. .]:our syd) + =+ den=((de now hen ~ ruf) [. .]:our syd) abet:(take-diffing:den wen q.q.hin) [mos ..^$] :: @@ -3776,7 +3782,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ruf) [. .]:our syd) + =+ den=((de now hen ~ ruf) [. .]:our syd) abet:(take-castify:den wen q.q.hin) [mos ..^$] :: @@ -3786,7 +3792,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ruf) [. .]:our syd) + =+ den=((de now hen ~ ruf) [. .]:our syd) abet:(take-mutating:den wen q.q.hin) [mos ..^$] :: @@ -3795,7 +3801,7 @@ =+ our=(slav %p i.t.tea) =+ syd=(slav %tas i.t.t.tea) =^ mos ruf - =+ den=((de now hen ruf) [. .]:our syd) + =+ den=((de now hen ~ ruf) [. .]:our syd) abet:(take-patch:den q.q.hin) [mos ..^$] :: @@ -3804,7 +3810,7 @@ =+ our=(slav %p i.t.tea) =+ syd=(slav %tas i.t.t.tea) =^ mos ruf - =+ den=((de now hen ruf) [. .]:our syd) + =+ den=((de now hen ~ ruf) [. .]:our syd) abet:(take-ergo:den q.q.hin) [mos ..^$] :: @@ -3815,7 +3821,7 @@ =* syd i.t.t.t.tea =+ lem=(slav %da i.t.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ruf) [our her] syd) + =+ den=((de now hen ~ ruf) [our her] syd) abet:(take-foreign-plops:den ?~(lem ~ `lem) q.q.hin) [mos ..^$] :: @@ -3831,7 +3837,7 @@ ->+ =* pax t.t.t.t.t.t.tea =^ mos ruf - =+ den=((de now hen ruf) [our her] syd) + =+ den=((de now hen ~ ruf) [our her] syd) abet:(take-foreign-x:den car cas pax q.q.hin) [mos ..^$] == From 4c846c95a63b62fd818605866ed182c6f25484be Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 26 Jan 2018 22:47:49 +0100 Subject: [PATCH 126/184] More debug pokes, for checking incoming subs and resubscribing to federating children. --- app/hall.hoon | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/hall.hoon b/app/hall.hoon index 04ec09826..69dd39d94 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2847,6 +2847,15 @@ lent=(lent grams.s) known=k mismatch=m + ?: =(a 'check subs') + ~& 'here are all incoming non-circle subs' + ~& ^- (list (pair ship path)) + %+ murn ~(tap by sup.bol) + |= {b/bone s/ship p/path} + ^- (unit (pair ship path)) + ?: ?=({$circle *} p) ~ + `[s p] + [~ +>] ?: =(a 'rebuild') ~& 'rebuilding message references...' =- [~ +>.$(stories -)] @@ -2882,5 +2891,10 @@ |= {n/name s/story} [n src.shape.s] [~ +>] + ?: =(`0 (find "re-listen " (trip a))) + ~& 're-listening' + :_ +> + :_ ~ + (wire-to-peer /report/(crip (slag 10 (trip a)))) [~ +>] -- From c8337088cbaa00c37ba90c80d4e46d50b3c55f35 Mon Sep 17 00:00:00 2001 From: Keaton Dunsford Date: Thu, 1 Feb 2018 12:23:35 -0800 Subject: [PATCH 127/184] Fix indented code blocks to fenced in new /web/testing/umd doc file This was causing syntax errors upon loading the web interface and sending the initial build request to Ford. This commit appears to fix that. For future `.umd` authors, see the `/web/unmark/doc/umd` file for Urbit-flavored markdown syntax. --- web/testing.umd | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/web/testing.umd b/web/testing.umd index d7bf405ca..064c95dca 100644 --- a/web/testing.umd +++ b/web/testing.umd @@ -9,28 +9,34 @@ shape can go in `%/tests` and then are exposed to a system wide test runner. Say you put a test suite in `%/tests/new-hoon/thr.hoon`: - > +ls %/tests - new-hoon/ - > +ls %/tests/new-hoon - ls/hoon mp/hoon myb/hoon thr/hoon +``` +> +ls %/tests +new-hoon/ +> +ls %/tests/new-hoon +ls/hoon mp/hoon myb/hoon thr/hoon +``` You can then just run that individual test suite (and not the ones that are beside it in the `%/tests/new-hoon` directory) with: - > +tests /new-hoon/thr - /new-hoon/thr/test-seconds OK - /new-hoon/thr/test-partition OK - /new-hoon/thr/test-firsts OK - /new-hoon/thr/test-apply OK +``` +> +tests /new-hoon/thr +/new-hoon/thr/test-seconds OK +/new-hoon/thr/test-partition OK +/new-hoon/thr/test-firsts OK +/new-hoon/thr/test-apply OK +``` ## The test file So what is the structure of these test files? They contain a door, with arms starting with `++test-` or `++check-`. At minimum: - /+ tester - |_ tester-type:tester - ++ test-some-test - (expect-eq 4 4 "trivial") - -- +``` +/+ tester +|_ tester-type:tester +++ test-some-test + (expect-eq 4 4 "trivial") +-- +``` All of the utilities you need to write tests are in the tester library. Also, like other hoon files, you can stack cores for models and utility functions with only the final core being inspected for test arms. From 3244cd28029ca46043ef254a4454ec12990d3148 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Feb 2018 21:57:38 +0100 Subject: [PATCH 128/184] No longer deduce request source from duct, but pull from socks in %warp and %west as intended. --- sys/vane/clay.hoon | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 7805da841..94596654a 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -373,6 +373,7 @@ :: :: -- current time `now` :: -- current duct `hen` +:: -- foreign requester `for`, if any :: -- local urbit `our` :: -- target urbit `her` :: -- target desk `syd` @@ -412,7 +413,7 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |% ++ de :: per desk - |= {now/@da hen/duct src/(unit ship) raft} + |= {now/@da hen/duct for/(unit ship) raft} |= {{our/@p her/@p} syd/desk} =* ruf +>+<+>+ =+ ^- {hun/(unit duct) rede} @@ -3463,12 +3464,6 @@ ((hard task:able) q.hic) == ^+ [p=*(list move) q=..^$] - =/ src/(unit ship) - %+ roll hen - |= {wir/wire src/(unit ship)} - ?^ src src - ?. ?=({$a @ @ *} wir) ~ - `(slav %p i.t.t.wir) ?- -.q.hic $boat :_ ..^$ @@ -3476,7 +3471,7 @@ :: $drop =^ mos ruf - =+ den=((de now hen src ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen ~ ruf) [. .]:p.q.hic q.q.hic) abet:drop-me:den [mos ..^$] :: @@ -3484,7 +3479,7 @@ ?: =(%$ q.q.hic) [~ ..^$] =^ mos ruf - =+ den=((de now hen src ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen ~ ruf) [. .]:p.q.hic q.q.hic) abet:(edit:den now r.q.hic) [mos ..^$] :: @@ -3538,7 +3533,7 @@ ?: =(%$ q.q.hic) [~ ..^$] =^ mos ruf - =+ den=((de now hen src ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen ~ ruf) [. .]:p.q.hic q.q.hic) abet:abet:(start:(me:ze:den [r.q.hic s.q.hic] ~ &) t.q.hic u.q.hic) [mos ..^$] :: @@ -3557,7 +3552,7 @@ ?~ dos [~ ..^$] =^ mos ruf - =+ den=((de now hen src ruf) [. .]:p.q.q.hic q.q.q.hic) + =+ den=((de now hen ~ ruf) [. .]:p.q.q.hic q.q.q.hic) abet:(mont:den p.q.hic q.q.hic) [mos ..^$] :: @@ -3594,7 +3589,8 @@ :: $warp =^ mos ruf - =+ den=((de now hen src ruf) p.q.hic p.q.q.hic) + =+ for=?:(=(p.p.q.hic q.p.q.hic) ~&(%local-warp ~) `q.p.q.hic) + =+ den=((de now hen for ruf) p.q.hic p.q.q.hic) :: =- ~? ?=([~ %sing %w *] q.q.q.hic) :: :* %someones-warping :: rav=u.q.q.q.hic @@ -3625,7 +3621,8 @@ =+ syd=(slav %tas i.t.q.q.hic) =+ inx=(slav %ud i.t.t.q.q.hic) =^ mos ruf - =+ den=((de now hen src ruf) p.q.hic syd) + =+ for=?:(=(p.p.q.hic q.p.q.hic) ~&(%local-west ~) `q.p.q.hic) + =+ den=((de now hen for ruf) p.q.hic syd) abet:(take-foreign-update:den inx ((hard (unit rand)) r.q.hic)) [[[hen %give %mack ~] mos] ..^$] :: @@ -3705,7 +3702,15 @@ [~ ~] =+ run=((soft care) ren) ?~ run [~ ~] - =+ den=((de now [/scryduct ~] `his ruf) [. .]:his syd) + ::TODO if it ever gets filled properly, pass in the full fur. + =/ for/(unit ship) + %- ~(rep in (fall fur ~)) + |= {m/monk s/(unit ship)} + ?^ s s + ?: ?=($| -.m) ~ + ?: =(p.m his) ~ + `p.m + =+ den=((de now [/scryduct ~] ?:(=(for `his) ~ for) ruf) [. .]:his syd) =+ (aver:den u.run u.luk tyl) ?~ - - ?~ u.- - From 1b231e82f81fb8cb53b3d21baf544532db2bef1e Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 6 Feb 2018 22:18:25 +0100 Subject: [PATCH 129/184] Implement %perm clay request for setting permissions of a node. --- sys/vane/clay.hoon | 24 ++++++++++++++++++++++++ sys/zuse.hoon | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 94596654a..823100f1e 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -792,6 +792,23 @@ (lobe-to-silk:ze a p.-) == :: + :: Set permissions for a node. + :: + ++ perm + |= {pax/path rit/rite} + ^+ +> + =< (emit hen %give %mack ~) + ?- -.rit + $r wake(per (put-perm per pax red.rit)) + $w wake(pew (put-perm pew pax wit.rit)) + $rw wake(per (put-perm per pax red.rit), pew (put-perm pew pax wit.rit)) + == + :: + ++ put-perm + |= {pes/(map path rule) pax/path new/(unit rule)} + ?~ new (~(del by pes) pax) + (~(put by pes) pax u.new) + :: :: Cancel a request. :: :: For local requests, we just remove it from `qyx`. For foreign requests, @@ -3586,6 +3603,13 @@ (skim ~(tap by mon.ruf) (corl (cury test p.q.hic) tail)) |= {pot/term bem/beam} [u.hez.ruf %give %ogre pot] + :: + $perm + =^ mos ruf + ::TODO after new boot system, just use our from global. + =+ den=((de now hen ~ ruf) [. .]:our.q.hic des.q.hic) + abet:(perm:den pax.q.hic rit.q.hic) + [mos ..^$] :: $warp =^ mos ruf diff --git a/sys/zuse.hoon b/sys/zuse.hoon index e6c4b0029..1deb4daf3 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -407,7 +407,7 @@ {$mont p/desk q/beam} :: mount to unix {$dirk p/desk} :: mark mount dirty {$ogre p/$@(desk beam)} :: delete mount point - {$perm des/desk pax/path rit/rite} :: change permissions + {$perm our/ship des/desk pax/path rit/rite} :: change permissions {$warp p/sock q/riff} :: file request {$wegh $~} :: report memory {$went p/sack q/path r/@ud s/coop} :: response confirm From 6a67b1191543664ddc09c8fda5d8cf686e3281d2 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 7 Feb 2018 01:34:09 +0100 Subject: [PATCH 130/184] Request sources are now properly bound to the requests, rather than only passed into the desk core initially. --- sys/vane/clay.hoon | 167 ++++++++++++++++++++++++--------------------- 1 file changed, 90 insertions(+), 77 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 823100f1e..49b1e02ca 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -56,7 +56,7 @@ :: A map of requests to a set of all the subscribers who should be notified :: when the request is filled/updated. :: -++ cult (jug rove duct) +++ cult (jug wove duct) :: :: Domestic desk state. :: @@ -277,6 +277,7 @@ :: Generally used when we store a request in our state somewhere. :: ++ cach (unit (unit (each cage lobe))) :: cached result +++ wove {p/(unit ship) q/rove} :: stored source + req ++ rove :: stored request $% {$sing p/mood} :: single request {$next p/mood q/cach} :: next version @@ -413,9 +414,9 @@ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |% ++ de :: per desk - |= {now/@da hen/duct for/(unit ship) raft} + |= {now/@da hen/duct raft} |= {{our/@p her/@p} syd/desk} - =* ruf +>+<+>+ + =* ruf +>+<+> =+ ^- {hun/(unit duct) rede} =+ rom=(~(get by fat.ruf) her) ?~ rom @@ -458,14 +459,14 @@ :: Handle `%sing` requests :: ++ aver - |= mun/mood + |= {for/(unit ship) mun/mood} ^- (unit (unit (each cage lobe))) =+ ezy=?~(ref ~ (~(get by haw.u.ref) mun)) ?^ ezy `(bind u.ezy |=(a/cage [%& a])) =+ nao=(case-to-aeon:ze q.mun) :: ~& [%aver-mun nao [%from syd lim q.mun]] - ?~(nao ~ (read-at-aeon:ze u.nao mun)) + ?~(nao ~ (read-at-aeon:ze for u.nao mun)) :: ++ ford-fail |=(tan/tang ~|(%ford-fail (mean tan))) :: @@ -662,14 +663,14 @@ :: foreign ship. :: ++ duce :: produce request - |= rov/rove + |= wov/wove ^+ +> - =. rov (dedupe rov) - =. qyx (~(put ju qyx) rov hen) + =. wov (dedupe wov) + =. qyx (~(put ju qyx) wov hen) ?~ ref - (mabe rov |=(@da (bait hen +<))) + (mabe q.wov |=(@da (bait hen +<))) |- ^+ +>+.$ - =+ rav=(reve rov) + =+ rav=(reve q.wov) =+ ^= vaw ^- rave ?. ?=({$sing $v *} rav) rav [%many %| [%ud let.dom] `case`q.p.rav r.p.rav] @@ -691,17 +692,21 @@ :: all get filled at once. :: ++ dedupe :: find existing alias - |= rov/rove ^- rove - =; ron/(unit rove) (fall ron rov) + |= wov/wove + ^- wove + =; won/(unit wove) (fall won wov) + =* rov q.wov ?- -.rov $sing ~ $next =+ aey=(case-to-aeon:ze q.p.rov) ?~ aey ~ - %+ roll ~(tap in ~(key by qyx)) - |= {hav/rove res/(unit rove)} + %- ~(rep in ~(key by qyx)) + |= {haw/wove res/(unit wove)} ?^ res res - =- ?:(- `hav ~) + ?. =(p.wov p.haw) ~ + =* hav q.haw + =- ?:(- `haw ~) ?& ?=($next -.hav) =(p.hav p.rov(q q.p.hav)) :: @@ -714,10 +719,12 @@ $mult =+ aey=(case-to-aeon:ze p.p.rov) ?~ aey ~ - %+ roll ~(tap in ~(key by qyx)) - |= {hav/rove res/(unit rove)} + %- ~(rep in ~(key by qyx)) + |= {haw/wove res/(unit wove)} ?^ res res - =- ?:(- `hav ~) + ?. =(p.wov p.haw) ~ + =* hav q.haw + =- ?:(- `haw ~) ?& ?=($mult -.hav) =(p.hav p.rov(p p.p.hav)) :: @@ -735,10 +742,12 @@ $many =+ aey=(case-to-aeon:ze p.q.rov) ?~ aey ~ - %+ roll ~(tap in ~(key by qyx)) - |= {hav/rove res/(unit rove)} + %- ~(rep in ~(key by qyx)) + |= {haw/wove res/(unit wove)} ?^ res res - =- ?:(- `hav ~) + ?. =(p.wov p.haw) ~ + =* hav q.haw + =- ?:(- `haw ~) ?& ?=($many -.hav) =(hav rov(p.q p.q.hav)) :: @@ -816,17 +825,17 @@ :: ++ cancel-request :: release request ^+ . - =^ ros/(list rove) qyx + =^ wos/(list wove) qyx :_ (~(run by qyx) |=(a/(set duct) (~(del in a) hen))) %- ~(rep by qyx) - |= {{a/rove b/(set duct)} c/(list rove)} + |= {{a/wove b/(set duct)} c/(list wove)} ?.((~(has in b) hen) c [a c]) ?~ ref => .(ref `(unit rind)`ref) :: XX TMI - ?: =(~ ros) + :: XX handle? + ?: =(~ wos) + :: XX handle? |- ^+ +> - ?~ ros +> - $(ros t.ros, +> (mabe i.ros |=(@da (best hen +<)))) + ?~ wos +> + $(wos t.wos, +> (mabe q.i.wos |=(@da (best hen +<)))) ^+ ..cancel-request =+ nux=(~(get by fod.u.ref) hen) ?~ nux ..cancel-request @@ -844,13 +853,13 @@ :: and then waiting if the subscription range extends into the future. :: ++ start-request - |= rav/rave + |= {for/(unit ship) rav/rave} ^+ +> ?- -.rav $sing - =+ ver=(aver p.rav) + =+ ver=(aver for p.rav) ?~ ver - (duce rav) + (duce for rav) ?~ u.ver (blub hen) (blab hen p.rav u.u.ver) @@ -903,9 +912,11 @@ new/(map (pair care path) cach) == ^+ ..start-request + %+ duce for + ^- rove ?: ?=($mult -.rav) - (duce -.rav p.rav nex old new) - %^ duce -.rav p.rav + [-.rav p.rav nex old new] + :+ -.rav p.rav =+ ole=~(tap by old) ?> (lte (lent ole) 1) ?~ ole ~ @@ -929,26 +940,26 @@ %+ turn ~(tap by req) |= {c/care p/path} ^- (pair (pair care path) cach) - [[c p] (aver c cas p)] + [[c p] (aver for c cas p)] -- :: $many =+ nab=(case-to-aeon:ze p.q.rav) ?~ nab ?> =(~ (case-to-aeon:ze q.q.rav)) - (duce [- p q ~]:rav) + (duce for [- p q ~]:rav) =+ huy=(case-to-aeon:ze q.q.rav) ?: &(?=(^ huy) |((lth u.huy u.nab) &(=(0 u.huy) =(0 u.nab)))) (blub hen) =+ top=?~(huy let.dom u.huy) - =+ ear=(lobes-at-path:ze top r.q.rav) + =+ ear=(lobes-at-path:ze for top r.q.rav) =. +>.$ (bleb hen u.nab ?:(p.rav ~ `[u.nab top])) ?^ huy (blub hen) =+ ^= ptr ^- case [%ud +(let.dom)] - (duce `rove`[%many p.rav [ptr q.q.rav r.q.rav] ear]) + (duce for `rove`[%many p.rav [ptr q.q.rav r.q.rav] ear]) == :: :: Print a summary of changes to dill. @@ -1774,32 +1785,34 @@ ++ wake :: update subscribers ^+ . =+ xiq=~(tap by qyx) - =| xaq/(list {p/rove q/(set duct)}) + =| xaq/(list {p/wove q/(set duct)}) |- ^+ ..wake ?~ xiq ..wake(qyx (~(gas by *cult) xaq)) ?: =(~ q.i.xiq) $(xiq t.xiq, xaq xaq) :: drop forgotten - ?- -.p.i.xiq + =* for p.p.i.xiq + =* rov q.p.i.xiq + ?- -.rov $sing - =+ cas=?~(ref ~ (~(get by haw.u.ref) `mood`p.p.i.xiq)) + =+ cas=?~(ref ~ (~(get by haw.u.ref) `mood`p.rov)) ?^ cas %= $ xiq t.xiq ..wake ?~ u.cas (blub-all q.i.xiq ~) - (blab-all q.i.xiq p.p.i.xiq %& u.u.cas) + (blab-all q.i.xiq p.rov %& u.u.cas) == - =+ nao=(case-to-aeon:ze q.p.p.i.xiq) + =+ nao=(case-to-aeon:ze q.p.rov) ?~ nao $(xiq t.xiq, xaq [i.xiq xaq]) :: ~& %reading-at-aeon - =+ vid=(read-at-aeon:ze u.nao p.p.i.xiq) + =+ vid=(read-at-aeon:ze for u.nao p.rov) :: ~& %red-at-aeon ?~ vid :: ?: =(0 u.nao) - :: ~& [%oh-poor `path`[syd '0' r.p.p.i.xiq]] + :: ~& [%oh-poor `path`[syd '0' r.p.rov]] :: $(xiq t.xiq) - :: ~& [%oh-well desk=syd mood=p.p.i.xiq aeon=u.nao] + :: ~& [%oh-well desk=syd mood=p.rov aeon=u.nao] $(xiq t.xiq, xaq [i.xiq xaq]) - $(xiq t.xiq, ..wake (balk-all q.i.xiq u.vid p.p.i.xiq)) + $(xiq t.xiq, ..wake (balk-all q.i.xiq u.vid p.rov)) :: :: %next is just %mult with one path, so we pretend %next = %mult here. ?($next $mult) @@ -1808,7 +1821,7 @@ :: {old} is the revision at {(dec yon)}, {new} is the revision at {yon}. :: if we have no {yon} yet, that means it was still unknown last time :: we checked. - =* vor p.i.xiq + =* vor rov |^ =/ rov/rove ?: ?=($mult -.vor) vor @@ -1874,7 +1887,7 @@ ++ store :: check again later |= rov/rove ^+ ..wake - =- ^^$(xiq t.xiq, xaq [i.xiq(p -) xaq]) + =- ^^$(xiq t.xiq, xaq [i.xiq(p [for -]) xaq]) ?> ?=($mult -.rov) ?: ?=($mult -.vor) rov ?> ?=({* $~ $~} r.rov) @@ -1901,7 +1914,7 @@ ++ read-unknown :: fill in the blanks |= {mol/mool hav/(map (pair care path) cach)} %. |= {{c/care p/path} o/cach} - ?^(o o (aver c p.mol p)) + ?^(o o (aver for c p.mol p)) =- ~(urn by -) ?^ hav hav %- ~(gas by *(map (pair care path) cach)) @@ -1909,8 +1922,8 @@ -- :: $many - =+ mot=`moat`q.p.i.xiq - =* sav r.p.i.xiq + =+ mot=`moat`q.rov + =* sav r.rov =+ nab=(case-to-aeon:ze p.mot) ?~ nab $(xiq t.xiq, xaq [i.xiq xaq]) @@ -1919,19 +1932,19 @@ =. p.mot [%ud +(let.dom)] %= $ xiq t.xiq - xaq [i.xiq(q.p mot) xaq] + xaq [i.xiq(q.q.p mot) xaq] ..wake =+ ^= ear - (lobes-at-path:ze let.dom r.mot) + (lobes-at-path:ze for let.dom r.mot) ?: =(sav ear) ..wake - (bleb-all q.i.xiq let.dom ?:(p.p.i.xiq ~ `[u.nab let.dom])) + (bleb-all q.i.xiq let.dom ?:(p.rov ~ `[u.nab let.dom])) == %= $ xiq t.xiq ..wake =- (blub-all:- q.i.xiq ~) =+ ^= ear - (lobes-at-path:ze u.huy r.mot) + (lobes-at-path:ze for u.huy r.mot) ?: =(sav ear) (blub-all q.i.xiq ~) - (bleb-all q.i.xiq +(u.nab) ?:(p.p.i.xiq ~ `[u.nab u.huy])) + (bleb-all q.i.xiq +(u.nab) ?:(p.rov ~ `[u.nab u.huy])) == == ++ drop-me @@ -2221,7 +2234,7 @@ :: Gets a map of the data at the given path and all children of it. :: ++ lobes-at-path - |= {yon/aeon pax/path} + |= {for/(unit ship) yon/aeon pax/path} ^- (map path lobe) ?: =(0 yon) ~ %- malt @@ -2488,7 +2501,7 @@ :: Should change last few lines to an explicit ++read-w. :: ++ read-at-aeon :: read-at-aeon:ze - |= {yon/aeon mun/mood} :: seek and read + |= {for/(unit ship) yon/aeon mun/mood} :: seek and read ^- (unit (unit (each cage lobe))) ?: &(?=($w p.mun) !?=($ud -.q.mun)) :: NB only her speed ?^(r.mun [~ ~] [~ ~ %& %aeon !>(yon)]) @@ -3488,7 +3501,7 @@ :: $drop =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) abet:drop-me:den [mos ..^$] :: @@ -3496,7 +3509,7 @@ ?: =(%$ q.q.hic) [~ ..^$] =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) abet:(edit:den now r.q.hic) [mos ..^$] :: @@ -3550,7 +3563,7 @@ ?: =(%$ q.q.hic) [~ ..^$] =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) abet:abet:(start:(me:ze:den [r.q.hic s.q.hic] ~ &) t.q.hic u.q.hic) [mos ..^$] :: @@ -3569,7 +3582,7 @@ ?~ dos [~ ..^$] =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:p.q.q.hic q.q.q.hic) + =+ den=((de now hen ruf) [. .]:p.q.q.hic q.q.q.hic) abet:(mont:den p.q.hic q.q.hic) [mos ..^$] :: @@ -3607,14 +3620,13 @@ $perm =^ mos ruf ::TODO after new boot system, just use our from global. - =+ den=((de now hen ~ ruf) [. .]:our.q.hic des.q.hic) + =+ den=((de now hen ruf) [. .]:our.q.hic des.q.hic) abet:(perm:den pax.q.hic rit.q.hic) [mos ..^$] :: $warp =^ mos ruf - =+ for=?:(=(p.p.q.hic q.p.q.hic) ~&(%local-warp ~) `q.p.q.hic) - =+ den=((de now hen for ruf) p.q.hic p.q.q.hic) + =+ den=((de now hen ruf) p.q.hic p.q.q.hic) :: =- ~? ?=([~ %sing %w *] q.q.q.hic) :: :* %someones-warping :: rav=u.q.q.q.hic @@ -3624,7 +3636,8 @@ =< abet ?~ q.q.q.hic cancel-request:den - (start-request:den u.q.q.q.hic) + =+ for=?:(=(p.p.q.hic q.p.q.hic) ~&(%local-warp ~) `q.p.q.hic) + (start-request:den for u.q.q.q.hic) [mos ..^$] :: $went @@ -3639,14 +3652,14 @@ :- hen :^ %pass [(scot %p p.p.q.hic) (scot %p q.p.q.hic) t.q.q.hic] %c + ::TODO ...so, this circumvents permission checks? [%warp [p.p.q.hic p.p.q.hic] ryf] == ?> ?=({$answer @ @ $~} q.q.hic) =+ syd=(slav %tas i.t.q.q.hic) =+ inx=(slav %ud i.t.t.q.q.hic) =^ mos ruf - =+ for=?:(=(p.p.q.hic q.p.q.hic) ~&(%local-west ~) `q.p.q.hic) - =+ den=((de now hen for ruf) p.q.hic syd) + =+ den=((de now hen ruf) p.q.hic syd) abet:(take-foreign-update:den inx ((hard (unit rand)) r.q.hic)) [[[hen %give %mack ~] mos] ..^$] :: @@ -3734,8 +3747,8 @@ ?: ?=($| -.m) ~ ?: =(p.m his) ~ `p.m - =+ den=((de now [/scryduct ~] ?:(=(for `his) ~ for) ruf) [. .]:his syd) - =+ (aver:den u.run u.luk tyl) + =+ den=((de now [/scryduct ~] ruf) [. .]:his syd) + =+ (aver:den for u.run u.luk tyl) ?~ - - ?~ u.- - ?: ?=($& -.u.u.-) ``p.u.u.- @@ -3760,7 +3773,7 @@ |= dojo dom =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:our syd) + =+ den=((de now hen ruf) [. .]:our syd) abet:abet:(route:(me:ze:den [her sud] kan |) sat dat) [mos ..^$] ?: ?=({$blab care @ @ *} tea) @@ -3791,7 +3804,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:our syd) + =+ den=((de now hen ruf) [. .]:our syd) abet:(take-inserting:den wen q.q.hin) [mos ..^$] :: @@ -3801,7 +3814,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:our syd) + =+ den=((de now hen ruf) [. .]:our syd) abet:(take-diffing:den wen q.q.hin) [mos ..^$] :: @@ -3811,7 +3824,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:our syd) + =+ den=((de now hen ruf) [. .]:our syd) abet:(take-castify:den wen q.q.hin) [mos ..^$] :: @@ -3821,7 +3834,7 @@ =+ syd=(slav %tas i.t.t.tea) =+ wen=(slav %da i.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:our syd) + =+ den=((de now hen ruf) [. .]:our syd) abet:(take-mutating:den wen q.q.hin) [mos ..^$] :: @@ -3830,7 +3843,7 @@ =+ our=(slav %p i.t.tea) =+ syd=(slav %tas i.t.t.tea) =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:our syd) + =+ den=((de now hen ruf) [. .]:our syd) abet:(take-patch:den q.q.hin) [mos ..^$] :: @@ -3839,7 +3852,7 @@ =+ our=(slav %p i.t.tea) =+ syd=(slav %tas i.t.t.tea) =^ mos ruf - =+ den=((de now hen ~ ruf) [. .]:our syd) + =+ den=((de now hen ruf) [. .]:our syd) abet:(take-ergo:den q.q.hin) [mos ..^$] :: @@ -3850,7 +3863,7 @@ =* syd i.t.t.t.tea =+ lem=(slav %da i.t.t.t.t.tea) =^ mos ruf - =+ den=((de now hen ~ ruf) [our her] syd) + =+ den=((de now hen ruf) [our her] syd) abet:(take-foreign-plops:den ?~(lem ~ `lem) q.q.hin) [mos ..^$] :: @@ -3866,7 +3879,7 @@ ->+ =* pax t.t.t.t.t.t.tea =^ mos ruf - =+ den=((de now hen ~ ruf) [our her] syd) + =+ den=((de now hen ruf) [our her] syd) abet:(take-foreign-x:den car cas pax q.q.hin) [mos ..^$] == From 8b0b82eb729d5166f8a07a2bf6a51012208f4b49 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 7 Feb 2018 21:04:07 +0100 Subject: [PATCH 131/184] Implemented permission checks for read requests. --- sys/vane/clay.hoon | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 49b1e02ca..390f6dec8 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -2355,6 +2355,41 @@ ?^(r.mun ~ !!) :: [~ %w !>([t.yak (forge-nori yak)])])-all (query(ank.dom ank:(descend-path:(zu ank.dom) r.mun)) p.mun) :: dead code :: + :: + ++ may-read + |= {who/ship car/care yon/aeon pax/path} + ^- ? + ?+ car + (allowed-by who pax per.red) + :: + ?($y $z) + =+ tak=(~(get by hit.dom) yon) + ?~ tak | + =+ yak=(tako-to-yaki u.tak) + =+ len=(lent pax) + %+ levy ~(tap by (~(del in ~(key by q.yak)) pax)) + |= p/path + ?& =(pax (scag len p)) + |(?=($z car) =(+(len) (lent p))) + == + == + :: + ++ may-write + |= {w/ship p/path} + (allowed-by w p pew.red) + :: + ++ allowed-by + |= {who/ship pax/path pes/(map path rule)} + ^- ? + =+ rul=rul:(read-p-in pax pes) + =- =(0 -) + %+ mix ?=($black mod.rul) + %- ~(rep in who.rul) + |= {w/whom h/?} + ?: h & + ?: ?=($& -.w) =(w &+who) + (~(has in (fall (~(get by cez) p.w) ~)) who) + :: :: Checks for existence of a node at an aeon. :: :: This checks for existence of content at the node, and does *not* look @@ -2503,6 +2538,8 @@ ++ read-at-aeon :: read-at-aeon:ze |= {for/(unit ship) yon/aeon mun/mood} :: seek and read ^- (unit (unit (each cage lobe))) + ?. |(?=($~ for) (may-read u.for p.mun yon r.mun)) + ~ ?: &(?=($w p.mun) !?=($ud -.q.mun)) :: NB only her speed ?^(r.mun [~ ~] [~ ~ %& %aeon !>(yon)]) ?: ?=($d p.mun) From 3f7e76cca5746c81943fe46f4ff9cdc7f43eb253 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 7 Feb 2018 21:07:42 +0100 Subject: [PATCH 132/184] Implement requests for reading and writing permission groups. --- sys/vane/clay.hoon | 17 +++++++++++++++++ sys/zuse.hoon | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 390f6dec8..56b735f6e 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3535,6 +3535,23 @@ $boat :_ ..^$ [hen %give %hill (turn ~(tap by mon.ruf) head)]~ + ::. + $cred + =. cez.ruf + ?~ cew.q.hic (~(del by cez.ruf) nom.q.hic) + (~(put by cez.ruf) nom.q.hic cew.q.hic) + :: wake all desks, a request may have been affected. + =| mos/(list move) + =+ rom=(fall (~(get by fat.ruf) our.q.hic) *room) + =+ des=~(tap in ~(key by dos.rom)) + |- + ?~ des [[[hen %give %mack ~] mos] ..^^$] + =+ den=((de now hen ruf) [. .]:our.q.hic i.des) + =^ mor ruf abet:wake:den + $(des t.des, mos (weld mos mor)) + :: + $crew + [[hen %give %cruz cez.ruf]~ ..^$] :: $drop =^ mos ruf diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 1deb4daf3..73abafece 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -381,7 +381,7 @@ ++ able ^? |% ++ gift :: out result <-$ - $% {$cruz cez/(map @tas crew)} :: permission groups + $% {$cruz cez/(map @ta crew)} :: permission groups {$dirk p/@tas} :: mark mount dirty {$ergo p/@tas q/mode} :: version update {$hill p/(list @tas)} :: mount points @@ -397,8 +397,8 @@ == :: ++ task :: in request ->$ $% {$boat $~} :: pier rebooted - {$cred nom/@ta cew/crew} :: set permission group - {$crew $~} :: permission groups + {$cred our/ship nom/@ta cew/crew} :: set permission group + {$crew our/ship} :: permission groups {$drop p/@p q/desk} :: cancel pending merge {$info p/@p q/desk r/nori} :: internal edit {$init p/@p} :: report install From c890dad27147256e52d20ae0045287e4aa1dea53 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 7 Feb 2018 21:11:25 +0100 Subject: [PATCH 133/184] Support %p requests. --- sys/vane/clay.hoon | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 56b735f6e..af82b31d5 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -1528,6 +1528,9 @@ ?- p.p.u.rut $d ~| %totally-temporary-error-please-replace-me + !! + $p + ~| %requesting-foreign-permissions-is-invalid !! $u ~| %im-thinkin-its-prolly-a-bad-idea-to-request-rang-over-the-network @@ -2327,9 +2330,10 @@ :: eliminate ++read and ++query :: ++ query :: query:ze - |= ren/$?($u $v $x $y $z) :: endpoint query + |= ren/$?($p $u $v $x $y $z) :: endpoint query ^- (unit cage) ?- ren + $p !! $u !! :: [~ %null [%atom %n] ~] $v [~ %dome !>(dom)] $x !! :: ?~(q.ank.dom ~ [~ q.u.q.ank.dom]) @@ -2355,12 +2359,35 @@ ?^(r.mun ~ !!) :: [~ %w !>([t.yak (forge-nori yak)])])-all (query(ank.dom ank:(descend-path:(zu ank.dom) r.mun)) p.mun) :: dead code :: + :: Gets the permissions that apply to a particular node. + :: + :: If the node has no permissions of its own, we use its parent's. + :: If no permissions have been set for the entire tree above the node, + :: we default to fully private (empty whitelist). + :: + ++ read-p + |= pax/path + ^- (unit (unit (each cage lobe))) + =- [~ ~ %& %noun !>(-)] + :- (read-p-in pax per.red) + (read-p-in pax pew.red) + :: + ++ read-p-in + |= {pax/path pes/(map path rule)} + ^- dict + =+ rul=(~(get by pes) pax) + ?^ rul [pax u.rul] + ?~ pax [/ %white ~] + $(pax t.pax) :: ++ may-read |= {who/ship car/care yon/aeon pax/path} ^- ? ?+ car (allowed-by who pax per.red) + :: + $p + =(who our) :: ?($y $z) =+ tak=(~(get by hit.dom) yon) @@ -2549,6 +2576,8 @@ ?^ r.mun ~&(%no-cd-path [~ ~]) [~ ~ %& %noun !>(~(key by dos.u.rom))] + ?: ?=($p p.mun) + (read-p r.mun) ?: ?=($u p.mun) (read-u yon r.mun) ?: ?=($v p.mun) From f296c9bbae9f744353b969f12f9b9ec5f5dd9ed1 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 7 Feb 2018 22:14:59 +0100 Subject: [PATCH 134/184] Ensure local copies of foreign desks are always fully accessible. --- sys/vane/clay.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index af82b31d5..ad8a3aa94 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -429,8 +429,8 @@ dom=*dome dok=~ mer=~ - per=~ - pew=~ + per=[[/ %black ~] ~ ~] + pew=[[/ %black ~] ~ ~] == :- `hun.u.rom =+ jod=(fall (~(get by dos.u.rom) syd) *dojo) From f0ee4032855d02831bd7f0d5ccb701cf9a5aa8d7 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 7 Feb 2018 22:28:33 +0100 Subject: [PATCH 135/184] Misc small cleanup. --- sys/vane/clay.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index ad8a3aa94..19de5fd56 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -353,7 +353,7 @@ {$writ p/riot} :: == == :: $: $f :: - $% {$made p/@uvH q/gage:ford} :: + $% {$made p/@uvH q/gage:ford} :: == == :: $: $t :: $% {$wake $~} :: timer activate @@ -1971,7 +1971,7 @@ :: and content :: -- creating commits and content and adding them to the tree :: -- finding which data needs to be sent over the network to keep the - :: -- other urbit up-to-date + :: other urbit up-to-date :: -- reading from the file tree through different `++care` options :: -- the `++me` core for merging. :: @@ -3719,7 +3719,7 @@ =< abet ?~ q.q.q.hic cancel-request:den - =+ for=?:(=(p.p.q.hic q.p.q.hic) ~&(%local-warp ~) `q.p.q.hic) + =+ for=?:(=(p.p.q.hic q.p.q.hic) ~ `q.p.q.hic) (start-request:den for u.q.q.q.hic) [mos ..^$] :: From 91fe74d7d6dea5a523bd52f7108e0f53e2746cf9 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 8 Feb 2018 00:42:40 +0100 Subject: [PATCH 136/184] Add requester ship to clay's %warp task to aid in permission checks for %wests. --- lib/hood/kiln.hoon | 12 ++++++------ sys/vane/clay.hoon | 19 +++++++++---------- sys/vane/dill.hoon | 4 ++-- sys/vane/ford.hoon | 8 ++++---- sys/zuse.hoon | 2 +- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/lib/hood/kiln.hoon b/lib/hood/kiln.hoon index 1b6d1327d..e9c12522f 100644 --- a/lib/hood/kiln.hoon +++ b/lib/hood/kiln.hoon @@ -70,7 +70,7 @@ {$poke wire dock pear} :: {$wipe wire @p $~} :: {$wait wire @da} :: - {$warp wire sock riff} :: + {$warp wire ship sock riff} :: == :: ++ pear :: poke fruit $% {$hall-command command:hall} :: @@ -222,7 +222,7 @@ ++ subscribe-next %- emit ^- card - :* %warp /kiln/autoload [our our] %home ~ + :* %warp /kiln/autoload our [our our] %home ~ %next %z da+now /sys == :: @@ -349,7 +349,7 @@ %- blab :_ ~ :* ust %warp /kiln/sync/[syd]/(scot %p her)/[sud] - [our her] sud ~ + our [our her] sud ~ == :: ++ start-track @@ -358,7 +358,7 @@ %- blab :~ :* ost %warp /kiln/sync/[syd]/(scot %p her)/[sud] - [our her] sud ~ %sing %y ud+let / + our [our her] sud ~ %sing %y ud+let / == == :: ++ start-sync @@ -367,7 +367,7 @@ %- blab :~ :* ost %warp [%kiln %sync syd (scot %p her) sud ?:(reset /reset /)] - [our her] sud ~ %sing %w [%da now] / + our [our her] sud ~ %sing %w [%da now] / == == :: ++ writ @@ -414,7 +414,7 @@ %- blab :_ ~ :* ost %warp /kiln/sync/[syd]/(scot %p her)/[sud] - [our her] sud ~ %sing %y ud+let / + our [our her] sud ~ %sing %y ud+let / == -- :: diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 19de5fd56..2a1cecbe5 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -329,7 +329,7 @@ $: $c :: to %clay $% {$info p/@p q/@tas r/nori} :: internal edit {$merg p/@p q/@tas r/@p s/@tas t/case u/germ} :: merge desks - {$warp p/sock q/riff} :: + {$warp p/ship q/sock r/riff} :: == == :: $: $d :: $% {$flog p/{$crud p/@tas q/(list tank)}} :: to %dill @@ -2777,7 +2777,7 @@ %- emit(wat.dat %ali) :* hen %pass [%merge (scot %p p.bob) q.bob (scot %p p.ali) q.ali %ali ~] - %c %warp [p.bob p.ali] q.ali + %c %warp p.bob [p.bob p.ali] q.ali `[%sing %v cas.dat /] == :: @@ -3709,18 +3709,18 @@ :: $warp =^ mos ruf - =+ den=((de now hen ruf) p.q.hic p.q.q.hic) - :: =- ~? ?=([~ %sing %w *] q.q.q.hic) + =+ den=((de now hen ruf) q.q.hic p.r.q.hic) + :: =- ~? ?=([~ %sing %w *] q.r.q.hic) :: :* %someones-warping - :: rav=u.q.q.q.hic + :: rav=u.q.r.q.hic :: mos=-< :: == :: - =< abet - ?~ q.q.q.hic + ?~ q.r.q.hic cancel-request:den - =+ for=?:(=(p.p.q.hic q.p.q.hic) ~ `q.p.q.hic) - (start-request:den for u.q.q.q.hic) + =+ for=?:(=(p.q.hic p.q.q.hic) ~ `p.q.hic) + (start-request:den for u.q.r.q.hic) [mos ..^$] :: $went @@ -3735,8 +3735,7 @@ :- hen :^ %pass [(scot %p p.p.q.hic) (scot %p q.p.q.hic) t.q.q.hic] %c - ::TODO ...so, this circumvents permission checks? - [%warp [p.p.q.hic p.p.q.hic] ryf] + [%warp q.p.q.hic [p.p.q.hic p.p.q.hic] ryf] == ?> ?=({$answer @ @ $~} q.q.hic) =+ syd=(slav %tas i.t.q.q.hic) diff --git a/sys/vane/dill.hoon b/sys/vane/dill.hoon index 76983aa7d..43b423a45 100644 --- a/sys/vane/dill.hoon +++ b/sys/vane/dill.hoon @@ -47,7 +47,7 @@ == :: ++ note-clay :: $% {$merg p/@p q/@tas r/@p s/@tas t/case u/germ:clay}:: merge desks - {$warp p/sock q/riff:clay} :: wait for clay hack + {$warp p/ship q/sock r/riff:clay} :: wait for clay hack == :: ++ note-dill :: note to self, odd $% {$crud p/@tas q/(list tank)} :: @@ -297,7 +297,7 @@ %pass / %c - [%warp [our our] %base `[%sing %y [%ud 1] /]] + [%warp our [our our] %base `[%sing %y [%ud 1] /]] == == :: diff --git a/sys/vane/ford.hoon b/sys/vane/ford.hoon index 3e2a20afd..0d31637fb 100644 --- a/sys/vane/ford.hoon +++ b/sys/vane/ford.hoon @@ -12,7 +12,7 @@ ++ move {p/duct q/(wind note gift:able)} :: local move ++ note :: out request $-> $% $: $c :: to %clay - $% {$warp p/sock q/riff:clay} :: + $% {$warp p/ship q/sock r/riff:clay} :: == == :: $: $f :: to %ford $% {$exec p/@p q/(unit bilk:ford)} :: @@ -294,7 +294,7 @@ |= {ren/care:clay bem/beam ask/?} :: ~& warp+[(en-beam bem) ask] :+ %pass [(scot %p our) ren (en-beam bem)] - [%c [%warp [our p.bem] q.bem ?.(ask ~ `[%next ren r.bem (flop s.bem)])]] + [%c [%warp our [our p.bem] q.bem ?.(ask ~ `[%next ren r.bem (flop s.bem)])]] :: :: ++ zo @@ -321,7 +321,7 @@ |= {van/vane ren/care:clay bem/beam} ^- (wind note gift:able) ?+ van ~|(stub-cancel+van !!) - $c [%pass (camp-wire +<) van [%warp [our p.bem] q.bem ~]] + $c [%pass (camp-wire +<) van [%warp our [our p.bem] q.bem ~]] $g [%pass (camp-wire +<) van [%deal [our p.bem] q.bem [%pull ~]]] == :: @@ -351,7 +351,7 @@ :: $c :+ %pass (camp-wire +<.$) - [%c [%warp [our p.bem] q.bem [~ %sing ren r.bem (flop s.bem)]]] + [%c [%warp our [our p.bem] q.bem [~ %sing ren r.bem (flop s.bem)]]] == == :: diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 73abafece..8dbcfafcf 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -408,7 +408,7 @@ {$dirk p/desk} :: mark mount dirty {$ogre p/$@(desk beam)} :: delete mount point {$perm our/ship des/desk pax/path rit/rite} :: change permissions - {$warp p/sock q/riff} :: file request + {$warp p/ship q/sock r/riff} :: file request. {$wegh $~} :: report memory {$went p/sack q/path r/@ud s/coop} :: response confirm {$west p/sack q/path r/*} :: network request From 97eb2a91ae36ba2bd30dad52a9a7588f9a5f51fa Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 8 Feb 2018 14:39:53 +0100 Subject: [PATCH 137/184] State adapter. --- sys/vane/clay.hoon | 73 ++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 2a1cecbe5..8eb6451d2 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3536,7 +3536,7 @@ :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: =| :: instrument state - $: $3 :: vane version + $: $4 :: vane version ruf/raft :: revision tree == :: |= {now/@da eny/@ ski/sley} :: activate @@ -3767,44 +3767,55 @@ :: ++ load => |% - += rove-2 - $% {$sing p/mood} - {$next p/mood q/(unit (each cage lobe))} - {$many p/? q/moat r/(map path lobe)} + += wove-3 rove + ++ cult-3 (jug wove-3 duct) + ++ dojo-3 + $: qyx/cult-3 + dom/dome + dok/(unit dork) + mer/(unit mery) == - ++ cult-2 (jug rove-2 duct) - ++ dojo-2 (cork dojo |=(a/dojo a(qyx *cult-2))) - ++ rede-2 (cork rede |=(a/rede a(qyx *cult-2))) - ++ room-2 (cork room |=(a/room a(dos (~(run by dos.a) dojo-2)))) - ++ rung-2 (cork rung |=(a/rung a(rus (~(run by rus.a) rede-2)))) - ++ raft-2 - %+ cork raft - |=(a/raft a(fat (~(run by fat.a) room-2), hoy (~(run by hoy.a) rung-2))) - ++ axle $%({$2 ruf/raft-2} {$3 ruf/raft}) + ++ rede-3 + $: lim/@da + ref/(unit rind) + qyx/cult-3 + dom/dome + dok/(unit dork) + mer/(unit mery) + == + ++ room-3 (cork room |=(a/room a(dos (~(run by dos.a) dojo-3)))) + ++ rung-3 (cork rung |=(a/rung a(rus (~(run by rus.a) rede-3)))) + ++ raft-3 + $: fat/(map ship room-3) + hoy/(map ship rung-3) + ran/rang + mon/(map term beam) + hez/(unit duct) + == + ++ axle $%({$3 ruf/raft-3} {$4 ruf/raft}) -- |= old/axle ^+ ..^$ ?- -.old - $3 ..^$(ruf ruf.old) - $2 =/ rov - |= a/rove-2 ^- rove - ?+ -.a a - $next - ?~ q.a a - a(q `q.a) - == + $4 ..^$(ruf ruf.old) + $3 =/ wov + |= a/wove-3 ^- wove + [~ a] =/ cul - |= a/cult-2 ^- cult + |= a/cult-3 ^- cult %- ~(gas by *cult) - (turn ~(tap by a) |=({p/rove-2 q/(set duct)} [(rov p) q])) + (turn ~(tap by a) |=({p/wove-3 q/(set duct)} [(wov p) q])) =/ rom - =+ doj=|=(a/dojo-2 a(qyx (cul qyx.a))) - |=(a/room-2 a(dos (~(run by dos.a) doj))) + =+ doj=|=(dojo-3 [(cul qyx) dom dok mer ~ ~]) + |=(a/room-3 a(dos (~(run by dos.a) doj))) =/ run - =+ red=|=(a/rede-2 a(qyx (cul qyx.a))) - |=(a/rung-2 a(rus (~(run by rus.a) red))) - =+ r=ruf.old - $(old [%3 r(fat (~(run by fat.r) rom), hoy (~(run by hoy.r) run))]) + =/ red + |= rede-3 + =+ [[/ %black ~] ~ ~] + [lim ref (cul qyx) dom dok mer - -] + |=(a/rung-3 a(rus (~(run by rus.a) red))) + =+ ruf.old + $(old [%4 [(~(run by fat) rom) (~(run by hoy) run) ran mon hez ~]]) == :: ++ scry :: inspect @@ -3836,7 +3847,7 @@ ?: ?=($& -.u.u.-) ``p.u.u.- ~ :: -++ stay [%3 ruf] +++ stay [%4 ruf] ++ take :: accept response |= {tea/wire hen/duct hin/(hypo sign)} ^+ [p=*(list move) q=..^$] From aa2843fedbb9cf045e1f3b181521671285463f09 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 8 Feb 2018 17:10:09 +0100 Subject: [PATCH 138/184] Maintain old %warp interface. Use %werp for %west read requests. This also makes live-updating to this new clay easier. --- lib/hood/kiln.hoon | 21 ++++++++++++++------- sys/vane/clay.hoon | 23 +++++++++++++++-------- sys/vane/dill.hoon | 4 ++-- sys/vane/ford.hoon | 8 ++++---- sys/zuse.hoon | 3 ++- 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/lib/hood/kiln.hoon b/lib/hood/kiln.hoon index e9c12522f..f793f060a 100644 --- a/lib/hood/kiln.hoon +++ b/lib/hood/kiln.hoon @@ -70,7 +70,7 @@ {$poke wire dock pear} :: {$wipe wire @p $~} :: {$wait wire @da} :: - {$warp wire ship sock riff} :: + {$warp wire sock riff} :: == :: ++ pear :: poke fruit $% {$hall-command command:hall} :: @@ -222,7 +222,7 @@ ++ subscribe-next %- emit ^- card - :* %warp /kiln/autoload our [our our] %home ~ + :* %warp /kiln/autoload [our our] %home ~ %next %z da+now /sys == :: @@ -349,7 +349,7 @@ %- blab :_ ~ :* ust %warp /kiln/sync/[syd]/(scot %p her)/[sud] - our [our her] sud ~ + [our her] sud ~ == :: ++ start-track @@ -358,7 +358,7 @@ %- blab :~ :* ost %warp /kiln/sync/[syd]/(scot %p her)/[sud] - our [our her] sud ~ %sing %y ud+let / + [our her] sud ~ %sing %y ud+let / == == :: ++ start-sync @@ -367,11 +367,18 @@ %- blab :~ :* ost %warp [%kiln %sync syd (scot %p her) sud ?:(reset /reset /)] - our [our her] sud ~ %sing %w [%da now] / + [our her] sud ~ %sing %w [%da now] / == == :: ++ writ - |= {reset/? rot/riot} + |= $: reset/? + $= rot + %- unit + $: p/{p/?($d $p $u $v $w $x $y $z) q/case r/desk} + q/path + r/cage + == + == ?~ rot %^ spam leaf+"bad %writ response" @@ -414,7 +421,7 @@ %- blab :_ ~ :* ost %warp /kiln/sync/[syd]/(scot %p her)/[sud] - our [our her] sud ~ %sing %y ud+let / + [our her] sud ~ %sing %y ud+let / == -- :: diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 8eb6451d2..1d206bdc3 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -329,7 +329,8 @@ $: $c :: to %clay $% {$info p/@p q/@tas r/nori} :: internal edit {$merg p/@p q/@tas r/@p s/@tas t/case u/germ} :: merge desks - {$warp p/ship q/sock r/riff} :: + {$warp p/sock q/riff} :: + {$werp p/ship q/sock r/riff} :: == == :: $: $d :: $% {$flog p/{$crud p/@tas q/(list tank)}} :: to %dill @@ -2777,7 +2778,7 @@ %- emit(wat.dat %ali) :* hen %pass [%merge (scot %p p.bob) q.bob (scot %p p.ali) q.ali %ali ~] - %c %warp p.bob [p.bob p.ali] q.ali + %c %warp [p.bob p.ali] q.ali `[%sing %v cas.dat /] == :: @@ -3707,9 +3708,16 @@ abet:(perm:den pax.q.hic rit.q.hic) [mos ..^$] :: - $warp + ?($warp $werp) + =^ for q.hic + ?: ?=($warp -.q.hic) + [~ q.hic] + :_ [%warp q.q.hic r.q.hic] + ?: =(p.q.hic p.q.q.hic) ~&([%huh-this-west-may-be-weird p.q.hic] ~) + `p.q.hic + ?> ?=($warp -.q.hic) =^ mos ruf - =+ den=((de now hen ruf) q.q.hic p.r.q.hic) + =+ den=((de now hen ruf) p.q.hic p.q.q.hic) :: =- ~? ?=([~ %sing %w *] q.r.q.hic) :: :* %someones-warping :: rav=u.q.r.q.hic @@ -3717,10 +3725,9 @@ :: == :: - =< abet - ?~ q.r.q.hic + ?~ q.q.q.hic cancel-request:den - =+ for=?:(=(p.q.hic p.q.q.hic) ~ `p.q.hic) - (start-request:den for u.q.r.q.hic) + (start-request:den for u.q.q.q.hic) [mos ..^$] :: $went @@ -3735,7 +3742,7 @@ :- hen :^ %pass [(scot %p p.p.q.hic) (scot %p q.p.q.hic) t.q.q.hic] %c - [%warp q.p.q.hic [p.p.q.hic p.p.q.hic] ryf] + [%werp q.p.q.hic [p.p.q.hic p.p.q.hic] ryf] == ?> ?=({$answer @ @ $~} q.q.hic) =+ syd=(slav %tas i.t.q.q.hic) diff --git a/sys/vane/dill.hoon b/sys/vane/dill.hoon index 43b423a45..3da18f372 100644 --- a/sys/vane/dill.hoon +++ b/sys/vane/dill.hoon @@ -47,7 +47,7 @@ == :: ++ note-clay :: $% {$merg p/@p q/@tas r/@p s/@tas t/case u/germ:clay}:: merge desks - {$warp p/ship q/sock r/riff:clay} :: wait for clay hack + {$warp p/sock q/riff:clay} :: wait for clay hack == :: ++ note-dill :: note to self, odd $% {$crud p/@tas q/(list tank)} :: @@ -297,7 +297,7 @@ %pass / %c - [%warp our [our our] %base `[%sing %y [%ud 1] /]] + [%warp [our our] %base `[%sing %y [%ud 1] /]] == == :: diff --git a/sys/vane/ford.hoon b/sys/vane/ford.hoon index 0d31637fb..a30900366 100644 --- a/sys/vane/ford.hoon +++ b/sys/vane/ford.hoon @@ -12,7 +12,7 @@ ++ move {p/duct q/(wind note gift:able)} :: local move ++ note :: out request $-> $% $: $c :: to %clay - $% {$warp p/ship q/sock r/riff:clay} :: + $% {$warp p/sock q/riff:clay} :: == == :: $: $f :: to %ford $% {$exec p/@p q/(unit bilk:ford)} :: @@ -294,7 +294,7 @@ |= {ren/care:clay bem/beam ask/?} :: ~& warp+[(en-beam bem) ask] :+ %pass [(scot %p our) ren (en-beam bem)] - [%c [%warp our [our p.bem] q.bem ?.(ask ~ `[%next ren r.bem (flop s.bem)])]] + [%c [%warp [our p.bem] q.bem ?.(ask ~ `[%next ren r.bem (flop s.bem)])]] :: :: ++ zo @@ -321,7 +321,7 @@ |= {van/vane ren/care:clay bem/beam} ^- (wind note gift:able) ?+ van ~|(stub-cancel+van !!) - $c [%pass (camp-wire +<) van [%warp our [our p.bem] q.bem ~]] + $c [%pass (camp-wire +<) van [%warp [our p.bem] q.bem ~]] $g [%pass (camp-wire +<) van [%deal [our p.bem] q.bem [%pull ~]]] == :: @@ -351,7 +351,7 @@ :: $c :+ %pass (camp-wire +<.$) - [%c [%warp our [our p.bem] q.bem [~ %sing ren r.bem (flop s.bem)]]] + [%c [%warp [our p.bem] q.bem [~ %sing ren r.bem (flop s.bem)]]] == == :: diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 8dbcfafcf..4ce04b6c9 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -408,7 +408,8 @@ {$dirk p/desk} :: mark mount dirty {$ogre p/$@(desk beam)} :: delete mount point {$perm our/ship des/desk pax/path rit/rite} :: change permissions - {$warp p/ship q/sock r/riff} :: file request. + {$warp p/sock q/riff} :: internal file req + {$werp p/ship q/sock r/riff} :: external file req {$wegh $~} :: report memory {$went p/sack q/path r/@ud s/coop} :: response confirm {$west p/sack q/path r/*} :: network request From b44130cd052dc27e97c7206200bd8466d55c8cd9 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 8 Feb 2018 21:57:58 +0100 Subject: [PATCH 139/184] Undo accidentally committed kiln changes. --- lib/hood/kiln.hoon | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/hood/kiln.hoon b/lib/hood/kiln.hoon index f793f060a..1b6d1327d 100644 --- a/lib/hood/kiln.hoon +++ b/lib/hood/kiln.hoon @@ -371,14 +371,7 @@ == == :: ++ writ - |= $: reset/? - $= rot - %- unit - $: p/{p/?($d $p $u $v $w $x $y $z) q/case r/desk} - q/path - r/cage - == - == + |= {reset/? rot/riot} ?~ rot %^ spam leaf+"bad %writ response" From d15442eb31fef4fd84b1c13a52f9710186a3b13d Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 00:34:44 +0100 Subject: [PATCH 140/184] Make kiln not out of date. For some reason it/hood's not getting compiled against the latest zuse? --- lib/hood/kiln.hoon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/hood/kiln.hoon b/lib/hood/kiln.hoon index 1b6d1327d..7d1cd9724 100644 --- a/lib/hood/kiln.hoon +++ b/lib/hood/kiln.hoon @@ -79,6 +79,12 @@ {$helm-reset $~} :: == :: ++ move (pair bone card) :: user-level move + ++ riot ::tmp up-to-date riot + %- unit + $: p/{p/?($d $p $u $v $w $x $y $z) q/case r/desk} + q/path + r/cage + == -- |_ moz/(list move) ++ abet :: resolve From f835ac4c570506ba8224ff21f95aa498229ebac0 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 00:35:42 +0100 Subject: [PATCH 141/184] Fix permission checks for %y and %z requests. --- sys/vane/clay.hoon | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 1d206bdc3..a771d7764 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -2395,11 +2395,13 @@ ?~ tak | =+ yak=(tako-to-yaki u.tak) =+ len=(lent pax) - %+ levy ~(tap by (~(del in ~(key by q.yak)) pax)) - |= p/path - ?& =(pax (scag len p)) - |(?=($z car) =(+(len) (lent p))) - == + =- (levy ~(tap in -) |=(p/path (allowed-by who p per.red))) + %+ roll ~(tap in (~(del in ~(key by q.yak)) pax)) + |= {p/path s/(set path)} + ?. =(pax (scag len p)) s + %- ~(put in s) + ?: ?=($z car) p + (scag +(len) p) == :: ++ may-write From d7fdb4545ed979efe53b53544deecfcfdb6a8826 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 00:37:17 +0100 Subject: [PATCH 142/184] Ensure %kids desk is publicly readable. Set permissions for that during boot and clay update. --- sys/vane/clay.hoon | 9 +++++++-- sys/vane/dill.hoon | 13 ++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index a771d7764..4e6c49301 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3815,8 +3815,13 @@ %- ~(gas by *cult) (turn ~(tap by a) |=({p/wove-3 q/(set duct)} [(wov p) q])) =/ rom - =+ doj=|=(dojo-3 [(cul qyx) dom dok mer ~ ~]) - |=(a/room-3 a(dos (~(run by dos.a) doj))) + |= room-3 + :- hun + %- ~(urn by dos) + |= {d/desk dojo-3} + =/ n/dojo [(cul qyx) dom dok mer ~ ~] + ?. =(%kids d) n + n(per [[/ %black ~] ~ ~]) =/ run =/ red |= rede-3 diff --git a/sys/vane/dill.hoon b/sys/vane/dill.hoon index 3da18f372..505e73b45 100644 --- a/sys/vane/dill.hoon +++ b/sys/vane/dill.hoon @@ -48,6 +48,7 @@ ++ note-clay :: $% {$merg p/@p q/@tas r/@p s/@tas t/case u/germ:clay}:: merge desks {$warp p/sock q/riff:clay} :: wait for clay hack + {$perm p/ship q/desk r/path s/rite:clay} :: change permissions == :: ++ note-dill :: note to self, odd $% {$crud p/@tas q/(list tank)} :: @@ -280,7 +281,7 @@ (sync %home our %base) (init-sync %home our %base) =. +> ?. ?=(?($duke $king $czar) can) +> - (sync %kids our %base) + (show %kids):(sync %kids our %base) =. +> autoload =. +> peer |- ^+ +>+ @@ -316,6 +317,16 @@ :_(moz [hen %pass ~ %g %deal [our our] ram %peer /drum]) == :: + ++ show :: permit reads on desk + |= des/desk + %_ +>.$ + moz + :_ moz + :* hen %pass /show %c %perm our + des / r+`[%black ~] + == + == + :: ++ sync |= syn/{desk ship desk} %_ +>.$ From ee1fb2b4ab7ed04aea760832db49b5cf83b49053 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 12:59:42 +0100 Subject: [PATCH 143/184] We no longer need to set local copies of remote desks to readable explicitly. --- sys/vane/clay.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 4e6c49301..fe43b80b8 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -430,8 +430,8 @@ dom=*dome dok=~ mer=~ - per=[[/ %black ~] ~ ~] - pew=[[/ %black ~] ~ ~] + per=~ + pew=~ == :- `hun.u.rom =+ jod=(fall (~(get by dos.u.rom) syd) *dojo) From f60bb7efc1f165c5504facd167c361f3696c22fa Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 13:00:12 +0100 Subject: [PATCH 144/184] Actually do permission checks in ++lobes-at-path, for %many requests. --- sys/vane/clay.hoon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index fe43b80b8..3ff9b27ef 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -2241,6 +2241,8 @@ |= {for/(unit ship) yon/aeon pax/path} ^- (map path lobe) ?: =(0 yon) ~ + :: we use %z for the check because it looks at all child paths. + ?: |(?=($~ for) (may-read u.for %z yon pax)) ~ %- malt %+ skim %~ tap by From e541a55575a9cfe27ec954a7b9d6727694e99849 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 13:25:46 +0100 Subject: [PATCH 145/184] Cleanup and stylistic changes. --- sys/vane/clay.hoon | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 3ff9b27ef..e5efeb9b8 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -375,7 +375,6 @@ :: :: -- current time `now` :: -- current duct `hen` -:: -- foreign requester `for`, if any :: -- local urbit `our` :: -- target urbit `her` :: -- target desk `syd` @@ -3717,21 +3716,16 @@ ?: ?=($warp -.q.hic) [~ q.hic] :_ [%warp q.q.hic r.q.hic] - ?: =(p.q.hic p.q.q.hic) ~&([%huh-this-west-may-be-weird p.q.hic] ~) + ?: =(p.q.hic p.q.q.hic) ~ `p.q.hic ?> ?=($warp -.q.hic) + =* rif q.q.hic =^ mos ruf - =+ den=((de now hen ruf) p.q.hic p.q.q.hic) - :: =- ~? ?=([~ %sing %w *] q.r.q.hic) - :: :* %someones-warping - :: rav=u.q.r.q.hic - :: mos=-< - :: == - :: - + =+ den=((de now hen ruf) p.q.hic p.rif) =< abet - ?~ q.q.q.hic + ?~ q.rif cancel-request:den - (start-request:den for u.q.q.q.hic) + (start-request:den for u.q.rif) [mos ..^$] :: $went @@ -3809,14 +3803,26 @@ ^+ ..^$ ?- -.old $4 ..^$(ruf ruf.old) - $3 =/ wov + $3 |^ + =- ^$(old [%4 -]) + =+ ruf.old + :* (~(run by fat) rom) + (~(run by hoy) run) + ran mon hez ~ + == + :: + ++ wov |= a/wove-3 ^- wove [~ a] - =/ cul + :: + ++ cul |= a/cult-3 ^- cult %- ~(gas by *cult) - (turn ~(tap by a) |=({p/wove-3 q/(set duct)} [(wov p) q])) - =/ rom + %+ turn ~(tap by a) + |= {p/wove-3 q/(set duct)} + [(wov p) q] + :: + ++ rom |= room-3 :- hun %- ~(urn by dos) @@ -3824,14 +3830,14 @@ =/ n/dojo [(cul qyx) dom dok mer ~ ~] ?. =(%kids d) n n(per [[/ %black ~] ~ ~]) - =/ run + :: + ++ run =/ red |= rede-3 =+ [[/ %black ~] ~ ~] [lim ref (cul qyx) dom dok mer - -] |=(a/rung-3 a(rus (~(run by rus.a) red))) - =+ ruf.old - $(old [%4 [(~(run by fat) rom) (~(run by hoy) run) ran mon hez ~]]) + -- == :: ++ scry :: inspect From 315823250f4dfd64f2cfd44fc4ce00c9a5e6c8f4 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 13:33:15 +0100 Subject: [PATCH 146/184] Add req alias for incoming requests. --- sys/vane/clay.hoon | 131 +++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 65 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index e5efeb9b8..95ed21140 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3550,36 +3550,37 @@ |= $: hen/duct hic/(hypo (hobo task:able)) == + =* req q.hic => %= . :: XX temporary - q.hic + req ^- task:able - ?: ?=($soft -.q.hic) + ?: ?=($soft -.req) =+ - ~|([%bad-soft (@t -.p.q.hic)] ((soft task:able) p.q.hic)) + ~|([%bad-soft (@t -.p.req)] ((soft task:able) p.req)) ?~ - - ~& [%bad-softing (@t -.p.q.hic)] !! + ~& [%bad-softing (@t -.p.req)] !! u.- - ?: (~(nest ut -:!>(*task:able)) | p.hic) q.hic - ~& [%clay-call-flub (@tas `*`-.q.hic)] - ((hard task:able) q.hic) + ?: (~(nest ut -:!>(*task:able)) | p.hic) req + ~& [%clay-call-flub (@tas `*`-.req)] + ((hard task:able) req) == ^+ [p=*(list move) q=..^$] - ?- -.q.hic + ?- -.req $boat :_ ..^$ [hen %give %hill (turn ~(tap by mon.ruf) head)]~ ::. $cred =. cez.ruf - ?~ cew.q.hic (~(del by cez.ruf) nom.q.hic) - (~(put by cez.ruf) nom.q.hic cew.q.hic) + ?~ cew.req (~(del by cez.ruf) nom.req) + (~(put by cez.ruf) nom.req cew.req) :: wake all desks, a request may have been affected. =| mos/(list move) - =+ rom=(fall (~(get by fat.ruf) our.q.hic) *room) + =+ rom=(fall (~(get by fat.ruf) our.req) *room) =+ des=~(tap in ~(key by dos.rom)) |- ?~ des [[[hen %give %mack ~] mos] ..^^$] - =+ den=((de now hen ruf) [. .]:our.q.hic i.des) + =+ den=((de now hen ruf) [. .]:our.req i.des) =^ mor ruf abet:wake:den $(des t.des, mos (weld mos mor)) :: @@ -3588,28 +3589,28 @@ :: $drop =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) + =+ den=((de now hen ruf) [. .]:p.req q.req) abet:drop-me:den [mos ..^$] :: $info - ?: =(%$ q.q.hic) + ?: =(%$ q.req) [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) - abet:(edit:den now r.q.hic) + =+ den=((de now hen ruf) [. .]:p.req q.req) + abet:(edit:den now r.req) [mos ..^$] :: $init :_ %_ ..^$ fat.ruf - ?< (~(has by fat.ruf) p.q.hic) - (~(put by fat.ruf) p.q.hic [-(hun hen)]:[*room .]) + ?< (~(has by fat.ruf) p.req) + (~(put by fat.ruf) p.req [-(hun hen)]:[*room .]) == - =+ [bos=(sein:title p.q.hic) can=(clan:title p.q.hic)] + =+ [bos=(sein:title p.req) can=(clan:title p.req)] %- zing ^- (list (list move)) - :~ ?: =(bos p.q.hic) ~ - [hen %pass /init-merge %c %merg p.q.hic %base bos %kids da+now %init]~ + :~ ?: =(bos p.req) ~ + [hen %pass /init-merge %c %merg p.req %base bos %kids da+now %init]~ :: ~ == @@ -3617,9 +3618,9 @@ $into =. hez.ruf `hen :_ ..^$ - =+ bem=(~(get by mon.ruf) p.q.hic) - ?: &(?=($~ bem) !=(%$ p.q.hic)) - ~|([%bad-mount-point-from-unix p.q.hic] !!) + =+ bem=(~(get by mon.ruf) p.req) + ?: &(?=($~ bem) !=(%$ p.req)) + ~|([%bad-mount-point-from-unix p.req] !!) =+ ^- bem/beam ?^ bem u.bem @@ -3631,7 +3632,7 @@ ?~ dos ~ ?: =(0 let.dom.u.dos) - =+ cos=(mode-to-soba ~ s.bem q.q.hic r.q.hic) + =+ cos=(mode-to-soba ~ s.bem q.req r.req) =+ ^- {one/(list {path miso}) two/(list {path miso})} %+ skid cos |= {a/path b/miso} @@ -3643,85 +3644,85 @@ [hen %pass /two %c %info p.bem q.bem %& two] == =+ yak=(~(got by hut.ran.ruf) (~(got by hit.dom.u.dos) let.dom.u.dos)) - =+ cos=(mode-to-soba q.yak (flop s.bem) q.q.hic r.q.hic) + =+ cos=(mode-to-soba q.yak (flop s.bem) q.req r.req) [hen %pass /both %c %info p.bem q.bem %& cos]~ :: $merg :: direct state up - ?: =(%$ q.q.hic) + ?: =(%$ q.req) [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.hic q.q.hic) - abet:abet:(start:(me:ze:den [r.q.hic s.q.hic] ~ &) t.q.hic u.q.hic) + =+ den=((de now hen ruf) [. .]:p.req q.req) + abet:abet:(start:(me:ze:den [r.req s.req] ~ &) t.req u.req) [mos ..^$] :: $mont =. hez.ruf ?^(hez.ruf hez.ruf `[[%$ %sync ~] ~]) - =+ pot=(~(get by mon.ruf) p.q.hic) + =+ pot=(~(get by mon.ruf) p.req) ?^ pot ~& [%already-mounted pot] [~ ..^$] =. mon.ruf - (~(put by mon.ruf) p.q.hic [p.q.q.hic q.q.q.hic r.q.q.hic] s.q.q.hic) - =+ yar=(~(get by fat.ruf) p.q.q.hic) + (~(put by mon.ruf) p.req [p.q.req q.q.req r.q.req] s.q.req) + =+ yar=(~(get by fat.ruf) p.q.req) ?~ yar [~ ..^$] - =+ dos=(~(get by dos.u.yar) q.q.q.hic) + =+ dos=(~(get by dos.u.yar) q.q.req) ?~ dos [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.q.hic q.q.q.hic) - abet:(mont:den p.q.hic q.q.hic) + =+ den=((de now hen ruf) [. .]:p.q.req q.q.req) + abet:(mont:den p.req q.req) [mos ..^$] :: $dirk ?~ hez.ruf ~& %no-sync-duct [~ ..^$] - ?. (~(has by mon.ruf) p.q.hic) - ~& [%not-mounted p.q.hic] + ?. (~(has by mon.ruf) p.req) + ~& [%not-mounted p.req] [~ ..^$] - :- ~[[u.hez.ruf %give %dirk p.q.hic]] + :- ~[[u.hez.ruf %give %dirk p.req]] ..^$ :: $ogre ?~ hez.ruf ~& %no-sync-duct [~ ..^$] - ?@ p.q.hic - ?. (~(has by mon.ruf) p.q.hic) - ~& [%not-mounted p.q.hic] + ?@ p.req + ?. (~(has by mon.ruf) p.req) + ~& [%not-mounted p.req] [~ ..^$] - :_ ..^$(mon.ruf (~(del by mon.ruf) p.q.hic)) - [u.hez.ruf %give %ogre p.q.hic]~ + :_ ..^$(mon.ruf (~(del by mon.ruf) p.req)) + [u.hez.ruf %give %ogre p.req]~ :_ %_ ..^$ mon.ruf %- molt %+ skip ~(tap by mon.ruf) - (corl (cury test p.q.hic) tail) + (corl (cury test p.req) tail) == %+ turn - (skim ~(tap by mon.ruf) (corl (cury test p.q.hic) tail)) + (skim ~(tap by mon.ruf) (corl (cury test p.req) tail)) |= {pot/term bem/beam} [u.hez.ruf %give %ogre pot] :: $perm =^ mos ruf ::TODO after new boot system, just use our from global. - =+ den=((de now hen ruf) [. .]:our.q.hic des.q.hic) - abet:(perm:den pax.q.hic rit.q.hic) + =+ den=((de now hen ruf) [. .]:our.req des.req) + abet:(perm:den pax.req rit.req) [mos ..^$] :: ?($warp $werp) - =^ for q.hic - ?: ?=($warp -.q.hic) - [~ q.hic] - :_ [%warp q.q.hic r.q.hic] - ?: =(p.q.hic p.q.q.hic) ~ - `p.q.hic - ?> ?=($warp -.q.hic) - =* rif q.q.hic + =^ for req + ?: ?=($warp -.req) + [~ req] + :_ [%warp q.req r.req] + ?: =(p.req p.q.req) ~ + `p.req + ?> ?=($warp -.req) + =* rif q.req =^ mos ruf - =+ den=((de now hen ruf) p.q.hic p.rif) + =+ den=((de now hen ruf) p.req p.rif) =< abet ?~ q.rif cancel-request:den @@ -3733,21 +3734,21 @@ !! :: $west - ?: ?=({$question *} q.q.hic) - =+ ryf=((hard riff) r.q.hic) + ?: ?=({$question *} q.req) + =+ ryf=((hard riff) r.req) :_ ..^$ :~ [hen %give %mack ~] :- hen - :^ %pass [(scot %p p.p.q.hic) (scot %p q.p.q.hic) t.q.q.hic] + :^ %pass [(scot %p p.p.req) (scot %p q.p.req) t.q.req] %c - [%werp q.p.q.hic [p.p.q.hic p.p.q.hic] ryf] + [%werp q.p.req [p.p.req p.p.req] ryf] == - ?> ?=({$answer @ @ $~} q.q.hic) - =+ syd=(slav %tas i.t.q.q.hic) - =+ inx=(slav %ud i.t.t.q.q.hic) + ?> ?=({$answer @ @ $~} q.req) + =+ syd=(slav %tas i.t.q.req) + =+ inx=(slav %ud i.t.t.q.req) =^ mos ruf - =+ den=((de now hen ruf) p.q.hic syd) - abet:(take-foreign-update:den inx ((hard (unit rand)) r.q.hic)) + =+ den=((de now hen ruf) p.req syd) + abet:(take-foreign-update:den inx ((hard (unit rand)) r.req)) [[[hen %give %mack ~] mos] ..^$] :: $wegh From 9f05d2f66265683730a82d949f62d7c3d4a4afc9 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 9 Feb 2018 14:48:08 +0100 Subject: [PATCH 147/184] Add faces to clay ++task. --- sys/vane/clay.hoon | 102 +++++++++++++++++++++++---------------------- sys/zuse.hoon | 28 +++++++------ 2 files changed, 69 insertions(+), 61 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 95ed21140..5158e5d5b 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3589,28 +3589,28 @@ :: $drop =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.req q.req) + =+ den=((de now hen ruf) [. .]:our.req des.req) abet:drop-me:den [mos ..^$] :: $info - ?: =(%$ q.req) + ?: =(%$ des.req) [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.req q.req) - abet:(edit:den now r.req) + =+ den=((de now hen ruf) [. .]:our.req des.req) + abet:(edit:den now dit.req) [mos ..^$] :: $init :_ %_ ..^$ fat.ruf - ?< (~(has by fat.ruf) p.req) - (~(put by fat.ruf) p.req [-(hun hen)]:[*room .]) + ?< (~(has by fat.ruf) our.req) + (~(put by fat.ruf) our.req [-(hun hen)]:[*room .]) == - =+ [bos=(sein:title p.req) can=(clan:title p.req)] + =+ [bos=(sein:title our.req) can=(clan:title our.req)] %- zing ^- (list (list move)) - :~ ?: =(bos p.req) ~ - [hen %pass /init-merge %c %merg p.req %base bos %kids da+now %init]~ + :~ ?: =(bos our.req) ~ + [hen %pass /init-merge %c %merg our.req %base bos %kids da+now %init]~ :: ~ == @@ -3618,9 +3618,9 @@ $into =. hez.ruf `hen :_ ..^$ - =+ bem=(~(get by mon.ruf) p.req) - ?: &(?=($~ bem) !=(%$ p.req)) - ~|([%bad-mount-point-from-unix p.req] !!) + =+ bem=(~(get by mon.ruf) des.req) + ?: &(?=($~ bem) !=(%$ des.req)) + ~|([%bad-mount-point-from-unix des.req] !!) =+ ^- bem/beam ?^ bem u.bem @@ -3632,7 +3632,7 @@ ?~ dos ~ ?: =(0 let.dom.u.dos) - =+ cos=(mode-to-soba ~ s.bem q.req r.req) + =+ cos=(mode-to-soba ~ s.bem all.req fis.req) =+ ^- {one/(list {path miso}) two/(list {path miso})} %+ skid cos |= {a/path b/miso} @@ -3644,66 +3644,68 @@ [hen %pass /two %c %info p.bem q.bem %& two] == =+ yak=(~(got by hut.ran.ruf) (~(got by hit.dom.u.dos) let.dom.u.dos)) - =+ cos=(mode-to-soba q.yak (flop s.bem) q.req r.req) + =+ cos=(mode-to-soba q.yak (flop s.bem) all.req fis.req) [hen %pass /both %c %info p.bem q.bem %& cos]~ :: $merg :: direct state up - ?: =(%$ q.req) + ?: =(%$ des.req) [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.req q.req) - abet:abet:(start:(me:ze:den [r.req s.req] ~ &) t.req u.req) + =+ den=((de now hen ruf) [. .]:our.req des.req) + abet:abet:(start:(me:ze:den [her.req dem.req] ~ &) cas.req how.req) [mos ..^$] :: $mont =. hez.ruf ?^(hez.ruf hez.ruf `[[%$ %sync ~] ~]) - =+ pot=(~(get by mon.ruf) p.req) + =+ pot=(~(get by mon.ruf) des.req) ?^ pot ~& [%already-mounted pot] [~ ..^$] + =* bem bem.req =. mon.ruf - (~(put by mon.ruf) p.req [p.q.req q.q.req r.q.req] s.q.req) - =+ yar=(~(get by fat.ruf) p.q.req) + (~(put by mon.ruf) des.req [p.bem q.bem r.bem] s.bem) + =+ yar=(~(get by fat.ruf) p.bem) ?~ yar [~ ..^$] - =+ dos=(~(get by dos.u.yar) q.q.req) + =+ dos=(~(get by dos.u.yar) q.bem) ?~ dos [~ ..^$] =^ mos ruf - =+ den=((de now hen ruf) [. .]:p.q.req q.q.req) - abet:(mont:den p.req q.req) + =+ den=((de now hen ruf) [. .]:p.bem q.bem) + abet:(mont:den des.req bem) [mos ..^$] :: $dirk ?~ hez.ruf ~& %no-sync-duct [~ ..^$] - ?. (~(has by mon.ruf) p.req) - ~& [%not-mounted p.req] + ?. (~(has by mon.ruf) des.req) + ~& [%not-mounted des.req] [~ ..^$] - :- ~[[u.hez.ruf %give %dirk p.req]] + :- ~[[u.hez.ruf %give %dirk des.req]] ..^$ :: $ogre ?~ hez.ruf ~& %no-sync-duct [~ ..^$] - ?@ p.req - ?. (~(has by mon.ruf) p.req) - ~& [%not-mounted p.req] + =* pot pot.req + ?@ pot + ?. (~(has by mon.ruf) pot) + ~& [%not-mounted pot] [~ ..^$] - :_ ..^$(mon.ruf (~(del by mon.ruf) p.req)) - [u.hez.ruf %give %ogre p.req]~ + :_ ..^$(mon.ruf (~(del by mon.ruf) pot)) + [u.hez.ruf %give %ogre pot]~ :_ %_ ..^$ mon.ruf %- molt %+ skip ~(tap by mon.ruf) - (corl (cury test p.req) tail) + (corl (cury test pot) tail) == %+ turn - (skim ~(tap by mon.ruf) (corl (cury test p.req) tail)) - |= {pot/term bem/beam} - [u.hez.ruf %give %ogre pot] + (skim ~(tap by mon.ruf) (corl (cury test pot) tail)) + |= {pon/term bem/beam} + [u.hez.ruf %give %ogre pon] :: $perm =^ mos ruf @@ -3716,13 +3718,13 @@ =^ for req ?: ?=($warp -.req) [~ req] - :_ [%warp q.req r.req] - ?: =(p.req p.q.req) ~ - `p.req + :_ [%warp wer.req rif.req] + ?: =(who.req p.wer.req) ~ + `who.req ?> ?=($warp -.req) - =* rif q.req + =* rif rif.req =^ mos ruf - =+ den=((de now hen ruf) p.req p.rif) + =+ den=((de now hen ruf) wer.req p.rif) =< abet ?~ q.rif cancel-request:den @@ -3734,21 +3736,23 @@ !! :: $west - ?: ?=({$question *} q.req) - =+ ryf=((hard riff) r.req) + =* wer wer.req + =* pax pax.req + ?: ?=({$question *} pax) + =+ ryf=((hard riff) res.req) :_ ..^$ :~ [hen %give %mack ~] :- hen - :^ %pass [(scot %p p.p.req) (scot %p q.p.req) t.q.req] + :^ %pass [(scot %p p.wer) (scot %p q.wer) t.pax] %c - [%werp q.p.req [p.p.req p.p.req] ryf] + [%werp q.wer [p.wer p.wer] ryf] == - ?> ?=({$answer @ @ $~} q.req) - =+ syd=(slav %tas i.t.q.req) - =+ inx=(slav %ud i.t.t.q.req) + ?> ?=({$answer @ @ $~} pax) + =+ syd=(slav %tas i.t.pax) + =+ inx=(slav %ud i.t.t.pax) =^ mos ruf - =+ den=((de now hen ruf) p.req syd) - abet:(take-foreign-update:den inx ((hard (unit rand)) r.req)) + =+ den=((de now hen ruf) wer syd) + abet:(take-foreign-update:den inx ((hard (unit rand)) res.req)) [[[hen %give %mack ~] mos] ..^$] :: $wegh diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 4ce04b6c9..0e7427c52 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -399,20 +399,24 @@ $% {$boat $~} :: pier rebooted {$cred our/ship nom/@ta cew/crew} :: set permission group {$crew our/ship} :: permission groups - {$drop p/@p q/desk} :: cancel pending merge - {$info p/@p q/desk r/nori} :: internal edit - {$init p/@p} :: report install - {$into p/desk q/? r/mode} :: external edit - {$merg p/@p q/desk r/@p s/desk t/case u/germ} :: merge desks - {$mont p/desk q/beam} :: mount to unix - {$dirk p/desk} :: mark mount dirty - {$ogre p/$@(desk beam)} :: delete mount point + {$drop our/@p des/desk} :: cancel pending merge + {$info our/@p des/desk dit/nori} :: internal edit + {$init our/@p} :: report install + {$into des/desk all/? fis/mode} :: external edit + $: $merg :: merge desks + our/@p des/desk :: target + her/@p dem/desk cas/case :: source + how/germ :: method + == :: + {$mont des/desk bem/beam} :: mount to unix + {$dirk des/desk} :: mark mount dirty + {$ogre pot/$@(desk beam)} :: delete mount point {$perm our/ship des/desk pax/path rit/rite} :: change permissions - {$warp p/sock q/riff} :: internal file req - {$werp p/ship q/sock r/riff} :: external file req + {$warp wer/sock rif/riff} :: internal file req + {$werp who/ship wer/sock rif/riff} :: external file req {$wegh $~} :: report memory - {$went p/sack q/path r/@ud s/coop} :: response confirm - {$west p/sack q/path r/*} :: network request + {$went wer/sack pax/path num/@ud ack/coop} :: response confirm + {$west wer/sack pax/path res/*} :: network request == :: -- ::able :: From 3d791048e827240c72579395940ebe11a9b7f630 Mon Sep 17 00:00:00 2001 From: John Franklin Date: Mon, 12 Feb 2018 06:45:11 -0600 Subject: [PATCH 148/184] Replace $-(* *) with gate. --- sys/hoon.hoon | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index 0b63fc9be..59d98f51b 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -387,7 +387,7 @@ (b u.a) :: ++ bind :: argue - |* {a/(unit) b/$-(* *)} + |* {a/(unit) b/gate} ?~ a ~ [~ u=(b u.a)] :: @@ -661,7 +661,7 @@ :: ++ turn :: transform ~/ %turn - |* {a/(list) b/$-(* *)} + |* {a/(list) b/gate} |- ?~ a ~ [i=(b i.a) t=$(a t.a)] @@ -1472,7 +1472,7 @@ $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b))) :: +- rib :: transform + product - |* {b/* c/$-(* *)} + |* {b/* c/gate} |- ^+ [b a] ?~ a [b ~] =+ d=(c n.a b) @@ -1482,7 +1482,7 @@ [-.f [n.a +.e +.f]] :: +- run :: apply gate to values - |* b/$-(* *) + |* b/gate |- ?~ a a [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)] @@ -1764,7 +1764,7 @@ :::: 2n: functional hacks :: :: :: :: -++ aftr |*(a/$-(* *) |*(b/$-(* *) (pair b a))) :: pair after +++ aftr |*(a/gate |*(b/gate (pair b a))) :: pair after ++ cork |*({a/_|=(* **) b/gate} (corl b a)) :: compose forward ++ corl :: compose backwards |* {a/gate b/_|=(* **)} @@ -1782,9 +1782,9 @@ |* b/_+<+.a (a b c) :: -++ fore |*(a/$-(* *) |*(b/$-(* *) (pair a b))) :: pair before +++ fore |*(a/gate |*(b/gate (pair a b))) :: pair before ++ hard :: force remold - |* han/$-(* *) + |* han/gate |= fud/* ^- han ~_ leaf+"hard" =+ gol=(han fud) @@ -1794,7 +1794,7 @@ ++ head |*(^ ,:+<-) :: get head ++ same |*(* +<) :: identity ++ soft :: maybe remold - |* han/$-(* *) + |* han/gate |= fud/* ^- (unit han) =+ gol=(han fud) ?.(=(gol fud) ~ [~ gol]) @@ -3627,7 +3627,7 @@ ++ dime {p/@ta q/@} :: ++ edge {p/hair q/(unit {p/* q/nail})} :: parsing output ++ hair {p/@ud q/@ud} :: parsing trace -++ like |* a/$-(* *) :: generic edge +++ like |* a/gate :: generic edge |= b/_`*`[(hair) ~] :: :- p=(hair -.b) :: ^= q :: @@ -4410,7 +4410,7 @@ :: ++ cook :: apply gate ~/ %cook - |* {poq/$-(* *) sef/rule} + |* {poq/gate sef/rule} ~/ %fun |= tub/nail =+ vex=(sef tub) @@ -12651,7 +12651,7 @@ == :: ++ desk @tas :: ship desk case spur ++ cage (cask vase) :: global metadata -++ cask |*(a/$-(* *) (pair mark a)) :: global data +++ cask |*(a/gate (pair mark a)) :: global data ++ cuff :: permissions $: p/(unit (set monk)) :: can be read by q/(set monk) :: caused or created by @@ -12659,8 +12659,8 @@ ++ curd {p/@tas q/*} :: typeless card ++ dock (pair @p term) :: message target ++ duct (list wire) :: causal history -++ hypo |*(a/$-(* *) (pair type a)) :: type associated -++ hobo |* a/$-(* *) :: task wrapper +++ hypo |*(a/gate (pair type a)) :: type associated +++ hobo |* a/gate :: task wrapper $? $% {$soft p/*} :: == :: a :: @@ -12716,7 +12716,7 @@ mev/type :: -:!>([%meta *vase]) == :: ++ wind :: new kernel action - |* {a/$-(* *) b/$-(* *)} :: forward+reverse + |* {a/gate b/gate} :: forward+reverse $% {$pass p/path q/a} :: advance {$slip p/a} :: lateral {$give p/b} :: retreat From 8c532942b4de99858f6c9410fb491f673b30d096 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 12 Feb 2018 16:02:32 +0100 Subject: [PATCH 149/184] Deleting a permissions group now deletes it from all rules. --- sys/vane/clay.hoon | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 5158e5d5b..484528aea 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -818,6 +818,21 @@ ?~ new (~(del by pes) pax) (~(put by pes) pax u.new) :: + :: Remove a group from all rules. + :: + ++ forget-crew + |= nom/@ta + %= +> + per (forget-crew-in nom per) + pew (forget-crew-in nom pew) + == + :: + ++ forget-crew-in + |= {nom/@ta rus/(map path rule)} + %- ~(run by rus) + |= r/rule + r(who (~(del in who.r) |+nom)) + :: :: Cancel a request. :: :: For local requests, we just remove it from `qyx`. For foreign requests, @@ -3581,7 +3596,10 @@ |- ?~ des [[[hen %give %mack ~] mos] ..^^$] =+ den=((de now hen ruf) [. .]:our.req i.des) - =^ mor ruf abet:wake:den + =^ mor ruf + =< abet:wake + ?: ?=(^ cew.req) den + (forget-crew:den nom.req) $(des t.des, mos (weld mos mor)) :: $crew From ab0dc23065d894f63e0d4e6d33608199d6a0c609 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 12 Feb 2018 16:27:14 +0100 Subject: [PATCH 150/184] Return an error when trying to add rules that contain undefined permission groups. --- sys/vane/clay.hoon | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 484528aea..5ab5387e4 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -806,6 +806,23 @@ ++ perm |= {pax/path rit/rite} ^+ +> + =/ mis/(set @ta) + %+ roll + =- ~(tap in -) + ?- -.rit + $r who:(fall red.rit *rule) + $w who:(fall wit.rit *rule) + $rw (~(uni in who:(fall red.rit *rule)) who:(fall wit.rit *rule)) + == + |= {w/whom s/(set @ta)} + ?: |(?=($& -.w) (~(has by cez) p.w)) s + (~(put in s) p.w) + ?^ mis + =- (emit hen %give %mack `[%leaf "No such group(s): {-}"]~) + %+ roll ~(tap in `(set @ta)`mis) + |= {g/@ta t/tape} + ?~ t (trip g) + :(weld t ", " (trip g)) =< (emit hen %give %mack ~) ?- -.rit $r wake(per (put-perm per pax red.rit)) From 9f66086936f1a0dcebd7a49a88cb821ec46604fd Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 12 Feb 2018 17:56:48 +0100 Subject: [PATCH 151/184] Permission list structure. --- sys/vane/clay.hoon | 18 +++++++++--------- sys/zuse.hoon | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 5ab5387e4..60519d0ce 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -68,8 +68,8 @@ dom/dome :: desk state dok/(unit dork) :: commit state mer/(unit mery) :: merge state - per/(map path rule) :: read perms per path - pew/(map path rule) :: write perms per path + per/regs :: read perms per path + pew/regs :: write perms per path == :: :: Desk state. @@ -242,8 +242,8 @@ dom/dome :: revision state dok/(unit dork) :: outstanding diffs mer/(unit mery) :: outstanding merges - per/(map path rule) :: read perms per path - pew/(map path rule) :: write perms per path + per/regs :: read perms per path + pew/regs :: write perms per path == :: :: :: Foreign request manager. @@ -831,7 +831,7 @@ == :: ++ put-perm - |= {pes/(map path rule) pax/path new/(unit rule)} + |= {pes/regs pax/path new/(unit rule)} ?~ new (~(del by pes) pax) (~(put by pes) pax u.new) :: @@ -845,8 +845,8 @@ == :: ++ forget-crew-in - |= {nom/@ta rus/(map path rule)} - %- ~(run by rus) + |= {nom/@ta pes/regs} + %- ~(run by pes) |= r/rule r(who (~(del in who.r) |+nom)) :: @@ -2407,7 +2407,7 @@ (read-p-in pax pew.red) :: ++ read-p-in - |= {pax/path pes/(map path rule)} + |= {pax/path pes/regs} ^- dict =+ rul=(~(get by pes) pax) ?^ rul [pax u.rul] @@ -2442,7 +2442,7 @@ (allowed-by w p pew.red) :: ++ allowed-by - |= {who/ship pax/path pes/(map path rule)} + |= {who/ship pax/path pes/regs} ^- ? =+ rul=rul:(read-p-in pax pes) =- =(0 -) diff --git a/sys/zuse.hoon b/sys/zuse.hoon index 0e7427c52..a060cb6d2 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -505,6 +505,7 @@ {$mult p/mool} :: next version of any {$many p/? q/moat} :: track range == :: + ++ regs (map path rule) :: rules for paths ++ riff {p/desk q/(unit rave)} :: request+desist ++ rite :: new permissions $% {$r red/(unit rule)} :: for read From 61505ff785d5db8588053c5e924e872a901fe429 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 12 Feb 2018 17:57:59 +0100 Subject: [PATCH 152/184] Clay task for retrieving the rules that apply to a group. --- sys/vane/clay.hoon | 21 +++++++++++++++++++++ sys/zuse.hoon | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 60519d0ce..69ae18c4f 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3621,6 +3621,27 @@ :: $crew [[hen %give %cruz cez.ruf]~ ..^$] + :: + $crow + =+ rom=(fall (~(get by fat.ruf) our.req) *room) + =+ des=~(tap by dos.rom) + =| rus/(map desk {r/regs w/regs}) + |^ + ?~ des [[hen %give %croz rus]~ ..^^$] + =+ per=(filter-rules per.q.i.des) + =+ pew=(filter-rules pew.q.i.des) + $(des t.des, rus (~(put by rus) p.i.des per pew)) + :: + ++ filter-rules + |= pes/regs + ^+ pes + =- (~(gas in *regs) -) + %+ murn ~(tap by pes) + |= {p/path r/rule} + ^- (unit (pair path rule)) + ?. (~(has in who.r) |+nom.req) ~ + `[p r] + -- :: $drop =^ mos ruf diff --git a/sys/zuse.hoon b/sys/zuse.hoon index a060cb6d2..3e6797589 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -381,7 +381,8 @@ ++ able ^? |% ++ gift :: out result <-$ - $% {$cruz cez/(map @ta crew)} :: permission groups + $% {$croz rus/(map desk {r/regs w/regs})} :: rules for group + {$cruz cez/(map @ta crew)} :: permission groups {$dirk p/@tas} :: mark mount dirty {$ergo p/@tas q/mode} :: version update {$hill p/(list @tas)} :: mount points @@ -399,6 +400,7 @@ $% {$boat $~} :: pier rebooted {$cred our/ship nom/@ta cew/crew} :: set permission group {$crew our/ship} :: permission groups + {$crow our/ship nom/@ta} :: group usage {$drop our/@p des/desk} :: cancel pending merge {$info our/@p des/desk dit/nori} :: internal edit {$init our/@p} :: report install From a33eec2d756d3ff83c4457f23c6948e72e950e1e Mon Sep 17 00:00:00 2001 From: John Franklin Date: Tue, 13 Feb 2018 04:43:52 -0600 Subject: [PATCH 153/184] Use ++mold instead of ++gate in ++cask and ++hypo. --- sys/hoon.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index 59d98f51b..d52f3f2ac 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -12651,7 +12651,7 @@ == :: ++ desk @tas :: ship desk case spur ++ cage (cask vase) :: global metadata -++ cask |*(a/gate (pair mark a)) :: global data +++ cask |*(a/mold (pair mark a)) :: global data ++ cuff :: permissions $: p/(unit (set monk)) :: can be read by q/(set monk) :: caused or created by @@ -12659,7 +12659,7 @@ ++ curd {p/@tas q/*} :: typeless card ++ dock (pair @p term) :: message target ++ duct (list wire) :: causal history -++ hypo |*(a/gate (pair type a)) :: type associated +++ hypo |*(a/mold (pair type a)) :: type associated ++ hobo |* a/gate :: task wrapper $? $% {$soft p/*} :: == :: From a6c6714c5dbbd743c327f4b8fb07a2b056f6844a Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Feb 2018 19:45:24 +0100 Subject: [PATCH 154/184] Fixed incorrect recursion logic for finding permissions. --- sys/vane/clay.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 69ae18c4f..457468ce4 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -2412,7 +2412,7 @@ =+ rul=(~(get by pes) pax) ?^ rul [pax u.rul] ?~ pax [/ %white ~] - $(pax t.pax) + $(pax (scag (dec (lent pax)) `path`pax)) :: ++ may-read |= {who/ship car/care yon/aeon pax/path} From 3b2543dfe81230eeabf17434e3bb614f2badff14 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Feb 2018 19:47:17 +0100 Subject: [PATCH 155/184] Fixed and simplified logic in ++allowed-by. --- sys/vane/clay.hoon | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 457468ce4..902650378 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -2445,12 +2445,11 @@ |= {who/ship pax/path pes/regs} ^- ? =+ rul=rul:(read-p-in pax pes) - =- =(0 -) - %+ mix ?=($black mod.rul) + =- ?:(?=($black mod.rul) !- -) %- ~(rep in who.rul) - |= {w/whom h/?} + |= {w/whom h/_|} ?: h & - ?: ?=($& -.w) =(w &+who) + ?: ?=($& -.w) =(p.w who) (~(has in (fall (~(get by cez) p.w) ~)) who) :: :: Checks for existence of a node at an aeon. From 7c747731ca35d64411254a3ca07d7fea8c072fb1 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Feb 2018 19:47:44 +0100 Subject: [PATCH 156/184] For %crow tasks: Skim instead of murn. No longer include desks with no rules. --- sys/vane/clay.hoon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index 902650378..be8cb4298 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3629,17 +3629,17 @@ ?~ des [[hen %give %croz rus]~ ..^^$] =+ per=(filter-rules per.q.i.des) =+ pew=(filter-rules pew.q.i.des) - $(des t.des, rus (~(put by rus) p.i.des per pew)) + =? rus |(?=(^ per) ?=(^ pew)) + (~(put by rus) p.i.des per pew) + $(des t.des) :: ++ filter-rules |= pes/regs ^+ pes =- (~(gas in *regs) -) - %+ murn ~(tap by pes) + %+ skim ~(tap by pes) |= {p/path r/rule} - ^- (unit (pair path rule)) - ?. (~(has in who.r) |+nom.req) ~ - `[p r] + (~(has in who.r) |+nom.req) -- :: $drop From 29001f23862a4eecf6c334f19e56aebcd2cc006f Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Feb 2018 20:12:30 +0100 Subject: [PATCH 157/184] Actually support %crow moves in gall. --- sys/vane/gall.hoon | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/vane/gall.hoon b/sys/vane/gall.hoon index 32d58674c..bd5aba4f2 100644 --- a/sys/vane/gall.hoon +++ b/sys/vane/gall.hoon @@ -1227,6 +1227,7 @@ $conf `%g $cred `%c $crew `%c + $crow `%c $deal `%g $exec `%f $flog `%d From 3b233303d2ad6cceecbafe055cbabf22d48865aa Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Feb 2018 22:47:04 +0100 Subject: [PATCH 158/184] Make dill properly deal with clay acks. Also adds a comment about the reason for making the %kids desk public. --- sys/vane/dill.hoon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/vane/dill.hoon b/sys/vane/dill.hoon index 505e73b45..72493a0ae 100644 --- a/sys/vane/dill.hoon +++ b/sys/vane/dill.hoon @@ -80,6 +80,7 @@ $% {$mere p/(each (set path) (pair term tang))} :: {$note p/@tD q/tank} :: {$writ p/riot:clay} :: + {$mack p/(unit tang)} :: == :: ++ sign-dill :: $% {$blit p/(list blit)} :: @@ -281,6 +282,7 @@ (sync %home our %base) (init-sync %home our %base) =. +> ?. ?=(?($duke $king $czar) can) +> + :: make kids desk publicly readable, so syncs work. (show %kids):(sync %kids our %base) =. +> autoload =. +> peer @@ -407,6 +409,10 @@ :: {$c $writ *} init + :: + {$c $mack *} + ?~ p.sih +>.$ + (mean >%dill-clay-nack< u.p.sih) :: {$d $blit *} (done +.sih) From 4d5e15cb4639f5a45eee03520bc5de604139a256 Mon Sep 17 00:00:00 2001 From: Fang Date: Tue, 13 Feb 2018 23:29:16 +0100 Subject: [PATCH 159/184] Include generators for making (paths on) desks public or private. --- app/hood.hoon | 2 ++ gen/hood/private.hoon | 10 ++++++++++ gen/hood/public.hoon | 10 ++++++++++ lib/hood/kiln.hoon | 12 ++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 gen/hood/private.hoon create mode 100644 gen/hood/public.hoon diff --git a/app/hood.hoon b/app/hood.hoon index a729cb382..506c808f1 100644 --- a/app/hood.hoon +++ b/app/hood.hoon @@ -133,6 +133,7 @@ ++ coup-kiln-spam (wrap take-coup-spam):from-kiln ++ diff-sole-effect-drum-phat (wrap diff-sole-effect-phat):from-drum ++ init-helm |=({way/wire *} [~ +>]) +++ mack-kiln (wrap mack):from-kiln ++ made-write (wrap made):from-write ++ made-kiln (wrap take-made):from-kiln ++ mere-kiln (wrap take-mere):from-kiln @@ -186,6 +187,7 @@ ++ poke-kiln-overload (wrap poke-overload):from-kiln ++ poke-kiln-unmount (wrap poke-unmount):from-kiln ++ poke-kiln-unsync (wrap poke-unsync):from-kiln +++ poke-kiln-permission (wrap poke-permission):from-kiln ++ poke-womb-invite (wrap poke-invite):from-womb ++ poke-womb-save (wrap poke-save):from-womb ++ poke-womb-obey (wrap poke-obey):from-womb diff --git a/gen/hood/private.hoon b/gen/hood/private.hoon new file mode 100644 index 000000000..bcfe62ff4 --- /dev/null +++ b/gen/hood/private.hoon @@ -0,0 +1,10 @@ +:: Kiln: make (subtree in) desk privately readable. +:: +:::: /gen/hood/private/hoon + :: +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + {arg/{des/desk may/?($~ {pax/path $~})} $~} + == +:- %kiln-permission +[des ?~(may / pax.may) |]:arg diff --git a/gen/hood/public.hoon b/gen/hood/public.hoon new file mode 100644 index 000000000..eea1bcba7 --- /dev/null +++ b/gen/hood/public.hoon @@ -0,0 +1,10 @@ +:: Kiln: make (subtree in) desk publicly readable. +:: +:::: /gen/hood/public/hoon + :: +:- %say +|= $: {now/@da eny/@uvJ bec/beak} + {arg/{des/desk may/?($~ {pax/path $~})} $~} + == +:- %kiln-permission +[des ?~(may / pax.may) &]:arg diff --git a/lib/hood/kiln.hoon b/lib/hood/kiln.hoon index 7d1cd9724..3dbe9e561 100644 --- a/lib/hood/kiln.hoon +++ b/lib/hood/kiln.hoon @@ -67,6 +67,7 @@ {$dirk wire @tas} :: {$ogre wire $@(@tas beam)} :: {$merg wire @p @tas @p @tas case germ} :: + {$perm wire ship desk path rite:clay} :: {$poke wire dock pear} :: {$wipe wire @p $~} :: {$wait wire @da} :: @@ -191,6 +192,12 @@ =+ old=;;((map @da cord) (fall (file where) ~)) `(foal where %sched !>((~(put by old) tym eve))) :: +++ poke-permission + |= {syd/desk pax/path pub/?} + =< abet + %^ emit %perm /kiln/permission + [our syd pax %r ~ ?:(pub %black %white) ~] +:: ++ poke-autoload |=(lod/(unit ?) abet:(poke:autoload lod)) ++ poke-start-autoload |=($~ abet:start:autoload) :: @@ -273,6 +280,11 @@ :: ++ poke-wipe-ford |=($~ abet:(emit %wipe /kiln our ~)) :: +++ mack + |= {way/wire saw/(unit tang)} + ~? ?=(^ saw) [%kiln-nack u.saw] + abet +:: ++ take |=(way/wire ?>(?=({@ $~} way) (work i.way))) :: general handler ++ take-mere :: |= {way/wire are/(each (set path) (pair term tang))} From e807db905589253892b3872226ae3f7cb90c2fac Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Feb 2018 16:54:51 +0100 Subject: [PATCH 160/184] Add usage tags to circle configs, allowing clients to store arbitrary meta usage info. --- app/hall.hoon | 31 +++++++++++++++++++++++++++++++ app/talk.hoon | 1 + lib/hall-json.hoon | 4 ++++ lib/hall.hoon | 9 +++++++++ mar/hall/action.hoon | 4 ++++ sur/hall.hoon | 5 +++++ 6 files changed, 54 insertions(+) diff --git a/app/hall.hoon b/app/hall.hoon index 69dd39d94..b9f7322bf 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -316,11 +316,13 @@ ?- -.act :: circle configuration $create (action-create +.act) + $design (action-design +.act) $source (action-source +.act) $depict (action-depict +.act) $filter (action-filter +.act) $permit (action-permit +.act) $delete (action-delete +.act) + $usage (action-usage +.act) :: messaging $convey (action-convey +.act) $phrase (action-phrase +.act) @@ -384,6 +386,7 @@ %^ impact nom %new :* [[[our.bol nom] ~] ~ ~] des + ~ *filter :- typ ?. ?=(?($village $journal) typ) ~ @@ -391,6 +394,14 @@ == (ta-evil (crip "{(trip nom)}: already exists")) :: + ++ action-design + :> creates a story with the specified config. + :: + |= {nom/name cof/config} + ?. (~(has in stories) nom) + (impact nom %new cof) + (ta-evil (crip "{(trip nom)}: already exists")) + :: ++ action-delete :> delete + announce :> @@ -438,6 +449,15 @@ (ta-evil (crip "no story {(trip nom)}")) so-done:(~(so-sources so nom ~ u.soy) sub srs) :: + ++ action-usage + :> add or remove usage tags. + :: + |= {nom/name add/? tas/tags} + =+ soy=(~(get by stories) nom) + ?~ soy + (ta-evil (crip "no story {(trip nom)}")) + so-done:(~(so-usage so nom ~ u.soy) add tas) + :: :> # %messaging +| ++ action-convey @@ -1102,6 +1122,17 @@ ?: =(cap cap.shape) +> (so-delta-our %config so-cir %caption cap) :: + ++ so-usage + :> add or remove usage tags. + :: + |= {add/? tas/tags} + ^+ +> + =/ sas/tags + %. tag.shape + ?:(add ~(dif in tas) ~(int in tas)) + ?~ sas +>.$ + (so-delta-our %config so-cir %usage add sas) + :: ++ so-filter :> change message rules :> diff --git a/app/talk.hoon b/app/talk.hoon index 28c007bf2..7e59c8a9c 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -1828,6 +1828,7 @@ $(dif [%filter fit.cof.dif]) ?: ?=($remove -.dif) (sh-note (weld "rip " (~(cr-show cr cir) ~))) + ?: ?=($usage -.dif) +> %- sh-note %+ weld (weld ~(cr-phat cr cir) ": ") diff --git a/lib/hall-json.hoon b/lib/hall-json.hoon index bcdb7697d..2bf9a1779 100644 --- a/lib/hall-json.hoon +++ b/lib/hall-json.hoon @@ -178,6 +178,7 @@ $full (conf cof.a) $source (pairs add+b+add.a src+(sorc src.a) ~) $caption s+cap.a + $usage (pairs add+b+add.a tas+(sa tas.a cord) ~) $filter (filt fit.a) $secure s+sec.a $permit (pairs add+b+add.a sis+(sa sis.a ship) ~) @@ -229,6 +230,7 @@ %- pairs :~ src+(sa src.a sorc) cap+s+cap.a + tag+(sa tag.a cord) fit+(filt fit.a) con+(cont con.a) == @@ -425,6 +427,7 @@ %- of :~ full+conf source+(ot add+bo src+sorc ~) + usage+(ot add+bo tas+(as so) ~) caption+so filter+filt secure+secu @@ -469,6 +472,7 @@ %- ot :~ src+(as sorc) cap+so + tag+(as so) fit+filt con+cont == diff --git a/lib/hall.hoon b/lib/hall.hoon index a543d882c..ff6d7401e 100644 --- a/lib/hall.hoon +++ b/lib/hall.hoon @@ -126,6 +126,15 @@ $caption cof(cap cap.dif) $filter cof(fit fit.dif) $remove cof + :: + $usage + %= cof + tag + %. tas.dif + ?: add.dif + ~(uni in tag.cof) + ~(dif in tag.cof) + == :: $source %= cof diff --git a/mar/hall/action.hoon b/mar/hall/action.hoon index 24ae2dcab..09381cf86 100644 --- a/mar/hall/action.hoon +++ b/mar/hall/action.hoon @@ -16,11 +16,13 @@ ^- action:hall =- (need ((of -) a)) :~ create+(ot nom+so des+so sec+secu ~) + design+(ot nom+so cof+conf ~) delete+(ot nom+so why+(mu so) ~) depict+(ot nom+so des+so ~) filter+(ot nom+so fit+filt ~) permit+(ot nom+so inv+bo sis+(as (su fed:ag)) ~) source+(ot nom+so sub+bo srs+(as sorc) ~) + usage+(ot nom+so add+bo tas+(as so) ~) :: convey+(ar thot) phrase+(ot aud+audi ses+(ar spec:dejs:hall-json) ~) @@ -46,11 +48,13 @@ %- pairs ?- -.act $create ~[nom+s+nom.act des+s+des.act sec+s+sec.act] + $design ~[nom+s+nom.act cof+(conf cof.act)] $delete ~[nom+s+nom.act why+(mabe why.act cord:enjs)] $depict ~[nom+s+nom.act des+s+des.act] $filter ~[nom+s+nom.act fit+(filt fit.act)] $permit ~[nom+s+nom.act inv+b+inv.act sis+(sa sis.act ship)] $source ~[nom+s+nom.act sub+b+sub.act srs+(sa srs.act sorc)] + $usage ~[nom+s+nom.act add+b+add.act tas+(sa tas.act cord:enjs)] :: $phrase ~[aud+(audi aud.act) ses+a+(turn ses.act spec:enjs)] :: diff --git a/sur/hall.hoon b/sur/hall.hoon index 499799627..3d3bfd995 100644 --- a/sur/hall.hoon +++ b/sur/hall.hoon @@ -16,6 +16,7 @@ ::TODO rename ++ name term :< circle name ++ nick cord :< local nickname +++ tags (set knot) :< usage tags :: :> # :> # %query-models @@ -110,6 +111,7 @@ $% {$full cof/config} :< set w/o side-effects {$source add/? src/source} :< add/rem sources {$caption cap/cord} :< changed description + {$usage add/? tas/tags} :< add/rem usage tags {$filter fit/filter} :< changed filter {$secure sec/security} :< changed security {$permit add/? sis/(set ship)} :< add/rem to b/w-list @@ -136,11 +138,13 @@ ++ action :> user action $% :: circle configuration :: {$create nom/name des/cord sec/security} :< create circle + {$design nom/name cof/config} :< create with config {$delete nom/name why/(unit cord)} :< delete + announce {$depict nom/name des/cord} :< change description {$filter nom/name fit/filter} :< change message rules {$permit nom/name inv/? sis/(set ship)} :< invite/banish {$source nom/name sub/? srs/(set source)} :< un/sub to/from src + {$usage nom/name add/? tas/tags} :< add/rem usage tags :: messaging :: {$convey tos/(list thought)} :< post exact {$phrase aud/audience ses/(list speech)} :< post easy @@ -178,6 +182,7 @@ ++ config :> circle config $: src/(set source) :< active sources cap/cord :< description + tag/tags :< usage tags fit/filter :< message rules con/control :< restrictions == :: From 4acc7b372b782c73d1afdeec62070aecc4e25655 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Feb 2018 17:20:52 +0100 Subject: [PATCH 161/184] No longer automatically send invite messages when changing permissions. --- app/hall.hoon | 8 -------- app/talk.hoon | 6 +++++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index b9f7322bf..2d5656527 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -1392,14 +1392,6 @@ =/ sus/(set ship) %. sis.con.shape ?:(add ~(dif in sis) ~(int in sis)) - =. +>.$ - :: if banishing: notify only those affected. - :: if inviting: notify all targets. - =? sis !inv sus - =- (so-act [%phrase - [%inv inv so-cir]~]) - %- ~(rep in `(set ship)`sis) - |= {s/ship a/audience} - (~(put in a) [s %inbox]) ?~ sus +>.$ :: if banished, remove their presences. =? +>.$ !inv diff --git a/app/talk.hoon b/app/talk.hoon index 7e59c8a9c..01e353ff4 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -1180,7 +1180,11 @@ :: |= {inv/? nom/name sis/(set ship)} ^+ ..sh-work - (sh-act %permit nom inv sis) + =. ..sh-work (sh-act %permit nom inv sis) + =- (sh-act %phrase - [%inv inv [self nom]]~) + %- ~(rep in sis) + |= {s/ship a/audience} + (~(put in a) [s %inbox]) :: ++ filter |= {nom/name cus/? utf/?} From 50eeea9f069444eb6fa2f58f21b6ae73dd9b8ec8 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Feb 2018 21:46:44 +0100 Subject: [PATCH 162/184] Help kiln transition by inlining new types. These should be removed after an update has happened. --- lib/hood/kiln.hoon | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/hood/kiln.hoon b/lib/hood/kiln.hoon index 3dbe9e561..f1842587a 100644 --- a/lib/hood/kiln.hoon +++ b/lib/hood/kiln.hoon @@ -67,7 +67,7 @@ {$dirk wire @tas} :: {$ogre wire $@(@tas beam)} :: {$merg wire @p @tas @p @tas case germ} :: - {$perm wire ship desk path rite:clay} :: + {$perm wire ship desk path rite} :: {$poke wire dock pear} :: {$wipe wire @p $~} :: {$wait wire @da} :: @@ -86,6 +86,13 @@ q/path r/cage == + ++ rite ::tmp + $% {$r red/(unit rule)} + {$w wit/(unit rule)} + {$rw red/(unit rule) wit/(unit rule)} + == + ++ rule {mod/?($black $white) who/(set whom)} ::tmp + ++ whom (each ship @ta) ::tmp -- |_ moz/(list move) ++ abet :: resolve From 7d8a0a36a3ffea0a2ece14ca6b02f56618a318de Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Feb 2018 22:41:52 +0100 Subject: [PATCH 163/184] Add state adapters. --- app/hall.hoon | 14 ++++++++++++-- app/talk.hoon | 12 ++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 2d5656527..b3cde9bd5 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -110,6 +110,13 @@ $% {$repeat cir/circle ses/(list serial)} :< messaging wire {$circle nom/name src/source} :< subscription wire == :: + :: + ++ old-state + (cork state |=(a/state a(stories (~(run by stories.a) old-story)))) + ++ old-story + (cork story |=(a/story a(shape *old-config, mirrors (~(run by mirrors.a) old-config)))) + ++ old-config + {src/(set source) cap/cord fit/filter con/control} -- :: :> # @@ -125,12 +132,15 @@ ++ prep :> adapts state. :: - |= old/(unit state) + |= old/(unit old-state) ^- (quip move _..prep) ?~ old %- pre-bake ta-done:ta-init:ta - [~ ..prep(+<+ u.old)] + =- [~ ..prep(+<+ `state`u.old(stories -))] + %- ~(run by stories.u.old) + |= soy/old-story + (story soy(shape [src cap ~ fit con]:shape.soy)) :: :> # %engines :> main cores. diff --git a/app/talk.hoon b/app/talk.hoon index 01e353ff4..01741e0ac 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -105,6 +105,11 @@ {$help $~} :< print usage info == :: ++ glyphs `wall`~[">=+-" "}),." "\"'`^" "$%&@"] :< circle char pool ' + :: + ++ old-state + (cork state |=(a/state a(mirrors (~(run by mirrors.a) old-config)))) + ++ old-config + {src/(set source) cap/cord fit/filter con/control} -- :: :> # @@ -121,11 +126,14 @@ ++ prep :> adapts state :: - |= old/(unit state) + |= old/(unit old-state) ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - [~ ..prep(+<+ u.old)] + =- [~ ..prep(+<+ `state`u.old(mirrors -))] + %- ~(run by mirrors.u.old) + |= old-config + [src cap ~ fit con] :: :> # :> # %utility From b40103a05980a26e5bd03f436dc4221adc02fdfb Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Fri, 16 Feb 2018 13:14:04 -0800 Subject: [PATCH 164/184] Revert "updates ++boil:ap to crash if a book has pages with the same tag" --- sys/hoon.hoon | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index ffffbf557..35a287dfb 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -7457,21 +7457,12 @@ [%axil %void] ?~ t.p.gen boil(gen i.p.gen) - =/ def bile(gen i.p.gen) - =| tag/(set term) - =? tag ?=($& -.def) (~(put in tag) `@tas`q.p.p.def) - =/ end - =| lit/(list line) - |- ^+ lit - =/ tar bile(gen i.t.p.gen) - ?. ?=($& -.tar) - ~_(leaf+"book-foul" !!) - =/ hed `@tas`q.p.p.tar - ?: (~(has in tag) hed) - ~_(leaf+"book-dup-page: {}" !!) - =. lit [+.tar lit] - ?~ t.t.p.gen lit - $(tag (~(put in tag) hed), t.p.gen t.t.p.gen) + =+ :* def=bile(gen i.p.gen) + ^= end ^- (list line) + ~_ leaf+"book-foul" + %+ turn `(list hoon)`t.p.gen + |=(a/hoon =+(bile(gen a) ?>(?=($& -<) ->))) + == ?- -.def $& [%kelp p.def end] $| ?~(end p.def [%fern p.def [%kelp end] ~]) From 94a72a74f6c91904a1ca01c77d2677c00761137c Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 19 Feb 2018 15:31:13 +0100 Subject: [PATCH 165/184] Pulled subscriptions can no longer cause a story to be created. This doesn't seem to be an issue for other arms, but the fact that that isn't immediately clear is cause for mild concern. --- app/hall.hoon | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index b3cde9bd5..8063bd23f 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2672,11 +2672,10 @@ |= pax/path ^- (quip move _+>) %- pre-bake - :_ ~ =+ qer=(path-to-query %circle pax) ?> ?=($circle -.qer) - :+ %story nom.qer - [%peer | src.bol qer] + ?. (~(has by stories) nom.qer) ~ + [%story nom.qer %peer | src.bol qer]~ :: ++ reap :> subscription n/ack From 344fb38bc6f26eb8b4fc9ee32af0aaf9085f5145 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 19 Feb 2018 16:23:58 +0100 Subject: [PATCH 166/184] Make hall's ++prep more robust. --- app/hall.hoon | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 8063bd23f..62a007619 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -110,13 +110,6 @@ $% {$repeat cir/circle ses/(list serial)} :< messaging wire {$circle nom/name src/source} :< subscription wire == :: - :: - ++ old-state - (cork state |=(a/state a(stories (~(run by stories.a) old-story)))) - ++ old-story - (cork story |=(a/story a(shape *old-config, mirrors (~(run by mirrors.a) old-config)))) - ++ old-config - {src/(set source) cap/cord fit/filter con/control} -- :: :> # @@ -124,7 +117,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall state} +|_ {bol/bowl:gall $1 state} :: :> # %transition :> prep transition @@ -132,15 +125,35 @@ ++ prep :> adapts state. :: - |= old/(unit old-state) + => |% + ++ states + ?(state-0 $%({$1 s/state})) + :: + ++ state-0 + (cork state |=(a/state a(stories (~(run by stories.a) story-0)))) + ++ story-0 + %+ cork story + |=(a/story a(shape *config-0, mirrors (~(run by mirrors.a) config-0))) + ++ config-0 + {src/(set source) cap/cord fit/filter con/control} + -- + =| mos/(list move) + |= old/(unit states) ^- (quip move _..prep) ?~ old %- pre-bake ta-done:ta-init:ta - =- [~ ..prep(+<+ `state`u.old(stories -))] - %- ~(run by stories.u.old) - |= soy/old-story - (story soy(shape [src cap ~ fit con]:shape.soy)) + ?- -.u.old + $1 + [mos ..prep(+<+ u.old)] + :: + ?($~ ^) :: $0 + =- $(old `[%1 u.old(stories -)]) + %- ~(run by stories.u.old) + |= soy/story-0 + ^- story + (story soy(shape [src cap ~ fit con]:shape.soy)) + == :: :> # %engines :> main cores. From d070c182704276697fb3f2a56866ad0bc7391400 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 19 Feb 2018 17:10:12 +0100 Subject: [PATCH 167/184] Make talk's ++prep more robust. Jumps through a weird hoop to work with non-versioned state. --- app/talk.hoon | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 01741e0ac..b3ab83b5d 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -105,11 +105,6 @@ {$help $~} :< print usage info == :: ++ glyphs `wall`~[">=+-" "}),." "\"'`^" "$%&@"] :< circle char pool ' - :: - ++ old-state - (cork state |=(a/state a(mirrors (~(run by mirrors.a) old-config)))) - ++ old-config - {src/(set source) cap/cord fit/filter con/control} -- :: :> # @@ -117,7 +112,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall state} +|_ {bol/bowl:gall $1 state} :: :> # %transition :> prep transition @@ -126,14 +121,31 @@ ++ prep :> adapts state :: - |= old/(unit old-state) + => |% + ++ states + ?(state-0 $%({$1 s/state})) + :: + ++ state-0 + (cork state |=(a/state a(mirrors (~(run by mirrors.a) config-0)))) + ++ config-0 + {src/(set source) cap/cord fit/filter con/control} + -- + =| mos/(list move) + |= old/(unit states) ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - =- [~ ..prep(+<+ `state`u.old(mirrors -))] - %- ~(run by mirrors.u.old) - |= old-config - [src cap ~ fit con] + ?+ -.u.old + :: $0 + =+ ole=(state-0 u.old) + =- $(old `[%1 ole(mirrors -)]) + %- ~(run by mirrors.ole) + |= config-0 + [src cap ~ fit con] + :: + $1 + [mos ..prep(+<+ [%1 (state +.u.old)])] + == :: :> # :> # %utility From 3452d8756ec01c81e3fb4fe434ec6e79c1427c08 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 19 Feb 2018 18:36:41 +0100 Subject: [PATCH 168/184] Fixed error in #417, use "type" instead of "span". --- sys/hoon.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index 20c316649..358909f41 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -9449,7 +9449,7 @@ {$cell *} | {$core *} dext(ref repo(sut ref)) {$face *} dext(ref q.ref) - {$fork *} (levy ~(tap in p.ref) |=(span dext(ref +<))) + {$fork *} (levy ~(tap in p.ref) |=(type dext(ref +<))) {$help *} dext(ref q.ref) {$hold *} ?: (~(has in reg) ref) & ?: (~(has in gil) [sut ref]) & From 3e43963426e1691cb13802ae845099f7cb757170 Mon Sep 17 00:00:00 2001 From: Fang Date: Mon, 19 Feb 2018 20:55:00 +0100 Subject: [PATCH 169/184] Ensure that %remove diffs actually get sent out for those interested in config. In the future, this should also go out to those interested in group, and delete the remote group when it is received. --- app/hall.hoon | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 62a007619..764a0572c 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -911,7 +911,8 @@ $bear (so-bear bur.rum) $peer (so-delta-our rum) $gram (so-open src nev.rum) - $remove (so-delta-our %config src %remove ~) + $remove ::TODO should also remove from {remotes}? + (so-delta-our %config src %remove ~) :: $new ?: =(src so-cir) @@ -2336,6 +2337,7 @@ ?+ -.det %hasnot $gram %grams $new %config-l + $remove %config-l $config ?: =(cir.det [our.bol nom]) %config-l %config-r $status ?: =(cir.det [our.bol nom]) @@ -2428,10 +2430,15 @@ ?. =(nom.qer nom.det) ~ ?. %- circle-feel-story [wer.qer wat.qer nom.det det.det] ~ - =/ sor (~(got by stories) nom.qer) - ?. =< in %. ran.qer - ~(so-in-range so:ta nom.qer ~ sor) ~ - ?. ?=(?($gram $new $config $status) -.det.det) ~ + ?. ?| ?=($remove -.det.det) + :: + =< in %. ran.qer + =+ soy=(~(got by stories) nom.qer) + ~(so-in-range so:ta nom.qer ~ soy) + == + ~ + =+ out=?($gram $new $config $status $remove) + ?. ?=(out -.det.det) ~ :+ ~ %circle ?+ det.det det.det {$gram *} From 66533b7aa6f28bdc25e9c5f9844880214a819c12 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 19 Feb 2018 18:59:16 -0800 Subject: [PATCH 170/184] propagate cache properly when erroring inside /_ --- sys/vane/ford.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vane/ford.hoon b/sys/vane/ford.hoon index 3e2a20afd..4b004000e 100644 --- a/sys/vane/ford.hoon +++ b/sys/vane/ford.hoon @@ -1583,7 +1583,7 @@ |= {cof/cafe dir/knot} =+ nod=(chap(s.how [dir s.how]) cof bax hon) ?: ?=($2 -.q.nod) - (flue cof) + (flue p.nod) (cope nod (flux some)) %- flux |= doy/(map @ cage) ^- vase From 8a4e3c865651f3ff3d7dff5052d6d017ec5b528d Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 21 Feb 2018 13:23:58 +0100 Subject: [PATCH 171/184] Revert "Add usage tags to circle configs, allowing clients to store arbitrary meta usage info." This reverts commit e807db905589253892b3872226ae3f7cb90c2fac. --- app/hall.hoon | 31 ------------------------------- app/talk.hoon | 1 - lib/hall-json.hoon | 4 ---- lib/hall.hoon | 9 --------- mar/hall/action.hoon | 4 ---- sur/hall.hoon | 5 ----- 6 files changed, 54 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 764a0572c..2924f32dd 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -339,13 +339,11 @@ ?- -.act :: circle configuration $create (action-create +.act) - $design (action-design +.act) $source (action-source +.act) $depict (action-depict +.act) $filter (action-filter +.act) $permit (action-permit +.act) $delete (action-delete +.act) - $usage (action-usage +.act) :: messaging $convey (action-convey +.act) $phrase (action-phrase +.act) @@ -409,7 +407,6 @@ %^ impact nom %new :* [[[our.bol nom] ~] ~ ~] des - ~ *filter :- typ ?. ?=(?($village $journal) typ) ~ @@ -417,14 +414,6 @@ == (ta-evil (crip "{(trip nom)}: already exists")) :: - ++ action-design - :> creates a story with the specified config. - :: - |= {nom/name cof/config} - ?. (~(has in stories) nom) - (impact nom %new cof) - (ta-evil (crip "{(trip nom)}: already exists")) - :: ++ action-delete :> delete + announce :> @@ -472,15 +461,6 @@ (ta-evil (crip "no story {(trip nom)}")) so-done:(~(so-sources so nom ~ u.soy) sub srs) :: - ++ action-usage - :> add or remove usage tags. - :: - |= {nom/name add/? tas/tags} - =+ soy=(~(get by stories) nom) - ?~ soy - (ta-evil (crip "no story {(trip nom)}")) - so-done:(~(so-usage so nom ~ u.soy) add tas) - :: :> # %messaging +| ++ action-convey @@ -1146,17 +1126,6 @@ ?: =(cap cap.shape) +> (so-delta-our %config so-cir %caption cap) :: - ++ so-usage - :> add or remove usage tags. - :: - |= {add/? tas/tags} - ^+ +> - =/ sas/tags - %. tag.shape - ?:(add ~(dif in tas) ~(int in tas)) - ?~ sas +>.$ - (so-delta-our %config so-cir %usage add sas) - :: ++ so-filter :> change message rules :> diff --git a/app/talk.hoon b/app/talk.hoon index b3ab83b5d..c43ab5f69 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -1852,7 +1852,6 @@ $(dif [%filter fit.cof.dif]) ?: ?=($remove -.dif) (sh-note (weld "rip " (~(cr-show cr cir) ~))) - ?: ?=($usage -.dif) +> %- sh-note %+ weld (weld ~(cr-phat cr cir) ": ") diff --git a/lib/hall-json.hoon b/lib/hall-json.hoon index 2bf9a1779..bcdb7697d 100644 --- a/lib/hall-json.hoon +++ b/lib/hall-json.hoon @@ -178,7 +178,6 @@ $full (conf cof.a) $source (pairs add+b+add.a src+(sorc src.a) ~) $caption s+cap.a - $usage (pairs add+b+add.a tas+(sa tas.a cord) ~) $filter (filt fit.a) $secure s+sec.a $permit (pairs add+b+add.a sis+(sa sis.a ship) ~) @@ -230,7 +229,6 @@ %- pairs :~ src+(sa src.a sorc) cap+s+cap.a - tag+(sa tag.a cord) fit+(filt fit.a) con+(cont con.a) == @@ -427,7 +425,6 @@ %- of :~ full+conf source+(ot add+bo src+sorc ~) - usage+(ot add+bo tas+(as so) ~) caption+so filter+filt secure+secu @@ -472,7 +469,6 @@ %- ot :~ src+(as sorc) cap+so - tag+(as so) fit+filt con+cont == diff --git a/lib/hall.hoon b/lib/hall.hoon index ff6d7401e..a543d882c 100644 --- a/lib/hall.hoon +++ b/lib/hall.hoon @@ -126,15 +126,6 @@ $caption cof(cap cap.dif) $filter cof(fit fit.dif) $remove cof - :: - $usage - %= cof - tag - %. tas.dif - ?: add.dif - ~(uni in tag.cof) - ~(dif in tag.cof) - == :: $source %= cof diff --git a/mar/hall/action.hoon b/mar/hall/action.hoon index 09381cf86..24ae2dcab 100644 --- a/mar/hall/action.hoon +++ b/mar/hall/action.hoon @@ -16,13 +16,11 @@ ^- action:hall =- (need ((of -) a)) :~ create+(ot nom+so des+so sec+secu ~) - design+(ot nom+so cof+conf ~) delete+(ot nom+so why+(mu so) ~) depict+(ot nom+so des+so ~) filter+(ot nom+so fit+filt ~) permit+(ot nom+so inv+bo sis+(as (su fed:ag)) ~) source+(ot nom+so sub+bo srs+(as sorc) ~) - usage+(ot nom+so add+bo tas+(as so) ~) :: convey+(ar thot) phrase+(ot aud+audi ses+(ar spec:dejs:hall-json) ~) @@ -48,13 +46,11 @@ %- pairs ?- -.act $create ~[nom+s+nom.act des+s+des.act sec+s+sec.act] - $design ~[nom+s+nom.act cof+(conf cof.act)] $delete ~[nom+s+nom.act why+(mabe why.act cord:enjs)] $depict ~[nom+s+nom.act des+s+des.act] $filter ~[nom+s+nom.act fit+(filt fit.act)] $permit ~[nom+s+nom.act inv+b+inv.act sis+(sa sis.act ship)] $source ~[nom+s+nom.act sub+b+sub.act srs+(sa srs.act sorc)] - $usage ~[nom+s+nom.act add+b+add.act tas+(sa tas.act cord:enjs)] :: $phrase ~[aud+(audi aud.act) ses+a+(turn ses.act spec:enjs)] :: diff --git a/sur/hall.hoon b/sur/hall.hoon index 3d3bfd995..499799627 100644 --- a/sur/hall.hoon +++ b/sur/hall.hoon @@ -16,7 +16,6 @@ ::TODO rename ++ name term :< circle name ++ nick cord :< local nickname -++ tags (set knot) :< usage tags :: :> # :> # %query-models @@ -111,7 +110,6 @@ $% {$full cof/config} :< set w/o side-effects {$source add/? src/source} :< add/rem sources {$caption cap/cord} :< changed description - {$usage add/? tas/tags} :< add/rem usage tags {$filter fit/filter} :< changed filter {$secure sec/security} :< changed security {$permit add/? sis/(set ship)} :< add/rem to b/w-list @@ -138,13 +136,11 @@ ++ action :> user action $% :: circle configuration :: {$create nom/name des/cord sec/security} :< create circle - {$design nom/name cof/config} :< create with config {$delete nom/name why/(unit cord)} :< delete + announce {$depict nom/name des/cord} :< change description {$filter nom/name fit/filter} :< change message rules {$permit nom/name inv/? sis/(set ship)} :< invite/banish {$source nom/name sub/? srs/(set source)} :< un/sub to/from src - {$usage nom/name add/? tas/tags} :< add/rem usage tags :: messaging :: {$convey tos/(list thought)} :< post exact {$phrase aud/audience ses/(list speech)} :< post easy @@ -182,7 +178,6 @@ ++ config :> circle config $: src/(set source) :< active sources cap/cord :< description - tag/tags :< usage tags fit/filter :< message rules con/control :< restrictions == :: From f1eeb66af084564fc9160bb697fed598b37f03d0 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 21 Feb 2018 15:03:16 +0100 Subject: [PATCH 172/184] Adapt state. --- app/hall.hoon | 31 +++++++++++++++++-------------- app/talk.hoon | 28 ++++++++++++++++------------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 2924f32dd..2fec45905 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -117,7 +117,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall $1 state} +|_ {bol/bowl:gall $2 state} :: :> # %transition :> prep transition @@ -127,15 +127,15 @@ :: => |% ++ states - ?(state-0 $%({$1 s/state})) + ?(state $%({$1 s/state-1} {$2 s/state})) :: - ++ state-0 - (cork state |=(a/state a(stories (~(run by stories.a) story-0)))) - ++ story-0 + ++ state-1 + (cork state |=(a/state a(stories (~(run by stories.a) story-1)))) + ++ story-1 %+ cork story - |=(a/story a(shape *config-0, mirrors (~(run by mirrors.a) config-0))) - ++ config-0 - {src/(set source) cap/cord fit/filter con/control} + |=(a/story a(shape *config-1, mirrors (~(run by mirrors.a) config-1))) + ++ config-1 + {src/(set source) cap/cord tag/(set knot) fit/filter con/control} -- =| mos/(list move) |= old/(unit states) @@ -144,15 +144,18 @@ %- pre-bake ta-done:ta-init:ta ?- -.u.old - $1 + $2 [mos ..prep(+<+ u.old)] :: - ?($~ ^) :: $0 - =- $(old `[%1 u.old(stories -)]) - %- ~(run by stories.u.old) - |= soy/story-0 + $1 + =- $(old `[%2 s.u.old(stories -)]) + %- ~(run by stories.s.u.old) + |= soy/story-1 ^- story - (story soy(shape [src cap ~ fit con]:shape.soy)) + (story soy(shape [src cap fit con]:shape.soy)) + :: + ?($~ ^) :: $0 + $(old `[%2 u.old]) == :: :> # %engines diff --git a/app/talk.hoon b/app/talk.hoon index c43ab5f69..0b134e47c 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -112,7 +112,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall $1 state} +|_ {bol/bowl:gall $2 state} :: :> # %transition :> prep transition @@ -123,12 +123,12 @@ :: => |% ++ states - ?(state-0 $%({$1 s/state})) + ?(state $%({$1 s/state-1} {$2 s/state})) :: - ++ state-0 - (cork state |=(a/state a(mirrors (~(run by mirrors.a) config-0)))) - ++ config-0 - {src/(set source) cap/cord fit/filter con/control} + ++ state-1 + (cork state |=(a/state a(mirrors (~(run by mirrors.a) config-1)))) + ++ config-1 + {src/(set source) cap/cord tag/(set knot) fit/filter con/control} -- =| mos/(list move) |= old/(unit states) @@ -137,14 +137,18 @@ ta-done:ta-init:ta ?+ -.u.old :: $0 - =+ ole=(state-0 u.old) - =- $(old `[%1 ole(mirrors -)]) - %- ~(run by mirrors.ole) - |= config-0 - [src cap ~ fit con] + $(old `[%2 u.old]) + :: + $2 + [mos ..prep(+<+ [%2 (state +.u.old)])] :: $1 - [mos ..prep(+<+ [%1 (state +.u.old)])] + :: we hard-cast here because it find-errors on s.u.old otherwise? + =+ ole=(state-1 +.u.old) + =- $(old `[%2 ole(mirrors -)]) + %- ~(run by mirrors.ole) + |= config-1 + [src cap fit con] == :: :> # From 99ec7aa21f752052d7fef2e206ec8d48f7c186b3 Mon Sep 17 00:00:00 2001 From: Joseph Bryan Date: Wed, 21 Feb 2018 18:45:03 -0500 Subject: [PATCH 173/184] fixes overflow on prompts greater than the terminal width --- lib/hood/drum.hoon | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/hood/drum.hoon b/lib/hood/drum.hoon index 217fc547e..a76d84291 100644 --- a/lib/hood/drum.hoon +++ b/lib/hood/drum.hoon @@ -392,8 +392,9 @@ ++ se-show :: show buffer, raw |= lin/(pair @ud stub:dill) ^+ +> + =. p.lin (add p.lin (lent-stye:klr q.lin)) ?: =(mir lin) +> - =. +> ?:(=(p.mir p.lin) +> (se-blit %hop (add p.lin (lent-stye:klr q.lin)))) + =. +> ?:(=(p.mir p.lin) +> (se-blit %hop p.lin)) =. +> ?:(=(q.mir q.lin) +> (se-blit %pom q.lin)) +>(mir lin) :: @@ -401,13 +402,13 @@ |= {pom/stub:dill lin/(pair @ud (list @c))} ^+ +> =/ pol (lent-char:klr pom) - =/ end (sub edg pol) =/ pos (add pol p.lin) ?: (gte (div (mul pol 100) edg) 35) :: old style (long prompt) - =/ off ?:((lte p.lin end) 0 (sub p.lin end)) + =/ off ?:((lte pos edg) 0 (sub pos edg)) %+ se-show (sub pos off) (swag:klr [off edg] (welp pom [*stye:dill q.lin]~)) + =/ end (sub edg pol) =. off ?: (gth p.lin (add end off)) (sub p.lin end) ?: (lth p.lin off) From cfd52cc2ae83bcab8559d338bfef16a2555ac02e Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 13:01:05 +0100 Subject: [PATCH 174/184] Make initial federation result send just the last 100 messages. --- app/hall.hoon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 2fec45905..2e5bc56e2 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -2192,9 +2192,9 @@ :: only auto-federate channels for now. ?. ?=($channel sec.con.shape.s) ~ :+ ~ n - :: share no more than 2k messages at once, for performance reasons. - :+ ?: (lte count.s 2.000) grams.s - (slag (sub count.s 2.000) grams.s) + :: share no more than the last 100, for performance reasons. + :+ ?: (lte count.s 100) grams.s + (slag (sub count.s 100) grams.s) [shape.s mirrors.s] [locals.s remotes.s] :: From 35d3b04d2147c77dc27bf0956e4abdb77092ae24 Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 14 Feb 2018 16:54:51 +0100 Subject: [PATCH 175/184] Add usage tags to circle configs, allowing clients to store arbitrary meta usage info. --- app/hall.hoon | 31 +++++++++++++++++++++++++++++++ app/talk.hoon | 1 + lib/hall-json.hoon | 4 ++++ lib/hall.hoon | 9 +++++++++ mar/hall/action.hoon | 4 ++++ sur/hall.hoon | 5 +++++ 6 files changed, 54 insertions(+) diff --git a/app/hall.hoon b/app/hall.hoon index 2e5bc56e2..68d6fd418 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -342,11 +342,13 @@ ?- -.act :: circle configuration $create (action-create +.act) + $design (action-design +.act) $source (action-source +.act) $depict (action-depict +.act) $filter (action-filter +.act) $permit (action-permit +.act) $delete (action-delete +.act) + $usage (action-usage +.act) :: messaging $convey (action-convey +.act) $phrase (action-phrase +.act) @@ -410,6 +412,7 @@ %^ impact nom %new :* [[[our.bol nom] ~] ~ ~] des + ~ *filter :- typ ?. ?=(?($village $journal) typ) ~ @@ -417,6 +420,14 @@ == (ta-evil (crip "{(trip nom)}: already exists")) :: + ++ action-design + :> creates a story with the specified config. + :: + |= {nom/name cof/config} + ?. (~(has in stories) nom) + (impact nom %new cof) + (ta-evil (crip "{(trip nom)}: already exists")) + :: ++ action-delete :> delete + announce :> @@ -464,6 +475,15 @@ (ta-evil (crip "no story {(trip nom)}")) so-done:(~(so-sources so nom ~ u.soy) sub srs) :: + ++ action-usage + :> add or remove usage tags. + :: + |= {nom/name add/? tas/tags} + =+ soy=(~(get by stories) nom) + ?~ soy + (ta-evil (crip "no story {(trip nom)}")) + so-done:(~(so-usage so nom ~ u.soy) add tas) + :: :> # %messaging +| ++ action-convey @@ -1129,6 +1149,17 @@ ?: =(cap cap.shape) +> (so-delta-our %config so-cir %caption cap) :: + ++ so-usage + :> add or remove usage tags. + :: + |= {add/? tas/tags} + ^+ +> + =/ sas/tags + %. tag.shape + ?:(add ~(dif in tas) ~(int in tas)) + ?~ sas +>.$ + (so-delta-our %config so-cir %usage add sas) + :: ++ so-filter :> change message rules :> diff --git a/app/talk.hoon b/app/talk.hoon index 0b134e47c..f6eebf662 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -1856,6 +1856,7 @@ $(dif [%filter fit.cof.dif]) ?: ?=($remove -.dif) (sh-note (weld "rip " (~(cr-show cr cir) ~))) + ?: ?=($usage -.dif) +> %- sh-note %+ weld (weld ~(cr-phat cr cir) ": ") diff --git a/lib/hall-json.hoon b/lib/hall-json.hoon index bcdb7697d..2bf9a1779 100644 --- a/lib/hall-json.hoon +++ b/lib/hall-json.hoon @@ -178,6 +178,7 @@ $full (conf cof.a) $source (pairs add+b+add.a src+(sorc src.a) ~) $caption s+cap.a + $usage (pairs add+b+add.a tas+(sa tas.a cord) ~) $filter (filt fit.a) $secure s+sec.a $permit (pairs add+b+add.a sis+(sa sis.a ship) ~) @@ -229,6 +230,7 @@ %- pairs :~ src+(sa src.a sorc) cap+s+cap.a + tag+(sa tag.a cord) fit+(filt fit.a) con+(cont con.a) == @@ -425,6 +427,7 @@ %- of :~ full+conf source+(ot add+bo src+sorc ~) + usage+(ot add+bo tas+(as so) ~) caption+so filter+filt secure+secu @@ -469,6 +472,7 @@ %- ot :~ src+(as sorc) cap+so + tag+(as so) fit+filt con+cont == diff --git a/lib/hall.hoon b/lib/hall.hoon index a543d882c..ff6d7401e 100644 --- a/lib/hall.hoon +++ b/lib/hall.hoon @@ -126,6 +126,15 @@ $caption cof(cap cap.dif) $filter cof(fit fit.dif) $remove cof + :: + $usage + %= cof + tag + %. tas.dif + ?: add.dif + ~(uni in tag.cof) + ~(dif in tag.cof) + == :: $source %= cof diff --git a/mar/hall/action.hoon b/mar/hall/action.hoon index 24ae2dcab..09381cf86 100644 --- a/mar/hall/action.hoon +++ b/mar/hall/action.hoon @@ -16,11 +16,13 @@ ^- action:hall =- (need ((of -) a)) :~ create+(ot nom+so des+so sec+secu ~) + design+(ot nom+so cof+conf ~) delete+(ot nom+so why+(mu so) ~) depict+(ot nom+so des+so ~) filter+(ot nom+so fit+filt ~) permit+(ot nom+so inv+bo sis+(as (su fed:ag)) ~) source+(ot nom+so sub+bo srs+(as sorc) ~) + usage+(ot nom+so add+bo tas+(as so) ~) :: convey+(ar thot) phrase+(ot aud+audi ses+(ar spec:dejs:hall-json) ~) @@ -46,11 +48,13 @@ %- pairs ?- -.act $create ~[nom+s+nom.act des+s+des.act sec+s+sec.act] + $design ~[nom+s+nom.act cof+(conf cof.act)] $delete ~[nom+s+nom.act why+(mabe why.act cord:enjs)] $depict ~[nom+s+nom.act des+s+des.act] $filter ~[nom+s+nom.act fit+(filt fit.act)] $permit ~[nom+s+nom.act inv+b+inv.act sis+(sa sis.act ship)] $source ~[nom+s+nom.act sub+b+sub.act srs+(sa srs.act sorc)] + $usage ~[nom+s+nom.act add+b+add.act tas+(sa tas.act cord:enjs)] :: $phrase ~[aud+(audi aud.act) ses+a+(turn ses.act spec:enjs)] :: diff --git a/sur/hall.hoon b/sur/hall.hoon index 499799627..3d3bfd995 100644 --- a/sur/hall.hoon +++ b/sur/hall.hoon @@ -16,6 +16,7 @@ ::TODO rename ++ name term :< circle name ++ nick cord :< local nickname +++ tags (set knot) :< usage tags :: :> # :> # %query-models @@ -110,6 +111,7 @@ $% {$full cof/config} :< set w/o side-effects {$source add/? src/source} :< add/rem sources {$caption cap/cord} :< changed description + {$usage add/? tas/tags} :< add/rem usage tags {$filter fit/filter} :< changed filter {$secure sec/security} :< changed security {$permit add/? sis/(set ship)} :< add/rem to b/w-list @@ -136,11 +138,13 @@ ++ action :> user action $% :: circle configuration :: {$create nom/name des/cord sec/security} :< create circle + {$design nom/name cof/config} :< create with config {$delete nom/name why/(unit cord)} :< delete + announce {$depict nom/name des/cord} :< change description {$filter nom/name fit/filter} :< change message rules {$permit nom/name inv/? sis/(set ship)} :< invite/banish {$source nom/name sub/? srs/(set source)} :< un/sub to/from src + {$usage nom/name add/? tas/tags} :< add/rem usage tags :: messaging :: {$convey tos/(list thought)} :< post exact {$phrase aud/audience ses/(list speech)} :< post easy @@ -178,6 +182,7 @@ ++ config :> circle config $: src/(set source) :< active sources cap/cord :< description + tag/tags :< usage tags fit/filter :< message rules con/control :< restrictions == :: From f5cb07948f68634aadae5480581bf51a18a2bfc9 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 15:17:12 +0100 Subject: [PATCH 176/184] Clean up ++prep of hall and talk. --- app/hall.hoon | 24 +++--------------------- app/talk.hoon | 26 +++++--------------------- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/app/hall.hoon b/app/hall.hoon index 68d6fd418..b5ff955d8 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -117,7 +117,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall $2 state} +|_ {bol/bowl:gall $0 state} :: :> # %transition :> prep transition @@ -127,15 +127,7 @@ :: => |% ++ states - ?(state $%({$1 s/state-1} {$2 s/state})) - :: - ++ state-1 - (cork state |=(a/state a(stories (~(run by stories.a) story-1)))) - ++ story-1 - %+ cork story - |=(a/story a(shape *config-1, mirrors (~(run by mirrors.a) config-1))) - ++ config-1 - {src/(set source) cap/cord tag/(set knot) fit/filter con/control} + $%({$0 s/state}) -- =| mos/(list move) |= old/(unit states) @@ -144,18 +136,8 @@ %- pre-bake ta-done:ta-init:ta ?- -.u.old - $2 + $0 [mos ..prep(+<+ u.old)] - :: - $1 - =- $(old `[%2 s.u.old(stories -)]) - %- ~(run by stories.s.u.old) - |= soy/story-1 - ^- story - (story soy(shape [src cap fit con]:shape.soy)) - :: - ?($~ ^) :: $0 - $(old `[%2 u.old]) == :: :> # %engines diff --git a/app/talk.hoon b/app/talk.hoon index f6eebf662..8ecc9a223 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -112,7 +112,7 @@ :> # :> functional cores and arms. :: -|_ {bol/bowl:gall $2 state} +|_ {bol/bowl:gall $0 state} :: :> # %transition :> prep transition @@ -123,32 +123,16 @@ :: => |% ++ states - ?(state $%({$1 s/state-1} {$2 s/state})) - :: - ++ state-1 - (cork state |=(a/state a(mirrors (~(run by mirrors.a) config-1)))) - ++ config-1 - {src/(set source) cap/cord tag/(set knot) fit/filter con/control} + $%({$0 s/state}) -- =| mos/(list move) |= old/(unit states) ^- (quip move _..prep) ?~ old ta-done:ta-init:ta - ?+ -.u.old - :: $0 - $(old `[%2 u.old]) - :: - $2 - [mos ..prep(+<+ [%2 (state +.u.old)])] - :: - $1 - :: we hard-cast here because it find-errors on s.u.old otherwise? - =+ ole=(state-1 +.u.old) - =- $(old `[%2 ole(mirrors -)]) - %- ~(run by mirrors.ole) - |= config-1 - [src cap fit con] + ?- -.u.old + $0 + [mos ..prep(+<+ u.old)] == :: :> # From 0d647de57046d8f282103e950f0c721ed3c9c594 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 15:19:17 +0100 Subject: [PATCH 177/184] Clean up ++load of vanes. --- sys/vane/clay.hoon | 68 +++------------------------------------------- sys/vane/dill.hoon | 12 ++------ sys/vane/eyre.hoon | 11 ++------ sys/vane/ford.hoon | 2 +- sys/vane/gall.hoon | 44 ++---------------------------- 5 files changed, 13 insertions(+), 124 deletions(-) diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index be8cb4298..82648a890 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -3571,7 +3571,7 @@ :: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: =| :: instrument state - $: $4 :: vane version + $: $0 :: vane version ruf/raft :: revision tree == :: |= {now/@da eny/@ ski/sley} :: activate @@ -3832,72 +3832,12 @@ :: ++ load => |% - += wove-3 rove - ++ cult-3 (jug wove-3 duct) - ++ dojo-3 - $: qyx/cult-3 - dom/dome - dok/(unit dork) - mer/(unit mery) - == - ++ rede-3 - $: lim/@da - ref/(unit rind) - qyx/cult-3 - dom/dome - dok/(unit dork) - mer/(unit mery) - == - ++ room-3 (cork room |=(a/room a(dos (~(run by dos.a) dojo-3)))) - ++ rung-3 (cork rung |=(a/rung a(rus (~(run by rus.a) rede-3)))) - ++ raft-3 - $: fat/(map ship room-3) - hoy/(map ship rung-3) - ran/rang - mon/(map term beam) - hez/(unit duct) - == - ++ axle $%({$3 ruf/raft-3} {$4 ruf/raft}) + ++ axle $%({$0 ruf/raft}) -- |= old/axle ^+ ..^$ ?- -.old - $4 ..^$(ruf ruf.old) - $3 |^ - =- ^$(old [%4 -]) - =+ ruf.old - :* (~(run by fat) rom) - (~(run by hoy) run) - ran mon hez ~ - == - :: - ++ wov - |= a/wove-3 ^- wove - [~ a] - :: - ++ cul - |= a/cult-3 ^- cult - %- ~(gas by *cult) - %+ turn ~(tap by a) - |= {p/wove-3 q/(set duct)} - [(wov p) q] - :: - ++ rom - |= room-3 - :- hun - %- ~(urn by dos) - |= {d/desk dojo-3} - =/ n/dojo [(cul qyx) dom dok mer ~ ~] - ?. =(%kids d) n - n(per [[/ %black ~] ~ ~]) - :: - ++ run - =/ red - |= rede-3 - =+ [[/ %black ~] ~ ~] - [lim ref (cul qyx) dom dok mer - -] - |=(a/rung-3 a(rus (~(run by rus.a) red))) - -- + $0 ..^$(ruf ruf.old) == :: ++ scry :: inspect @@ -3929,7 +3869,7 @@ ?: ?=($& -.u.u.-) ``p.u.u.- ~ :: -++ stay [%4 ruf] +++ stay [%0 ruf] ++ take :: accept response |= {tea/wire hen/duct hin/(hypo sign)} ^+ [p=*(list move) q=..^$] diff --git a/sys/vane/dill.hoon b/sys/vane/dill.hoon index 72493a0ae..4c68ae188 100644 --- a/sys/vane/dill.hoon +++ b/sys/vane/dill.hoon @@ -7,15 +7,9 @@ ++ gill (pair ship term) :: general contact -- :: => |% :: console protocol -++ all-axle ?(old-axle axle) :: -++ old-axle :: all dill state - $: $2 :: - ore/(unit ship) :: identity once set - hey/(unit duct) :: default duct - dug/(map duct axon) :: conversations - == :: +++ all-axle ?(axle) :: ++ axle :: - $: $3 :: + $: $0 :: ore/(unit ship) :: identity once set hey/(unit duct) :: default duct dug/(map duct axon) :: conversations @@ -520,8 +514,6 @@ :: ++ load :: trivial |= old/all-axle - ?: ?=($2 -.old) - $(old [%3 ore hey dug ~ ~ ~ ~ ~ ~]:old) ..^$(all old) :: |= old=* :: diable :: ..^$(ore.all `~zod) diff --git a/sys/vane/eyre.hoon b/sys/vane/eyre.hoon index 2b21228bb..eec028e8f 100644 --- a/sys/vane/eyre.hoon +++ b/sys/vane/eyre.hoon @@ -85,7 +85,7 @@ -- :: |% :: models ++ bolo :: eyre state - $: $6 :: version + $: $0 :: version gub/@t :: random identity hov/(unit ship) :: master for remote top/beam :: ford serve prefix @@ -2025,15 +2025,10 @@ ~ :: ++ load :: take previous state - =+ driv-5=_=>(*driv [cor=p req=req.q]) - =+ bolo-5={$5 _=+(*bolo +.-(sec (~(run by sec.-) driv-5)))} - =+ bolo-4={$4 _%*(+ *bolo-5 lyv *(map duct ^))} ::|= * %. (bolo +<) - |= old/?(bolo bolo-5 bolo-4) ^+ ..^$ + |= old/?(bolo) ^+ ..^$ ?- -.old - $6 ..^$(+>- old) - $5 $(old [%6 +.old(sec (~(run by sec.old) |=(driv-5 [cor & req])))]) - $4 $(old [%5 +.old(lyv ~)]) :: minor leak + $0 ..^$(+>- old) == :: ++ scry diff --git a/sys/vane/ford.hoon b/sys/vane/ford.hoon index e0c6f077a..1fcb60c89 100644 --- a/sys/vane/ford.hoon +++ b/sys/vane/ford.hoon @@ -33,7 +33,7 @@ -- :: |% :: structures ++ axle :: all %ford state - $: $2 :: version for update + $: $0 :: version for update pol/(map ship baby) :: == :: ++ baby :: state by ship diff --git a/sys/vane/gall.hoon b/sys/vane/gall.hoon index bd5aba4f2..99d587897 100644 --- a/sys/vane/gall.hoon +++ b/sys/vane/gall.hoon @@ -31,27 +31,11 @@ -- :: |% :::::::::::::::::::::::::::::::::::::::::::::::::::::: %gall state :::::::::::::::::::::::::::::::::::::::::::::::::::::: -++ axle-n ?(axle-1 axle-2 axle-3 axle-4) :: upgrade path -++ axle-1 {$1 pol/(map ship mast-1)} :: -++ mast-1 :: - (cork mast-2 |=(mast-2 +<(bum (~(run by bum) seat-1)))) :: -++ seat-1 :: - (cork seat-2 |=(seat-2 +<+)) :: -++ axle-2 {$2 pol/(map ship mast-2)} :: -++ mast-2 (cork mast-3 |=(mast-3 +<+)) :: -++ seat-2 seat-3 :: -++ axle-3 {$3 pol/(map ship mast-3)} :: -++ mast-3 :: - (cork mast-4 |=(mast-4 +<(bum (~(run by bum) seat-3)))) :: -++ seat-3 :: - (cork seat-4 |=(seat-4 +<+)) :: -++ axle-4 axle :: -++ mast-4 mast :: -++ seat-4 seat :: +++ axle-n ?(axle) :: upgrade path :::::::::::::::::::::::::::::::::::::::::::::::::::::: state proper :::::::::::::::::::::::::::::::::::::::::::::::::::::: ++ axle :: all state - $: $4 :: state version + $: $0 :: state version pol/(map ship mast) :: apps by ship == :: ++ gest :: subscriber data @@ -1311,29 +1295,7 @@ |= old/axle-n ^+ ..^$ ?- -.old - $4 ..^$(all old) - $3 - %= $ - old ^- axle-4 - => |=(seat-3 `seat-4`[*misvale-data +<]) - => |=(mast-3 +<(bum (~(run by bum) +>))) - old(- %4, pol (~(run by pol.old) .)) - == - :: - $2 - %= $ - old ^- axle-3 - => |=(mast-2 [*(unit duct) +<]) - old(- %3, pol (~(run by pol.old) .)) - == - :: - $1 - %= $ - old ^- axle-2 - => |=(seat-1 `seat-2`[*worm +<]) - => |=(mast-1 +<(bum (~(run by bum) +>))) - old(- %2, pol (~(run by pol.old) .)) - == + $0 ..^$(all old) == :: ++ scry From 42803b305db56be2dbd0c71109d2935bb3c1c62f Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 15:28:58 +0100 Subject: [PATCH 178/184] Remove update crutch from kiln. --- lib/hood/kiln.hoon | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lib/hood/kiln.hoon b/lib/hood/kiln.hoon index f1842587a..c6f80ff6a 100644 --- a/lib/hood/kiln.hoon +++ b/lib/hood/kiln.hoon @@ -80,19 +80,6 @@ {$helm-reset $~} :: == :: ++ move (pair bone card) :: user-level move - ++ riot ::tmp up-to-date riot - %- unit - $: p/{p/?($d $p $u $v $w $x $y $z) q/case r/desk} - q/path - r/cage - == - ++ rite ::tmp - $% {$r red/(unit rule)} - {$w wit/(unit rule)} - {$rw red/(unit rule) wit/(unit rule)} - == - ++ rule {mod/?($black $white) who/(set whom)} ::tmp - ++ whom (each ship @ta) ::tmp -- |_ moz/(list move) ++ abet :: resolve From f7329c5872a019c6770d439f7bae90cdaed9d761 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Thu, 22 Feb 2018 10:03:13 -0500 Subject: [PATCH 179/184] escapes "{" in tape print (++dash:us) (#636) modifies ++dash:us to take a list of additional characters to escape --- app/dojo.hoon | 2 +- sys/hoon.hoon | 26 ++++++++++++++++---------- sys/vane/clay.hoon | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/dojo.hoon b/app/dojo.hoon index 657057f4a..d709a9b4f 100644 --- a/app/dojo.hoon +++ b/app/dojo.hoon @@ -549,7 +549,7 @@ $tang ;;(tang q.q.cay) $httr =+ hit=;;(httr:eyre q.q.cay) - =- (flop (turn `wall`- |=(a/tape leaf+(dash:us a '')))) + =- (flop (turn `wall`- |=(a/tape leaf+(dash:us a '' ~)))) :- "HTTP {}" %+ weld (turn q.hit |=({a/@t b/@t} "{(trip a)}: {(trip b)}")) diff --git a/sys/hoon.hoon b/sys/hoon.hoon index 358909f41..719d6c2c2 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -9907,14 +9907,20 @@ -- |_ sut/type ++ dash - |= {mil/tape lim/char} ^- tape - :- lim - |- ^- tape - ?~ mil [lim ~] - ?: =(lim i.mil) ['\\' i.mil $(mil t.mil)] - ?: =('\\' i.mil) ['\\' i.mil $(mil t.mil)] - ?: (lte ' ' i.mil) [i.mil $(mil t.mil)] - ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (end 2 1 i.mil)) $(mil t.mil)] + |= {mil/tape lim/char lam/tape} + ^- tape + =/ esc (~(gas in *(set @tD)) lam) + :- lim + |- ^- tape + ?~ mil [lim ~] + ?: ?| =(lim i.mil) + =('\\' i.mil) + (~(has in esc) i.mil) + == + ['\\' i.mil $(mil t.mil)] + ?: (lte ' ' i.mil) + [i.mil $(mil t.mil)] + ['\\' ~(x ne (rsh 2 1 i.mil)) ~(x ne (end 2 1 i.mil)) $(mil t.mil)] :: ++ deal |=(lum/* (dish dole lum)) ++ dial @@ -10046,7 +10052,7 @@ [(need ^$(q.ham %yarn, lum -.lum)) $(lum +.lum)] :: $yarn - [~ %leaf (dash (tape lum) '"')] + [~ %leaf (dash (tape lum) '"' "\{")] :: $void ~ @@ -10059,7 +10065,7 @@ ?+ (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig))) ~(rend co [%$ p.q.ham lum]) $$ ~(rend co [%$ %ud lum]) - $t (dash (rip 3 lum) '\'') + $t (dash (rip 3 lum) '\'' ~) $tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])] == :: diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index be8cb4298..e0a66a2cf 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -1012,7 +1012,7 @@ |= a/cord ?: ((sane %ta) a) [%leaf (trip a)] - [%leaf (dash:us (trip a) '\'')] + [%leaf (dash:us (trip a) '\'' ~)] $(p.lem t.p.lem) == :: From 2c07f0ab25f39271de0ca21a9a96af7a584fb99c Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 19:11:41 +0100 Subject: [PATCH 180/184] Bump ames protocol version. Now set in a single constant. --- sys/vane/ames.hoon | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/vane/ames.hoon b/sys/vane/ames.hoon index 06ce563d2..389159f66 100644 --- a/sys/vane/ames.hoon +++ b/sys/vane/ames.hoon @@ -4,6 +4,7 @@ => =~ :: structures =, ames +=+ protocol-version=0 |% += move [p=duct q=(wind note:able gift:able)] :: local move -- @@ -385,7 +386,7 @@ vix=(bex +((cut 0 [25 2] mag))) :: width of sender tay=(cut 0 [27 5] mag) :: message type == - ?> =(7 vez) + ?> =(protocol-version vez) ?> =(chk (end 0 20 (mug bod))) :+ [(end 3 wix bod) (cut 3 [wix vix] bod)] (kins tay) @@ -405,7 +406,7 @@ =+ tay=(ksin q.kec) %+ mix %+ can 0 - :~ [3 7] + :~ [3 protocol-version] [20 (mug bod)] [2 yax] [2 qax] @@ -995,7 +996,7 @@ ++ gnaw :: gnaw:am |= [kay=cape ryn=lane pac=rock] :: process packet ^- [p=(list boon) q=fort] - ?. =(7 (end 0 3 pac)) [~ fox] + ?. =(protocol-version (end 0 3 pac)) [~ fox] =+ kec=(bite pac) ?: (goop p.p.kec) [~ fox] ?. (~(has by urb.ton.fox) q.p.kec) From 4c16ecba89432bf722e7c7ef98b6d7dfcc8d2934 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 19:11:59 +0100 Subject: [PATCH 181/184] Remove trailing whitespace from ames. --- sys/vane/ames.hoon | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sys/vane/ames.hoon b/sys/vane/ames.hoon index 389159f66..f90a9d0eb 100644 --- a/sys/vane/ames.hoon +++ b/sys/vane/ames.hoon @@ -1,4 +1,4 @@ -:: :: ames (4a), networking +:: :: ames (4a), networking :: |= pit=vase => =~ @@ -160,7 +160,7 @@ 0w0 :: 42, ~tul, Curtis Yarvin 0w0 :: 43, ~met, Curtis Yarvin 0w0 :: 44, ~wen, Curtis Yarvin - 0w0 :: 45, ~byn, Curtis Yarvin + 0w0 :: 45, ~byn, Curtis Yarvin 0w0 :: 46, ~hex, James Torre 0w0 :: 47, ~feb, urbit.org 0wK.GoKEY.rMjfn.ZcvFQ.n4BmX :: 48, ~pyl, Michael Hartl (oldkey) @@ -172,7 +172,7 @@ 0w0 :: 54, ~wyd, Curtis Yarvin 0w0 :: 55, ~tep, Curtis Yarvin 0w0 :: 56, ~bes, Curtis Yarvin - 0w0 :: 57, ~dex, Jared Hance + 0w0 :: 57, ~dex, Jared Hance 0w0 :: 58, ~sef, Owen Rescher 0w0 :: 59, ~wyc, Galen Wolfe-Pauly 0w0 :: 60, ~bur, Galen Wolfe-Pauly @@ -976,10 +976,10 @@ |= [our=ship ger=@uw fak=?] :: instantiate emperor ^- [p=(list boon) q=fort] =+ ^= loy - ?: fak + ?: fak :: fake uses carrier number as seed :: - (pit:nu:crub:crypto 512 our) + (pit:nu:crub:crypto 512 our) (pit:nu:crub:crypto 512 ger) =+ fim==(fig:ex:loy (zeno our)) ?: &(!fak !fim) !! :: not fake & bad fig @@ -1115,7 +1115,7 @@ :: it now, since it obviously won't be processed. :: ~& [%fail-ack did.rum] - =^ gud +>.$ + =^ gud +>.$ (cook ``[%dead-message ~] cha `[q.u.cun r.u.cun]) ?. gud +>.$ %= +>.$ @@ -1276,15 +1276,15 @@ :: or negative ack if this ship is blocked :: =* cop ^- coop - %+ fall - (~(get by bum.rum) num) + %+ fall + (~(get by bum.rum) num) ?:(bad ~ ``[%blocked ~]) con:(cook (~(get by bum.rum) num) cha `[ryn dam]) :: :: insert this message in unprocessed set :: =. mis.rum (~(put by mis.rum) num [kay ryn dam dut]) - :: + :: :: if ship is blocked, advance pointer to latest message :: =. did.rum ?.(bad did.rum num) @@ -1553,7 +1553,7 @@ (hunt lth doz rtn.sop.bah) :: ++ load - |= old=fort + |= old=fort ~& %ames-reload ..^$(fox old) :: @@ -1614,7 +1614,7 @@ :_ fox [hen %pass pax i.q.q.bon %west p.bon t.q.q.bon r.bon]~ :: %ouzo - :: ~& [%send now p.bon `@p`(mug (shaf %flap q.bon))] + :: ~& [%send now p.bon `@p`(mug (shaf %flap q.bon))] :_ fox [[gad.fox [%give %send p.bon q.bon]] ~] :: @@ -1684,7 +1684,7 @@ ?: ?=(%wegh -.kyz) ~& %ames-weighing [[hen %give %mass wegh]~ +>] - =+ ^= fuy + =+ ^= fuy ^- [p=(list boon) q=fort] ?- -.kyz %barn From de59162ff3b3af1979e620fc485d7dd87ebb850f Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 19:32:51 +0100 Subject: [PATCH 182/184] Talk now only loads in messages from the last five days on first boot. Makes moons suffer less when connecting to old planets. --- app/talk.hoon | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/talk.hoon b/app/talk.hoon index 8ecc9a223..5e5d76607 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -29,9 +29,10 @@ |% ++ state :> application state $: :: messaging state :: - count/@ud :< (lent grams) grams/(list telegram) :< all history known/(map serial @ud) :< messages heard + last/@ud :< last heard + count/@ud :< (lent grams) sources/(set circle) :< our subscriptions :: circle details :: remotes/(map circle group) :< remote presences @@ -226,7 +227,9 @@ server :: %+ welp /circle/[inbox]/grams/config/group - ?:(=(0 count) ~ [(scot %ud count) ~]) + ?. =(0 last) + [(scot %ud last) ~] + [(scot %da (sub now.bol ~d5)) ~] == :: :> # @@ -367,7 +370,7 @@ ~&([%unexpected-circle-rumor -.rum] +>) :: $gram - (ta-learn gam.nev.rum) + (ta-open nev.rum) :: $config =+ cur=(fall (~(get by mirrors) cir.rum) *config) @@ -453,15 +456,16 @@ :: |= nes/(list envelope) ^+ +> - (ta-lesson (turn nes tail)) + ?~ nes +> + $(nes t.nes, +> (ta-open i.nes)) :: - ++ ta-lesson - :> learn all telegrams in a list. + ++ ta-open + :> learn message from an envelope. :: - |= gaz/(list telegram) + |= nev/envelope ^+ +> - ?~ gaz +> - $(gaz t.gaz, +> (ta-learn i.gaz)) + =? last (gth num.nev last) num.nev + (ta-learn gam.nev) :: ++ ta-learn :> save/update message @@ -2458,7 +2462,7 @@ == ?: =(a 'reset') ~& 'full reset incoming, hold on to your cli...' - :_ +>(grams ~, known ~, count 0) + :_ +>(grams ~, known ~, count 0, last 0) :~ [ost.bol %pull /server/client server ~] [ost.bol %pull /server/inbox server ~] peer-client From 6bb3a3f1964919500910361dc172b1276ca4759f Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 19:44:13 +0100 Subject: [PATCH 183/184] Named magic number. --- app/talk.hoon | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index 5e5d76607..b6f879da6 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -229,7 +229,8 @@ %+ welp /circle/[inbox]/grams/config/group ?. =(0 last) [(scot %ud last) ~] - [(scot %da (sub now.bol ~d5)) ~] + =+ history-days=~d5 + [(scot %da (sub now.bol history-days)) ~] == :: :> # From 62edfa5d210600481801604f71cac984ba417f25 Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 22 Feb 2018 19:47:56 +0100 Subject: [PATCH 184/184] Be semantically correct. --- app/talk.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/talk.hoon b/app/talk.hoon index b6f879da6..d6553ce88 100644 --- a/app/talk.hoon +++ b/app/talk.hoon @@ -227,7 +227,7 @@ server :: %+ welp /circle/[inbox]/grams/config/group - ?. =(0 last) + ?. =(0 count) [(scot %ud last) ~] =+ history-days=~d5 [(scot %da (sub now.bol history-days)) ~]