diff --git a/README.md b/README.md index 673ae82..c2de96a 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,18 @@ REPO_REGISTRY_LLM_PROVIDER=gemini REPO_REGISTRY_LLM_MODEL=gemini-2.5-flash ``` +LLM assistance can also be disabled even when a provider is configured: + +```bash +REPO_REGISTRY_LLM_ENABLED=false +``` + +Individual analysis requests may opt out with `{"use_llm_assistance": false}`. +For local demos, `{"trusted_auto_approve": true}` approves the generated +candidate graph immediately after analysis and records the review decision as +`trusted_auto_approve_candidate_graph`. The default remains review-first: +automation is off unless explicitly requested. + ## Agent-Facing Endpoints The v0.1 API covers the main registration, analysis, review, search, and inspection loop: diff --git a/src/repo_registry/core/service.py b/src/repo_registry/core/service.py index e86525e..0d68b68 100644 --- a/src/repo_registry/core/service.py +++ b/src/repo_registry/core/service.py @@ -121,6 +121,8 @@ class RegistryService: *, source_path: str | None = None, use_cached_checkout: bool = False, + use_llm_assistance: bool = True, + trusted_auto_approve: bool = False, access_username: str | None = None, access_password: str | None = None, ) -> ScanSummary: @@ -187,6 +189,7 @@ class RegistryService: repository, facts, stored_chunks, + use_llm_assistance=use_llm_assistance, ) except Exception as exc: log_operation( @@ -221,6 +224,16 @@ class RegistryService: action="llm_extraction_used", notes=f"Generated {len(candidates)} candidate ability draft(s).", ) + if trusted_auto_approve: + self.approve_candidate_graph( + repository_id, + completed_run.id, + notes=( + "Trusted auto-populate mode approved candidate graph " + f"after {candidate_source} candidate generation." + ), + action="trusted_auto_approve_candidate_graph", + ) log_operation( "analysis_completed", repository_id=repository_id, @@ -241,8 +254,10 @@ class RegistryService: repository: Repository, facts: list[ObservedFact], chunks: list[ContentChunk], + *, + use_llm_assistance: bool = True, ): - if self.llm_extractor is not None: + if use_llm_assistance and self.llm_extractor is not None: extracted = self.llm_extractor.extract(repository, chunks) if extracted: return self.llm_mapper.map(extracted, facts, chunks), "llm" @@ -290,6 +305,7 @@ class RegistryService: analysis_run_id: int, *, notes: str = "", + action: str = "approve_candidate_graph", ) -> RepositoryAbilityMap: graph = self.store.get_candidate_graph(repository_id, analysis_run_id) pending_abilities = [ @@ -347,7 +363,7 @@ class RegistryService: self.store.create_review_decision( repository_id, analysis_run_id, - action="approve_candidate_graph", + action=action, notes=notes, ) self.store.update_repository_status(repository_id, "indexed") diff --git a/src/repo_registry/web_api/app.py b/src/repo_registry/web_api/app.py index 448b14c..413b744 100644 --- a/src/repo_registry/web_api/app.py +++ b/src/repo_registry/web_api/app.py @@ -61,6 +61,7 @@ class Settings(BaseSettings): database_path: str = Field(default="var/repo-registry.sqlite3") checkout_root: str = Field(default="var/checkouts") + llm_enabled: bool = Field(default=True) llm_provider: str | None = Field(default=None) llm_model: str | None = Field(default=None) embedding_provider: str | None = Field(default=None) @@ -80,7 +81,7 @@ def get_service(settings: Settings = Depends(get_settings)) -> RegistryService: store = RegistryStore(database_path) store.initialize() llm_extractor = None - if settings.llm_provider: + if settings.llm_enabled and settings.llm_provider: adapter = create_llm_connect_adapter( settings.llm_provider, model=settings.llm_model, @@ -246,6 +247,8 @@ def create_analysis_run( repository_id, source_path=payload.source_path, use_cached_checkout=payload.use_cached_checkout, + use_llm_assistance=payload.use_llm_assistance, + trusted_auto_approve=payload.trusted_auto_approve, access_username=payload.access_username, access_password=payload.access_password, ) diff --git a/src/repo_registry/web_api/schemas.py b/src/repo_registry/web_api/schemas.py index 4800ba3..340d42c 100644 --- a/src/repo_registry/web_api/schemas.py +++ b/src/repo_registry/web_api/schemas.py @@ -203,6 +203,8 @@ class EvidenceUpdate(BaseModel): class AnalysisRunCreate(BaseModel): source_path: str | None = None use_cached_checkout: bool = False + use_llm_assistance: bool = True + trusted_auto_approve: bool = False access_username: str | None = None access_password: str | None = Field(default=None, repr=False) @@ -212,6 +214,8 @@ class AnalysisRunCreate(BaseModel): {}, {"source_path": "/path/to/local/repository"}, {"use_cached_checkout": True}, + {"use_llm_assistance": False}, + {"trusted_auto_approve": True}, { "access_username": "git-user", "access_password": "access-token", diff --git a/src/repo_registry/web_ui/views.py b/src/repo_registry/web_ui/views.py index c1bc4fe..225d491 100644 --- a/src/repo_registry/web_ui/views.py +++ b/src/repo_registry/web_ui/views.py @@ -214,6 +214,8 @@ def render_repository_index( + +