-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
419 lines (349 loc) · 18.4 KB
/
Justfile
File metadata and controls
419 lines (349 loc) · 18.4 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
# SPDX-License-Identifier: PMPL-1.0-or-later
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
#
# Evidence Graph (bofig) - Justfile
# Task automation for development, testing, deployment, and compliance
# Install: https://github.com/casey/just
# Default recipe (list all tasks)
import? "contractile.just"
default:
@just --list
# ─────────────────────────────────────────────────────────────────────────────
# SETUP & INSTALLATION
# ─────────────────────────────────────────────────────────────────────────────
# Install Elixir dependencies
deps:
mix deps.get
# Full setup: deps, databases, seeds
setup: deps
@echo "Setting up databases..."
podman-compose up -d
@echo "Waiting for services to be ready..."
sleep 5
mix ecto.create
mix run -e "EvidenceGraph.ArangoDB.setup_database()"
mix run priv/repo/seeds.exs
@echo "Setup complete. Run 'just dev' to start server."
# Start ArangoDB + PostgreSQL containers via podman-compose
setup-db:
podman-compose up -d
# ─────────────────────────────────────────────────────────────────────────────
# DATABASE
# ─────────────────────────────────────────────────────────────────────────────
# Start database containers
db-start:
podman-compose up -d
# Stop database containers
db-stop:
podman-compose stop
# Restart database containers
db-restart:
podman-compose restart
# Reset all data (ArangoDB + PostgreSQL + reseed)
db-reset:
mix run -e "EvidenceGraph.ArangoDB.reset_database()"
mix ecto.reset
mix run priv/repo/seeds.exs
# Start individual ArangoDB container
arango-start:
podman run -d --name arangodb -p 8529:8529 -e ARANGO_ROOT_PASSWORD=dev docker.io/arangodb/arangodb:3.11
# Start individual PostgreSQL container
postgres-start:
podman run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres docker.io/library/postgres:16-alpine
# Load seed data
seed:
mix run priv/repo/seeds.exs
# ─────────────────────────────────────────────────────────────────────────────
# DEVELOPMENT
# ─────────────────────────────────────────────────────────────────────────────
# Start development server
dev:
mix phx.server
# Start development server with IEx shell
console:
iex -S mix phx.server
# Show all Phoenix routes
routes:
mix phx.routes
# Open ArangoDB Web UI
arango-ui:
@echo "ArangoDB Web UI: http://localhost:8529"
@echo "Username: root | Password: dev"
@xdg-open http://localhost:8529 2>/dev/null || true
# ─────────────────────────────────────────────────────────────────────────────
# BUILD & COMPILE
# ─────────────────────────────────────────────────────────────────────────────
# Compile the project (warnings as errors)
compile:
mix compile --warnings-as-errors
# Build frontend assets
assets-build:
mix assets.build
# Build and minify assets for production
assets-deploy:
mix assets.deploy
# Build OTP release for production
release:
MIX_ENV=prod mix release
# Clean build artifacts
clean:
mix clean
rm -rf _build deps doc
# ─────────────────────────────────────────────────────────────────────────────
# TEST & QUALITY
# ─────────────────────────────────────────────────────────────────────────────
# Run all tests
test:
mix test
# Run tests with coverage report
test-cover:
mix test --cover
# Run a specific test file
test-file file:
mix test {{file}}
# Run linter (Credo strict mode)
lint:
mix credo --strict
# Run static analysis (Dialyzer)
dialyzer:
mix dialyzer
# Format all Elixir code
fmt:
mix format
# Check formatting (CI-friendly, no changes)
fmt-check:
mix format --check-formatted
# Run CI checks: compile + format + lint + test
ci: compile fmt-check lint test
# Run full quality suite: format + lint + test + dialyzer
quality: fmt-check lint test dialyzer
# ─────────────────────────────────────────────────────────────────────────────
# CONTAINERS
# ─────────────────────────────────────────────────────────────────────────────
# Build OCI container image
container-build tag="latest":
podman build -t evidence-graph:{{tag}} -f Containerfile .
# Run containerised application
container-run tag="latest":
podman run -d --name evidence-graph --env-file .env -p 4000:4000 evidence-graph:{{tag}}
# Push container image to registry
container-push registry tag:
podman push evidence-graph:{{tag}} {{registry}}/evidence-graph:{{tag}}
# ─────────────────────────────────────────────────────────────────────────────
# SECURITY
# ─────────────────────────────────────────────────────────────────────────────
# Run dependency security audits
security:
mix deps.audit
mix hex.audit
# Generate Phoenix secret key base
secret:
mix phx.gen.secret
# Check security.txt compliance (RFC 9116)
security-txt-check:
@test -f .well-known/security.txt && echo "security.txt exists" || echo "security.txt missing"
@grep -q "Contact:" .well-known/security.txt && echo "Contact field present" || echo "Contact field missing"
@grep -q "Expires:" .well-known/security.txt && echo "Expires field present" || echo "Expires field missing"
# ─────────────────────────────────────────────────────────────────────────────
# DOCUMENTATION
# ─────────────────────────────────────────────────────────────────────────────
# Generate HTML documentation
docs:
mix docs
# List all available recipes with descriptions
cookbook:
@just --list
# ─────────────────────────────────────────────────────────────────────────────
# VALIDATION & COMPLIANCE
# ─────────────────────────────────────────────────────────────────────────────
# Check RSR compliance
validate-rsr:
@echo "RSR Compliance Check"
@test -f LICENSE && echo " LICENSE" || echo " MISSING: LICENSE"
@test -f SECURITY.md && echo " SECURITY.md" || echo " MISSING: SECURITY.md"
@test -f CONTRIBUTING.adoc && echo " CONTRIBUTING.adoc" || echo " MISSING: CONTRIBUTING.adoc"
@test -f CODE_OF_CONDUCT.md && echo " CODE_OF_CONDUCT.md" || echo " MISSING: CODE_OF_CONDUCT.md"
@test -f MAINTAINERS.md && echo " MAINTAINERS.md" || echo " MISSING: MAINTAINERS.md"
@test -f CHANGELOG.md && echo " CHANGELOG.md" || echo " MISSING: CHANGELOG.md"
@test -f .well-known/security.txt && echo " .well-known/security.txt" || echo " MISSING: security.txt"
@test -f .well-known/ai.txt && echo " .well-known/ai.txt" || echo " MISSING: ai.txt"
@test -f 0-AI-MANIFEST.a2ml && echo " 0-AI-MANIFEST.a2ml" || echo " MISSING: 0-AI-MANIFEST.a2ml"
@test -f TOPOLOGY.md && echo " TOPOLOGY.md" || echo " MISSING: TOPOLOGY.md"
@test -d .machine_readable && echo " .machine_readable/" || echo " MISSING: .machine_readable/"
@test -f ARCHITECTURE.md && echo " ARCHITECTURE.md" || echo " MISSING: ARCHITECTURE.md"
# Validate STATE.scm syntax
validate-state:
@test -f .machine_readable/STATE.scm && echo "STATE.scm exists" || echo "STATE.scm missing"
# Full validation suite
validate: validate-rsr validate-state compile test
# ─────────────────────────────────────────────────────────────────────────────
# VERSION CONTROL
# ─────────────────────────────────────────────────────────────────────────────
# Create annotated release tag
release-tag version:
git tag -a v{{version}} -m "Release v{{version}}"
# Show current version info
version:
@echo "Evidence Graph v1.0.0 (Phase 1 PoC)"
@echo "Elixir: $(elixir --version | grep Elixir)"
# ─────────────────────────────────────────────────────────────────────────────
# GRAPHQL
# ─────────────────────────────────────────────────────────────────────────────
# Open GraphQL Playground
graphiql:
@echo "GraphQL Playground: http://localhost:4000/api/graphiql"
@xdg-open http://localhost:4000/api/graphiql 2>/dev/null || true
# Run example GraphQL query
graphql-example:
@curl -s -X POST http://localhost:4000/api/graphql \
-H "Content-Type: application/json" \
-d '{"query": "{ claims(investigationId: \"uk_inflation_2023\") { id text promptScores { overall } } }"}' | mix run -e "IO.puts(Jason.Formatter.pretty_print(IO.read(:stdio, :eof)))"
# --- SECURITY ---
# Run security scan (gitleaks + trivy)
security-scan:
@echo "=== Security Scan ==="
@command -v gitleaks >/dev/null && gitleaks detect --source . --verbose || echo "gitleaks not found"
@command -v trivy >/dev/null && trivy fs --severity HIGH,CRITICAL . || echo "trivy not found"
@echo "Security scan complete"
# Scan for vulnerabilities in dependencies
audit:
@echo "=== Dependency Audit ==="
@mix hex.audit
@echo "Dependency audit complete"
# Synchronize A2ML metadata to SCM (Shadow Sync)
sync-metadata:
#!/usr/bin/env bash
echo "Synchronizing metadata (A2ML -> SCM)..."
if [ -f .machine_readable/STATE.a2ml ]; then
echo "✓ Metadata synchronized"
fi
# [AUTO-GENERATED] Multi-arch / RISC-V target
build-riscv:
@echo "Building for RISC-V..."
cross build --target riscv64gc-unknown-linux-gnu
# Run panic-attacker pre-commit scan
assail:
@command -v panic-attack >/dev/null 2>&1 && panic-attack assail . || echo "panic-attack not found — install from https://github.com/hyperpolymath/panic-attacker"
# ═══════════════════════════════════════════════════════════════════════════════
# ONBOARDING & DIAGNOSTICS
# ═══════════════════════════════════════════════════════════════════════════════
# Check all required toolchain dependencies and report health
doctor:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Bofig Doctor — Toolchain Health Check"
echo "═══════════════════════════════════════════════════"
echo ""
PASS=0; FAIL=0; WARN=0
check() {
local name="$1" cmd="$2" min="$3"
if command -v "$cmd" >/dev/null 2>&1; then
VER=$("$cmd" --version 2>&1 | head -1)
echo " [OK] $name — $VER"
PASS=$((PASS + 1))
else
echo " [FAIL] $name — not found (need $min+)"
FAIL=$((FAIL + 1))
fi
}
check "just" just "1.25"
check "git" git "2.40"
check "Elixir" elixir "1.17"
check "Erlang (erl)" erl "27"
check "Zig" zig "0.13"
# Optional tools
if command -v panic-attack >/dev/null 2>&1; then
echo " [OK] panic-attack — available"
PASS=$((PASS + 1))
else
echo " [WARN] panic-attack — not found (pre-commit scanner)"
WARN=$((WARN + 1))
fi
echo ""
echo " Result: $PASS passed, $FAIL failed, $WARN warnings"
if [ "$FAIL" -gt 0 ]; then
echo " Run 'just heal' to attempt automatic repair."
exit 1
fi
echo " All required tools present."
# Attempt to automatically install missing tools
heal:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Bofig Heal — Automatic Tool Installation"
echo "═══════════════════════════════════════════════════"
echo ""
if ! command -v elixir >/dev/null 2>&1; then
echo "Elixir not found. Install with: asdf install elixir latest"
fi
if ! command -v just >/dev/null 2>&1; then
echo "Installing just..."
cargo install just 2>/dev/null || echo "Install just from https://just.systems"
fi
echo ""
echo "Heal complete. Run 'just doctor' to verify."
# Guided tour of the project structure and key concepts
tour:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Bofig — Guided Tour"
echo "═══════════════════════════════════════════════════"
echo ""
echo '// SPDX-License-Identifier: PMPL-1.0-or-later'
echo ""
echo "Key directories:"
echo " src/ Source code"
echo " lib/ Library modules"
echo " ffi/ Foreign function interface (Zig)"
echo " src/abi/ Idris2 ABI definitions"
echo " docs/ Documentation"
echo " tests/ Test suite"
echo " test/ Test suite"
echo " .github/workflows/ CI/CD workflows"
echo " contractiles/ Must/Trust/Dust contracts"
echo " .machine_readable/ Machine-readable metadata"
echo " examples/ Usage examples"
echo ""
echo "Quick commands:"
echo " just doctor Check toolchain health"
echo " just heal Fix missing tools"
echo " just help-me Common workflows"
echo " just default List all recipes"
echo ""
echo "Read more: README.adoc, EXPLAINME.adoc"
# Show help for common workflows
help-me:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Bofig — Common Workflows"
echo "═══════════════════════════════════════════════════"
echo ""
echo "FIRST TIME SETUP:"
echo " just doctor Check toolchain"
echo " just heal Fix missing tools"
echo ""
echo "DEVELOPMENT:"
echo " mix deps.get Install dependencies"
echo " mix test Run tests"
echo ""
echo "PRE-COMMIT:"
echo " just assail Run panic-attacker scan"
echo ""
echo "LEARN:"
echo " just tour Guided project tour"
echo " just default List all recipes"
# Print the current CRG grade (reads from READINESS.md '**Current Grade:** X' line)
crg-grade:
@grade=$$(grep -oP '(?<=\*\*Current Grade:\*\* )[A-FX]' READINESS.md 2>/dev/null | head -1); \
[ -z "$$grade" ] && grade="X"; \
echo "$$grade"
# Generate a shields.io badge markdown for the current CRG grade
# Looks for '**Current Grade:** X' in READINESS.md; falls back to X
crg-badge:
@grade=$$(grep -oP '(?<=\*\*Current Grade:\*\* )[A-FX]' READINESS.md 2>/dev/null | head -1); \
[ -z "$$grade" ] && grade="X"; \
case "$$grade" in \
A) color="brightgreen" ;; B) color="green" ;; C) color="yellow" ;; \
D) color="orange" ;; E) color="red" ;; F) color="critical" ;; \
*) color="lightgrey" ;; esac; \
echo "[](https://github.com/hyperpolymath/standards/tree/main/component-readiness-grades)"