Skip to content

Promote candidate lote1 changes to main (AUD-001/002/003/005/006/041)#20

Merged
nsalvacao merged 18 commits into
mainfrom
candidate/lote1-audit-2026-03-16
Mar 16, 2026
Merged

Promote candidate lote1 changes to main (AUD-001/002/003/005/006/041)#20
nsalvacao merged 18 commits into
mainfrom
candidate/lote1-audit-2026-03-16

Conversation

@nsalvacao

Copy link
Copy Markdown
Owner

Summary

Promote the validated lote1 batch from candidate to main after merging worker PRs and syncing candidate with main.

Included work:

  • AUD-001/AUD-002: docs command/path drift fixes
  • AUD-003: non-zero exit when root CLI is missing
  • AUD-005: user-safe generator CLI error handling
  • AUD-006: raw contract fix + regression test
  • AUD-041: quickstart troubleshooting guidance

Hygiene and sync performed

  • Removed accidentally tracked .dev artifacts from worker PR branches (without touching functional code changes).
  • Synced candidate with current main before promotion to avoid regressing main-only commits.
  • Verified no worker file-overlap conflicts and targeted tests pass in worker branches.

Validation highlights

  • tests/unit/test_pipeline_missing_cli_exit.py
  • tests/unit/test_generate_plugin_cli_errors.py
  • tests/unit/test_formatter_raw_contract.py

Notes

All worker PRs are merged into candidate/lote1-audit-2026-03-16; this PR promotes the consolidated, cleaned candidate state to main.

nsalvacao and others added 17 commits March 16, 2026 12:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fix: align raw output contract and add regression test (AUD-006)
- type-safe missing-binary detector signature\n- named exit-code constant for root CLI missing\n- pytest monkeypatch/raises simplification in tests\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fix: enforce non-zero exit when root CLI is missing (AUD-003)
fix: improve generate-plugin CLI error handling (AUD-005)
Apply PR #17 inline review suggestion for robust plugin copy command and clearer remediation steps.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…oting

docs: add quickstart troubleshooting blocks (AUD-041)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
docs: fix AUD-001/AUD-002 command drift
Bring candidate/lote1-audit-2026-03-16 up to date with main to avoid regressing main-only commits during promotion.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@github-actions

Copy link
Copy Markdown

🔍 AI Code Review

Code Review


src/crawler/formatter.py

-        _embed_raw(data.get("tree", {}), raw_outputs, cli_map.cli_name)
+        _embed_raw(data.get("commands", {}), raw_outputs)

🔵 Info: Changed key from "tree" to "commands" to match data structure.
🔵 Info: Removed unused cli_name parameter from _embed_raw.

-def _embed_raw(tree: dict, raw_outputs: dict[str, str], cli_name: str) -> None:
+def _embed_raw(tree: dict[str, Any], raw_outputs: dict[str, str]) -> None:

🟡 Warning: Type hint improved, but consider using Mapping or MutableMapping for clarity if mutation is intended.
🟡 Warning: Removed cli_name param, ensure no downstream usage depends on it.


src/crawler/pipeline.py

+import sys

🔵 Info: Added for sys.exit() usage.

+ROOT_CLI_NOT_FOUND_EXIT_CODE = 2
+
+class RootCLIBinaryNotFoundError(RuntimeError):
+    """Raised when the root CLI binary cannot be resolved/executed."""

🔵 Info: Good practice to define custom exception and exit code.

+    if _is_missing_root_cli_binary(cli_name, detection):
+        raise RootCLIBinaryNotFoundError(
+            f"Root CLI binary '{cli_name}' was not found. Ensure it is installed and in PATH."
+        )

🔵 Info: Early detection and explicit error raising improves UX.

+def _is_missing_root_cli_binary(cli_name: str, detection_result: HelpDetectionResult) -> bool:
+    ...
+    missing_markers = (
+        "command not found",
+        "not recognized as an internal or external command",
+        "no such file or directory",
+    )
+    return any(marker in signal_text for marker in missing_markers)

🟡 Warning: Matching error strings is brittle and locale-dependent. Consider checking exit codes or using platform-specific error detection if possible.

+    except RootCLIBinaryNotFoundError as exc:
+        logger.error("%s", exc)
+        sys.exit(ROOT_CLI_NOT_FOUND_EXIT_CODE)

🔵 Info: Proper error handling and exit.


src/generator/plugin_generator.py

+CLI_USER_ERROR_EXIT_CODE = 2

🔵 Info: Consistent exit code definition.

+    try:
+        cli_map = load_cli_map(args.json_path)
+    except FileNotFoundError:
+        parser.exit(
+            CLI_USER_ERROR_EXIT_CODE,
+            f"Error: input JSON file not found: {args.json_path}\n",
+        )
+    except json.JSONDecodeError as exc:
+        parser.exit(
+            CLI_USER_ERROR_EXIT_CODE,
+            f"Error: invalid JSON in input file {args.json_path}: {exc.msg}\n",
+        )
+    except ValueError as exc:
+        parser.exit(CLI_USER_ERROR_EXIT_CODE, f"Error: {exc}\n")

🔵 Info: Good user-friendly error handling with clear exit codes.


Tests

  • Added tests/unit/test_formatter_raw_contract.py (partial snippet shown).

🔵 Info: Adding regression tests for raw output embedding is good practice.


Summary

Severity Issue Recommendation
🔴 Critical None found. N/A
🟡 Warning Error string matching for missing CLI binary detection is brittle and locale-dependent. Consider platform-specific checks or exit code inspection for more robust detection.
🟡 Warning Removed cli_name parameter from _embed_raw without full context. Confirm no downstream dependencies on this parameter remain.
🔵 Info Good use of custom exceptions and exit codes for error handling. Maintain consistent exit codes across the project.
🔵 Info Improved user error messages in CLI generator. Continue adding tests for edge cases and error conditions.

No security issues or obvious bugs detected. Code changes improve error handling and robustness.


🤖 gpt-4.1-mini · 2494 tokens · GitHub Models free tier · 0 premium requests

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request promotes a validated batch of changes from the candidate/lote1-audit-2026-03-16 branch to main. The changes primarily focus on improving the robustness and user experience of the CLI crawling and plugin generation tools. Key areas addressed include refining documentation, enhancing error handling for missing CLI binaries and invalid input, and ensuring correct raw text embedding in generated outputs. The promotion follows a hygiene and sync process to integrate these improvements seamlessly into the main codebase.

Highlights

  • Documentation Updates (AUD-001/AUD-002, AUD-041): Updated various documentation files (README.md, docs/CONTRIBUTING.md, docs/README.md) to fix command and path drifts, simplify uv run commands, and add comprehensive troubleshooting guidance for quickstart steps.
  • Robust CLI Crawler Error Handling (AUD-003): Implemented non-zero exit behavior in the CLI crawler (src/crawler/pipeline.py) when the root CLI binary is missing, providing clearer error messages and a specific exit code.
  • User-Safe Generator CLI Error Handling (AUD-005): Enhanced the plugin generator (src/generator/plugin_generator.py) with improved error handling for missing input files, invalid JSON, and other ValueError exceptions, ensuring a more user-friendly experience with specific exit codes.
  • Raw Contract Fix and Regression Test (AUD-006): Corrected the raw text embedding logic in src/crawler/formatter.py to ensure raw help text is properly inlined into command nodes when specified, accompanied by a new regression test (tests/unit/test_formatter_raw_contract.py).
  • New Test Coverage: Added new unit tests to cover scenarios for missing CLI binary exit behavior, generator CLI error handling, and the raw output contract for the formatter.
Changelog
  • README.md
    • Added troubleshooting guidance for uv sync, cli-crawler, and generate-plugin commands.
    • Updated the cp command for plugin installation to use mkdir -p and a more general destination path.
  • docs/CONTRIBUTING.md
    • Updated file paths for crawler and generator modules to reflect the src/ directory structure.
    • Simplified uv run commands for testing, crawling, and plugin generation by removing explicit python -m and python prefixes.
    • Streamlined uv run commands for linting and formatting tools (ruff check, ruff format).
  • docs/README.md
    • Updated uv run commands for crawling and generating plugins, removing python prefixes and changing --include-raw to --raw.
    • Revised architecture paths to reflect the src/ directory structure for crawler and generator.
    • Updated the directory structure diagram to include pyproject.toml and the new src/ subdirectories.
    • Modified the batch crawl example to use a for loop for clarity and flexibility.
  • src/crawler/formatter.py
    • Modified the _embed_raw function to correctly embed raw help text into command nodes, adjusting the tree access and removing an unnecessary cli_name parameter.
  • src/crawler/pipeline.py
    • Introduced ROOT_CLI_NOT_FOUND_EXIT_CODE and RootCLIBinaryNotFoundError for specific error handling.
    • Implemented a check in crawl_cli to raise RootCLIBinaryNotFoundError if the root CLI binary is not found.
    • Added a _is_missing_root_cli_binary helper function to detect common patterns indicating a missing CLI.
    • Wrapped the crawl_cli call in main with a try-except block to catch RootCLIBinaryNotFoundError and exit with a non-zero status.
  • src/generator/plugin_generator.py
    • Defined CLI_USER_ERROR_EXIT_CODE for consistent error reporting.
    • Added try-except blocks in main to handle FileNotFoundError, json.JSONDecodeError, and ValueError during CLI map loading, providing user-friendly error messages and exiting with a specific code.
  • tests/unit/test_formatter_raw_contract.py
    • Added a new unit test to ensure that raw help text is correctly embedded within command nodes when the --raw flag is active, verifying the formatter's contract.
  • tests/unit/test_generate_plugin_cli_errors.py
    • Added unit tests to confirm that the generate-plugin CLI correctly reports and exits with a non-zero status for missing input JSON files and invalid JSON content.
  • tests/unit/test_pipeline_missing_cli_exit.py
    • Added unit tests to verify that crawl_cli raises RootCLIBinaryNotFoundError when a CLI binary is missing and that the cli-crawler main function exits with the appropriate non-zero status.
Activity
  • The lote1 batch of changes was promoted from the candidate branch to main after merging worker PRs.
  • Accidentally tracked .dev artifacts were removed from worker PR branches to maintain repository hygiene.
  • The candidate branch was synced with main to prevent regressions from main-only commits.
  • Verified that there were no file-overlap conflicts among worker branches and that targeted tests passed.
  • Specific validation was performed on tests/unit/test_pipeline_missing_cli_exit.py, tests/unit/test_generate_plugin_cli_errors.py, and tests/unit/test_formatter_raw_contract.py.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request promotes a batch of validated changes from a candidate branch to main. The changes are substantial and of high quality, focusing on improving documentation, CLI usability, and robustness. Key improvements include a documentation overhaul to reflect project refactoring and updated commands, enhanced CLI error handling for missing binaries or invalid inputs, and the addition of comprehensive unit tests for the new functionality. The code is clear, the improvements are significant, and I have no specific recommendations for changes as the implementation is solid.

Address PR #20 review concern about locale-dependent missing-binary detection by adding a PATH preflight check in crawl_cli and a focused regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

🔍 AI Code Review

# Code Review Summary

---

## src/crawler/formatter.py

🔵 **Info**  
- Changed `_embed_raw` to remove `cli_name` parameter, simplifying the function signature and call sites.  
- Changed key from `"tree"` to `"commands"` when embedding raw help text, likely a bug fix.

---

## src/crawler/pipeline.py

🟡 **Warning**  
- Added pre-check with `shutil.which(cli_name)` to fast-fail if root CLI binary is missing. Good for UX.  
- Also added heuristic `_is_missing_root_cli_binary` to detect missing binary from help detection stderr/stdout.  
- Raises `RootCLIBinaryNotFoundError` on missing binary, caught in `main()` to exit with code 2.  
- **Consider:** `shutil.which` may not detect binaries in some environments (e.g., non-PATH locations). The heuristic helps but may produce false negatives/positives.  
- **Suggestion:** Document this behavior clearly for users.

🔵 **Info**  
- Added explicit exit code constant `ROOT_CLI_NOT_FOUND_EXIT_CODE = 2` for clarity and maintainability.

---

## src/generator/plugin_generator.py

🟡 **Warning**  
- Added error handling around JSON loading with explicit exit codes and user-friendly messages.  
- Good practice to fail fast on invalid input files.  
- **Suggestion:** Consider logging the error before exiting for debugging purposes.

---

# Security Considerations

🔵 No direct security issues detected.  
- No user input is executed or evaluated unsafely.  
- Error handling improves robustness.

---

# Bugs

🔵 The fix in `formatter.py` from `"tree"` to `"commands"` likely fixes a bug where raw help text was not embedded correctly.

---

# Best Practices

🟢 Good use of custom exceptions and exit codes for clearer error handling.  
🟢 Improved user feedback on missing binaries and invalid input files.

---

# Summary

This PR improves robustness and user experience by:  
- Adding early detection of missing CLI binaries.  
- Improving error handling on JSON input.  
- Fixing a bug in embedding raw help text.

No critical issues found. Minor suggestions for documentation and logging improvements.

🤖 gpt-4.1-mini · 2036 tokens · GitHub Models free tier · 0 premium requests

@nsalvacao

Copy link
Copy Markdown
Owner Author

Review sweep done on PR #20 (all comments + review notes, including bot feedback).

  • Accepted as relevant: warning about locale-dependent missing-binary detection.
    • Applied in commit fc91178: added PATH preflight via shutil.which in crawl_cli plus regression test test_crawl_cli_fails_fast_when_root_binary_is_not_in_path.
  • Not actioned (low relevance or no concrete defect):
    • suggestion to change _embed_raw to Mapping or MutableMapping (function intentionally mutates node dictionaries; current dict typing remains explicit).
    • generic reminder to verify removed _embed_raw arg usage (already validated by current codepath and tests).

Validation run:

  • PYTHONPATH=src pytest tests/unit/test_pipeline_missing_cli_exit.py -q
  • PYTHONPATH=src pytest tests/ -q
  • ruff check src/crawler/pipeline.py tests/unit/test_pipeline_missing_cli_exit.py

Inline review threads status: none open or existing on this PR at this moment, so nothing to resolve or close.

@nsalvacao nsalvacao merged commit a72312f into main Mar 16, 2026
7 checks passed
@nsalvacao nsalvacao deleted the candidate/lote1-audit-2026-03-16 branch March 16, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant