Files
brahman/crates/modules/semantic_dht/minga-cli/src/error.rs
T
Sergio 4db168253c feat(minga): multi-lenguaje en parser — Python, TypeScript, JavaScript, Go
Minga deja de ser Rust-only. Cualquiera de los cinco dialectos
(Rust + 4 nuevos) se ingresa al CAS por su AST normalizado, hashea
estructuralmente, sincroniza por DHT como cualquier nodo. La
auto-deteccion por extension hace que minga ingest archivo.{py,ts,js,go}
"simplemente funcione".

API nueva en minga_core::parse:
- Funciones por dialecto: python, typescript, javascript, go (~6 LOC
  c/u sobre el parse_with comun). Mas la rust existente.
- Enum Dialect con parse(source) y name() para logging.
- detect_by_extension(ext) -> Option<Dialect>: rs/py/pyi/ts/js/mjs/
  cjs/go (case-insensitive). None para extensiones desconocidas.

Wire en minga-cli:
- cmd_ingest deja de hardcodear parse::rust — usa
  detect_dialect(file)?.parse(...).
- initial_scan + cmd_watch cambian is_rs_file -> is_supported_source.
- CliError::UnsupportedLanguage { path, extension } nuevo, lista las
  extensiones reconocidas en el mensaje.

Notas sobre hashing:
- Hashing estructural (cas::hash_node) funciona para todos. NO es
  alpha-equivalente.
- Hashing alpha-equivalente (alpha::hash_node_alpha) sigue siendo
  Rust-only — cada lenguaje tiene reglas distintas para binder vs
  constructor; implementacion per-language queda como work futuro
  (requiere conocimiento profundo de cada gramatica).
- Sanity test structural_hash_distinguishes_languages verifica que
  "x = 1" parseado como Python != JS — las gramaticas no comparten
  kinds, hashes salen distintos. Importante para evitar colisiones.

Deps nuevas (workspace + minga-core):
- tree-sitter-python 0.23, tree-sitter-typescript 0.23 (modo
  LANGUAGE_TYPESCRIPT, no TSX), tree-sitter-javascript 0.23,
  tree-sitter-go 0.23.

Tests: 9 nuevos en parse::tests (parse basico para 5 dialectos +
detect_by_extension canonical/case-insensitive + name() +
structural_hash_distinguishes_languages). 108 verdes en minga-core,
10 en minga-cli, sin regresion.

Pendientes: alpha-hashing per-language; alpha-Rust documentados en
alpha.rs (if let, while let, let-else, let-chains, or_pattern con
bindings).
2026-05-09 16:06:31 +00:00

50 lines
1.3 KiB
Rust

use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum CliError {
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("keypair file: {0}")]
KeypairFile(#[from] minga_store::KeypairFileError),
#[error("store: {0}")]
Store(#[from] minga_store::StoreError),
#[error("attestation: {0}")]
Attestation(#[from] minga_core::AttestationError),
#[error("parse: {0}")]
Parse(#[from] minga_core::parse::ParseError),
#[error("network: {0}")]
Network(#[from] minga_p2p::NodeError),
#[error("peer open: {0}")]
PeerOpen(#[from] minga_p2p::PeerOpenError),
#[error("peer sync: {0}")]
PeerSync(#[from] minga_p2p::PeerSyncError),
#[error("multiaddr inválido: {0}")]
Multiaddr(String),
#[error("el directorio del repo ya existe: {0}")]
AlreadyExists(PathBuf),
#[error("el multiaddr no incluye `/p2p/<peer_id>`")]
NoPeerIdInMultiaddr,
#[error("timeout esperando conexión")]
SyncTimeout,
#[error("notify (file watcher): {0}")]
Notify(#[from] notify::Error),
#[error(
"lenguaje no soportado para {path}: extensión '{extension}' no mapea \
a ningún dialecto conocido (rs, py, pyi, ts, js, mjs, cjs, go)"
)]
UnsupportedLanguage { path: PathBuf, extension: String },
}