From bc7f4da406fbd802b08985ba583e52f040bdba85 Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 14 Nov 2026 00:06:35 +0000 Subject: Layout: cmd/, src/, test/, everything built into obj/ 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. --- README | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'README') diff --git a/README b/README index 8b5d9e3..f795411 100644 --- a/README +++ b/README @@ -220,14 +220,37 @@ Reading this as an operator hit it instead of a ticket to whoever set this up. +Layout +------ + + cmd/main.c the command line: dispatch, usage, exit status + src/ the engine, as a library the command line adds nothing to + test/ one program per area, plus the behavioural suite + build/ helpers used while building and installing + container/ the image: Dockerfile, entrypoint, server configuration + ci/ the pipeline + + src/glob.c the pattern matching, such as it is + src/util.c allocation, string buffers, writing a file atomically + src/policy.c reading the file, and answering from it + src/hook.c the mode git calls, and the only one a push depends on + src/validate.c does this policy, and the host around it, add up + src/edit.c grant and revoke, without losing the file + +Everything compiles into `obj/`, test runners included, so a build leaves the +tree as it found it apart from the binary. `git-authz` is one program rather +than several because every one of them has to answer "what does this rule mean" +identically: a `check` that disagrees with the hook is not two programs, it is +one that lies. + + Tests ----- make test -`tests/unit.c` tests the policy engine directly - matching, normalisation, the -ladder, `@all`, scope, the sentences - and is the place where the semantics -are pinned. `tests/run.sh` drives the binary the way git does: an identity in +The programs in `test/` test the engine directly - matching, normalisation, the +ladder, `@all`, scope, the sentences - and are where the semantics are pinned. `test/run.sh` drives the binary the way git does: an identity in the environment, `old new ref` lines on stdin, the repository as the working directory, the hook reached through its own name. It uses no git at all, so it runs anywhere a compiler does, and it tests the real binary rather than a model -- cgit v1.2.3