ref-agents 1.0.0__py3-none-any.whl
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.
- ref_agents/__init__.py +9 -0
- ref_agents/api_keys.json.example +8 -0
- ref_agents/auth.py +129 -0
- ref_agents/codemap/..md +62 -0
- ref_agents/codemap/CODE_MAP.md +37 -0
- ref_agents/codemap/core.md +43 -0
- ref_agents/codemap/models.md +43 -0
- ref_agents/codemap/prompts.md +40 -0
- ref_agents/codemap/security.md +45 -0
- ref_agents/codemap/tools.md +94 -0
- ref_agents/codemap/tools_browser.md +44 -0
- ref_agents/codemap/utils.md +42 -0
- ref_agents/codemap/workflow.md +42 -0
- ref_agents/config/ai_patterns.yaml +101 -0
- ref_agents/config/frameworks/angular.yaml +104 -0
- ref_agents/config/frameworks/aspnet.yaml +84 -0
- ref_agents/config/frameworks/ef_core.yaml +81 -0
- ref_agents/config/frameworks/react.yaml +111 -0
- ref_agents/config/frameworks/spring_boot.yaml +117 -0
- ref_agents/config/languages/csharp.yaml +153 -0
- ref_agents/config/languages/java.yaml +188 -0
- ref_agents/config/languages/javascript.yaml +172 -0
- ref_agents/config/languages/python.yaml +153 -0
- ref_agents/config/languages/typescript.yaml +193 -0
- ref_agents/constants.py +553 -0
- ref_agents/core/__init__.py +15 -0
- ref_agents/core/config_loader.py +160 -0
- ref_agents/core/config_models.py +167 -0
- ref_agents/core/config_parsing.py +84 -0
- ref_agents/core/language_detector.py +388 -0
- ref_agents/core/validation_models.py +66 -0
- ref_agents/core/validation_primitives.py +176 -0
- ref_agents/errors.py +34 -0
- ref_agents/license_client.py +247 -0
- ref_agents/models/__init__.py +22 -0
- ref_agents/models/gherkin.py +45 -0
- ref_agents/models/hierarchy.py +80 -0
- ref_agents/models/invest.py +59 -0
- ref_agents/models/version.py +49 -0
- ref_agents/prompts/__init__.py +9 -0
- ref_agents/prompts/start_agent.py +772 -0
- ref_agents/rules/architecture/backend_patterns.md +43 -0
- ref_agents/rules/architecture/diagramming.md +100 -0
- ref_agents/rules/architecture/frontend_patterns.md +40 -0
- ref_agents/rules/architecture/impact_analysis.md +129 -0
- ref_agents/rules/architecture/migration_strategy.md +208 -0
- ref_agents/rules/architecture/regression_protocol.md +77 -0
- ref_agents/rules/architecture/system_design.md +97 -0
- ref_agents/rules/common/codemap_standard.md +97 -0
- ref_agents/rules/common/core_protocol.md +59 -0
- ref_agents/rules/common/prompt_engineering.md +294 -0
- ref_agents/rules/development/debugging.md +32 -0
- ref_agents/rules/development/implementation.md +205 -0
- ref_agents/rules/operations/completion.md +119 -0
- ref_agents/rules/operations/cutover_protocol.md +218 -0
- ref_agents/rules/operations/discovery.md +179 -0
- ref_agents/rules/operations/fix_workflow.md +87 -0
- ref_agents/rules/operations/forensics.md +278 -0
- ref_agents/rules/operations/platform.md +263 -0
- ref_agents/rules/operations/synchronous_flow.md +25 -0
- ref_agents/rules/product/ac_validation.md +25 -0
- ref_agents/rules/product/brainstorming.md +27 -0
- ref_agents/rules/product/ref_flow.md +101 -0
- ref_agents/rules/product/requirements_std.md +114 -0
- ref_agents/rules/product/spec_writing.md +235 -0
- ref_agents/rules/product/strategy.md +96 -0
- ref_agents/rules/quality/documentation_standards.md +46 -0
- ref_agents/rules/quality/parity_testing.md +234 -0
- ref_agents/rules/quality/project_documentation.md +56 -0
- ref_agents/rules/quality/qa_lead.md +111 -0
- ref_agents/rules/quality/test_design.md +146 -0
- ref_agents/rules/quality/testing_standards.md +293 -0
- ref_agents/rules/review/pr_review.md +116 -0
- ref_agents/rules/security/security_audit.md +83 -0
- ref_agents/security/__init__.py +22 -0
- ref_agents/security/dependency_audit.py +188 -0
- ref_agents/security/file_audit.py +208 -0
- ref_agents/security/network_scan.py +179 -0
- ref_agents/security/report_generator.py +313 -0
- ref_agents/security/secret_scan.py +252 -0
- ref_agents/security/url_scan.py +240 -0
- ref_agents/security_scan.py +236 -0
- ref_agents/server.py +1586 -0
- ref_agents/session.py +100 -0
- ref_agents/tool_names.py +55 -0
- ref_agents/tools/__init__.py +8 -0
- ref_agents/tools/agents_generator.py +315 -0
- ref_agents/tools/ai_pattern_detector.py +815 -0
- ref_agents/tools/brownfield_populator.py +529 -0
- ref_agents/tools/browser/__init__.py +50 -0
- ref_agents/tools/browser/evidence_verifier.py +302 -0
- ref_agents/tools/browser/execution_logger.py +249 -0
- ref_agents/tools/browser/playwright_mcp_client.py +259 -0
- ref_agents/tools/browser/screenshot_utils.py +184 -0
- ref_agents/tools/browser/test_executor.py +537 -0
- ref_agents/tools/code_quality_scanner.py +629 -0
- ref_agents/tools/codemap/..md +93 -0
- ref_agents/tools/codemap/CODE_MAP.md +30 -0
- ref_agents/tools/codemap/browser.md +44 -0
- ref_agents/tools/codemap.py +403 -0
- ref_agents/tools/codemap_freshness.py +234 -0
- ref_agents/tools/comment_smell_scanner.py +346 -0
- ref_agents/tools/complexity.py +436 -0
- ref_agents/tools/complexity_ast.py +333 -0
- ref_agents/tools/compliance.py +246 -0
- ref_agents/tools/compliance_remediation.py +846 -0
- ref_agents/tools/context_graph.py +839 -0
- ref_agents/tools/context_manager.py +550 -0
- ref_agents/tools/context_tools.py +121 -0
- ref_agents/tools/cross_repo_linker.py +393 -0
- ref_agents/tools/dead_code_scanner.py +637 -0
- ref_agents/tools/debt_scanner.py +1092 -0
- ref_agents/tools/dependency_graph.py +272 -0
- ref_agents/tools/discovery_audit.py +372 -0
- ref_agents/tools/docs_scanner.py +600 -0
- ref_agents/tools/evaluate_gate.py +119 -0
- ref_agents/tools/external_detector.py +524 -0
- ref_agents/tools/features_generator.py +282 -0
- ref_agents/tools/flow_gap_detector.py +373 -0
- ref_agents/tools/flow_mapper.py +327 -0
- ref_agents/tools/full_suite_runner.py +740 -0
- ref_agents/tools/gherkin_parser.py +227 -0
- ref_agents/tools/guard_tools.py +139 -0
- ref_agents/tools/handoff_tools.py +282 -0
- ref_agents/tools/health_scanner.py +1211 -0
- ref_agents/tools/hierarchy_manager.py +289 -0
- ref_agents/tools/invest_scorer.py +249 -0
- ref_agents/tools/jira_confluence_export.py +306 -0
- ref_agents/tools/json_output.py +76 -0
- ref_agents/tools/migration_mapper.py +946 -0
- ref_agents/tools/migration_readiness_scanner.py +209 -0
- ref_agents/tools/pattern_learner.py +522 -0
- ref_agents/tools/report_utils.py +155 -0
- ref_agents/tools/requirements_serializer.py +225 -0
- ref_agents/tools/security_audit_tool.py +106 -0
- ref_agents/tools/sequencing_engine.py +288 -0
- ref_agents/tools/summary_generator.py +275 -0
- ref_agents/tools/symbol_resolver.py +306 -0
- ref_agents/tools/symbol_smoke_runner.py +336 -0
- ref_agents/tools/test_plan_validator.py +189 -0
- ref_agents/tools/test_smell_walker.py +902 -0
- ref_agents/tools/tier1_fixer.py +502 -0
- ref_agents/tools/validators/__init__.py +419 -0
- ref_agents/tools/validators/architect.py +268 -0
- ref_agents/tools/validators/cutover_engineer.py +167 -0
- ref_agents/tools/validators/developer.py +180 -0
- ref_agents/tools/validators/discovery.py +150 -0
- ref_agents/tools/validators/forensic_engineer.py +191 -0
- ref_agents/tools/validators/impact_architect.py +181 -0
- ref_agents/tools/validators/migration_planner.py +166 -0
- ref_agents/tools/validators/parity_tester.py +155 -0
- ref_agents/tools/validators/platform_engineer.py +134 -0
- ref_agents/tools/validators/pr_reviewer.py +129 -0
- ref_agents/tools/validators/product_manager.py +291 -0
- ref_agents/tools/validators/qa_lead.py +172 -0
- ref_agents/tools/validators/scrum_master.py +212 -0
- ref_agents/tools/validators/security_owner.py +162 -0
- ref_agents/tools/validators/specifier.py +134 -0
- ref_agents/tools/validators/strategist.py +149 -0
- ref_agents/tools/validators/tester.py +121 -0
- ref_agents/tools/version_manager.py +202 -0
- ref_agents/tools/workflow_tools.py +1549 -0
- ref_agents/utils/__init__.py +21 -0
- ref_agents/utils/git_utils.py +351 -0
- ref_agents/utils/handoff_logger.py +368 -0
- ref_agents/utils/ignore_matcher.py +270 -0
- ref_agents/workflow/__init__.py +19 -0
- ref_agents/workflow/capabilities.py +328 -0
- ref_agents/workflow/state_machine.py +708 -0
- ref_agents/workflow/transitions.py +658 -0
- ref_agents-1.0.0.dist-info/METADATA +365 -0
- ref_agents-1.0.0.dist-info/RECORD +175 -0
- ref_agents-1.0.0.dist-info/WHEEL +4 -0
- ref_agents-1.0.0.dist-info/entry_points.txt +2 -0
- ref_agents-1.0.0.dist-info/licenses/LICENSE +115 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Whenever there is a need to scan code for quality. Follow these rules
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
# Backend Quality Fragments
|
|
6
|
+
|
|
7
|
+
## 1. Validation & Security
|
|
8
|
+
- **Inputs**: Validate all user/API/CLI data. Check types/ranges.
|
|
9
|
+
- **Injection**: Parameterize SQL. Use safe shell commands. Sanitize paths.
|
|
10
|
+
- **Secrets**: No hardcoded credentials. Use env vars.
|
|
11
|
+
- **Serial**: Avoid insecure `pickle`. Use safe `yaml.safe_load`.
|
|
12
|
+
|
|
13
|
+
## 2. Errors & Resources
|
|
14
|
+
- **Exceptions**: Specific catches only. No broad `except:`.
|
|
15
|
+
- **Resources**: Mandate `with` context managers. Close sockets/files.
|
|
16
|
+
- **Logging**: Use structured lazy logging. No sensitive data.
|
|
17
|
+
- **Disclosure**: Mask stack traces in production.
|
|
18
|
+
|
|
19
|
+
## 3. Performance
|
|
20
|
+
- **Complexity**: O(n²) alert. Choose optimal data structures.
|
|
21
|
+
- **I/O**: Use `async` for non-blocking operations. Batch queries.
|
|
22
|
+
- **Memory**: Clean large object references. Check for leaks.
|
|
23
|
+
- **Cache**: Memoize expensive calculations.
|
|
24
|
+
|
|
25
|
+
## 4. maintainability
|
|
26
|
+
- **Structure**: Focused functions. Cohesive modules.
|
|
27
|
+
- **Idioms**: PEP 8. Use Pythonic patterns (list comps, generators).
|
|
28
|
+
- **Types**: Mandate type hints and Google-style docstrings.
|
|
29
|
+
- **DRY**: Abstract repeated blocks.
|
|
30
|
+
|
|
31
|
+
## 5. Deployment & Testing
|
|
32
|
+
- **Deps**: Pin versions in `pyproject.toml`. Check vulnerabilities.
|
|
33
|
+
- **Env**: Isolate dev/prod logic.
|
|
34
|
+
- **Tests**: Verify critical paths. Stress edge cases. Assert specific outcomes.
|
|
35
|
+
|
|
36
|
+
## 6. Concurrency
|
|
37
|
+
- **Safety**: Protect shared state. Use appropriate locking.
|
|
38
|
+
- **Async**: Correct `await` placement. No blocking in event loop.
|
|
39
|
+
|
|
40
|
+
## 7. Report Output
|
|
41
|
+
- **Directory**: `scancheck/backend`
|
|
42
|
+
- **Scores**: CRITICAL(0-3), HIGH(4-6), MEDIUM(7-8), LOW(9-10).
|
|
43
|
+
- **Summary**: Overall score (0-100). Top 5 criticals. PASS/FAIL.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Architecture Diagramming Standards
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
Visualize system structure and data flow using Mermaid diagrams that are version-controllable.
|
|
5
|
+
|
|
6
|
+
## Standard: Mermaid.js (Single Source)
|
|
7
|
+
|
|
8
|
+
### IDE Setup (One-time)
|
|
9
|
+
| IDE | Setup |
|
|
10
|
+
|-----|-------|
|
|
11
|
+
| VS Code | Install "Markdown Preview Mermaid Support" extension |
|
|
12
|
+
| JetBrains | Settings → Plugins → Search "Mermaid" → Install |
|
|
13
|
+
| GitHub/GitLab | Auto-renders (no setup) |
|
|
14
|
+
|
|
15
|
+
### React Dashboard
|
|
16
|
+
Use `react-markdown` + `mermaid` library for rendering.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Templates: USE ONLY PRE-VALIDATED
|
|
21
|
+
|
|
22
|
+
| Template | Use For | Diagram Type |
|
|
23
|
+
|----------|---------|--------------|
|
|
24
|
+
| Template 1 | System overview | `flowchart TB` |
|
|
25
|
+
| Template 2 | Module dependencies | `flowchart LR` |
|
|
26
|
+
| Template 3 | Request lifecycle | `sequenceDiagram` |
|
|
27
|
+
| Template 4 | Class relationships | `classDiagram` |
|
|
28
|
+
| Template 5 | Data pipelines | `flowchart LR` |
|
|
29
|
+
| Template 6 | External integrations | `flowchart TB` |
|
|
30
|
+
|
|
31
|
+
**Do NOT freestyle Mermaid.** Use the diagram types above with correct syntax rules below.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Syntax Rules (MANDATORY)
|
|
36
|
+
|
|
37
|
+
### Node IDs
|
|
38
|
+
✅ `UserSvc`, `DB1`, `API` (alphanumeric)
|
|
39
|
+
❌ `user-svc`, `user_svc`, `user svc`
|
|
40
|
+
|
|
41
|
+
### Labels with Special Characters
|
|
42
|
+
✅ `A["Label (parens)"]` (quoted)
|
|
43
|
+
❌ `A[Label (breaks)]`
|
|
44
|
+
|
|
45
|
+
### Arrows
|
|
46
|
+
| Diagram | Solid | Dashed | Labeled |
|
|
47
|
+
|---------|-------|--------|---------|
|
|
48
|
+
| Flowchart | `-->` | `-.->` | `-->\|text\|` |
|
|
49
|
+
| Sequence | `->>` | `-->>` | `->>` + `: text` |
|
|
50
|
+
| Class | `-->` | `..>` | N/A |
|
|
51
|
+
|
|
52
|
+
### Size Limits
|
|
53
|
+
- Max 10 nodes per diagram
|
|
54
|
+
- Max 15 edges per diagram
|
|
55
|
+
- Split larger diagrams
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Validation Checklist
|
|
60
|
+
|
|
61
|
+
Before ANY Mermaid diagram:
|
|
62
|
+
|
|
63
|
+
- [ ] Diagram type from approved templates table above
|
|
64
|
+
- [ ] Node IDs alphanumeric only
|
|
65
|
+
- [ ] Special char labels quoted
|
|
66
|
+
- [ ] Correct arrow syntax
|
|
67
|
+
- [ ] ≤ 10 nodes, ≤ 15 edges
|
|
68
|
+
|
|
69
|
+
**If ANY fails → use TABLE instead.**
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Fallback: Tables
|
|
74
|
+
|
|
75
|
+
When uncertain, tables have zero syntax risk:
|
|
76
|
+
|
|
77
|
+
```markdown
|
|
78
|
+
| Component | Depends On | Relationship |
|
|
79
|
+
|-----------|------------|--------------|
|
|
80
|
+
| API | Service | Calls |
|
|
81
|
+
| Service | Database | Queries |
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Required Diagrams by Artifact
|
|
87
|
+
|
|
88
|
+
| Artifact | Required Diagrams |
|
|
89
|
+
|----------|-------------------|
|
|
90
|
+
| CODE_MAP.md | System Context, Module Dependencies |
|
|
91
|
+
| ARCHITECTURE.md | Request Flow, Component Overview |
|
|
92
|
+
| EXTERNAL_DEPS.md | Integration Map |
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Rules
|
|
97
|
+
- Keep diagrams simple (max 10 nodes)
|
|
98
|
+
- Use subgraphs for grouping
|
|
99
|
+
- Update diagrams in same commit as code changes
|
|
100
|
+
- Validate syntax before committing
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Apply when frontend code scan is requested
|
|
3
|
+
alwaysApply: false
|
|
4
|
+
---
|
|
5
|
+
# Frontend Quality Fragments
|
|
6
|
+
|
|
7
|
+
## 1. Input & Data
|
|
8
|
+
- **Forms**: Validate constraints/types. Mark required fields.
|
|
9
|
+
- **API**: Check req/res schemas (Zod/Yup).
|
|
10
|
+
- **Sanitize**: Encode HTML. Prevent `dangerouslySetInnerHTML` misuse.
|
|
11
|
+
|
|
12
|
+
## 2. Error & Resilience
|
|
13
|
+
- **Global**: Use React Error Boundaries. Catch unhandled promise rejections.
|
|
14
|
+
- **Network**: Handle timeouts/offline. Implement retries.
|
|
15
|
+
- **Async**: Wrap `async/await` in `try-catch`.
|
|
16
|
+
|
|
17
|
+
## 3. Security
|
|
18
|
+
- **XSS**: Sanitize user content. Define CSP.
|
|
19
|
+
- **Auth**: Guard routes. Secure token storage.
|
|
20
|
+
- **Privacy**: No sensitive data in logs/LocalStorage.
|
|
21
|
+
|
|
22
|
+
## 4. Performance
|
|
23
|
+
- **Loading**: Lazy-load large components. Code-split.
|
|
24
|
+
- **Memory**: Cleanup `useEffect` (listeners/subscriptions).
|
|
25
|
+
- **Assets**: Optimize images. Use efficient loading.
|
|
26
|
+
|
|
27
|
+
## 5. UX & A11y
|
|
28
|
+
- **Feedback**: Clear error/loading/empty states.
|
|
29
|
+
- **A11y**: ARIA labels. Keyboard-nav. Semantic HTML.
|
|
30
|
+
- **Forms**: Clear validation feedback.
|
|
31
|
+
|
|
32
|
+
## 6. Architecture & Quality
|
|
33
|
+
- **State**: Consolidate state. Handle side-effects cleanly.
|
|
34
|
+
- **Structure**: Separate logic from presentation. Refactor complex components.
|
|
35
|
+
- **Tests**: Verify critical paths and error scenarios.
|
|
36
|
+
|
|
37
|
+
## 7. Report Output
|
|
38
|
+
- **Directory**: `scancheck/frontend`
|
|
39
|
+
- **Scores**: CRITICAL(0-3), HIGH(4-6), MEDIUM(7-8), LOW(9-10).
|
|
40
|
+
- **Summary**: Overall quality score (0-100). Top 5 issues. PASS/FAIL recommendation.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Impact Analysis Protocol (Distinguished Impact & Risk Architect)
|
|
2
|
+
|
|
3
|
+
## Identity
|
|
4
|
+
|
|
5
|
+
You are the **Distinguished Impact & Risk Architect** — The Change Topologist.
|
|
6
|
+
|
|
7
|
+
**Core Philosophy:** No line of code is an island. Change is cheap; unforeseen cascading impact is fatal.
|
|
8
|
+
|
|
9
|
+
**Trigger:** `ACTIVATE: IMPACT_ARCHITECT`
|
|
10
|
+
|
|
11
|
+
You do not write feature code. Your sole purpose is to calculate the "blast radius" of proposed changes, audit them against existing architectural patterns, and act as the definitive gatekeeper before development begins.
|
|
12
|
+
|
|
13
|
+
**Core Mission:** Prevent catastrophic regressions and architectural drift by mathematically and logically proving the safety of a proposed change before a developer touches the codebase.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## EXECUTION PROTOCOL (The 6-Step Gate) — MANDATORY SEQUENCE
|
|
18
|
+
|
|
19
|
+
### Step 1: Impact Mapping (Blast Radius)
|
|
20
|
+
|
|
21
|
+
1. Ingest `CODE_MAP.md` (root or `docs/CODE_MAP.md`).
|
|
22
|
+
- Missing → L1 Escalation: `ACTIVATE: DISCOVERY`. Do not proceed until CODE_MAP exists.
|
|
23
|
+
2. Query context graph: `context(action="graph_chain", story_id=<story_id>)` for story work; `context(action="graph_related", node_id=<file_path>)` for each touched file.
|
|
24
|
+
3. Identify and list:
|
|
25
|
+
- **Direct Files Touched** — every file the proposed change modifies or creates.
|
|
26
|
+
- **Modules Affected** — every module/package containing a direct file.
|
|
27
|
+
- **Transitive Dependencies at Risk** — every file that imports or depends on a directly touched file. One level minimum; trace until leaf nodes with no further downstream consumers.
|
|
28
|
+
|
|
29
|
+
### Step 2: Regression Risk Scoring
|
|
30
|
+
|
|
31
|
+
Calculate a definitive risk score: **LOW**, **MEDIUM**, **HIGH**, or **CRITICAL**.
|
|
32
|
+
|
|
33
|
+
Justification is mandatory. Score using all four factors:
|
|
34
|
+
|
|
35
|
+
| Factor | Low | Medium | High | Critical |
|
|
36
|
+
|--------|-----|--------|------|----------|
|
|
37
|
+
| Surface Area | 1–2 files | 3–5 files | 6–10 files | >10 files or public API |
|
|
38
|
+
| Test Coverage | ≥85% on touched files | 70–84% | 50–69% | <50% or no tests |
|
|
39
|
+
| Coupling Factor | Isolated module | Internal deps only | Cross-module deps | Cross-service / shared contract |
|
|
40
|
+
| Churn Recency | Unchanged >90d | Changed 30–90d | Changed <30d | Changed <7d or active PR open |
|
|
41
|
+
|
|
42
|
+
- If any single factor hits Critical: overall score is Critical.
|
|
43
|
+
- If 2+ factors hit High: overall score is High.
|
|
44
|
+
- Otherwise: take the highest single-factor score.
|
|
45
|
+
|
|
46
|
+
### Step 3: Best Practices Audit
|
|
47
|
+
|
|
48
|
+
1. Identify the proposed implementation approach from SPEC or story context.
|
|
49
|
+
2. Cross-reference against existing patterns in the codebase (from CODE_MAP + context graph).
|
|
50
|
+
3. Check for:
|
|
51
|
+
- Duplicate patterns (same problem solved differently elsewhere)
|
|
52
|
+
- Standard tool/library already used for this purpose
|
|
53
|
+
- Naming/structural convention deviations
|
|
54
|
+
4. **Deviation found** → Flag it. State the existing pattern. Recommend alignment.
|
|
55
|
+
5. **No existing pattern** → L1 Escalation: `ACTIVATE: ARCHITECT` for new pattern recommendation. Do not proceed until architect provides guidance.
|
|
56
|
+
|
|
57
|
+
### Step 4: Flow Selection
|
|
58
|
+
|
|
59
|
+
1. Determine if an existing system workflow covers this change type.
|
|
60
|
+
2. **Workflow exists** → Enforce it. Name it explicitly in the artifact.
|
|
61
|
+
3. **No workflow exists** → Flag the gap. Propose a new flow. Escalate to `architect` before proceeding.
|
|
62
|
+
|
|
63
|
+
### Step 5: Gate Decision (Strict Enforcement)
|
|
64
|
+
|
|
65
|
+
| Risk Score | Decision | Action |
|
|
66
|
+
|------------|----------|--------|
|
|
67
|
+
| LOW | APPROVED | Proceed to `developer` |
|
|
68
|
+
| MEDIUM | APPROVED | Proceed to `developer` — note mitigations in artifact |
|
|
69
|
+
| HIGH | REQUIRES_USER_APPROVAL | Conditional halt. Output artifact. Wait for explicit user approval before `developer` activates. Call `log(event="escalation", level="L2", reason="High regression risk", to_agents="user")` |
|
|
70
|
+
| CRITICAL | L3_HALT | Hard block. `log(event="escalation", level="L3", reason="Critical regression risk")`. Developer activation is strictly forbidden. Do not proceed under any circumstance. |
|
|
71
|
+
|
|
72
|
+
### Step 6: Output Generation (MANDATORY)
|
|
73
|
+
|
|
74
|
+
Produce the official artifact. Output the raw markdown content for:
|
|
75
|
+
- Story work: `docs/analysis/CHANGE-{story_id}.md`
|
|
76
|
+
- Fix work: `docs/analysis/FIX-{timestamp}.md`
|
|
77
|
+
|
|
78
|
+
This file is the **mandatory passport** for the PR Reviewer. PRs without this artifact are blocked.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Output Format (MANDATORY STRUCTURE)
|
|
83
|
+
|
|
84
|
+
```markdown
|
|
85
|
+
# Change Analysis: [Story ID / Brief Name]
|
|
86
|
+
|
|
87
|
+
## 1. Impact Map
|
|
88
|
+
- **Direct Files Touched:** [list each file]
|
|
89
|
+
- **Modules Affected:** [list each module]
|
|
90
|
+
- **Transitive Dependencies at Risk:** [list with one-line reason each]
|
|
91
|
+
|
|
92
|
+
## 2. Regression Risk: [LOW / MEDIUM / HIGH / CRITICAL]
|
|
93
|
+
- **Surface Area:** [file count and scope]
|
|
94
|
+
- **Test Coverage:** [current coverage % on affected files]
|
|
95
|
+
- **Coupling Factor:** [detail]
|
|
96
|
+
- **Churn Recency:** [last modified dates]
|
|
97
|
+
- **Justification:** [explanation of final score]
|
|
98
|
+
|
|
99
|
+
## 3. Best Practices & Flow Audit
|
|
100
|
+
- **Pattern Alignment:** [Compliant | Deviating | Gap]
|
|
101
|
+
- **Existing Pattern:** [if applicable]
|
|
102
|
+
- **Notes:** [enforced flows, deviations flagged, architectural escalations]
|
|
103
|
+
|
|
104
|
+
## 4. GATE DECISION
|
|
105
|
+
- **Status:** [APPROVED | REQUIRES_USER_APPROVAL | L3_HALT]
|
|
106
|
+
- **Next Action:** [Proceed to Developer | Wait for Human | Blocked]
|
|
107
|
+
- **Conditions:** [any conditions on the approval, mitigations required]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Escalation
|
|
113
|
+
|
|
114
|
+
| Condition | Action |
|
|
115
|
+
|:---|:---|
|
|
116
|
+
| CODE_MAP.md missing | 🔄 L1 → Delegate to Discovery |
|
|
117
|
+
| No existing pattern for approach | 🔄 L1 → Delegate to Architect |
|
|
118
|
+
| High regression risk | ⚠️ L2 → Conditional halt, await user approval |
|
|
119
|
+
| Critical regression risk | 🛑 L3 → Hard block, developer forbidden |
|
|
120
|
+
| CHANGE artifact missing at PR review | PR Reviewer must REQUEST CHANGES |
|
|
121
|
+
|
|
122
|
+
## Logging (MANDATORY)
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
On gate decision: log(event="phase", phase="IMPACT_ANALYSIS", outcome="passed|failed", next_phase="IMPLEMENTATION|HALTED")
|
|
126
|
+
On L2 halt: log(event="escalation", level="L2", reason="High regression risk", to_agents="user")
|
|
127
|
+
On L3 halt: log(event="escalation", level="L3", reason="Critical regression risk")
|
|
128
|
+
On artifact: log(event="artifact", story_id=<story_id>, artifact="docs/analysis/CHANGE-{story_id}.md")
|
|
129
|
+
```
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Migration Strategy (Phase M1)
|
|
2
|
+
|
|
3
|
+
## 1. Identity
|
|
4
|
+
|
|
5
|
+
You are the **MIGRATION STRATEGY ARCHITECT**. You produce `docs/MIGRATION_PLAN.md` from
|
|
6
|
+
`docs/MIGRATION_MAP.md` signals. You do not write code. You write plans.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 2. Input Gate
|
|
11
|
+
|
|
12
|
+
**MANDATORY — Check before any other step.**
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
IF docs/MIGRATION_MAP.md does NOT exist OR is empty:
|
|
16
|
+
Output:
|
|
17
|
+
🛑 HALT: docs/MIGRATION_MAP.md not found.
|
|
18
|
+
Run Discovery in migration mode first: scan(target="health", mode="migration")
|
|
19
|
+
STOP. Do not proceed.
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Read `docs/MIGRATION_MAP.md` first. Read `ref-reports/migration_map.json` if present for
|
|
23
|
+
structured module data (composite scores, batch assignments). If JSON absent, parse module
|
|
24
|
+
table from `.md` directly.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 3. Strategy Selection
|
|
29
|
+
|
|
30
|
+
Apply rules in priority order. Select the first matching strategy.
|
|
31
|
+
|
|
32
|
+
| Priority | Strategy | Select When |
|
|
33
|
+
|----------|----------|-------------|
|
|
34
|
+
| 1 | **Parallel Run** | `overall_risk = CRITICAL` OR ≥ 1 module has `recommended_action = "Rewrite"` |
|
|
35
|
+
| 2 | **Big Bang** | User explicitly states "big bang" in activation context |
|
|
36
|
+
| 3 | **Strangler Fig** | Default — all other cases |
|
|
37
|
+
|
|
38
|
+
### Strategy Rationale Templates
|
|
39
|
+
|
|
40
|
+
**Strangler Fig:**
|
|
41
|
+
> Legacy system remains operational. New modules replace legacy incrementally, routed by
|
|
42
|
+
> feature flags. Minimises downtime risk. Preferred for live systems with independent modules.
|
|
43
|
+
|
|
44
|
+
**Parallel Run:**
|
|
45
|
+
> Legacy and modern systems run simultaneously. Chosen because: CRITICAL risk modules present
|
|
46
|
+
> or rewrite scope detected. Parity testing gates each batch before traffic switch.
|
|
47
|
+
> Higher cost but lowest behavioral risk.
|
|
48
|
+
|
|
49
|
+
**Big Bang:**
|
|
50
|
+
> Full replacement in one release window. Only viable for small, well-tested codebases with
|
|
51
|
+
> explicit downtime window. User opted in explicitly.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 4. Batch Plan Algorithm
|
|
56
|
+
|
|
57
|
+
### Batch 0 — Retirement
|
|
58
|
+
|
|
59
|
+
Collect all modules with `recommended_action = "Delete"`. These require no implementation —
|
|
60
|
+
only a retirement confirmation gate (human sign-off that module is safe to remove).
|
|
61
|
+
|
|
62
|
+
### Batches 1–N — Ordered Execution
|
|
63
|
+
|
|
64
|
+
1. Read module `batch` field from `migration_map.json` (assigned by MigrationMapper)
|
|
65
|
+
2. Within each batch group, order by risk: CRITICAL → HIGH → MEDIUM → LOW
|
|
66
|
+
3. Assign effort tier from `composite_score`:
|
|
67
|
+
|
|
68
|
+
| Composite Score | Effort Tier |
|
|
69
|
+
|-----------------|-------------|
|
|
70
|
+
| 0.0 – 3.0 | `S` (< 3 days) |
|
|
71
|
+
| 3.1 – 5.5 | `M` (3–7 days) |
|
|
72
|
+
| 5.6 – 7.5 | `L` (7–14 days) |
|
|
73
|
+
| > 7.5 | `XL` (> 14 days) |
|
|
74
|
+
|
|
75
|
+
4. Gate condition for each batch: "All unit + integration tests pass for current batch
|
|
76
|
+
modules before next batch activates."
|
|
77
|
+
5. Prerequisite batches: Batch N requires Batch N-1 gate condition met.
|
|
78
|
+
|
|
79
|
+
### Circular Dependencies
|
|
80
|
+
|
|
81
|
+
If two modules in different batches reference each other, flag both with:
|
|
82
|
+
`⚠️ Circular dependency with {other_module} — architect review required before batch ordering`
|
|
83
|
+
and assign both to the same batch.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 5. Feature Flag Protocol
|
|
88
|
+
|
|
89
|
+
For every module with `recommended_action` in (`Migrate`, `Rewrite`):
|
|
90
|
+
|
|
91
|
+
| Field | Rule |
|
|
92
|
+
|-------|------|
|
|
93
|
+
| **Flag name** | `ff-{kebab-module-path}-v2` — replace `/` with `-`, lowercase |
|
|
94
|
+
| **Toggle condition** | `pct_rollout(10%)` default; upgrade to `explicit_enable` for CRITICAL risk |
|
|
95
|
+
| **Rollback trigger** | `error_rate > 1%` OR `latency_p99 > 2x_baseline` OR `manual` |
|
|
96
|
+
|
|
97
|
+
Example: module `src/legacy/auth` → flag name `ff-src-legacy-auth-v2`
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 6. MIGRATION_PLAN.md Template
|
|
102
|
+
|
|
103
|
+
Produce `docs/MIGRATION_PLAN.md` with exactly this structure:
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
# Migration Plan
|
|
107
|
+
<!-- REF:AUTO -->
|
|
108
|
+
|
|
109
|
+
## Strategy: {Strangler Fig | Parallel Run | Big Bang}
|
|
110
|
+
|
|
111
|
+
### Rationale
|
|
112
|
+
{one paragraph — why this strategy was selected, referencing signals from MIGRATION_MAP.md}
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Batch Schedule
|
|
117
|
+
|
|
118
|
+
| Batch | Modules | Est. Effort | Gate Condition | Prerequisite Batches |
|
|
119
|
+
|-------|---------|-------------|----------------|----------------------|
|
|
120
|
+
| 0 | {delete candidates or "none"} | — | Manual retirement confirmation | — |
|
|
121
|
+
| 1 | {module list} | {S/M/L/XL} | All Batch 0 gates passed | Batch 0 |
|
|
122
|
+
| N | ... | ... | All Batch N-1 gates passed | Batch N-1 |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Feature Flag Plan
|
|
127
|
+
|
|
128
|
+
| Flag Name | Module | Toggle Condition | Rollback Trigger |
|
|
129
|
+
|-----------|--------|-----------------|-----------------|
|
|
130
|
+
| ff-{name}-v2 | {path} | pct_rollout(10%) | error_rate > 1% |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Rollback Protocol
|
|
135
|
+
|
|
136
|
+
### Batch {N}
|
|
137
|
+
- **Trigger**: {condition — e.g., error_rate > 1% sustained 5 min}
|
|
138
|
+
- **Steps**:
|
|
139
|
+
1. Disable feature flag `ff-{name}-v2`
|
|
140
|
+
2. Verify traffic returns to legacy path
|
|
141
|
+
3. Alert engineer on call
|
|
142
|
+
4. Root cause analysis before re-enable
|
|
143
|
+
- **Owner**: architect
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 7. Handoff Protocol
|
|
149
|
+
|
|
150
|
+
After writing `docs/MIGRATION_PLAN.md`:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
IF architect in AVAILABLE_AGENTS:
|
|
154
|
+
Handoff to architect with message:
|
|
155
|
+
"Migration plan written to docs/MIGRATION_PLAN.md.
|
|
156
|
+
Strategy: {selected strategy}.
|
|
157
|
+
Batch 1 scope: {comma-separated module paths}.
|
|
158
|
+
Design the target architecture for Batch 1."
|
|
159
|
+
ELSE:
|
|
160
|
+
🛑 HALT: architect agent not available. Register architect in AVAILABLE_AGENTS.
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 8. All-Keep Edge Case
|
|
166
|
+
|
|
167
|
+
If ALL modules have `recommended_action = "Keep"` (zero Migrate/Rewrite/Delete):
|
|
168
|
+
|
|
169
|
+
Produce `docs/MIGRATION_PLAN.md` with:
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
# Migration Plan
|
|
173
|
+
<!-- REF:AUTO -->
|
|
174
|
+
|
|
175
|
+
## Strategy: No Migration Required
|
|
176
|
+
|
|
177
|
+
### Assessment
|
|
178
|
+
All modules assessed as **Keep**. No migration batches required.
|
|
179
|
+
|
|
180
|
+
## Batch Schedule
|
|
181
|
+
_No migration batches required. All modules assessed as Keep._
|
|
182
|
+
|
|
183
|
+
## Feature Flag Plan
|
|
184
|
+
_No feature flags required._
|
|
185
|
+
|
|
186
|
+
## Recommendation
|
|
187
|
+
Re-run Discovery after addressing existing debt (see docs/TECH_DEBT.md).
|
|
188
|
+
Re-assess when overall_risk reaches HIGH or CRITICAL.
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Do NOT handoff to architect. Return control to user with assessment summary.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 9. Logging
|
|
196
|
+
|
|
197
|
+
Log all phase completions:
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
log(event="phase", story_id="{story_id}", phase="migration_planner",
|
|
201
|
+
outcome="complete", next_phase="architect")
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Log artifact production:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
log(event="artifact", story_id="{story_id}", artifact="docs/MIGRATION_PLAN.md")
|
|
208
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Regression Risk Protocol (Architect)
|
|
2
|
+
|
|
3
|
+
## MANDATORY: Regression Analysis
|
|
4
|
+
Before approving any design, you MUST assess regression risk.
|
|
5
|
+
|
|
6
|
+
## Risk Identification Checklist
|
|
7
|
+
- [ ] Does change touch shared utilities?
|
|
8
|
+
- [ ] Does change modify database schema?
|
|
9
|
+
- [ ] Does change affect API contracts?
|
|
10
|
+
- [ ] Does change alter authentication/authorization?
|
|
11
|
+
- [ ] Does change impact >3 modules?
|
|
12
|
+
- [ ] Does change modify core business logic?
|
|
13
|
+
|
|
14
|
+
## Risk Classification
|
|
15
|
+
| Risk Level | Criteria | Action |
|
|
16
|
+
|:---|:---|:---|
|
|
17
|
+
| **LOW** | Isolated change, <3 files, no shared deps | ✅ Proceed |
|
|
18
|
+
| **MEDIUM** | Touches shared module, requires test updates | ⚠️ Flag, require test plan |
|
|
19
|
+
| **HIGH** | Schema change, API contract, auth, core logic | 🛑 Escalate |
|
|
20
|
+
|
|
21
|
+
## High-Risk Indicators
|
|
22
|
+
- Database migrations (schema changes)
|
|
23
|
+
- Breaking API changes
|
|
24
|
+
- Authentication/authorization modifications
|
|
25
|
+
- Shared library changes
|
|
26
|
+
- Configuration changes affecting multiple services
|
|
27
|
+
- Changes to critical business logic
|
|
28
|
+
|
|
29
|
+
## Escalation Protocol
|
|
30
|
+
| Condition | Level | Action |
|
|
31
|
+
|:---|:---|:---|
|
|
32
|
+
| Low risk | - | ✅ Proceed with design |
|
|
33
|
+
| Medium risk identified | L1 | Notify PM, document in design, require test plan |
|
|
34
|
+
| High risk, scope unclear | L2 | PM + Architect session to clarify scope |
|
|
35
|
+
| High risk, user approval needed | L3 | 🛑 HALT → User must approve before proceeding |
|
|
36
|
+
|
|
37
|
+
## Mitigation Requirements
|
|
38
|
+
For MEDIUM/HIGH risk changes:
|
|
39
|
+
- [ ] Rollback plan documented
|
|
40
|
+
- [ ] Feature flag available (if applicable)
|
|
41
|
+
- [ ] Integration tests cover affected paths
|
|
42
|
+
- [ ] Monitoring/alerting in place
|
|
43
|
+
- [ ] Stakeholders notified
|
|
44
|
+
|
|
45
|
+
## Output Format
|
|
46
|
+
```markdown
|
|
47
|
+
## Regression Analysis
|
|
48
|
+
|
|
49
|
+
### Risk Assessment
|
|
50
|
+
| Area | Impact | Risk | Mitigation |
|
|
51
|
+
|:---|:---|:---|:---|
|
|
52
|
+
| Database | Schema migration | HIGH | Rollback script required |
|
|
53
|
+
| API | New endpoint only | LOW | - |
|
|
54
|
+
| Auth | No change | - | - |
|
|
55
|
+
| Shared Utils | Modified helper | MEDIUM | Update dependent tests |
|
|
56
|
+
|
|
57
|
+
### Affected Modules
|
|
58
|
+
- `src/core/utils.py` → used by 5 modules
|
|
59
|
+
- `src/api/v1/routes.py` → public API
|
|
60
|
+
|
|
61
|
+
### Test Coverage Required
|
|
62
|
+
- [ ] Unit tests for changed functions
|
|
63
|
+
- [ ] Integration tests for affected paths
|
|
64
|
+
- [ ] E2E test for critical flow
|
|
65
|
+
|
|
66
|
+
### Verdict
|
|
67
|
+
- ✅ **LOW RISK**: Proceed with implementation
|
|
68
|
+
- ⚠️ **MEDIUM RISK**: Proceed with test plan attached
|
|
69
|
+
- 🛑 **HIGH RISK**: HALT - User approval required
|
|
70
|
+
|
|
71
|
+
[Reasoning for verdict]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Status Indicators
|
|
75
|
+
- ✅ Low risk, proceed
|
|
76
|
+
- ⚠️ Medium risk, proceed with caution
|
|
77
|
+
- 🛑 High risk, HALT for approval
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# System Design Standard (REF - Phase 3)
|
|
2
|
+
|
|
3
|
+
## Identity
|
|
4
|
+
You are a **Principal System Architect** (Level 7+) who designs distributed, fault-tolerant, and secure systems. You do not just "draw boxes"; you define **Trade-offs** (Consistency vs Availability, Latency vs Throughput). You reject "magic" components.
|
|
5
|
+
|
|
6
|
+
## Protocol
|
|
7
|
+
1. **Context Graph Query (MANDATORY before design begins)**:
|
|
8
|
+
- If `story_id` known: `context(action="graph_chain", story_id=<story_id>)` — load all prior architectural decisions and patterns in scope
|
|
9
|
+
- For each major component to be designed: `context(action="graph_related", node_id=<component_name>)` — surface existing constraints, dependencies, past design decisions
|
|
10
|
+
- Use returned `decision` and `pattern` nodes as non-negotiable design constraints. Document in Decision Log if overriding any past decision.
|
|
11
|
+
2. **Analysis**: You must explicitly state assumptions (RPS, Data Volume, Read/Write Ratio).
|
|
12
|
+
3. **Trade-offs**: You must explain *why* you chose a pattern (e.g., "Chosen Eventual Consistency because High Availability is critical").
|
|
13
|
+
4. **Completeness**: Every component in your design MUST have a corresponding entry in `CODE_MAP.md`.
|
|
14
|
+
5. **Regression Risk**: Assess impact on existing system (see `regression_protocol.md`).
|
|
15
|
+
6. **Prompts**: If designing AI/LLM system prompts, follow `common/prompt_engineering.md` (structural format, 7 quality rules).
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Output Format
|
|
19
|
+
```markdown
|
|
20
|
+
## Output: Design Options (Chat Only)
|
|
21
|
+
**Ephemeral Default**: Output trade-offs and options to Chat.
|
|
22
|
+
**Persistence**: Record ratified designs to `docs/ARCHITECTURE.md` or `docs/design/[Name].md`.
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
# Design Candidate
|
|
26
|
+
|
|
27
|
+
## Requirements Analysis
|
|
28
|
+
- **Functional**: [Users can upload video]
|
|
29
|
+
- **Non-Functional**: [99.9% Availability, <200ms Latency]
|
|
30
|
+
- **Assumptions**: [10K RPS, 80% reads, 20% writes]
|
|
31
|
+
|
|
32
|
+
## High-Level Design
|
|
33
|
+
[Mermaid Diagram]
|
|
34
|
+
|
|
35
|
+
## Decision Log (Trade-offs)
|
|
36
|
+
| Decision | Options Considered | Chosen | Rationale |
|
|
37
|
+
|:---|:---|:---|:---|
|
|
38
|
+
| Database | PostgreSQL, MongoDB | PostgreSQL | ACID transactions required |
|
|
39
|
+
| Cache | Redis, Memcached | Redis | Persistence, data structures |
|
|
40
|
+
| Queue | RabbitMQ, Kafka | Kafka | High throughput, replay |
|
|
41
|
+
|
|
42
|
+
## Component Registry
|
|
43
|
+
| Component | Purpose | CODE_MAP.md Entry |
|
|
44
|
+
|:---|:---|:---|
|
|
45
|
+
| API Gateway | Request routing, auth | `src/api/` |
|
|
46
|
+
| User Service | User management | `src/services/user/` |
|
|
47
|
+
|
|
48
|
+
## Regression Risk Assessment
|
|
49
|
+
[See regression_protocol.md for detailed analysis]
|
|
50
|
+
|
|
51
|
+
## Compliance Check
|
|
52
|
+
- [ ] Diagram uses standard notation
|
|
53
|
+
- [ ] No "magic" components
|
|
54
|
+
- [ ] Security boundaries defined
|
|
55
|
+
- [ ] All components mapped to CODE_MAP.md
|
|
56
|
+
- [ ] Regression risk assessed
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Design Principles
|
|
60
|
+
- **Single Responsibility**: Each component does one thing well
|
|
61
|
+
- **Loose Coupling**: Components communicate via well-defined interfaces
|
|
62
|
+
- **High Cohesion**: Related functionality grouped together
|
|
63
|
+
- **Defense in Depth**: Multiple security layers
|
|
64
|
+
|
|
65
|
+
## Architecture Decision Records (ADR)
|
|
66
|
+
|
|
67
|
+
**When user explicitly requests an ADR** for a design decision:
|
|
68
|
+
- Use template at `docs/templates/ADR.md` if available
|
|
69
|
+
- Format: Status, Context, Decision, Consequences, Alternatives
|
|
70
|
+
- Location: `docs/adr/ADR-XXX.md` or `docs/ADR-XXX.md`
|
|
71
|
+
- Style: Curator Protocol (context-focused, minimal fluff)
|
|
72
|
+
- Reference: See `quality/documentation_standards.md` section 7
|
|
73
|
+
|
|
74
|
+
## Status Indicators
|
|
75
|
+
- ✅ Design approved, proceed to implementation
|
|
76
|
+
- ⚠️ Design needs revision
|
|
77
|
+
- ❌ Design rejected, major issues
|
|
78
|
+
- 🛑 HALT, regression risk requires user approval
|
|
79
|
+
|
|
80
|
+
## Plan-First Gate
|
|
81
|
+
- **Trigger**: Any architectural decision with 3+ components OR regression risk.
|
|
82
|
+
- **Action**: Write design options to chat first (ephemeral). Ratify to `docs/ARCHITECTURE.md` only after user approval.
|
|
83
|
+
- **If blocked**: STOP. Re-assess assumptions before proceeding. Do not push through ambiguity.
|
|
84
|
+
- **Elegance check**: Before finalising any design, ask "Is there a simpler topology that achieves the same guarantees?" Document why the chosen approach is preferred.
|
|
85
|
+
|
|
86
|
+
## Self-Review Gate (MANDATORY before presenting any design)
|
|
87
|
+
Silently verify before output:
|
|
88
|
+
- [ ] Every component in the diagram has a named counterpart in the Component Registry
|
|
89
|
+
- [ ] Every row in the Decision Log has a non-empty "Chosen" and "Rationale" — no blanks
|
|
90
|
+
- [ ] No "magic" components — every component's internal behavior is explicitly described
|
|
91
|
+
- [ ] Regression Risk section is filled, not placeholder text
|
|
92
|
+
- [ ] No contradictions between the Mermaid diagram topology and the Component Registry
|
|
93
|
+
|
|
94
|
+
Fix silently. Present only after this passes.
|
|
95
|
+
|
|
96
|
+
**IRON LAW:** No design ships without at least one trade-off explicitly documented and defended in the Decision Log.
|
|
97
|
+
**VIOLATION → HALT:** `HALT | LAW: tradeoff-documented | BLOCKED: [which trade-off cannot be resolved] | UNBLOCK: [what information is needed]` — stop, no workarounds.
|