gunk-dev/the-valley

web.nix

source6d983a3125dfmain's published tip history
9.6 KiB
1# The web UI (web/): the shared export contract, the publisher, the
2# receiver, and the web server. Each check runs the unit test derivation
3# defined in nix/packages.nix.
4{
5 pkgs,
6 packages,
7 ...
8}:
9{
10 # The projection over the shared fixture, which holds every disclosure
11 # rule: what reaches export.json, hidden projects' edges, a knot that
12 # waits on a hidden knot marked with waiting_on_hidden alone, the field
13 # gone once its one hidden blocker is done, the display mapping. The
14 # content digest; strict reading of export.json, with
15 # nothing after its document; each of VerifyManifest's steps, in order;
16 # the manifest's grammar and its agreement with export.json; the
17 # streaming body check; bundle acceptance against real git, refusing
18 # wrong tips, prerequisites, extra refs, corrupt objects and a header
19 # past its bound, writing a commit-graph git verifies, and serving no
20 # commit main does not reach, nor one named in the other object
21 # format's length, alone or among several; git's
22 # output read within its limit, with git stopped past it or when its
23 # reader stops early; and the receiver's state directory. For the state
24 # directory: uploads/ stays private to the receiver and generations/ stays
25 # group- and world-readable under any umask; readers hold
26 # a generation through activations, every file of a generation is synced
27 # before high-water names it, a repository interrupted by a crash is
28 # rebuilt, recovery verifies a generation before activating it and keeps
29 # one whose git check was interrupted, and injected sweep and swap
30 # failures are reported separately from the commit; Stage and Activate
31 # wait for a held store lock only until their context expires, leaving
32 # staging and the active generation unchanged on cancellation; and an
33 # activation that exceeds MaxStorage is refused with its new repositories
34 # removed. An end-to-end pass uploads to a real valley-web-receive with
35 # its bearer token, a real valley-web serves the activated export, a pass
36 # with a wrong token fails as unauthenticated while the edge keeps serving,
37 # and a pass after withdrawing anyone's grant removes the project from the
38 # edge. go vet runs after the tests.
39 web-unit = packages.web.unit;
40
41 # Read access, which the publisher reads its consents through: both
42 # consents read out of real commits under the real schemas, an explicit
43 # empty reader set and an empty scope letting no one read, anyone's
44 # restrictions, no principal name special, a policy for another project
45 # and a grant for another identity covering nothing, other destinations'
46 # grants and expired principals' left out, policy/web never read, tree
47 # entries with a directory part or named twice refused before anything
48 # is copied out, a directory named twice on the way to a document
49 # refused, redeclared definitions widening nothing, a field spelled in
50 # another case than the schema's refused, and the coverage report over a
51 # real valley, with the registry read at its ref. go vet runs after them.
52 readaccess-unit = packages.readaccess.unit;
53
54 # The server and valley-web over the shared fixture, uploaded to a real
55 # store, and real git. The plan page's reading order, its free to start
56 # legend, its one card of ready changes, and the export's age, marked
57 # stale after five minutes; a knot's body and comments, with the edited
58 # one marked; a hidden project answering every route exactly as a
59 # missing one, though its repository is in the generation; a blocked
60 # knot's chip naming its published blockers and, once, unpublished
61 # work; projects
62 # named source, knots and web-export served on every route, and their
63 # roots redirected to their trees, while the server's own paths under
64 # /-/ are never a project's; a commit
65 # main's tip does not reach, and every other object ID or name, refused
66 # with the one 404; hostile README, file, file name, commit subject and
67 # knot text rendered inert, and large and binary files not shown; a
68 # reference into the hidden project naming nothing of it; a directory
69 # past MaxRead listed in part, and a 5 MiB commit message ending its
70 # page of history early; the directories along a path sharing one
71 # MaxRead; the older links of history showing every commit once through
72 # a merge whose lines run across pages, and every link of a page past
73 # MaxFrontier lines, or one ended before a merge past MaxLeftToShow,
74 # reaching every commit; a merge whose parents pass a record of git log
75 # shown, first on a page and further down, with its first MaxParents
76 # followed; a source request's git slot held for a bound of its own from
77 # admission, through a slow export read and its git, answering 503 and
78 # giving back its slot, and given back before it renders; a SHA-256
79 # project served by full commit IDs alone; a file of MaxFile newlines shown to MaxLines;
80 # a chain of knots near the graph's limit shown to MaxPlanDepth, with
81 # the plan's structure built once; the policy on every response,
82 # admitting the page's inline stylesheet and script by their hashes; a
83 # request keeping its generation while another activates; an export
84 # read once per generation, however many requests wait for it, across
85 # activations; a load started only by a request taking a loader slot,
86 # with requests that wait for one ending at their deadline or when
87 # their reader goes away, leaving no load behind and holding no
88 # generation; a load reading export.json from a slow pipe stopped part
89 # way once its one request's deadline passes, caching nothing and
90 # giving back its generation; a flood during a load keeping
91 # MaxLoadWaiting requests waiting and answering the rest 503, with the
92 # server's goroutines and open files bounded; source requests past
93 # MaxGit and MaxWaiting answering 503, with an activation while they
94 # wait and a deadline that covers the wait; a request held past its
95 # deadline before it renders answering 503; a page past MaxResponse on
96 # a knot, and past a smaller bound on a file, a directory, a page of
97 # history and the plan, answering the one short page that says it is
98 # too large; readers that never read holding no git slot and no
99 # generation, and, asking for more than MaxBuffered in large pages of
100 # three sizes, holding no more of the heap than it and no more than
101 # MaxLarge, their pages' starts counted, with a large page it has no
102 # room for answering 503 while the plan, a knot and a directory still
103 # render; and valley-web run as a process of its own, serving and
104 # stopping on SIGTERM, and serving every page from a read-only state
105 # directory that the receiver wrote under umask 0077 as another user. go
106 # vet runs after the tests.
107 web-server-unit = packages.valley-web.unit;
108
109 # The receiver binary, valley-web-receive, run as a subprocess over the
110 # shared fixture's signed export and real git. A three-step upload
111 # activates an export that a separate valley-web process serves from the
112 # same state directory, and re-posting the manifest or commit is refused
113 # as replayed. Requests with no token, a wrong token, a non-Bearer scheme,
114 # or two Authorization headers are refused as unauthenticated on every
115 # route without staging anything. Stale, future-dated, foreign-key, and
116 # foreign-destination manifests are refused; a manifest older than the
117 # staged one is refused as superseded while newer manifests replace staged
118 # bodies; and committing an unstaged sequence fails as no-manifest. Bodies
119 # with a hash mismatch, a size mismatch (with or without Content-Length),
120 # a Content-Encoding header, or an undeclared hash are refused; a
121 # concurrent upload of the same body receives 503; and an interrupted body
122 # upload leaves no partial file in staging, fails commit as incomplete
123 # while keeping the active export intact, and activates once re-sent in
124 # full. Manifests and bodies past --max-body or --max-upload fail as
125 # too-large before staging, while uploads at both caps succeed; a manifest
126 # reusing one bundle across eight projects fails when it exceeds
127 # --max-storage, and uploads within the cap succeed. When stalled
128 # manifests fill all 4 request slots, the next authenticated request gets
129 # 503 and an unauthenticated request still gets 401 while valley-web keeps
130 # serving, and uploads resume once the stalled clients disconnect. When 32
131 # connections stall in headers, valley-web keeps serving and a subsequent
132 # upload succeeds once the header timeout closes them. OPTIONS * with a
133 # withheld body on all 32 connections returns immediately so a following
134 # upload succeeds. A manifest request canceled while waiting for the store
135 # lock stages nothing. On SIGTERM the receiver drains and exits within its
136 # timeout even with all connections held, and CLI usage, token-file, and
137 # verifier-file errors exit without printing the token. Every test request
138 # and dial is bounded, and every subprocess exits with the test process.
139 # go vet runs after the tests.
140 web-receiver-unit = packages.valley-web-receive.unit;
141
142 # The edge container image, unpacked layer by layer: /bin/valley-web and
143 # /bin/valley-web-receive resolve to store paths inside the image along
144 # with the git binary embedded in each; /etc/passwd and /etc/group define
145 # valley-web-receive, valley-web, and their shared valley-web group;
146 # /var/lib/valley-web is the sole declared volume and is owned by
147 # valley-web-receive:valley-web with mode 0750; and the image defaults to
148 # user valley-web with no default entrypoint or command.
149 web-image = pkgs.runCommand "valley-web-image" {
150 nativeBuildInputs = [ pkgs.jq ];
151 image = packages.valley-web-image;
152 } (builtins.readFile ./web-image.sh);
153}