Architecture & Language Support
CodeSpider is structured as a modular Go daemon (fed7f5c) that separates deterministic code intelligence from LLM tool-calling investigation.
Request & Review Pipeline
Section titled “Request & Review Pipeline”Gitea Webhook (POST /webhook, HMAC-SHA256 verified) │ ▼WebhookHandler (internal/gitea) │ Normalizes pull_request & @codespider issue_comment events │ Filters draft/WIP and bot PRs ▼Worker Pool (internal/worker) │ - Deduplicates already-reviewed SHAs (internal/store) │ - Periodically reconciles open PRs to recover missed webhooks │ - Cancels superseded runs when new commits arrive on the same PR │ - Checks out ephemeral git worktree at head SHA (internal/workspace) │ - Loads AGENTS.md / base-branch .codespider.yaml (internal/repoconfig) ▼Deterministic + Agentic Loop (internal/codeintel, internal/analysis, internal/agent) │ - Runs AST / go/types / CFG / secret checks first │ - Executes read_file / search_code / git_forensics / add_inline_comment │ - Enforces step budget, token budget, and Blue-Team refutation gate ▼Gitea REST API (internal/gitea) └─ Posts inline comments + sticky summary + 👀 reaction + commit statusKey Go Packages
Section titled “Key Go Packages”cmd/codespider: Daemon HTTP server, CLI (review,bench,healthcheck), Operations Console UI, and gracefulSIGTERMshutdown.internal/gitea: Webhook HMAC verification, slash-command parsing, event normalization, and Gitea v1 REST client.internal/workspace: Bare git mirror cache, isolated per-PR worktrees, symlink-safe path resolution, and secret redaction.internal/codeintel,internal/analysis,internal/semdiff: Go AST/type symbol indexing, intraprocedural CFG/dataflow, and semantic hunk pruning.internal/agent&internal/llm: OpenAI-compatible/chat/completionsclient with retry/backoff, step/token budgets, and duplicate-call guards.internal/store&internal/metrics: Atomic JSON persistence (data/state.json) and Prometheus/JSON metric snapshots.
Polyglot Language Support & Capability Matrix
Section titled “Polyglot Language Support & Capability Matrix”CodeSpider uses a versioned analyzer interface (internal/lang, InterfaceVersion = "v1") with explicit capability negotiation:
| Language | Adapter | Active Capabilities | Known Limitations |
|---|---|---|---|
Go (.go) |
stdlib go/ast + go/types + CFG |
syntax, symbols, imports, types, calls, cfg, data_flow, semantic_diff, contracts, tests |
External modules without .a archives are tracked in UnresolvedImports. |
Python (.py) |
Isolated python3 -I -S ast.parse subprocess |
syntax, symbols, imports, calls, semantic_diff, contracts, tests |
Syntactic AST + type annotations only; never executes target code. |
TypeScript / JS (.ts, .tsx, .js, .jsx) |
node + typescript.createSourceFile (or structural scanner) |
symbols, imports, contracts, tests (+ syntax, calls, semantic_diff with typescript) |
Single-file AST extraction; cross-file tsc requires project node_modules. |
Rust (.rs) |
Structural Rust item & contract extractor | symbols, imports, contracts, tests, semantic_diff |
Does not expand macros or run rust-analyzer trait/borrow inference. |
5-State Evidence Machine
Section titled “5-State Evidence Machine”| State | Meaning |
|---|---|
statically_supported |
Backed by AST, go/types, CFG, or deterministic rule checks. |
model_corroborated |
Identified or corroborated by the LLM across surrounding worktree files. |
differentially_reproduced |
Verified via opt-in isolated run_proof_test container execution. |
inconclusive |
Insufficient evidence to confirm regression or safety. |
refuted |
Disproved during Blue-Team inspection or isolated verification. |