create-living-architecture 1.0.8 → 2.0.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 (62) hide show
  1. package/.living-arch/SYSTEM.md +26 -0
  2. package/.living-arch/architecture.json +6 -0
  3. package/README.md +535 -0
  4. package/installer.js +42 -0
  5. package/package.json +10 -25
  6. package/src/app/__init__.py +16 -0
  7. package/src/app/__pycache__/__init__.cpython-314.pyc +0 -0
  8. package/src/app/__pycache__/validation-workflow.cpython-314.pyc +0 -0
  9. package/src/app/installer-workflow.js +56 -0
  10. package/src/app/validation-workflow.py +184 -0
  11. package/src/config/SYSTEM.md +58 -0
  12. package/src/config/changes.json +11 -0
  13. package/src/config/execution.json +9 -0
  14. package/src/config/f-tags.json +12 -0
  15. package/src/config/interfaces.json +16 -0
  16. package/src/config/modules.json +19 -0
  17. package/src/config/operations.json +272 -0
  18. package/src/config/r-layers.json +111 -0
  19. package/src/contract/cli/la-new.sh +64 -0
  20. package/src/contract/cli/network-scan.py +195 -0
  21. package/src/contract/hooks/commit-msg +17 -0
  22. package/src/contract/hooks/pre-commit +4 -0
  23. package/src/domain/__init__.py +20 -0
  24. package/src/domain/__pycache__/__init__.cpython-314.pyc +0 -0
  25. package/src/domain/__pycache__/config_loader.cpython-314.pyc +0 -0
  26. package/src/domain/__pycache__/la-output.cpython-314.pyc +0 -0
  27. package/src/domain/__pycache__/validate-changes.cpython-314.pyc +0 -0
  28. package/src/domain/__pycache__/validate-execution.cpython-314.pyc +0 -0
  29. package/src/domain/__pycache__/validate-f-tags.cpython-314.pyc +0 -0
  30. package/src/domain/__pycache__/validate-operations.cpython-314.pyc +0 -0
  31. package/src/domain/__pycache__/validate-r-layers.cpython-314.pyc +0 -0
  32. package/src/domain/config_loader.py +84 -0
  33. package/src/domain/installer-logic.js +30 -0
  34. package/src/domain/la-output.py +46 -0
  35. package/src/domain/validate-changes.py +60 -0
  36. package/src/domain/validate-execution.py +91 -0
  37. package/src/domain/validate-f-tags.py +93 -0
  38. package/src/domain/validate-operations.py +100 -0
  39. package/src/domain/validate-r-layers.py +202 -0
  40. package/src/exec/__init__.py +21 -0
  41. package/src/exec/__pycache__/__init__.cpython-314.pyc +0 -0
  42. package/src/exec/__pycache__/file-io.cpython-314.pyc +0 -0
  43. package/src/exec/__pycache__/git-io.cpython-314.pyc +0 -0
  44. package/src/exec/__pycache__/module-loader.cpython-314.pyc +0 -0
  45. package/src/exec/file-io.py +99 -0
  46. package/src/exec/git-io.py +59 -0
  47. package/src/exec/installer-io.js +36 -0
  48. package/src/exec/module-loader.py +29 -0
  49. package/index.js +0 -79
  50. package/templates/.living-arch/SYSTEM.md +0 -53
  51. package/templates/ARCHITECTURE.md +0 -56
  52. package/templates/README.md +0 -28
  53. package/templates/src/api/README.md +0 -13
  54. package/templates/src/database/README.md +0 -13
  55. package/templates/src/domain/README.md +0 -12
  56. package/templates/src/integrations/README.md +0 -13
  57. package/templates/starter-template/ARCHITECTURE.md +0 -56
  58. package/templates/starter-template/README.md +0 -28
  59. package/templates/starter-template/src/api/README.md +0 -13
  60. package/templates/starter-template/src/database/README.md +0 -13
  61. package/templates/starter-template/src/domain/README.md +0 -12
  62. package/templates/starter-template/src/integrations/README.md +0 -13
@@ -0,0 +1,56 @@
1
+ /**
2
+ * installer-workflow.js - R2 Application
3
+ * Orchestrates: validate -> plan -> scaffold -> hook -> commit.
4
+ */
5
+
6
+ const path = require('path');
7
+ const { execSync } = require('child_process');
8
+ const logic = require('../domain/installer-logic');
9
+ const io = require('../exec/installer-io');
10
+
11
+ function run(projectName) {
12
+ // 1. Validate
13
+ const validation = logic.validateProjectName(projectName);
14
+ if (!validation.valid) {
15
+ return { success: false, error: validation.error };
16
+ }
17
+
18
+ // 2. Check target doesn't already exist
19
+ if (io.exists(projectName)) {
20
+ return { success: false, error: `Directory '${projectName}' already exists` };
21
+ }
22
+
23
+ // 3. Build plan
24
+ const laSourceDir = path.resolve(__dirname, '../..');
25
+ const plan = logic.buildScaffoldPlan(projectName, laSourceDir);
26
+
27
+ // 4. Copy LA structure
28
+ io.copyDir(path.join(laSourceDir, 'src'), path.join(plan.targetDir, 'src'));
29
+ io.copyDir(path.join(laSourceDir, '.living-arch'), path.join(plan.targetDir, '.living-arch'));
30
+
31
+ // 5. Init git
32
+ execSync(`git init ${plan.targetDir}`, { stdio: 'pipe' });
33
+
34
+ // 6. Hook up pre-commit and commit-msg
35
+ const hooksDir = path.join(plan.targetDir, 'src/contract/hooks');
36
+ const gitHooksDir = path.join(plan.targetDir, '.git/hooks');
37
+
38
+ io.chmodExec(path.join(hooksDir, 'pre-commit'));
39
+ io.chmodExec(path.join(hooksDir, 'commit-msg'));
40
+
41
+ const preCommitSrc = path.resolve(path.join(hooksDir, 'pre-commit'));
42
+ const commitMsgSrc = path.resolve(path.join(hooksDir, 'commit-msg'));
43
+
44
+ io.writeFile(path.join(gitHooksDir, 'pre-commit'), `#!/bin/bash\n"${preCommitSrc}" "$@"\n`);
45
+ io.writeFile(path.join(gitHooksDir, 'commit-msg'), `#!/bin/bash\n"${commitMsgSrc}" "$@"\n`);
46
+ io.chmodExec(path.join(gitHooksDir, 'pre-commit'));
47
+ io.chmodExec(path.join(gitHooksDir, 'commit-msg'));
48
+
49
+ // 7. Initial commit — no F-tag, scaffold is not a feature
50
+ execSync('git add .', { cwd: plan.targetDir, stdio: 'pipe' });
51
+ execSync('git commit --no-verify -m "LA v2.0 scaffold"', { cwd: plan.targetDir, stdio: 'pipe' });
52
+
53
+ return { success: true, projectName, targetDir: plan.targetDir };
54
+ }
55
+
56
+ module.exports = { run };
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ validation-workflow.py - R2 Orchestration
4
+ Coordinates all R1 validators with R4 I/O.
5
+ R4 reads files, R1 validates content, R2 assembles results.
6
+ """
7
+
8
+ import sys
9
+ import os
10
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
11
+
12
+ from exec import git_io, file_io
13
+ from domain import (
14
+ validate_f_tags,
15
+ validate_execution,
16
+ validate_operations,
17
+ validate_r_layers,
18
+ validate_changes,
19
+ la_output,
20
+ )
21
+ from domain.config_loader import get_module_from_filepath
22
+
23
+
24
+ def run_all_validators():
25
+ commit_msg = git_io.get_commit_message()
26
+ if not commit_msg:
27
+ return {'error': 'No commit message found', 'overall_valid': False}
28
+
29
+ staged_files = git_io.get_staged_files()
30
+
31
+ results = {
32
+ 'commit_message': commit_msg,
33
+ 'staged_files': staged_files,
34
+ 'validations': {}
35
+ }
36
+
37
+ # R0-driven validators (commit message only)
38
+ results['validations']['changes'] = validate_changes.validate(commit_msg)
39
+ results['validations']['f_tags'] = validate_f_tags.validate(commit_msg)
40
+
41
+ # Per-file validators — R4 reads, R1 checks
42
+ exec_results = []
43
+ qc_results = []
44
+ layer_violations = []
45
+
46
+ for filepath in staged_files:
47
+ if not filepath.endswith(('.py', '.js')):
48
+ continue
49
+
50
+ content = file_io.read_file(filepath)
51
+ if content is None:
52
+ continue
53
+
54
+ exec_results.append(validate_execution.validate(filepath, content))
55
+ qc_results.append(validate_operations.validate(filepath, content))
56
+ layer_violations.extend(validate_r_layers.check_file(filepath, content))
57
+
58
+ results['validations']['execution'] = {
59
+ 'valid': all(r.get('valid', True) for r in exec_results),
60
+ 'files': exec_results
61
+ }
62
+
63
+ results['validations']['qc'] = {
64
+ 'valid': all(r.get('valid', True) for r in qc_results),
65
+ 'files': qc_results,
66
+ 'violations': [v for r in qc_results for v in r.get('violations', [])]
67
+ }
68
+
69
+ results['validations']['r_layers'] = {
70
+ 'valid': len(layer_violations) == 0,
71
+ 'violations': layer_violations
72
+ }
73
+
74
+ # Module detection
75
+ modules_touched = set()
76
+ for filepath in staged_files:
77
+ module = get_module_from_filepath(filepath)
78
+ if module:
79
+ modules_touched.add(module)
80
+ results['modules_touched'] = sorted(modules_touched)
81
+
82
+ results['overall_valid'] = all(
83
+ v.get('valid', True) for v in results['validations'].values()
84
+ )
85
+
86
+ return results
87
+
88
+
89
+ def validate_files(filepaths):
90
+ """
91
+ Run execution + QC validators against a list of files.
92
+ Used by network-scan (R3) to get real results for scan_feature.
93
+ """
94
+ exec_valid = True
95
+ qc_valid = True
96
+ qc_violations = []
97
+
98
+ for filepath in filepaths:
99
+ content = file_io.read_file(filepath)
100
+ if content is None:
101
+ continue
102
+ e = validate_execution.validate(filepath, content)
103
+ q = validate_operations.validate(filepath, content)
104
+ if not e.get('valid', True):
105
+ exec_valid = False
106
+ if not q.get('valid', True):
107
+ qc_valid = False
108
+ qc_violations.extend(q.get('violations', []))
109
+
110
+ return {
111
+ 'execution': {'valid': exec_valid},
112
+ 'qc': {'valid': qc_valid, 'violations': qc_violations}
113
+ }
114
+
115
+
116
+ def format_output(results):
117
+ lines = []
118
+ lines.append(la_output.header('LIVING ARCHITECTURE'))
119
+ lines.append(f" {results['commit_message']}")
120
+ lines.append('')
121
+
122
+ if results.get('modules_touched'):
123
+ lines.append(f" Modules: {', '.join(results['modules_touched'])}")
124
+ lines.append('')
125
+
126
+ # R-layers
127
+ r_val = results['validations']['r_layers']
128
+ if r_val['valid']:
129
+ lines.append(f" {'R-layers':14}{la_output.ok('')}")
130
+ else:
131
+ n = len(r_val['violations'])
132
+ suffix = 's' if n != 1 else ''
133
+ lines.append(f" {'R-layers':14}{la_output.err(f'{n} violation{suffix}')}")
134
+
135
+ # F-tag
136
+ f_tag_val = results['validations']['f_tags']
137
+ if f_tag_val.get('valid'):
138
+ f_tag_name = f_tag_val.get('f_tag', 'F-unknown')
139
+ if f_tag_val.get('complete'):
140
+ lines.append(f" {f_tag_name:14}{la_output.ok('')}")
141
+ else:
142
+ missing = ', '.join(f_tag_val.get('layers_missing', []))
143
+ lines.append(f" {f_tag_name:14}{la_output.warn(f'missing {missing}')}")
144
+ else:
145
+ lines.append(f" {'F-tag':14}{la_output.err(f_tag_val.get('error', 'Invalid'))}")
146
+
147
+ # Execution
148
+ exec_val = results['validations']['execution']
149
+ lines.append(f" {'Execution':14}{la_output.ok('') if exec_val['valid'] else la_output.err('')}")
150
+
151
+ # QC
152
+ qc_val = results['validations']['qc']
153
+ if qc_val['valid']:
154
+ lines.append(f" {'QC':14}{la_output.ok('')}")
155
+ else:
156
+ violations = qc_val.get('violations', [])
157
+ lines.append(f" {'QC':14}{la_output.err(violations[0] if violations else 'violation')}")
158
+
159
+ # C-code
160
+ c_val = results['validations']['changes']
161
+ if c_val.get('valid'):
162
+ lines.append(f" {'C-code':14}{la_output.ok(c_val.get('c_code', ''))}")
163
+ else:
164
+ lines.append(f" {'C-code':14}{la_output.err(c_val.get('error', 'Invalid'))}")
165
+
166
+ lines.append('')
167
+ if results['overall_valid']:
168
+ lines.append(f" {la_output.ok(la_output.bold('COMMIT ALLOWED'))}")
169
+ else:
170
+ lines.append(f" {la_output.err(la_output.bold('BLOCKED: Fix errors to proceed'))}")
171
+ lines.append('')
172
+ lines.append(la_output.divider())
173
+
174
+ return '\n'.join(lines)
175
+
176
+
177
+ if __name__ == '__main__':
178
+ results = run_all_validators()
179
+
180
+ if 'error' in results:
181
+ sys.exit(0)
182
+
183
+ print(format_output(results))
184
+ sys.exit(0 if results['overall_valid'] else 1)
@@ -0,0 +1,58 @@
1
+ # Living Architecture - Project Guide
2
+
3
+ ## R-Layer Gravity
4
+
5
+ - **R0** `src/config/` - Pure configuration
6
+ - **R1** `src/domain/` - Pure business logic
7
+ - **R2** `src/app/` - Orchestration & workflows
8
+ - **R3** `src/contract/` - API boundaries & interfaces
9
+ - **R4** `src/exec/` - I/O operations
10
+
11
+ ## Commit Format
12
+
13
+ ```
14
+ [F-feature-name/R#/C#] Description
15
+ ```
16
+
17
+ **Examples:**
18
+ - `[F-login/R1/C2] Add password validation logic`
19
+ - `[F-payments/R4/C2] Add Stripe API integration`
20
+ - `[F-checkout/R2/C1] Refactor cart workflow`
21
+
22
+ ## Change Codes (C#)
23
+
24
+ - **C1** - Internal refactoring
25
+ - **C2** - New feature
26
+ - **C3** - API/contract change
27
+ - **C4** - R-layer restructure
28
+ - **C5** - Migration
29
+
30
+ ## Module Naming Convention (Optional)
31
+
32
+ Group related code across ALL R-layers using module prefixes:
33
+
34
+ **Format:** `{module}-{component}.ext`
35
+
36
+ **Example - Auth module:**
37
+ ```
38
+ R0/config/auth-rules.json
39
+ R1/domain/auth-login.py
40
+ R2/app/auth-workflow.py
41
+ R3/contract/auth-api.js
42
+ R4/exec/auth-db.py
43
+ ```
44
+
45
+ **Benefits:**
46
+ - Visual grouping across layers
47
+ - Easy searching: `find . -name "auth-*"`
48
+ - Validators display module info
49
+ - **Entirely optional** - use if helpful
50
+
51
+ ## Commands
52
+
53
+ ```bash
54
+ network-scan # See all features
55
+ network-scan F-login # Analyze one feature
56
+ ```
57
+
58
+ Let code settle at its natural gravity level.
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "codes": {
4
+ "C1": "Internal - refactor, no external change",
5
+ "C2": "Feature - new functionality",
6
+ "C3": "Contract - API/interface change",
7
+ "C4": "Structure - R-layer reorganization",
8
+ "C5": "Migration - data/dependency update"
9
+ },
10
+ "format": "C[1-5]"
11
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "patterns": {
4
+ "io_ownership": "Single owner per I/O channel",
5
+ "state_machines": "Complete state transitions",
6
+ "coordination": "Single R2 orchestrator per path",
7
+ "flow_paths": "No circular dependencies"
8
+ }
9
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "format": {
4
+ "pattern": "F-[a-z][a-z0-9-]*",
5
+ "description": "Kebab-case, starts with lowercase letter"
6
+ },
7
+ "completeness": {
8
+ "required_layers": ["R1", "R3", "R4"],
9
+ "optional_layers": ["R0", "R2"],
10
+ "description": "Complete feature needs logic (R1), interface (R3), and I/O (R4)"
11
+ }
12
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "enabled": false,
4
+ "description": "Interface contracts between R-layers (manual documentation)",
5
+ "convention": {
6
+ "format": "Document expected inputs/outputs between layers",
7
+ "examples": [
8
+ "R2 calls R1: login(username, password) -> Session",
9
+ "R3 calls R2: checkout() -> OrderConfirmation"
10
+ ]
11
+ },
12
+ "validation": {
13
+ "enforce_contracts": false,
14
+ "note": "Interfaces are documented, not enforced. Use for human/AI reference."
15
+ }
16
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "enabled": true,
4
+ "convention": {
5
+ "format": "{module}-{component}.ext",
6
+ "description": "Group related code across R-layers with module prefix",
7
+ "examples": [
8
+ "auth-login.py",
9
+ "auth-session.py",
10
+ "payment-process.py",
11
+ "cart-add.py"
12
+ ]
13
+ },
14
+ "rules": {
15
+ "enforce_boundaries": false,
16
+ "warn_cross_module": true,
17
+ "display_in_output": true
18
+ }
19
+ }
@@ -0,0 +1,272 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "specification": "operational.json",
4
+ "enforcement_mode": "blocking",
5
+
6
+ "operational_dimensions": {
7
+ "O1_access_control": {
8
+ "name": "Access Control & Abuse Prevention",
9
+ "scope": "all external access points",
10
+ "mandatory_checks": [
11
+ {
12
+ "check": "authentication_required",
13
+ "rule": "All external access SHALL be authenticated or explicitly marked public",
14
+ "enforcement_layer": "R3_contract"
15
+ },
16
+ {
17
+ "check": "authorization_enforcement",
18
+ "rule": "Authorization SHALL be enforced at Application layer (R2)",
19
+ "enforcement_layer": "R2_application"
20
+ },
21
+ {
22
+ "check": "no_business_logic_in_auth",
23
+ "rule": "Execution layer SHALL NOT encode business permission logic",
24
+ "violation": "Auth checks in controllers acceptable; auth rules are not"
25
+ }
26
+ ]
27
+ },
28
+
29
+ "O2_traffic_management": {
30
+ "name": "Traffic Management",
31
+ "scope": "all system boundaries",
32
+ "mandatory_properties": [
33
+ {
34
+ "property": "rate_limiting",
35
+ "requirement": "SHALL exist at system boundaries",
36
+ "identity_aware": true,
37
+ "supported_identities": ["user", "token", "ip", "api_key"],
38
+ "state_location": "R4_execution"
39
+ },
40
+ {
41
+ "property": "throttling",
42
+ "requirement": "SHALL prevent accidental DoS",
43
+ "notes": "Protects against AI-generated infinite loops"
44
+ },
45
+ {
46
+ "property": "quotas",
47
+ "requirement": "SHALL be configurable per identity type"
48
+ },
49
+ {
50
+ "property": "burst_control",
51
+ "requirement": "SHALL define maximum burst size"
52
+ }
53
+ ],
54
+ "code_pattern_example": {
55
+ "violation": "await fetch(externalAPI)",
56
+ "compliant": "await rateLimiter.wrap(() => fetch(externalAPI, {timeout: 5000}), {maxRetries: 3, identity: userId})"
57
+ }
58
+ },
59
+
60
+ "O3_reliability": {
61
+ "name": "Reliability & Fault Tolerance",
62
+ "scope": "all external calls and stateful operations",
63
+ "mandatory_properties": [
64
+ {
65
+ "property": "timeout",
66
+ "requirement": "All external calls SHALL define timeouts",
67
+ "type": "number",
68
+ "constraint": ">0 and <=30000",
69
+ "units": "milliseconds"
70
+ },
71
+ {
72
+ "property": "retry_policy",
73
+ "requirement": "Retry logic SHALL be bounded and explicit",
74
+ "constraints": {
75
+ "max_attempts": "<=5",
76
+ "backoff_type": ["exponential", "linear", "fixed"],
77
+ "max_backoff_ms": "<=60000"
78
+ }
79
+ },
80
+ {
81
+ "property": "circuit_breaker",
82
+ "requirement": "High-volume external dependencies SHOULD implement circuit breakers",
83
+ "parameters": {
84
+ "failure_threshold": "configurable",
85
+ "timeout": "configurable",
86
+ "reset_timeout": "configurable"
87
+ }
88
+ },
89
+ {
90
+ "property": "graceful_degradation",
91
+ "requirement": "Failure modes SHALL be predictable",
92
+ "notes": "Unhandled error is not an acceptable system state"
93
+ }
94
+ ]
95
+ },
96
+
97
+ "O4_performance": {
98
+ "name": "Performance & Resource Control",
99
+ "scope": "all resource-intensive operations",
100
+ "mandatory_constraints": [
101
+ {
102
+ "constraint": "resource_isolation",
103
+ "rule": "Resource-heavy operations SHALL be isolated",
104
+ "examples": ["batch processing", "large file operations", "complex computations"]
105
+ },
106
+ {
107
+ "constraint": "explicit_caching",
108
+ "rule": "Caching SHALL be explicit and invalidation-defined",
109
+ "forbidden": "implicit caching without invalidation strategy"
110
+ },
111
+ {
112
+ "constraint": "bounded_operations",
113
+ "rule": "No unbounded loops or recursive calls",
114
+ "enforcement": "All loops must have explicit termination condition",
115
+ "notes": "Performance bugs become availability bugs at scale"
116
+ },
117
+ {
118
+ "constraint": "concurrency_limits",
119
+ "rule": "Concurrent operations SHALL have explicit limits"
120
+ },
121
+ {
122
+ "constraint": "memory_budgets",
123
+ "rule": "Large allocations SHALL be bounded and justified"
124
+ }
125
+ ]
126
+ },
127
+
128
+ "O5_observability": {
129
+ "name": "Observability",
130
+ "scope": "all critical paths and error conditions",
131
+ "mandatory_requirements": [
132
+ {
133
+ "requirement": "structured_logging",
134
+ "rule": "All critical paths SHALL emit structured logs",
135
+ "format": "machine-parseable (JSON recommended)",
136
+ "minimum_fields": ["timestamp", "level", "message", "context"]
137
+ },
138
+ {
139
+ "requirement": "error_detectability",
140
+ "rule": "Errors SHALL be machine-detectable",
141
+ "implementation": "structured error objects, not string messages"
142
+ },
143
+ {
144
+ "requirement": "business_metrics",
145
+ "rule": "Metrics SHALL align with business events",
146
+ "examples": ["user_action_completed", "transaction_processed", "api_call_made"]
147
+ },
148
+ {
149
+ "requirement": "tracing",
150
+ "rule": "Distributed operations SHOULD include trace IDs",
151
+ "propagation": "across service boundaries"
152
+ }
153
+ ],
154
+ "notes": "If you cannot observe it, AI cannot safely optimize it"
155
+ },
156
+
157
+ "O6_configuration": {
158
+ "name": "Configuration & Environment",
159
+ "scope": "all environment-dependent behavior",
160
+ "mandatory_rules": [
161
+ {
162
+ "rule": "no_environment_logic_in_domain",
163
+ "constraint": "No environment-specific logic in R1 or R2",
164
+ "allowed_location": "R4_infrastructure only"
165
+ },
166
+ {
167
+ "rule": "no_hardcoded_secrets",
168
+ "constraint": "Secrets SHALL NOT be hard-coded",
169
+ "enforcement": "blocking",
170
+ "detection": "scan for patterns like API keys, passwords, tokens"
171
+ },
172
+ {
173
+ "rule": "external_configuration",
174
+ "constraint": "Configuration SHALL be externally injectable",
175
+ "methods": ["environment variables", "config files", "external config service"]
176
+ },
177
+ {
178
+ "rule": "feature_flags",
179
+ "recommendation": "Use feature flags for gradual rollouts",
180
+ "location": "R4_execution"
181
+ }
182
+ ],
183
+ "notes": "Environment coupling is a hidden dependency dimension"
184
+ },
185
+
186
+ "O7_data_safety": {
187
+ "name": "Data Safety & Lifecycle",
188
+ "scope": "all data operations",
189
+ "mandatory_requirements": [
190
+ {
191
+ "requirement": "input_validation",
192
+ "rule": "All external inputs SHALL be validated",
193
+ "location": "R3_interface or R2_application",
194
+ "forbidden": "trusting external input without validation"
195
+ },
196
+ {
197
+ "requirement": "schema_versioning",
198
+ "rule": "Schema changes SHALL be versioned",
199
+ "applies_to": ["database schemas", "API contracts", "message formats"]
200
+ },
201
+ {
202
+ "requirement": "intentional_deletion",
203
+ "rule": "Data deletion SHALL be intentional and auditable",
204
+ "forbidden": "cascading deletes without explicit approval"
205
+ },
206
+ {
207
+ "requirement": "backup_strategy",
208
+ "rule": "Critical data SHALL have backup and recovery plan",
209
+ "testing": "recovery procedures SHALL be tested"
210
+ },
211
+ {
212
+ "requirement": "retention_policy",
213
+ "rule": "Data retention SHALL be explicitly defined",
214
+ "compliance": "Consider regulatory requirements (GDPR, etc.)"
215
+ }
216
+ ],
217
+ "notes": "Data bugs are permanent bugs"
218
+ }
219
+ },
220
+
221
+ "cross_dimension_rules": [
222
+ "No operational concern may violate architectural invariants",
223
+ "Operational logic SHALL NOT leak into Domain logic (R1)",
224
+ "Execution (R4) MAY support operational enforcement only"
225
+ ],
226
+
227
+ "review_protocol": {
228
+ "for_each_change": [
229
+ {
230
+ "step": 1,
231
+ "action": "Identify affected operational dimensions"
232
+ },
233
+ {
234
+ "step": 2,
235
+ "action": "Verify architectural compliance (D1-D5)"
236
+ },
237
+ {
238
+ "step": 3,
239
+ "action": "Verify bounded behavior (no infinite loops, unbounded retries, etc.)"
240
+ },
241
+ {
242
+ "step": 4,
243
+ "action": "Verify failure handling (timeouts, circuit breakers, error propagation)"
244
+ },
245
+ {
246
+ "step": 5,
247
+ "action": "Halt on violation"
248
+ }
249
+ ],
250
+ "notes": "Most production outages are review failures, not code failures"
251
+ },
252
+
253
+ "ai_instructions": {
254
+ "before_external_calls": [
255
+ "Add timeout parameter",
256
+ "Wrap in rate limiter if user/client-triggered",
257
+ "Define retry policy with max attempts <=5",
258
+ "Add structured error handling"
259
+ ],
260
+ "before_data_operations": [
261
+ "Validate all inputs",
262
+ "Check schema version compatibility",
263
+ "Ensure deletion is explicit and logged"
264
+ ],
265
+ "before_resource_intensive_ops": [
266
+ "Define concurrency limits",
267
+ "Add execution timeout",
268
+ "Implement progress monitoring"
269
+ ],
270
+ "on_violation": "HALT and request architectural review"
271
+ }
272
+ }