Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
1799 lines (1644 loc) · 84.3 KB
/
Copy pathMakefile
File metadata and controls
1799 lines (1644 loc) · 84.3 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
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Astra Makefile
.PHONY: help
help:
@echo "Astra Development Commands"
@echo "=================================="
@echo ""
@echo "Quick Start:"
@echo " make dev-start - Start deterministic server-only development (deps + debug API + web)"
@echo " make dev-start-server-only - Start server-only runtime (deps + API + web; no edge provider)"
@echo " make dev-start-server-edge - Start server + local astra-edge provider"
@echo " make dev-stop - Stop all services"
@echo " make dev-status - Show all service status"
@echo " make dev-init - Initialize development environment"
@echo ""
@echo "Dependencies (MatrixOne + Memoria):"
@echo " make dev-deps-up - Start MatrixOne + Memoria"
@echo " make dev-deps-down - Stop dependency services"
@echo " make dev-deps-clean - Stop and remove all data (destructive!)"
@echo " make dev-deps-status - Show dependency status"
@echo " make dev-deps-logs - Show dependency logs"
@echo " make dev-db-connect - Connect to MatrixOne CLI"
@echo ""
@echo "API Server:"
@echo " make dev-api-start - Start API server (release build)"
@echo " make dev-api-start-debug - Start API server (debug build, fast)"
@echo " make dev-api-stop - Stop API server"
@echo " make dev-api-restart - Restart API server (release)"
@echo " make dev-api-restart-debug - Restart API server (debug, fast)"
@echo " make dev-api-logs - Show API server logs"
@echo " make dev-api-status - Show API server status"
@echo ""
@echo "Web UI:"
@echo " make dev-sdk-deps - Install/build local @astra/sdk for web UI"
@echo " make dev-web-deps - Install web UI dependencies"
@echo " make dev-web-start - Start web UI (default http://localhost:3536; override with ASTRA_WEB_PORT=<port>)"
@echo " make dev-web-stop - Stop web UI"
@echo " make dev-web-restart - Restart web UI"
@echo " make dev-web-logs - Show web UI logs"
@echo " make dev-web-status - Show web UI status"
@echo ""
@echo "Edge Provider:"
@echo " make dev-edge-start - Start local astra-edge provider for web/server workspace tools"
@echo " make dev-edge-stop - Stop local astra-edge provider"
@echo " make dev-edge-logs - Show astra-edge logs"
@echo " make dev-edge-status - Show this checkout's repo-managed astra-edge status"
@echo ""
@echo "Testing:"
@echo " make test - test-offline + test-online (Rust DB online; optional SDK remote E2E if ASTRA_SDK_ONLINE_E2E=1)"
@echo " make test-offline - Rust workspace + e2e-hooks + @astra/sdk (30s per case; default 2 nextest threads, override: NEXTEST_OFFLINE_THREADS=<n> / NEXTEST_OFFLINE_PROFILE=<profile>)"
@echo " make validate-capability-matrix - Verify capability system-test references resolve"
@echo " make test-online - Rust #[ignore] + Matrix E2E (60s per case via profile=strict-online; see .config/nextest.toml)"
@echo " make test-memoria-databases - Verify Memoria database bootstrap contract"
@echo " make test-stack-bootstrap - Verify stack startup bootstraps Memoria before API"
@echo " make test-memoria-online-contract - Real Memoria missing-ID/circuit-recovery contract (explicit)"
@echo " make test-runtime-profiles - Server-only + server+edge + managed runtime + CLI-local profile guardrails"
@echo " make test-server-only - Focused Web/runtime tests for server-only access surface"
@echo " make test-server-edge - Focused tests for edge provider protocol and routing"
@echo " make test-managed-runtime - Focused tests for sandbox/orchestrator/MCP provider routing"
@echo " make test-cli-local - Focused tests for CLI-local provider routing"
@echo " make test-no-sticky-control - Fast no-sticky control-plane tests (approval/ask_user/edge callbacks; no live DB)"
@echo " make test-cleanup-pressure - Live MatrixOne cleanup pressure probes (explicit, not part of test-online)"
@echo " make test-durable-event-pressure - Live MatrixOne durable event pressure probe (explicit, not part of test-online)"
@echo " make test-saas - SaaS platform E2E (docs/testing/saas-test-plan.md §5; MatrixOne + optional SDK)"
@echo " make test-saas-coverage - SaaS E2E + llvm line coverage report (needs: cargo install cargo-llvm-cov)"
@echo " make harness-live-llm - Live LLM suite (real provider APIs from .models.yaml; one model per provider)"
@echo " make test-contract - Run contract tests (http/admin/config)"
@echo " (also: test-sdk-offline, test-web-offline, test-sdk-online — @astra/sdk + web offline; remote E2E opt-in on test-online)"
@echo ""
@echo "Code Quality:"
@echo " make check - Run all static checks (lint + format + type)"
@echo " make ci - Run CI checks (check + test)"
@echo " make lint - Run clippy (warnings are errors)"
@echo " make audit - Run cargo-audit (needs: cargo install cargo-audit)"
@echo " make format - Format code"
@echo " make format-check - Check formatting"
@echo ""
@echo "Build:"
@echo " make build - Build entire Rust workspace (release)"
@echo " make build-debug - Build entire Rust workspace (debug, fast)"
@echo " make build-server - Build astra-server (release)"
@echo " make build-server-debug - Build astra-server (debug, fast)"
@echo " make build-edge - Build astra-edge provider (release)"
@echo " make build-edge-debug - Build astra-edge provider (debug, fast)"
@echo " make build-cli - Build astra CLI (release)"
@echo " make build-cli-debug - Build astra CLI (debug, fast)"
@echo ""
@echo "Cleanup:"
@echo " make clean - Remove ALL Rust build artifacts (target/)"
@echo " make clean-stale - Remove artifacts not accessed in 12h (override: STALE_HOURS=N)"
@echo " make clean-debug - Remove debug/ directory only"
@echo " make sweep - Remove artifacts older than 4h (runs auto before release builds)"
@echo ""
@echo "Memoria (Memory Service):"
@echo " make memoria-start - Start Memoria service"
@echo " make memoria-stop - Stop Memoria service"
@echo " make memoria-logs - Show Memoria logs"
@echo " make memoria-status - Show Memoria status"
@echo ""
@echo "All-in-One Docker Deployment:"
@echo " make stack-env - Create .env and generate stack secrets"
@echo " make stack-setup - Complete guided setup from any stack state (admin/model optional)"
@echo " make stack-start - Initialize, start, and verify the Compose stack"
@echo " make stack-up - Start MatrixOne + Memoria + API"
@echo " make stack-up-server-only - Start compose stack without local edge provider"
@echo " make stack-up-server-edge - Start compose stack plus local astra-edge provider"
@echo " make stack-down - Stop compose stack"
@echo " make stack-clean - Stop compose stack and remove MatrixOne data"
@echo " make stack-status - Show compose stack status"
@echo " make stack-verify - Verify API health and a memory round trip"
@echo " make stack-logs - Follow stack logs (SERVICE=api optional)"
@echo ""
@echo "Docker API (alternative to source mode):"
@echo " make dev-start-docker - Start deps + API in Docker"
@echo " make dev-api-docker-up - Start API server in Docker"
@echo " make dev-api-docker-down - Stop API server Docker container"
@echo ""
@echo "Release maintenance:"
@echo " make release-prepare - Synchronize release versions (VERSION=...)"
@echo " make release-check - Run the read-only release preflight (VERSION=...)"
# ============================================================================
# Variables
# ============================================================================
CARGO_MANIFEST := Cargo.toml
CARGO := cargo
CARGO_MANIFEST_FLAG := --manifest-path $(CARGO_MANIFEST)
API_SHELL_PKG := -p astra-runtime
RUST_TARGET_DIR := target
RUST_DEBUG_BIN_DIR := $(RUST_TARGET_DIR)/debug
RUST_RELEASE_BIN_DIR := $(RUST_TARGET_DIR)/release
API_SERVER_BIN := astra-server
EDGE_BIN := astra-edge
CLI_BINS := astra
CLI_RELEASE_FLAGS ?= --no-default-features
IMAGE_NAME ?= matrixorigin/astra
DOCKER_BUILD_ARGS ?=
DOCKER_PROXY_BUILD_ARGS := --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy --build-arg HTTP_PROXY --build-arg HTTPS_PROXY --build-arg NO_PROXY
IMAGE_VERSION ?= $(if $(VERSION),$(patsubst v%,%,$(VERSION)),dev)
IMAGE_REVISION ?= $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
IMAGE_SOURCE_DIRTY ?= $(shell if git rev-parse --is-inside-work-tree >/dev/null 2>&1 && test -z "$$(git status --porcelain=v1 --untracked-files=no 2>/dev/null)"; then echo false; else echo true; fi)
IMAGE_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)
DOCKER_METADATA_BUILD_ARGS := --build-arg IMAGE_VERSION=$(IMAGE_VERSION) --build-arg IMAGE_REVISION=$(IMAGE_REVISION) --build-arg IMAGE_SOURCE_DIRTY=$(IMAGE_SOURCE_DIRTY) --build-arg IMAGE_BRANCH=$(IMAGE_BRANCH)
# Project-wide default for every API server mode. Compose may remap the
# host-facing port, but the container listens on this value.
DEFAULT_API_PORT := 17001
STACK_DIR := deployment/all-in-one
STACK_ENV := $(STACK_DIR)/.env
# Always resolve the Compose project from the selected env file. Explicit
# --project-name/--file plus clearing the two process-level overrides keeps
# stack-setup's isolation decision authoritative even in a user's shell.
STACK_COMPOSE := cd $(STACK_DIR) && project_name="$$(. "$(abspath scripts/lib/env_file.sh)"; env_file_read "$(abspath $(STACK_ENV))" ASTRA_STACK_NAME 2>/dev/null || true)"; project_name="$${project_name:-all-in-one}"; env -u COMPOSE_PROJECT_NAME -u COMPOSE_FILE UID=$$(id -u) GID=$$(id -g) ASTRA_STACK_ENV_FILE="$(abspath $(STACK_ENV))" docker compose --project-name "$$project_name" --file "$(abspath $(STACK_DIR)/docker-compose.yml)" --env-file "$(abspath $(STACK_ENV))"
STACK_SECRET_ENV := ASTRA_JWT_SECRET ASTRA_TOKEN_ENCRYPTION_KEY ASTRA_RUNTIME_ROOT_SECRET MEMORIA_MASTER_KEY
STACK_EMBEDDING_ENV := MEMORIA_EMBEDDING_BASE_URL
STACK_RECREATE ?= 0
STACK_RECREATE_ARGS := $(if $(filter 1 true yes,$(STACK_RECREATE)),--force-recreate --remove-orphans,)
# Per-test-case hard budget. Any case running longer than the budget is
# killed and counted as FAIL. Nextest has no CLI override for slow-timeout
# (`--config` is Cargo-only, not nextest), so budgets live as named profiles
# in `.config/nextest.toml`. All profiles currently use 30s (relaxed
# from original 1-2s due to known session_sync_log prune contention — see
# nextest.toml comment for tracking details).
# To switch budgets, override the profile name:
# make test-online NEXTEST_ONLINE_PROFILE=strict-online-ci
NEXTEST_OFFLINE_PROFILE ?= strict
NEXTEST_ONLINE_PROFILE ?= strict-online
# Keep the offline gate deterministic on hosts where the strict profile would
# otherwise fan out to every CPU. The runtime tests create many independent
# Tokio runtimes and filesystem-backed session fixtures; unconstrained
# process-level fan-out turns scheduling and temporary-state contention into
# false failures. Override for a tuned machine when doing an explicit stress
# run (for example, NEXTEST_OFFLINE_THREADS=8).
NEXTEST_OFFLINE_THREADS ?= 2
CLEANUP_PRESSURE_PROFILE ?= smoke
CLEANUP_PRESSURE_DATABASE_BASE ?= astra_runtime_test_cleanup_pressure
CLEANUP_PRESSURE_ARGS ?=
DURABLE_EVENT_PRESSURE_PROFILE ?= smoke
DURABLE_EVENT_PRESSURE_DATABASE ?= astra_runtime_test_durable_event_pressure
DURABLE_EVENT_PRESSURE_ARGS ?=
NEXTEST_OFFLINE_FLAGS := --profile $(NEXTEST_OFFLINE_PROFILE) --test-threads $(NEXTEST_OFFLINE_THREADS)
NEXTEST_ONLINE_FLAGS := --profile $(NEXTEST_ONLINE_PROFILE)
# Operational pressure probes have dedicated runners and data-size controls.
# Keep them out of the generic ignored-test lane, whose per-case timeout is a
# correctness budget rather than a load-test budget.
NEXTEST_CLEANUP_PRESSURE_EXCLUSION := not test(/(db_cleanup_expired|db_truncate_gc|prompt_retention)_pressure_probe/)
# Phase-0 production baselines require hermetic binary/model inputs and the
# ASTRA_PHASE0_BASELINE_EXCLUSIVE guard. They are owned by
# scripts/phase0-production-baseline.sh, not the generic ignored-test lane.
NEXTEST_PHASE0_BASELINE_EXCLUSION := not test(/e2e_matrix_phase0_(server_only_production_baseline|external_(production_topologies|edge_server_m1))/)
# ============================================================================
# Environment Setup
# ============================================================================
.PHONY: dev-init
dev-init: setup install-dev-deps
@echo "Initializing development environment..."
@bash scripts/dev/init.sh
.PHONY: setup
setup:
@echo "Setting up Astra development environment..."
@if [ ! -f .env ]; then \
cp .env.example .env; \
echo "✅ Created .env file (please review and customize)"; \
else \
echo "⚠️ .env already exists, skipping"; \
fi
.PHONY: install-dev-deps
install-dev-deps:
@echo "Installing Rust workspace dependencies..."
@cargo fetch --manifest-path Cargo.toml
@$(MAKE) dev-web-deps
@echo "✅ Development dependencies ready"
.PHONY: check-runtime
check-runtime:
@echo "Checking runtime environment..."
@echo ""
@echo "1. Docker:"
@if command -v docker >/dev/null 2>&1; then \
echo " ✅ $$(docker --version)"; \
if docker ps >/dev/null 2>&1; then \
echo " ✅ Docker daemon running"; \
else \
echo " ❌ Docker daemon not running"; \
fi; \
else \
echo " ❌ Not installed"; \
fi
@echo ""
@echo "2. Rust API binary:"
@cargo build -q --manifest-path Cargo.toml -p astra-runtime --release --bin astra-server && echo " ✅ Rust binary build OK"
# ============================================================================
# Dependencies (MatrixOne + Memoria)
# ============================================================================
DEPS_COMPOSE := cd deployment/all-in-one && env UID=$$(id -u) GID=$$(id -g) docker compose -f docker-compose.deps.yml --env-file ../../.env
.PHONY: dev-deps-up
dev-deps-up:
@echo "Starting dependency services (MatrixOne + Memoria)..."
@if [ -d deployment/all-in-one/data ] && [ "$$(stat -c '%u' deployment/all-in-one/data 2>/dev/null || stat -f '%u' deployment/all-in-one/data 2>/dev/null)" != "$$(id -u)" ]; then \
echo "❌ Error: Data directory owned by root"; \
echo " Run: make dev-deps-clean"; \
echo " Or: sudo chown -R $$(id -u):$$(id -g) deployment/all-in-one/data"; \
exit 1; \
fi
@mkdir -p deployment/all-in-one/data/matrixone deployment/all-in-one/data/matrixone/logs deployment/all-in-one/data/logs/memoria
@$(DEPS_COMPOSE) up -d matrixone
@$(MAKE) dev-deps-wait-matrixone
@$(MAKE) dev-deps-ensure-memoria
@echo "✅ Dependency services started (MatrixOne :6001, Memoria :8100)"
.PHONY: dev-deps-down
dev-deps-down:
@echo "Stopping dependency services..."
@$(DEPS_COMPOSE) down
@echo "✅ Dependency services stopped"
.PHONY: dev-deps-clean
dev-deps-clean:
@echo "⚠️ WARNING: This will delete all dependency data!"
@set -e; printf "Are you sure? [y/N] " && read REPLY && \
if [ "$$REPLY" = "y" ] || [ "$$REPLY" = "Y" ]; then \
($(DEPS_COMPOSE) down -v); \
if [ -d deployment/all-in-one/data ]; then \
if [ "$$(stat -c '%u' deployment/all-in-one/data 2>/dev/null || stat -f '%u' deployment/all-in-one/data 2>/dev/null)" != "$$(id -u)" ]; then \
sudo rm -rf deployment/all-in-one/data; \
else \
rm -rf deployment/all-in-one/data; \
fi; \
fi; \
rm -f api_server.pid api_server.log; \
echo "✅ All dependency data removed"; \
else \
echo "Cancelled"; \
fi
.PHONY: dev-deps-status
dev-deps-status:
@echo "Dependency Services Status:"
@echo "==========================="
@$(DEPS_COMPOSE) ps
.PHONY: dev-deps-logs
dev-deps-logs:
@$(DEPS_COMPOSE) logs -f
.PHONY: dev-deps-logs-once
dev-deps-logs-once:
@$(DEPS_COMPOSE) logs --no-color
.PHONY: dev-deps-wait-matrixone
dev-deps-wait-matrixone:
@echo "Waiting for MatrixOne..."
@set -a; [ -f .env ] && . ./.env; set +a; \
debug_port="$${MATRIXONE_DEBUG_HTTP_PORT:-6060}"; \
for i in $$(seq 1 90); do \
if curl --noproxy '*' --connect-timeout 1 --max-time 2 -sf "http://127.0.0.1:$$debug_port/debug/vars" >/dev/null 2>&1; then \
echo "✅ MatrixOne is healthy"; \
break; \
fi; \
if [ "$$i" -eq 90 ]; then \
echo "❌ MatrixOne not ready after 180s"; \
echo " Tip: Check with 'make dev-deps-status' or 'make dev-deps-logs-once'"; \
exit 1; \
fi; \
echo " Waiting for MatrixOne... ($$i/90)"; \
sleep 2; \
done
.PHONY: dev-deps-ensure-memoria
dev-deps-ensure-memoria:
@set -e; set -a; [ -f .env ] && . ./.env; set +a; \
./scripts/dev/ensure-memoria-databases.sh; \
( $(DEPS_COMPOSE) up -d memoria ); \
if [ -n "$${MEMORIA_MASTER_KEY:-}" ] && curl --noproxy '*' --connect-timeout 1 --max-time 2 -sf \
-H "Authorization: Bearer $$MEMORIA_MASTER_KEY" \
"http://127.0.0.1:$${MEMORIA_PORT:-8100}/v1/health/analyze" >/dev/null 2>&1; then \
echo "✅ Memoria already healthy"; \
elif curl --noproxy '*' --connect-timeout 1 --max-time 2 -sf \
"http://127.0.0.1:$${MEMORIA_PORT:-8100}/health" >/dev/null 2>&1; then \
echo "Memoria listener is ready but authenticated storage is not; restarting Memoria..."; \
( $(DEPS_COMPOSE) restart memoria ); \
fi
.PHONY: dev-deps-wait
dev-deps-wait:
@$(MAKE) dev-deps-wait-matrixone
@$(MAKE) dev-deps-ensure-memoria
@set -a; [ -f .env ] && . ./.env; set +a; \
./scripts/dev/check-memoria-owner.sh
@echo "Waiting for Memoria..."
@set -a; [ -f .env ] && . ./.env; set +a; \
if [ -z "$${MEMORIA_MASTER_KEY:-}" ]; then \
echo "❌ MEMORIA_MASTER_KEY is required for an authenticated readiness check"; \
exit 2; \
fi; \
for i in $$(seq 1 60); do \
if curl --noproxy '*' --connect-timeout 1 --max-time 2 -sf \
-H "Authorization: Bearer $$MEMORIA_MASTER_KEY" \
"http://127.0.0.1:$${MEMORIA_PORT:-8100}/v1/health/analyze" >/dev/null 2>&1; then \
echo "✅ Memoria is healthy"; \
echo "✅ Dependency services ready"; \
exit 0; \
fi; \
if [ "$$i" -eq 60 ]; then \
echo "❌ Memoria not ready after 120s"; \
echo " The process-only /health endpoint is not sufficient; authenticated storage readiness failed."; \
echo " Tip: Check with 'make dev-deps-status' or 'make dev-deps-logs-once'"; \
exit 1; \
fi; \
echo " Waiting for Memoria... ($$i/60)"; \
sleep 2; \
done
.PHONY: dev-db-connect
dev-db-connect:
@set -a; [ -f .env ] && . ./.env; set +a; \
scripts/dev/mysql-client.sh
# ============================================================================
# API Server (Source Code Mode)
# ============================================================================
.PHONY: dev-api-start
dev-api-start:
@./scripts/dev/start-api.sh
.PHONY: dev-api-stop
dev-api-stop:
@echo "Stopping API server..."
@./scripts/dev/stop-api.sh
.PHONY: dev-api-start-debug
dev-api-start-debug:
@BUILD_MODE=debug ./scripts/dev/start-api.sh
.PHONY: dev-api-restart dev-api-restart-locked
dev-api-restart:
@./scripts/dev/with-api-lifecycle-lock.sh $(MAKE) --no-print-directory dev-api-restart-locked
dev-api-restart-locked:
@./scripts/dev/require-api-lifecycle-lock.sh
@$(MAKE) --no-print-directory dev-api-stop
@sleep 1
@$(MAKE) --no-print-directory dev-api-start
.PHONY: dev-api-restart-debug dev-api-restart-debug-locked
dev-api-restart-debug:
@./scripts/dev/with-api-lifecycle-lock.sh $(MAKE) --no-print-directory dev-api-restart-debug-locked
dev-api-restart-debug-locked:
@./scripts/dev/require-api-lifecycle-lock.sh
@$(MAKE) --no-print-directory dev-api-stop
@sleep 1
@$(MAKE) --no-print-directory dev-api-start-debug
.PHONY: dev-api-logs
dev-api-logs:
@if [ -f api_server.log ]; then \
tail -f api_server.log; \
else \
echo "❌ api_server.log not found. Is API server running?"; \
fi
.PHONY: dev-api-status
dev-api-status:
@echo "API Server Status:"
@echo "=================="
@if [ -f api_server.pid ] && kill -0 $$(cat api_server.pid) 2>/dev/null; then \
echo " ✅ Running (PID: $$(cat api_server.pid))"; \
API_PORT=$${ASTRA_API_PORT:-$(DEFAULT_API_PORT)}; \
if command -v jq >/dev/null 2>&1; then \
NO_PROXY=localhost curl -s http://localhost:$$API_PORT/health 2>/dev/null | jq . || echo " ⚠️ Health check failed"; \
else \
NO_PROXY=localhost curl -s http://localhost:$$API_PORT/health 2>/dev/null || echo " ⚠️ Health check failed"; \
fi; \
else \
echo " ❌ Not running"; \
fi
# ============================================================================
# Web UI (Next.js Dev Server)
# ============================================================================
.PHONY: dev-sdk-deps
dev-sdk-deps:
@if [ ! -x packages/sdk/node_modules/.bin/tsup ]; then \
echo "Installing local @astra/sdk dependencies..."; \
cd packages/sdk && npm ci --no-audit --no-fund; \
else \
echo "✅ Local @astra/sdk dependencies ready"; \
fi
# The Web app consumes the package's dist entrypoint. Rebuild when source or
# package configuration changed so a restarted Web server cannot silently load
# an older decoder.
@if [ ! -f packages/sdk/dist/index.js ] || [ ! -f packages/sdk/dist/index.d.ts ] || \
[ -n "$$(find packages/sdk/src packages/sdk/package.json packages/sdk/tsconfig.json packages/sdk/tsup.config.ts \
-type f -newer packages/sdk/dist/index.js -print -quit 2>/dev/null)" ]; then \
echo "Building local @astra/sdk package..."; \
cd packages/sdk && npm run build; \
else \
echo "✅ Local @astra/sdk build ready"; \
fi
.PHONY: dev-web-deps
dev-web-deps: dev-sdk-deps
@if [ ! -f web/node_modules/next/dist/bin/next ] || \
[ ! -f web/node_modules/@astra/sdk/package.json ]; then \
echo "Installing web UI dependencies..."; \
cd web && npm ci --no-audit --no-fund; \
else \
echo "✅ Web UI dependencies ready"; \
fi
.PHONY: dev-web-start
dev-web-start: dev-web-deps
@./scripts/dev/start-web.sh
.PHONY: dev-web-stop
dev-web-stop:
@./scripts/dev/stop-web.sh
.PHONY: dev-web-restart
dev-web-restart: dev-web-stop
@sleep 1
@$(MAKE) dev-web-start
.PHONY: dev-web-logs
dev-web-logs:
@LOG_FILE=$${ASTRA_WEB_LOG_FILE:-web_server.log}; \
if [ -f "$$LOG_FILE" ]; then \
tail -f "$$LOG_FILE"; \
else \
echo "❌ $$LOG_FILE not found. Is web UI running?"; \
fi
.PHONY: dev-web-status
dev-web-status:
@PID_FILE=$${ASTRA_WEB_PID_FILE:-web_server.pid}; \
WEB_PORT=$${ASTRA_WEB_PORT:-$${WEB_PORT:-3536}}; \
echo "Web UI Status:"; \
echo "=============="; \
if [ -f "$$PID_FILE" ] && kill -0 $$(cat "$$PID_FILE") 2>/dev/null; then \
PID=$$(cat "$$PID_FILE"); \
RUNNING_PORT=$$(ps -p "$$PID" -o command= 2>/dev/null | sed -nE 's/.*--port[[:space:]]+([0-9]+).*/\1/p' | tail -1); \
if [ -n "$$RUNNING_PORT" ] && [ "$$RUNNING_PORT" != "$$WEB_PORT" ]; then \
echo " ⚠️ Running on different port (PID: $$PID, URL: http://localhost:$$RUNNING_PORT; configured: $$WEB_PORT)"; \
else \
echo " ✅ Running (PID: $$PID, URL: http://localhost:$$WEB_PORT)"; \
NO_PROXY=localhost,127.0.0.1 curl -s --connect-timeout 1 --max-time 2 "http://127.0.0.1:$$WEB_PORT" >/dev/null 2>&1 || echo " ⚠️ HTTP check failed"; \
fi; \
else \
echo " ❌ Not running"; \
fi
# ============================================================================
# Edge Provider (local execution provider for server/web runtime)
# ============================================================================
.PHONY: dev-edge-start
dev-edge-start:
@BUILD_MODE=$${ASTRA_EDGE_BUILD_MODE:-debug} ./scripts/dev/start-edge.sh
.PHONY: dev-edge-stop
dev-edge-stop:
@./scripts/dev/stop-edge.sh
.PHONY: dev-edge-logs
dev-edge-logs:
@LOG_FILE=$${ASTRA_EDGE_LOG_FILE:-$(CURDIR)/astra_edge.log}; \
if [ -f "$$LOG_FILE" ]; then \
tail -f "$$LOG_FILE"; \
else \
echo "❌ $$LOG_FILE not found. Is astra-edge running?"; \
fi
.PHONY: dev-edge-status
dev-edge-status:
@PID_FILE=$${ASTRA_EDGE_PID_FILE:-$(CURDIR)/astra_edge.pid}; \
. ./scripts/dev/edge-process.sh; \
echo "Repo-managed Edge Provider Status:"; \
echo "=================================="; \
if [ -f "$$PID_FILE" ] && edge_process_is_owned "$(CURDIR)" "$$(cat "$$PID_FILE")"; then \
PID=$$(cat "$$PID_FILE"); \
echo " ✅ Running (PID: $$PID)"; \
else \
echo " ❌ Not running"; \
fi
# ============================================================================
# API Server (Docker Mode)
# ============================================================================
.PHONY: dev-api-docker-build
dev-api-docker-build:
@echo "Building API server image..."
@docker build $(DOCKER_PROXY_BUILD_ARGS) $(DOCKER_METADATA_BUILD_ARGS) $(DOCKER_BUILD_ARGS) -t $(IMAGE_NAME):latest .
@echo "✅ Image built"
.PHONY: dev-api-docker-up
dev-api-docker-up:
@echo "Starting API server (Docker mode)..."
@cd deployment/all-in-one && docker compose --env-file ../../.env up -d --no-deps api
@echo "✅ API server container started"
.PHONY: dev-api-docker-down
dev-api-docker-down:
@echo "Stopping API server containers..."
@cd deployment/all-in-one && docker compose --env-file ../../.env stop api && docker compose --env-file ../../.env rm -f api
@echo "✅ API server containers stopped"
.PHONY: dev-api-docker-logs
dev-api-docker-logs:
@cd deployment/all-in-one && docker compose --env-file ../../.env logs -f api
.PHONY: dev-api-docker-scale
dev-api-docker-scale:
@if [ -z "$(REPLICAS)" ]; then \
echo "❌ Usage: make dev-api-docker-scale REPLICAS=N"; \
exit 1; \
fi
@echo "Scaling API server to $(REPLICAS) replicas..."
@cd deployment/all-in-one && docker compose --env-file ../../.env up -d --no-deps --scale api=$(REPLICAS) api
@echo "✅ Scaled to $(REPLICAS) replicas"
.PHONY: release-prepare
release-prepare:
@if [ -z "$(VERSION)" ]; then \
echo "❌ VERSION is required, for example: make release-prepare VERSION=0.2.0"; \
exit 1; \
fi
@scripts/prepare-release-version.py "$(VERSION)"
.PHONY: release-check
release-check:
@if [ -z "$(VERSION)" ]; then \
echo "❌ VERSION is required, for example: make release-check VERSION=0.1.0"; \
exit 1; \
fi
@scripts/validate-release-version.sh "$(VERSION)"
@python3 scripts/ci/validate_repository.py
@echo "✅ Release metadata, installer, artifacts, and workflow contracts are consistent"
@echo " Commit and merge the reviewed version changes, then run make release-publish VERSION=$(VERSION) from main."
.PHONY: release-publish
release-publish:
@if [ -z "$(VERSION)" ]; then \
echo "❌ VERSION is required, for example: make release-publish VERSION=0.2.0"; \
exit 1; \
fi
@scripts/validate-release-version.sh "$(VERSION)"
@command -v gh >/dev/null 2>&1 || { echo "❌ GitHub CLI (gh) is required to start a release"; exit 1; }
@gh auth status -h github.com >/dev/null 2>&1 || { echo "❌ Authenticate gh with permission to dispatch repository workflows"; exit 1; }
@default_branch="$$(gh repo view matrixorigin/Astra --json defaultBranchRef --jq '.defaultBranchRef.name')"; \
if [ "$$(git branch --show-current)" != "$$default_branch" ]; then \
echo "❌ Run release-publish from $$default_branch after the release PR merges"; \
exit 1; \
fi; \
if ! git diff --quiet || ! git diff --cached --quiet; then \
echo "❌ Commit or stash local changes before starting a release"; \
exit 1; \
fi; \
git fetch origin "$$default_branch"; \
if [ "$$(git rev-parse HEAD)" != "$$(git rev-parse "origin/$$default_branch")" ]; then \
echo "❌ Local $$default_branch is not at origin/$$default_branch; fast-forward it before starting a release"; \
exit 1; \
fi
@gh workflow run release.yml --repo matrixorigin/Astra --ref main \
-f version="$(VERSION)" -f recover_existing_tag=false
@echo "✅ Release Astra started for $(VERSION). Candidate builds run before the protected release approval."
# ============================================================================
# Compose Stack Deployment
# ============================================================================
.PHONY: stack-env
stack-env:
@set -eu; \
tmp=""; value_file=""; \
cleanup_stack_env() { rm -f "$${tmp:-}" "$${value_file:-}"; }; \
trap cleanup_stack_env EXIT HUP INT TERM; \
if [ -f "$(STACK_ENV)" ]; then \
echo "✅ $(STACK_ENV) already exists"; \
else \
cp $(STACK_DIR)/.env.example $(STACK_ENV); \
echo "✅ Created $(STACK_ENV)"; \
fi; \
chmod 600 "$(STACK_ENV)"; \
. scripts/lib/env_file.sh; \
set_env_value() { \
key="$$1"; \
value="$$2"; \
tmp="$$(mktemp)"; \
value_file="$$(mktemp)"; \
chmod 600 "$$tmp" "$$value_file"; \
printf '%s' "$$value" > "$$value_file"; \
ASTRA_STACK_VALUE_FILE="$$value_file" awk -v key="$$key" ' \
BEGIN { \
value_file = ENVIRON["ASTRA_STACK_VALUE_FILE"]; \
if ((getline value < value_file) < 0) exit 1; \
close(value_file); \
done = 0; \
} \
{ \
line = $$0; \
sub(/^[[:space:]]*/, "", line); \
if (line ~ "^" key "[[:space:]]*=") { \
print key "=" value; \
done = 1; \
next; \
} \
print; \
} \
END { if (!done) print key "=" value } \
' "$(STACK_ENV)" > "$$tmp"; \
mv "$$tmp" "$(STACK_ENV)"; \
rm -f "$$value_file"; \
tmp=""; value_file=""; \
}; \
ensure_secret() { \
key="$$1"; \
if env_file_has_configured_value "$(STACK_ENV)" "$$key"; then \
echo "✅ $$key already configured"; \
return 0; \
fi; \
if ! command -v openssl >/dev/null 2>&1; then \
echo "❌ openssl is required to generate missing secret $$key"; \
exit 1; \
fi; \
value="$$(openssl rand -hex 32)"; \
set_env_value "$$key" "$$value"; \
echo "✅ Generated $$key"; \
}; \
ensure_secret ASTRA_JWT_SECRET; \
ensure_secret ASTRA_TOKEN_ENCRYPTION_KEY; \
ensure_secret ASTRA_RUNTIME_ROOT_SECRET; \
ensure_secret MEMORIA_MASTER_KEY; \
embedding_provider="$$(env_file_read "$(STACK_ENV)" MEMORIA_EMBEDDING_PROVIDER 2>/dev/null || true)"; \
embedding_provider="$$(printf '%s' "$$embedding_provider" | tr '[:upper:]' '[:lower:]')"; \
embedding_url="$$(env_file_read "$(STACK_ENV)" MEMORIA_EMBEDDING_BASE_URL 2>/dev/null || true)"; \
if [ "$$embedding_provider" = mock ]; then \
echo "✅ Mock embeddings configured (local evaluation)"; \
elif [ -n "$$embedding_url" ]; then \
echo "✅ Embedding endpoint configured (run make stack-setup to test it)"; \
else \
echo "Configure a real embedding endpoint, or use make stack-setup for guided configuration."; \
fi; \
trap - EXIT HUP INT TERM
.PHONY: stack-check-env
stack-check-env:
@if [ ! -f "$(STACK_ENV)" ]; then \
echo "❌ Missing $(STACK_ENV)"; \
echo " Run: make stack-env"; \
exit 1; \
fi
@. scripts/lib/env_file.sh; \
embedding_provider="$$(env_resolve_value "$(STACK_ENV)" MEMORIA_EMBEDDING_PROVIDER 2>/dev/null || true)"; \
embedding_provider="$$(printf '%s' "$$embedding_provider" | tr '[:upper:]' '[:lower:]')"; \
required="$(STACK_SECRET_ENV)"; \
if [ "$${embedding_provider:-openai}" != "mock" ]; then \
required="$$required $(STACK_EMBEDDING_ENV)"; \
fi; \
missing=""; \
for key in $$required; do \
value="$$(env_resolve_value "$(STACK_ENV)" "$$key" 2>/dev/null || true)"; \
if env_value_is_placeholder "$$value"; then \
missing="$$missing $$key"; \
fi; \
done; \
if [ -n "$$missing" ]; then \
echo "❌ Missing or insecure required config in $(STACK_ENV):$$missing"; \
echo " Run make stack-env to generate secrets. For non-mock embeddings, fill the base URL and any provider-required API key."; \
exit 1; \
fi
.PHONY: stack-config
stack-config: stack-check-env
@$(STACK_COMPOSE) config --quiet
@echo "✅ Compose stack config OK"
.PHONY: stack-start
stack-start: stack-env
@$(MAKE) stack-up
@$(MAKE) stack-verify
@echo ""
@echo "✅ Astra local stack is ready"
@echo " Next: make stack-setup STACK_ENV=\"$(STACK_ENV)\" (resume guided status and optional chat setup)"
@echo " Try: astra chat -m \"Explain what you can do in this deployment\""
.PHONY: stack-up
stack-up: stack-config
@echo "Starting compose stack..."
@if ! ( \
set -e; \
( $(STACK_COMPOSE) up -d $(STACK_RECREATE_ARGS) --wait --wait-timeout 180 matrixone ) || exit 1; \
set -a; . "$(STACK_ENV)" || exit 1; set +a; \
scripts/dev/ensure-memoria-databases.sh || exit 1; \
( $(STACK_COMPOSE) up -d $(STACK_RECREATE_ARGS) --wait --wait-timeout 180 memoria api ) || exit 1; \
); then \
echo ""; \
echo "❌ Compose stack did not become healthy."; \
echo ""; \
echo "Service status:"; \
( $(STACK_COMPOSE) ps -a ) || true; \
echo ""; \
echo "Recent service logs:"; \
failed_services="$$( \
for state in exited dead restarting unhealthy; do \
( $(STACK_COMPOSE) ps -a --status "$$state" --services ) 2>/dev/null || true; \
done | sort -u | tr '\n' ' ' \
)"; \
if [ -n "$$failed_services" ]; then \
( $(STACK_COMPOSE) logs --no-color --tail=80 $$failed_services ) || true; \
else \
echo "No failed container was identified; run 'make stack-logs STACK_ENV=\"$(STACK_ENV)\"' for full logs."; \
fi; \
echo ""; \
echo "Fix the first reported error, then rerun 'make stack-up STACK_ENV=\"$(STACK_ENV)\"'."; \
echo "The partial stack is left running so it can be inspected; use 'make stack-down STACK_ENV=\"$(STACK_ENV)\"' to stop it."; \
exit 1; \
fi
@echo "✅ Compose stack started"
@. scripts/lib/env_file.sh; \
API_PORT=$$(env_resolve_value "$(STACK_ENV)" ASTRA_API_PORT 2>/dev/null || true); \
BIND_ADDRESS=$$(env_resolve_value "$(STACK_ENV)" ASTRA_BIND_ADDRESS 2>/dev/null || true); \
API_HOST=$$(env_http_host_from_bind "$$BIND_ADDRESS"); \
echo " API: http://$$API_HOST:$${API_PORT:-$(DEFAULT_API_PORT)}"
.PHONY: stack-setup
stack-setup:
@scripts/setup/stack-setup.sh
.PHONY: stack-up-server-only
stack-up-server-only:
@echo "Stopping this checkout's repo-managed astra-edge provider..."
@$(MAKE) dev-edge-stop
@$(MAKE) stack-up
@echo "✅ Server-only stack ready (this checkout did not connect a User Runner)"
.PHONY: stack-up-server-edge
stack-up-server-edge: stack-up-server-only
@. scripts/lib/env_file.sh; \
API_PORT=$$([ -f "$(STACK_ENV)" ] && env_resolve_value "$(STACK_ENV)" ASTRA_API_PORT 2>/dev/null || true); \
BIND_ADDRESS=$$([ -f "$(STACK_ENV)" ] && env_resolve_value "$(STACK_ENV)" ASTRA_BIND_ADDRESS 2>/dev/null || true); \
API_HOST=$$(env_http_host_from_bind "$$BIND_ADDRESS"); \
ASTRA_EDGE_SERVER_URL="http://$$API_HOST:$${API_PORT:-$(DEFAULT_API_PORT)}" $(MAKE) dev-edge-start
@echo "✅ Server + edge stack ready"
.PHONY: stack-down
stack-down:
@$(STACK_COMPOSE) down
@echo "✅ Compose stack stopped"
.PHONY: stack-clean
stack-clean:
@$(STACK_COMPOSE) down -v
@echo "✅ Compose stack stopped and volumes removed"
.PHONY: stack-status
stack-status: stack-check-env
@$(STACK_COMPOSE) ps
.PHONY: stack-verify
stack-verify: stack-check-env
@scripts/ops/verify_all_in_one.sh "$(STACK_ENV)"
.PHONY: stack-logs
stack-logs: stack-check-env
@$(STACK_COMPOSE) logs -f $(SERVICE)
# ============================================================================
# Composite Commands
# ============================================================================
.PHONY: dev-start-server-only
dev-start-server-only:
@echo "Starting server-only development environment..."
@$(MAKE) dev-edge-stop
@$(MAKE) dev-deps-up
@$(MAKE) dev-deps-wait
@$(MAKE) dev-api-start-debug
@$(MAKE) dev-web-start
@echo ""
@echo "✅ Server-only development environment started!"
@echo " API: http://localhost:$${ASTRA_API_PORT:-$(DEFAULT_API_PORT)}"
@echo " Web: http://localhost:$${ASTRA_WEB_PORT:-$${WEB_PORT:-3536}}"
@echo " Edge provider: not connected"
@echo ""
@echo "Next steps:"
@echo " make build-cli-debug"
@echo " ./target/debug/astra admin register # first database only"
@echo " ./target/debug/astra admin model load .models.yaml --update-existing"
@echo " ./target/debug/astra"
.PHONY: dev-start-server-edge
dev-start-server-edge:
@$(MAKE) dev-start-server-only
@$(MAKE) dev-edge-start
@echo ""
@echo "✅ Server + edge development environment started!"
@echo " API: http://localhost:$${ASTRA_API_PORT:-$(DEFAULT_API_PORT)}"
@echo " Web: http://localhost:$${ASTRA_WEB_PORT:-$${WEB_PORT:-3536}}"
@echo " Edge workspace: $${ASTRA_EDGE_WORKSPACE_DIR:-$$(pwd)}"
.PHONY: dev-start
dev-start: dev-start-server-only
.PHONY: dev-start-docker
# Docker API mode reuses the dev dependency stack; dev-api-docker-up starts only api.
dev-start-docker: dev-deps-up dev-deps-wait dev-api-docker-up
@sleep 3
@echo ""
@echo "✅ Development environment ready (Docker mode)!"
@echo " API: http://localhost:$${ASTRA_API_PORT:-$(DEFAULT_API_PORT)}"
.PHONY: dev-stop
dev-stop: dev-edge-stop dev-web-stop dev-api-stop dev-deps-down
@echo "✅ All services stopped"
.PHONY: dev-restart
dev-restart: dev-stop
@sleep 1
@$(MAKE) dev-start
.PHONY: dev-status
dev-status:
@echo ""
@$(MAKE) dev-deps-status
@echo ""
@$(MAKE) dev-api-status
@echo ""
@$(MAKE) dev-web-status
@echo ""
@$(MAKE) dev-edge-status
.PHONY: dev-clean
dev-clean: dev-edge-stop dev-web-stop dev-api-stop dev-deps-clean
@echo "✅ Development environment cleaned"
.PHONY: dev-reset
dev-reset: dev-clean
@$(MAKE) dev-init
@echo "✅ Development environment reset"
.PHONY: dev-setup-demo
dev-setup-demo:
@bash scripts/setup/demo-init.sh
# A freshly recreated database must run the complete schema bootstrap before
# /health can answer. MatrixOne can take several minutes on a cold schema;
# keep the ordinary API-start timeout unchanged and give only this destructive
# reseed flow the longer readiness window.
.PHONY: dev-seed dev-seed-locked
dev-seed:
@echo "⚠️ This will reset the database and reseed admin + models."
@printf "Are you sure? [y/N] "; read REPLY; \
[ "$$REPLY" = "y" ] || [ "$$REPLY" = "Y" ] || { echo "Cancelled"; exit 1; }
@./scripts/dev/with-api-lifecycle-lock.sh $(MAKE) --no-print-directory dev-seed-locked
dev-seed-locked:
@./scripts/dev/require-api-lifecycle-lock.sh
@echo "Stopping API server before dropping the database..."
@$(MAKE) dev-api-stop
@$(MAKE) dev-deps-wait
@sleep 2
@set -a; [ -f .env ] && . ./.env; set +a; \
DB_NAME=$${ASTRA_DATABASE:-astra_runtime}; \
SQL="DROP DATABASE IF EXISTS $$DB_NAME; CREATE DATABASE $$DB_NAME;"; \
scripts/dev/mysql-client.sh -e "$$SQL"
@API_START_TIMEOUT_SECONDS=$${API_START_TIMEOUT_SECONDS:-600} $(MAKE) dev-api-restart-debug-locked build-cli-debug
@sleep 2
@echo "Registering admin (admin@mo.com)..."
@NO_PROXY=localhost ./target/debug/astra admin register \
--username admin --password 11111111 --email admin@mo.com
@echo "Logging in as admin..."
@NO_PROXY=localhost ./target/debug/astra admin login \
--username admin --password 11111111
@echo "Loading models from .models.yaml..."
@NO_PROXY=localhost ./target/debug/astra admin model load .models.yaml --update-existing
@echo ""
@echo "✅ Seed complete — admin@mo.com / 11111111"
# ============================================================================
# Build
# ============================================================================
.PHONY: build
build: build-release
.PHONY: build-release
build-release: sweep
@echo "Building Rust workspace (release)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG) --release
@echo "✅ Release artifacts: $(RUST_RELEASE_BIN_DIR)/"
.PHONY: build-cli
build-cli: build-cli-release
.PHONY: build-cli-release
build-cli-release: sweep
@echo "Building astra CLI (release)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG) -p astra-cli --release --bin astra $(CLI_RELEASE_FLAGS)
@echo "Binaries:"
@for bin in $(CLI_BINS); do echo " $(RUST_RELEASE_BIN_DIR)/$$bin"; done
.PHONY: build-server
build-server: build-server-release
.PHONY: build-server-release
build-server-release: sweep
@echo "Building astra-server (release)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG) $(API_SHELL_PKG) --release --bin $(API_SERVER_BIN)
@echo "Binary: $(RUST_RELEASE_BIN_DIR)/$(API_SERVER_BIN)"
.PHONY: build-edge
build-edge: build-edge-release
.PHONY: build-edge-release
build-edge-release: sweep
@echo "Building astra-edge (release)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG) -p astra-edge --release --bin $(EDGE_BIN)
@echo "Binary: $(RUST_RELEASE_BIN_DIR)/$(EDGE_BIN)"
# --- Debug builds (no sweep, no --release => fast incremental) ---
.PHONY: build-debug
build-debug:
@echo "Building Rust workspace (debug)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG)
@echo "✅ Debug artifacts: $(RUST_DEBUG_BIN_DIR)/"
.PHONY: build-cli-debug
build-cli-debug:
@echo "Building astra CLI (debug)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG) -p astra-cli --bin astra
@echo "Binaries:"
@for bin in $(CLI_BINS); do echo " $(RUST_DEBUG_BIN_DIR)/$$bin"; done
.PHONY: build-server-debug
build-server-debug:
@echo "Building astra-server (debug)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG) $(API_SHELL_PKG) --bin $(API_SERVER_BIN)
@echo "Binary: $(RUST_DEBUG_BIN_DIR)/$(API_SERVER_BIN)"
.PHONY: build-edge-debug
build-edge-debug:
@echo "Building astra-edge (debug)..."
@$(CARGO) build $(CARGO_MANIFEST_FLAG) -p astra-edge --bin $(EDGE_BIN)
@echo "Binary: $(RUST_DEBUG_BIN_DIR)/$(EDGE_BIN)"
# ============================================================================