Artifact d310c7ec6d4d31bd26f9e047a6ee4b273a7dd07a35438cf35e0b72afc23957ae:
- File
Makefile
— part of check-in
[1d1b0294ce]
at
2026-11-18 17:12:31
on branch stage-2
— Add the SSE framer and Messages API stream decoder
The framer is provider-neutral and pure over bytes. The decoder enforces event order and rebuilds each content block from its start object, so thinking signatures and unknown block types replay verbatim. Eleven recorded streams are decoded whole, bytewise and chunked against frozen summaries, and a libFuzzer target checks chunking independence and that decoded content is a JSON array. (user: dmestas, size: 6371) [annotate] [blame] [check-ins using]
# pic harness plus S0/S1 qualification gates.
CC ?= cc
PYTHON ?= python3
export CC
.PHONY: all check metadata test test-reporting replay dst sanitize coverage-mcdc \
fuzz-smoke bench filc-remote qualify help assertion-guard local-evidence test-context test-context-sanitize test-remote \
pic pic-dev test-pic test-sse test-decode fuzz-decode
all: check
check: test-pic metadata test-reporting replay coverage-mcdc assertion-guard test-remote
@printf '%s\n' 'PASS: pic crash/recovery suite and local qualification gates.'
metadata:
$(PYTHON) -I -B test/test_contracts.py
$(PYTHON) -I -B tools/check_contracts.py
test-reporting:
$(PYTHON) -I -B test/test_toolchain.py
test:
sh tools/test-native.sh normal
# The normal suite includes the fixed 100-seed deterministic replay campaign.
dst: test
replay: test
sh tools/test-native.sh replay
sanitize:
sh tools/test-native.sh sanitize
coverage-mcdc:
sh tools/mcdc.sh
assertion-guard:
sh tools/test-assertions.sh
fuzz-smoke:
sh tools/test-native.sh fuzz
bench:
sh tools/benchmark.sh
test-context:
sh test/context/test-driver.sh normal
test-context-sanitize:
sh test/context/test-driver.sh sanitize
test-remote:
sh test/test_remote_lifecycle.sh
$(PYTHON) -I -B test/remote/test_collect.py
# Run actual local gates before snapshotting metadata; never reuse a stale PASS.
local-evidence:
mkdir -p build/qualification
rm -f build/qualification/local-evidence.json
$(MAKE) check sanitize fuzz-smoke bench > build/qualification/local-checks.log 2>&1
$(PYTHON) -I -B tools/evidence.py --log build/qualification/local-checks.log
$(PYTHON) -I -B tools/check_contracts.py --evidence build/qualification/local-evidence.json
# Remote evidence gate; actual host operations remain explicit.
filc-remote:
@test -n "$(REMOTE_RUN)" || { printf '%s\n' 'GATED: supply REMOTE_RUN=/absolute/completed/filc-run; see docs/remote-lifecycle.md'; exit 2; }
sh tools/remote/run.sh reconcile "$(REMOTE_RUN)" > "$(REMOTE_RUN)/operator-reconcile.log"
$(PYTHON) -I -B tools/remote/report.py "$(REMOTE_RUN)"
$(PYTHON) -I -B tools/check_contracts.py --evidence "$(REMOTE_RUN)/qualification.json"
qualify: check sanitize fuzz-smoke bench
@printf '%s\n' 'GATED: local fixture evidence is not release qualification.' \
'Production runtime/release contracts remain unqualified; remote fixture evidence is a separate explicit gate.'
@exit 2
help:
@printf '%s\n' 'S0 only: check, metadata, test, dst, replay, sanitize, coverage-mcdc,' \
'fuzz-smoke, bench, test-context, test-context-sanitize, test-remote.' \
'filc-remote verifies an explicit REMOTE_RUN; full production qualify remains GATED.'
# ---- pic: the harness ------------------------------------------------------
# Release has no test code and no fault hooks; dev adds ASan/UBSan and crash points.
PIC_SRC := src/store.c src/loop.c src/provider_fake.c src/tools.c src/sse.c src/anthropic.c src/main.c
PIC_HDR := src/pic.h src/sse.h src/anthropic.h
PIC_VENDOR := vendor/libfossil
PIC_SQLITE := -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1
PIC_WARN := -std=c11 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wconversion \
-Wstrict-prototypes -Wmissing-prototypes -Wvla -Wcast-qual -D_DEFAULT_SOURCE -D_DARWIN_C_SOURCE
PIC_INC := -Isrc -isystem $(PIC_VENDOR) -DHAVE_LIBFOSSIL_CONFIG_H
PIC_SAN := -O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=all
ifeq ($(shell uname -s),Darwin)
PIC_LIBS := -lz -lm -lpthread -liconv
else
PIC_LIBS := -lz -lm -lpthread -ldl
endif
build/pic/release/vendor/%.o: $(PIC_VENDOR)/%.c
@mkdir -p $(@D)
$(CC) -O2 $(PIC_SQLITE) -DHAVE_LIBFOSSIL_CONFIG_H -w -I$(PIC_VENDOR) -c -o $@ $<
build/pic/dev/vendor/%.o: $(PIC_VENDOR)/%.c
@mkdir -p $(@D)
$(CC) $(PIC_SAN) $(PIC_SQLITE) -DHAVE_LIBFOSSIL_CONFIG_H -w -I$(PIC_VENDOR) -c -o $@ $<
PIC_REL_V := build/pic/release/vendor/sqlite3.o build/pic/release/vendor/libfossil.o
PIC_DEV_V := build/pic/dev/vendor/sqlite3.o build/pic/dev/vendor/libfossil.o
build/pic/release/pic: $(PIC_SRC) $(PIC_HDR) $(PIC_REL_V)
@mkdir -p $(@D)
$(CC) $(PIC_WARN) -O2 $(PIC_INC) -o $@ $(PIC_SRC) $(PIC_REL_V) $(PIC_LIBS)
build/pic/dev/pic: $(PIC_SRC) $(PIC_HDR) $(PIC_DEV_V)
@mkdir -p $(@D)
$(CC) $(PIC_WARN) $(PIC_SAN) -DPIC_FAULTS $(PIC_INC) -o $@ $(PIC_SRC) $(PIC_DEV_V) $(PIC_LIBS)
pic: build/pic/release/pic
pic-dev: build/pic/dev/pic
test-pic: test-sse test-decode build/pic/dev/pic build/pic/release/pic
ASAN_OPTIONS=detect_leaks=0 PIC=$(CURDIR)/build/pic/dev/pic sh test/pic/crash.sh
PIC=$(CURDIR)/build/pic/release/pic sh test/pic/crash.sh --no-faults
build/pic/dev/test_sse: test/pic/test_sse.c src/sse.c src/sse.h
@mkdir -p $(@D)
$(CC) $(PIC_WARN) $(PIC_SAN) -Isrc -o $@ test/pic/test_sse.c src/sse.c
test-sse: build/pic/dev/test_sse
build/pic/dev/test_sse
build/pic/dev/decode_stream: test/pic/decode_stream.c src/anthropic.c src/anthropic.h src/sse.c src/sse.h $(PIC_DEV_V)
@mkdir -p $(@D)
$(CC) $(PIC_WARN) $(PIC_SAN) $(PIC_INC) -o $@ test/pic/decode_stream.c src/anthropic.c src/sse.c $(PIC_DEV_V) $(PIC_LIBS)
test-decode: build/pic/dev/decode_stream
sh test/pic/decode.sh build/pic/dev/decode_stream
# libFuzzer needs an LLVM clang (Apple's lacks it). SQLite is rebuilt with the
# same compiler so one sanitizer runtime is linked. FUZZ_SECONDS bounds a run;
# new findings land in build/pic/fuzz/ and become fixtures when fixed.
FUZZ_CC ?= $(firstword $(wildcard /opt/homebrew/opt/llvm/bin/clang /usr/local/opt/llvm/bin/clang) clang)
FUZZ_SECONDS ?= 60
FUZZ_FLAGS := -O1 -g -fsanitize=fuzzer,address,undefined -fno-sanitize-recover=all
build/pic/fuzz/sqlite3.o: $(PIC_VENDOR)/sqlite3.c
@mkdir -p $(@D)
$(FUZZ_CC) -O1 -g -fsanitize=fuzzer-no-link,address,undefined $(PIC_SQLITE) -w -c -o $@ $<
build/pic/fuzz/fuzz_decode: test/fuzz/fuzz_decode.c src/anthropic.c src/anthropic.h src/sse.c src/sse.h build/pic/fuzz/sqlite3.o
$(FUZZ_CC) $(PIC_WARN) $(FUZZ_FLAGS) -Isrc -isystem $(PIC_VENDOR) -o $@ test/fuzz/fuzz_decode.c src/anthropic.c src/sse.c build/pic/fuzz/sqlite3.o -lm -lpthread
fuzz-decode: build/pic/fuzz/fuzz_decode
@mkdir -p build/pic/fuzz/corpus build/pic/fuzz/findings
build/pic/fuzz/fuzz_decode -max_total_time=$(FUZZ_SECONDS) -max_len=8192 -timeout=10 -dict=test/fuzz/sse.dict \
-artifact_prefix=build/pic/fuzz/findings/ build/pic/fuzz/corpus test/fuzz/decode-seeds