diff --git a/lyrashield/interface/main.py b/lyrashield/interface/main.py index 6899cc9..9844d77 100644 --- a/lyrashield/interface/main.py +++ b/lyrashield/interface/main.py @@ -25,6 +25,8 @@ get_global_report_state, initial_run_record, sanitize_attachments, + sanitize_local_sources, + sanitize_targets_info, validate_run_record, ) from lyrashield.artifacts.writer import ( @@ -1080,12 +1082,12 @@ def _persist_run_record( run_record = initial_run_record( args.run_name, auth_mode=codex.auth_mode(load_settings().llm.model), - targets_info=args.targets_info, + targets_info=sanitize_targets_info(args.targets_info), extra={ "scan_mode": args.scan_mode, "instruction": args.instruction, "non_interactive": args.non_interactive, - "local_sources": getattr(args, "local_sources", []), + "local_sources": sanitize_local_sources(getattr(args, "local_sources", [])), "attachments": sanitize_attachments(getattr(args, "attachments", [])), "diff_scope": getattr(args, "diff_scope", {"active": False}), "scope_mode": args.scope_mode, diff --git a/lyrashield/interface/utils.py b/lyrashield/interface/utils.py index ada826a..5e3aaee 100644 --- a/lyrashield/interface/utils.py +++ b/lyrashield/interface/utils.py @@ -1310,7 +1310,7 @@ def resolve_diff_scope_context( raise if not repo_scopes: - if scope_mode == "auto": + if scope_mode == "auto" and diff_head is None: metadata: dict[str, Any] = {"active": False, "mode": scope_mode} if skipped_non_git: metadata["skipped_non_git_sources"] = skipped_non_git @@ -1326,13 +1326,10 @@ def resolve_diff_scope_context( instruction_block = build_diff_scope_instruction(repo_scopes) total_analyzable = sum(len(scope.analyzable_files) for scope in repo_scopes) total_deleted = sum(len(scope.deleted_files) for scope in repo_scopes) + # Each changed path counts once: modified already carries copied paths and + # low-similarity renames, so adding renamed+copied again double-counts. total_changed = sum( - len(scope.added_files) - + len(scope.modified_files) - + len(scope.renamed_files) - + len(scope.copied_files) - + len(scope.deleted_files) - for scope in repo_scopes + len(scope.analyzable_files) + len(scope.deleted_files) for scope in repo_scopes ) metadata = { "active": True,