Docs-Builder

# Project Function Index (PFI)

Version: 1.1.1
Last Updated: January 23, 2026

Capabilities

  • Function discovery across .rpy contexts (python/init/early/inline/lambda/single-line defines).
  • Stat effect analysis: detects assignments, increments, compound ops, conditional mutations; integrates Stats 2.x and SAE for symbolic evaluation.
  • Consistency checks: signature drift, side-effect drift, dead/shadowed/duplicate functions, complexity, naming conventions.
  • Call graph: dependencies, transitive deps, cycle detection, DOT export.
  • Governance: emits JSONL events (FUNCTION_DISCOVERED, FUNCTION_ANALYZED, FUNCTION_WARNING, PFI_INDEXED).

Core APIs (Python)

  • FunctionIndexer — index project functions (index_project, get_function, get_functions_in_file).
  • StatEffectAnalyzer — analyze stat modifiers (analyze_function, analyze_all).
  • ConsistencyChecker — run warning checks (check_all, check_signature_drift, check_dead_functions).
  • CallGraph — build dependency graph (build_from_functions, detect_cycles, to_dot).
  • PFIExporter — export JSON (full|compact|by-stat) and call graph.

CLI

  • branchpy pfi -p <project> — full analysis.
  • --output <file> — save JSON export; --format full|compact|by-stat.
  • --export-dot <file> — export call graph.
  • --show-warnings / --show-dead / --show-call-graph — report modes.
  • --complexity-threshold N — adjust warning threshold.
  • --stats ... — add known stats.

VS Code Panel

  • Command: BranchPy: Show Functions (Ctrl+Alt+F), filters for stat modifiers/unused/redefined, sortable columns, export filtered JSON/DOT, navigate to definition.

Performance

  • 1k functions <5s; 10k <20s; ~1MB per 1k functions.
  • Caching of AST parsing and incremental exports; governance logging optional.

Integration

  • Compare system: dynamic jump resolution and alias suggestions for function-based jumps.
  • Governance: audit log at ~/.branchpy/pfi_governance.jsonl (optional toggle).
  • CLI/Server: branchpy analyze --export-functions uses PFI exporters.

Invariants

  • No code execution; analysis is static.
  • Governance logging is non-blocking; failures degrade gracefully.
  • Exports avoid project content beyond necessary function source snippets.