kkrunner.projects.ProjectRepository
- class kkrunner.projects.ProjectRepository(directory=None)[source]
Bases:
objectPersist and publish generation-checked project JSON documents.
Files remain authoritative. The in-memory snapshot exists only to report changes discovered by
refresh(); every save still performs its generation check against the current on-disk document while holding the corresponding stable sidecar lock.- Parameters:
directory (str | Path | None)
- subscribe(listener)[source]
Subscribe to local or refreshed project changes.
- Parameters:
listener (Callable[[str], None])
- Return type:
Callable[[], None]
- project(project_id)[source]
Load and remember one project by UUID.
- Parameters:
project_id (str)
- Return type:
- refresh()[source]
Reload project files and publish ids whose snapshots changed.
- Return type:
tuple[Project, …]
- create(name, *, parent_id=None, directory=None)[source]
Create a root or child project at generation one.
- Parameters:
name (str)
parent_id (str | None)
directory (str | Path | None)
- Return type:
- save(project, *, expected_generation, overwrite=False)[source]
Persist an edited project snapshot using optimistic concurrency.
overwritemeans exactly that: the supplied snapshot replaces newer persisted values after validating it against the current project forest. It is intentionally not an implicit merge operation.