Skip to content

Commit 23dd8b5

Browse files
committed
Refused host targets unless you shout the magic words
1 parent e4b1c06 commit 23dd8b5

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

ACTIVITY.log.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
{"who": "AGENT", "what": "Preparing commit for namespace rename to GITLEDGER", "where": [".clang-tidy", "include/libgitledger/version.h", "src/version.c"], "when": 1761212294, "why": "Need to record work before committing user-supplied METAGRAPH_ -> GITLEDGER_ changes", "how": "Reviewed diffs touching naming prefixes and version constants to ensure consistency", "protip": "Always log before you commit, especially when reconciling someone else's edits"}
88
{"who": "AGENT", "what": "Containerized default build/test workflow", "where": ["Makefile", "tools/container/", "tools/testing/prepare-fixtures.sh"], "when": 1761214089, "why": "Keep local builds isolated and mirror the CI matrix to avoid corrupting developer checkouts", "how": "Added Docker image + orchestration scripts, per-matrix sandbox copies, fixture repo preparation, and host override flag; validated with make cmake/test-cmake/tidy", "protip": "Always force CI parity locally\u2014if your make target doesn't match GitHub Actions, your bug reproductions will lie to you"}
99
{"who": "AGENT", "what": "Documented container-first workflow and host override", "where": ["README.md", "CONTRIBUTING.md"], "when": 1761214111, "why": "Need to warn contributors about destructive tests and explain the new Docker harness", "how": "Replaced direct build instructions with container commands, added guidance on I_KNOW_WHAT_I_AM_DOING and lint expectations", "protip": "Docs rot fast\u2014ship the how-to steps in the same change you land the tooling"}
10+
{"who": "AGENT", "what": "Added host safety guard for make targets", "where": ["Makefile", "README.md", "CONTRIBUTING.md"], "when": 1761216127, "why": "Ensure host builds/tests explode unless the acknowledgement flag is set when outside Docker", "how": "Added guard macro to host-* make targets and clarified docs about the requirement", "protip": "Belt-and-suspenders: gate the interface _and_ document the sharp edge you\u2019re hiding"}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Thanks for helping build `libgitledger`! This document complements the roadmap a
1616
These jobs copy the repo into isolated workspaces, prepare sandbox Git
1717
fixtures, and remove all remotes before mutating anything.
1818
- If you must run against the host checkout, export `I_KNOW_WHAT_I_AM_DOING=1`
19-
and call the desired target. The plain make targets will refuse to run on the
20-
host without that acknowledgement.
19+
and call the desired target. The makefile will otherwise abort host targets
20+
unless it detects the container guard.
2121
- Align tooling: warning flags, optional dependencies, and targets must stay consistent across CMake and Meson.
2222
- When adding dependencies, update both build descriptions and mention the change in the relevant issue.
2323
- Run `make lint` (containerised clang-format + clang-tidy) before submitting a

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ CLANG_FORMAT ?= clang-format
66
CLANG_TIDY ?= clang-tidy
77

88
DISPATCH := tools/container/dispatch.sh
9+
HOST_GUARD = @if [ "$${LIBGITLEDGER_IN_CONTAINER:-0}" != "1" ] && [ "$${I_KNOW_WHAT_I_AM_DOING:-0}" != "1" ]; then echo "Refusing to run host target outside Docker without I_KNOW_WHAT_I_AM_DOING=1" >&2; exit 1; fi
910

1011
cmake:
1112
@$(DISPATCH) cmake
1213

1314
host-cmake:
15+
$(HOST_GUARD)
1416
cmake -S . -B build-debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
1517
cmake --build build-debug
1618
cmake -S . -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release
@@ -20,6 +22,7 @@ meson:
2022
@$(DISPATCH) meson
2123

2224
host-meson:
25+
$(HOST_GUARD)
2326
@if [ -d meson-debug ]; then \
2427
meson setup meson-debug --buildtype debugoptimized --reconfigure; \
2528
else \
@@ -37,13 +40,15 @@ both:
3740
@$(DISPATCH) both
3841

3942
host-both:
43+
$(HOST_GUARD)
4044
$(MAKE) host-cmake
4145
$(MAKE) host-meson
4246

4347
test-cmake:
4448
@$(DISPATCH) test-cmake
4549

4650
host-test-cmake:
51+
$(HOST_GUARD)
4752
$(MAKE) host-cmake
4853
ctest --test-dir build-debug --output-on-failure
4954
ctest --test-dir build-release --output-on-failure
@@ -52,6 +57,7 @@ test-meson:
5257
@$(DISPATCH) test-meson
5358

5459
host-test-meson:
60+
$(HOST_GUARD)
5561
$(MAKE) host-meson
5662
meson test -C meson-debug --print-errorlogs
5763
meson test -C meson-release --print-errorlogs
@@ -60,6 +66,7 @@ test-both:
6066
@$(DISPATCH) test-both
6167

6268
host-test-both:
69+
$(HOST_GUARD)
6370
$(MAKE) host-test-cmake
6471
$(MAKE) host-test-meson
6572

@@ -73,19 +80,22 @@ format-check:
7380
@$(DISPATCH) format-check
7481

7582
host-format-check:
83+
$(HOST_GUARD)
7684
tools/lint/clang_format_check.sh $(CLANG_FORMAT)
7785

7886
lint:
7987
@$(DISPATCH) lint
8088

8189
host-lint:
90+
$(HOST_GUARD)
8291
$(MAKE) host-format-check
8392
$(MAKE) host-tidy
8493

8594
tidy:
8695
@$(DISPATCH) tidy
8796

8897
host-tidy:
98+
$(HOST_GUARD)
8999
@if [ "${RUN_TIDY:-1}" = "0" ]; then \
90100
echo "Skipping clang-tidy because RUN_TIDY=0"; \
91101
else \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ I_KNOW_WHAT_I_AM_DOING=1 make test-both
5353
```
5454

5555
You can still invoke the underlying host targets directly (`make host-cmake`,
56-
`make host-test-meson`, etc.), but doing so without the acknowledgement flag is
57-
strongly discouraged.
56+
`make host-test-meson`, etc.), but they now abort unless you exported the
57+
acknowledgement flag or are already inside the container environment.
5858

5959
### Clean / format helpers
6060

0 commit comments

Comments
 (0)