stemedb/applications/aphoria/src/walker/language.rs
jordan d3a88585fe feat: Phase 6 UAT - Admission control, HLC recency, cluster coordination
This commit includes comprehensive work on Phase 6 features:

## Admission Control (Phase 6 admission middleware)
- AdmissionStore implementation backed by TrustRankStore
- PoW verification with tier-based difficulty computation
- Trust tier progression (Newcomer → Established → Trusted → Authority)
- API integration with admission status endpoints

## HLC Recency Lens (Phase 6C)
- HlcRecencyLens for distributed system ordering
- Hybrid logical clock integration with causality preservation

## Cluster Coordination (Phase 6C)
- Multi-node cluster tests (availability, partition tolerance)
- CRDT convergence tests for anti-entropy sync
- Gateway handler improvements

## Aphoria Code Linter (Phase 2A)
- RFC/OWASP corpus builders with network fetching and caching
- Concept hierarchy with auto-alias creation on conflict detection
- Multiple security extractors (TLS, JWT, CORS, secrets, rate limiting)

## Code Organization
- Split large files into modules to comply with 500-line limit
- Improved test organization with separate test modules
- Fixed rkyv serialization for EigenTrustState (AgentScore struct)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 00:43:37 -07:00

77 lines
2.2 KiB
Rust

//! Language detection for projects.
use std::path::Path;
use crate::types::Language;
/// Detect the primary language of a project.
///
/// Priority:
/// 1. Explicit language in config (handled by caller)
/// 2. Presence of language-specific manifest files
/// 3. File count heuristic (most common extension)
///
/// Not yet wired into the scan pipeline; will be used when
/// auto-detection replaces the config-based language setting.
#[allow(dead_code)]
pub fn detect_project_language(root: &Path) -> Language {
// Check for manifest files
if root.join("Cargo.toml").exists() {
return Language::Rust;
}
if root.join("go.mod").exists() {
return Language::Go;
}
if root.join("package.json").exists() {
// Could be TypeScript or JavaScript
if root.join("tsconfig.json").exists() {
return Language::TypeScript;
}
return Language::JavaScript;
}
if root.join("pyproject.toml").exists() || root.join("requirements.txt").exists() {
return Language::Python;
}
// Fallback: Unknown
Language::Unknown
}
#[cfg(test)]
mod tests {
use super::*;
use tempfile::TempDir;
#[test]
fn test_detect_rust_project() {
let dir = TempDir::new().expect("create temp dir");
std::fs::write(dir.path().join("Cargo.toml"), "[package]").expect("write file");
assert_eq!(detect_project_language(dir.path()), Language::Rust);
}
#[test]
fn test_detect_go_project() {
let dir = TempDir::new().expect("create temp dir");
std::fs::write(dir.path().join("go.mod"), "module test").expect("write file");
assert_eq!(detect_project_language(dir.path()), Language::Go);
}
#[test]
fn test_detect_typescript_project() {
let dir = TempDir::new().expect("create temp dir");
std::fs::write(dir.path().join("package.json"), "{}").expect("write file");
std::fs::write(dir.path().join("tsconfig.json"), "{}").expect("write file");
assert_eq!(detect_project_language(dir.path()), Language::TypeScript);
}
#[test]
fn test_detect_unknown() {
let dir = TempDir::new().expect("create temp dir");
assert_eq!(detect_project_language(dir.path()), Language::Unknown);
}
}