Version: 1.1 | Effective Date: 2025-12-05 | Status: Active
This document defines the immutable principles of SourceAtlas analysis. All analysis commands (/atlas.*) must adhere to these principles. Analysis results that violate these principles should be considered incomplete.
Immutable: Always prioritize scanning high-entropy files over linear traversal.
High-entropy file scanning order:
- Configuration files (package.json, go.mod, Cargo.toml, pyproject.toml)
- Project documentation (README.md, CLAUDE.md, ARCHITECTURE.md)
- Core models (models/, entities/, domain/)
- Entry points (main., index., app.*)
- Test samples (1-2 representative tests)
Validation: Each analysis must record the list of "high-entropy files scanned".
Immutable: The number of scanned files must not exceed the specified ratio of total project files.
| Project Scale | File Count | Max Scan Ratio | Max Scan Count |
|---|---|---|---|
| TINY | <20 | 50% | 10 |
| SMALL | 20-50 | 20% | 10 |
| MEDIUM | 50-150 | 10% | 15 |
| LARGE | 150-500 | 5% | 25 |
| VERY_LARGE | >500 | 3% | 30 |
Validation: Analysis reports must include a scan_ratio field; violations should trigger a warning.
Guidance: Understanding project structure is more important than reading implementation details.
Priority order:
- Directory structure and naming conventions
- Module dependencies
- API contracts and interface definitions
- Implementation details (only when necessary)
Immutable: The following directories must be excluded from file counting and scanning under all circumstances.
.venv/ # Python virtual environment
node_modules/ # Node.js dependencies
vendor/ # PHP/Go dependencies
__pycache__/ # Python cache
.git/ # Git internals
Pods/ # iOS CocoaPods
DerivedData/ # Xcode build artifacts
build/ # Generic build directory
dist/ # Generic distribution directory
target/ # Rust/Maven build
.next/ # Next.js build
.nuxt/ # Nuxt.js build
Validation: Detection scripts must exclude these directories before counting files.
Configurable: The following directories are included by default but can be excluded by users.
tests/ # Test directory
docs/ # Documentation directory
examples/ # Examples directory
Immutable: Hypothesis count must be adjusted based on project scale.
| Project Scale | Target Hypothesis Count | Low-Confidence Hypothesis Limit |
|---|---|---|
| TINY | 5-8 | 2 |
| SMALL | 7-10 | 3 |
| MEDIUM | 10-15 | 4 |
| LARGE | 12-18 | 5 |
| VERY_LARGE | 15-20 | 6 |
Definition: Low-confidence hypothesis = confidence < 0.5
Validation: When exceeding the low-confidence limit, prioritize marking the weakest hypotheses as "needs validation" or improve confidence through additional scanning.
Immutable: Each hypothesis must include the following fields.
hypothesis: "Declarative statement describing the inference"
confidence: 0.0-1.0 # Confidence level
evidence: "Evidence reference in file:line format"
validation_method: "How to validate in subsequent stages"Validation: Hypotheses missing any field should be considered incomplete.
Guidance: Confidence levels should follow these standards.
| Confidence Range | Meaning | Evidence Requirement |
|---|---|---|
| 0.85-1.0 | Almost certain | Explicit declaration in config file |
| 0.7-0.85 | Highly likely | Multiple indirect evidence |
| 0.5-0.7 | Moderately likely | Single indirect evidence |
| 0.0-0.5 | Needs validation | Speculation, lacks direct evidence |
Guidance: When trade-offs are needed, prioritize retaining these hypothesis types.
Priority order (high → low):
- Architecture hypotheses (overall structure, design patterns)
- Tech stack hypotheses (languages, frameworks, databases)
- Business domain hypotheses (what the project does)
- Development practice hypotheses (testing, CI/CD)
- AI collaboration hypotheses (Level 0-4)
Immutable: All assertions must be supported by evidence using standard format.
file_path:line_number # Precise reference
Examples:
src/models/User.php:42- Exact line numberREADME.md:15-30- Range referencepackage.json- Whole file reference (only for config files)
Guidance: Different types of evidence have different credibility levels.
| Evidence Type | Credibility | Example |
|---|---|---|
| Config declaration | Highest | dependencies in package.json |
| Documentation statement | High | Project description in README.md |
| Code structure | Medium-high | Directory naming, file organization |
| Code content | Medium | import statements, class definitions |
| Inference | Low | Guesses based on patterns |
Immutable: Conclusive statements without evidence are prohibited in analysis reports.
❌ Wrong: "This is a high-quality project"
✅ Correct: "This is a high-quality project (evidence: test coverage config .github/workflows/ci.yml:45, lint rules .eslintrc.js)"
Immutable: Output format must follow these standards.
| Analysis Type | Format | Reason |
|---|---|---|
| Stage 0 Fingerprint | YAML | Structured, machine-readable |
| Stage 1 Validation | Markdown | Human-readable report |
| Stage 2 History | Markdown | Narrative analysis |
| Quick Commands | Markdown | Immediate feedback |
Immutable: All analysis output must include the following metadata.
metadata:
analysis_time: "ISO 8601 timestamp"
total_files: N # Total project files (after exclusions)
scanned_files: M # Actual scanned file count
scan_ratio: "X.X%" # M/N percentage
project_scale: "TINY|SMALL|MEDIUM|LARGE|VERY_LARGE"
constitution_version: "1.0"Guidance: Output language should match user preference or the project's primary language.
- Default: Traditional Chinese (Taiwan terminology)
- Technical terms: Keep English originals
- Proper nouns: Do not translate (e.g., React, Django, Kubernetes)
Guidance: Each command should auto-validate quality before output, embedding warnings when issues are found.
Check Items (by priority):
| Check | Severity | Example Warning |
|---|---|---|
| scan_ratio exceeds limit | ⚠️ scan_ratio 12% exceeds MEDIUM project limit of 10% |
|
| Hypothesis missing required fields | ⚠️ Hypothesis #3 missing evidence field |
|
| Incorrect evidence format | ⚠️ Evidence format should be file:line, found "src/app.ts" |
|
| Missing required metadata | ⚠️ Missing project_scale metadata |
|
| Too many low-confidence hypotheses | ℹ️ INFO | ℹ️ 5 low-confidence hypotheses, recommend further validation |
Warning Format:
---
⚠️ **Quality Warning**
- scan_ratio 12% exceeds limit
- Hypothesis #3 missing evidence field
---Principles:
- Warnings should be embedded in output, not blocking the flow
- Display HIGH severity issues first
- Keep concise, one line per warning
Immutable: Project scale is determined by the number of code files after exclusions.
TINY: < 20 files
SMALL: 20 - 50 files
MEDIUM: 50 - 150 files
LARGE: 150 - 500 files
VERY_LARGE: > 500 files
Immutable: Projects of different scales require different analysis strategies.
| Behavior | TINY | SMALL | MEDIUM | LARGE | VERY_LARGE |
|---|---|---|---|---|---|
| Scan depth | Deep | Medium-deep | Medium | Shallow | Very shallow |
| Hypothesis count | 5-8 | 7-10 | 10-15 | 12-18 | 15-20 |
| Model scanning | All | All | 3-5 | 3-5 | 5-7 |
| Test scanning | All | 2-3 | 1-2 | 1-2 | 2-3 |
Guidance: TINY projects (<20 files) may not need full SourceAtlas analysis.
Recommendations:
- <10 files: Read directly, no systematic analysis needed
- 10-20 files: Use
/atlas.overviewfor quick scan only -
20 files: Normal SourceAtlas workflow
Immutable: Handoffs must be based on actual analysis findings, not static lists.
Each handoff suggestion must:
- Reference specific findings from the current analysis
- Explain why this suggestion relates to the findings
- Provide specific executable parameters
❌ Forbidden: "You can use /atlas.pattern to learn more"
✅ Correct: "/atlas.pattern "repository" - Found Repository pattern used in 15 places, need to understand implementation conventions"
Immutable: When any of the following conditions are met, the
recommended_nextsection should be omitted.
| Condition | Description |
|---|---|
| Sufficient analysis depth | 4+ commands executed covering multiple dimensions (overview + pattern + flow + history/impact) |
| Project too small | TINY project (<10 files) can read all files directly |
| Findings too vague | Cannot give high-confidence (>0.7) parameter suggestions |
| Goal achieved | User's question has been answered |
When omitting handoffs, provide an end prompt:
✅ **Analysis sufficient** - Ready to start implementation
Based on the above findings, recommend prioritizing:
1. [Specific action item]
2. [Specific action item]Immutable: Handoffs suggestions follow these rules.
- Primary: Must be provided (unless end conditions are met)
- Secondary: Optional (only when there's a clear relevant second option)
Forbidden to force a Secondary suggestion just for format consistency. When there's only one clear direction, provide only Primary.
Output Format: Use numbered table for quick user selection:
## Recommended Next
| # | Command | Purpose |
|---|---------|---------|
| 1 | `/atlas.pattern "repository"` | Found Repository pattern used in 15 places, need to understand implementation conventions |
| 2 | `/atlas.flow "checkout"` | Trace the complete execution path of checkout flow |
💡 Enter a number (e.g., `1`) or copy the command to executeUsers can enter 1 for quick execution or copy the full command.
Immutable: Handoffs parameters must meet the following quality standards.
| Requirement | Description | Example |
|---|---|---|
| Specific | Include executable parameters | ✅ /atlas.pattern "repository" |
| Not generic | Avoid abstract descriptions | ❌ /atlas.pattern "relevant pattern" |
| Verifiable | Parameters correspond to actual existing targets | File paths exist, pattern names are valid |
| Finding-based | Parameters come from current analysis results | ✅ Use actual file names discovered in analysis |
Immutable: The
whyfield for each suggestion must:
- Reference specific findings from the current analysis (numbers, file names, issues)
- Explain the causal relationship between finding and suggestion
- Express concisely in 1-2 sentences
❌ Forbidden: "To learn more details" ✅ Correct: "Found setSQL.py is depended on by 3 modules with no tests, need to assess modification risk"
Amendments to this Constitution require:
- Propose amendment suggestion in
ideas/ - Validate new principles on 3+ projects
- Update
dev-notes/to record decision rationale - Increment version number
- Update effective date
- MAJOR (e.g., 1.0 → 2.0): Non-backward-compatible principle changes
- MINOR (e.g., 1.0 → 1.1): New principles or clarifications
- PATCH (e.g., 1.0.0 → 1.0.1): Typo fixes, formatting adjustments
Guidance: Amendments should maintain backward compatibility as much as possible, keeping previously valid analysis results still valid.
- Confirm correct project path
- Exclusion directories configured (.venv, node_modules, etc.)
- Determine project scale (TINY/SMALL/MEDIUM/LARGE/VERY_LARGE)
- Prioritize scanning high-entropy files
- Scan ratio within specified limits
- Hypothesis count matches project scale
- Each hypothesis has complete four elements
- Output includes required metadata
- Each assertion has supporting evidence
- Low-confidence hypotheses don't exceed limit
- Format complies with standards (YAML/Markdown)
- Auto-validate before output
- HIGH severity issues shown with
⚠️warning - Warnings embedded in output, not blocking flow
- Warning format correct (one per line, HIGH priority first)
- End conditions met? If yes, omit
recommended_next - Primary suggestion has specific parameters (not generic)
- Secondary only provided when clear second option exists
- Rationale references specific findings from current analysis
- Parameters based on actual findings (file names, pattern names)
| Term | Definition |
|---|---|
| High-entropy file | Files containing large amounts of project information (configs, docs, models) |
| Scan ratio | Actual scanned file count / Total project file count |
| Hypothesis | Inference based on scan results, pending later validation |
| Confidence level | Subjective estimate of hypothesis correctness (0.0-1.0) |
| Evidence | Specific file references supporting assertions |
| Document | Relationship |
|---|---|
CLAUDE.md |
Development guide (how to develop SourceAtlas); this Constitution focuses on analysis behavior |
PROMPTS.md |
Complete prompt templates, should follow this Constitution's principles |
.claude/commands/atlas.*.md |
Command implementations, must reference this Constitution |
scripts/atlas/*.sh |
Helper scripts, should implement this Constitution's exclusion and counting logic |
End of Document
This Constitution is maintained by the SourceAtlas team. For questions or suggestions, please submit them in the ideas/ directory.