<feed xmlns='http://www.w3.org/2005/Atom'>
<title>access-control/.gitignore, branch ai/test-branch</title>
<subtitle>Unnamed repository
</subtitle>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/'/>
<entry>
<title>Layout: cmd/, src/, test/, everything built into obj/</title>
<updated>2026-11-14T00:06:35+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T00:06:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=bc7f4da406fbd802b08985ba583e52f040bdba85'/>
<id>bc7f4da406fbd802b08985ba583e52f040bdba85</id>
<content type='text'>
The tree had grown sideways: main.c living among the sources it dispatches to,
one test binary covering everything, object files left in the source directory
because the Makefile put them there and, worse, tracked them.

Now the command line is cmd/main.c, the engine is src/ and nothing in it knows
about the command line, and each area of the engine has its own program under
test/ - glob, norm, parse, need, check - each linking the library and reporting
its own count.  A failure says which area broke instead of taking the whole run
down with a single "unit: 171" line, which is the only thing a per-file split
buys and it is worth the small duplication the shared test.h absorbs.

Objects go to obj/, test runners to obj/test_runner/, so a build leaves the
tree as it found it.  The stale src/*.o and tests/unit that were committed
earlier are gone; they were build output in a source tree and the .gitignore
that should have stopped them arrived after they did.

The Makefile follows the same shape as the other C trees here: directories in
variables, wildcards for the sources, one pattern rule that makes its own
directory, test runners built from the same objects as the binary so they
cannot test a different build than ships, and `test` running every runner with
a foreach so the first failure stops the line.  `strict` is `all` with -Werror,
which is what CI now calls instead of passing CFLAGS in from outside; the
sanitizer and install targets are unchanged in what they do.

Behaviour is unchanged: 171 direct checks and 154 behavioural ones, same as
before the move, and make install still stages a working hook symlink.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The tree had grown sideways: main.c living among the sources it dispatches to,
one test binary covering everything, object files left in the source directory
because the Makefile put them there and, worse, tracked them.

Now the command line is cmd/main.c, the engine is src/ and nothing in it knows
about the command line, and each area of the engine has its own program under
test/ - glob, norm, parse, need, check - each linking the library and reporting
its own count.  A failure says which area broke instead of taking the whole run
down with a single "unit: 171" line, which is the only thing a per-file split
buys and it is worth the small duplication the shared test.h absorbs.

Objects go to obj/, test runners to obj/test_runner/, so a build leaves the
tree as it found it.  The stale src/*.o and tests/unit that were committed
earlier are gone; they were build output in a source tree and the .gitignore
that should have stopped them arrived after they did.

The Makefile follows the same shape as the other C trees here: directories in
variables, wildcards for the sources, one pattern rule that makes its own
directory, test runners built from the same objects as the binary so they
cannot test a different build than ships, and `test` running every runner with
a foreach so the first failure stops the line.  `strict` is `all` with -Werror,
which is what CI now calls instead of passing CFLAGS in from outside; the
sanitizer and install targets are unchanged in what they do.

Behaviour is unchanged: 171 direct checks and 154 behavioural ones, same as
before the move, and make install still stages a working hook symlink.
</pre>
</div>
</content>
</entry>
<entry>
<title>git-authz: one C program for who may move which refs</title>
<updated>2026-11-13T19:04:50+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-13T19:04:50+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=f87a792743227ea06cfa1580f8d30a618b4d1a04'/>
<id>f87a792743227ea06cfa1580f8d30a618b4d1a04</id>
<content type='text'>
A git host that anonymous-clones and shared-pushes has one question left to
answer: which human may move which ref.  This answers it from one plain file,
in one binary, with no runtime beyond libc.

Four modes, because they must agree exactly about what a rule means - a check
that answers differently from the hook is a program that lies:

  check      one question, for an operator or a script
  authorize  a whole push, the way core.hooksPath hands it over: identity from
             GIT_HOST_USER (ssh key option) or REMOTE_USER (http auth), and one
             "old new ref" line per ref on stdin.  Also runs as "pre-receive",
             which is how git finds it.
  validate   does the policy parse, and is the host wired to run it
  edit       grant, revoke, protect (the deployed policy is a read-only mount on
             purpose, so these are for the source copy and say so when told)

The verdict is the exit status, since the caller is a hook: 0 allowed, 1 denied,
3 no usable policy, 64 usage.  A policy that cannot be read or does not parse
denies everything rather than guessing, and one bad line poisons the whole file
on purpose: a mistyped rule that quietly widens access is worse than an evening
of refused pushes.

Semantics kept from the shell engine this replaces: levels are monotone (admin
implies force implies write), rules add up rather than order, "@" is only
everyone the policy already names, protected refs cost one step more than the
action asked for, and refs that are neither branches nor tags are for admins.
"main", "heads/main" and "refs/heads/main" are one branch; a bare name is never
a tag.

Two facts a push does not carry - is old an ancestor of new, and which branch
HEAD points at - are asked of git, and an answer that cannot be had is taken the
expensive way.  tests/unit.c covers the matcher directly (173 checks); the
behavioural suite that drives this the way git does follows next.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A git host that anonymous-clones and shared-pushes has one question left to
answer: which human may move which ref.  This answers it from one plain file,
in one binary, with no runtime beyond libc.

Four modes, because they must agree exactly about what a rule means - a check
that answers differently from the hook is a program that lies:

  check      one question, for an operator or a script
  authorize  a whole push, the way core.hooksPath hands it over: identity from
             GIT_HOST_USER (ssh key option) or REMOTE_USER (http auth), and one
             "old new ref" line per ref on stdin.  Also runs as "pre-receive",
             which is how git finds it.
  validate   does the policy parse, and is the host wired to run it
  edit       grant, revoke, protect (the deployed policy is a read-only mount on
             purpose, so these are for the source copy and say so when told)

The verdict is the exit status, since the caller is a hook: 0 allowed, 1 denied,
3 no usable policy, 64 usage.  A policy that cannot be read or does not parse
denies everything rather than guessing, and one bad line poisons the whole file
on purpose: a mistyped rule that quietly widens access is worse than an evening
of refused pushes.

Semantics kept from the shell engine this replaces: levels are monotone (admin
implies force implies write), rules add up rather than order, "@" is only
everyone the policy already names, protected refs cost one step more than the
action asked for, and refs that are neither branches nor tags are for admins.
"main", "heads/main" and "refs/heads/main" are one branch; a bare name is never
a tag.

Two facts a push does not carry - is old an ancestor of new, and which branch
HEAD points at - are asked of git, and an answer that cannot be had is taken the
expensive way.  tests/unit.c covers the matcher directly (173 checks); the
behavioural suite that drives this the way git does follows next.
</pre>
</div>
</content>
</entry>
</feed>
