Clean up %clay-live to %c, %gall-live to %g

This commit is contained in:
Elliot Glaysher 2018-03-30 13:21:08 -07:00
parent 9520999b00
commit aded7050fa
2 changed files with 48 additions and 66 deletions

View File

@ -27,11 +27,11 @@
:: pinned-schematic shows a once build
::
=/ pinned-schematic=schematic:ford
[%pin now [%scry [%clay-live care=%x bel=[[~nul %desk] /foo/bar]]]]
[%pin now [%scry [%c care=%x bel=[[~nul %desk] /foo/bar]]]]
:: live-schematic shows a live build
::
=/ live-schematic=schematic:ford
[%scry [%clay-live care=%x bel=[[~nul %desk] /baz/doo]]]
[%scry [%c care=%x bel=[[~nul %desk] /baz/doo]]]
:: eternal-schematic shows a trivial live build
::
=/ eternal-schematic=schematic:ford
@ -58,11 +58,11 @@
=/ ford (ford-turbo now=~1234.5.6 eny=0xdead.beef scry=scry-is-forbidden)
::
=/ six-schematic=schematic:ford
[%pin ~1234.5.6 [%scry [%clay-live care=%x bel=[[~nul %desk] /foo/bar]]]]
[%pin ~1234.5.6 [%scry [%c care=%x bel=[[~nul %desk] /foo/bar]]]]
=/ nine-schematic=schematic:ford
[%pin ~1234.5.9 [%scry [%clay-live care=%x bel=[[~nul %desk] /baz/doo]]]]
[%pin ~1234.5.9 [%scry [%c care=%x bel=[[~nul %desk] /baz/doo]]]]
=/ three-schematic=schematic:ford
[%pin ~1234.5.3 [%scry [%clay-live care=%x bel=[[~nul %desk] /car/dor]]]]
[%pin ~1234.5.3 [%scry [%c care=%x bel=[[~nul %desk] /car/dor]]]]
;: welp
::
%- expect-eq !>
@ -93,21 +93,21 @@
::
;: welp
%- expect-eq !>
:- `path`(to-wire:ford [%clay-live care=%x bel=[[~nul %desk] /foo/bar]])
:- `path`(to-wire:ford [%c care=%x bel=[[~nul %desk] /foo/bar]])
/c/x/~nul/desk/0/bar/foo
::
%- expect-eq !>
:- `dependency:ford`[%clay-live care=%x bel=[[~nul %desk] /foo/bar]]
:- `dependency:ford`[%c care=%x bel=[[~nul %desk] /foo/bar]]
(from-wire:ford /c/x/~nul/desk/0/bar/foo)
::
%- expect-eq !>
:- ^- path
(to-wire:ford [%gall-live care=%x bel=[[~nul %desk] /foo/bar]])
(to-wire:ford [%g care=%x bel=[[~nul %desk] /foo/bar]])
/g/x/~nul/desk/0/bar/foo
::
%- expect-eq !>
:- ^- dependency:ford
[%gall-live care=%x bel=[[~nul %desk] /foo/bar]]
[%g care=%x bel=[[~nul %desk] /foo/bar]]
(from-wire:ford /g/x/~nul/desk/0/bar/foo)
==
::
@ -187,7 +187,7 @@
=^ moves ford
%- call:ford
:* duct=~ type=~ %make ~nul
[%pin ~1234.5.6 [%scry %clay-live ren=%x rail=[[~nul %desk] /bar/foo]]]
[%pin ~1234.5.6 [%scry %c ren=%x rail=[[~nul %desk] /bar/foo]]]
==
%+ welp
%- expect-eq !>
@ -209,7 +209,7 @@
=^ moves ford
%- call:ford
:* duct=~ type=~ %make ~nul
[%pin ~1234.5.6 [%scry %clay-live ren=%x rail=[[~nul %desk] /bar/foo]]]
[%pin ~1234.5.6 [%scry %c ren=%x rail=[[~nul %desk] /bar/foo]]]
::
==
%+ welp
@ -217,7 +217,7 @@
:- moves
:~ :* duct=~ %give %made ~1234.5.6 %complete
%result %pin ~1234.5.6 %error
:~ leaf+"clay-live scry failed for"
:~ leaf+"scry failed for"
leaf+"%cx /~nul/desk/~1234.5.6/foo/bar"
== == ==
::
@ -234,7 +234,7 @@
=^ moves ford
%- call:ford
:* duct=~ type=~ %make ~nul
[%pin ~1234.5.6 [%scry %clay-live ren=%x rail=[[~nul %desk] /bar/foo]]]
[%pin ~1234.5.6 [%scry %c ren=%x rail=[[~nul %desk] /bar/foo]]]
==
%+ welp
%- expect-eq !>
@ -276,7 +276,7 @@
=^ moves ford
%- call:ford
:* duct=~ type=~ %make ~nul
[%scry %clay-live care=%x rail=[[~nul %desk] /bar/foo]]
[%scry %c care=%x rail=[[~nul %desk] /bar/foo]]
==
;: welp
%- expect-eq !>
@ -331,7 +331,7 @@
::
=/ schematic=schematic:ford
:* %same %pin ~1234.5.6
[%scry %clay-live care=%x rail=[[~nul %desk] /bar/foo]]
[%scry %c care=%x rail=[[~nul %desk] /bar/foo]]
==
=/ build=build:ford [~1234.5.6 schematic]
=/ result=build-result:ford
@ -346,16 +346,16 @@
%- expect-eq !>
:- results:(~(got by state-by-ship.+>+<.ford) ~nul)
%- my :~
:- [~1234.5.6 [%scry %clay-live care=%x rail=[[~nul %desk] /bar/foo]]]
:- [~1234.5.6 [%scry %c care=%x rail=[[~nul %desk] /bar/foo]]]
[%result ~1234.5.6 %result %scry %noun !>(42)]
::
:- :* ~1234.5.6 %pin ~1234.5.6
[%scry %clay-live care=%x rail=[[~nul %desk] /bar/foo]]
[%scry %c care=%x rail=[[~nul %desk] /bar/foo]]
==
[%result ~1234.5.6 %result %pin ~1234.5.6 %result %scry %noun !>(42)]
::
:- :* ~1234.5.6 %same %pin ~1234.5.6
[%scry %clay-live care=%x rail=[[~nul %desk] /bar/foo]]
[%scry %c care=%x rail=[[~nul %desk] /bar/foo]]
==
:* %result ~1234.5.6 %result %same %result %pin ~1234.5.6
%result %scry %noun !>(42)

View File

@ -73,12 +73,18 @@
:: +dependency: dependency on a value from the urbit namespace
::
+= dependency
$% :: live dependency on a clay path; varies with time
$: :: vane which we are querying
::
[%clay-live care=care:clay =rail]
:: live dependency on a gall path; varies with time
vane=?(%c %g)
:: type of request
::
[%gall-live care=care:clay =rail]
:: TODO: care:clay should be cleaned up in zuse as it is a general
:: type, not a clay specific one.
::
care=care:clay
:: path on which to depend, missing time which will be filled in
::
=rail
==
:: +build-result: the referentially transparent result of a +build
::
@ -910,24 +916,7 @@
++ to-wire
|= =dependency
^- wire
:: todo: remove %clay-live, %gall-live. replace with %c and %g. most of this
:: fucntion goes away.
::
::
|^ ?- -.dependency
%clay-live (encode %c)
%gall-live (encode %g)
==
:: +encode:to-wire: encode :vane, :care, :live, and :beam into a +wire
::
++ encode
|= vane=?(%c %g)
^- wire
::
=/ beam=beam (extract-beam dependency date=~)
::
[vane care.dependency (en-beam beam)]
--
[vane.dependency care.dependency (en-beam (extract-beam dependency date=~))]
:: +from-wire: decode a +dependency from a +wire
::
++ from-wire
@ -935,17 +924,15 @@
^- dependency
::
?> ?=([@ @ *] wire)
:: parse :wire's components into :vane, :care, :live, and :beam
:: parse :wire's components into :vane, :care, and :rail
::
=/ vane ((hard ?(%c %g)) i.wire)
=/ care ((hard care:clay) i.t.wire)
=/ beam (need (de-beam ((hard ^wire) t.t.wire)))
::
=/ beam (need (de-beam ((hard ^wire) t.t.wire)))
=/ rail [disc=[p.beam q.beam] spur=s.beam]
::
?: =(%c vane)
[%clay-live care rail]
[%gall-live care rail]
[vane care rail]
:: +extract-beam: obtain a +beam from a +dependency
::
:: Fills case with [%ud 0] for live dependencies if :date is `~`.
@ -953,21 +940,16 @@
::
++ extract-beam
|= [=dependency date=(unit @da)] ^- beam
?- -.dependency
?(%clay-live %gall-live)
::
=/ case=case ?~(date [%ud 0] [%da u.date])
::
=, rail.dependency
[[ship.disc desk.disc case] spur]
==
::
=/ case=case ?~(date [%ud 0] [%da u.date])
::
=, rail.dependency
[[ship.disc desk.disc case] spur]
:: +extract-disc: obtain a +disc from a +dependency
::
++ extract-disc
|= =dependency ^- disc
?- -.dependency
?(%clay-live %gall-live) disc.rail.dependency
==
disc.rail.dependency
:: +get-sub-schematics: find any schematics contained within :schematic
::
++ get-sub-schematics
@ -1198,7 +1180,7 @@
%+ turn ~(tap in care-paths)
|= [care=care:clay =path] ^- dependency
::
[%clay-live care bel=[disc spur=(flop path)]]
[%c care rail=[disc spur=(flop path)]]
:: store changed dependencies persistently in case rebuilds finish later
::
=. dependency-updates.state
@ -1468,7 +1450,7 @@
::
=/ dependency dependency.schematic.build
::
?. ?=(%clay-live -.dependency)
?. ?=(%c -.dependency)
|
::
=/ updates (fall (~(get by dependency-updates.state) date.build) ~)
@ -1568,7 +1550,7 @@
::
=/ dependency dependency.schematic.build
::
?. ?=(%clay-live -.dependency)
?. ?=(%c -.dependency)
this
::
=/ disc=disc disc.rail.dependency
@ -1739,7 +1721,7 @@
:: link :disc to :dependency
::
=? dependencies.state
&(live ?=(%clay-live -.dependency))
&(live ?=(%c -.dependency))
(~(put ju dependencies.state) [disc dependency])
:: perform scry operation if we don't already know the result
::
@ -1779,7 +1761,7 @@
=? latest-by-disc.state
?& live
::
?=(%clay-live -.dependency)
?=(%c -.dependency)
::
=/ latest-date (~(get by latest-by-disc.state) disc)
::
@ -1791,13 +1773,13 @@
:: mark :disc as dirty if we're building a live dependency
::
=? dirty-discs
&(live ?=(%clay-live -.dependency))
&(live ?=(%c -.dependency))
(~(put in dirty-discs) disc)
:: scry failed
::
?~ u.scry-response
=/ error=tang
:~ leaf+"clay-live scry failed for"
:~ leaf+"scry failed for"
leaf+"%c{(trip care.dependency)} {<(en-beam beam)>}"
==
[[%build-result %error error] this]
@ -1972,7 +1954,7 @@
%+ murn ~(tap in `(set dependency)`dependencies)
|= =dependency ^- (unit [care:clay path])
::
?. ?=(%clay-live -.dependency) ~
?. ?=(%c -.dependency) ~
::
`[care.dependency (flop spur.rail.dependency)]
:: if :request-contents is `~`, this code is incorrect
@ -2034,13 +2016,13 @@
(~(del ju blocks.state) dependency build)
:: check if :build depends on a live clay +dependency
::
=/ has-live-dependency ?=([%scry %clay-live *] schematic.build)
=/ has-live-dependency ?=([%scry %c *] schematic.build)
:: clean up dependency tracking and maybe cancel clay subscription
::
=? this has-live-dependency
:: type system didn't know, so tell it again
::
?> ?=([%scry %clay-live *] schematic.build)
?> ?=([%scry %c *] schematic.build)
::
=/ dependency dependency.schematic.build
=/ disc=disc (extract-disc dependency)