Skip to content
Merged
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Before planning, implementing, debugging, refactoring, or reviewing code, consul
- **Mandatory Documentation Synchronization**: Update documentation, command matrix, and README (`devops docs generate --sync-readme`, `docs/`, `AGENTS.md`) after every change to prevent documentation drift.
- **Mandatory CLI Defect Filing**: If `devops` CLI commands emit unexpected errors, traceback failures, or warnings during local development or routine tasks, immediately file a tracking issue and sync to GitHub Projects before continuing.
- **Mandatory Telemetry, Log & CLI Output Review**: AI agents must routinely review devops CLI command outputs, application logs (under `.data/logs/`), metrics, and OpenTelemetry tracing data (`@trace_span` / Logfire) for performance issues, latency bottlenecks, misconfigurations, unhandled exceptions, and diagnostic warnings. Any detected regression, error, or warning must be remediated and formally tracked in GitHub project tracking.
- **Continuous Review, Feedback & Self-Improvement Loop**: Maintain an active closed-loop review and self-improvement cycle as detailed in [`docs/SELF_IMPROVEMENT.md`](docs/SELF_IMPROVEMENT.md). When addressing review findings, write tests first matching verification criteria, apply clean remediations that satisfy architectural invariants (complexity $\le 10$, nesting depth $\le 5$), export verified review feedback (`devops review export-feedback` $\rightarrow$ `feedback_dataset.jsonl`), and continuously update anti-hallucination datasets (`common_hallucinations.json`) and task manuals.
- **Continuous Review, Feedback & Self-Improvement Loop**: Maintain an active closed-loop review and self-improvement cycle as detailed in [`docs/SELF_IMPROVEMENT.md`](docs/SELF_IMPROVEMENT.md). When addressing review findings, write tests first matching verification criteria, apply clean remediations that satisfy architectural invariants (complexity $\le 10$, nesting depth $\le 5$), export verified review feedback (`devops review export-feedback` $\rightarrow$ `feedback_dataset.jsonl`), and continuously update anti-hallucination datasets ([`src/devops_cli/ai/review/common_hallucinations.json`](src/devops_cli/ai/review/common_hallucinations.json)) and task manuals.


### Build, Lint & Test Commands
Expand Down
8 changes: 4 additions & 4 deletions docs/CLI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,10 @@ devops k8s bootstrap-openwebui [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--email`, `-e` | `string` | `admin@localhost` | Admin email address. |
| `--name`, `-n` | `string` | `Admin` | Admin display name. |
| `--password`, `-p` | `string` | - | Admin password. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--email`, `-e` | `string` | `admin@localhost` | Email address for the local administrator account. |
| `--password`, `-p` | `string` | - | Password for administrator. If omitted, securely generated and stored in OS Keyring. |
| `--name`, `-n` | `string` | `Local Administrator` | Full display name for the administrator. |
| `--context`, `-c` | `string` | - | Kubernetes context to target (defaults to config default or active). |
| `--show-password` | `boolean` | - | Display generated admin password in plain text instead of masking. |

### `devops k8s deploy-stack`
Expand Down
2 changes: 2 additions & 0 deletions docs/ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and domain categorization for all exceptions inheriting from `DevOpsCLIError`.
| `LLM_INFERENCE_ERROR` | `1` | Devops_cli.ai.rag.embeddings | Raised when embeddings generation fails across all endpoints. |
| `GITHUB_OPERATION_FAILED` | `1` | Git | Exception raised for GitHub API or CLI automation failures. |
| `GIT_OPERATION_ERROR` | `1` | Git | Base exception for Git repository and branch operation failures. |
| `VALIDATION_ERROR` | `1` | Devops_cli.http.client | Raised when an invalid timeout parameter type is provided. |
| `HARNESS_EXECUTION_ERROR` | `1` | Ai | Raised when execution of an AI test harness or benchmark fails. |
| `HARNESS_VALIDATION_ERROR` | `1` | Ai | Raised when an AI evaluation or harness schema validation fails. |
| `INCOMPLETE_TOOL_CALL` | `27` | Ai | Raised when a model stops due to token limit while emitting a tool call. |
Expand Down Expand Up @@ -80,6 +81,7 @@ and domain categorization for all exceptions inheriting from `DevOpsCLIError`.
| `ToolDownloadError` | `1` | Tools | Raised when an external tool download fails or is rejected. |
| `TOOL_EXECUTION_ERROR` | `1` | Tools | Base exception for external developer tool and binary execution failures. |
| `TOOL_FAILED` | `16` | Ai | Raised when a tool encounters an unrecoverable runtime failure without requesting model retry. |
| `VALIDATION_ERROR` | `1` | Devops_cli.telemetry.context | Raised when trace metadata or flags fail validation. |
| `UNEXPECTED_MODEL_BEHAVIOR` | `15` | Ai | Raised when model retry budget is exhausted or model emits unrecoverable response. |
| `USAGE_LIMIT_EXCEEDED` | `24` | Ai | Raised when an agent run exceeds configured request or token limits. |
| `USER_ERROR` | `21` | Ai | Raised when an invalid configuration or argument is provided by the application developer. |
Expand Down
2 changes: 1 addition & 1 deletion docs/SELF_IMPROVEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Before altering implementation code in `src/`:

### Step 6: Export Feedback & Update Knowledge Memory
- Run `devops review export-feedback` to append the session's findings, verifications, and resolutions to `feedback_dataset.jsonl`.
- If any finding was identified as a false positive, update `src/devops_cli/ai/knowledge_base/common_hallucinations.json`.
- If any finding was identified as a false positive, register or update catalog entries in `src/devops_cli/ai/review/common_hallucinations.json` (e.g. Keyring secret stores, prompt sanitization boundaries, local cache service bindings).
- Commit changes atomically: `fix(review): remediate findings and update self-improvement memory (#<issue>)`.

---
Expand Down
3 changes: 2 additions & 1 deletion docs/agent/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
| [#175](https://github.com/dan-petty/devops-cli/issues/175) | [#173](https://github.com/dan-petty/devops-cli/pull/173) | Project field options synchronization, complete pagination & generic owner resolution | `Done` | [`task-175-project-field-sync-pagination.md`](tasks/task-175-project-field-sync-pagination.md) |
| [#176](https://github.com/dan-petty/devops-cli/issues/176) | [#177](https://github.com/dan-petty/devops-cli/pull/177) | Remediate DevSecOps review findings & enhance review self-improvement loop | `Done` | [`task-176-review-findings-self-improvement.md`](tasks/task-176-review-findings-self-improvement.md) |
| — | [#182](https://github.com/dan-petty/devops-cli/pull/182) | Resolve Helm Stack Deploy SSA Conflicts, Loki Validation, and PodSecurity Failures | `Done` | [`task-183-stack-deploy-conflicts.md`](tasks/task-183-stack-deploy-conflicts.md) |
| [#183](https://github.com/dan-petty/devops-cli/issues/183) | [#184](https://github.com/dan-petty/devops-cli/pull/184) | Gate PR Merge Readiness on Required Approvals, Mergeable State, and Reviewer Feedback | `In Review` | [`task-183-pr-merge-readiness-gating.md`](tasks/task-183-pr-merge-readiness-gating.md) |
| [#183](https://github.com/dan-petty/devops-cli/issues/183) | [#184](https://github.com/dan-petty/devops-cli/pull/184) | Gate PR Merge Readiness on Required Approvals, Mergeable State, and Reviewer Feedback | `Done` | [`task-183-pr-merge-readiness-gating.md`](tasks/task-183-pr-merge-readiness-gating.md) |
| [#185](https://github.com/dan-petty/devops-cli/issues/185) | [#186](https://github.com/dan-petty/devops-cli/pull/186) | Remediate session 20260913-060209 findings and enhance review self-improvement loop | `In Review` | [`task-185-review-remediation-self-improvement.md`](tasks/task-185-review-remediation-self-improvement.md) |


---
Expand Down
4 changes: 2 additions & 2 deletions docs/agent/tasks/task-183-pr-merge-readiness-gating.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

**Issue**: [#183](https://github.com/dan-petty/devops-cli/issues/183)
**PR**: [#184](https://github.com/dan-petty/devops-cli/pull/184)
**Status**: In Review
**Status**: Done
**Milestone**: `v0.2.17`
**Taxonomy**: `type/bug`, `scope/github`, `priority/p1-high`, `status/in-review`
**Taxonomy**: `type/bug`, `scope/github`, `priority/p1-high`, `status/done`

---

Expand Down
41 changes: 41 additions & 0 deletions docs/agent/tasks/task-185-review-remediation-self-improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Task 185: Remediate Session 20260913-060209 Findings and Enhance Review Self-Improvement Loop

**Issue**: [#185](https://github.com/dan-petty/devops-cli/issues/185)
**PR**: [#186](https://github.com/dan-petty/devops-cli/pull/186)
**Status**: In Review
**Milestone**: `v0.2.17`
**Taxonomy**: `type/bug`, `scope/security`, `priority/high`, `status/in-review`

---

## 1. Overview & Objectives
Address reportable findings from multi-persona review session `20260913-060209` (`.data/reviews/20260913-060209/`):
- SSRF & metadata endpoint blocking in `devops sandbox probe` (`src/devops_cli/sandbox/probe.py`).
- Trace ID validation and Jaeger URL SSRF validation in `src/devops_cli/telemetry/waterfall.py`.
- Secret masking and restrictive file mode (`0o600`) in panic incident archiving (`src/devops_cli/sandbox/logs.py`).
- Path traversal and forbidden system path checks in cgroup parsing (`src/devops_cli/sandbox/metrics.py`).
- Detail payload truncation and secret masking in `EndpointProbeResult` (`src/devops_cli/sandbox/models.py`).
- Positional argument secret masking and pattern expansion in `src/devops_cli/security/sanitizer.py`.
- IPv6 bracket stripping in Valkey endpoint parser (`src/devops_cli/valkey/client.py`).
- HTTP client timeout type validation (`src/devops_cli/http/client.py`).
- Optional `trace_flags` support in `generate_traceparent` (`src/devops_cli/telemetry/context.py`).
- Calibrate anti-hallucination dataset (`common_hallucinations.json`) for false positives on Keyring secrets, prompt injection HTML escaping, and local service bindings.
- Export review feedback to `feedback_dataset.jsonl` and refine review prompts/docs for the closed self-improvement loop.

---

## 2. In-Progress Deliverables
- [x] Author test-first unit tests covering all remediations.
- [x] Remediate sandbox probe SSRF & metadata endpoint protection.
- [x] Remediate Jaeger query trace ID validation & URL validation.
- [x] Remediate incident log secret masking & restrictive permissions (`0o600`/`0o700`).
- [x] Remediate cgroup path traversal checks.
- [x] Remediate EndpointProbeResult details truncation & secret masking.
- [x] Remediate positional argument secret masking in sanitizer.
- [x] Remediate IPv6 bracket handling in Valkey endpoint parser.
- [x] Remediate HTTP timeout type validation.
- [x] Remediate `generate_traceparent` trace flags.
- [x] Update `common_hallucinations.json` with disarmed hallucination patterns.
- [x] Export review feedback dataset via `devops review export-feedback`.
- [x] Update `docs/SELF_IMPROVEMENT.md`, `src/devops_cli/ai/tasks/review.md`, and `AGENTS.md`.
- [x] Pass all 10 `devops ci` quality gates.
8 changes: 4 additions & 4 deletions docs/commands/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ devops k8s bootstrap-openwebui [OPTIONS]

| Option / Flag | Type | Default | Description |
|---|---|---|---|
| `--email`, `-e` | `string` | `admin@localhost` | Admin email address. |
| `--name`, `-n` | `string` | `Admin` | Admin display name. |
| `--password`, `-p` | `string` | - | Admin password. |
| `--context`, `-c` | `string` | - | Kubernetes cluster context name. |
| `--email`, `-e` | `string` | `admin@localhost` | Email address for the local administrator account. |
| `--password`, `-p` | `string` | - | Password for administrator. If omitted, securely generated and stored in OS Keyring. |
| `--name`, `-n` | `string` | `Local Administrator` | Full display name for the administrator. |
| `--context`, `-c` | `string` | - | Kubernetes context to target (defaults to config default or active). |
| `--show-password` | `boolean` | - | Display generated admin password in plain text instead of masking. |

---
Expand Down
91 changes: 91 additions & 0 deletions src/devops_cli/ai/review/common_hallucinations.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,96 @@
"occurrence_count": 1,
"last_seen": "2026-09-11T00:00:00",
"source": "builtin"
},
{
"id": "HALLUCINATION-KEYRING-PLAINTEXT-SECRETS",
"name": "OS Keyring / Runtime Credential Resolution Plaintext Secret Claim",
"category": "secret_scanning",
"description": "Claiming that Pydantic configuration models or settings classes store plaintext secrets in configuration files when credentials reside in OS Keyring, secure vault, or environment variables.",
"signature_patterns": [
"(?:plain-?text|plaintext)\\s+secrets?.*(?:configuration\\s+files?|settings\\.py)",
"settings\\.py.*(?:plain-?text\\s+secrets?|stored?\\s+in\\s+plain\\s+text)",
"(?:github\\.token|grafana\\.token|argocd\\.token).*persisted\\s+in\\s+config"
],
"pattern_keywords": [
"keyring_secret",
"settings_plaintext_secrets",
"config_secret_leak"
],
"file_patterns": [
"*settings.py",
"*config*.py"
],
"resolution": "Settings and configuration models securely resolve sensitive tokens and credentials from the OS Keyring or environment variables at runtime without persisting them to configuration files.",
"occurrence_count": 1,
"last_seen": "2026-09-13T00:00:00",
"source": "builtin"
},
{
"id": "HALLUCINATION-PROMPT-INJECTION-HTML-ESCAPE",
"name": "Prompt Injection Sanitizer HTML Escaping Claim",
"category": "general",
"description": "Claiming that prompt injection sanitizers (e.g. sanitize_prompt_injection) must escape HTML tags (<, >, &) or risking XSS in UI.",
"signature_patterns": [
"sanitize_prompt_injection.*(?:escape\\s+html|html\\.escape|xss)",
"(?:prompt\\s+injection|prompt\\s+boundary).*(?:escape\\s+html|xss\\s+in\\s+ui)"
],
"pattern_keywords": [
"prompt_injection_html_escape",
"sanitize_prompt_xss"
],
"file_patterns": [
"*sanitizer.py"
],
"resolution": "Prompt injection sanitizers strip boundary injection markers to protect LLM inference context; HTML escaping is strictly for browser DOM rendering and would corrupt code snippets, operators, and XML tags destined for language models.",
"occurrence_count": 1,
"last_seen": "2026-09-13T00:00:00",
"source": "builtin"
},
{
"id": "HALLUCINATION-LOCAL-CACHE-SSRF",
"name": "Local Cache / Valkey / Redis Loopback SSRF False Claim",
"category": "boundary_errors",
"description": "Claiming that local or internal caching tiers (Valkey, Redis, Memcached) must reject loopback (127.0.0.1, localhost) or private network IP addresses as SSRF.",
"signature_patterns": [
"(?:valkey|redis|cache).*must\\s+not\\s+(?:target|allow|be).*(?:localhost|127\\.0\\.0\\.1|private\\s+ip|loopback)",
"(?:valkey|redis).*validator\\s+may\\s+allow\\s+local\\s+connections",
"(?:valkeyconfig|valkey_config).*ssrf"
],
"pattern_keywords": [
"valkey_ssrf",
"redis_localhost_ssrf",
"cache_private_ip"
],
"file_patterns": [
"*valkey*.py",
"*settings.py",
"*cache*.py"
],
"resolution": "Valkey and Redis are internal caching services designed specifically to bind to localhost or private cluster IP addresses; rejecting local or private addresses prevents the caching tier from operating.",
"occurrence_count": 1,
"last_seen": "2026-09-13T00:00:00",
"source": "builtin"
},
{
"id": "HALLUCINATION-PROMETHEUS-EXPOSITION-SYNTAX",
"name": "Prometheus Exposition Syntax Parser False Unvalidated Claim",
"category": "syntax_grammar",
"description": "Claiming that Prometheus exposition parsers lack metric name or label validation when regex patterns already enforce compliant naming syntax.",
"signature_patterns": [
"(?:parse_prometheus_exposition|prometheus_exposition).*unvalidated\\s+metric\\s+names?",
"unvalidated\\s+metric\\s+names?\\s+and\\s+labels.*prometheus"
],
"pattern_keywords": [
"prometheus_exposition_validation",
"unvalidated_metric_names"
],
"file_patterns": [
"*metrics.py"
],
"resolution": "Prometheus exposition parsers validate metric names and label keys against standard Prometheus regex tokenizers (e.g. ^[a-zA-Z_:][a-zA-Z0-9_:]*$) conforming to official OpenMetrics and Prometheus exposition specifications.",
"occurrence_count": 1,
"last_seen": "2026-09-13T00:00:00",
"source": "builtin"
}
]
Loading
Loading