arcvision 0.2.14 → 0.2.16

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 (134) hide show
  1. package/ARCVISION_DIRECTORY_STRUCTURE.md +104 -0
  2. package/CLI_STRUCTURE.md +110 -0
  3. package/CONFIGURATION.md +119 -0
  4. package/IMPLEMENTATION_SUMMARY.md +99 -0
  5. package/README.md +149 -89
  6. package/architecture.authority.ledger.json +46 -0
  7. package/arcvision-0.2.3.tgz +0 -0
  8. package/arcvision-0.2.4.tgz +0 -0
  9. package/arcvision-0.2.5.tgz +0 -0
  10. package/arcvision.context.diff.json +2181 -0
  11. package/arcvision.context.json +1021 -0
  12. package/arcvision.context.v1.json +2163 -0
  13. package/arcvision.context.v2.json +2173 -0
  14. package/arcvision_context/README.md +93 -0
  15. package/arcvision_context/architecture.authority.ledger.json +83 -0
  16. package/arcvision_context/arcvision.context.json +6884 -0
  17. package/debug-cycle-detection.js +56 -0
  18. package/dist/index.js +1626 -25
  19. package/docs/ENHANCED_ACCURACY_SAFETY_PROTOCOL.md +172 -0
  20. package/docs/accuracy-enhancement-artifacts/enhanced-validation-config.json +98 -0
  21. package/docs/acig-robustness-guide.md +164 -0
  22. package/docs/authoritative-gate-implementation.md +168 -0
  23. package/docs/cli-strengthening-summary.md +232 -0
  24. package/docs/invariant-system-summary.md +100 -0
  25. package/docs/invariant-system.md +112 -0
  26. package/generate_large_test.js +42 -0
  27. package/large_test_repo.json +1 -0
  28. package/output1.json +2163 -0
  29. package/output2.json +2163 -0
  30. package/package.json +46 -36
  31. package/scan_calcom_report.txt +0 -0
  32. package/scan_leafmint_report.txt +0 -0
  33. package/scan_output.txt +0 -0
  34. package/scan_trigger_report.txt +0 -0
  35. package/schema/arcvision_context_schema_v1.json +136 -1
  36. package/src/arcvision-guard.js +433 -0
  37. package/src/core/authority-core-detector.js +382 -0
  38. package/src/core/authority-ledger.js +300 -0
  39. package/src/core/blastRadius.js +299 -0
  40. package/src/core/call-resolver.js +196 -0
  41. package/src/core/change-evaluator.js +509 -0
  42. package/src/core/change-evaluator.js.backup +424 -0
  43. package/src/core/change-evaluator.ts +285 -0
  44. package/src/core/chunked-uploader.js +180 -0
  45. package/src/core/circular-dependency-detector.js +404 -0
  46. package/src/core/cli-error-handler.js +458 -0
  47. package/src/core/cli-validator.js +458 -0
  48. package/src/core/compression.js +64 -0
  49. package/src/core/context_builder.js +741 -0
  50. package/src/core/dependency-manager.js +134 -0
  51. package/src/core/di-detector.js +202 -0
  52. package/src/core/diff-analyzer.js +76 -0
  53. package/src/core/example-invariants.js +135 -0
  54. package/src/core/failure-mode-synthesizer.js +341 -0
  55. package/src/core/invariant-analyzer.js +294 -0
  56. package/src/core/invariant-detector.js +548 -0
  57. package/src/core/invariant-enforcer.js +171 -0
  58. package/src/core/invariant-evaluation-utils.js +172 -0
  59. package/src/core/invariant-hooks.js +152 -0
  60. package/src/core/invariant-integration-example.js +186 -0
  61. package/src/core/invariant-registry.js +298 -0
  62. package/src/core/invariant-registry.ts +100 -0
  63. package/src/core/invariant-types.js +66 -0
  64. package/src/core/invariants-index.js +88 -0
  65. package/src/core/method-tracker.js +170 -0
  66. package/src/core/override-handler.js +304 -0
  67. package/src/core/ownership-resolver.js +227 -0
  68. package/src/core/parser-enhanced.js +80 -0
  69. package/src/core/parser.js +610 -0
  70. package/src/core/path-resolver.js +240 -0
  71. package/src/core/pattern-matcher.js +246 -0
  72. package/src/core/progress-tracker.js +71 -0
  73. package/src/core/react-nextjs-detector.js +245 -0
  74. package/src/core/readme-generator.js +167 -0
  75. package/src/core/retry-handler.js +57 -0
  76. package/src/core/scanner.js +289 -0
  77. package/src/core/semantic-analyzer.js +204 -0
  78. package/src/core/structural-context-owner.js +442 -0
  79. package/src/core/symbol-indexer.js +164 -0
  80. package/src/core/tsconfig-utils.js +73 -0
  81. package/src/core/type-analyzer.js +272 -0
  82. package/src/core/watcher.js +18 -0
  83. package/src/core/workspace-scanner.js +88 -0
  84. package/src/engine/context_builder.js +280 -0
  85. package/src/engine/context_sorter.js +59 -0
  86. package/src/engine/context_validator.js +200 -0
  87. package/src/engine/id-generator.js +16 -0
  88. package/src/engine/pass1_facts.js +260 -0
  89. package/src/engine/pass2_semantics.js +333 -0
  90. package/src/engine/pass3_lifter.js +99 -0
  91. package/src/engine/pass4_signals.js +201 -0
  92. package/src/index.js +830 -0
  93. package/src/plugins/express-plugin.js +48 -0
  94. package/src/plugins/plugin-manager.js +58 -0
  95. package/src/plugins/react-plugin.js +54 -0
  96. package/temp_original.js +0 -0
  97. package/test/determinism-test.js +83 -0
  98. package/test-authoritative-context.js +53 -0
  99. package/test-real-authoritative-context.js +118 -0
  100. package/test-upload-enhancements.js +111 -0
  101. package/test_repos/allowed-clean-architecture/.arcvision/invariants.json +57 -0
  102. package/test_repos/allowed-clean-architecture/adapters/controllers/UserController.js +95 -0
  103. package/test_repos/allowed-clean-architecture/adapters/http/HttpServer.js +78 -0
  104. package/test_repos/allowed-clean-architecture/application/dtos/CreateUserRequest.js +37 -0
  105. package/test_repos/allowed-clean-architecture/application/services/UserService.js +61 -0
  106. package/test_repos/allowed-clean-architecture/arcvision_context/README.md +93 -0
  107. package/test_repos/allowed-clean-architecture/arcvision_context/arcvision.context.json +2796 -0
  108. package/test_repos/allowed-clean-architecture/domain/interfaces/UserRepository.js +25 -0
  109. package/test_repos/allowed-clean-architecture/domain/models/User.js +39 -0
  110. package/test_repos/allowed-clean-architecture/index.js +45 -0
  111. package/test_repos/allowed-clean-architecture/infrastructure/database/DatabaseConnection.js +56 -0
  112. package/test_repos/allowed-clean-architecture/infrastructure/repositories/InMemoryUserRepository.js +61 -0
  113. package/test_repos/allowed-clean-architecture/package.json +15 -0
  114. package/test_repos/blocked-legacy-monolith/.arcvision/invariants.json +78 -0
  115. package/test_repos/blocked-legacy-monolith/arcvision_context/README.md +93 -0
  116. package/test_repos/blocked-legacy-monolith/arcvision_context/arcvision.context.json +2882 -0
  117. package/test_repos/blocked-legacy-monolith/database/dbConnection.js +35 -0
  118. package/test_repos/blocked-legacy-monolith/index.js +38 -0
  119. package/test_repos/blocked-legacy-monolith/modules/emailService.js +31 -0
  120. package/test_repos/blocked-legacy-monolith/modules/paymentProcessor.js +37 -0
  121. package/test_repos/blocked-legacy-monolith/package.json +15 -0
  122. package/test_repos/blocked-legacy-monolith/shared/utils.js +19 -0
  123. package/test_repos/blocked-legacy-monolith/utils/helpers.js +23 -0
  124. package/test_repos/risky-microservices-concerns/.arcvision/invariants.json +69 -0
  125. package/test_repos/risky-microservices-concerns/arcvision_context/README.md +93 -0
  126. package/test_repos/risky-microservices-concerns/arcvision_context/arcvision.context.json +3070 -0
  127. package/test_repos/risky-microservices-concerns/common/utils.js +77 -0
  128. package/test_repos/risky-microservices-concerns/gateways/apiGateway.js +84 -0
  129. package/test_repos/risky-microservices-concerns/index.js +20 -0
  130. package/test_repos/risky-microservices-concerns/libs/deprecatedHelper.js +36 -0
  131. package/test_repos/risky-microservices-concerns/package.json +15 -0
  132. package/test_repos/risky-microservices-concerns/services/orderService.js +42 -0
  133. package/test_repos/risky-microservices-concerns/services/userService.js +48 -0
  134. package/verify_engine.js +116 -0
@@ -0,0 +1,104 @@
1
+ # ArcVision Output Directory Structure
2
+
3
+ ## 📁 New Dedicated Directory Implementation
4
+
5
+ ArcVision now generates all output files in a dedicated `/arcvision_context/` directory to keep your project root clean and organized.
6
+
7
+ ## 📂 Directory Structure
8
+
9
+ ```
10
+ your-project/
11
+ ├── arcvision_context/ ← NEW: Dedicated ArcVision output directory
12
+ │ ├── arcvision.context.json ← Structural context (OVERWRITTEN each scan)
13
+ │ ├── architecture.authority.ledger.json ← Authority decisions (APPENDED only)
14
+ │ └── README.md ← Documentation (OVERWRITTEN each scan)
15
+ ├── .arcvision/ ← Configuration directory (unchanged)
16
+ │ ├── invariants.json ← Architectural rules
17
+ │ ├── config.json ← Project configuration
18
+ │ └── tokens/ ← Authentication tokens
19
+ └── [your other project files]
20
+ ```
21
+
22
+ ## 🔁 File Update Behavior
23
+
24
+ ### **arcvision.context.json** (Structural Truth)
25
+ - ✅ **OVERWRITTEN** completely each time you run `arcvision scan`
26
+ - Contains current structural analysis of your codebase
27
+ - Generated fresh from source code every time
28
+ - Located: `./arcvision_context/arcvision.context.json`
29
+
30
+ ### **architecture.authority.ledger.json** (Decision Truth)
31
+ - ✅ **APPENDED TO** - never overwritten
32
+ - Contains permanent record of all BLOCKED and OVERRIDDEN decisions
33
+ - Uses append-only approach for audit trail
34
+ - Located: `./arcvision_context/architecture.authority.ledger.json`
35
+
36
+ ### **README.md** (Documentation)
37
+ - ✅ **OVERWRITTEN** each time you run `arcvision scan`
38
+ - Generated documentation about the current context
39
+ - Updates with latest blast radius analysis
40
+ - Located: `./arcvision_context/README.md`
41
+
42
+ ## 🚀 Usage Examples
43
+
44
+ ### Generate context in dedicated directory:
45
+ ```bash
46
+ arcvision scan
47
+ # Creates/updates files in ./arcvision_context/
48
+ ```
49
+
50
+ ### Evaluate changes using context from dedicated directory:
51
+ ```bash
52
+ arcvision evaluate
53
+ # Automatically looks for context in ./arcvision_context/arcvision.context.json
54
+ ```
55
+
56
+ ### View authority ledger statistics:
57
+ ```bash
58
+ arcvision ledger --stats
59
+ # Reads from ./arcvision_context/architecture.authority.ledger.json
60
+ ```
61
+
62
+ ### Override a blocked decision:
63
+ ```bash
64
+ arcvision override --event-id evt_12345 --reason "Emergency fix" --owner "developer"
65
+ # Records in ./arcvision_context/architecture.authority.ledger.json
66
+ ```
67
+
68
+ ## ⚙️ Configuration Options
69
+
70
+ The directory location can be customized using environment variables:
71
+
72
+ ```bash
73
+ # Change the authority ledger location
74
+ export AUTHORITY_LEDGER_PATH=./custom/path/architecture.authority.ledger.json
75
+
76
+ # Change the default arcvision context directory name
77
+ # (would require code modification)
78
+ ```
79
+
80
+ ## 🛡️ Backward Compatibility
81
+
82
+ - Existing commands work exactly the same
83
+ - No breaking changes to CLI interface
84
+ - All file references automatically use the new directory structure
85
+ - Legacy context files in root directory are no longer used
86
+
87
+ ## 📊 Benefits
88
+
89
+ 1. **Clean Project Root**: Keeps generated files organized in one place
90
+ 2. **Clear Separation**: Distinguishes between configuration (`.arcvision/`) and output (`arcvision_context/`)
91
+ 3. **Easy Cleanup**: Simply delete the `arcvision_context/` directory to regenerate all outputs
92
+ 4. **Version Control Friendly**: Easy to `.gitignore` just the output directory while keeping configuration
93
+ 5. **Consistent Location**: All ArcVision outputs are predictably located
94
+
95
+ ## 🎯 Implementation Details
96
+
97
+ The implementation ensures:
98
+ - Directory is created automatically if it doesn't exist
99
+ - All file operations are relative to the `arcvision_context/` directory
100
+ - Authority ledger maintains append-only behavior regardless of location
101
+ - Error handling for directory creation and file access
102
+ - Clear console messages indicating file locations
103
+
104
+ This change maintains all existing functionality while providing better organization and cleaner project structure.
@@ -0,0 +1,110 @@
1
+ # ArcVision CLI Tool Structure
2
+
3
+ ## Directory Layout
4
+
5
+ ```
6
+ cli/
7
+ ├── docs/
8
+ │ ├── blast-radius-implementation.md
9
+ │ └── blast-radius.md
10
+ ├── schema/
11
+ │ └── arcvision_context_schema_v1.json
12
+ ├── src/
13
+ │ ├── core/
14
+ │ │ ├── blastRadius.js
15
+ │ │ ├── di-detector.js
16
+ │ │ ├── method-tracker.js
17
+ │ │ ├── parser-enhanced.js
18
+ │ │ ├── parser.js
19
+ │ │ ├── path-resolver.js
20
+ │ │ ├── react-nextjs-detector.js
21
+ │ │ ├── scanner.js
22
+ │ │ ├── semantic-analyzer.js
23
+ │ │ ├── tsconfig-utils.js
24
+ │ │ ├── type-analyzer.js
25
+ │ │ └── watcher.js
26
+ │ ├── engine/
27
+ │ │ ├── context_builder.js
28
+ │ │ ├── context_sorter.js
29
+ │ │ ├── context_validator.js
30
+ │ │ └── id-generator.js
31
+ │ ├── plugins/
32
+ │ │ ├── express-plugin.js
33
+ │ │ ├── plugin-manager.js
34
+ │ │ └── react-plugin.js
35
+ │ └── index.js
36
+ ├── test/
37
+ │ └── determinism-test.js
38
+ ├── .npmignore
39
+ ├── README.md
40
+ ├── arcvision.context.json
41
+ ├── jest.config.json
42
+ ├── output1.json
43
+ ├── output2.json
44
+ ├── package-lock.json
45
+ └── package.json
46
+ ```
47
+
48
+ ## Directory and File Purposes
49
+
50
+ ### Root Directory Files
51
+ - **package.json**: Defines the CLI tool's metadata, dependencies, and entry points
52
+ - **package-lock.json**: Locks dependency versions for consistent installations
53
+ - **README.md**: Documentation for the CLI tool
54
+ - **.npmignore**: Specifies files to exclude when publishing to npm
55
+ - **arcvision.context.json**: Contains context data generated by the CLI tool
56
+ - **jest.config.json**: Jest testing framework configuration
57
+ - **output1.json & output2.json**: Sample or test output files
58
+
59
+ ### docs/
60
+ Contains documentation files related to the "blast radius" feature of the CLI tool:
61
+ - **blast-radius-implementation.md**: Implementation details of the blast radius feature
62
+ - **blast-radius.md**: General documentation about the blast radius functionality
63
+
64
+ ### schema/
65
+ Contains the JSON schema for validating context files:
66
+ - **arcvision_context_schema_v1.json**: Schema definition for the ArcVision context format
67
+
68
+ ### src/
69
+ The main source code directory organized into three subdirectories:
70
+
71
+ #### src/core/
72
+ Contains core functionality for code analysis and scanning:
73
+ - **blastRadius.js**: Implements blast radius calculation functionality
74
+ - **di-detector.js**: Detects dependency injection patterns
75
+ - **method-tracker.js**: Tracks method calls and dependencies
76
+ - **parser-enhanced.js**: Enhanced parsing functionality
77
+ - **parser.js**: Core parsing functionality
78
+ - **path-resolver.js**: Resolves file paths within the project
79
+ - **react-nextjs-detector.js**: Detects React and Next.js specific patterns
80
+ - **scanner.js**: Main scanning functionality
81
+ - **semantic-analyzer.js**: Performs semantic analysis of code
82
+ - **tsconfig-utils.js**: Utilities for working with TypeScript configuration
83
+ - **type-analyzer.js**: Analyzes types in the codebase
84
+ - **watcher.js**: Watches for file changes during scanning
85
+
86
+ #### src/engine/
87
+ Contains the core engine functionality for building and managing context:
88
+ - **context_builder.js**: Builds the context from scanned files
89
+ - **context_sorter.js**: Sorts context elements
90
+ - **context_validator.js**: Validates the generated context
91
+ - **id-generator.js**: Generates unique IDs for context elements
92
+ - **pass1_facts.js**: Syntactic fact extraction - parses files and extracts raw syntactic facts (imports, exports, functions, classes)
93
+ - **pass2_semantics.js**: Semantic resolution - resolves import strings to actual file IDs and links method calls to their definitions
94
+ - **pass3_lifter.js**: Structural lifting - infers structural roles (Store, Service, Component, Utility) based on naming and connectivity
95
+ - **pass4_signals.js**: Signal extraction - calculates graph metrics like Blast Radius, Centrality, and identifies high-value nodes
96
+
97
+ #### src/plugins/
98
+ Contains plugin architecture for extending functionality:
99
+ - **express-plugin.js**: Plugin for Express.js framework detection
100
+ - **plugin-manager.js**: Manages loading and execution of plugins
101
+ - **react-plugin.js**: Plugin for React framework detection
102
+
103
+ ### src/index.js
104
+ The main entry point for the CLI application that coordinates all the functionality.
105
+
106
+ ### test/
107
+ Contains test files:
108
+ - **determinism-test.js**: Tests for ensuring consistent results across multiple runs
109
+
110
+ This CLI tool appears to be designed for analyzing codebases, generating context files, and detecting dependencies and relationships within the code, with support for various frameworks like React, Next.js, and Express.
@@ -0,0 +1,119 @@
1
+ # ArcVision Authoritative Gate Configuration
2
+
3
+ This file documents all environment variables that can be used to configure the Authoritative Gate behavior without hardcoding values.
4
+
5
+ ## Authority Ledger Configuration
6
+
7
+ ```bash
8
+ # Schema version for the authority ledger
9
+ ARCHITECTURE_LEDGER_SCHEMA_VERSION=1.0
10
+
11
+ # System identifier (defaults to current directory name)
12
+ ARCHITECTURE_SYSTEM_ID=my-project-name
13
+
14
+ # Default values for git metadata when not provided
15
+ DEFAULT_COMMIT_REF=HEAD
16
+ DEFAULT_BRANCH_NAME=main
17
+ DEFAULT_AUTHOR=system
18
+ ```
19
+
20
+ ## Override Handler Configuration
21
+
22
+ ```bash
23
+ # Minimum reason length for overrides
24
+ OVERRIDE_MIN_REASON_LENGTH=10
25
+
26
+ # Override command format and placeholders
27
+ OVERRIDE_COMMAND_FORMAT=arcvision override --event-id {eventId}
28
+ OVERRIDE_REASON_PLACEHOLDER= --reason "<detailed explanation>"
29
+ OVERRIDE_OWNER_PLACEHOLDER= --owner "<responsible person>"
30
+
31
+ # Override requirements text
32
+ OVERRIDE_REQUIREMENTS_HEADER=Requirements:
33
+ OVERRIDE_REASON_REQUIREMENT=• Reason must be detailed (minimum {minLength} characters)
34
+ OVERRIDE_OWNER_REQUIREMENT=• Owner must be identified
35
+ OVERRIDE_RECORDING_REQUIREMENT=• Override is permanently recorded
36
+ OVERRIDE_FUTURE_SCRUTINY=• Future violations will face increased scrutiny
37
+ ```
38
+
39
+ ## CLI Configuration
40
+
41
+ ```bash
42
+ # Complete CLI description
43
+ CLI_DESCRIPTION=CLI to visualize codebase architecture
44
+
45
+ # Quick start instructions
46
+ CLI_QUICK_START_INSTRUCTIONS=Quick Start:
47
+ 1. Sign up at the ArcVision dashboard
48
+ 2. Create a project and name it
49
+ 3. Generate a CLI token
50
+ 4. Run: arcvision link <token>
51
+ 5. Run: arcvision scan --upload
52
+ 6. Open dashboard to see results
53
+
54
+ # Default invariants (JSON format)
55
+ DEFAULT_INVARIANTS_JSON=[{"id":"generic-architecture-rules","system":"general","description":"Generic rules","severity":"risk","scope":{"files":["**/*.js","**/*.ts"]},"rule":{"type":"dependency","condition":{}}}]
56
+ ```
57
+
58
+ ## Blocked Evaluation Messages
59
+
60
+ ```bash
61
+ # Override command format for blocked evaluations
62
+ BLOCKED_OVERRIDE_COMMAND_FORMAT=arcvision override --event-id {eventId}
63
+ BLOCKED_OVERRIDE_REASON_PLACEHOLDER= --reason "<detailed explanation>"
64
+ BLOCKED_OVERRIDE_OWNER_PLACEHOLDER= --owner "<your-identifier>"
65
+ BLOCKED_OVERRIDE_WARNING=[WARNING] Override creates permanent architectural scar
66
+ ```
67
+
68
+ ## Override Success/Failure Messages
69
+
70
+ ```bash
71
+ # Successful override messages
72
+ OVERRIDE_PERMANENT_RECORD_MESSAGE=[PERMANENT RECORD] This override is now in the architectural ledger
73
+ OVERRIDE_FUTURE_SCRUTINY_MESSAGE=Future violations will face increased scrutiny
74
+
75
+ # Failure messages
76
+ OVERRIDE_FAILURE_HEADER=❌ OVERRIDE FAILED
77
+ OVERRIDE_FAILURE_ERROR_PREFIX=Error:
78
+ OVERRIDE_FAILURE_REQUIREMENTS_HEADER=Requirements:
79
+ OVERRIDE_FAILURE_BLOCKED_REQUIREMENT=• Event must be BLOCKED
80
+ OVERRIDE_FAILURE_REASON_REQUIREMENT=• Reason must be detailed (>10 chars)
81
+ OVERRIDE_FAILURE_OWNER_REQUIREMENT=• Owner must be specified
82
+ OVERRIDE_FAILURE_DUPLICATE_REQUIREMENT=• Event must not already be overridden
83
+ ```
84
+
85
+ ## Usage Examples
86
+
87
+ ### Setting environment variables in bash:
88
+ ```bash
89
+ export OVERRIDE_MIN_REASON_LENGTH=20
90
+ export ARCHITECTURE_SYSTEM_ID=my-awesome-project
91
+ export OVERRIDE_COMMAND_FORMAT="arcvision override --id {eventId}"
92
+ ```
93
+
94
+ ### Setting environment variables in Windows:
95
+ ```cmd
96
+ set OVERRIDE_MIN_REASON_LENGTH=20
97
+ set ARCHITECTURE_SYSTEM_ID=my-awesome-project
98
+ set OVERRIDE_COMMAND_FORMAT=arcvision override --id {eventId}
99
+ ```
100
+
101
+ ### Using a .env file:
102
+ Create a `.env` file in your project root:
103
+ ```
104
+ OVERRIDE_MIN_REASON_LENGTH=25
105
+ ARCHITECTURE_SYSTEM_ID=enterprise-system
106
+ CLI_DESCRIPTION=Enterprise Architecture Governance CLI
107
+ ```
108
+
109
+ ## Benefits of Configuration Approach
110
+
111
+ 1. **No Hardcoded Values**: All text and behavior can be customized
112
+ 2. **Environment-Specific Configuration**: Different settings for dev/staging/prod
113
+ 3. **Team Customization**: Teams can adapt messages to their workflow
114
+ 4. **Localization Support**: Messages can be translated for different teams
115
+ 5. **Compliance Requirements**: Regulatory text can be configured as needed
116
+
117
+ ## Default Behavior
118
+
119
+ When environment variables are not set, the system falls back to sensible defaults that maintain the core Authoritative Gate functionality while providing flexibility for customization.
@@ -0,0 +1,99 @@
1
+ # ArcVision Invariant System Implementation Summary
2
+
3
+ ## Overview
4
+
5
+ The ArcVision invariant system has been successfully implemented to detect and analyze system invariants when ArcVision scans repositories. This addresses the core requirement to encode SYSTEM INVARIANTS - conditions that must ALWAYS hold true in any scanned system.
6
+
7
+ ## Key Components Created/Modified
8
+
9
+ ### 1. Core Invariant Detection Engine
10
+ - **`src/core/invariant-detector.js`** - Detects architectural invariants in scanned repositories by analyzing code structure, patterns, and content
11
+ - **`src/core/invariant-analyzer.js`** - Analyzes detected invariants and provides insights about their significance and impact
12
+
13
+ ### 2. Enhanced Scanning Pipeline
14
+ - **`src/engine/pass1_facts.js`** - Extended to detect invariant indicators during syntactic fact extraction
15
+ - **`src/engine/pass2_semantics.js`** - Updated to carry forward invariant indicators through semantic resolution
16
+ - **`src/engine/pass3_lifter.js`** - Updated to preserve invariant information during structural lifting
17
+ - **`src/engine/pass4_signals.js`** - Updated to maintain invariant indicators in final output
18
+ - **`src/core/scanner.js`** - Enhanced with invariant detection and analysis capabilities
19
+ - **`src/core/context_builder.js`** - Updated to include invariant data in the final context
20
+
21
+ ### 3. Schema Updates
22
+ - **`schema/arcvision_context_schema_v1.json`** - Extended to include invariant fields
23
+ - **Context output** now includes:
24
+ - `invariants` - Array of detected system invariants
25
+ - `invariant_analysis` - Analysis results with insights and recommendations
26
+ - `architectural_health` - Assessment of system's architectural health based on invariants
27
+
28
+ ## How It Works
29
+
30
+ ### During Repository Scanning
31
+ 1. **Pass 1**: Detects potential invariant indicators in code (assertions, validations, guards, etc.)
32
+ 2. **Pass 2-4**: Preserve and carry forward invariant information through the pipeline
33
+ 3. **Invariant Detection**: Analyzes the collected data to identify actual system invariants
34
+ 4. **Invariant Analysis**: Evaluates the significance and impact of detected invariants
35
+ 5. **Health Assessment**: Provides an architectural health score based on invariant coverage
36
+
37
+ ### Invariant Categories Detected
38
+ - **Critical Path Invariants**: Conditions that must always hold or cause existential system failure
39
+ - **Boundary Invariants**: Constraints that enforce architectural boundaries
40
+ - **Module Invariants**: Conditions governing component behavior
41
+ - **System Invariants**: Overall system-level constraints
42
+
43
+ ### Patterns Recognized
44
+ - Assertion-based checks (`assert()` calls)
45
+ - Validation functions (`validateXxx`, `checkXxx`, `ensureXxx`, `guardXxx`, `verifyXxx`)
46
+ - State transition constraints
47
+ - Boundary enforcement patterns
48
+ - Error handling with invariant implications
49
+ - Guard clauses and defensive programming patterns
50
+
51
+ ## Benefits Delivered
52
+
53
+ ### For Scanned Repositories
54
+ 1. **Automatic Invariant Discovery**: ArcVision now identifies existing invariants in any scanned repository
55
+ 2. **Architectural Health Assessment**: Provides a quantitative measure of architectural robustness
56
+ 3. **Insight Generation**: Offers insights about system strengths and potential gaps
57
+ 4. **Recommendation Engine**: Suggests improvements to strengthen system invariants
58
+
59
+ ### System-Level Impact
60
+ 1. **Non-Optional Architecture**: Ensures architectural intents survive code changes, refactors, and scale
61
+ 2. **Prevents "Works Locally, Breaks System-Wide" Bugs**: Invariants catch violations before they cause cascading failures
62
+ 3. **Survives Refactors**: System-level properties maintained despite component-level changes
63
+ 4. **Executable Documentation**: Invariants serve as both enforcement and specification
64
+
65
+ ## Integration Points
66
+
67
+ The invariant system integrates seamlessly with existing ArcVision architecture:
68
+ - Maintains backward compatibility with existing functionality
69
+ - Extends the 4-pass structural analysis pipeline
70
+ - Enhances the context output without disrupting existing workflows
71
+ - Works with all supported file types (.js, .ts, .jsx, .tsx, .lua, etc.)
72
+
73
+ ## Files Modified/Added
74
+
75
+ ### New Files
76
+ 1. `src/core/invariant-detector.js` - Invariant detection engine
77
+ 2. `src/core/invariant-analyzer.js` - Invariant analysis and assessment
78
+ 3. Updated schema in `schema/arcvision_context_schema_v1.json`
79
+
80
+ ### Modified Files
81
+ 1. `src/engine/pass1_facts.js` - Added invariant indicator detection
82
+ 2. `src/engine/pass2_semantics.js` - Preserved invariant data
83
+ 3. `src/engine/pass3_lifter.js` - Carried forward invariant information
84
+ 4. `src/engine/pass4_signals.js` - Maintained invariant indicators
85
+ 5. `src/core/scanner.js` - Integrated invariant detection and analysis
86
+ 6. `src/core/context_builder.js` - Included invariant data in output
87
+
88
+ ## Validation
89
+
90
+ The system has been tested and verified to:
91
+ - Successfully integrate with the existing scanning pipeline
92
+ - Properly detect invariant patterns in code
93
+ - Generate meaningful analysis and health assessments
94
+ - Maintain performance and compatibility
95
+ - Produce valid context output according to the extended schema
96
+
97
+ ## Conclusion
98
+
99
+ The ArcVision invariant system now enables any scanned repository to have its architectural invariants automatically detected, analyzed, and assessed. This fulfills the requirement to encode SYSTEM INVARIANTS that ensure architectural intent is non-optional and survives code changes, refactors, and scale across all repositories that ArcVision analyzes.
package/README.md CHANGED
@@ -1,89 +1,149 @@
1
- # ArcVision System Context Artifact
2
-
3
-
4
- ## What This Is [arcvision.context.json](./arcvision.context.json)
5
-
6
- This file is the **canonical structural context** of this codebase.
7
- It represents how the system actually works — not how it is described.
8
-
9
- It is generated directly from source code by ArcVision.
10
-
11
- ## What This Replaces
12
-
13
- This artifact replaces:
14
- - Manual repository scanning
15
- - Tribal knowledge held by senior engineers
16
- - Re-explaining the system to new developers
17
- - Re-prompting LLMs with partial or incorrect context
18
- - Guessing blast radius of changes
19
-
20
- ## When You Must Use This
21
-
22
- Use this artifact when:
23
- - Onboarding a new developer
24
- - Prompting an AI assistant about this codebase
25
- - Making architectural changes
26
- - Investigating unexpected behavior
27
- - Assessing risk before modifying core modules
28
-
29
- ## What This Artifact Contains
30
-
31
- - Canonical module and dependency graph
32
- - Execution and data flow relationships
33
- - Structural roles (service, store, boundary, etc.)
34
- - Invariants inferred from the system
35
- - Impact metrics (blast radius, coupling)
36
-
37
- ## Determinism & Trust
38
-
39
- - Generated from commit: 0008311ad914a5f2200bd38d1b3029d47f281a46
40
- - Generation timestamp: 2026-01-15T11:08:33.477Z
41
- - Tool version: 0.2.13
42
- - Deterministic: same input → same output
43
- - Explicit assumptions listed inside the artifact
44
-
45
- If this artifact conflicts with human memory, **trust the artifact**.
46
-
47
- ## Structural Context Hubs
48
-
49
- The following files have the highest blast radius and represent critical structural hubs in the system:
50
-
51
- - **src/lib/utils.ts**
52
- - Blast Radius: 62 files (13.42% of codebase)
53
- - Risk: Changes here may silently propagate across the system.
54
-
55
- - **src/components/ui/button.tsx**
56
- - Blast Radius: 49 files (10.61% of codebase)
57
- - Risk: Acts as a coordination layer between components.
58
-
59
- - **src/lib/supabase/client.ts**
60
- - Blast Radius: 45 files (9.74% of codebase)
61
- - Risk: Modifications can cause widespread inconsistencies.
62
-
63
-
64
-
65
- ## How to Use With AI
66
-
67
- When prompting AI tools, include this file as system context.
68
- Do not ask the AI to infer architecture without it.
69
-
70
- ## When to Regenerate
71
-
72
- Regenerate this artifact when:
73
- - Core modules change
74
- - New services are added
75
- - Dependency structure shifts
76
-
77
- Run:
78
-
79
- ```
80
- arcvision scan --upload
81
- ```
82
-
83
- ## Source of Truth
84
-
85
- This artifact is the **source of truth** for system structure.
86
- All explanations, decisions, and AI reasoning should reference it.
87
-
88
- Some execution script invocations are dynamically assembled at runtime and may not be statically traceable; such scripts are included
89
- as execution boundaries without guaranteed call-site resolution
1
+ # ArcVision CLI
2
+
3
+ A powerful architectural governance tool that prevents breaking changes and enforces architectural invariants.
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ ```bash
8
+ # Install globally
9
+ npm install -g @arcvision/cli
10
+
11
+ # Link to your project
12
+ arcvision link YOUR_PROJECT_TOKEN
13
+
14
+ # Scan your codebase
15
+ arcvision scan --upload
16
+
17
+ # Evaluate architectural changes
18
+ arcvision acig . --fail-on-blocked
19
+ ```
20
+
21
+ ## 🛡️ Authoritative Change Impact Gate (ACIG)
22
+
23
+ Prevent architectural violations before they reach production:
24
+
25
+ ```bash
26
+ # Block breaking changes
27
+ arcvision acig . --fail-on-blocked
28
+
29
+ # Show detailed analysis
30
+ arcvision acig . --verbose
31
+
32
+ # Simulate changes
33
+ arcvision acig . --simulate-changes "src/core/engine.js,src/api/routes.js"
34
+ ```
35
+
36
+ ## 🔧 Core Commands
37
+
38
+ ### `arcvision scan`
39
+ Generate architectural context from your codebase
40
+
41
+ ```bash
42
+ arcvision scan [directory] [--upload]
43
+ ```
44
+
45
+ ### `arcvision acig` / `arcvision evaluate`
46
+ Evaluate changes against architectural invariants
47
+
48
+ ```bash
49
+ arcvision acig [directory] [--fail-on-blocked] [--verbose]
50
+ ```
51
+
52
+ ### `arcvision override`
53
+ Override blocked decisions with permanent record
54
+
55
+ ```bash
56
+ arcvision override --event-id EVENT_ID --reason "Detailed explanation" --owner "your-name"
57
+ ```
58
+
59
+ ### `arcvision ledger`
60
+ Inspect authority ledger records
61
+
62
+ ```bash
63
+ arcvision ledger --stats # Show statistics
64
+ arcvision ledger --recent-blocks # Show recent blocked events
65
+ ```
66
+
67
+ ### `arcvision diff`
68
+ Compare architectural context between versions
69
+
70
+ ```bash
71
+ arcvision diff old-context.json new-context.json
72
+ ```
73
+
74
+ ## 📊 Features
75
+
76
+ - **Circular Dependency Detection**: Identify architectural cycles
77
+ - **Blast Radius Analysis**: Understand change impact
78
+ - **Invariant Enforcement**: Prevent architectural violations
79
+ - **Authority Ledger**: Permanent record of decisions
80
+ - **CI/CD Integration**: GitHub Actions and curl scripts
81
+ - **Multi-format Support**: JavaScript, TypeScript, React, Express
82
+
83
+ ## 🎯 Decision Types
84
+
85
+ - **ALLOWED**: Safe changes that comply with architecture
86
+ - **RISKY**: Changes with warnings - review recommended
87
+ - **BLOCKED**: Violations that must be fixed before merging
88
+
89
+ ## 🔧 Configuration
90
+
91
+ Create `.arcvision/invariants.json` to define your architectural rules:
92
+
93
+ ```json
94
+ [
95
+ {
96
+ "id": "no-circular-deps",
97
+ "system": "core",
98
+ "description": "Prevent circular dependencies",
99
+ "severity": "critical",
100
+ "scope": { "files": ["src/**/*.js"] },
101
+ "rule": {
102
+ "type": "dependency",
103
+ "condition": { "circular": false }
104
+ }
105
+ }
106
+ ]
107
+ ```
108
+
109
+ ## 📈 Example Output
110
+
111
+ ```
112
+ 🔒 Authoritative Change Impact Gate (ACIG)
113
+ Evaluating changes against canonical system invariants...
114
+
115
+ ============================================================
116
+ DECISION: BLOCKED
117
+ ============================================================
118
+ ❌ CHANGE BLOCKED - Invariant violations detected
119
+ ❌ 2 invariant(s) violated:
120
+ 1. Circular dependency detected between src/auth/service.js and src/database/connection.js
121
+ System: core, Severity: critical
122
+ 2. Authority core modification detected
123
+ System: security, Severity: critical
124
+
125
+ [!] AUTHORITATIVE GATE BLOCKED THIS CHANGE
126
+ To override with permanent record, run:
127
+ arcvision override --event-id evt_123456789 --reason "<detailed explanation>" --owner "<your-identifier>"
128
+
129
+ [WARNING] Override creates permanent architectural scar
130
+ ```
131
+
132
+ ## 🛠️ Requirements
133
+
134
+ - Node.js >= 16.0.0
135
+ - npm or yarn package manager
136
+
137
+ ## 📚 Documentation
138
+
139
+ - [Full Documentation](https://github.com/arcvision/cli)
140
+ - [API Reference](https://github.com/arcvision/cli/docs)
141
+ - [Invariant System Guide](https://github.com/arcvision/cli/docs/invariant-system.md)
142
+
143
+ ## 🤝 Contributing
144
+
145
+ Contributions welcome! See our [contributing guidelines](CONTRIBUTING.md).
146
+
147
+ ## 📄 License
148
+
149
+ MIT License - see [LICENSE](LICENSE) file.