ProjectContext API
The project object passed to every policy's evaluate function provides these methods:
Methods
project.get_file_content(path) -> str | None
Read the content of a file by its path. Returns None if the file doesn't exist.
content = project.get_file_content("README.md")
if content and "## Contributing" in content:
# Has a contributing section
project.list_files() -> list[str]
List all file paths in the repository.
project.get_languages() -> dict[str, float]
Language breakdown as percentages.
project.get_members() -> list[dict]
Project members with roles.
project.get_contributors() -> list[dict]
Contributors with commit counts.
project.get_default_branch() -> str
Name of the default branch.
project.get_topics() -> list[str]
Repository topics/tags.
project.get_metadata() -> dict
General repository metadata.
meta = project.get_metadata()
# {
# "name": "my-project",
# "description": "A cool project",
# "web_url": "https://github.com/org/my-project",
# "created_at": "2024-01-01T00:00:00Z",
# "updated_at": "2024-06-01T00:00:00Z",
# }
Execution environment
- Policies run in isolated gVisor containers with no network access
- Execution timeout: 30 seconds
- Memory limit: 128 MB
- Only the
projectAPI is available — no filesystem, no imports beyond the standard library