Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/acdeveloper-sci/fortriage/llms.txt

Use this file to discover all available pages before exploring further.

ForTriage’s analysis pipeline is encapsulated in the fortriage.pipeline module. The public surface consists of a single entry-point function run_pipeline() and the PipelineResult dataclass it returns. The pipeline invokes Forti4D as a subprocess, reads its CSV and Markdown outputs into memory, and returns them in a structured result object. All other modules — views, AI Insights, session state — depend only on PipelineResult’s fields and never interact with Forti4D directly.

run_pipeline()

run_pipeline is the single public function in the fortriage.pipeline module. It accepts a path to a directory of Fortran source files, runs the full Forti4D analysis, and returns a PipelineResult with all output data loaded into memory. Signature
run_pipeline(source_dir: Path) -> PipelineResult
ParameterTypeDescription
source_dirPathPath to a directory containing Fortran source files to analyze.
Returns: PipelineResult — all report data loaded into memory. Raises:
  • PipelineError — if forti4d exits with a non-zero return code, the executable is not found in PATH, or the subprocess invocation fails at the OS level.
  • FileNotFoundError — if expected output files are absent after a successful run.
run_pipeline is a blocking call — it uses subprocess.run and waits for Forti4D to complete before returning. In the Streamlit app it is invoked in a background thread so that the UI can display a rotating spinner and remain responsive during analysis.
Example
from pathlib import Path
from fortriage.pipeline import run_pipeline, PipelineError

try:
    result = run_pipeline(Path("/path/to/fortran/src"))
    print(result.prioritization.head())
except PipelineError as e:
    print(f"Analysis failed: {e}")

PipelineResult

PipelineResult is a frozen dataclass. All data is loaded into memory before temporary directories are cleaned up, so no file-path references escape this object.
@dataclass(frozen=True)
class PipelineResult:
    prioritization: pd.DataFrame
    consolidated: pd.DataFrame
    migration_strategy: pd.DataFrame
    common_coupling: pd.DataFrame
    clones: pd.DataFrame
    project_summary: str
FieldTypeSource fileDescription
prioritizationpd.DataFramereport_prioritization.csvRanked units with tier, score, CC, Fan-In, strategy, reachability, and key legacy metrics. Primary table for the Overview view and AI Insights KPIs.
consolidatedpd.DataFramereport_consolidated.csvFull diagnostic report with approximately 34 columns per unit, including all raw metrics used to compute the Score. Used by the Drill-down view.
migration_strategypd.DataFramereport_migration_strategy.csvPer-unit migration strategy, sorted by Priority_Num. Displayed in the Report Explorer tab.
common_couplingpd.DataFramecommon_coupling.csvCOMMON block coupling risks — one row per COMMON block, with unit/file counts and risk level. Used by the Report Explorer and AI Insights.
clonespd.DataFramereport_clones.csvDuplicate and near-duplicate unit detection — one row per clone pair. Used by the Report Explorer and AI Insights.
project_summarystrPROJECT_SUMMARY.mdExecutive summary in Markdown format, rendered verbatim in the Executive Summary view.

PipelineError

PipelineError is the single exception type raised for all subprocess-level failures. Callers only ever need to catch this one type to handle “the pipeline could not produce a result.” Raised when:
  • forti4d exits with a non-zero return code.
  • The forti4d executable is not found in PATH.
  • The subprocess invocation fails at the OS level for any other reason.
The error message includes the last 20 lines of Forti4D’s stderr output (controlled by STDERR_TAIL_LINES in config.py). The full raw stderr is often long and mostly noise; only the trailing lines tend to carry the actual error message — the same principle as tail -n for log inspection.
All subprocess failures — whether a non-zero exit code or an OS-level exception like FileNotFoundError from the operating system when the executable is missing — are normalized to PipelineError. Downstream callers never need to handle subprocess.CalledProcessError, OSError, or any other subprocess exception type.

Environment Variables

The pipeline sets several environment variables in the subprocess environment before invoking Forti4D.
VariableSet byDescription
FORT_SRCrun_pipelinePoints to the isolated temp copy of source files. Consumed by Forti4D to locate input files.
FORT_OUTrun_pipelinePoints to the temp output directory. Forti4D writes all CSV and Markdown reports here.
PYTHONIOENCODINGrun_pipelineSet to utf-8 in the child process to prevent UnicodeEncodeError on Windows (where the default console encoding is cp1252, which cannot encode some characters Forti4D writes to stdout/stderr).
FORTRIAGE_PROMPTS_DIRCaller (optional)Overrides the PROMPTS_DIR constant at runtime, pointing to a custom directory of LLM prompt files. See the Configuration reference for details.

Subprocess Isolation

ForTriage ensures that the Forti4D analysis is fully isolated and leaves no temporary files on disk after completion.
1

Copy sources to a temp directory

User-provided source files are copied into a temporary directory with the prefix fortriage_src_*. This prevents any writes from the analysis engine from touching the user’s original files.
2

Create an output temp directory

A second temporary directory with the prefix fortriage_out_* is created to receive Forti4D’s CSV and Markdown report outputs.
3

Invoke Forti4D

Forti4D is invoked as a subprocess with FORT_SRC and FORT_OUT set to the respective temp directories. The process runs synchronously.
4

Load outputs into memory

All six output files are read into PipelineResult fields before the temp directories are cleaned up.
5

Clean up temp directories

Both temp directories are deleted by Python’s tempfile.TemporaryDirectory context manager. PipelineResult holds all data in memory — no file path references escape the dataclass.
This design means PipelineResult is fully self-contained. There are no file handles, no temp paths, and no references to the filesystem after run_pipeline returns. The entire analysis artifact lives in the dataclass fields until the Streamlit session ends or a new analysis is started.

Build docs developers (and LLMs) love