@nomos-arc/arc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/.claude/settings.local.json +10 -0
  2. package/.nomos-config.json +5 -0
  3. package/CLAUDE.md +108 -0
  4. package/LICENSE +190 -0
  5. package/README.md +569 -0
  6. package/dist/cli.js +21120 -0
  7. package/docs/auth/googel_plan.yaml +1093 -0
  8. package/docs/auth/google_task.md +235 -0
  9. package/docs/auth/hardened_blueprint.yaml +1658 -0
  10. package/docs/auth/red_team_report.yaml +336 -0
  11. package/docs/auth/session_state.yaml +162 -0
  12. package/docs/certificate/cer_enhance_plan.md +605 -0
  13. package/docs/certificate/certificate_report.md +338 -0
  14. package/docs/dev_overview.md +419 -0
  15. package/docs/feature_assessment.md +156 -0
  16. package/docs/how_it_works.md +78 -0
  17. package/docs/infrastructure/map.md +867 -0
  18. package/docs/init/master_plan.md +3581 -0
  19. package/docs/init/red_team_report.md +215 -0
  20. package/docs/init/report_phase_1a.md +304 -0
  21. package/docs/integrity-gate/enhance_drift.md +703 -0
  22. package/docs/integrity-gate/overview.md +108 -0
  23. package/docs/management/manger-task.md +99 -0
  24. package/docs/management/scafffold.md +76 -0
  25. package/docs/map/ATOMIC_BLUEPRINT.md +1349 -0
  26. package/docs/map/RED_TEAM_REPORT.md +159 -0
  27. package/docs/map/map_task.md +147 -0
  28. package/docs/map/semantic_graph_task.md +792 -0
  29. package/docs/map/semantic_master_plan.md +705 -0
  30. package/docs/phase7/TEAM_RED.md +249 -0
  31. package/docs/phase7/plan.md +1682 -0
  32. package/docs/phase7/task.md +275 -0
  33. package/docs/prompts/USAGE.md +312 -0
  34. package/docs/prompts/architect.md +165 -0
  35. package/docs/prompts/executer.md +190 -0
  36. package/docs/prompts/hardener.md +190 -0
  37. package/docs/prompts/red_team.md +146 -0
  38. package/docs/verification/goveranance-overview.md +396 -0
  39. package/docs/verification/governance-overview.md +245 -0
  40. package/docs/verification/verification-arc-ar.md +560 -0
  41. package/docs/verification/verification-architecture.md +560 -0
  42. package/docs/very_next.md +52 -0
  43. package/docs/whitepaper.md +89 -0
  44. package/overview.md +1469 -0
  45. package/package.json +63 -0
  46. package/src/adapters/__tests__/git.test.ts +296 -0
  47. package/src/adapters/__tests__/stdio.test.ts +70 -0
  48. package/src/adapters/git.ts +226 -0
  49. package/src/adapters/pty.ts +159 -0
  50. package/src/adapters/stdio.ts +113 -0
  51. package/src/cli.ts +83 -0
  52. package/src/commands/apply.ts +47 -0
  53. package/src/commands/auth.ts +301 -0
  54. package/src/commands/certificate.ts +89 -0
  55. package/src/commands/discard.ts +24 -0
  56. package/src/commands/drift.ts +116 -0
  57. package/src/commands/index.ts +78 -0
  58. package/src/commands/init.ts +121 -0
  59. package/src/commands/list.ts +75 -0
  60. package/src/commands/map.ts +55 -0
  61. package/src/commands/plan.ts +30 -0
  62. package/src/commands/review.ts +58 -0
  63. package/src/commands/run.ts +63 -0
  64. package/src/commands/search.ts +147 -0
  65. package/src/commands/show.ts +63 -0
  66. package/src/commands/status.ts +59 -0
  67. package/src/core/__tests__/budget.test.ts +213 -0
  68. package/src/core/__tests__/certificate.test.ts +385 -0
  69. package/src/core/__tests__/config.test.ts +191 -0
  70. package/src/core/__tests__/preflight.test.ts +24 -0
  71. package/src/core/__tests__/prompt.test.ts +358 -0
  72. package/src/core/__tests__/review.test.ts +161 -0
  73. package/src/core/__tests__/state.test.ts +362 -0
  74. package/src/core/auth/__tests__/manager.test.ts +166 -0
  75. package/src/core/auth/__tests__/server.test.ts +220 -0
  76. package/src/core/auth/gcp-projects.ts +160 -0
  77. package/src/core/auth/manager.ts +114 -0
  78. package/src/core/auth/server.ts +141 -0
  79. package/src/core/budget.ts +119 -0
  80. package/src/core/certificate.ts +502 -0
  81. package/src/core/config.ts +212 -0
  82. package/src/core/errors.ts +54 -0
  83. package/src/core/factory.ts +49 -0
  84. package/src/core/graph/__tests__/builder.test.ts +272 -0
  85. package/src/core/graph/__tests__/contract-writer.test.ts +175 -0
  86. package/src/core/graph/__tests__/enricher.test.ts +299 -0
  87. package/src/core/graph/__tests__/parser.test.ts +200 -0
  88. package/src/core/graph/__tests__/pipeline.test.ts +202 -0
  89. package/src/core/graph/__tests__/renderer.test.ts +128 -0
  90. package/src/core/graph/__tests__/resolver.test.ts +185 -0
  91. package/src/core/graph/__tests__/scanner.test.ts +231 -0
  92. package/src/core/graph/__tests__/show.test.ts +134 -0
  93. package/src/core/graph/builder.ts +303 -0
  94. package/src/core/graph/constraints.ts +94 -0
  95. package/src/core/graph/contract-writer.ts +93 -0
  96. package/src/core/graph/drift/__tests__/classifier.test.ts +215 -0
  97. package/src/core/graph/drift/__tests__/comparator.test.ts +335 -0
  98. package/src/core/graph/drift/__tests__/drift.test.ts +453 -0
  99. package/src/core/graph/drift/__tests__/reporter.test.ts +203 -0
  100. package/src/core/graph/drift/classifier.ts +165 -0
  101. package/src/core/graph/drift/comparator.ts +205 -0
  102. package/src/core/graph/drift/reporter.ts +77 -0
  103. package/src/core/graph/enricher.ts +251 -0
  104. package/src/core/graph/grammar-paths.ts +30 -0
  105. package/src/core/graph/html-template.ts +493 -0
  106. package/src/core/graph/map-schema.ts +137 -0
  107. package/src/core/graph/parser.ts +336 -0
  108. package/src/core/graph/pipeline.ts +209 -0
  109. package/src/core/graph/renderer.ts +92 -0
  110. package/src/core/graph/resolver.ts +195 -0
  111. package/src/core/graph/scanner.ts +145 -0
  112. package/src/core/logger.ts +46 -0
  113. package/src/core/orchestrator.ts +792 -0
  114. package/src/core/plan-file-manager.ts +66 -0
  115. package/src/core/preflight.ts +64 -0
  116. package/src/core/prompt.ts +173 -0
  117. package/src/core/review.ts +95 -0
  118. package/src/core/state.ts +294 -0
  119. package/src/core/worktree-coordinator.ts +77 -0
  120. package/src/search/__tests__/chunk-extractor.test.ts +339 -0
  121. package/src/search/__tests__/embedder-auth.test.ts +124 -0
  122. package/src/search/__tests__/embedder.test.ts +267 -0
  123. package/src/search/__tests__/graph-enricher.test.ts +178 -0
  124. package/src/search/__tests__/indexer.test.ts +518 -0
  125. package/src/search/__tests__/integration.test.ts +649 -0
  126. package/src/search/__tests__/query-engine.test.ts +334 -0
  127. package/src/search/__tests__/similarity.test.ts +78 -0
  128. package/src/search/__tests__/vector-store.test.ts +281 -0
  129. package/src/search/chunk-extractor.ts +167 -0
  130. package/src/search/embedder.ts +209 -0
  131. package/src/search/graph-enricher.ts +95 -0
  132. package/src/search/indexer.ts +483 -0
  133. package/src/search/lexical-searcher.ts +190 -0
  134. package/src/search/query-engine.ts +225 -0
  135. package/src/search/vector-store.ts +311 -0
  136. package/src/types/index.ts +572 -0
  137. package/src/utils/__tests__/ansi.test.ts +54 -0
  138. package/src/utils/__tests__/frontmatter.test.ts +79 -0
  139. package/src/utils/__tests__/sanitize.test.ts +229 -0
  140. package/src/utils/ansi.ts +19 -0
  141. package/src/utils/context.ts +44 -0
  142. package/src/utils/frontmatter.ts +27 -0
  143. package/src/utils/sanitize.ts +78 -0
  144. package/test/e2e/lifecycle.test.ts +330 -0
  145. package/test/fixtures/mock-planner-hang.ts +5 -0
  146. package/test/fixtures/mock-planner.ts +26 -0
  147. package/test/fixtures/mock-reviewer-bad.ts +8 -0
  148. package/test/fixtures/mock-reviewer-retry.ts +34 -0
  149. package/test/fixtures/mock-reviewer.ts +18 -0
  150. package/test/fixtures/sample-project/src/circular-a.ts +6 -0
  151. package/test/fixtures/sample-project/src/circular-b.ts +6 -0
  152. package/test/fixtures/sample-project/src/config.ts +15 -0
  153. package/test/fixtures/sample-project/src/main.ts +19 -0
  154. package/test/fixtures/sample-project/src/services/product-service.ts +20 -0
  155. package/test/fixtures/sample-project/src/services/user-service.ts +18 -0
  156. package/test/fixtures/sample-project/src/types.ts +14 -0
  157. package/test/fixtures/sample-project/src/utils/index.ts +14 -0
  158. package/test/fixtures/sample-project/src/utils/validate.ts +12 -0
  159. package/tsconfig.json +20 -0
  160. package/vitest.config.ts +12 -0
@@ -0,0 +1,89 @@
1
+ # Towards Deterministic Governance in Stochastic AI-Assisted Software Engineering: The nomos-arc.ai Framework
2
+
3
+ **Author:** Ibrahim Magdy
4
+ **Lead Architect & CEO, nomos-arc.ai** **Date:** April 12, 2026
5
+ **Subject:** Software Architecture & AI Orchestration
6
+
7
+ ---
8
+
9
+ ## Abstract
10
+ The rapid adoption of Large Language Models (LLMs) in software development has introduced a critical paradox: while generative velocity has increased, architectural integrity is eroding. Current AI coding tools operate on a stochastic basis, prioritizing local syntactic correctness over global structural coherence. This paper proposes **nomos-arc.ai**, a deterministic governance framework that acts as an "Architectural Compiler." By implementing a multi-layered verification pipeline, cryptographic integrity chains, and mathematical quality metrics, nomos-arc.ai bridges the gap between probabilistic AI generation and verifiable engineering standards.
11
+
12
+ ---
13
+
14
+ ## 1. Introduction: The Stochastic Entropy Problem
15
+ Generative AI models are fundamentally probabilistic. In the context of software engineering, this leads to **Architectural Drift**, where AI-generated changes satisfy immediate functional requirements but violate long-term maintainability constraints. The "Stochastic Gap" is defined as the variance between the AI’s predicted solution and the system’s formal architectural requirements.
16
+
17
+ nomos-arc.ai introduces the concept of **Constraint Conformance**, shifting the paradigm from "Code Generation" to "Verifiable Intent."
18
+
19
+ ---
20
+
21
+ ## 2. Theoretical Framework: The Northbridge-Southbridge Model
22
+ nomos-arc.ai architecture is modeled after high-performance hardware controllers, bifurcating duties into two logical bridges:
23
+
24
+ ### 2.1 The Northbridge (Cognitive Control)
25
+ Responsible for high-level reasoning and architectural verification. It manages the **Intermediate Representation (IR)** of the codebase, embodied in the `project_map.json`.
26
+ * **Symbolic Reasoning:** Utilizing Abstract Syntax Trees (AST) to resolve dependencies.
27
+ * **Inference Engine:** Validating AI plans against a hierarchical rules engine.
28
+
29
+ ### 2.2 The Southbridge (Operational I/O)
30
+ Manages the deterministic environment where code is executed and tested.
31
+ * **Worktree Isolation:** Ensuring zero-side-effect execution environments.
32
+ * **Baseline Capture:** Capturing the pre-execution state $S_{base}$ to evaluate relative delta $\Delta$.
33
+
34
+ ---
35
+
36
+ ## 3. Mathematical Foundations of Quality Enforcement
37
+
38
+ To move beyond subjective code reviews, nomos-arc.ai utilizes the **Maintainability Index (MI)** as a hard gate for convergence.
39
+
40
+ ### 3.1 The Maintainability Index Formula
41
+ The system computes the MI for every affected module using the following derived formula:
42
+
43
+ $$MI = \max\left(0, \frac{171 - 5.2 \ln(V) - 0.23 G - 16.2 \ln(L)}{171} \times 100\right)$$
44
+
45
+ Where:
46
+ * $V$ = **Halstead Volume**, representing the information density: $V = (N_1 + N_2) \log_2(n_1 + n_2)$.
47
+ * $G$ = **Cyclomatic Complexity**, representing the number of independent paths through the source code.
48
+ * $L$ = **Logical Lines of Code (LLOC)**, derived from statement nodes in the AST.
49
+
50
+ ### 3.2 Dynamic Convergence Thresholds
51
+ nomos-arc.ai does not use static approval scores. The required threshold $T_{req}$ is a function of the **Blast Radius** $B_r$:
52
+
53
+ $$T_{req} = T_{base} + \alpha \cdot \log(B_r + 1)$$
54
+
55
+ Where $B_r$ is the count of direct and indirect dependents in the dependency graph. This ensures that core modules require a higher degree of verification ($>98\%$) compared to peripheral modules.
56
+
57
+ ---
58
+
59
+ ## 4. The 8-Step Verifiable Pipeline
60
+ nomos-arc.ai implements a deterministic finite state machine (FSM) to orchestrate the AI’s workflow:
61
+
62
+ 1. **State Snapshot ($\sigma_0$):** Capture baseline metrics ($L_0, G_0, MI_0$).
63
+ 2. **Contract Drafting:** Generation of a structured "Plan of Intent."
64
+ 3. **Projected AST Validation:** Verifying symbol references in the proposed plan against a virtualized future state of the graph.
65
+ 4. **Shadow Execution:** Physical file mutation in an isolated Git worktree.
66
+ 5. **Hard Gating:** Compiler-level verification. If $Build(C) = Fail$, the iteration is discarded.
67
+ 6. **Soft Gating & Scoring:** AI-assisted review for semantic alignment and style.
68
+ 7. **Delta Analysis ($\Delta \sigma$):** Verification that $\sigma_{new} \ge \sigma_0$ (Relative non-regression).
69
+ 8. **Cryptographic Attestation:** Issuing a SHA-256 hash chain linking the task, plan, and final diff.
70
+
71
+ ---
72
+
73
+ ## 5. Architectural Drift Detection
74
+ nomos-arc.ai defines **Structural Drift** ($\Delta_{drift}$) as the divergence between the baseline graph $G_b$ and the current graph $G_c$.
75
+
76
+ $$\Delta_{drift} = (E_c \setminus E_b) \cup (V_c \setminus V_b)$$
77
+
78
+ Where $V$ represents the set of symbols (vertices) and $E$ represents the set of dependencies (edges). nomos-arc.ai classifies these drifts into:
79
+ * **Breaking Drift:** Removal of exported symbols with $B_r > 0$.
80
+ * **Quality Drift:** Regression in $MI$ below the configured floor.
81
+
82
+ ---
83
+
84
+ ## 6. Conclusion: The "Compiler for Intent"
85
+ nomos-arc.ai redefines the role of AI in the software lifecycle. By acting as a **Deterministic Validator** for **Stochastic Generators**, it ensures that software evolution is governed by engineering rigor rather than probabilistic luck. The framework provides a verifiable path toward autonomous engineering where the machine is not just a co-author, but a self-regulating architect.
86
+
87
+ ---
88
+ *© 2026 nomos-arc.ai Research. All Rights Reserved.*
89
+