ggen 2.7.1

ggen is a deterministic, language-agnostic code generation framework that treats software artifacts as projections of knowledge graphs.
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
# GitHub API configuration
[env]
GITHUB_REPO = "seanchatmangpt/ggen"
GITHUB_API = "https://api.github.com"
GITHUB_PAGES_URL = "https://seanchatmangpt.github.io/ggen"
# Act configuration for local GitHub Actions testing
ACT_CONTAINER_ARCH = "linux/amd64"
ACT_PLATFORM = "ubuntu-latest=catthehacker/ubuntu:act-latest"
ACT_MEMORY = "2g"
ACT_CPUS = "2"

# Verify timeout command exists before running any task
[tasks.timeout-check]
description = "Verify timeout command exists (required for all tasks)"
workspace = false
command = "command"
args = ["-v", "timeout"]
ignore_errors = false

# Core development tasks - with timeout wrappers
[tasks.check]
description = "Check code without building (quick feedback, 5s timeout)"
workspace = false
command = "timeout"
args = ["5s", "cargo", "check"]

# Pre-push check with longer timeout for lock contention scenarios
[tasks.check-pre-push]
description = "Check code for pre-push hook (30s timeout for lock contention)"
workspace = false
command = "timeout"
args = ["30s", "cargo", "check"]

[tasks.build]
description = "Build in debug mode"
command = "timeout"
args = ["10s", "cargo", "build", "-p", "ggen-cli-lib", "--bin", "ggen"]

[tasks.build-release]
description = "Build in release mode"
command = "timeout"
args = [
  "30s",
  "cargo",
  "build",
  "--release",
  "-p",
  "ggen-cli-lib",
  "--bin",
  "ggen",
]
run_task = { name = "verify-binary" }

[tasks.verify-binary]
description = "Verify ggen binary was built"
workspace = false
script_runner = "@shell"
script = '''
#!/bin/bash
if [ -f "target/release/ggen" ]; then
    echo "✅ Binary found: target/release/ggen"
    ls -lh target/release/ggen
elif [ -f "target/debug/ggen" ]; then
    echo "✅ Binary found: target/debug/ggen"
    ls -lh target/debug/ggen
else
    echo "❌ Binary not found in expected locations"
    exit 1
fi
'''

[tasks.clean]
description = "Clean build artifacts"
command = "timeout"
args = ["5s", "cargo", "clean"]

[tasks.fmt]
description = "Format code"
command = "timeout"
args = ["5s", "cargo", "fmt", "--all"]

[tasks.lint]
description = "Run clippy with strict settings"
workspace = false
command = "timeout"
args = [
  "5s",
  "cargo",
  "clippy",
  "--all-targets",
  "--all-features",
  "--",
  "-D",
  "warnings",
]

[tasks.pre-commit]
description = "Run pre-commit validation checks (format, lint, test, hooks, docs)"
workspace = false
dependencies = [
  "timeout-check",
  "fmt",
  "lint",
  "test",
  "test-doc",
  "validate-docs",
  "docs-check",
]
script_runner = "@shell"
script = '''
# Run git hook validation if available
if [ -f .git/hooks/pre-commit ]; then
  echo "🔍 Running pre-commit hook validation..."
  .git/hooks/pre-commit || {
    echo "❌ Pre-commit hook validation failed"
    echo "   Fix all issues before committing"
    exit 1
  }
  echo "✅ Pre-commit hook validation passed"
else
  echo "⚠️  No pre-commit hook found, skipping hook validation"
  echo "   Run: scripts/install-git-hooks.sh to install hooks"
fi
'''

[tasks.test]
description = "Run all tests"
command = "timeout"
args = ["30s", "cargo", "test", "--workspace", "--no-default-features"]
workspace = false

[tasks.test-unit]
description = "Unit tests only"
workspace = false
command = "timeout"
args = ["10s", "cargo", "test", "--workspace", "--lib"]

[tasks.test-integration]
description = "Integration tests only"
workspace = false
command = "timeout"
args = ["30s", "cargo", "test", "--test"]

[tasks.test-ignored]
description = "Run ignored integration tests (long-running, requires Docker)"
workspace = false
command = "timeout"
args = [
  "20m",
  "cargo",
  "test",
  "--test",
  "marketplace_nextjs_ontology_e2e",
  "--",
  "--ignored",
  "--nocapture",
]

[tasks.test-doc]
description = "Run doctests (CRITICAL: Verifies all doctests compile and run)"
workspace = false
command = "timeout"
args = ["60s", "cargo", "test", "--doc", "--workspace"]

[tasks.test-timings]
description = "Run tests and generate timing report to identify slow tests"
workspace = false
command = "timeout"
args = [
  "30s",
  "cargo",
  "test",
  "--workspace",
  "--",
  "--test-threads",
  "1",
  "--nocapture",
  "--report-time",
]

[tasks.test-single-threaded]
description = "Run tests in single-threaded mode for deterministic execution"
workspace = false
command = "timeout"
args = ["30s", "cargo", "test", "--workspace", "--", "--test-threads", "1"]
env = { "RUST_TEST_THREADS" = "1" }

[tasks.deterministic]
description = "Run deterministic tests with fixed seeds and single-threaded execution"
workspace = false
command = "timeout"
args = ["30s", "cargo", "test", "--workspace", "--", "--test-threads", "1"]
env = { "RUST_TEST_THREADS" = "1", "RNG_SEED" = "42" }

[tasks.validate-outputs]
description = "Validate deterministic outputs (runs deterministic tests)"
workspace = false
dependencies = ["deterministic"]

[tasks.validate-rdf]
description = "Validate RDF graphs, SPARQL queries, and ensure deterministic processing"
workspace = false
dependencies = ["timeout-check"]
script_runner = "@shell"
script = '''
#!/bin/bash
set -e

echo "🔍 Validating RDF graphs and SPARQL queries..."
echo ""

# Run RDF validation tests
echo "📋 Running RDF validation tests..."
timeout 30s cargo test --package ggen-core --lib rdf::validation -- --nocapture || {
    echo "❌ RDF validation tests failed"
    exit 1
}

# Run graph validation tests
echo ""
echo "📋 Running graph validation tests..."
timeout 30s cargo test --package ggen-core --lib graph -- --nocapture || {
    echo "❌ Graph validation tests failed"
    exit 1
}

# Run RDF integration tests if they exist
if timeout 5s cargo test --test rdf_validation_integration --no-run 2>/dev/null; then
    echo ""
    echo "📋 Running RDF integration tests..."
    timeout 30s cargo test --test rdf_validation_integration -- --nocapture || {
        echo "❌ RDF integration tests failed"
        exit 1
    }
fi

# Run graph E2E tests if they exist
if timeout 5s cargo test --test integration_graph_e2e --no-run 2>/dev/null; then
    echo ""
    echo "📋 Running graph E2E tests..."
    timeout 30s cargo test --test integration_graph_e2e graph -- --nocapture || {
        echo "⚠️  Some graph E2E tests failed (non-critical)"
    }
fi

echo ""
echo "✅ RDF validation complete!"
echo ""
echo "Validation checklist:"
echo "  ✓ RDF graph syntax validation"
echo "  ✓ Graph consistency checks"
echo "  ✓ SPARQL query syntax validation"
echo "  ✓ Deterministic processing verification"
'''

[tasks.test-testcontainers]
description = "Run testcontainers production readiness validation tests"
command = "cargo"
args = ["test", "--package", "ggen-cli-lib", "--test", "integration"]
env = { "RUST_LOG" = "info" }

[tasks.test-cleanroom]
description = "Run cleanroom production tests with testcontainers"
workspace = false
command = "cargo"
args = [
  "test",
  "--package",
  "ggen-cli-lib",
  "--test",
  "integration_tests",
  "--",
  "testcontainers_cleanroom",
]
env = { "RUST_LOG" = "info" }

[tasks.test-cleanroom-crate]
description = "Run tests for the cleanroom crate"
workspace = false
command = "cargo"
args = ["test", "--package", "cleanroom"]
env = { "RUST_LOG" = "info" }

[tasks.lint-cleanroom]
description = "Run clippy on cleanroom crate"
workspace = false
command = "cargo"
args = ["clippy", "--package", "cleanroom", "--", "-D", "warnings"]

[tasks.cleanroom-validate]
description = "Validate cleanroom implementation and integration"
workspace = false
dependencies = ["test-cleanroom-crate", "test-cleanroom", "lint-cleanroom"]

[tasks.cleanroom-slo-check]
description = "Check cleanroom performance SLOs"
workspace = false
command = "cargo"
args = [
  "test",
  "--package",
  "cleanroom",
  "--release",
  "--",
  "--nocapture",
  "slo",
]
env = { "RUST_LOG" = "info" }

[tasks.cleanroom-profile]
description = "Profile cleanroom performance"
workspace = false
command = "cargo"
args = ["flamegraph", "--package", "cleanroom", "--bin", "cleanroom-bench"]

[tasks.production-readiness]
description = "Comprehensive production readiness validation with testcontainers"
workspace = false
dependencies = [
  "test-testcontainers",
  "test-cleanroom",
  "cleanroom-validate",
  "test-unit",
  "test-integration",
  "lint",
  "build-release",
]

[tasks.production-readiness-script]
description = "Run production readiness validation script"
workspace = false
command = "./scripts/production-readiness-validation.sh"
args = ["--full"]

[tasks.test-live]
description = "Run tests with live LLM integrations (requires API keys)"
command = "cargo"
args = ["test", "--features", "live-llm-tests,all-integrations"]

[tasks.test-ollama]
description = "Run Ollama integration tests (requires Ollama running)"
command = "cargo"
args = [
  "test",
  "--features",
  "ollama-integration",
  "--test",
  "ollama_integration",
  "-p",
  "ggen-ai",
]

[tasks.test-openai]
description = "Run OpenAI integration tests (requires OPENAI_API_KEY)"
command = "cargo"
args = ["test", "--features", "openai-integration,live-llm-tests"]
env = { "RUST_LOG" = "info" }

[tasks.test-anthropic]
description = "Run Anthropic integration tests (requires ANTHROPIC_API_KEY)"
command = "cargo"
args = ["test", "--features", "anthropic-integration,live-llm-tests"]
env = { "RUST_LOG" = "info" }

[tasks.test-ollama-performance]
description = "Run Ollama performance and stress tests"
workspace = false
command = "cargo"
args = [
  "test",
  "--package",
  "ggen-ai",
  "--features",
  "ollama-integration",
  "--test",
  "ollama_performance",
]

[tasks.test-ollama-resilience]
description = "Run Ollama resilience and error recovery tests"
workspace = false
command = "cargo"
args = [
  "test",
  "--package",
  "ggen-ai",
  "--features",
  "ollama-integration",
  "--test",
  "ollama_resilience",
]

[tasks.test-ollama-all]
description = "Run all Ollama integration tests (integration, performance, resilience)"
workspace = false
dependencies = [
  "test-ollama",
  "test-ollama-performance",
  "test-ollama-resilience",
]

[tasks.validate-ollama]
description = "Validate Ollama integration (checks service, model, and runs tests)"
workspace = false
command = "./scripts/validate-ollama.sh"

# GitHub Actions local testing with act (80/20: minimal essential tasks)
[tasks.act]
description = "Run a GitHub Actions workflow locally with act (usage: cargo make act WORKFLOW=ci.yml JOB=fmt). Examples: 'cargo make act WORKFLOW=lint.yml JOB=lint', 'cargo make act WORKFLOW=ci.yml' (runs all jobs)"
workspace = false
script_runner = "@shell"
script = '''
#!/bin/bash
set -e

WORKFLOW="${WORKFLOW:-ci.yml}"
JOB="${JOB:-}"

if [ -z "$JOB" ]; then
  echo "Running workflow: $WORKFLOW (all jobs)"
  act \
    --container-architecture "${ACT_CONTAINER_ARCH}" \
    --platform "${ACT_PLATFORM}" \
    -W ".github/workflows/${WORKFLOW}"
else
  echo "Running workflow: $WORKFLOW, job: $JOB"
  act \
    --container-architecture "${ACT_CONTAINER_ARCH}" \
    --platform "${ACT_PLATFORM}" \
    -W ".github/workflows/${WORKFLOW}" \
    -j "${JOB}"
fi
'''

[tasks.act-list]
description = "List available GitHub Actions workflows"
workspace = false
command = "act"
args = ["--list"]

[tasks.act-validate]
description = "Validate all workflows can be parsed by act (dry-run)"
workspace = false
script_runner = "@shell"
script = '''
#!/bin/bash
set -e

echo "🔍 Validating all GitHub Actions workflows with act..."
echo ""

ERRORS=0
WORKFLOWS=(
  "ci.yml"
  "test.yml"
  "build.yml"
  "lint.yml"
  "marketplace-test.yml"
  "marketplace.yml"
  "security-audit.yml"
  "quality-gates.yml"
  "london-tdd-tests.yml"
  "deploy-docs.yml"
  "release.yml"
  "homebrew-release.yml"
)

for workflow in "${WORKFLOWS[@]}"; do
  if [ -f ".github/workflows/${workflow}" ]; then
    echo "📋 Validating ${workflow}..."
    if act --dryrun -W ".github/workflows/${workflow}" > /dev/null 2>&1; then
      echo "  ✅ ${workflow} is valid"
    else
      echo "  ❌ ${workflow} has errors"
      ERRORS=$((ERRORS + 1))
    fi
  else
    echo "  ⚠️  ${workflow} not found"
  fi
done

echo ""
if [ $ERRORS -eq 0 ]; then
  echo "✅ All workflows validated successfully"
  exit 0
else
  echo "❌ Found ${ERRORS} workflow(s) with errors"
  exit 1
fi
'''

[tasks.act-status]
description = "Check act installation and Docker status"
workspace = false
script = '''
#!/bin/bash
set -e

echo "🔍 Checking act installation..."
if command -v act &> /dev/null; then
    echo "✅ act is installed"
    act --version
else
    echo "❌ act is not installed"
    echo ""
    echo "📦 Installation instructions:"
    echo "  macOS: brew install act"
    echo "  Linux: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash"
    echo "  Or: https://github.com/nektos/act/releases"
    exit 1
fi

echo ""
echo "🐳 Checking Docker status..."
if docker ps > /dev/null 2>&1; then
    echo "✅ Docker daemon is running"
    docker --version
    echo ""
    echo "📊 Docker resource usage:"
    docker system df
else
    echo "❌ Docker daemon is not running"
    echo "   Start Docker Desktop or Docker daemon"
    exit 1
fi
'''

[tasks.act-cleanup]
description = "Clean up act containers and images"
workspace = false
script = '''
echo "🧹 Cleaning up act containers..."
docker ps -a --filter "label=act" --format "table {{.ID}}\t{{.Status}}\t{{.Names}}" | grep act || true
docker container prune -f --filter "label=act" || true
docker image prune -f --filter "label=act" || true
echo "✅ Act cleanup complete"
'''

[tasks.test-bdd]
description = "Run BDD tests (Cucumber feature tests)"
workspace = false
command = "cargo"
args = ["test", "--test", "bdd"]

[tasks.test-bdd-feature]
description = "Run specific BDD feature (usage: cargo make test-bdd-feature FEATURE=graph)"
workspace = false
command = "cargo"
args = ["test", "--test", "bdd", "test_${FEATURE}_features"]

[tasks.test-bdd-verbose]
description = "Run BDD tests with verbose output"
workspace = false
command = "cargo"
args = ["test", "--test", "bdd", "--", "--nocapture"]

[tasks.audit]
description = "Security audit"
command = "cargo"
args = ["audit"]
workspace = false

[tasks.audit-outdated]
description = "Check for outdated dependencies"
command = "cargo"
args = ["outdated"]
workspace = false

[tasks.audit-unused]
description = "Check for unused dependencies (requires nightly)"
command = "cargo"
args = ["+nightly", "udeps"]
workspace = false

[tasks.check-dead-code]
description = "Check for dead code and unused items (waste detection)"
workspace = false
command = "timeout"
args = [
  "10s",
  "cargo",
  "clippy",
  "--workspace",
  "--all-targets",
  "--",
  "-W",
  "dead_code",
  "-W",
  "unused_imports",
  "-W",
  "unused_variables",
]

[tasks.check-unused-features]
description = "Check for unused feature flags (waste detection)"
workspace = false
command = "timeout"
args = ["10s", "cargo", "check", "--workspace", "--all-features"]
script_runner = "@shell"
script = '''
#!/bin/bash
# Check for feature flags that might be unused
echo "Checking for potentially unused features..."
echo "Review Cargo.toml files for features that are never enabled"
echo "Run: grep -r 'feature.*=' crates/*/Cargo.toml | grep -v 'default'"
'''

[tasks.validate-examples]
description = "Validate all examples compile (waste prevention)"
workspace = false
command = "timeout"
args = ["30s", "cargo", "check", "--workspace", "--examples"]

[tasks.audit-deny]
description = "Comprehensive dependency audit with cargo-deny"
command = "cargo"
args = ["deny", "check"]
workspace = false

[tasks.audit-all]
description = "Run all dependency audits"
dependencies = ["audit", "audit-outdated", "audit-deny"]
workspace = false

[tasks.format]
description = "Format code"
command = "cargo"
args = ["fmt", "--all"]

[tasks.clippy-ci-flow]
description = "Run clippy with CI-friendly settings"
command = "cargo"
args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"]

[tasks.test-verbose]
description = "Run tests with verbose output"
workspace = false
command = "cargo"
args = ["test", "--workspace", "--", "--nocapture"]

[tasks.test-proptest]
description = "Run property-based tests with proptest"
command = "cargo"
args = ["test", "--workspace", "--features", "proptest", "--", "--nocapture"]

[tasks.test-proptest-single]
description = "Run property-based tests for a single package"
command = "cargo"
args = [
  "test",
  "--package",
  "${PACKAGE}",
  "--features",
  "proptest",
  "--",
  "--nocapture",
]

[tasks.test-proptest-parallel]
description = "Run property-based tests in parallel"
command = "cargo"
args = [
  "test",
  "--workspace",
  "--features",
  "proptest",
  "--",
  "--test-threads",
  "4",
  "--nocapture",
]

# mdbook documentation tasks (workspace-level only)

[tasks.docs-api]
description = "Build API documentation with rustdoc"
workspace = false
command = "timeout"
args = ["10s", "cargo", "doc", "--no-deps", "--open"]

[tasks.docs-check]
description = "Verify API documentation compiles without errors (for CI/pre-commit)"
workspace = false
env = { RUSTDOCFLAGS = "-D warnings" }
command = "timeout"
args = ["30s", "cargo", "doc", "--no-deps", "--all"]

[tasks.docs-build]
description = "Build documentation with mdbook"
workspace = false
command = "timeout"
args = ["30s", "mdbook", "build", "docs"]

[tasks.docs-serve]
description = "Serve documentation locally with mdbook"
workspace = false
command = "mdbook"
args = ["serve", "docs", "--open"]

[tasks.docs-watch]
description = "Watch and rebuild documentation on changes"
workspace = false
command = "mdbook"
args = ["watch", "docs"]

[tasks.docs-clean]
description = "Clean built documentation"
workspace = false
command = "rm"
args = ["-rf", "docs/book", "target/doc"]

[tasks.docs-test]
description = "Test documentation build"
workspace = false
dependencies = ["docs-build"]
command = "echo"
args = ["✅ Documentation built successfully"]

[tasks.docs]
description = "Build all documentation (API + guides)"
workspace = false
dependencies = ["docs-api", "docs-build"]

[tasks.docs-validate]
description = "Validate documentation structure and links"
workspace = false
dependencies = ["docs-build"]
command = "./scripts/docs-validate.sh"

[tasks.validate-docs]
description = "Validate documentation accuracy (FMEA-based checks: cargo commands, paths, macros)"
workspace = false
command = "./scripts/validate-docs.sh"

[tasks.docs-deploy]
description = "Build and validate documentation for deployment"
workspace = false
dependencies = ["docs-clean", "docs-build", "docs-validate"]

# GitHub Pages API Diagnostic Tasks

[tasks.gh-pages-status]
description = "Check GitHub Pages configuration and deployment status via API"
workspace = false
command = "./scripts/gh-pages-status.sh"

[tasks.gh-workflow-status]
description = "Check GitHub Actions workflow status for Pages deployment"
workspace = false
command = "./scripts/gh-workflow-status.sh"

[tasks.gh-pages-compare]
description = "Compare local docs build with deployed version"
workspace = false
dependencies = ["docs-build"]
command = "./scripts/gh-pages-compare.sh"

[tasks.gh-pages-trigger]
description = "Trigger GitHub Pages deployment workflow manually"
workspace = false
command = "./scripts/gh-pages-trigger.sh"

[tasks.gh-pages-logs]
description = "View logs from latest GitHub Pages deployment"
workspace = false
command = "./scripts/gh-pages-logs.sh"

[tasks.gh-pages-setup-check]
description = "Comprehensive GitHub Pages setup validation"
workspace = false
command = "./scripts/gh-pages-setup-check.sh"

# ============================================================================
# Marketplace Validation Tasks
# ============================================================================

[tasks.marketplace-validate]
description = "Validate all marketplace packages for production readiness"
workspace = false
command = "./marketplace/scripts/validate_all_packages.sh"

[tasks.marketplace-validate-update]
description = "Validate all packages and update production_ready flags"
workspace = false
command = "./marketplace/scripts/update_production_flags.sh"

[tasks.marketplace-report]
description = "Generate validation reports for all marketplace packages"
workspace = false
command = "./marketplace/scripts/generate_validation_report.sh"

# ============================================================================
# Compilation Validation Tasks (Root Cause Prevention)
# ============================================================================

[tasks.check-all-crates]
description = "Check all crates compile (prevents type mismatch errors)"
workspace = false
command = "cargo"
args = ["check", "--workspace", "--all-targets"]

[tasks.compile-validation]
description = "Validate all crates compile (root cause prevention)"
workspace = false
dependencies = ["check-all-crates"]
command = "echo"
args = ["✅ All crates compile successfully"]

[tasks.type-safety-check]
description = "Check for type safety issues (root cause prevention)"
workspace = false
command = "./scripts/check-type-safety.sh"

# Add docs tasks to existing workflows (if they exist)
[tasks.ci]
description = "Run CI pipeline"
workspace = false
dependencies = [
  "format",
  "clippy-ci-flow",
  "check-all-crates",
  "detect-gaps",
  "test",
  "test-doc",
  "audit-all",
  "docs-test",
]

# ============================================================================
# Release Validation Tasks (FMEA-based)
# ============================================================================

[tasks.release-validate-git-state]
description = "Validate git state is clean (FMEA: prevents release with uncommitted changes, RPN 504)"
workspace = false
command = "./scripts/release-validate-git-state.sh"

[tasks.release-validate-version]
description = "Validate version consistency across all crates (FMEA: prevents version mismatches, RPN 504)"
workspace = false
command = "./scripts/release-validate-version.sh"

[tasks.release-validate-artifacts]
description = "Validate all required release artifacts exist (FMEA: prevents missing artifacts, RPN 180)"
workspace = false
command = "./scripts/release-validate-artifacts.sh"

[tasks.release-validate-build]
description = "Validate release build succeeds (FMEA: prevents config-specific errors, RPN 432)"
workspace = false
dependencies = ["build-release"]

[tasks.release-validate-security]
description = "Validate security audit passes (FMEA: prevents vulnerabilities in release, RPN 360)"
workspace = false
dependencies = ["audit-all"]

[tasks.release-validate-changelog]
description = "Validate CHANGELOG has entry for release version (FMEA: prevents missing changelog, RPN 288)"
workspace = false
script_runner = "@shell"
script = '''
#!/bin/bash
root_version=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*version = "\(.*\)"/\1/' | tr -d '"')
if ! grep -q "^## \[$root_version\]" CHANGELOG.md; then
    echo "❌ ERROR: CHANGELOG.md missing entry for version $root_version"
    exit 1
fi
echo "✅ CHANGELOG.md has entry for $root_version"
'''

[tasks.release-validate-breaking-changes]
description = "Detect breaking changes requiring documentation (FMEA: prevents undocumented breaking changes, RPN 240)"
workspace = false
command = "./scripts/release-validate-breaking-changes.sh"

[tasks.release-validate-docs-sync]
description = "Validate documentation version sync (FMEA: prevents outdated version references, RPN 96)"
workspace = false
command = "./scripts/release-validate-docs-sync.sh"

[tasks.release-validate]
description = "Comprehensive release validation (all FMEA checks)"
workspace = false
dependencies = [
  "release-validate-git-state",
  "release-validate-version",
  "release-validate-artifacts",
  "release-validate-build",
  "release-validate-security",
  "release-validate-changelog",
  "release-validate-breaking-changes",
  "release-validate-docs-sync",
  "test",
  "lint",
]

[tasks.release]
description = "Create a release"
dependencies = ["release-validate", "ci", "docs-build"]

# ============================================================================
# Homebrew Release Tasks
# ============================================================================

[tasks.brew-update-formula]
description = "Update Homebrew formula with SHA256 from latest release"
workspace = false
command = "./scripts/update-homebrew-formula.sh"
args = ["${1}"]

[tasks.brew-update]
alias = "brew-update-formula"

[tasks.release-brew]
description = "Complete release workflow with Homebrew update"
workspace = false
dependencies = ["ci", "docs-build"]
command = "./scripts/release-brew.sh"

[tasks.release-check]
description = "Check if release artifacts are ready"
workspace = false
command = "./scripts/release-check.sh"
args = ["${1}"]

# ============================================================================
# GitHub Actions Workflow Health Check
# ============================================================================

[tasks.ci-check]
description = "Check GitHub Actions workflow health and report failures"
workspace = false
command = "./scripts/ci-health-check.sh"

[tasks.ci-health]
alias = "ci-check"

# ============================================================================
# Gap Detection Tasks
# ============================================================================

[tasks.detect-gaps]
description = "Detect missing tests and coverage gaps (80/20 focused)"
workspace = false
command = "./scripts/detect-test-gaps.sh"

[tasks.enforce-coverage]
description = "Enforce test coverage for changed files"
workspace = false
command = "./scripts/enforce-test-coverage.sh"

[tasks.install-hooks]
description = "Install git hooks with gap detection"
workspace = false
command = "./scripts/install-git-hooks.sh"

[tasks.gap-report]
description = "Generate comprehensive gap detection report"
workspace = false
dependencies = ["detect-gaps"]
script = '''
if [ -f target/gap-detection-report.json ]; then
  echo "📊 Gap Detection Report:"
  cat target/gap-detection-report.json | jq .
else
  echo "❌ No report found. Run: cargo make detect-gaps"
fi
'''

# ============================================================================
# Shell Completion Tasks
# ============================================================================

[tasks.completions]
description = "Generate shell completion scripts"
command = "cargo"
args = [
  "run",
  "--bin",
  "ggen",
  "--",
  "shell",
  "completion",
  "generate",
  "--shell",
  "${SHELL}",
  "--output",
  "${OUTPUT}",
]

[tasks.completions-install]
description = "Install shell completion scripts"
command = "cargo"
args = [
  "run",
  "--bin",
  "ggen",
  "--",
  "shell",
  "completion",
  "install",
  "--shell",
  "${SHELL}",
  "--force",
]

[tasks.completions-list]
description = "List supported shell completion types"
command = "cargo"
args = ["run", "--bin", "ggen", "--", "shell", "completion", "list"]

# =============================================================================
# Node.js N-API addon tasks
# =============================================================================

[tasks.node-build]
description = "Build Node N-API addon in debug"
workspace = false
script_runner = "@shell"
script = '''
cd node && (
  command -v npx >/dev/null 2>&1 && npx --yes @napi-rs/cli@2.18.0 build || \
  (command -v corepack >/dev/null 2>&1 && corepack pnpm dlx @napi-rs/cli@2.18.0 build) || \
  (command -v yarn >/dev/null 2>&1 && yarn dlx @napi-rs/cli@2.18.0 build)
)
'''

[tasks.node-build-release]
description = "Build Node N-API addon in release"
workspace = false
script_runner = "@shell"
script = '''
cd node && (
  command -v npx >/dev/null 2>&1 && npx --yes @napi-rs/cli@2.18.0 build --release || \
  (command -v corepack >/dev/null 2>&1 && corepack pnpm dlx @napi-rs/cli@2.18.0 build --release) || \
  (command -v yarn >/dev/null 2>&1 && yarn dlx @napi-rs/cli@2.18.0 build --release)
)
'''

[tasks.node-test]
description = "Run Node addon tests deterministically"
workspace = false
script_runner = "@shell"
script = '''
cd node && (
  command -v npx >/dev/null 2>&1 && npx --yes vitest run --reporter=dot || \
  (command -v corepack >/dev/null 2>&1 && corepack pnpm dlx vitest run --reporter=dot) || \
  (command -v yarn >/dev/null 2>&1 && yarn dlx vitest run --reporter=dot)
)
'''

[tasks.node-prebuild]
description = "Create prebuilt binaries for common targets"
workspace = false
script_runner = "@shell"
script = '''
cd node && (
  command -v npx >/dev/null 2>&1 && npx --yes @napi-rs/cli@2.18.0 prebuild -t x86_64-unknown-linux-gnu -t aarch64-apple-darwin -t x86_64-apple-darwin -t x86_64-pc-windows-msvc || \
  (command -v corepack >/dev/null 2>&1 && corepack pnpm dlx @napi-rs/cli@2.18.0 prebuild -t x86_64-unknown-linux-gnu -t aarch64-apple-darwin -t x86_64-apple-darwin -t x86_64-pc-windows-msvc) || \
  (command -v yarn >/dev/null 2>&1 && yarn dlx @napi-rs/cli@2.18.0 prebuild -t x86_64-unknown-linux-gnu -t aarch64-apple-darwin -t x86_64-apple-darwin -t x86_64-pc-windows-msvc)
)
'''