A static analysis tool for measuring architectural context exposure in codebases.
Project description
Context Footprint
A static analysis tool for measuring architectural context exposure in codebases.
Context Footprint is a research prototype that computes a Context Footprint (CF) metric for functions and types in a codebase.
CF approximates the amount of code context that must be traversed to analyze a given symbol, based on language-level dependencies and abstraction boundaries.
This tool is developed alongside an ongoing academic study and is intended for measurement, comparison, and empirical analysis, rather than production use.
Status
⚠️ Research Preview
- The CF definition and traversal rules are still evolving.
- APIs, outputs, and heuristics may change before publication.
- The repository currently serves reproducibility and early feedback purposes.
What the Tool Does
Given a semantic index of a codebase, the tool can:
- Compute the distribution of CF values across all functions or types
- Identify symbols with unusually large context exposure
- Query the CF of a specific symbol
- Print the source code that contributes to a symbol’s CF
CF is computed via conservative graph traversal over language-level dependencies, with configurable pruning rules.
Supported Languages
The tool consumes semantic data (JSON) produced by language-specific extractors (e.g. LSP-based), and is therefore language-agnostic in principle.
Tested languages include:
- Python
- TypeScript
Support for additional languages depends on the availability of semantic data extractors that output the SemanticData JSON format.
Installation
Option 1: uv / pip (recommended)
Install as a Python tool—includes the cf-extract command for Python project extraction:
uv tool install cftool
# or: pip install cftool
Requires Python 3.9+.
Option 2: Cargo
Build from source:
git clone https://github.com/yourusername/context-footprint.git
cd context-footprint
cargo build --release
Requires Rust 1.70+.
Prerequisites
- A semantic data JSON file for the target project (e.g. from
cf-extractfor Python)
Basic Usage
1. Generate semantic data
For Python projects, use the bundled extractor:
cf-extract /path/to/python/project > semantic_data.json
Or use another extractor (e.g. LSP-based) that outputs the SemanticData JSON format.
2. Analyze CF distribution
cftool semantic_data.json stats
# or with cargo build: ./target/release/cftool semantic_data.json stats
3. Find symbols with highest CF
cftool semantic_data.json top --limit 10
4. Query a specific symbol
cftool semantic_data.json compute "<symbol-id>"
5. Inspect contributing context
cftool semantic_data.json context "<symbol-id>"
Output
The tool reports CF values as token counts, using a configurable size function. Output includes percentile distributions and summary statistics for large codebases.
Example:
Functions - Context Footprint Distribution:
Count: 856
Median: 245 tokens
90th percentile: 20,567 tokens
How CF Is Computed (Brief)
-
A directed dependency graph is constructed from the semantic data (JSON).
-
Starting from a target symbol, dependencies are traversed conservatively.
-
Traversal stops at:
- External libraries
- Explicit abstraction boundaries defined by the pruning policy
-
The size of the reachable subgraph is summed.
The default pruning policy is intentionally conservative and favors soundness over precision.
For a formal definition, see docs/design.md.
Project Structure
The implementation separates core analysis logic from language-specific adapters:
src/
├─ domain/ # Graph model and traversal logic
└─ adapters/ # Size functions, doc scoring, test detection
License
Apache 2.0
Acknowledgements
Semantic data is consumed as JSON (e.g. from LSP-based extractors).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file context_footprint-0.1.0-py3-none-win_amd64.whl.
File metadata
- Download URL: context_footprint-0.1.0-py3-none-win_amd64.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad235eb82518fb189d46f07fa047c21544a53766e40c5395c389dfa868e7694e
|
|
| MD5 |
241f80b0cb341d5a66fd1c2ce62969cd
|
|
| BLAKE2b-256 |
d09e50cf63dace1d02c85fac74108b6e01ad092d37a72eef57fa8eff75bda483
|
File details
Details for the file context_footprint-0.1.0-py3-none-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: context_footprint-0.1.0-py3-none-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 2.8 MB
- Tags: Python 3, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e774c263218208bfe2215175043afd09275065670e214cd3570e123d97af6f0e
|
|
| MD5 |
01580624812aadcbd22ed6fdfd582e9a
|
|
| BLAKE2b-256 |
8bf6618994405e6bb951fe260825d5f2ec0634250c759a6262c50708038a277d
|
File details
Details for the file context_footprint-0.1.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: context_footprint-0.1.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baf4f606e25b3dc7692d5355195bc9256fe2dc2d896d59624e22c3a3cfe0df7a
|
|
| MD5 |
d3ba7e6dab55d8b7bc1154d19fe8f70b
|
|
| BLAKE2b-256 |
bf23fbf21a77317fc58e0efe05049708a521f05e6a8dc07e6b3516f731a4bce0
|