gunk-dev/the-valley

web.nix

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