@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.
- package/.claude/settings.local.json +10 -0
- package/.nomos-config.json +5 -0
- package/CLAUDE.md +108 -0
- package/LICENSE +190 -0
- package/README.md +569 -0
- package/dist/cli.js +21120 -0
- package/docs/auth/googel_plan.yaml +1093 -0
- package/docs/auth/google_task.md +235 -0
- package/docs/auth/hardened_blueprint.yaml +1658 -0
- package/docs/auth/red_team_report.yaml +336 -0
- package/docs/auth/session_state.yaml +162 -0
- package/docs/certificate/cer_enhance_plan.md +605 -0
- package/docs/certificate/certificate_report.md +338 -0
- package/docs/dev_overview.md +419 -0
- package/docs/feature_assessment.md +156 -0
- package/docs/how_it_works.md +78 -0
- package/docs/infrastructure/map.md +867 -0
- package/docs/init/master_plan.md +3581 -0
- package/docs/init/red_team_report.md +215 -0
- package/docs/init/report_phase_1a.md +304 -0
- package/docs/integrity-gate/enhance_drift.md +703 -0
- package/docs/integrity-gate/overview.md +108 -0
- package/docs/management/manger-task.md +99 -0
- package/docs/management/scafffold.md +76 -0
- package/docs/map/ATOMIC_BLUEPRINT.md +1349 -0
- package/docs/map/RED_TEAM_REPORT.md +159 -0
- package/docs/map/map_task.md +147 -0
- package/docs/map/semantic_graph_task.md +792 -0
- package/docs/map/semantic_master_plan.md +705 -0
- package/docs/phase7/TEAM_RED.md +249 -0
- package/docs/phase7/plan.md +1682 -0
- package/docs/phase7/task.md +275 -0
- package/docs/prompts/USAGE.md +312 -0
- package/docs/prompts/architect.md +165 -0
- package/docs/prompts/executer.md +190 -0
- package/docs/prompts/hardener.md +190 -0
- package/docs/prompts/red_team.md +146 -0
- package/docs/verification/goveranance-overview.md +396 -0
- package/docs/verification/governance-overview.md +245 -0
- package/docs/verification/verification-arc-ar.md +560 -0
- package/docs/verification/verification-architecture.md +560 -0
- package/docs/very_next.md +52 -0
- package/docs/whitepaper.md +89 -0
- package/overview.md +1469 -0
- package/package.json +63 -0
- package/src/adapters/__tests__/git.test.ts +296 -0
- package/src/adapters/__tests__/stdio.test.ts +70 -0
- package/src/adapters/git.ts +226 -0
- package/src/adapters/pty.ts +159 -0
- package/src/adapters/stdio.ts +113 -0
- package/src/cli.ts +83 -0
- package/src/commands/apply.ts +47 -0
- package/src/commands/auth.ts +301 -0
- package/src/commands/certificate.ts +89 -0
- package/src/commands/discard.ts +24 -0
- package/src/commands/drift.ts +116 -0
- package/src/commands/index.ts +78 -0
- package/src/commands/init.ts +121 -0
- package/src/commands/list.ts +75 -0
- package/src/commands/map.ts +55 -0
- package/src/commands/plan.ts +30 -0
- package/src/commands/review.ts +58 -0
- package/src/commands/run.ts +63 -0
- package/src/commands/search.ts +147 -0
- package/src/commands/show.ts +63 -0
- package/src/commands/status.ts +59 -0
- package/src/core/__tests__/budget.test.ts +213 -0
- package/src/core/__tests__/certificate.test.ts +385 -0
- package/src/core/__tests__/config.test.ts +191 -0
- package/src/core/__tests__/preflight.test.ts +24 -0
- package/src/core/__tests__/prompt.test.ts +358 -0
- package/src/core/__tests__/review.test.ts +161 -0
- package/src/core/__tests__/state.test.ts +362 -0
- package/src/core/auth/__tests__/manager.test.ts +166 -0
- package/src/core/auth/__tests__/server.test.ts +220 -0
- package/src/core/auth/gcp-projects.ts +160 -0
- package/src/core/auth/manager.ts +114 -0
- package/src/core/auth/server.ts +141 -0
- package/src/core/budget.ts +119 -0
- package/src/core/certificate.ts +502 -0
- package/src/core/config.ts +212 -0
- package/src/core/errors.ts +54 -0
- package/src/core/factory.ts +49 -0
- package/src/core/graph/__tests__/builder.test.ts +272 -0
- package/src/core/graph/__tests__/contract-writer.test.ts +175 -0
- package/src/core/graph/__tests__/enricher.test.ts +299 -0
- package/src/core/graph/__tests__/parser.test.ts +200 -0
- package/src/core/graph/__tests__/pipeline.test.ts +202 -0
- package/src/core/graph/__tests__/renderer.test.ts +128 -0
- package/src/core/graph/__tests__/resolver.test.ts +185 -0
- package/src/core/graph/__tests__/scanner.test.ts +231 -0
- package/src/core/graph/__tests__/show.test.ts +134 -0
- package/src/core/graph/builder.ts +303 -0
- package/src/core/graph/constraints.ts +94 -0
- package/src/core/graph/contract-writer.ts +93 -0
- package/src/core/graph/drift/__tests__/classifier.test.ts +215 -0
- package/src/core/graph/drift/__tests__/comparator.test.ts +335 -0
- package/src/core/graph/drift/__tests__/drift.test.ts +453 -0
- package/src/core/graph/drift/__tests__/reporter.test.ts +203 -0
- package/src/core/graph/drift/classifier.ts +165 -0
- package/src/core/graph/drift/comparator.ts +205 -0
- package/src/core/graph/drift/reporter.ts +77 -0
- package/src/core/graph/enricher.ts +251 -0
- package/src/core/graph/grammar-paths.ts +30 -0
- package/src/core/graph/html-template.ts +493 -0
- package/src/core/graph/map-schema.ts +137 -0
- package/src/core/graph/parser.ts +336 -0
- package/src/core/graph/pipeline.ts +209 -0
- package/src/core/graph/renderer.ts +92 -0
- package/src/core/graph/resolver.ts +195 -0
- package/src/core/graph/scanner.ts +145 -0
- package/src/core/logger.ts +46 -0
- package/src/core/orchestrator.ts +792 -0
- package/src/core/plan-file-manager.ts +66 -0
- package/src/core/preflight.ts +64 -0
- package/src/core/prompt.ts +173 -0
- package/src/core/review.ts +95 -0
- package/src/core/state.ts +294 -0
- package/src/core/worktree-coordinator.ts +77 -0
- package/src/search/__tests__/chunk-extractor.test.ts +339 -0
- package/src/search/__tests__/embedder-auth.test.ts +124 -0
- package/src/search/__tests__/embedder.test.ts +267 -0
- package/src/search/__tests__/graph-enricher.test.ts +178 -0
- package/src/search/__tests__/indexer.test.ts +518 -0
- package/src/search/__tests__/integration.test.ts +649 -0
- package/src/search/__tests__/query-engine.test.ts +334 -0
- package/src/search/__tests__/similarity.test.ts +78 -0
- package/src/search/__tests__/vector-store.test.ts +281 -0
- package/src/search/chunk-extractor.ts +167 -0
- package/src/search/embedder.ts +209 -0
- package/src/search/graph-enricher.ts +95 -0
- package/src/search/indexer.ts +483 -0
- package/src/search/lexical-searcher.ts +190 -0
- package/src/search/query-engine.ts +225 -0
- package/src/search/vector-store.ts +311 -0
- package/src/types/index.ts +572 -0
- package/src/utils/__tests__/ansi.test.ts +54 -0
- package/src/utils/__tests__/frontmatter.test.ts +79 -0
- package/src/utils/__tests__/sanitize.test.ts +229 -0
- package/src/utils/ansi.ts +19 -0
- package/src/utils/context.ts +44 -0
- package/src/utils/frontmatter.ts +27 -0
- package/src/utils/sanitize.ts +78 -0
- package/test/e2e/lifecycle.test.ts +330 -0
- package/test/fixtures/mock-planner-hang.ts +5 -0
- package/test/fixtures/mock-planner.ts +26 -0
- package/test/fixtures/mock-reviewer-bad.ts +8 -0
- package/test/fixtures/mock-reviewer-retry.ts +34 -0
- package/test/fixtures/mock-reviewer.ts +18 -0
- package/test/fixtures/sample-project/src/circular-a.ts +6 -0
- package/test/fixtures/sample-project/src/circular-b.ts +6 -0
- package/test/fixtures/sample-project/src/config.ts +15 -0
- package/test/fixtures/sample-project/src/main.ts +19 -0
- package/test/fixtures/sample-project/src/services/product-service.ts +20 -0
- package/test/fixtures/sample-project/src/services/user-service.ts +18 -0
- package/test/fixtures/sample-project/src/types.ts +14 -0
- package/test/fixtures/sample-project/src/utils/index.ts +14 -0
- package/test/fixtures/sample-project/src/utils/validate.ts +12 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
تركيزنا الآن سينصب على تحويل **nomos-arc.ai** من مجرد أداة تحليلية إلى **محرك حوكمة (Governance Engine)**. الهدف هو بناء صمام أمان يمنع التدهور المعماري (Architectural Decay) آلياً.
|
|
2
|
+
|
|
3
|
+
إليك التصميم الهندسي لـ **CI/CD Integrity Gate**:
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. بنية المقارنة (State Differential Analysis)
|
|
8
|
+
لتحقيق الحوكمة، يجب أن ننتقل من "قراءة الخريطة" إلى "مقارنة الحالات". العملية تعتمد على مقارنة مخرجات `arc map` بين فرع الـ (Base) وفرع الـ (Feature).
|
|
9
|
+
|
|
10
|
+
### خوارزمية كشف الانحراف (Drift Detection Algorithm)
|
|
11
|
+
نعرّف "معامل التأثير المعماري" ($I$) للتعديل المقترح كدالة في عمق العقدة وعدد التبعيات المتأثرة:
|
|
12
|
+
|
|
13
|
+
$$I(\Delta) = \sum_{i \in \text{Modified}} (\omega_{d} \cdot \frac{1}{\text{depth}_i} + \omega_{c} \cdot \text{dependents}_i)$$
|
|
14
|
+
|
|
15
|
+
حيث:
|
|
16
|
+
* $\omega_{d}$: وزن العمق (كلما قل العمق، زادت الخطورة).
|
|
17
|
+
* $\omega_{c}$: وزن الاتصال (Connectivity).
|
|
18
|
+
|
|
19
|
+
إذا تجاوزت قيمة $I$ حداً معيناً (Threshold) دون وجود "شهادة مراجعة" (`arc review`) موقعة إلكترونياً، يتم كسر الـ Pipeline.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. تسلسل العمل في GitHub Action (The Pipeline Sequence)
|
|
24
|
+
|
|
25
|
+
يعمل الـ Runner وفق التسلسل التالي لضمان النزاهة:
|
|
26
|
+
|
|
27
|
+
1. **Environment Setup:** تثبيت Node.js وتهيئة مفتاح `GEMINI_API_KEY` (لعمليات الـ Enrichment إذا لزم الأمر).
|
|
28
|
+
2. **Base Map Recovery:** محاولة استعادة `project_map.json` الخاص بفرع الـ Main من الـ Cache أو إعادة توليده.
|
|
29
|
+
3. **Head Map Generation:** تشغيل `arc map` على كود الـ PR الحالي لتوليد الخريطة الجديدة.
|
|
30
|
+
4. **Semantic Diffing:** تشغيل أمر جديد مقترح وهو `arc compare --base base_map.json --head head_map.json`.
|
|
31
|
+
5. **Policy Evaluation:** التحقق من القواعد (Rules) المحددة في `.nomos-config.json`.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 3. منطق الحارس (The Gatekeeper Logic)
|
|
38
|
+
|
|
39
|
+
يجب أن يركز الـ `arc compare` على ثلاثة أنواع من الانتهاكات:
|
|
40
|
+
|
|
41
|
+
| نوع الانتهاك | الوصف التقني | الإجراء في CI |
|
|
42
|
+
| :--- | :--- | :--- |
|
|
43
|
+
| **Circular Dependency** | اكتشاف حلقة تبعية جديدة (عن طريق Tarjan's SCC). | **Block (Exit 1)** |
|
|
44
|
+
| **Core Module Bloat** | زيادة الـ `dependents_count` لموديول أساسي بنسبة > 20%. | **Warning/Block** |
|
|
45
|
+
| **Semantic Drift** | تغيير الـ `purpose` في مخرجات الـ AI دون تحديث الـ Documentation. | **Warning** |
|
|
46
|
+
| **Integrity Breach** | وجود كود معدل لا يمتلك `sha256` مطابق في الـ `CertificatePayload`. | **Block (Critical)** |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 4. نموذج الـ GitHub Action Workflow (`.github/workflows/nomos-gate.yml`)
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
name: nomos-arc Architectural Gate
|
|
54
|
+
|
|
55
|
+
on:
|
|
56
|
+
pull_request:
|
|
57
|
+
branches: [ main ]
|
|
58
|
+
|
|
59
|
+
jobs:
|
|
60
|
+
governance:
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
steps:
|
|
63
|
+
- uses: actions/checkout@v4
|
|
64
|
+
with:
|
|
65
|
+
fetch-depth: 0 # مهم للحصول على تاريخ الفروع للمقارنة
|
|
66
|
+
|
|
67
|
+
- name: Install nomos-arc.ai
|
|
68
|
+
run: npm install -g .
|
|
69
|
+
|
|
70
|
+
- name: Generate Current Map
|
|
71
|
+
run: arc map
|
|
72
|
+
env:
|
|
73
|
+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
|
74
|
+
|
|
75
|
+
- name: Run Integrity Check
|
|
76
|
+
id: nomos_check
|
|
77
|
+
run: |
|
|
78
|
+
# استدعاء أداة المقارنة
|
|
79
|
+
# ستقوم الأداة بمقارنة الخريطة الحالية بخريطة الفرع الرئيسي
|
|
80
|
+
arc compare --fail-on-drift --threshold 0.8
|
|
81
|
+
|
|
82
|
+
- name: Comment on PR
|
|
83
|
+
if: failure()
|
|
84
|
+
uses: actions/github-script@v7
|
|
85
|
+
with:
|
|
86
|
+
script: |
|
|
87
|
+
github.rest.issues.createComment({
|
|
88
|
+
issue_number: context.issue.number,
|
|
89
|
+
owner: context.repo.owner,
|
|
90
|
+
repo: context.repo.repo,
|
|
91
|
+
body: '⚠️ **nomos-arc.ai Governance Alert:** Architectural drift detected. High-impact core modules modified without proper semantic alignment. Please run `arc review` locally.'
|
|
92
|
+
})
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 5. ميزة "العقد الدلالي" (Semantic Contract Enforcement)
|
|
98
|
+
|
|
99
|
+
لإتمام هذا الربط، نحتاج لتعديل في الـ `arc-cli` يدعم:
|
|
100
|
+
* **Checkpointing:** القدرة على حفظ "بصمة" معمارية للمشروع عند كل Release مستقر.
|
|
101
|
+
* **Shadow Comparison:** مقارنة الـ AST المولد من الـ PR مقابل الـ AST المخزن في الخريطة الأصلية دون الحاجة لملفات الـ `.ts` الأصلية (لزيادة الخصوصية والسرعة).
|
|
102
|
+
|
|
103
|
+
**بهذا نضمن:**
|
|
104
|
+
1. لا يتم دمج أي كود يكسر الـ Graph.
|
|
105
|
+
2. لا يتم تغيير الـ Core Logic إلا بعلم الـ Reviewer Agent.
|
|
106
|
+
3. التوثيق (Semantic Info) يظل دائماً متزامناً مع الكود الفعلي.
|
|
107
|
+
|
|
108
|
+
هل نبدأ بصياغة خوارزمية الـ `compare` داخل الـ `src/core/` لتمكين الـ CLI من اكتشاف هذه الفروقات؟
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
تصميم ذكي وفعّال. فصل "واجهة المستخدم" (ملفات Markdown للعميل) عن "النظام العصبي" (ملفات YAML للـ AI) يحقق مبدأ **Separation of Concerns** ويسمح بتحسين الـ Tokens في الـ Prompts، حيث تتعامل الوكلاء مع بيانات مهيكلة مباشرة.
|
|
2
|
+
|
|
3
|
+
سأقوم بصياغة الهيكل المقترح لهذا النظام مع تعريف بروتوكول التشغيل لكل مرحلة.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## أولاً: الهيكل التنظيمي للمجلدات (Dual-Storage Architecture)
|
|
8
|
+
|
|
9
|
+
سيتم تقسيم البيانات إلى مستويين:
|
|
10
|
+
1. **المستوى الظاهري (Human-Readable):** تحت مسمى `tasks-management/` بصيغة `.md`.
|
|
11
|
+
2. **المستوى العميق (Machine-Readable):** تحت مسمى `.nomos/` بصيغة `.yaml`.
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
project-root/
|
|
15
|
+
├── tasks-management/ # للمطور والعميل (Human-Facing)
|
|
16
|
+
│ ├── tasks/ # [ID]-task-description.md
|
|
17
|
+
│ ├── plans/ # [ID]-implementation-plan.md
|
|
18
|
+
│ ├── reports/ # [ID]-red-team-critique.md
|
|
19
|
+
│ └── certificates/ # [ID]-completion-certificate.md
|
|
20
|
+
│
|
|
21
|
+
└── .nomos/ # لمحرك الذكاء الاصطناعي (Agent-Facing)
|
|
22
|
+
├── state/ # [ID]-lifecycle.yaml (الحالة اللحظية)
|
|
23
|
+
├── context/ # [ID]-raw-plan.yaml (بيانات تقنية مكثفة)
|
|
24
|
+
├── rules/ # architecture-constraints.yaml
|
|
25
|
+
└── graph/ # project_map.json & vector_index/
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## ثانياً: دورة حياة المهمة (State Machine Sequence)
|
|
31
|
+
|
|
32
|
+
سنستخدم ملف الـ `.yaml` داخل `.nomos/state/` كمصدر وحيد للحقيقة (Source of Truth) لنظام الحالة.
|
|
33
|
+
|
|
34
|
+
### 1. مرحلة التهيئة (`arc init <task>`)
|
|
35
|
+
* **Action:** إنشاء ملف `task.md` (بسيط للعميل) وملف `lifecycle.yaml` (يحتوي على الـ Meta-data والـ SHA-256 للبداية).
|
|
36
|
+
* **State:** `status: DRAFT`.
|
|
37
|
+
|
|
38
|
+
### 2. مرحلة التخطيط (`arc plan <task>`)
|
|
39
|
+
* **Action:** يقوم الـ Planner Agent بقراءة الـ `project_map.json` والقواعد، ثم يولد الخطة.
|
|
40
|
+
* **Output:** * `plans/[ID]-plan.md` (شرح منطقي).
|
|
41
|
+
* `.nomos/context/[ID]-plan.yaml` (قائمة بالتعديلات البرمجية الدقيقة، الـ Endpoints، وتغييرات الـ Schema).
|
|
42
|
+
* **State:** `status: PLANNING_COMPLETED`.
|
|
43
|
+
|
|
44
|
+
### 3. مرحلة الطعن (The Red Team / Adversarial Review)
|
|
45
|
+
هنا تبدأ الـ Loop الحقيقية لمنع الهلوسة.
|
|
46
|
+
* **Action:** يقوم الـ Red Team Agent بتحليل الـ `.yaml` الخاص بالخطة مقابل القواعد المعمارية.
|
|
47
|
+
* **Output:** * `reports/[ID]-critique.md` (تنبيهات للمستخدم).
|
|
48
|
+
* `.nomos/state/[ID]-critique.yaml` (قائمة بالثغرات المكتشفة بـ `severity: high/medium`).
|
|
49
|
+
* **Loop:** إذا وجدت ثغرات `high` يتم إعادة المهمة لحالة `PLANNING` آلياً مع حقن التقرير في البرومبت.
|
|
50
|
+
|
|
51
|
+
### 4. مرحلة التنفيذ والتوثيق (`arc apply`)
|
|
52
|
+
* **Action:** بعد الموافقة، يتم تنفيذ الكود في Shadow Branch.
|
|
53
|
+
* **Certificate:** توليد شهادة تشفيرية تربط بين:
|
|
54
|
+
* `Initial Task Hash`
|
|
55
|
+
* `Approved Plan Hash`
|
|
56
|
+
* `Final Code Diff Hash`
|
|
57
|
+
* **State:** `status: CERTIFIED`.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## ثالثاً: هيكل ملف الحالة الـ YAML (المحرك)
|
|
64
|
+
|
|
65
|
+
هذا النموذج لما سيقرأه الـ Agent في كل خطوة لضمان عدم التشتت:
|
|
66
|
+
|
|
67
|
+
```yaml
|
|
68
|
+
# .nomos/state/TASK-001.yaml
|
|
69
|
+
task_id: TASK-001
|
|
70
|
+
version: 1.2
|
|
71
|
+
metadata:
|
|
72
|
+
created_at: 2026-04-10T21:00:00Z
|
|
73
|
+
branch: nomos/feat-auth-fix
|
|
74
|
+
current_step: RED_TEAM_REVIEW
|
|
75
|
+
|
|
76
|
+
integrity_chain:
|
|
77
|
+
task_hash: sha256:e3b0c442...
|
|
78
|
+
current_plan_hash: sha256:7f83b169...
|
|
79
|
+
|
|
80
|
+
convergence_metrics:
|
|
81
|
+
iterations: 2
|
|
82
|
+
red_team_score: 0.85 # يحتاج 0.90 للعبور
|
|
83
|
+
unresolved_issues: 1
|
|
84
|
+
|
|
85
|
+
shadow_state:
|
|
86
|
+
affected_files:
|
|
87
|
+
- src/core/auth.ts
|
|
88
|
+
- src/api/middleware.ts
|
|
89
|
+
dependency_impact: low
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## رابعاً: الأكشن القادم (Implementation Step)
|
|
95
|
+
|
|
96
|
+
للبدء في تنفيذ هذه "الدورة الثالثة" برمجياً، نحتاج لبناء الـ **Orchestrator Class**. هذا الكلاس سيكون مسؤولاً عن:
|
|
97
|
+
1. **File Mirroring:** عندما يكتب الـ Agent ملف YAML، يقوم الكلاس تلقائياً بتوليد الـ Markdown المقابل له للعميل.
|
|
98
|
+
2. **Git Automation:** التعامل مع الـ Shadow Branches والتأكد من أن الـ `commit message` تحتوي على الـ `Task-ID`.
|
|
99
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
To ensure the **nomos-arc.ai** environment is governed by deterministic logic rather than heuristic guesswork, the `thresholds` section in `.nomos-config.json` acts as the "Decision Logic" layer. These parameters define the boundary between acceptable architectural evolution and risky hallucination.
|
|
2
|
+
|
|
3
|
+
Here is the detailed analytical breakdown of the recommended thresholds:
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Semantic Similarity Threshold (`default_threshold`)
|
|
8
|
+
|
|
9
|
+
This threshold determines the sensitivity of the `arc search` engine. Since nomos-arc.ai uses $L2$-normalized unit vectors, the similarity score $s$ is derived from the dot-product distance $d_{\text{dot}}$.
|
|
10
|
+
|
|
11
|
+
* **Recommended Value:** `0.70`
|
|
12
|
+
* **Engineering Rationale:** * **$s > 0.85$:** Extremely high precision. Only returns near-identical conceptual matches. May miss relevant context that uses different terminology.
|
|
13
|
+
* **$s < 0.60$:** High noise. Returns vaguely related files, increasing "Token Bloat" and distracting the AI Planner.
|
|
14
|
+
* **The "Goldilocks" Zone ($0.70$):** Balances recall (finding related logic) and precision (filtering out irrelevant noise).
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 2. Convergence Score (`convergence_threshold`)
|
|
19
|
+
|
|
20
|
+
This is the most critical metric for the **Cybernetic Loop**. It defines the minimum score required from the **Red Team (Adversary)** before a plan is allowed to proceed to the `apply` (execution) phase.
|
|
21
|
+
|
|
22
|
+
* **Recommended Value:** `0.90`
|
|
23
|
+
* **Mathematical Representation:**
|
|
24
|
+
$$S = \frac{I_{resolved}}{I_{total}} \ge 0.90$$
|
|
25
|
+
* **Operational Logic:** If the Red Team identifies 10 issues (logic flaws, rule violations, or security risks) and the Planner only addresses 8 in the next iteration, the score is $0.80$. The system will **block** execution and force another `plan -> review` cycle until 90% of issues are resolved.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 3. Entropy Threshold (`entropy_threshold`)
|
|
30
|
+
|
|
31
|
+
Located in the security block, this governs the **Secret Sanitization Pipeline**.
|
|
32
|
+
|
|
33
|
+
* **Recommended Value:** `4.5` (bits per character)
|
|
34
|
+
* **Technical Justification:**
|
|
35
|
+
* Standard English text and code typically fall between $1.5$ and $3.5$ bits of entropy.
|
|
36
|
+
* Cryptographic keys, API tokens, and high-randomness strings usually exceed $4.0$.
|
|
37
|
+
* Setting this to `4.5` allows the system to automatically flag and redact potential secrets before they are sent to the Gemini API for enrichment or planning.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 4. Architectural Impact Threshold (`impact_ratio`)
|
|
42
|
+
|
|
43
|
+
This threshold determines when a module is classified as a **Core Module**, triggering stricter governance rules.
|
|
44
|
+
|
|
45
|
+
* **Parameters:**
|
|
46
|
+
* `core_modules_count`: Top `N` modules by dependent count.
|
|
47
|
+
* `max_dependents_drift`: `0.20` (20%).
|
|
48
|
+
* **Governance Rule:** If a task increases the number of dependents for a module by more than 20% in a single plan, `arc review` will flag it as **"Architectural Bloat"** and require a manual override or a higher convergence score ($0.95$).
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
### Revised `.nomos-config.json` Template
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"project_name": "nomos-arc.ai",
|
|
57
|
+
"version": "0.1.0",
|
|
58
|
+
"thresholds": {
|
|
59
|
+
"semantic_search": 0.70,
|
|
60
|
+
"convergence": 0.90,
|
|
61
|
+
"security_entropy": 4.5,
|
|
62
|
+
"impact_drift_limit": 0.20
|
|
63
|
+
},
|
|
64
|
+
"models": {
|
|
65
|
+
"indexing": "gemini-embedding-001",
|
|
66
|
+
"mapping": "gemini-1.5-flash",
|
|
67
|
+
"orchestration": "gemini-1.5-pro"
|
|
68
|
+
},
|
|
69
|
+
"governance": {
|
|
70
|
+
"enforce_shadow_branch": true,
|
|
71
|
+
"require_certification": true,
|
|
72
|
+
"auto_retry_iterations": 3
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|