RepoPulse: update backend/app and dependencies (+3 areas)

Public changes compared with the previous published export:
26 files changed.

Affected areas:
- backend/app: 11 files
- dependencies: 5 files
- deployment and CI: 3 files
- documentation: 2 files
- tests: 5 files

Changed files:
- Updated: "Dockerfile.unraid"
- Updated: "README.md"
- Updated: "backend/Dockerfile"
- Updated: "backend/app/acquisition.py"
- Updated: "backend/app/architecture.py"
- Updated: "backend/app/git_analysis.py"
- Updated: "backend/app/gitea.py"
- Updated: "backend/app/jobs.py"
- Updated: "backend/app/main.py"
- Added: "backend/app/processes.py"
- Updated: "backend/app/rules.py"
- Updated: "backend/app/scanner.py"
- Updated: "backend/app/signals.py"
- Updated: "backend/app/store.py"
- Updated: "backend/pyproject.toml"
- Added: "backend/tests/test_api_responsiveness.py"
- Added: "backend/tests/test_processes.py"
- Updated: "backend/tests/test_scanner.py"
- Updated: "backend/tests/test_signals_v11.py"
- Updated: "backend/tests/test_store.py"
- Updated: "docker-compose.yml"
- Updated: "docs/ARCHITECTURE.md"
- Updated: "frontend/package-lock.json"
- Updated: "frontend/package.json"
- Updated: "package-lock.json"
- Updated: "package.json"

Export provenance/manifests refreshed; excluded from the change summary.

Publish curated RepoPulse source from a251f826238908b156485299061da76482780ed2
This commit is contained in:
Public Source Publisher committed 2026-11-17 21:10:30 +00:00
1 parent 23a4a721f1
commit 61ae49f9d0
28 files changed
+1083 -408

No files matched your search

+138 -68
View File
@@ -4,6 +4,7 @@ import ast
import json
import math
import os
import posixpath
import re
from collections import Counter
from pathlib import Path
@@ -66,8 +67,10 @@ def _ts_path_aliases(root: Path) -> list[tuple[str, str]]:
return aliases[:100]
def _workspace_packages(root: Path) -> dict[str, Path]:
packages: dict[str, Path] = {}
def _workspace_packages(root: Path) -> dict[str, str]:
"""Map local package names to their root-relative POSIX directory."""
packages: dict[str, str] = {}
for manifest in _bounded_config_files(root, {"package.json"}, maximum=100):
try:
if manifest.stat().st_size > 256_000:
@@ -75,7 +78,7 @@ def _workspace_packages(root: Path) -> dict[str, Path]:
data = json.loads(manifest.read_text(encoding="utf-8"))
name = data.get("name") if isinstance(data, dict) else None
if isinstance(name, str) and name and not name.startswith((".", "/")):
packages.setdefault(name, manifest.parent)
packages.setdefault(name, manifest.parent.relative_to(root).as_posix())
except (OSError, ValueError, json.JSONDecodeError, TypeError):
continue
return packages
@@ -116,79 +119,118 @@ def _resolve_python_target(module: str, module_map: dict[str, str]) -> str | Non
return None
def _python_imports(path: str, text: str, module_map: dict[str, str]) -> set[str]:
try:
tree = ast.parse(text)
except SyntaxError:
return set()
def python_package_parts(path: str) -> list[str]:
"""Return the package that relative imports in ``path`` resolve against."""
current_names = _module_names(path)
current = current_names[0] if current_names else ""
current_parts = current.split(".") if current else []
if not path.endswith("/__init__.py") and current_parts:
package_parts = current_parts[:-1]
else:
package_parts = current_parts
return current_parts[:-1]
return current_parts
imports: set[str] = set()
def python_import_modules(node: ast.AST, package_parts: list[str]) -> list[str]:
"""Return the absolute (still unresolved) module names referenced by one import node."""
if isinstance(node, ast.Import):
return [alias.name for alias in node.names]
if isinstance(node, ast.ImportFrom):
module = node.module or ""
if node.level:
trim = max(0, node.level - 1)
prefix = package_parts[:-trim] if trim else package_parts
return [".".join([*prefix, *([module] if module else [])])]
return [module]
return []
def extract_python_imports(path: str, tree: ast.AST) -> tuple[str, ...]:
package_parts = python_package_parts(path)
modules: dict[str, None] = {}
for node in ast.walk(tree):
if isinstance(node, ast.Import):
for alias in node.names:
target = _resolve_python_target(alias.name, module_map)
if target and target != path:
imports.add(target)
elif isinstance(node, ast.ImportFrom):
module = node.module or ""
if node.level:
trim = max(0, node.level - 1)
prefix = package_parts[:-trim] if trim else package_parts
absolute = ".".join([*prefix, *([module] if module else [])])
else:
absolute = module
target = _resolve_python_target(absolute, module_map)
if target and target != path:
imports.add(target)
return imports
if isinstance(node, (ast.Import, ast.ImportFrom)):
for module in python_import_modules(node, package_parts):
modules.setdefault(module)
return tuple(modules)
def extract_js_specifiers(text: str) -> tuple[str, ...]:
return tuple(dict.fromkeys(match.group("target") for match in JS_IMPORT_RE.finditer(text)))
def extract_imports(path: str, text: str, language: str) -> tuple[str, ...]:
"""Extract compact, unresolved import references so source text need not be retained."""
if language == "Python":
try:
tree = ast.parse(text)
except (SyntaxError, ValueError):
return ()
return extract_python_imports(path, tree)
if language in {"TypeScript", "JavaScript"}:
return extract_js_specifiers(text)
return ()
def _lexical_relative(path: str) -> str | None:
"""Normalize a root-relative POSIX path without filesystem access.
Candidates are only matched against already safety-checked scanner paths, so
symlink resolution adds nothing; a path escaping the root yields no target.
"""
if not path or path.startswith("/"):
return None
normalized = posixpath.normpath(path)
if normalized == ".." or normalized.startswith("../"):
return None
return normalized
def _resolve_js_target(
root: Path,
source_path: str,
specifier: str,
known: set[str],
aliases: list[tuple[str, str]],
workspace_packages: dict[str, Path],
workspace_packages: dict[str, str],
) -> str | None:
relative_base: str | None = None
if specifier.startswith("."):
source_dir = (root / source_path).parent
base = (source_dir / specifier).resolve()
relative_base = _lexical_relative(posixpath.join(posixpath.dirname(source_path), specifier))
else:
base = None
matched_alias = False
for alias, target in aliases:
if alias.endswith("/*") and specifier.startswith(alias[:-1]):
base = (root / target.replace("*", specifier[len(alias) - 1 :])).resolve()
relative_base = _lexical_relative(target.replace("*", specifier[len(alias) - 1 :]))
matched_alias = True
break
if alias == specifier:
base = (root / target).resolve()
relative_base = _lexical_relative(target)
matched_alias = True
break
if base is None:
if not matched_alias:
package_name = next(
(name for name in workspace_packages if specifier == name or specifier.startswith(f"{name}/")),
(
name
for name in workspace_packages
if specifier == name or specifier.startswith(f"{name}/")
),
None,
)
if package_name:
package_root = workspace_packages[package_name]
suffix = specifier.removeprefix(package_name).lstrip("/")
base = package_root / suffix if suffix else package_root / "src" / "index"
if base is None:
return None
try:
relative_base = base.relative_to(root.resolve()).as_posix()
except ValueError:
relative_base = _lexical_relative(
posixpath.join(package_root, suffix)
if suffix
else posixpath.join(package_root, "src", "index")
)
if relative_base is None:
return None
candidates = [relative_base]
suffix = Path(relative_base).suffix.lower()
suffix = posixpath.splitext(relative_base)[1].lower()
if suffix in JS_EXTENSIONS:
extensionless = relative_base[: -len(suffix)]
candidates.extend(extensionless + extension for extension in JS_EXTENSIONS)
@@ -199,22 +241,6 @@ def _resolve_js_target(
return next((candidate for candidate in candidates if candidate in known), None)
def _js_imports(
root: Path,
path: str,
text: str,
known: set[str],
aliases: list[tuple[str, str]],
workspace_packages: dict[str, Path],
) -> set[str]:
imports: set[str] = set()
for match in JS_IMPORT_RE.finditer(text):
target = _resolve_js_target(root, path, match.group("target"), known, aliases, workspace_packages)
if target and target != path:
imports.add(target)
return imports
def build_architecture(
root: Path,
source_texts: dict[str, str],
@@ -226,27 +252,71 @@ def build_architecture(
max_nodes: int = 160,
max_edges: int = 600,
) -> tuple[ArchitectureGraph, list[Hotspot]]:
"""Compatibility entry point that accepts full source texts."""
imports_by_path = {
path: extract_imports(path, text, language_by_path.get(path, ""))
for path, text in source_texts.items()
}
return build_architecture_from_imports(
root,
imports_by_path,
language_by_path,
loc_by_path,
debt_by_path,
churn_by_path,
max_nodes=max_nodes,
max_edges=max_edges,
)
def build_architecture_from_imports(
root: Path,
imports_by_path: dict[str, tuple[str, ...]],
language_by_path: dict[str, str],
loc_by_path: dict[str, int],
debt_by_path: dict[str, int],
churn_by_path: dict[str, int],
*,
max_nodes: int = 160,
max_edges: int = 600,
) -> tuple[ArchitectureGraph, list[Hotspot]]:
"""Build the bounded graph from compact import references; no source text is retained."""
max_nodes = max(1, max_nodes)
max_edges = max(0, max_edges)
known_paths = set(source_texts)
known_paths = set(imports_by_path)
module_map = _python_module_map(list(known_paths))
ts_aliases = _ts_path_aliases(root)
workspace_packages = _workspace_packages(root)
js_cache: dict[tuple[str, str], str | None] = {}
edge_pairs: set[tuple[str, str]] = set()
total_inbound: Counter[str] = Counter()
total_outbound: Counter[str] = Counter()
total_edges = 0
truncated = len(known_paths) > max_nodes
for path in sorted(source_texts):
text = source_texts[path]
for path in sorted(imports_by_path):
references = imports_by_path[path]
language = language_by_path.get(path, "")
targets: set[str] = set()
if language == "Python":
targets = _python_imports(path, text, module_map)
for module in references:
target = _resolve_python_target(module, module_map)
if target and target != path:
targets.add(target)
elif language in {"TypeScript", "JavaScript"}:
targets = _js_imports(root, path, text, known_paths, ts_aliases, workspace_packages)
else:
targets = set()
directory = posixpath.dirname(path)
for specifier in references:
# Only relative specifiers depend on the importing directory.
key = (directory if specifier.startswith(".") else "", specifier)
if key not in js_cache:
js_cache[key] = _resolve_js_target(
path, specifier, known_paths, ts_aliases, workspace_packages
)
target = js_cache[key]
if target and target != path:
targets.add(target)
for target in sorted(targets):
if target not in known_paths:
continue