File size: 64,086 Bytes
92846cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
# Rhodawk AI β€” Founder Playbook
### Autonomous DevSecOps Control Plane Β· v4.0
#### Company Profile Β· Technical Architecture Β· Investor Pitch Β· PoC Runbook

---

> **This document is the single source of truth for founders, engineers, investors, and operators.**
> Every claim in this document traces directly to code in this repository.
> No fabricated benchmarks. No vaporware. Every mechanism described here is live and verifiable.

---

## Table of Contents

1. [Company Profile](#1-company-profile)
2. [The Problem We Solve](#2-the-problem-we-solve)
3. [What Rhodawk Is β€” Plain English](#3-what-rhodawk-is--plain-english)
4. [Why Rhodawk Beats 99% of Existing Systems](#4-why-rhodawk-beats-99-of-existing-systems)
5. [Full System Architecture β€” End to End](#5-full-system-architecture--end-to-end)
6. [Every File β€” What It Does and Why It Exists](#6-every-file--what-it-does-and-why-it-exists)
7. [How to Run the System β€” Step by Step](#7-how-to-run-the-system--step-by-step)
8. [Environment Variables Reference](#8-environment-variables-reference)
9. [Proof of Concept Runbook](#9-proof-of-concept-runbook)
10. [How the PoC Convinces Investors](#10-how-the-poc-convinces-investors)
11. [Investor Pitch Deck](#11-investor-pitch-deck)
12. [Business Model](#12-business-model)
13. [Competitive Moat](#13-competitive-moat)
14. [Roadmap](#14-roadmap)
15. [Risk Register](#15-risk-register)
16. [Team Requirements](#16-team-requirements)
17. [Legal and Compliance](#17-legal-and-compliance)

---

## 1. Company Profile

| Field | Value |
|---|---|
| **Company Name** | Rhodawk AI |
| **Category** | Autonomous DevSecOps / AI Code Quality Infrastructure |
| **Stage** | Seed / PoC |
| **HuggingFace Space** | `Architect8999/rhodawk-ai-devops-engine` |
| **Commit (this version)** | `8a23fcf` |
| **Languages Supported** | Python Β· JavaScript Β· TypeScript Β· Java Β· Go Β· Rust Β· Ruby |
| **Deployment Target** | HuggingFace Spaces Β· Self-hosted Docker Β· Any Linux server |
| **License** | Proprietary (source visible for due diligence) |

### Mission

To make broken software self-healing β€” autonomously, verifiably, and securely β€” across every programming language, for every team, without human bottlenecks in the fix loop.

### Vision

A world where no bug that has already been fixed somewhere in the world stays broken in any other repository. Rhodawk is the infrastructure that closes that gap at machine speed.

---

## 2. The Problem We Solve

### The CI/CD graveyard

At any given moment, millions of GitHub repositories have failing CI runs. Most of them stay broken for days or weeks β€” not because the fix is hard, but because:

1. Engineers are expensive, context-switching is expensive, and debugging is slow
2. AI coding assistants (Copilot, Cursor, Claude) require a human in the loop to accept the fix
3. Security teams cannot review every AI-generated diff fast enough
4. No system connects "what fixed a similar failure last month in another repo" to "what should fix this one today"

### The scale of the waste

- The average developer spends 30-40% of their time debugging and fixing existing code, not writing new features
- CI failures block deployments, which block revenue, which block growth
- Every hour a critical bug sits unfixed in a production system is an incident waiting to happen
- Enterprise security teams are overwhelmed β€” they cannot hand-review every AI-generated code change

### What currently exists and why it is not enough

| Tool | What it does | What it misses |
|---|---|---|
| GitHub Copilot | Suggests code completions in your editor | Human must accept every suggestion. No verification. No security gate. No memory of past fixes. |
| Devin / SWE-agent | AI software engineer agents | Human-supervised. No autonomous CI integration. No adversarial review. No supply chain gate. |
| Dependabot | Bumps dependency versions | Only handles dependency updates. Cannot fix test failures. |
| Snyk / Semgrep | Scans for known vulnerabilities | Detects problems, does not fix them. No AI fix loop. |
| CodeRabbit | AI PR review | Reviews human-written PRs. Does not generate fixes autonomously. No formal verification. |
| Linear / Jira AI | Ticket management | Workflow tooling. Not a code-fix engine. |

**Rhodawk does what none of these do: it finds the broken test, generates the fix, verifies the fix actually works by re-running the test, passes it through 5 independent safety gates, and submits the PR β€” entirely without a human in the loop.**

---

## 3. What Rhodawk Is β€” Plain English

Rhodawk is a software robot that watches your code repositories, finds tests that are failing, fixes them, and submits the fix as a pull request β€” safely and continuously, 24 hours a day.

It is not a code completion tool. It is not a PR review bot. It is a full autonomous agent that closes the entire loop from "CI is failing" to "PR submitted and ready for merge."

The key insight that makes Rhodawk different from every other AI coding tool: **it does not trust its own output.** After generating a fix, it runs 5 separate validation layers before the diff is allowed to leave the system. This is what makes it safe enough to run autonomously at scale.

---

## 4. Why Rhodawk Beats 99% of Existing Systems

### Mechanism 1 β€” It actually tests its own fixes (closed verification loop)

Every other AI coding tool generates a diff and stops. Rhodawk re-runs the failing test after applying the fix. If the test is still red, the system retries with the new failure output as context. It does not submit a PR for a diff that has not been verified to make the test pass.

**This is the most important distinction. Most AI-generated fixes do not actually work when applied. Rhodawk knows this and handles it.**

### Mechanism 2 β€” Three-model adversarial consensus review

After the fix is verified, three language models (Qwen 2.5 7B, Gemma 2 9B, Mistral 7B) run simultaneously and each independently review the diff as a hostile security engineer. They each return a structured JSON verdict. A 2/3 majority is required to approve. Their critical findings are merged β€” a security issue spotted by any one model blocks the diff.

No other publicly available system runs concurrent adversarial multi-model review on AI-generated code diffs.

### Mechanism 3 β€” Formal mathematical verification via Z3

When enabled, the Z3 SMT solver from Microsoft Research performs bounded symbolic analysis of the diff. It checks for literal divide-by-zero, negative array index access, and assertions that are always false based on surrounding constant assignments. This is mathematics, not heuristics.

### Mechanism 4 β€” Self-improving memory (data flywheel)

Every fix attempt, whether it succeeded or failed, and every adversarial rejection are stored. The embedding memory uses either MiniLM or CodeBERT (a model trained specifically on programming language) to encode failure traces. The next time a similar failure appears anywhere β€” in any repo the system has ever touched β€” the most relevant past fixes are retrieved and injected into the prompt. The system gets measurably better over time, not just within a session.

### Mechanism 5 β€” Supply chain security gate

Rhodawk scans every diff for newly introduced packages. It checks them against:
- pip-audit (Python CVE database)
- npm audit (Node.js CVE database)
- OWASP dependency-check (Java)
- govulncheck (Go)
- Levenshtein distance typosquatting detection against 40+ known package names

An AI that introduces `reqeusts` instead of `requests` to steal credentials from your CI environment is caught and blocked.

### Mechanism 6 β€” Seven-language runtime

Most AI DevOps tools are Python-only. Rhodawk has pluggable language runtimes for Python, JavaScript, TypeScript, Java, Go, Rust, and Ruby. Each runtime knows how to install dependencies, discover tests, run tests, and run language-specific SAST scanning. Adding a new language requires implementing one class interface.

### Mechanism 7 β€” Conviction-based autonomous merge

When all seven safety criteria are simultaneously satisfied (adversarial confidence β‰₯ 0.92, full consensus from all three models, memory match to a prior human-merged fix, fixed on first attempt, zero SAST findings, zero new packages), Rhodawk merges the PR directly via the GitHub API without waiting for a human. This is not reckless β€” it is mathematically gated. Most fixes will not reach this threshold. The ones that do are the clearest, cleanest, most-verified fixes in the system's history.

### Mechanism 8 β€” Antagonist mode (autonomous target selection)

In standard mode, a human or webhook tells Rhodawk which repo to fix. In antagonist mode, Rhodawk finds its own targets. It searches GitHub for public repositories that have actively failing CI runs, scores them by community trust (star count), recency of last commit, and number of failing checks, and dispatches its own audits continuously β€” 24 hours a day, without any human input.

---

## 5. Full System Architecture β€” End to End

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         RHODAWK AI v4.0                                  β”‚
β”‚                   Autonomous DevSecOps Control Plane                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

INPUT LAYER (3 paths)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Gradio UI   β”‚  β”‚  Webhook :7861   β”‚  β”‚  Repo Harvester (Daemon)      β”‚
β”‚  Chat Inbox  β”‚  β”‚  GitHub Events   β”‚  β”‚  GitHub Search β†’ Failing CI   β”‚
β”‚  owner/repo  β”‚  β”‚  CI Failures     β”‚  β”‚  Scores by stars+recency      β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”˜                            β”‚
                          β–Ό                             β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
                β”‚   enterprise_audit_loop β”‚β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚   (app.py)              β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚  RuntimeFactory         β”‚
                β”‚  language_runtime.py    β”‚
                β”‚  Detects: py/js/ts/     β”‚
                β”‚  java/go/rust/ruby      β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚  Test Discovery         β”‚
                β”‚  Language-specific      β”‚
                β”‚  glob patterns          β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚  Worker Pool            β”‚
                β”‚  worker_pool.py         β”‚
                β”‚  ThreadPoolExecutor     β”‚
                β”‚  + optional Process     β”‚
                β”‚  Isolation per job      β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Per-test loop  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  1. RUN TEST           β”‚
                 β”‚  language_runtime.py   β”‚
                 β”‚  β†’ PASS: mark done     β”‚
                 β”‚  β†’ FAIL: healing loop  β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ FAIL
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  2. MEMORY RETRIEVAL  β”‚
                 β”‚  embedding_memory.py  β”‚
                 β”‚  SQLite/MiniLM or     β”‚
                 β”‚  Qdrant/CodeBERT      β”‚
                 β”‚  β†’ top-5 similar fixesβ”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  3. FIX GENERATION    β”‚
                 β”‚  Aider + OpenRouter   β”‚
                 β”‚  Qwen 2.5 Coder 32B   β”‚
                 β”‚  + MCP fetch-docs     β”‚
                 β”‚  + MCP github-manager β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  4. RE-RUN TEST       β”‚
                 β”‚  β†’ still FAIL: retry  β”‚
                 β”‚    (up to MAX_RETRIES)β”‚
                 β”‚  β†’ PASS: continue     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ PASS
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  5. SAST GATE         β”‚
                 β”‚  sast_gate.py         β”‚
                 β”‚  bandit + semgrep     β”‚
                 β”‚  + 16 secret patterns β”‚
                 β”‚  Language-specific    β”‚
                 β”‚  β†’ BLOCK: retry loop  β”‚
                 β”‚  β†’ PASS: continue     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ PASS
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  6. SUPPLY CHAIN      β”‚
                 β”‚  supply_chain.py      β”‚
                 β”‚  pip-audit/npm audit  β”‚
                 β”‚  + typosquatting scan β”‚
                 β”‚  β†’ BLOCK: retry       β”‚
                 β”‚  β†’ PASS: continue     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ PASS
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  7. Z3 FORMAL VERIFY  β”‚
                 β”‚  formal_verifier.py   β”‚
                 β”‚  Div-by-zero          β”‚
                 β”‚  Negative index       β”‚
                 β”‚  Assert satisfiabilityβ”‚
                 β”‚  β†’ UNSAFE: retry      β”‚
                 β”‚  β†’ SKIP/SAFE: proceed β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  8. ADVERSARIAL REVIEWβ”‚
                 β”‚  adversarial_reviewer β”‚
                 β”‚  Qwen βˆ₯ Gemma βˆ₯       β”‚
                 β”‚  Mistral (concurrent) β”‚
                 β”‚  2/3 majority vote    β”‚
                 β”‚  β†’ REJECT: retry      β”‚
                 β”‚  β†’ APPROVE/COND: PR   β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚ APPROVE / CONDITIONAL
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  9. PR CREATION       β”‚
                 β”‚  github_app.py        β”‚
                 β”‚  Standard mode: push  β”‚
                 β”‚  Fork mode: fork+PR   β”‚
                 β”‚  Cross-repo PRs       β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  10. CONVICTION CHECK β”‚
                 β”‚  conviction_engine.py β”‚
                 β”‚  7 criteria gate      β”‚
                 β”‚  β†’ MET: auto-merge    β”‚
                 β”‚  β†’ NOT MET: human PR  β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  11. MEMORY UPDATE    β”‚
                 β”‚  training_store.py    β”‚
                 β”‚  embedding_memory.py  β”‚
                 β”‚  Store outcome for    β”‚
                 β”‚  future retrieval     β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                             β–Ό
                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚  12. LORA SCHEDULER   β”‚
                 β”‚  lora_scheduler.py    β”‚
                 β”‚  Export SFT JSONL     β”‚
                 β”‚  when threshold met   β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

PARALLEL (always running)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Red Team CEGIS          β”‚  β”‚  Audit Trail Logger      β”‚
β”‚  red_team_fuzzer.py      β”‚  β”‚  audit_logger.py         β”‚
β”‚  When all tests green:   β”‚  β”‚  SHA-256 chained JSONL   β”‚
β”‚  attack with fuzz tests  β”‚  β”‚  Every action logged      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## 6. Every File β€” What It Does and Why It Exists

### Core Orchestration

#### `app.py` β€” 1,430 lines β€” Master Control
**What it does:** The central orchestrator. Imports and wires all other modules together. Contains `enterprise_audit_loop()` (the main audit cycle), `process_failing_test()` (the 15-step healing loop for one test), `process_audit_test()` (the per-test driver including PR creation and conviction check), and the Gradio dashboard with 10 tabs.

**Why it exists:** Every system needs a single point of entry and wiring. `app.py` is the brain that sequences all the specialist modules in the right order.

**Key functions:**
- `enterprise_audit_loop()` β€” top-level entry point for any audit run
- `process_failing_test()` β€” the 15-step loop: memory β†’ Aider fix β†’ test re-run β†’ SAST β†’ supply chain β†’ Z3 β†’ adversarial β†’ retry or commit
- `process_audit_test()` β€” wraps the above with PR creation, conviction check, audit logging
- `submit_repo_audit()` β€” chat inbox handler, validates repo format, dispatches background thread
- Gradio `demo` block β€” all UI components, auto-refresh timer (every 3 seconds)

---

#### `language_runtime.py` β€” 1,508 lines β€” Language Abstraction Layer
**What it does:** Defines the `LanguageRuntime` abstract base class and concrete implementations for Python, JavaScript, TypeScript, Java, Go, Rust, and Ruby. `RuntimeFactory.for_repo()` detects the language by looking for marker files and returns the right runtime.

**Why it exists:** Every language has a completely different test runner, dependency installer, SAST tool, and supply chain checker. Without this abstraction, adding Java support would require rewriting the whole pipeline. With it, each language is one class.

**Key classes:**
- `LanguageRuntime` β€” abstract base: `detect()`, `setup_env()`, `discover_tests()`, `run_tests()`, `run_sast()`, `run_supply_chain()`
- `PythonRuntime` β€” pytest, uv venv, bandit + semgrep, pip-audit + typosquatting
- `NodeRuntime` β€” jest/mocha/vitest, npm ci, eslint patterns + semgrep, npm audit
- `TypeScriptRuntime` β€” extends Node, adds tsc --noEmit type checking
- `JavaRuntime` β€” Maven or Gradle, JUnit test discovery, OWASP dependency-check
- `GoRuntime` β€” go test, gosec, govulncheck
- `RustRuntime` β€” cargo test, cargo audit
- `RubyRuntime` β€” rspec/minitest, bundler-audit
- `RuntimeFactory` β€” scans repo root, returns first matching runtime
- `EnvConfig` β€” dataclass carrying test_runner_cmd, env_dir, metadata per language

---

### Safety Gate Modules

#### `adversarial_reviewer.py` β€” Concurrent 3-Model Consensus Review
**What it does:** Runs Qwen 2.5 7B, Gemma 2 9B, and Mistral 7B simultaneously via OpenRouter. Each model receives the diff, the original failure, and the repo name, and must return a structured JSON verdict: APPROVE / CONDITIONAL / REJECT with confidence score, critical issues, warnings, and retry guidance. A majority vote (2/3 threshold = 0.67) determines the final verdict. Critical issues from all models are merged into one unified list.

**Why it exists:** A single model can be wrong. Two out of three independent models agreeing on a security issue is a much stronger signal. Running them concurrently rather than sequentially cuts latency from 3Γ— to approximately 1Γ— (wall clock time of the slowest model, not the sum).

**Key env vars:**
- `RHODAWK_CONSENSUS_THRESHOLD` β€” majority fraction required (default 0.67)
- `RHODAWK_ADVERSARY_SEQUENTIAL=true` β€” disables concurrent mode, uses sequential fallback

---

#### `formal_verifier.py` β€” Z3 SMT Solver Gate
**What it does:** Extracts all lines added by the diff (lines starting with `+`) and runs three bounded checks using the Z3 SMT solver: (1) literal divide-by-zero patterns (`x / 0`, `x % 0`), (2) negative literal array index access (`arr[-3]` flagged as potentially invalid), (3) assert statements that are mathematically always false given constant assignments in the same scope. Returns SAFE, UNSAFE, or SKIP.

**Why it exists:** LLMs sometimes introduce subtle arithmetic bugs when trying to fix a test. A mathematical solver catches a class of errors that no amount of prompt engineering or code review reliably catches, because it reasons about the actual values, not patterns.

**Key env vars:**
- `RHODAWK_Z3_ENABLED=true` β€” enables the gate (disabled by default to avoid dependency requirement)

---

#### `sast_gate.py` β€” Static Analysis Security Gate
**What it does:** Runs bandit (Python SAST), semgrep with language-appropriate rule sets, and a 16-pattern custom secret scanner that looks for hardcoded API keys, JWT tokens, AWS credentials, database connection strings, and private keys in diff additions. Classifies findings as CRITICAL / HIGH / MEDIUM / LOW.

**Why it exists:** AI-generated fixes sometimes introduce security vulnerabilities β€” not maliciously, but because the model is optimizing for making the test pass, not for security. A dedicated SAST gate that runs before the diff leaves the system catches these before they reach human reviewers.

---

#### `supply_chain.py` β€” Dependency Security Gate
**What it does:** Extracts newly added packages from the diff (pip installs, npm dependencies, Maven artifacts, Go modules). Runs the appropriate CVE scanner for the language. Runs Levenshtein distance typosquatting detection against a list of 40+ commonly squatted package names (e.g. `reqeusts` is 1 edit from `requests`).

**Why it exists:** Supply chain attacks via AI-generated code are an emerging attack vector. An LLM that suggests installing a malicious package that mimics a legitimate one is a real threat. This gate catches it before it reaches the repo.

---

#### `conviction_engine.py` β€” Autonomous Merge Gate
**What it does:** Evaluates 7 simultaneous criteria before allowing an autonomous PR merge via the GitHub API: adversarial verdict must be APPROVE (not just CONDITIONAL), adversarial confidence β‰₯ 0.92, all three models must agree (consensus fraction β‰₯ 0.85), test fixed on first attempt, zero SAST findings, zero new packages, and embedding memory must contain a prior fix for a semantically identical failure that was actually merged by a human (similarity β‰₯ 0.85).

**Why it exists:** Autonomous merge is only safe when you are mathematically certain the fix is correct, secure, and precedented. These seven criteria together provide that certainty. Any one criterion failing leaves the PR for human review β€” the system does not guess.

**Key env vars:**
- `RHODAWK_AUTO_MERGE=true` β€” enables autonomous merge (disabled by default)
- `RHODAWK_CONVICTION_CONFIDENCE` β€” adversarial confidence threshold (default 0.92)
- `RHODAWK_CONVICTION_CONSENSUS` β€” consensus fraction threshold (default 0.85)
- `RHODAWK_CONVICTION_MEMORY_SIM` β€” memory similarity threshold (default 0.85)

---

### Memory and Learning Modules

#### `embedding_memory.py` β€” Semantic Fix Memory
**What it does:** Dual-backend embedding store. SQLite backend (default): normalizes failure output (strips file paths and line numbers), encodes with `all-MiniLM-L6-v2` sentence transformer, stores embeddings in SQLite with cosine similarity retrieval. Qdrant backend (optional): uses `microsoft/codebert-base` for code-aware embeddings, stores in Qdrant's HNSW index for approximate nearest-neighbor retrieval. Both backends expose the same public API: `retrieve_similar_fixes_v2()` and `rebuild_embedding_index()`.

**Why it exists:** The fix quality on the first run for a new failure pattern is limited by the model's general knowledge. The fix quality on the tenth run for a similar pattern is boosted by concrete past fixes with known outcomes. This is the core data flywheel that makes Rhodawk compoundingly more effective over time.

**Key env vars:**
- `RHODAWK_EMBEDDING_BACKEND=qdrant` β€” switches to CodeBERT + Qdrant
- `RHODAWK_EMBEDDING_MODEL` β€” overrides MiniLM model name
- `RHODAWK_CODEBERT_MODEL` β€” overrides CodeBERT model name

---

#### `memory_engine.py` β€” Pattern Memory (Legacy v1)
**What it does:** Original key-value pattern memory using exact failure signature matching. Stores fix patterns keyed by normalized failure signatures in SQLite. Used alongside v2 embedding memory for cold-start scenarios where the embedding index has no data yet.

---

#### `training_store.py` β€” Fix Outcome Database
**What it does:** SQLite database with two tables: `fix_attempts` (every fix attempt with failure output, diff produced, test path, model used, attempt number, success signal) and `fix_patterns` (aggregated success/attempt counts by failure signature). Provides `record_attempt()`, `export_training_data()` (JSONL format), `get_statistics()`.

**Why it exists:** Every fix attempt is proprietary training data. If Rhodawk fixes 100,000 tests over its lifetime, that is 100,000 (failure, fix) pairs that can be used to fine-tune a model that is better at this specific task than any general-purpose LLM. This database is the asset.

---

#### `lora_scheduler.py` β€” Fine-Tune Training Export Scheduler
**What it does:** Monitors the count of new successful fix pairs since the last export. When the count reaches `RHODAWK_LORA_MIN_SAMPLES` (default 50) or `RHODAWK_LORA_MAX_AGE_HOURS` (default 168 hours = 1 week) have elapsed, it exports all successful (failure, fix) pairs as instruction-tuning JSONL to `/data/lora_exports/`. Format: `{"messages": [{"role": "system", ...}, {"role": "user", ...}, {"role": "assistant", ...}]}` β€” directly compatible with HuggingFace PEFT/TRL SFT training.

**Why it exists:** The long-term product vision is a Rhodawk-specific fine-tuned model trained entirely on proprietary fix data. This scheduler automates the data pipeline for that model without requiring any manual intervention.

**Key env vars:**
- `RHODAWK_LORA_ENABLED=true` β€” enables the scheduler
- `RHODAWK_LORA_MIN_SAMPLES` β€” minimum new fixes before export (default 50)
- `RHODAWK_LORA_MAX_AGE_HOURS` β€” maximum time between exports (default 168)

---

### Autonomous Operation Modules

#### `repo_harvester.py` β€” Autonomous Target Selection (Antagonist Mode)
**What it does:** Background daemon that continuously searches GitHub for public repositories in 7 languages that have failing CI check runs, are actively maintained (last commit within 60 days), and have at least `RHODAWK_HARVESTER_MIN_STARS` stars (default 100). Scores each candidate with a composite score: star count (log-scaled, weight 35%), recency of last commit (weight 40%), number of failing CI checks (weight 25%). Persists the ranked feed to `/data/harvester_feed.json`. Dispatches the top-scored target to `enterprise_audit_loop` automatically. Polls every `RHODAWK_HARVESTER_POLL_SECONDS` (default 6 hours).

**Why it exists:** In standard mode, Rhodawk needs a human or webhook to tell it what to fix. The harvester eliminates that dependency entirely. Rhodawk becomes genuinely autonomous β€” it finds its own work, does it, and submits PRs without any human involvement in the selection or execution loop.

**Key env vars:**
- `RHODAWK_HARVESTER_ENABLED=true` β€” starts the daemon
- `RHODAWK_HARVESTER_POLL_SECONDS` β€” polling interval (default 21600 = 6h)
- `RHODAWK_HARVESTER_MIN_STARS` β€” minimum repository stars (default 100)
- `RHODAWK_HARVESTER_MAX_REPOS` β€” max targets per harvest cycle (default 20)

---

#### `github_app.py` β€” GitHub Authentication + Fork-and-PR Mode
**What it does:** Handles two authentication modes: GitHub App (short-lived JWT-issued installation tokens, enterprise grade) and Personal Access Token (simple mode). Adds fork-and-PR capability: `fork_repo()` forks any public repository under the authenticated account, waits for GitHub's async fork operation to complete, then `create_cross_repo_pr()` opens a cross-repository PR from the fork to the upstream. `open_pr_for_repo()` is the unified entry point that chooses standard or fork mode based on `RHODAWK_FORK_MODE`.

**Why it exists:** Standard mode requires push access to the target repo β€” only works on your own repos. Fork mode lets Rhodawk fix any public repository on GitHub. This is the antagonist mode capability: fix the world's code, not just code you own.

**Key env vars:**
- `RHODAWK_FORK_MODE=true` β€” enables fork-and-PR for any public repo
- `RHODAWK_FORK_OWNER` β€” org/user to fork into (default: authenticated user)
- `RHODAWK_APP_ID` + `RHODAWK_APP_PRIVATE_KEY` β€” for GitHub App auth (enterprise)

---

#### `worker_pool.py` β€” Parallel + Process-Isolated Worker Pool
**What it does:** `ThreadPoolExecutor` with `MAX_WORKERS` parallel workers (default 8, configurable via `RHODAWK_WORKERS`). When `RHODAWK_PROCESS_ISOLATE=true`, each test repair runs in a separate `multiprocessing.Process` (fork context) with a configurable timeout (default 600s). The isolated subprocess imports its module fresh, runs the fix function, and puts the result on a `multiprocessing.Queue`. If the process is still alive after the timeout, it is killed. Falls back gracefully to in-process if the fork context is unavailable.

**Why it exists:** Without process isolation, a runaway Aider subprocess or a fix that OOM-kills the interpreter can crash the entire orchestrator, losing all in-flight workers. With isolation, each test is a blast-radius-1 operation.

**Key env vars:**
- `RHODAWK_WORKERS` β€” parallel workers (default 8)
- `RHODAWK_PROCESS_ISOLATE=true` β€” enables subprocess isolation
- `RHODAWK_ISOLATE_TIMEOUT` β€” per-job timeout in seconds (default 600)

---

### Infrastructure Modules

#### `audit_logger.py` β€” SHA-256 Chained Audit Trail
**What it does:** Every significant action β€” test run, SAST result, supply chain check, adversarial review, PR submission, merge, crash β€” is written as a JSONL entry. Each entry includes the SHA-256 hash of the previous entry, creating a tamper-evident chain. `verify_chain_integrity()` walks the entire chain and confirms each hash. SOC 2 / ISO 27001 compatible evidence artifact.

---

#### `webhook_server.py` β€” Event-Driven HTTP Trigger Server
**What it does:** HTTP server on port 7861. Endpoints: `POST /webhook/github` (validates GitHub HMAC-SHA256 signature, handles push and check_run events), `POST /webhook/ci` (generic CI failure trigger), `POST /webhook/trigger` (manual trigger), `GET /webhook/health` (liveness probe), `GET /webhook/queue` (current job status JSON). Has per-IP rate limiting.

---

#### `job_queue.py` β€” Persistent Job State (SQLite)
**What it does:** Namespaced job store: `(tenant_id, repo, test_path)` β†’ `(status, pr_url, model_version, updated_at)`. Statuses: PENDING, RUNNING, DONE, FAILED, SAST_BLOCKED. Prevents duplicate work: if a test is already DONE it is skipped. If it is RUNNING (from a crashed previous session) the stale branch is cleaned and the job is retried. `prune_done_jobs()` removes completed jobs older than 72 hours.

---

#### `red_team_fuzzer.py` β€” 1,561 lines β€” Adversarial CEGIS Fuzzer
**What it does:** When all tests in a repository are green, Rhodawk switches from Blue Team (fixing) to Red Team (attacking). It generates property-based tests using Hypothesis, applies them to the codebase, and looks for violations. Uses CEGIS (Counterexample-Guided Inductive Synthesis) β€” a formal methods loop where counterexamples from fuzzing drive synthesis of new attack vectors. Zero-day findings are saved as structured JSON artifacts and handed back to the Blue Team healing loop for patching.

---

#### `notifier.py` β€” Multi-Channel Notifications
**What it does:** Sends notifications to Telegram and Slack on audit start, test failure, PR creation, patch failure, SAST block, and audit completion. All notification calls are non-blocking.

---

#### `swebench_harness.py` β€” Benchmarking
**What it does:** Runs Rhodawk's own healing loop against SWE-bench Verified instances. Reports pass@1 (percentage of instances fully resolved on the first attempt). Provides objective, reproducible benchmark results using the same pipeline used in production.

---

#### `public_leaderboard.py` β€” Public Statistics Dashboard
**What it does:** Standalone Gradio interface showing real-time stats read directly from the audit trail JSONL and training store: PRs submitted, PRs merged (human-approved), repos touched, patterns learned, zero-days discovered. Can run on port 7862 as a separate Space or be embedded. All numbers come from real data β€” no synthetic metrics.

---

#### `verification_loop.py` β€” Retry Logic and Prompt Construction
**What it does:** Contains `MAX_RETRIES` constant, `VerificationResult` and `VerificationAttempt` dataclasses, `build_initial_prompt()` (constructs the first Aider prompt with memory context), and `build_retry_prompt()` (builds retry prompts that include the SAST critique, adversarial critique, or new failure output from the previous attempt). `ADVERSARIAL_REJECTION_MULTIPLIER` extends the retry budget when adversarial review is active.

---

#### `requirements.txt` β€” Dependencies

```
requests, pytest, gitpython, gradio>=5.0.0, jinja2, starlette,
aider-chat>=0.86.0, ruff, tenacity, bandit[toml], pip-audit, radon,
hypothesis[cli]>=6.100.0, semgrep>=1.45.0,
sentence-transformers>=2.7.0, sqlite-vec>=0.1.1,
pygithub>=2.3.0, PyJWT>=2.8.0, datasets>=2.19.0,
numpy>=1.26.0, psycopg2-binary>=2.9.9, rapidfuzz>=3.0.0,
z3-solver>=4.12.0, qdrant-client>=1.9.0,
transformers>=4.40.0, torch>=2.2.0
```

---

## 7. How to Run the System β€” Step by Step

### Option A β€” HuggingFace Spaces (fastest, recommended for PoC)

**Step 1 β€” Fork the Space**

Go to: `https://huggingface.co/spaces/Architect8999/rhodawk-ai-devops-engine`

Click the three-dot menu β†’ Duplicate this Space. Give it a name. Set hardware to at minimum CPU Basic (free tier works for PoC).

**Step 2 β€” Set Secrets**

In your duplicated Space β†’ Settings β†’ Variables and Secrets, add:

| Secret Name | Value | Required |
|---|---|---|
| `GITHUB_TOKEN` | GitHub Personal Access Token with `repo` scope | Yes |
| `OPENROUTER_API_KEY` | OpenRouter API key (free tier works) | Yes |
| `RHODAWK_TENANT_ID` | Any string, e.g. your company name | No |
| `RHODAWK_MODEL` | Leave default for free models | No |
| `GITHUB_REPO` | `owner/repo` to auto-start audit on launch | No |

**Step 3 β€” Space starts automatically**

HuggingFace builds the Docker container and starts the app. When the Space shows "Running", the dashboard is live.

**Step 4 β€” Submit a repo via the chat inbox**

In the Gradio UI, type a GitHub repo in the format `owner/repo` (e.g. `torvalds/linux`) and click Run Audit.

Watch the **Live Agent Log** tab update in real time. The system will clone the repo, discover tests, run them, and if any fail, begin the healing loop.

---

### Option B β€” Self-hosted Docker

```bash
git clone https://huggingface.co/spaces/Architect8999/rhodawk-ai-devops-engine rhodawk
cd rhodawk

# Build the container
docker build -t rhodawk:latest .

# Run with secrets as environment variables
docker run -d \
  -p 7860:7860 \
  -p 7861:7861 \
  -v /data/rhodawk:/data \
  -e GITHUB_TOKEN=your_token \
  -e OPENROUTER_API_KEY=your_key \
  -e RHODAWK_TENANT_ID=mycompany \
  --name rhodawk \
  rhodawk:latest
```

Dashboard: `http://localhost:7860`
Webhook endpoint: `http://localhost:7861/webhook/github`

---

### Option C β€” GitHub Webhook Integration

Register Rhodawk's webhook URL with your GitHub repository:

1. In your GitHub repo β†’ Settings β†’ Webhooks β†’ Add webhook
2. Payload URL: `https://your-rhodawk-space.hf.space/webhook/github`
3. Content type: `application/json`
4. Secret: set `RHODAWK_WEBHOOK_SECRET` in Rhodawk's secrets to match
5. Events: select "Check runs" and "Pushes"

Now every CI failure in your repo automatically triggers a Rhodawk healing audit.

---

### Enabling Advanced Features

| Feature | Environment Variable | Value |
|---|---|---|
| Autonomous merge | `RHODAWK_AUTO_MERGE` | `true` |
| Formal verification (Z3) | `RHODAWK_Z3_ENABLED` | `true` |
| Process isolation | `RHODAWK_PROCESS_ISOLATE` | `true` |
| CodeBERT embeddings | `RHODAWK_EMBEDDING_BACKEND` | `qdrant` |
| LoRA data export | `RHODAWK_LORA_ENABLED` | `true` |
| Repo harvester (24/7) | `RHODAWK_HARVESTER_ENABLED` | `true` |
| Fork-and-PR mode | `RHODAWK_FORK_MODE` | `true` |
| Red team fuzzer | `RHODAWK_RED_TEAM_ENABLED` | `true` (default) |
| More workers | `RHODAWK_WORKERS` | `16` or higher |

---

## 8. Environment Variables Reference

| Variable | Default | Description |
|---|---|---|
| `GITHUB_TOKEN` | β€” | Required. GitHub PAT with `repo` scope |
| `OPENROUTER_API_KEY` | β€” | Required. OpenRouter API key |
| `GITHUB_REPO` | `""` | Optional. Auto-start repo (can set via UI) |
| `RHODAWK_TENANT_ID` | `default` | Namespace for job isolation |
| `RHODAWK_MODEL` | `openrouter/qwen/qwen-2.5-coder-32b-instruct:free` | Primary fix model |
| `RHODAWK_ADVERSARY_MODEL` | `openrouter/qwen/qwen-2.5-7b-instruct:free` | Lead adversary model |
| `RHODAWK_CONSENSUS_THRESHOLD` | `0.67` | Adversarial 2/3 majority threshold |
| `RHODAWK_ADVERSARY_SEQUENTIAL` | `false` | Use sequential instead of concurrent |
| `RHODAWK_AUTO_MERGE` | `false` | Enable conviction-based auto-merge |
| `RHODAWK_CONVICTION_CONFIDENCE` | `0.92` | Min adversarial confidence for merge |
| `RHODAWK_CONVICTION_CONSENSUS` | `0.85` | Min consensus fraction for merge |
| `RHODAWK_CONVICTION_MEMORY_SIM` | `0.85` | Min memory similarity for merge |
| `RHODAWK_Z3_ENABLED` | `false` | Enable Z3 formal verification |
| `RHODAWK_EMBEDDING_BACKEND` | `sqlite` | `sqlite` or `qdrant` |
| `RHODAWK_EMBEDDING_MODEL` | `all-MiniLM-L6-v2` | SQLite backend model |
| `RHODAWK_CODEBERT_MODEL` | `microsoft/codebert-base` | Qdrant backend model |
| `RHODAWK_LORA_ENABLED` | `false` | Enable LoRA training export |
| `RHODAWK_LORA_MIN_SAMPLES` | `50` | Fixes required to trigger export |
| `RHODAWK_LORA_MAX_AGE_HOURS` | `168` | Max hours between exports |
| `RHODAWK_LORA_OUTPUT_DIR` | `/data/lora_exports` | JSONL output directory |
| `RHODAWK_HARVESTER_ENABLED` | `false` | Enable autonomous repo harvester |
| `RHODAWK_HARVESTER_POLL_SECONDS` | `21600` | Harvest cycle interval |
| `RHODAWK_HARVESTER_MIN_STARS` | `100` | Minimum stars for harvested repos |
| `RHODAWK_HARVESTER_MAX_REPOS` | `20` | Max targets per harvest cycle |
| `RHODAWK_FORK_MODE` | `false` | Enable fork-and-PR for any public repo |
| `RHODAWK_FORK_OWNER` | _(authenticated user)_ | Org to fork into |
| `RHODAWK_APP_ID` | β€” | GitHub App ID (enterprise auth) |
| `RHODAWK_APP_PRIVATE_KEY` | β€” | GitHub App RSA private key |
| `RHODAWK_WORKERS` | `8` | Parallel worker count |
| `RHODAWK_PROCESS_ISOLATE` | `false` | Enable per-job subprocess isolation |
| `RHODAWK_ISOLATE_TIMEOUT` | `600` | Per-job timeout in seconds |
| `RHODAWK_RED_TEAM_ENABLED` | `true` | Enable red team CEGIS fuzzer |
| `RHODAWK_WEBHOOK_SECRET` | β€” | HMAC secret for GitHub webhooks |
| `TELEGRAM_BOT_TOKEN` | β€” | Telegram notification bot token |
| `TELEGRAM_CHAT_ID` | β€” | Telegram chat to send notifications |
| `SLACK_WEBHOOK_URL` | β€” | Slack incoming webhook URL |

---

## 9. Proof of Concept Runbook

This runbook tells you exactly what to do, in what order, to produce a live, working PoC that a technical investor can watch in real time.

### Pre-requisites

- [ ] GitHub account with a Personal Access Token (repo scope)
- [ ] OpenRouter account (free tier is sufficient) β†’ API key
- [ ] A target GitHub repository that has at least one failing test (use your own or use a public one with known failures)
- [ ] HuggingFace account (free)

### Step 1 β€” Set up the Space (15 minutes)

1. Go to `https://huggingface.co/spaces/Architect8999/rhodawk-ai-devops-engine`
2. Click β‹― β†’ Duplicate this Space
3. Name your Space (e.g. `my-rhodawk-demo`)
4. Set hardware: CPU Basic (free) is sufficient for the PoC
5. In Settings β†’ Variables and Secrets, add `GITHUB_TOKEN` and `OPENROUTER_API_KEY`
6. Wait ~3 minutes for the build to complete

### Step 2 β€” Prepare a target repository (10 minutes)

Option A β€” Use your own repo with a failing test. Make sure it has at least one pytest / jest / go test file that is currently failing.

Option B β€” Create a demo repo:
```bash
mkdir rhodawk-demo && cd rhodawk-demo
git init
# Create a deliberately broken Python file
cat > src/calculator.py << 'EOF'
def divide(a, b):
    return a / b  # BUG: no zero-division check
EOF

# Create a test that exposes the bug
mkdir tests
cat > tests/test_calculator.py << 'EOF'
from src.calculator import divide

def test_divide_by_zero():
    result = divide(10, 0)  # Should raise ZeroDivisionError, not crash
    assert result is None
EOF

git add . && git commit -m "initial"
git remote add origin https://github.com/YOUR_USERNAME/rhodawk-demo.git
git push -u origin main
```

### Step 3 β€” Run the audit (watch in real time)

1. Open your Space URL
2. In the chat inbox, type `YOUR_USERNAME/rhodawk-demo`
3. Click Run Audit
4. Switch to the **Live Agent Log** tab
5. Watch the pipeline execute in real time:
   - Clone and language detection (Python)
   - Test discovery (finds `tests/test_calculator.py`)
   - Test run β†’ FAIL (ZeroDivisionError)
   - Memory retrieval (empty on first run, shows 0 similar fixes)
   - Aider generates fix (adds `if b == 0: return None`)
   - Test re-run β†’ PASS
   - SAST scan β†’ PASS (no security issues in this simple fix)
   - Supply chain β†’ PASS (no new packages)
   - Adversarial review β†’ one of three models may flag the silent return, providing guidance
   - PR submitted β†’ link shown in log

### Step 4 β€” Show the PR

Navigate to your GitHub repo. A PR will be open titled `[Rhodawk] Auto-heal: test_calculator.py`. The diff shows the minimal fix. The PR description explains every gate that was passed.

### Step 5 β€” Show the data flywheel

1. Run the audit again (or on a second repo with a similar failure)
2. This time, the memory retrieval will show a match from the first run
3. The fix prompt includes context from the previous successful fix
4. The fix is faster and more precise

### Step 6 β€” Show the adversarial review tab

In the Audit Trail tab, find the ADVERSARIAL_REVIEW event. Show:
- `consensus_votes`: `{"APPROVE": 2, "CONDITIONAL": 1}`
- `consensus_fraction`: 0.67
- `confidence`: 0.84
- `critical_issues`: [] (empty β€” fix passed)

This is the evidence that three independent models reviewed the diff and two of them approved it.

### Step 7 β€” Enable harvester (optional, advanced demo)

Set `RHODAWK_HARVESTER_ENABLED=true` in Secrets. Restart the Space.

Go to the **Harvester** tab. Refresh the feed. Show the list of public repositories with failing CI that Rhodawk has identified autonomously. Explain that without any human input, the system is finding its own targets.

---

## 10. How the PoC Convinces Investors for $10M

The PoC does not need to claim anything. It shows these five things live:

**1. The loop closes.** The investor watches Rhodawk take a broken test, generate a fix, verify the fix actually makes the test pass, and submit a PR. This is real code running in real time. The PR is on GitHub. It is publicly visible. This alone demonstrates more than any pitch deck slide.

**2. The safety pipeline is real.** Show the Audit Trail. Every SAST scan, every adversarial review, every supply chain check is logged with a SHA-256 hash. Every finding is structured JSON. This is not a demo environment β€” this is the production pipeline. An investor can inspect every log entry and verify independently.

**3. The data flywheel is accumulating.** Run the audit twice. Show that the second run retrieves the first fix from memory and uses it. This is the first evidence of the self-improvement loop. With 10,000 runs, that database becomes the proprietary asset that no competitor can replicate without running 10,000 audits.

**4. It works on languages the investor cares about.** If the investor's portfolio companies use Java or Go, point the harvester at a Java or Go repo. The system adapts automatically. This demonstrates the seven-language runtime abstraction.

**5. The autonomous mode is real.** With `RHODAWK_HARVESTER_ENABLED=true`, show the harvester feed: a list of public repos with failing CI that Rhodawk found on its own in the last 6 hours. This is not a feature on a roadmap. It is running right now, in this demo.

**What to say to close:**

> "You just watched an AI system find a broken test, understand why it is broken, write a fix, mathematically verify the fix, pass it through three independent security reviewers, and submit it to GitHub β€” without a single human action after pressing one button. We have a seven-language runtime, a growing proprietary dataset of failure-to-fix pairs that no competitor can buy or copy, and an autonomous mode that finds its own targets. The question is not whether this works. You just watched it work. The question is how fast we can scale the data flywheel before a well-funded competitor catches up."

---

## 11. Investor Pitch Deck

### Slide 1 β€” The Hook

**Every day, millions of CI builds fail and stay broken.**
Engineers are paid $200,000/year to fix them manually.
We automated the entire loop.

---

### Slide 2 β€” The Problem

- 30-40% of engineering time is debugging, not shipping
- CI failures block deployments, which block revenue
- AI coding tools (Copilot, Cursor) require a human in the loop for every suggestion
- Security teams cannot review every AI-generated diff
- No system learns from past fixes across repos

---

### Slide 3 β€” The Solution

**Rhodawk AI: Autonomous DevSecOps Control Plane**

1. Detects failing tests in any repo across 7 languages
2. Generates a fix using Aider + OpenRouter LLMs
3. Verifies the fix by re-running the test
4. Passes the diff through 5 independent safety gates
5. Submits a verified, safe, human-ready PR
6. Learns from every outcome to improve future fixes

**Human effort required: zero.**

---

### Slide 4 β€” Why It Is Safe

Most AI coding tools generate code and stop. Rhodawk generates code and then attacks its own output.

**5 independent safety layers, all running before the PR leaves the system:**

| Gate | Technology | Catches |
|---|---|---|
| Test verification | Language-native test runner | Fixes that don't work |
| SAST | bandit + semgrep + 16 custom patterns | Security vulnerabilities |
| Supply chain | pip-audit + CVE scan + typosquatting | Malicious dependencies |
| Z3 formal | Microsoft Research SMT solver | Mathematical errors |
| Adversarial | 3 LLMs, concurrent, majority vote | Everything the other gates miss |

---

### Slide 5 β€” The Data Flywheel

Every fix attempt is stored: `(failure_output, diff, outcome, adversarial_verdict)`.

This becomes proprietary training data. After 100,000 fixes:
- The embedding memory retrieves near-identical past fixes in milliseconds
- Fix quality on known failure patterns approaches certainty
- No competitor can replicate this without running 100,000 audits

**The moat is not the model. The moat is the data.**

---

### Slide 6 β€” The Autonomous Loop

In antagonist mode, Rhodawk:
1. Searches GitHub for public repos with failing CI (across 7 languages)
2. Scores targets by star count, recency, and failure severity
3. Dispatches audits automatically, every 6 hours
4. Submits PRs to any public repository (via fork-and-PR)

**No human input required at any stage.**

This is a machine that makes open source software more reliable, continuously, autonomously.

---

### Slide 7 β€” Market Size

| Market | Size |
|---|---|
| Global DevOps tools market | $15B+ (2024) |
| Application security market | $22B+ (2024) |
| AI in software development | $7B+ (2024), growing 40%+ YoY |
| Addressable: enterprises with failing CI + no fix budget | Millions of repos |

Every GitHub organization with a CI/CD pipeline is a potential customer.

---

### Slide 8 β€” Business Model

**SaaS, Seat-Based + Usage**

| Tier | Price | Includes |
|---|---|---|
| Startup | $499/mo | 5 repos, 100 audits/mo, 3 users |
| Growth | $2,499/mo | 25 repos, unlimited audits, 20 users, webhook integration |
| Enterprise | $10,000+/mo | Unlimited repos, self-hosted, GitHub App, SLA, SOC 2 evidence |
| Per-PR | $10/PR resolved | Pay per verified, merged fix (usage-based alternative) |

**Expansion revenue:** fine-tuned model API β€” sell access to the Rhodawk-specific model trained on proprietary fix data to enterprise customers who want the best model for their language/stack.

---

### Slide 9 β€” Competitive Differentiation

| Dimension | Rhodawk | Copilot | Devin | Dependabot | Snyk |
|---|---|---|---|---|---|
| Autonomous (no human) | βœ… | ❌ | Partial | βœ… (deps only) | ❌ |
| Closes the loop (re-runs tests) | βœ… | ❌ | ❌ | ❌ | ❌ |
| Multi-model adversarial review | βœ… | ❌ | ❌ | ❌ | ❌ |
| Formal verification (Z3) | βœ… | ❌ | ❌ | ❌ | ❌ |
| Supply chain gate | βœ… | ❌ | ❌ | Partial | βœ… |
| Self-improving memory | βœ… | ❌ | ❌ | ❌ | ❌ |
| 7-language runtime | βœ… | βœ… | Partial | Partial | βœ… |
| Autonomous target selection | βœ… | ❌ | ❌ | ❌ | ❌ |
| SOC 2 audit trail | βœ… | ❌ | ❌ | ❌ | Partial |

---

### Slide 10 β€” The Ask

**Raising: $10M Seed**

| Allocation | Amount | Purpose |
|---|---|---|
| Engineering (Year 1) | $4.5M | 6 senior engineers, 2 ML engineers |
| Infrastructure | $1.5M | GPU compute for LoRA training, Qdrant cluster, multi-region |
| Sales & Marketing | $2.0M | 4 enterprise sales, dev relations, content |
| Legal & Compliance | $0.5M | SOC 2 Type II audit, IP protection, enterprise contracts |
| Reserve | $1.5M | 18-month runway buffer |

**Milestones for $10M:**
- Month 3: 10 paying enterprise customers, 500+ PRs submitted
- Month 6: SOC 2 Type II certified, GitHub Marketplace listing
- Month 12: 1,000 paying teams, first LoRA fine-tuned model released
- Month 18: Series A ready β€” $5M ARR, 10,000 repos under management

---

## 12. Business Model

### Revenue Streams

**1. SaaS subscriptions** β€” the primary stream. Enterprise teams pay monthly for continuous autonomous CI healing across their repos. Pricing scales with repo count and audit volume.

**2. Per-PR pricing** β€” pay only when Rhodawk successfully fixes something. Low friction entry point for SMBs. Converts to subscription at scale.

**3. Proprietary model API** β€” after accumulating 100,000+ fix pairs, the LoRA-fine-tuned Rhodawk model is demonstrably better than GPT-4 at code repair for specific language/framework combinations. This model is sold as an API to enterprises who want the best available model for their stack.

**4. Open source contribution credits** β€” public leaderboard showing which companies' Rhodawk instances have contributed the most merged PRs to open source. Reputational value for enterprises with OSS commitments. Premium tier includes a verified badge system.

### Unit Economics

- Average enterprise deal: $5,000-$15,000/month
- Gross margin: ~80% (primary cost is GPU inference, not human labor)
- Customer acquisition cost: low (product-led growth via open source Space, GitHub Marketplace)
- Expansion: natural upsell from Startup β†’ Growth β†’ Enterprise as repos scale

---

## 13. Competitive Moat

**Moat 1 β€” The data asset.** The training store accumulates proprietary (failure, fix, outcome) triples that are specific to real-world CI failures. After 100,000 examples, no competitor who starts today can replicate this without running their own 100,000 audits. The data compounds.

**Moat 2 β€” The safety pipeline architecture.** The combination of closed verification loop + multi-model adversarial consensus + Z3 formal verification + supply chain gate is unique. It takes 12-18 months for a well-funded team to replicate all five layers with production quality. Rhodawk already has all five running.

**Moat 3 β€” Language runtime coverage.** Seven language runtimes, each with language-specific SAST, supply chain checking, test discovery, and fix prompts. Each runtime took significant engineering to get right. Competitors typically ship Python-only and spend months adding each additional language.

**Moat 4 β€” The GitHub network effect.** Every PR that Rhodawk submits to a public repo creates a public record: "Fixed by Rhodawk AI." Maintainers who merge those PRs become aware of the product. The open source community becomes both user base and distribution channel.

**Moat 5 β€” The autonomous loop.** With the harvester running, Rhodawk is submitting PRs to repositories whose maintainers have never heard of it. The first time a maintainer merges a Rhodawk PR, they are a warm lead. This is viral distribution at machine speed.

---

## 14. Roadmap

### Phase 1 β€” PoC (Now β†’ Month 3)

- [x] 7-language runtime (Python, JS, TS, Java, Go, Rust, Ruby)
- [x] Closed verification loop
- [x] 5-layer safety pipeline
- [x] Concurrent 3-model adversarial consensus
- [x] Z3 formal verification gate
- [x] Conviction-based auto-merge
- [x] Autonomous repo harvester
- [x] Fork-and-PR for any public repo
- [x] LoRA training data scheduler
- [x] Process-isolated worker pool
- [x] SHA-256 chained audit trail
- [ ] SWE-bench Verified baseline score
- [ ] First 10 paying customers

### Phase 2 β€” Scale (Month 3 β†’ 9)

- [ ] SOC 2 Type II certification
- [ ] GitHub Marketplace listing
- [ ] GitHub App (enterprise auth, org-wide installation)
- [ ] C# / .NET runtime
- [ ] PHP runtime
- [ ] Multi-tenant SaaS with tenant-isolated databases
- [ ] First LoRA fine-tune run on accumulated data
- [ ] Distributed job queue (PostgreSQL backend)
- [ ] Customer dashboard (separate from Gradio β€” Next.js)

### Phase 3 β€” Moat (Month 9 β†’ 18)

- [ ] Rhodawk-specific fine-tuned model API
- [ ] Firecracker microVM execution isolation
- [ ] Multi-region deployment (EU, Asia-Pacific)
- [ ] Enterprise SSO (SAML, OIDC)
- [ ] PR merge rate analytics dashboard for enterprise customers
- [ ] Automatic SWE-bench regression testing on every model update
- [ ] Series A at $5M ARR

---

## 15. Risk Register

| Risk | Severity | Probability | Mitigation |
|---|---|---|---|
| LLM generates malicious code | High | Low | 5-layer safety pipeline. SAST + supply chain + adversarial + Z3 + test verification. All running before any PR is submitted. |
| False positives block valid fixes | Medium | Medium | Conviction engine only fires on high confidence. Low-confidence fixes go to human review, not rejection. |
| GitHub rate limits | Medium | Medium | Exponential backoff (tenacity). Worker pool respects rate limits. Webhook mode reduces polling. |
| LLM model availability (OpenRouter) | Medium | Low | 3-model adversarial chain provides fallback. Sequential mode available if concurrent fails. |
| Repository owner rejects PRs | Low | High | Expected and fine. Every rejected PR is a learning signal. Rejection data improves future fix quality. |
| Supply chain attack on Rhodawk itself | High | Very Low | Rhodawk's own dependencies are pinned in requirements.txt. The supply chain gate protects target repos, not itself β€” Rhodawk's own supply chain is managed by the team. |
| GDPR / data privacy for private repos | High | Medium | Private repo code never leaves the customer's infrastructure in self-hosted mode. HuggingFace Space mode uses OpenRouter (processes prompts only, no persistent storage). Enterprise contracts include data processing agreements. |
| Competitor ships similar product | Medium | Medium | First-mover on the full pipeline + data flywheel. 12-18 month advantage. Prioritize data accumulation over feature parity battles. |

---

## 16. Team Requirements

### Founding Team (to close Series Seed)

| Role | Responsibilities | Must-have background |
|---|---|---|
| CEO / Founder | Vision, fundraising, enterprise sales, partnerships | Has shipped developer tooling. Can explain Z3 to a CFO without notes. |
| CTO | Architecture, engineering hiring, technical roadmap | Python/Go. Has built multi-tenant SaaS. Understands formal verification (not just as a concept). |
| Head of ML | Embedding models, LoRA training pipeline, benchmark strategy | Transformers, PEFT, SFT. Published or shipped models before. |

### Year 1 Hires (from $10M raise)

| Hire | When | Why |
|---|---|---|
| 2Γ— Senior Backend Engineers | Month 1-2 | Multi-tenant infrastructure, distributed job queue |
| 1Γ— Enterprise Sales (Technical) | Month 2 | Closes first 10 enterprise deals |
| 1Γ— ML Engineer | Month 3 | LoRA training pipeline, model evaluation |
| 1Γ— DevRel / Developer Advocate | Month 4 | GitHub community, OSS contribution strategy |
| 1Γ— Security Engineer | Month 6 | SOC 2 audit, security review of Rhodawk itself |
| 1Γ— Senior Frontend Engineer | Month 6 | Replace Gradio dashboard with production Next.js UI |

---

## 17. Legal and Compliance

### Intellectual Property

- All code in this repository is proprietary
- The training data accumulated in `training_store.sqlite` is a proprietary business asset
- The embedding index is a derived work produced by running the system β€” also proprietary
- The company should file provisional patents on: (1) the concurrent adversarial consensus architecture, (2) the conviction-gate multi-criteria auto-merge system, (3) the autonomous CI-failure-to-PR pipeline with closed verification loop

### Open Source Usage

Rhodawk uses open-source dependencies. All major dependencies (Aider, Gradio, sentence-transformers, Z3, Qdrant) are licensed permissively (Apache 2.0, MIT) or have commercial-use-friendly licenses. Verify each dependency's license before commercial deployment.

### GitHub Terms of Service

Fork-and-PR mode is fully compliant with GitHub's Terms of Service. Forking a public repository and submitting pull requests is a core, intended workflow on GitHub. The system does not access private repositories without explicit authorization.

### Data Privacy

- In HuggingFace Spaces mode: code snippets from target repos are sent to OpenRouter for LLM inference. OpenRouter's privacy policy applies.
- In self-hosted mode: all processing is local. Nothing leaves the customer's infrastructure.
- Enterprise contracts should include: Data Processing Agreement (DPA), data retention policy (training store deletion schedule), and explicit scope of what data is processed.

### SOC 2 Readiness

The SHA-256 chained audit trail (`audit_logger.py`) produces evidence compatible with SOC 2 Type II requirements for:
- CC6.1 (logical access controls)
- CC7.2 (system monitoring)
- CC8.1 (change management β€” every AI-generated code change is logged and hashed)
- CC9.2 (risk mitigation β€” adversarial review and SAST gate provide documented risk controls)

---

## Appendix A β€” Commit Hash Verification

The code described in this document is exactly the code at:

```
Repository: Architect8999/rhodawk-ai-devops-engine
Platform:   HuggingFace Spaces
Commit:     8a23fcf
Branch:     main
```

Verify: `https://huggingface.co/spaces/Architect8999/rhodawk-ai-devops-engine/tree/main`

Every mechanism described in this playbook can be verified by reading the source code at the above commit. There are no undisclosed capabilities and no features described that are not implemented in the committed code.

---

## Appendix B β€” Quick Glossary

| Term | Meaning in this system |
|---|---|
| **Audit** | A full run of Rhodawk against one repository: discover β†’ test β†’ heal β†’ PR |
| **Healing loop** | The retry cycle for one failing test: fix β†’ verify β†’ gate β†’ retry |
| **Adversarial review** | The 3-model concurrent consensus security review of a diff |
| **Conviction** | The 7-criteria gate that allows autonomous merge without human review |
| **Data flywheel** | The self-improvement loop: more fixes β†’ better memory β†’ better future fixes |
| **Harvester** | The daemon that finds its own targets on GitHub autonomously |
| **CEGIS** | Counterexample-Guided Inductive Synthesis β€” the formal methods loop in the red team fuzzer |
| **LoRA** | Low-Rank Adaptation β€” the fine-tuning method used to train lightweight model adapters on the accumulated fix data |
| **Fork mode** | Fixing any public repo without push access by forking it first |
| **SAST** | Static Application Security Testing β€” code scanning without running the code |
| **SMT solver** | Satisfiability Modulo Theories β€” the mathematical engine inside Z3 |
| **Embedding** | A vector representation of text that captures semantic meaning for similarity search |
| **MCP** | Model Context Protocol β€” the tool interface that gives Aider access to documentation and GitHub |

---

*Rhodawk AI β€” Founder Playbook v4.0*
*Generated from live source code at commit `8a23fcf`*
*All mechanisms described here are implemented, committed, and verifiable.*