Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
301 lines (257 loc) · 9.16 KB
/
Copy pathTaskfile.yml
File metadata and controls
301 lines (257 loc) · 9.16 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
version: "3"
vars:
SERVER_BIN: server
CLI_BIN: trajecta
CONFIG: '{{default "config/config.yaml" .CONFIG}}'
VERSION:
sh: git describe --tags --always --dirty 2>/dev/null || echo dev
COMMIT:
sh: git rev-parse --short=12 HEAD 2>/dev/null || echo none
BRANCH:
sh: git branch --show-current 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown
BUILD_DATE:
sh: date -u +%Y-%m-%dT%H:%M:%SZ
LDFLAGS: >-
-s -w
-X main.Version={{.VERSION}}
-X main.Commit={{.COMMIT}}
-X main.Date={{.BUILD_DATE}}
-X main.Branch={{.BRANCH}}
tasks:
default:
cmds:
- task: build
ui:build:
desc: Build embedded Trace Monitor UI
dir: web/monitor-ui
cmds:
- bun install --frozen-lockfile
- bun run build
ui:typecheck:
desc: Type-check the TypeScript modules of the Monitor UI
dir: web/monitor-ui
cmds:
- bun install --frozen-lockfile
- bun run typecheck
ui:test:
desc: Run type-check, unit and browser smoke tests for the Monitor UI
dir: web/monitor-ui
cmds:
- bun install --frozen-lockfile
- bun run typecheck
- bun run test:unit
- bun run test:ui
ui:test:unit:
desc: Run the Monitor UI unit tests
dir: web/monitor-ui
cmds:
- bun install --frozen-lockfile
- bun run test:unit
ui:test:real:
desc: Run browser tests against the real Go Monitor server fixture
dir: web/monitor-ui
cmds:
- bun install --frozen-lockfile
- bun run test:ui:real
ui:screenshots:
desc: Regenerate the README screenshots (images/ and images/en/) from the fixture server
dir: web/monitor-ui
cmds:
- bun install --frozen-lockfile
- bunx playwright test --config playwright.screenshots.config.js
generate:ent:
desc: Generate ent control-plane DAO code
cmds:
- go generate ./ent/...
generate:secretmask:
desc: Regenerate the Ragel credential DFA (pkg/secretmask/rules_ragel.go) from rules.rl; requires the ragel-go binary
cmds:
- go generate ./pkg/secretmask/...
migrate:ent:sqlite:
desc: Generate a SQLite ent migration, pass NAME=change_name
cmds:
- >-
sh -c 'test -n "{{.NAME}}" ||
{ echo "NAME is required, for example: task migrate:ent:sqlite NAME=add_table"; exit 2; }'
- go run -mod=mod ent/migrate/main.go --dialect sqlite --dir ent/migrations "{{.NAME}}"
- go run -mod=mod ent/migrate/update_hash.go ent/migrations
migrate:ent:postgres:
desc: Generate a Postgres ent migration, pass NAME=change_name and DEV_URL=postgres://...
cmds:
- >-
sh -c 'test -n "{{.NAME}}" ||
{ echo "NAME is required, for example: task migrate:ent:postgres NAME=add_table DEV_URL=postgres://..."; exit 2; }'
- >-
sh -c 'test -n "{{.DEV_URL}}" ||
{ echo "DEV_URL is required and must point to a temporary development Postgres database"; exit 2; }'
- go run -mod=mod ent/migrate/main.go --dialect postgres --dir ent/postgres-migrations --dev-url "{{.DEV_URL}}" "{{.NAME}}"
- go run -mod=mod ent/migrate/update_hash.go ent/postgres-migrations
fmt:
desc: Format Go code
cmds:
- gofmt -w ./cmd ./internal ./pkg ./unittest ./tests ./web/monitor-ui/test-fixtures
fmt:check:
desc: Check Go formatting without modifying files
cmds:
- >-
sh -c 'files="$(gofmt -l ./cmd ./internal ./pkg ./unittest ./tests ./web/monitor-ui/test-fixtures)";
test -z "$files" || { echo "$files"; exit 1; }'
lint:
desc: Run golangci-lint static checks
cmds:
- golangci-lint run ./...
lint:vet:
desc: Run go vet directly
cmds:
- go vet ./...
test:
desc: Run unit tests
cmds:
- go test ./...
test:e2e:
desc: Run local end-to-end tests without external network dependencies
cmds:
- go test ./internal/proxy ./internal/monitor ./cmd/server ./cmd/trajecta ./unittest
atif:validate:
desc: Validate ATIF-v1.8 JSONL with pinned Harbor models (install scripts/atif-requirements.txt first)
cmds:
- python3 scripts/validate_atif.py {{.CLI_ARGS}}
test:atif:
desc: Test ATIF export and the official-model validator offline
cmds:
- go test ./internal/trajectory ./internal/monitor
# Precheck the Python dependency so a missing pydantic reports an
# actionable message instead of an opaque unittest import ERROR.
- >-
sh -c 'python3 -c "import pydantic" 2>/dev/null ||
{ echo "SKIP atif validator: pydantic is not installed.";
echo " install it with: python3 -m pip install -r scripts/atif-requirements.txt";
exit 0; }'
- python3 -m unittest discover -s scripts/atif_tests
test:codex-fixtures:
desc: Run offline Codex Responses fixture runner tests
cmds:
- env -u GOROOT go test ./internal/responses/httpapi ./internal/responses/runtime -count=1
test:short:
desc: Run unit tests without the Postgres integration paths (go test -short)
cmds:
- go test -short ./...
test:race:
desc: Run unit tests with the Go race detector
cmds:
- go test -race ./...
test:cover:
desc: Run unit tests and write coverage.out
cmds:
- go test -coverprofile=coverage.out ./...
bench:
desc: Run all Go benchmarks with allocation stats
cmds:
- go test -bench=. -benchmem ./...
bench:core:
desc: Run benchmarks for core proxy, record/replay, router, store, secretmask, and LLM packages
cmds:
- go test -bench=. -benchmem ./internal/proxy ./internal/router ./internal/store ./pkg/llm ./pkg/recordfile ./pkg/replay ./pkg/secretmask
bench:secretmask:
desc: Run credential/PII detection, masking and restore benchmarks
cmds:
- go test -count=1 -run '^$' -bench=. -benchmem ./pkg/secretmask
deps:verify:
desc: Verify module dependencies without editing go.mod or go.sum
cmds:
- go mod verify
- go list -mod=readonly ./...
deps:tidy:
desc: Tidy Go module files
cmds:
- go mod tidy
build:go:
desc: Build the server and CLI binaries without rebuilding the UI
cmds:
- go build -trimpath -ldflags="{{.LDFLAGS}}" -o {{.SERVER_BIN}} ./cmd/server
- go build -trimpath -ldflags="{{.LDFLAGS}}" -o {{.CLI_BIN}} ./cmd/trajecta
build:all:
desc: Build embedded UI and server binary
cmds:
- task: ui:build
- task: build:go
build:
desc: Build server binary and embedded UI
cmds:
- task: build:all
migrate:
desc: Rewrite legacy V2 cassettes to V3 and rebuild SQLite index
cmds:
- go run ./cmd/trajecta migrate -c {{.CONFIG}}
migrate:db:up:
desc: Apply application database migrations
cmds:
- go run ./cmd/trajecta db migrate up -c {{.CONFIG}}
migrate:legacy:
desc: Inspect a pre-rename deployment; pass ARGS="--apply" to write changes
cmds:
- go run ./cmd/trajecta upgrade -c {{.CONFIG}} {{default "" .ARGS}}
auth:init-user:
desc: Initialize an auth user, pass USER and PASSWORD
cmds:
- go run ./cmd/trajecta auth init-user -c {{.CONFIG}} --username "{{.USER}}" --password "{{.PASSWORD}}"
auth:create-token:
desc: Create an API token for a user, pass USER and NAME
cmds:
- go run ./cmd/trajecta auth create-token -c {{.CONFIG}} --username "{{.USER}}" --name "{{.NAME}}"
run:
desc: Start proxy and monitor with local config
cmds:
- go run ./cmd/server -c {{.CONFIG}}
docker:build:
desc: Build Docker image
cmds:
- >-
eval "$(./scripts/docker-build-env.sh)" &&
docker build
--add-host host.docker.internal:host-gateway
--build-arg GOPROXY="${DOCKER_BUILD_GOPROXY}"
--build-arg GOSUMDB="${DOCKER_BUILD_GOSUMDB}"
--build-arg HTTP_PROXY="${DOCKER_BUILD_HTTP_PROXY}"
--build-arg HTTPS_PROXY="${DOCKER_BUILD_HTTPS_PROXY}"
--build-arg NO_PROXY="${DOCKER_BUILD_NO_PROXY}"
--build-arg http_proxy="${DOCKER_BUILD_http_proxy}"
--build-arg https_proxy="${DOCKER_BUILD_https_proxy}"
--build-arg no_proxy="${DOCKER_BUILD_no_proxy}"
--build-arg VERSION="{{.VERSION}}"
--build-arg COMMIT="{{.COMMIT}}"
--build-arg BUILD_DATE="{{.BUILD_DATE}}"
--build-arg BRANCH="{{.BRANCH}}"
-t trajecta:local
.
docker:up:
desc: Start trajecta with docker compose
cmds:
- >-
eval "$(./scripts/docker-build-env.sh)" &&
export DOCKER_BUILD_GOPROXY DOCKER_BUILD_GOSUMDB
DOCKER_BUILD_HTTP_PROXY DOCKER_BUILD_HTTPS_PROXY DOCKER_BUILD_NO_PROXY
DOCKER_BUILD_http_proxy DOCKER_BUILD_https_proxy DOCKER_BUILD_no_proxy &&
docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d
check:
desc: Run the default local quality gate
cmds:
- task: check:quick
check:quick:
desc: Run formatting check, lint, and short tests
cmds:
- task: fmt:check
- task: lint
- task: test:short
check:full:
desc: Run full validation including race tests and full build
cmds:
- task: check:quick
- task: test
- task: test:e2e
- task: test:race
- task: build:all
clean:
desc: Remove local build artifacts
cmds:
- rm -f {{.SERVER_BIN}} {{.CLI_BIN}}