Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
781 lines (678 loc) · 53.6 KB
/
Copy pathMakefile
File metadata and controls
781 lines (678 loc) · 53.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
# SPDX-License-Identifier: AGPL-3.0-or-later
# ABOUTME: The project's one entry point. `make check` is the gate: the Stop hook runs it at the end of
# every agent turn that touched a file, and CI runs it; the pre-commit hook runs `make spot`. A change is
# not done until it passes. Standards: docs/contributors/standards/makefile.md.
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
# Under quiet_gate.py, which names the file in STEP_CLOCK, each recipe line runs through
# step_clock.sh, which records its target's time there: the gate says how long each step took
# (gate-throughput G0; the owner, 2026-11-13, make-check-time-2026-11-12.md option 6).
ifneq ($(STEP_CLOCK),)
ifneq ($(wildcard $(CURDIR)/scripts/step_clock.sh),)
SHELL := $(CURDIR)/scripts/step_clock.sh
.SHELLFLAGS = $@ -eu -o pipefail -c
endif
endif
.DEFAULT_GOAL := help
MAKEFLAGS += --no-print-directory
.DELETE_ON_ERROR:
# Tests run hermetically (D190): the same clock zone, locale and git configuration on every
# machine, so a test cannot pass on the developer's box and fail in CI for reasons of taste.
# Only test targets get it: git itself may need the machine's config (safe.directory).
HERMETIC := TZ=UTC LC_ALL=C.UTF-8 GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1
# The capabilities a job may run without (testing.md 3): set per CI step or lab job, never in a
# profile. Every Go test run prints it, so a test that skipped for want of one is never silent.
UNCONTROLLED := echo "ORPHEUM_TEST_UNCONTROLLED=$${ORPHEUM_TEST_UNCONTROLLED:-(none: a missing capability fails)}"
# Pinned tool versions. Changing one is an owner action (the pre-edit hook asks). golangci-lint's
# and sqlc's pins are in scripts/fetch_tools.py, which the development image is built from.
GO_MINOR := 1.26
NODE_MAJOR := 22
BASE ?=
PYTHON := python3
# The pinned golangci-lint and sqlc (scripts/fetch_tools.py links them into TOOLS_BIN) come first
# on every target's PATH, before any other copy the machine has. GOPATH/bin holds what `go install`
# put there (dlv); a fresh container's PATH often lacks it. Asked only where Go is: a machine that
# only deploys (`make deploy`) has git and Docker alone, and printed "go: command not found" at every
# make (nas.example, 2026-10-19).
TOOLS_BIN := $(or $(ORPHEUM_TOOLS_DIR),$(CURDIR)/.tools)/bin
GOPATH_BIN := $(shell command -v go >/dev/null 2>&1 && echo "$$(go env GOPATH)/bin:")
export PATH := $(TOOLS_BIN):$(GOPATH_BIN)$(PATH)
# Every Go build and test leaves its tree's path out of the build cache's keys (-trimpath), so the
# working tree, check-pr's tree and revert-red's probe trees reuse each other's compiled packages:
# check-pr's tree compiled the integration tier's tests in 69 s after the working tree had, and in
# 13 s with it (2026-10-20). A recorded path is then the import path, so no code finds a file from
# its own source's path (internal/testutil finds go.mod instead). dev-debug clears it for Delve.
export GOFLAGS := $(strip $(GOFLAGS) -trimpath)
# Node's compile cache and Playwright's transform cache, kept between runs beside the other caches:
# both default to the temporary directory, which is each gate run's own and deleted at its end
# (scripts/gate_lock.py); scripts/disk_guard.py caps the first.
export NODE_COMPILE_CACHE := $(or $(NODE_COMPILE_CACHE),$(HOME)/.cache/orpheum/node-compile-cache)
export PWTEST_CACHE_DIR := $(or $(PWTEST_CACHE_DIR),$(HOME)/.cache/orpheum/playwright-transform-cache)
# A Go suite's run keeps its timings, each test's and package's, always (scripts/go_test_timings.py,
# web/e2e/test-timings.ts; the owner, 2026-10-20): it reads `go test -json` and prints go test's own text.
GO_TIMINGS = $(PYTHON) scripts/go_test_timings.py
# One test run at a time on the repository, every worktree's included: a second waits; a run's own
# sub-runs pass through. `--as` names the holder, which the Stop hook reads (scripts/gate_lock.py;
# process review F17, 2026-10-27; make spot and every test run too, the owner, 2026-11-04).
GATE_LOCK = $(PYTHON) scripts/gate_lock.py
.PHONY: help
help: ## List the targets
@grep -hE '^[a-z][a-z-]*:.*## ' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*## "} {printf " %-22s %s\n", $$1, $$2}'
# ---------------------------------------------------------------------------------------------
# The gate
# ---------------------------------------------------------------------------------------------
# The gate's checks run in parallel after two that must come first: the tools are there, and the
# generated code is current (check-generated rewrites generated files the builds then read).
CHECK_JOBS ?= $(shell nproc 2>/dev/null || echo 4)
.PHONY: check
check: hooks ## The gate: everything that runs on every change, quietly (VERBOSE=1 prints all; the log is in .git/gate-logs)
@# Where the hooks run it: the gate's container when there is an engine (scripts/run_gate.py, F1).
@if $(PYTHON) scripts/run_gate.py --hops check; then exec $(PYTHON) scripts/in_dev_image.py check; \
else $(GATE_LOCK) --as check $(PYTHON) scripts/quiet_gate.py --fail-fast "make check" check-verbose; fi
# The spot check, while working: the tests of what changed (the web's: of what uses it too) and a
# type check of the Go packages importing it, about 30 s; not
# the gate, which make check is at the turn's end; the pre-commit hook runs it (D279, testing.md §10).
# It holds the test lock, so agents' commits wait for each other's tests (the owner, 2026-11-04).
# BASE=<rev> checks commits.
.PHONY: spot
spot: hooks ## Spot check while working: tests of what changed since BASE (default HEAD, so uncommitted), its Go importers type-checked, ~30 s
@# In the gate's container, as make check: one Go test cache for both (the caching audit's finding 4).
@if $(PYTHON) scripts/run_gate.py --hops spot; then exec $(PYTHON) scripts/in_dev_image.py spot $(if $(BASE),BASE='$(BASE)') $(if $(SPOT_JOBS),SPOT_JOBS=$(SPOT_JOBS)); \
else $(GATE_LOCK) --as spot $(PYTHON) scripts/spot_check.py $(if $(BASE),--base '$(BASE)') $(if $(SPOT_JOBS),--jobs $(SPOT_JOBS)); fi
# How long make check, check-pr and spot have taken, run by run, against their budgets, and the steps
# that took them over (scripts/gate_runs.py; the owner, 2026-11-21: they "keep dev loop velocity high").
.PHONY: gate-times
gate-times: ## How long make check, check-pr and spot took over the last DAYS (default 7), against their budgets
@$(PYTHON) scripts/gate_runs.py $(if $(DAYS),--days $(DAYS))
.PHONY: check-verbose
# web-deps runs before the parallel steps: check-generated and check-web both need it, and two
# installs at once raced each other (2026-10-01). It does nothing when the install is current.
check-verbose: check-tools web-deps go-warm ## The gate with every step's output
@# Room on the disk first, the caches trimmed to their caps (the disk-full review, 2026-10-28).
@$(PYTHON) scripts/disk_guard.py
@# A new worktree's type builds from the main checkout's, so its first type check is warm.
@$(PYTHON) scripts/seed_worktree.py
@# The tree as the gate starts: only that tree, unchanged at the end, is recorded as passed.
@$(PYTHON) scripts/check_stamp.py begin
@$(MAKE) --no-print-directory -j$(CHECK_JOBS) --output-sync=target check-parallel
@# The browser-mode tests after the rest, never beside it: beside a cold Go build their Firefox
@# failed to connect in vitest's 60 s twice, and they took 65 s for 10 s of tests (2026-10-20).
@$(MAKE) --no-print-directory web-test-browser
@# Then the end-to-end specs a change to the web client reaches, both passes, alone as well.
@$(MAKE) --no-print-directory test-e2e-reached
@$(PYTHON) scripts/check_stamp.py write
@# Named for itself: under make check the quiet gate says the pass, with its time (scripts/quiet_gate.py).
@echo "check-verbose: all gates passed"
.PHONY: check-parallel
# check-generated runs beside the rest: nothing reads what it generates, which goes to a temporary
# directory, and as a prerequisite it held every other step back by 7.6 s (2026-10-01).
check-parallel: check-generated check-docs check-scripts check-source check-deps check-claims check-media-names check-e2e-strings check-architecture check-go check-web-parallel
.PHONY: check-tools
check-tools: ## Fetch the pinned golangci-lint and sqlc if missing; fail if another pinned tool is missing or at the wrong version
@$(PYTHON) scripts/fetch_tools.py
@command -v go >/dev/null || { echo "go is not installed (need $(GO_MINOR).x)"; exit 1; }
@case "$$(go env GOVERSION)" in go$(GO_MINOR)|go$(GO_MINOR).*) ;; \
*) echo "go is $$(go env GOVERSION); this project pins $(GO_MINOR).x"; exit 1;; esac
@command -v node >/dev/null || { echo "node is not installed (need $(NODE_MAJOR).x)"; exit 1; }
@v="$$(node --version)"; case "$$v" in v$(NODE_MAJOR).*) ;; \
*) echo "node is $$v; this project pins $(NODE_MAJOR).x"; exit 1;; esac
@command -v $(PYTHON) >/dev/null || { echo "python3 is not installed"; exit 1; }
@command -v shellcheck >/dev/null || { echo "shellcheck is not installed"; exit 1; }
.PHONY: check-documentation
check-documentation: check-docs check-claims check-media-names check-architecture ## The gate for a change of documentation alone (scripts/documentation_only.py): what reads the docs, and no test of the code
@# The one Go test that reads a document, schema.md's owners table (the M4 closing audit).
@$(HERMETIC) go test -run '^TestArch_EachTableHasOneWritingPackage$$' ./internal/archtest/
# Within check-pr (a BASE given), whether the branch changed documentation alone: then the tiers
# that test the code have nothing to find (the owner, 2026-10-08).
DOCUMENTATION_ONLY = [ -n '$(BASE)' ] && $(PYTHON) scripts/documentation_only.py --base '$(BASE)'
.PHONY: check-docs
check-docs: ## Links, anchors, decision citations and the decision index
@$(PYTHON) scripts/check_docs.py
.PHONY: check-scripts
check-scripts: ## The gate scripts' own tests, and shellcheck on every shell script; not again while only Go, TypeScript or docs changed since they passed, and only the tests a Python change reaches
@$(PYTHON) scripts/area_stamp.py check-scripts $(SCRIPTS_READ) -- $(MAKE) --no-print-directory check-scripts-run
# What the gate scripts' tests read: all but the Go and TypeScript sources and the docs (scripts/
# area_stamp.py; the test audit, 2026-10-08).
SCRIPTS_READ = . ':(exclude,glob)**/*.go' ':(exclude,glob)**/*.ts' ':(exclude,glob)**/*.tsx' ':(exclude)docs'
.PHONY: check-scripts-run check-source freeze-compose check-deps check-vulns check-claims check-media-names check-architecture
check-scripts-run:
@$(HERMETIC) $(PYTHON) scripts/py_tests.py --reach
@files="$$(git ls-files --cached --others --exclude-standard | grep -E '(\.sh$$|^\.githooks/)' || true)"; \
if [ -n "$$files" ]; then shellcheck $$files; fi
check-source: ## SPDX headers match their directory; files stay under 800 lines; the published compose files are their version's frozen copy (D462 §6)
@$(PYTHON) scripts/check_source.py && $(PYTHON) scripts/check_released_compose.py
freeze-compose: ## Freeze the published compose files as cmd/orpheum/testdata/released/compose-v<n>, deployment.ComposeFileVersion's (D462 §6), and the discovery's as discovery-v<n>
@$(PYTHON) scripts/check_released_compose.py --freeze
check-deps: ## Every dependency is on the owner's allowlist with a reason
@$(PYTHON) scripts/check_deps.py
check-vulns: ## Known vulnerabilities in the pinned dependencies (govulncheck, npm audit): a prompt to upgrade, never a failure; first in check-pr and the nightly run
@$(PYTHON) scripts/check_vulns.py
check-claims: ## TestArch_ citations, decision IDs in code, and ORPHEUM_TEST_ variables resolve
@$(PYTHON) scripts/check_claims.py
check-media-names: ## No film, series or episode the registry (scripts/media_names.allow) does not list: the owner's library is never named (AGENTS.md rule 12)
@$(PYTHON) scripts/check_media_names.py
.PHONY: check-e2e-strings
check-e2e-strings: ## Every name, text or label an e2e spec's locator waits for is in the web client's words, not found first by check-pr's browser tier
@$(PYTHON) scripts/check_e2e_strings.py
check-architecture: ## Every package has a row in the architecture map; schema.md's owners table lists every table
@$(PYTHON) scripts/check_architecture_map.py
.PHONY: check-go
check-go: go-fmt go-lint go-vet go-test go-tidy go-speculative ## All Go checks
# go-warm compiles every package, test variants included, once, before lint, vet and the tests
# start beside each other: on a cold cache each of them compiled the same dependencies at once.
# On 4 CPUs with a cold cache, compiling first took the three from 232 s to 197 s; on a warm
# cache it costs under a second, since export data is cached and nothing is linked (2026-10-01).
.PHONY: go-warm
go-warm:
@go list -export -deps -test ./... >/dev/null
.PHONY: go-fmt
go-fmt: ## Fail if gofumpt or gci would change a file (fix with: make fmt)
@golangci-lint fmt --diff ./...
# golangci-lint holds one lock for every run on the machine, and refuses to start beside another
# run (make check's go-speculative, another worktree's gate, the Stop hook beside a commit's):
# --allow-serial-runners waits for the lock instead.
.PHONY: go-lint
go-lint: ## golangci-lint with the project's configuration, for release and dev builds and the integration tier
@golangci-lint run --allow-serial-runners --build-tags integration ./...
@golangci-lint run --allow-serial-runners --build-tags dev ./cmd/...
.PHONY: go-vet
go-vet: ## go vet for the shipped platform, for arm64 and riscv64 Linux, for macOS, for the dev build and for the integration tier
@go vet ./...
@GOOS=linux GOARCH=arm64 go vet ./... # D205: arm64 stays open
@GOOS=linux GOARCH=riscv64 go vet ./... # D205: riscv64 watched; compiles the linux files that leave amd64 and arm64 out
@GOOS=darwin GOARCH=arm64 go vet ./...
@go vet -tags dev ./...
@go vet -tags integration ./...
# The dev build's own tests are those in test files only it builds (`//go:build dev`): the rest of
# ./cmd ran in the release build just before, and running all of them again took 17 s of every
# make check (2026-10-06).
DEV_ONLY_TESTS = $(shell grep -l '^//go:build dev$$' cmd/*/*_test.go 2>/dev/null | xargs -r grep -ho '^func Test[A-Za-z0-9_]*' | sed 's/^func //' | paste -sd'|' -)
.PHONY: go-test
go-test: ## Unit and architecture tests, for the release build and the dev build's own
@$(UNCONTROLLED)
@$(HERMETIC) go test -json ./... | $(GO_TIMINGS) go
@test -n '$(DEV_ONLY_TESTS)' || { echo "go-test: no test file builds only with -tags dev; the dev pass would test nothing"; exit 1; }
@$(HERMETIC) go test -json -tags dev -run '^($(DEV_ONLY_TESTS))$$' ./cmd/... | $(GO_TIMINGS) go-dev
.PHONY: go-tidy
go-tidy: ## Fail if go.mod or go.sum is not tidy
@go mod tidy -diff
.PHONY: go-speculative
go-speculative: ## Fail on declarations whose only callers are tests
@$(PYTHON) scripts/lint_speculative_api.py
.PHONY: check-generated check-generated-sql check-generated-api
check-generated: check-generated-sql check-generated-api ## Fail if committed generated code differs from what its source generates; each generator not again while nothing it reads changed since it passed
# Each generator on what it reads alone: as one, sqlc ran on every Go or SDK change, 77 s of a make
# check under the load beside it for queries nothing had touched (the owner's go, 2026-11-21).
check-generated-sql:
@$(PYTHON) scripts/area_stamp.py check-generated-sql $(GENERATED_SQL_READ) -- $(PYTHON) scripts/check_generated.py generate-sql
# After sqlc, when both run: the Go it builds compiles what sqlc writes.
check-generated-api: check-generated-sql
@$(PYTHON) scripts/area_stamp.py check-generated-api $(GENERATED_API_READ) -- $(PYTHON) scripts/check_generated.py generate-api
# What each generator reads, and the files it writes (a hand edit fails), and how it runs (the
# Makefile, check_generated.py); no test file is built. sqlc: the migrations and queries, its config
# and its pin (make-check-time-2026-11-12.md option 2 made it one list, the owner's go, 2026-11-13).
GENERATED_UNREAD := ':(exclude,glob)**/*_test.go' ':(exclude,glob)**/testdata/**' ':(exclude,glob)**/*.md'
GENERATED_SQL_READ := internal/store/migrations internal/store/queries internal/store/cache/schema.sql \
internal/store/cache/queries internal/store/sqlcgen internal/store/cachegen sqlc.yaml scripts/fetch_tools.py \
Makefile scripts/check_generated.py $(GENERATED_UNREAD)
# The OpenAPI document and the compose files: the Go that `go run ./cmd/orpheum` builds, with what it
# embeds; the SDK's types: that document, the generator's pin in the lockfile, and the types it wrote.
GENERATED_API_READ := cmd internal pkg api deploy go.mod go.sum Makefile scripts/check_generated.py \
web/package.json web/package-lock.json web/packages/sdk/package.json web/packages/sdk/src/gen $(GENERATED_UNREAD)
.PHONY: check-web check-web-parallel
check-web: check-web-parallel ## Typecheck, lint, format, dependency rules and tests for web/, the browser-mode tests last
@$(MAKE) --no-print-directory web-test-browser
check-web-parallel: web-deps ## check-web but its browser-mode tests, at once: make check runs those after the rest
@$(MAKE) --no-print-directory -j6 --output-sync=target web-typecheck web-lint web-format-check web-deps-check web-test
# The web checks, each one of web/package.json's scripts. check-web runs them at once: one after
# another they took 16 s, the longest step of make check (2026-10-01).
.PHONY: web-typecheck web-lint web-format-check web-deps-check web-test web-test-browser web-test-browser-run
# These four not again while nothing they read changed since they passed (scripts/area_stamp.py):
# web/ alone, and for prettier the root .editorconfig too; on a Go-only turn they cost 23 s of CPU
# (make-check-time-2026-11-12.md option 5, the owner's go, 2026-11-13).
web-typecheck:
@$(PYTHON) scripts/area_stamp.py web-typecheck web -- npm --prefix web run --silent typecheck
web-lint:
@$(PYTHON) scripts/area_stamp.py web-lint web -- npm --prefix web run --silent lint
web-format-check:
@$(PYTHON) scripts/area_stamp.py web-format-check web .editorconfig -- npm --prefix web run --silent format:check
web-deps-check:
@$(PYTHON) scripts/area_stamp.py web-deps-check web -- npm --prefix web run --silent deps:check
web-test:
@# Only the tests the changes since the last pass reach, by vitest's import graph (scripts/web_tests.py).
@$(PYTHON) scripts/web_tests.py
# The browser-mode tests (web/vitest.browser.config.ts), beside the rest so none waits on them: each
# run starts Chromium and Firefox, about 9 s, so only those the changes since they passed reach, as
# web-test's (scripts/web_tests.py --browser; the owner, 2026-10-18: no light test waits on a heavy one;
# the caching audit's finding 8, 2026-10-28).
web-test-browser:
@if $(PYTHON) scripts/web_tests.py --browser --due; then $(MAKE) --no-print-directory web-test-browser-run; fi
# One browser-mode run at a time on the machine: two gates' runs at once (check-pr's tree, revert-red's
# worktrees, a sandbox's agents) pushed a walk's 72 round trips to the browser past its timeout
# (test-weight.md §26). The wait shows as this step's own time (§7). The hold has a lease: past it, a
# waiting run says the browser tests did not run and fails, where it hung (scripts/web_tests.py).
# In the repository's git directory, not /tmp, so it holds across the host and the development
# container, which do not share /tmp (gate-throughput audit, 2026-10-26).
BROWSER_MODE_LOCK ?= $(shell git rev-parse --path-format=absolute --git-common-dir)/browser-mode.lock
web-test-browser-run: browsers
@$(PYTHON) scripts/web_tests.py --browser --lock $(BROWSER_MODE_LOCK)
.PHONY: web-deps
web-deps: ## Install web dependencies from the lockfile when they are missing or stale
@# npm ci empties node_modules first, through a symlink too: a scratch worktree whose
@# node_modules pointed at the main tree's emptied it twice (2026-09-30, 2026-10-01).
@if [ -L web/node_modules ]; then echo "web-deps: web/node_modules is a symlink; npm ci would empty what it points at. Remove it and run make web-deps here."; exit 1; fi
@if [ ! -f web/node_modules/.package-lock.json ] || [ web/package-lock.json -nt web/node_modules/.package-lock.json ]; then \
npm --prefix web ci --no-audit --no-fund; fi
# ---------------------------------------------------------------------------------------------
# Branch gates: they compare a branch against its base, so they run in CI on a pull request and
# locally with `make check-pr` before pushing. BASE names the base; without it the gates use the
# commit the owner last took (`make mark-applied`), then origin/main, and refuse one too far back
# to mean anything (scripts/branch_base.py).
# ---------------------------------------------------------------------------------------------
RESOLVE_BASE = $(PYTHON) scripts/branch_base.py $(if $(BASE),--base '$(BASE)')
# check-pr's steps, in tiers by how long they take, the quickest first, and the slow tiers never
# beside the rest (the owner, 2026-10-15: "fast ones first, then medium ones with enough
# parallelization"). The integration tier stays beside the full web lint, which takes longer than
# it: beside the browser tier it saved nothing and slowed that tier (D607 §1, tried 2026-12-01). check-pr is the last run of a block of work, which is expected to pass, its
# pieces' tests having run already: every tier runs to its end, a failed one too, so one run shows
# every failure (the owner, 2026-10-17: "fail fast on piecework… run to completion on the final
# test run"), except that a failed fast or medium tier stops it before the slow tiers, minutes spent
# behind a lint error found in one (D424, 2026-11-05), and revert-red runs only once every other tier
# has passed: it took an hour, and a red browser test waited the hour behind it (the owner,
# 2026-11-24: "a lint issue shouldn't cause check-pr to fail after an hour of runtime"; the test-time
# stock-take's item 6). The piecework re-run,
# check-pr-failed, still stops at a failed tier. Each
# step runs through pr-step-<step>, which records whether it passed and on what commit
# (scripts/check_pr_steps.py), so `make check-pr-failed` can re-run only what failed.
PR_FAST_STEPS := check-test-weakening check-decision-status lint-commits check-source
PR_MEDIUM_STEPS := test-integration web-lint-full
PR_SLOW_STEPS := test-browser
PR_STEPS := $(PR_FAST_STEPS) $(PR_MEDIUM_STEPS) $(PR_SLOW_STEPS)
# A branch of documentation alone (scripts/documentation_only.py) cannot change what the code does,
# so its branch gate is these alone: what reads the documents, and the second's checks of its
# commits. check-pr and check-pr-failed run check-pr-documentation for it instead of their tiers
# (the owner, 2026-10-17: "It's impossible for documentation changes to affect code").
PR_DOCUMENTATION_STEPS := check-documentation $(PR_FAST_STEPS)
# Revert-red runs alone, never beside another tier: a timing test failing under the load of a probe
# would be counted as the probe's red, a "covered" nothing proved (audit-2026-09-29 §6). It runs in
# two parts (the owner, 2026-10-15): the code's probes, a package's tests each, and then every
# probe's browser run, the stylesheets' and the code's the cheap runs left green, reading the map the
# browser tier just recorded (the owner, 2026-10-17: no expensive test blocks a cheap one). Both come
# after every other tier: the code part ran right after the medium tier, so that a change no test
# notices was found in minutes, until it took an hour (2026-11-24).
PR_CODE_RED_STEP := check-revert-red-code
PR_LAST_STEP := check-revert-red-browser
# M4's acceptance under home, a few minutes (D252 §2, D261 §2): after the tiers and before
# revert-red, alone, as it shapes the container's loopback, which every tier's tests cross.
# check-pr-failed does not re-run it: `make test-acceptance-home BASE=...` does.
PR_SERIAL_STEP := test-acceptance-home
# How long check-pr may take, in seconds: the owner's seven minutes (D607), five until a day's batch
# no longer fitted them (agent-failures A24). A pass over it says so in its one line.
CHECK_PR_BUDGET_S := 420
.PHONY: check-pr
check-pr: hooks ## Branch gates against BASE, quietly (VERBOSE=1 prints all; the log is in .git/gate-logs)
@if ! $(PYTHON) scripts/run_gate.py --hops check-pr; then $(GATE_LOCK) --as check-pr $(MAKE) --no-print-directory check-pr-locked $(if $(BASE),BASE=$(BASE)); else exec $(PYTHON) scripts/in_dev_image.py check-pr $(if $(BASE),BASE=$(BASE)); fi
# check-pr once it holds the gate lock: the browsers, and with them web-deps' npm ci, install under it,
# so a make check the Stop hook started cannot run its own npm ci beside them (the 11-01 batch: they
# raced; the owner, 2026-11-01). Its tree's lock passes through (GATE_LOCK_HELD, scripts/gate_lock.py).
.PHONY: check-pr-locked
check-pr-locked: browsers
@$(PYTHON) scripts/quiet_gate.py "make check-pr" check-pr-verbose $(if $(BASE),BASE=$(BASE))
# check-pr runs on HEAD in its own worktree, holding a lock the hooks read, so the working tree stays
# free to edit and nothing tests beside it (scripts/check_pr_snapshot.py; the owner, 2026-10-20).
# Followed by the target and its variables, then `; fi`: outside that tree, it hands the target over,
# with the base resolved here, in the working tree.
CHECK_PR_IN_ITS_TREE = if [ -z "$${ORPHEUM_CHECK_PR_TREE:-}" ]; then exec $(PYTHON) scripts/check_pr_snapshot.py
.PHONY: check-pr-verbose
check-pr-verbose: ## Branch gates against BASE (default: where the last pass ended, or the owner's mark), its tiers from the quickest, every one run to its end once the quick ones pass (D424), revert-red last, once every other tier has passed, in check-pr's own tree; a pass marks HEAD as checked
@base="$$($(RESOLVE_BASE))"; $(CHECK_PR_IN_ITS_TREE) check-pr-verbose BASE="$$base"; fi; \
started="$$(date +%s)"; head="$$(git rev-parse HEAD)"; \
if $(PYTHON) scripts/documentation_only.py --base "$$base"; then \
exec $(MAKE) --no-print-directory check-pr-documentation BASE="$$base"; fi; \
$(PYTHON) scripts/disk_guard.py; \
$(PYTHON) scripts/check_vulns.py; \
state="$$(git rev-parse --git-common-dir)/check-pr/tree-state"; mkdir -p "$$(dirname "$$state")"; \
$(PYTHON) scripts/tree_state.py --save "$$state"; \
$(PYTHON) scripts/check_pr_steps.py start --base "$$base"; \
{ failed=0; \
$(MAKE) --no-print-directory -j$(CHECK_JOBS) -k --output-sync=target BASE="$$base" \
$(PR_FAST_STEPS:%=pr-step-%) || failed=1; \
$(MAKE) --no-print-directory -j$(CHECK_JOBS) -k --output-sync=target BASE="$$base" \
$(PR_MEDIUM_STEPS:%=pr-step-%) || failed=1; \
if [ "$$failed" -eq 0 ]; then \
$(MAKE) --no-print-directory BASE="$$base" $(PR_SERIAL_STEP:%=pr-step-%) || failed=1; \
$(MAKE) --no-print-directory BASE="$$base" $(PR_SLOW_STEPS:%=pr-step-%) || failed=1; \
else quick_failed=1; fi; \
if [ "$$failed" -eq 0 ]; then \
$(MAKE) --no-print-directory BASE="$$base" $(PR_CODE_RED_STEP:%=pr-step-%) || failed=1; \
$(MAKE) --no-print-directory BASE="$$base" $(PR_LAST_STEP:%=pr-step-%) || failed=1; \
elif [ -z "$${quick_failed:-}" ]; then tests_failed=1; fi; \
[ "$$failed" -eq 0 ]; } || { \
$(PYTHON) scripts/check_pr_steps.py durations $(PR_STEPS) $(PR_CODE_RED_STEP) $(PR_SERIAL_STEP) $(PR_LAST_STEP); \
if [ -n "$${quick_failed:-}" ]; then \
echo "make check-pr: a quick tier failed, so the acceptance and browser tiers and revert-red did not run (D424): fix it, then run the whole check-pr"; \
elif [ -n "$${tests_failed:-}" ]; then \
echo "make check-pr: the acceptance or browser tier failed, so revert-red did not run: fix it, then run the whole check-pr"; \
else echo "make check-pr: a tier failed, revert-red, every other tier having passed before it"; fi; exit 1; }; \
$(PYTHON) scripts/check_pr_steps.py durations $(PR_STEPS) $(PR_CODE_RED_STEP) $(PR_SERIAL_STEP) $(PR_LAST_STEP); \
$(PYTHON) scripts/tree_state.py --check "$$state"; \
$(PYTHON) scripts/branch_base.py --checked "$$head" --base "$$base" && $(PYTHON) scripts/check_pr_debt.py paid && { \
rm -f "$$(git rev-parse --path-format=absolute --git-common-dir)/revert-red/sweep-off"; \
took=$$(( $$(date +%s) - started )); \
if [ "$$took" -gt $(CHECK_PR_BUDGET_S) ]; then \
echo "make check-pr: passed in $${took} s, over its $(CHECK_PR_BUDGET_S) s budget: find the step that grew (standards/makefile.md)"; \
else echo "make check-pr: passed in $${took} s"; fi; }
# The loop's re-run: never a pass of check-pr, which is still required before a branch is done.
.PHONY: check-pr-failed
check-pr-failed: ## Re-run only the check-pr steps that failed last time (revert-red: only its failed files), in check-pr's own tree; then run the full check-pr
@base="$$($(RESOLVE_BASE))"; $(CHECK_PR_IN_ITS_TREE) check-pr-failed BASE="$$base"; fi; \
if $(PYTHON) scripts/documentation_only.py --base "$$base"; then \
exec $(MAKE) --no-print-directory check-pr-documentation BASE="$$base"; fi; \
$(PYTHON) scripts/check_pr_steps.py rerun --base "$$base" --jobs $(CHECK_JOBS) \
$(PR_FAST_STEPS:%=--always %) $(PR_MEDIUM_STEPS:%=--always %) \
--last $(PR_CODE_RED_STEP) --last $(PR_LAST_STEP) $(PR_STEPS) && \
$(PYTHON) scripts/check_pr_debt.py owe "$$base"
.PHONY: check-pr-documentation
check-pr-documentation: ## The branch gate for documentation alone, which check-pr runs instead for one: what reads the documents and the commits' quick checks, seconds; a pass marks HEAD as checked
@started="$$(date +%s)"; base="$$($(RESOLVE_BASE))"; head="$$(git rev-parse HEAD)"; \
if ! $(PYTHON) scripts/documentation_only.py --base "$$base"; then \
echo "make check-pr-documentation: more than documentation changed since $$(git rev-parse --short "$$base"); that branch's gate is make check-pr"; exit 1; fi; \
echo "make check-pr: documentation alone changed since $$(git rev-parse --short "$$base"), so its gate is the documents' and the commits' (check-pr-documentation)"; \
$(PYTHON) scripts/check_pr_steps.py start --base "$$base"; \
$(MAKE) --no-print-directory -j$(CHECK_JOBS) -k --output-sync=target BASE="$$base" \
$(PR_DOCUMENTATION_STEPS:%=pr-step-%) || { \
$(PYTHON) scripts/check_pr_steps.py durations $(PR_DOCUMENTATION_STEPS); \
echo "make check-pr-documentation: a check failed; each failure is above"; exit 1; }; \
$(PYTHON) scripts/check_pr_steps.py durations $(PR_DOCUMENTATION_STEPS); \
$(PYTHON) scripts/branch_base.py --checked "$$head" --base "$$base" && \
echo "make check-pr: passed in $$(( $$(date +%s) - started )) s, documentation alone"
pr-step-%:
@$(PYTHON) scripts/check_pr_steps.py record $* -- $(MAKE) --no-print-directory BASE='$(BASE)' $*
.PHONY: mark-applied
.PHONY: handoff
handoff: ## The state a next session needs, quoted from the records (decisions, VQ, debts, git), not from memory
@$(PYTHON) scripts/handoff.py
mark-applied: ## After `yoloai apply`: mark REV (default HEAD) as what the owner took, the branch gates' base
@$(PYTHON) scripts/branch_base.py --mark '$(or $(REV),HEAD)'
.PHONY: web-lint-full
web-lint-full: web-deps ## eslint without its cache: make check's cached lint cannot see a type another file changed; given BASE, only the changed web files and what uses an export whose type changed (scripts/impact.py)
@if $(DOCUMENTATION_ONLY); then echo "web-lint-full: skipped; documentation alone changed since $(BASE)"; \
elif [ -z '$(BASE)' ]; then npm --prefix web run --silent lint:full; \
else files="$$($(PYTHON) scripts/impact.py web-lint --base '$(BASE)')" || files=.; case "$$files" in \
"") echo "web-lint-full: skipped; nothing eslint reads changed since $(BASE)";; \
.) npm --prefix web run --silent lint:full;; \
*) cd web && npx --no-install eslint --max-warnings 0 --no-warn-ignored $$files;; esac; fi
.PHONY: check-revert-red
check-revert-red: ## Every behaviour change can turn a test red when reverted (D190); ONLY="a b" probes only those paths
@base="$$($(RESOLVE_BASE))"; $(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base "$$base" $(if $(ONLY),--only $(ONLY))
.PHONY: check-revert-red-failed
check-revert-red-failed: ## Revert-red on only the files its last run against BASE failed on; then run the full check
@base="$$($(RESOLVE_BASE))"; $(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base "$$base" --rerun-failed
.PHONY: check-revert-red-code check-revert-red-browser check-revert-red-code-failed check-revert-red-browser-failed
check-revert-red-code: ## Revert-red on the code (Go, TypeScript, Python) with its cheap runs alone: check-pr's tier after the medium one
@base="$$($(RESOLVE_BASE))"; $(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base "$$base" --part code
check-revert-red-browser: ## Revert-red's browser runs: the stylesheets, and the code check-revert-red-code left owing them; check-pr's last step
@base="$$($(RESOLVE_BASE))"; $(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base "$$base" --part browser
check-revert-red-code-failed: ## Revert-red on only the code files its last run against BASE failed on
@base="$$($(RESOLVE_BASE))"; $(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base "$$base" --rerun-failed --part code
check-revert-red-browser-failed: ## Revert-red's browser runs on only the files its last run against BASE failed on
@base="$$($(RESOLVE_BASE))"; $(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base "$$base" --rerun-failed --part browser
.PHONY: check-commit-red
check-commit-red: ## Revert-red on the last commit's code alone, against its parent: a minute's check after each commit, so a change no test notices is found while it is fresh (the owner, 2026-10-15)
@$(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base HEAD~1 --part code --unrecorded
.PHONY: check-test-weakening
check-test-weakening: ## No test got weaker, and no gate changed, without a trailer on a commit that touched it
@base="$$($(RESOLVE_BASE))"; $(PYTHON) scripts/check_test_weakening.py --base "$$base"
.PHONY: check-decision-status
check-decision-status: ## No commit records a decision whose Status already says it is built
@base="$$($(RESOLVE_BASE))"; $(PYTHON) scripts/check_docs.py --base "$$base"
.PHONY: lint-commits
lint-commits: ## Commit subjects, bodies and attribution trailers
@base="$$($(RESOLVE_BASE))"; $(PYTHON) scripts/lint_commits.py --base "$$base"
# ---------------------------------------------------------------------------------------------
# Longer runs
# ---------------------------------------------------------------------------------------------
# The nightly backstop to every narrowing above (the owner, 2026-10-17): check-pr checks only what a
# change can break, by stamps, maps and dependency graphs, and a skip whose key misses an input passes
# what should fail (test-weight.md, "Caches bring their own risk"). This trusts none of them: the
# stamps are cleared, every tier runs whole, uncached, and revert-red probes the last SINCE's commits
# with every browser run in turn. Every step runs to its end, a failed one too. CI runs it nightly
# (.github/workflows/ci.yml); the 2.5-hour M4 acceptance stays a milestone's.
#
# check-verbose's own web-test step runs vitest.config.ts's "fast" project (plain, DOM-free
# .test.ts files) with isolation off, for speed (test-architecture-2026-10-26.md, finding 4); the
# `test:isolated` run below is the backstop that guarantee asks for: the same suite, every file
# isolated, trusting nothing the "fast" project's own empirical check (vitest.config.ts's comment)
# found, so a module-state leak between two such files that check missed is still caught nightly.
SINCE ?= 24 hours ago
.PHONY: check-everything
check-everything: browsers ## Everything, trusting no stamp, cache or map: CI's nightly run; SINCE (default "24 hours ago") bounds revert-red's commits
@rm -rf "$$(git rev-parse --path-format=absolute --git-common-dir)/orpheum-area-stamps" "$$(git rev-parse --git-path orpheum-check-passed)"; \
failed=0; \
$(PYTHON) scripts/check_vulns.py; \
$(MAKE) --no-print-directory check-verbose || failed=1; \
npm --prefix web run --silent test:isolated || failed=1; \
$(UNCONTROLLED); $(HERMETIC) go test -race -count=1 -p "$$(( ($$(nproc) + 1) / 2 ))" -timeout 30m ./... || failed=1; \
$(MAKE) --no-print-directory test-integration-run || failed=1; \
npm --prefix web run --silent lint:full || failed=1; \
ORPHEUM_E2E_NIGHTLY=1 $(MAKE) --no-print-directory test-browser BASE= || failed=1; \
$(MAKE) --no-print-directory test-acceptance-home BASE= || failed=1; \
base="$$(git rev-list -1 --before='$(SINCE)' HEAD)"; \
if [ -z "$$base" ] || [ "$$base" = "$$(git rev-parse HEAD)" ]; then \
echo "check-everything: no commit since $(SINCE), so revert-red has nothing to probe"; \
else $(GATE_LOCK) --as revert-red $(PYTHON) scripts/check_revert_red.py --base "$$base" --part all --unrecorded --trust-no-record || failed=1; fi; \
if [ "$$failed" -ne 0 ]; then echo "make check-everything: FAILED; every step ran, so each failure is above"; exit 1; fi; \
echo "make check-everything: everything passed"
# The inventory at a design cycle's end: every tier to its end, no revert-red, and one list of what
# failed, each with its file and first failing line, in .dev/inventory/failures.md; a failure turns
# the background probe off for the sweep, until check-pr passes (scripts/inventory.py; the owner,
# 2026-11-24).
.PHONY: inventory
inventory: check-tools web-deps go-warm browsers ## Every test of every tier to its end, no revert-red, then one list of failures by file and line; at a design cycle's end
@$(PYTHON) scripts/disk_guard.py
@base="$$($(RESOLVE_BASE))"; $(GATE_LOCK) --as check-pr $(PYTHON) scripts/inventory.py --base "$$base" \
--jobs $(CHECK_JOBS) --quick $(filter-out check-source,$(PR_FAST_STEPS))
.PHONY: test-all
test-all: check ## The gate, then the race detector and uncached tests
@$(UNCONTROLLED)
@$(HERMETIC) go test -race -count=1 ./...
# The integration tier's tests are those in test files only it builds (`//go:build integration`):
# the rest are the unit tier's, which make check passed on the same code, and running all of them
# again, uncached, took 38 s of check-pr against 20 s for these alone (the test audit, 2026-10-08).
INTEGRATION_TEST_FILES = $(shell grep -rl --include='*_test.go' '^//go:build integration$$' cmd internal 2>/dev/null)
INTEGRATION_ONLY_TESTS = $(shell echo '$(INTEGRATION_TEST_FILES)' | xargs -r grep -ho '^func Test[A-Za-z0-9_]*' | sed 's/^func //' | paste -sd'|' -)
INTEGRATION_PACKAGES = $(sort $(patsubst %/,./%,$(dir $(INTEGRATION_TEST_FILES))))
.PHONY: test-integration
test-integration: ## The integration tier: tests that run the pinned FFmpeg and MKVToolNix (fetched as make ffmpeg and make mkvtoolnix do); given BASE, only the packages a change reaches (scripts/impact.py)
@if $(DOCUMENTATION_ONLY); then echo "test-integration: skipped; documentation alone changed since $(BASE)"; \
elif [ -z '$(BASE)' ]; then $(MAKE) --no-print-directory test-integration-run; \
else packages="$$($(PYTHON) scripts/impact.py integration --base '$(BASE)' $(INTEGRATION_PACKAGES))" || \
packages='$(INTEGRATION_PACKAGES)'; \
if [ -z "$$packages" ]; then echo "test-integration: skipped; no change since $(BASE) reaches its packages"; \
else $(MAKE) --no-print-directory test-integration-run INTEGRATION_PACKAGES="$$packages"; fi; fi
.PHONY: test-integration-run
test-integration-run:
@$(UNCONTROLLED)
@test -n '$(INTEGRATION_ONLY_TESTS)' || { echo "test-integration: no test file builds only with -tags integration; the tier would test nothing"; exit 1; }
@$(HERMETIC) ORPHEUM_TEST_FFMPEG_DIR="$(FFMPEG_DIR)" ORPHEUM_TEST_MKVTOOLNIX_DIR="$(MKVTOOLNIX_DIR)" \
go test -json -tags integration -count=1 -run '^($(INTEGRATION_ONLY_TESTS))$$' $(INTEGRATION_PACKAGES) | \
$(GO_TIMINGS) go-integration
# make check's end-to-end step: the specs a change under web/ reaches since the step last passed, by
# check-pr's reach (scripts/impact.py browser_scope), both passes: ten specs a design cycle left stale
# were first seen in check-pr's browser tier (the owner, 2026-11-24). Nothing runs when nothing the
# tier builds or runs changed; what the browser map cannot place runs the whole tier.
.PHONY: test-e2e-reached
test-e2e-reached: ## The end-to-end specs a change to the web client reaches since they last passed, both passes; in make check
@$(PYTHON) scripts/e2e_reached.py
.PHONY: test-browser
# Within check-pr (a BASE given), the tier is skipped when nothing it builds or runs changed: docs,
# the gates' scripts, tests alone (scripts/browser_tier_needed.py; the owner, 2026-10-06).
#
# The run records the browser map (web/e2e/browser-map.ts): what every test's pages held, which
# revert-red reads to run a stylesheet's revert in only the tests it can reach (scripts/browser_map.py).
# The map is stamped with the commit only when every test ran and passed on a clean tree, so a map
# that is partial, failed or of other code is never read. A new map empties the folder and keeps it:
# in check-pr's own tree it is a link to the working tree's (scripts/check_pr_snapshot.py), and
# removed, the link went with it, the map was made in check-pr's tree alone, and every make check
# after a change to the client ran the whole tier, 155 s, for want of a map (2026-11-28).
#
# Within check-pr, a change of the client's sources alone since the map's commit runs only the tests
# that loaded a chunk holding one (scripts/impact.py; the owner, 2026-10-17: "check-pr only checks
# what is actually possible to break"), and records no map, so the last complete one stays. The
# integration tier and the full lint narrow the same way; check-everything runs each whole nightly.
test-browser: browsers ## The browser tier: Chrome and Firefox against a server of its own, with the built client (D217 §4); given BASE, only when what it builds changed, and only the tests that loaded a changed client source (scripts/impact.py)
@if [ -z '$(BASE)' ] || $(PYTHON) scripts/browser_tier_needed.py --base '$(BASE)'; then \
only=all; if [ -n '$(BASE)' ] && [ -z '$(E2E_ARGS)$(ORPHEUM_E2E_ONLY)' ] && \
[ '$(E2E_CONFIG)' = web/e2e/playwright.config.ts ]; then only="$$($(PYTHON) scripts/impact.py browser)" || only=all; fi; \
case "$$only" in \
none) echo "test-browser: skipped; no browser test loaded what changed since the browser map's commit";; \
all) mkdir -p $(BROWSER_MAP_DIR) && find $(BROWSER_MAP_DIR)/ -mindepth 1 -delete && \
ORPHEUM_BROWSER_MAP_DIR="$(CURDIR)/$(BROWSER_MAP_DIR)" $(MAKE) --no-print-directory browser-tier && \
if [ -z '$(E2E_ARGS)$(ORPHEUM_E2E_ONLY)' ] && [ '$(E2E_CONFIG)' = web/e2e/playwright.config.ts ] && \
[ -z "$$(git status --porcelain)" ]; then git rev-parse HEAD > $(BROWSER_MAP_DIR)/complete; fi;; \
*) ORPHEUM_E2E_ONLY="$$only" $(MAKE) --no-print-directory browser-tier;; esac; fi
# The browsers Playwright drives are fetched by Playwright itself, for its own version: the one
# web/package-lock.json pins, which PLAYWRIGHT_VERSION repeats so a lockfile bump is seen here
# (check-deps compares the two). Nothing else installed them, so a fresh machine or CI failed at
# the browser tier (audit-2026-09-29 §6). Then each is started once, and on Linux one that cannot
# start is given the system libraries Playwright names for it (scripts/ensure_browsers.py): a
# rebuilt sandbox had none, and every browser test failed until they were found by hand (the owner,
# 2026-10-23: prerequisites install themselves). The development image holds them already, so CI's
# start passes at once. With the browsers there, the install checks and does nothing; the start
# takes about 1.5 s, so check-pr and the browser tests run it, never make check's every turn.
PLAYWRIGHT_VERSION := 1.63.0
PLAYWRIGHT_INSTALL_FLAGS ?=
.PHONY: browsers
browsers: web-deps ## Install the pinned Playwright's Chromium and Firefox, and on Linux the system libraries they need to start
@v="$$(npm --prefix web exec -- playwright --version)"; [ "$$v" = "Version $(PLAYWRIGHT_VERSION)" ] || \
{ echo "playwright is $$v; this project pins $(PLAYWRIGHT_VERSION)"; exit 1; }
@npm --prefix web exec -- playwright install $(PLAYWRIGHT_INSTALL_FLAGS) chromium firefox
@$(PYTHON) scripts/ensure_browsers.py
# The browser tier without installing the web packages: revert-red runs it in a worktree whose
# packages are links to the working tree's, which an install would replace.
# M4's acceptance (D252): two browsers for ORPHEUM_ACCEPTANCE_MINUTES (30) under each of the four
# netem profiles, each with some four minutes of voice alone after: two and a half hours (2.4 h on
# 2026-10-08); at a milestone's end, never in check-pr. It shapes the dev
# container's loopback with tc, so it runs in the development image, through ./dev when it is not in
# it (scripts/in_dev_image.py): check-pr ran the short one on the host, where it failed asking to be
# run through ./dev by hand (2026-10-23).
.PHONY: test-acceptance test-acceptance-here
test-acceptance: ## M4's acceptance: two browsers for 30 minutes under each netem profile (D252); at a milestone's end
@$(PYTHON) scripts/in_dev_image.py test-acceptance-here
test-acceptance-here: browsers
@$(MAKE) --no-print-directory browser-tier E2E_CONFIG=web/e2e/acceptance.config.ts
# The branch gate's short acceptance run (D252 §2, D261 §2): home alone, ACCEPTANCE_HOME_MINUTES
# long, its film with voice beside it only, measured for half a minute; in check-pr, only when what
# the browser tier builds changed. Voice alone is the full acceptance's: here it doubled check-pr's
# time (agent-failures A24).
ACCEPTANCE_HOME_MINUTES ?= 0.5
# The releases the cross-release test pairs this source with: the three newest release tags, a tag
# on this commit left out (it is this source).
CROSS_RELEASES ?= $(shell git tag --list 'v[0-9]*' --sort=-v:refname --no-contains HEAD | head -3 | tr '\n' ' ')
.PHONY: test-cross-release
test-cross-release: browsers ## D586 §2: this source's client under each of CROSS_RELEASES' loaders, and each of those releases' clients under this source's loader; run as a release is prepared, not in check-pr
@test -n '$(strip $(CROSS_RELEASES))' || { echo "test-cross-release: no release to pair with; name them, CROSS_RELEASES=\"v0.8.17 v0.8.18\"" >&2; exit 2; }
@ORPHEUM_CROSS_RELEASES='$(strip $(CROSS_RELEASES))' $(MAKE) --no-print-directory browser-tier
@$(PYTHON) scripts/release_tag.py --passed '$(strip $(CROSS_RELEASES))'
.PHONY: release-tag
release-tag: ## A release's annotated tag, VERSION=v<x.y.z> MESSAGE=<file of the batch's summary>: refused until check-pr closed the batch here, test-cross-release passed on this tree and orpheum-connect pins this commit's discovery/ (lead.md §9)
@test -n '$(VERSION)' -a -n '$(MESSAGE)' || { echo "release-tag: name both, VERSION=v0.8.20 MESSAGE=<file>" >&2; exit 2; }
@$(PYTHON) scripts/release_tag.py --tag '$(VERSION)' --message-file '$(MESSAGE)'
.PHONY: test-acceptance-home test-acceptance-home-here
test-acceptance-home: ## M4's acceptance under the home profile for ACCEPTANCE_HOME_MINUTES (D252 §2); in check-pr, only when Watch Together, voice, WebRTC, the player or playback changed
@$(PYTHON) scripts/in_dev_image.py test-acceptance-home-here $(if $(BASE),BASE='$(BASE)') \
ACCEPTANCE_HOME_MINUTES=$(ACCEPTANCE_HOME_MINUTES)
test-acceptance-home-here: browsers
@if [ -z '$(BASE)' ] || $(PYTHON) scripts/browser_tier_needed.py --base '$(BASE)' --acceptance; then \
ORPHEUM_ACCEPTANCE_MINUTES=$(ACCEPTANCE_HOME_MINUTES) ORPHEUM_ACCEPTANCE_PROFILES=home \
$(MAKE) --no-print-directory browser-tier E2E_CONFIG=web/e2e/acceptance.config.ts \
E2E_ARGS='--grep "stay in step"'; fi
E2E_CONFIG ?= web/e2e/playwright.config.ts
# Playwright's own arguments for one run, such as a --grep; none by default.
E2E_ARGS ?=
.PHONY: browser-tier
browser-tier:
@npm --prefix web run --silent build
@$(call EMBEDDING_BUILD,-tags dev -o $(DEV_DIR)/bin/orpheum-browser ./cmd/orpheum)
@status=0; $(BROWSER_PASS) $(E2E_ARGS) || status=$$?; \
if [ '$(E2E_CONFIG)' = web/e2e/playwright.config.ts ]; then \
ORPHEUM_E2E_TIMING=1 $(BROWSER_PASS) $(E2E_ARGS) || status=$$?; fi; exit $$status
# One pass of the browser tier. The tier's config runs two (playwright.config.ts): every test but the
# timed side by side, each worker on a server of its own, then the timed alone, both whatever the
# first's result, as the last run goes to completion (the owner, 2026-10-18). A narrowed run may leave
# one pass nothing to run, which passes.
BROWSER_PASS = $(HERMETIC) ORPHEUM_TEST_BINARY="$(CURDIR)/$(DEV_DIR)/bin/orpheum-browser" \
ORPHEUM_TEST_FFMPEG_DIR="$(FFMPEG_DIR)" npm --prefix web exec -- playwright test --config $(E2E_CONFIG) \
$(if $(filter web/e2e/playwright.config.ts,$(E2E_CONFIG)),--pass-with-no-tests)
# ---------------------------------------------------------------------------------------------
# Building and generating
# ---------------------------------------------------------------------------------------------
# The binary embeds whatever is in $(WEBCLIENT_DIST) (D216 §2). `make build` fills it for the one
# go build and empties it after, so no other build or test embeds a client by accident; the
# committed .keep keeps the directory, so every build compiles.
WEBCLIENT_DIST := internal/core/webclient/dist
WEBCLIENT_CLEAR := find $(WEBCLIENT_DIST) -mindepth 1 -maxdepth 1 ! -name .keep -exec rm -rf {} +
# One go build ($(1) its arguments) with the web client copied in, holding the test lock while the copy is
# there: a make check run beside ./staging's build found the client a test binary has none of, and
# TestServe_AnswersTheClientsAddressesAtTheRoot failed (2026-11-09). Inside a gate's run it passes through.
EMBEDDING_BUILD = $(GATE_LOCK) --as build sh -c '$(WEBCLIENT_CLEAR) && cp -r web/apps/web/dist/. $(WEBCLIENT_DIST)/ && \
go build $(1); status=$$?; $(WEBCLIENT_CLEAR); exit $$status'
.PHONY: build
build: web-deps ## Build the web apps into their dist/, then the server binary, with the web client in it, into bin/
@npm --prefix web run --silent build
@$(call EMBEDDING_BUILD,-trimpath -ldflags "-s -w" -o bin/orpheum ./cmd/orpheum)
.PHONY: deploy
deploy: ## Deploy this checkout's commit to DIR, on this machine (MEDIA= the first time; FORCE=yes skips the question an untagged commit or a modified tree asks)
@test -n "$(DIR)" || { echo "usage: make deploy DIR=<deployment directory> [MEDIA=<folder>...] [FORCE=yes]" >&2; exit 2; }
@deploy/release/build.sh --checkout "$(DIR)" $(if $(filter yes,$(FORCE)),--force) $(foreach folder,$(MEDIA),--media "$(folder)")
.PHONY: deploy-published
deploy-published: ## Install the published image TAG to DIR as a household does: its own install script, piped to sh (MEDIA= the first time)
@test -n "$(TAG)" -a -n "$(DIR)" || { echo "usage: make deploy-published TAG=<version, or latest> DIR=<deployment directory> [MEDIA=<folder>...]" >&2; exit 2; }
@test -f "$(DIR)/values.toml" -o -n "$(MEDIA)" || { echo "$(DIR) holds no deployment yet: name the folders that hold the films and series, MEDIA=\"/path/to/films /path/to/shows\"" >&2; exit 2; }
docker run --rm ghcr.io/kstenerud/orpheum:$(TAG) install-script | sh -s -- --dir "$(DIR)" $(foreach folder,$(MEDIA),--media "$(folder)")
.PHONY: generate generate-sql generate-api
generate: ## Regenerate committed generated code (sqlc for persistent.db and cache.db, the OpenAPI document, the SDK's TS types, the compose files)
@$(MAKE) --no-print-directory generate-sql
@$(MAKE) --no-print-directory generate-api
generate-sql: ## Regenerate sqlc's Go for persistent.db and cache.db
@if ls internal/store/queries/*.sql >/dev/null 2>&1; then \
$(PYTHON) scripts/fetch_tools.py; \
sqlc generate && sqlc vet; \
else echo "generate: no queries yet (internal/store/queries/*.sql); nothing to do"; fi
generate-api: web-deps ## Regenerate the OpenAPI document, the compose files and the SDK's TS types
@# Made in the system's temporary directory, removed however the run ends (one made beside it was left by a
@# stopped make check, 2026-10-08), and copied over only when it differs. Then each route's compose file (D462 §10.2).
@openapi_next=$$(mktemp "$${TMPDIR:-/tmp}/openapi.json.XXXXXX") && trap 'rm -f "$$openapi_next"' EXIT INT TERM && \
go run ./cmd/orpheum openapi > "$$openapi_next" && go run ./cmd/orpheum compose-files . && \
{ cmp -s "$$openapi_next" api/openapi.json || cp "$$openapi_next" api/openapi.json; }
@npm --prefix web exec --workspace @orpheum/sdk -- openapi-typescript ../../../api/openapi.json \
--output src/gen/api.ts --alphabetize --empty-objects-unknown >/dev/null
.PHONY: fmt
fmt-staged: ## Format the staged files in place and stage them again (the pre-commit hook runs it)
@$(PYTHON) scripts/format_files.py --staged
fmt: ## Format Go and web sources in place
@golangci-lint fmt ./...
@npm --prefix web run --silent format
# Development and debugging: mk/dev.mk, here so its variables are set where they always were.
include $(dir $(lastword $(MAKEFILE_LIST)))mk/dev.mk
# ---------------------------------------------------------------------------------------------
# Setting up a machine
# ---------------------------------------------------------------------------------------------
.PHONY: tools
tools: ## Fetch the pinned golangci-lint and sqlc into .tools/ (make check does it too)
@$(PYTHON) scripts/fetch_tools.py
.PHONY: setup go-test-lock
setup: hooks go-test-lock web-deps browsers ## Set up a clone: git hooks, go test's lock, web dependencies, the browsers (check, spot, dev and check-pr do their parts)
go-test-lock: ## Make `go test` typed anywhere take the repository's test lock (Go reads no repository setting: points your GOFLAGS' -exec at the main tree's)
@$(PYTHON) scripts/go_test_lock.py
# The git hooks, which a clone or a rebuilt sandbox lacks until set: without them a commit ran no gate,
# and the pre-bash hook refused every commit until `make setup` was found (2026-10-23). The gates and
# the dev loop set them first, so nothing has to be remembered.
.PHONY: hooks
hooks: ## Point git at .githooks/ if it is not already
@[ "$$(git config core.hooksPath)" = .githooks ] || \
{ git config core.hooksPath .githooks && echo "hooks: git hooks now run from .githooks/"; }
.PHONY: clean
clean: ## Remove build output
@rm -rf bin web/apps/*/dist
@$(WEBCLIENT_CLEAR)