Skip to content

fix(review): remediate session findings and harden self-improvement review loop - #673

Merged
dan-petty merged 1 commit into
release/v0.2.23from
fix/review-remediation-self-improvement
Sep 28, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.23from
fix/review-remediation-self-improvement

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

This PR remediates genuine findings identified during review session 20260928-040906 on release/v0.2.23 and hardens the self-improvement, common hallucination verification, and feedback loop.

Remediated Review Findings

  1. src/devops_cli/ai/run_store.py:
    • Hardened get_run(run_id, ...) to reject path traversal attempts containing /, \, or ...
    • Added verification that all matched files remain relative to the resolved base root workspace.
  2. src/devops_cli/cloudflare/client.py:
    • Narrowed broad exception handling in _handle_response to (ValueError, json.JSONDecodeError).
  3. src/devops_cli/ai/analyze/symbols.py:
    • Narrowed bare except Exception: in extract_python_source_symbols to SyntaxError, ValueError, RecursionError.
  4. src/devops_cli/ai/spend/payoff.py:
    • Narrowed bare except Exception: in _calculate_days_active to ValueError, TypeError.
  5. src/devops_cli/ai/knowledge_base/it_domains/tools/ollama.md:
    • Updated outdated manifest reference k8s/llm/ollama.yaml to k8s/llm/profiles/ollama-profiles.yaml.
  6. src/devops_cli/config/constants.py:
    • Expanded CONST_FIXTURE_CREDENTIAL_KEYWORDS to cover "hardcoded api key", "hardcoded key", "exposed api key", "plaintext api key", and "api key masking".

Self-Improvement & Review Loop Hardening

  1. Ground Truth Verification Refactoring (src/devops_cli/ai/review/common_hallucinations.py):
    • Decomposed monolithic verification into single-responsibility verifiers (_verify_syntax_grammar_ground_truth, _verify_secret_scanning_ground_truth, _verify_dependency_ecosystem_ground_truth, _verify_test_mocks_ground_truth, _verify_documentation_context_ground_truth, _verify_mutable_defaults_ground_truth, _verify_boundary_errors_ground_truth) with table-driven dispatch via _GROUND_TRUTH_VERIFIERS.
    • Added ecosystem verification checking approved dependencies in pyproject.toml (e.g. httpx2).
    • Added test mock token recognition in test paths (sk-gateway, example.com, etc.).
    • Added detection for prompt sanitizer placeholders (<masked-*>, ***REDACTED***).
  2. Catalog Entries (src/devops_cli/ai/review/common_hallucinations.json):
    • Added HALLUCINATION-STRUCTURAL-TUPLE-EQUALITY, HALLUCINATION-LOCALHOST-DEFAULT-CONFIG, HALLUCINATION-POSIX-SIGNAL-ZERO-LIVENESS, and HALLUCINATION-PRE-1-0-BREAKING-CHANGE.
    • Broadened regex signatures for HALLUCINATION-LOCAL-DEV-NODEPORT-EXPOSURE and HALLUCINATION-K8S-CLUSTER-OVERLAY-HTTP.
  3. Deterministic Short-Circuit Checkers (src/devops_cli/ai/review/verification.py):
    • Implemented _check_structural_tuple_equality_hallucination, _check_localhost_default_url_hallucination, _check_posix_signal_zero_liveness_hallucination, and _check_pre_1_0_breaking_change_hallucination.
    • Broadened _check_benign_compliment to intercept documentation narratives and praise before criteria execution runs.
  4. Prompt Hardening:
    • Updated src/devops_cli/ai/tasks/review.md and src/devops_cli/ai/tasks/verify_finding_system.md with explicit falsification rules against tautological criteria, documentation narratives, structural tuple assertions, localhost default configurations, and prompt sanitizer placeholder claims.
  5. Documentation & Calibration (docs/SELF_IMPROVEMENT.md):
    • Documented the Calibration Record for session 20260928-040906, tracking 174 findings, 5 false-positive classes, remediations, and systemic feedback loop hardening.
    • Calibrated review session 20260928-040906/findings.json (invalidating 28 recurring false alarms) and exported the updated feedback dataset via devops review export-feedback.
  6. Tests:
    • Added comprehensive tests in tests/test_common_hallucinations_hardening.py and tests/test_run_store.py enforcing structural tuple equality assertions.

Verification

  • Passed full devops ci quality gates locally with 100% pass across all 10 checks.
  • Passed pre-commit and pre-push hooks.

…ate findings

- Remediate genuine findings from review session 20260928-040906:
  - run_store: sanitize get_run against path traversal and verify relative path resolution
  - cloudflare: narrow broad exception handling to JSON and decoding errors
  - symbols: narrow bare exception in Python source symbol extraction
  - payoff: narrow bare exception in days active calculation
  - ollama docs: update k8s manifest reference to ollama-profiles.yaml
  - constants: expand fixture credential keywords
- Self-improvement and feedback loop hardening:
  - common_hallucinations: refactor verify_ground_truth_hallucination into dedicated helpers and table-driven dispatch
  - add ground truth verification for dependency ecosystem, test mocks, and masked secret redaction markers
  - add common hallucination catalog entries for structural tuple equality, localhost default configs, POSIX signal 0 liveness, and pre-1.0 breaking change tolerance
  - verification: add deterministic short-circuit checkers and early filters for tuple equality, localhost URLs, signal 0, and benign documentation compliments
  - prompts: update review and verification prompts to prevent tautological criteria verification and sanitizer marker false alarms
  - docs: record Calibration Record for session 20260928-040906 in docs/SELF_IMPROVEMENT.md
  - tests: add comprehensive unit tests with structural tuple equality assertions for new checkers and run_store traversal defenses
@dan-petty
dan-petty merged commit a5a9f53 into release/v0.2.23 Sep 28, 2026
8 checks passed
@dan-petty
dan-petty deleted the fix/review-remediation-self-improvement branch September 28, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

1 participant