Files
splinter/Makefile
T
Konrad 10e59f23ac splinter 0.1.0: loop, registry, session, transports, tests
Rebuilt from scratch after the previous attempt left no code behind: what
exists here is what compiles and what the tests prove, and nothing else is
claimed.

What is in it:
- a turn loop that refuses an over-budget request before sending it, reports
  unknown tools instead of guessing, and honours authorization classes
  (read runs, mutate/destructive ask unless --autonomous);
- a registry that is authoritative - the model names a tool, the registry
  decides whether it exists;
- an append-only JSONL session (O_APPEND, fsync per record), where a crash can
  only truncate the tail and the tail is skipped, not repaired;
- two transports: a deterministic mock (queue of replies, last request kept)
  and HTTP via curl(1) with the request body in a temp file;
- two builtins that exist to prove the classes: echo (read) and run
  (destructive, reports its exit status as an observation).

Five test binaries, no external framework, no network: mock driver covers the
answer path, a tool round, an unknown tool, a denial, autonomy, a failing tool,
the step limit, the byte budget (asserting that nothing was sent) and a
non-2xx reply.

The wire format is splinter's own line protocol (user/observe out,
answer/tool in); provider adapters translate. That is why the loop is testable
without a model, and why no vendor JSON is parsed in the core.
2026-11-07 08:06:34 +00:00

80 lines
2.3 KiB
Makefile

# splinter -- POSIX make, no GNU extensions, no shell helpers.
#
# `make` builds the binary
# `make check` builds and runs every test binary
# `make clean` removes generated files only
#
# Generated files never mix with handwritten ones, and nothing here needs a
# configure step: the dependency set is libc, plus curl(1) at runtime if you
# use --endpoint.
CC ?= cc
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Werror -D_POSIX_C_SOURCE=200809L -Iinclude
LDFLAGS ?=
LIBS ?=
BIN = splinter
OBJ = src/buf.o src/tool.o src/session.o src/transport.o src/transport_curl.o \
src/builtin.o src/agent.o
TESTS = tests/test_buf tests/test_tool tests/test_session tests/test_transport \
tests/test_agent
all: $(BIN)
$(BIN): $(OBJ) src/main.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) src/main.o $(LIBS)
src/buf.o: src/buf.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/buf.c
src/tool.o: src/tool.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/tool.c
src/session.o: src/session.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/session.c
src/transport.o: src/transport.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/transport.c
src/transport_curl.o: src/transport_curl.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/transport_curl.c
src/builtin.o: src/builtin.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/builtin.c
src/agent.o: src/agent.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/agent.c
src/main.o: src/main.c include/splinter.h
$(CC) $(CFLAGS) -c -o $@ src/main.c
tests/test_buf: tests/test_buf.c $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ tests/test_buf.c $(OBJ) $(LIBS)
tests/test_tool: tests/test_tool.c $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ tests/test_tool.c $(OBJ) $(LIBS)
tests/test_session: tests/test_session.c $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ tests/test_session.c $(OBJ) $(LIBS)
tests/test_transport: tests/test_transport.c $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ tests/test_transport.c $(OBJ) $(LIBS)
tests/test_agent: tests/test_agent.c $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ tests/test_agent.c $(OBJ) $(LIBS)
check: $(BIN) $(TESTS)
@set -e; for t in $(TESTS); do echo "== $$t"; ./$$t; done; \
echo "all tests passed"
install: $(BIN)
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp $(BIN) $(DESTDIR)$(PREFIX)/bin/
PREFIX ?= /usr/local
clean:
rm -f $(BIN) $(OBJ) src/main.o $(TESTS)
.PHONY: all check install clean