test(output): add direct unit tests for app/output.py (#871)#2
Closed
Davidson3556 wants to merge 1 commit into
Closed
test(output): add direct unit tests for app/output.py (#871)#2Davidson3556 wants to merge 1 commit into
Davidson3556 wants to merge 1 commit into
Conversation
Cover get_output_format(), _humanise_message(), _fmt_timing(), and ProgressTracker.start()/complete() in text mode. Tests are deterministic (env vars scrubbed via autouse fixture, time.monotonic patched, output format forced to text) so no real TTY is required.
Davidson3556
pushed a commit
that referenced
this pull request
May 6, 2026
…racer-Cloud#1287) * feat(rds): add RDS integration with describe instance and events tools - Add app/integrations/rds.py for source detection and param extraction - Add RDSDescribeInstanceTool for instance status and configuration - Add RDSEventsTool for failover, maintenance, and parameter events - Use shared aws_sdk_client read-only allowlist for safety - Add unit tests for integration helpers and both tools - Add "rds" to EvidenceSource literal in app/types/evidence.py Closes Tracer-Cloud#125 * fix(rds): honor RDS_REGION env var in both config and param extraction Greptile review caught two related issues in app/integrations/rds.py: - rds_config_from_env: env_str("AWS_REGION", DEFAULT_RDS_REGION) always returned a non-empty string, making the RDS_REGION fallback unreachable (P1 dead code). - rds_extract_params: only consulted AWS_REGION, never RDS_REGION, diverging from the config path (P2 inconsistency). Both functions now resolve region as: source-supplied > AWS_REGION > RDS_REGION > DEFAULT_RDS_REGION. Drops the now-unused os import. Adds three tests covering the previously-uncovered fallback paths: RDS_REGION-only in extract, RDS_REGION-only in config-from-env, and default when neither env var is set. * chore(rds): apply ruff lint and format fixes - ruff check --fix reorganized imports in tests/tools/test_rds_tools.py - ruff format reformatted app/integrations/rds.py * docs(rds): add RDS integration documentation - New docs/rds.mdx covering setup, env vars, IAM permissions, the two tools, use cases, and troubleshooting. References docs/aws.mdx for shared AWS credential setup rather than duplicating it. - Register the page under "Data and workflow systems" in docs/docs.json. Documents the RDS_REGION fallback semantics so users understand the region resolution order: source dict > AWS_REGION > RDS_REGION > default. * fix(rds): sanitize AWS SDK errors and warn on multiple instances - Replace raw AWS error forwarding with generic messages in both RDSDescribeInstanceTool and RDSEventsTool; full errors are logged server-side only to prevent leaking account IDs, ARNs, or regions. - Add warning log when DescribeDBInstances returns more than one instance, since only the first is used. - Update test assertions to match the new sanitized error messages. * test(rds): add coverage for multiple-instances warning path Verifies that when DescribeDBInstances returns >1 record, the tool uses the first instance and emits a warning log. * fix(rds): wire RDS into env discovery, classification, and source detection Reviewer found three real wiring gaps that meant the documented setup path never reached the planner. The integration helpers were correct but nothing else in the pipeline knew about RDS: - app/integrations/_catalog_impl.py::load_env_integrations now registers an "rds" record when rds_config_from_env returns a configured instance. Previously env-set RDS_DB_INSTANCE_IDENTIFIER was a no-op. - app/integrations/_catalog_impl.py::_classify_service_instance gains an "rds" branch that returns a flat shape ({db_instance_identifier, region, integration_id}) instead of falling through to the generic handler that nests fields under "credentials" — which made rds_is_available always return False for store-backed configs. - app/nodes/plan_actions/detect_sources.py now copies the resolved rds integration into sources["rds"], mirroring the rabbitmq/mariadb blocks. Without this, even a correctly-resolved integration would not be visible to rds_is_available. Adds tests/integrations/test_rds.py::test_rds_env_discovery_to_sources_pipeline which walks the full env -> load_env_integrations -> _classify_service_instance -> detect_sources path end to end and asserts each stage produces the expected shape, so this regression cannot reappear silently. * test(rds): add focused regression coverage for the three discovery gaps Adds six targeted tests that isolate each of the gaps the reviewer flagged so any regression in one stage fails its own test rather than bleeding into the end-to-end pipeline test: Gap #1 — load_env_integrations: test_load_env_integrations_skips_rds_when_db_id_missing Gap #2 — _classify_service_instance: test_classify_service_instance_rds_remote_store_returns_flat_shape test_classify_service_instance_rds_skips_when_db_id_missing Gap Tracer-Cloud#3 — detect_sources: test_detect_sources_propagates_rds_into_sources test_detect_sources_skips_rds_when_not_in_resolved_integrations test_detect_sources_skips_rds_when_db_id_blank The remote-store classifier test asserts the absence of a "credentials" key in the returned dict, which is the exact failure mode the reviewer called out (generic fallback nests fields and silently breaks rds_is_available). 25 RDS tests pass; mypy, lint, format clean. --------- Co-authored-by: code wizard <codewizard@gmail.com>
Davidson3556
pushed a commit
that referenced
this pull request
May 9, 2026
…ud#1576) * Move app imports inside main() to remove E402 noqas (PR #2 of 4) * Remove ARG001/PLC0415/BLE001 noqas in nodes and stragglers (PR Tracer-Cloud#3 of 4) * fix: add comment on banner.py to satisfy codeQL flagging
Davidson3556
pushed a commit
that referenced
this pull request
May 9, 2026
…rols (Tracer-Cloud#1387) * feat(cli): redact secrets from interactive history; add /privacy and /history controls Closes Tracer-Cloud#1377 * fix(cli): resolve history privacy review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(cli): restore privacy commands in help Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(privacy): close greptile gaps on PEM redaction and retention 0 Address Greptile review feedback to lift the score to 5/5: - P1 #1 (security): the private_key redaction pattern previously matched only the BEGIN header line, so pasted multi-line PEM blocks leaked the body and END footer to disk. Pattern now spans header through footer with a non-greedy body match. Test added that pastes a full RSA, EC, and OPENSSH PEM block and asserts both the base64 body and END marker are gone after redaction (single-string and history-store paths). - P1 #2: /history retention 0 now sets the cap by writing backend._max_entries directly and only calls _prune_to_cap when n > 0, matching the same guard that store_string already uses. Existing test_zero_sets_unlimited_without_crashing still passes. - P1 Tracer-Cloud#3: /history off and /history on already distinguish the three backend cases (RedactingFileHistory, plain FileHistory, InMemoryHistory) with accurate messages, and dedicated tests cover the FileHistory branch for both subcommands. - P2 #1: backend identity check uses isinstance(backend, InMemoryHistory) instead of fragile __class__.__name__ string matching. - P2 #2: paused is initialized in __init__ with an explicit bool annotation rather than as a class-level annotation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update app/cli/interactive_shell/history_policy.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix(cli): use set_max_entries for /history retention Avoid direct _max_entries mutation; matches RedactingFileHistory public API. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Anwesh <8139783+muddlebee@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: muddlebee <anweshknayak@gmail.com>
Davidson3556
pushed a commit
that referenced
this pull request
May 15, 2026
…racer-Cloud#1287) * feat(rds): add RDS integration with describe instance and events tools - Add app/integrations/rds.py for source detection and param extraction - Add RDSDescribeInstanceTool for instance status and configuration - Add RDSEventsTool for failover, maintenance, and parameter events - Use shared aws_sdk_client read-only allowlist for safety - Add unit tests for integration helpers and both tools - Add "rds" to EvidenceSource literal in app/types/evidence.py Closes Tracer-Cloud#125 * fix(rds): honor RDS_REGION env var in both config and param extraction Greptile review caught two related issues in app/integrations/rds.py: - rds_config_from_env: env_str("AWS_REGION", DEFAULT_RDS_REGION) always returned a non-empty string, making the RDS_REGION fallback unreachable (P1 dead code). - rds_extract_params: only consulted AWS_REGION, never RDS_REGION, diverging from the config path (P2 inconsistency). Both functions now resolve region as: source-supplied > AWS_REGION > RDS_REGION > DEFAULT_RDS_REGION. Drops the now-unused os import. Adds three tests covering the previously-uncovered fallback paths: RDS_REGION-only in extract, RDS_REGION-only in config-from-env, and default when neither env var is set. * chore(rds): apply ruff lint and format fixes - ruff check --fix reorganized imports in tests/tools/test_rds_tools.py - ruff format reformatted app/integrations/rds.py * docs(rds): add RDS integration documentation - New docs/rds.mdx covering setup, env vars, IAM permissions, the two tools, use cases, and troubleshooting. References docs/aws.mdx for shared AWS credential setup rather than duplicating it. - Register the page under "Data and workflow systems" in docs/docs.json. Documents the RDS_REGION fallback semantics so users understand the region resolution order: source dict > AWS_REGION > RDS_REGION > default. * fix(rds): sanitize AWS SDK errors and warn on multiple instances - Replace raw AWS error forwarding with generic messages in both RDSDescribeInstanceTool and RDSEventsTool; full errors are logged server-side only to prevent leaking account IDs, ARNs, or regions. - Add warning log when DescribeDBInstances returns more than one instance, since only the first is used. - Update test assertions to match the new sanitized error messages. * test(rds): add coverage for multiple-instances warning path Verifies that when DescribeDBInstances returns >1 record, the tool uses the first instance and emits a warning log. * fix(rds): wire RDS into env discovery, classification, and source detection Reviewer found three real wiring gaps that meant the documented setup path never reached the planner. The integration helpers were correct but nothing else in the pipeline knew about RDS: - app/integrations/_catalog_impl.py::load_env_integrations now registers an "rds" record when rds_config_from_env returns a configured instance. Previously env-set RDS_DB_INSTANCE_IDENTIFIER was a no-op. - app/integrations/_catalog_impl.py::_classify_service_instance gains an "rds" branch that returns a flat shape ({db_instance_identifier, region, integration_id}) instead of falling through to the generic handler that nests fields under "credentials" — which made rds_is_available always return False for store-backed configs. - app/nodes/plan_actions/detect_sources.py now copies the resolved rds integration into sources["rds"], mirroring the rabbitmq/mariadb blocks. Without this, even a correctly-resolved integration would not be visible to rds_is_available. Adds tests/integrations/test_rds.py::test_rds_env_discovery_to_sources_pipeline which walks the full env -> load_env_integrations -> _classify_service_instance -> detect_sources path end to end and asserts each stage produces the expected shape, so this regression cannot reappear silently. * test(rds): add focused regression coverage for the three discovery gaps Adds six targeted tests that isolate each of the gaps the reviewer flagged so any regression in one stage fails its own test rather than bleeding into the end-to-end pipeline test: Gap #1 — load_env_integrations: test_load_env_integrations_skips_rds_when_db_id_missing Gap #2 — _classify_service_instance: test_classify_service_instance_rds_remote_store_returns_flat_shape test_classify_service_instance_rds_skips_when_db_id_missing Gap Tracer-Cloud#3 — detect_sources: test_detect_sources_propagates_rds_into_sources test_detect_sources_skips_rds_when_not_in_resolved_integrations test_detect_sources_skips_rds_when_db_id_blank The remote-store classifier test asserts the absence of a "credentials" key in the returned dict, which is the exact failure mode the reviewer called out (generic fallback nests fields and silently breaks rds_is_available). 25 RDS tests pass; mypy, lint, format clean. --------- Co-authored-by: code wizard <codewizard@gmail.com>
Davidson3556
pushed a commit
that referenced
this pull request
May 15, 2026
…ud#1576) * Move app imports inside main() to remove E402 noqas (PR #2 of 4) * Remove ARG001/PLC0415/BLE001 noqas in nodes and stragglers (PR Tracer-Cloud#3 of 4) * fix: add comment on banner.py to satisfy codeQL flagging
Davidson3556
pushed a commit
that referenced
this pull request
May 15, 2026
…rols (Tracer-Cloud#1387) * feat(cli): redact secrets from interactive history; add /privacy and /history controls Closes Tracer-Cloud#1377 * fix(cli): resolve history privacy review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(cli): restore privacy commands in help Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(privacy): close greptile gaps on PEM redaction and retention 0 Address Greptile review feedback to lift the score to 5/5: - P1 #1 (security): the private_key redaction pattern previously matched only the BEGIN header line, so pasted multi-line PEM blocks leaked the body and END footer to disk. Pattern now spans header through footer with a non-greedy body match. Test added that pastes a full RSA, EC, and OPENSSH PEM block and asserts both the base64 body and END marker are gone after redaction (single-string and history-store paths). - P1 #2: /history retention 0 now sets the cap by writing backend._max_entries directly and only calls _prune_to_cap when n > 0, matching the same guard that store_string already uses. Existing test_zero_sets_unlimited_without_crashing still passes. - P1 Tracer-Cloud#3: /history off and /history on already distinguish the three backend cases (RedactingFileHistory, plain FileHistory, InMemoryHistory) with accurate messages, and dedicated tests cover the FileHistory branch for both subcommands. - P2 #1: backend identity check uses isinstance(backend, InMemoryHistory) instead of fragile __class__.__name__ string matching. - P2 #2: paused is initialized in __init__ with an explicit bool annotation rather than as a class-level annotation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update app/cli/interactive_shell/history_policy.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * fix(cli): use set_max_entries for /history retention Avoid direct _max_entries mutation; matches RedactingFileHistory public API. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Anwesh <8139783+muddlebee@users.noreply.github.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: muddlebee <anweshknayak@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
app/output.pyintests/test_output.py(35 tests).get_output_format(),_humanise_message()(all branches),_fmt_timing()(parametrised across the ms/seconds boundary), andProgressTracker.start()/complete()in text mode.time.monotonicmonkeypatched where elapsed time matters, output format forced totextso no real TTY is required.Closes Tracer-Cloud#871.
Test plan
python -m pytest tests/test_output.py— 35 passedruff check tests/test_output.py— cleanmake format-check— cleanmake typecheck— clean