Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .devops/review.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ Each bullet states what a review of this repository must not flag. The function
- Never flag documentation, architectural guides, security tutorials, knowledge base articles, prompt benchmarks, test assertions/fixtures, test mocks, sample configuration files (`*.example.*`, `*.sample.*`, `*.env.example`), or comments describing vulnerabilities in the context of avoiding or mitigating them.
- Infrastructure-as-Code operator outputs (`outputs.tf`) must not be flagged as remote command injection.
- **Ground-Truth Scope & Variable Verification (Zero False NameErrors)**: Analysis stages MUST NOT declare a variable, constant, or imported symbol as undefined (`NameError`) without verifying the entire enclosing function, class, or module scope. If a symbol was imported, assigned, or passed as a parameter in active scope or outer closure, the finding is a hallucination and MUST NOT be reported.
- **Criteria Inversion & Semantic Alignment**: Strictly distinguish between `verification_criteria` (positive evidence defect exists) and `invalidation_criteria` (conditions proving false positive). Satisfied invalidation conditions never corroborate findings.
- **Console Path Output vs Information Exposure (CWE-200)**: Printing local working directories, review target paths, or artifact locations to stdout/stderr is standard CLI UX and does NOT constitute CWE-200 Information Exposure, which applies to secrets, credentials, or private keys leaked to unauthenticated logs or external responses.
- **Safe Introspection vs Remote Code Execution (RCE)**: Introspecting attributes on internal typed Pydantic models via `getattr(model, field, default)` or `hasattr` is safe Python idiom and MUST NOT be flagged as insecure deserialization or arbitrary code execution.
15 changes: 4 additions & 11 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# devops-cli — GitHub Copilot Instructions

> **This file is a pointer, not the source.** GitHub Copilot looks specifically for
> `.github/copilot-instructions.md`, so this stub exists to redirect it. All actual instructions — project
> overview, build/test commands, code conventions, architecture, AI features,
> environment & modernization policy, and security notes — live in
> [AGENTS.md](../AGENTS.md). Read that file. `devops ai agents` regenerates
> this stub and leaves an existing AGENTS.md alone unless `--force` is given;
> do not duplicate content here.
>
> **Pre-1.0 Alpha Notice**: This codebase is active alpha software prior to release `1.0.0`
> with no backwards compatibility guarantees. The codebase must remain clean of legacy
> references and obsolete shims at all times. Post-1.0 releases adhere strictly to
> Semantic Versioning and enterprise change management (feature flags, deprecations, migrations).
> `.github/copilot-instructions.md`, so this stub exists to redirect it. [AGENTS.md](../AGENTS.md)
> holds the rules for every task and routes each task to the document that owns it. Read
> that file. `devops ai agents` regenerates this stub and leaves an existing AGENTS.md alone
> unless `--force` is given; do not duplicate content here.
259 changes: 43 additions & 216 deletions AGENTS.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,16 @@ Every command is registered on a `new_typer()` app (`OTelTyper`, `devops_cli/cor
Domain results are modelled with Pydantic in `devops_cli.models`. The REST routes define their own response models in `server/routes/`, and MCP tools return the CLI's text output:
- **Strict Typing**: Mandatory field descriptions, `Field(default_factory=...)` mutable defaults, and zero hardcoded synthetic scoring floats.
- **Bi-Directional JSON Schema Generation**: Clean schema generation for IDE completions and LLM tool calling.
- **Closed Tool Schemas**: An MCP tool and an agent schema refuse unknown arguments: `extra="forbid"` in Pydantic, `additionalProperties: false` in JSON Schema. The validation error names the arguments that the tool accepts.

### 3. Safe Subprocess Execution & Process Group Management
All external binaries run through `run_subprocess` / `run_subprocess_async` (`devops_cli.core.process`):
- Strict command argument list verification (rejecting hyphen-prefixed injection payloads) with `shell=False`.
- Explicit bounded timeouts (default 1800 s) with standardized `TimeoutExpired` domain error translation.
- An audit-record writer (`devops_cli.core.audit.record_audit_event`, `.data/logs/audit.jsonl`) exists but is not yet called from command or subprocess execution.
- Deterministic mock isolation protocols for fast offline unit testing, dry-run reporting, environment isolation, and OpenTelemetry spans.
- **Process groups**: Start a child with `start_new_session=True`, and stop it by its process group (`os.killpg`), as `_terminate_process_group` in `src/devops_cli/sandbox/host.py` does. Do not signal a pid below 2, the own process group (`os.getpgrp()`) or a process group below 2.
- **Shared container**: Never set `RLIMIT_NPROC`: Linux counts it for the real user across the container, so it starves VS Code Server and the shells. Never set `O_NONBLOCK` on descriptors 0, 1 or 2: it corrupts the terminal.

### 4. Multi-Stage Workflow Architecture
The review workflow runs as `ReviewPipelineOrchestrator` methods (pre-analysis, payload init, persona review, re-ranking, reporting), and `ai/review/stages/` holds `reporting.py`:
Expand All @@ -189,3 +192,7 @@ The review workflow runs as `ReviewPipelineOrchestrator` methods (pre-analysis,
- Native HTTP/2 connection pooling with persistent keepalive and backoff retries where supported.
- Connect-time egress checks by level (public, loopback-allowed, private-allowed), with cloud metadata addresses refused at every level.
- Automatic W3C `traceparent` header injection for distributed trace waterfalls.
- A client backs off with jitter on HTTP 429 and obeys `Retry-After`. It caches idempotent reads under `.data/` or in Valkey.

### 6. Files
Check the size of a file before you read it into memory (`MAX_REPOMAP_FILE_SIZE_BYTES`, 50 MiB). Resolve a path inside a root with `safe_resolve_subpath` (`devops_cli.core.paths`), which refuses a symlink or `..` that leaves the root.
15 changes: 4 additions & 11 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
@AGENTS.md

> **This file is a pointer, not the source.** Claude Code looks specifically for
> `CLAUDE.md`, so this stub exists to redirect it. All actual instructions — project
> overview, build/test commands, code conventions, architecture, AI features,
> environment & modernization policy, and security notes — live in
> [AGENTS.md](./AGENTS.md). Read that file. `devops ai agents` regenerates
> this stub and leaves an existing AGENTS.md alone unless `--force` is given;
> do not duplicate content here.
>
> **Pre-1.0 Alpha Notice**: This codebase is active alpha software prior to release `1.0.0`
> with no backwards compatibility guarantees. The codebase must remain clean of legacy
> references and obsolete shims at all times. Post-1.0 releases adhere strictly to
> Semantic Versioning and enterprise change management (feature flags, deprecations, migrations).
> `CLAUDE.md`, so this stub exists to redirect it. [AGENTS.md](./AGENTS.md)
> holds the rules for every task and routes each task to the document that owns it. Read
> that file. `devops ai agents` regenerates this stub and leaves an existing AGENTS.md alone
> unless `--force` is given; do not duplicate content here.
15 changes: 12 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ Thank you for your interest in contributing to DevOps CLI! This document outline

## 1. Development Philosophy & Core Invariants

DevOps CLI follows an uncompromising quality-first, test-driven engineering culture defined in [`AGENTS.md`](AGENTS.md):
These rules apply to every contributor. [`AGENTS.md`](AGENTS.md) sends agents here.

- **Test-First Implementation (TDD)**: All features, fixes, and refactorings **must** have tests written first. Tests serve as the executable documentation of public interfaces, edge cases, and architectural boundaries.
- **Complexity and Nesting Caps**:
- Ruff caps cyclomatic complexity at 10 (`C901`) in `pyproject.toml`. `uv run devops ci` and the pre-commit `ruff-check` hook run it with `--config pyproject.toml`, and `tests/test_ruff_complexity_cap.py` checks the resolved settings and every `ruff check` command. Functions over the cap when it was turned on carry `# noqa: C901`, and `tests/test_architectural_invariants.py` keeps their count from growing. `devops scan complexity` reports the same McCabe count and does not gate.
- Maximum nesting depth $\le 5$ (< 6 indentation levels) project-wide.
- Decompose multi-step procedures into dedicated single-responsibility helpers and pure predicates.
- For a closed set of cases, use `match` with `assert_never`, or a table. Do not write an `if`/`elif` chain.
- **Closed Lists and Standard Parsers**:
- Match a value against a list of strings only when the list covers a closed domain, such as one that an RFC or a language grammar defines.
- For an open domain, use a parser (`ast`, `tokenize`, `urllib.parse`, `ipaddress`, `packaging`) or an official registry, such as the Public Suffix List through `tldextract`.
- Declare each list, tuple or frozen set that matches, classifies or filters values in `src/devops_cli/config/constants.py` or `src/devops_cli/config/defaults.py`.
- **Names**: Name each file, module, class and function for its responsibility. Do not use a placeholder name, such as `temp_util.py`. Ruff `N` checks the form.
- **Line Breaks Belong to Source Files**: Hard-wrap text only in source files and Markdown documents. Write emitted text (terminal messages, Rich renderables, log records, `lang/en/` strings) as continuous paragraphs. Split a long string in the source with implicit string concatenation.
- **Strongly Typed Domain Exceptions**:
- All domain error states must raise strongly typed exceptions inheriting from `DevOpsCLIError` under `src/devops_cli/exceptions/`.
- Raising bare Python built-in exceptions (`ValueError`, `RuntimeError`, `TypeError`) is strictly prohibited.
Expand Down Expand Up @@ -55,8 +62,8 @@ uv run pre-commit install
uv run mypy path/to/modified.py
uv run devops ci test tests/test_architectural_invariants.py
```
4. **Run Comprehensive CI Quality Gate**:
Run the unified quality suite before committing:
4. **Run the Gate Before a Push**:
The pre-push hook runs the full gate, and a push goes only when every check passes:
```bash
uv run devops ci
```
Expand Down Expand Up @@ -94,6 +101,8 @@ uv run pre-commit install

The other types (`docs`, `test`, `build`, `ci`, `style`, `chore`) add no line. Do not edit `CHANGELOG.md`: release-please writes it in its release pull request. [`RELEASE_CYCLE.md`](RELEASE_CYCLE.md) tells what happens after the merge.
- **Commits on the Branch**: Commits on a topic branch also follow the Conventional Commits format. The squash merge replaces them with the title.
- **Fail-to-Pass Evidence**: A fix pull request cites its `fail-to-pass` check run (`devops ci fail-to-pass --base <ref>`, `.github/workflows/fail-to-pass.yml`). Do not type failure counts by hand. The check fails a pull request whose replay could not run on the base: pytest stopped, did not start or wrote no complete JUnit report. Such a pull request declares `Fail-to-pass: not applicable: <reason>` in its body. A changed test that only fails to collect on the base counts as errored.
- **Helper Scripts**: A committed helper script goes in `scripts/` as a PEP 723 file, and Ruff checks it. The pull request that adds the first script adds `scripts` to the mypy and Bandit targets. Scratch scripts stay untracked under `.data/agent/scratch/`.
- **Documentation Synchronization**:
Run documentation introspection after any command or option change:
```bash
Expand Down
15 changes: 4 additions & 11 deletions GEMINI.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
@./AGENTS.md

> **This file is a pointer, not the source.** Gemini CLI looks specifically for
> `GEMINI.md`, so this stub exists to redirect it. All actual instructions — project
> overview, build/test commands, code conventions, architecture, AI features,
> environment & modernization policy, and security notes — live in
> [AGENTS.md](./AGENTS.md). Read that file. `devops ai agents` regenerates
> this stub and leaves an existing AGENTS.md alone unless `--force` is given;
> do not duplicate content here.
>
> **Pre-1.0 Alpha Notice**: This codebase is active alpha software prior to release `1.0.0`
> with no backwards compatibility guarantees. The codebase must remain clean of legacy
> references and obsolete shims at all times. Post-1.0 releases adhere strictly to
> Semantic Versioning and enterprise change management (feature flags, deprecations, migrations).
> `GEMINI.md`, so this stub exists to redirect it. [AGENTS.md](./AGENTS.md)
> holds the rules for every task and routes each task to the document that owns it. Read
> that file. `devops ai agents` regenerates this stub and leaves an existing AGENTS.md alone
> unless `--force` is given; do not duplicate content here.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Specialized personas available for interactive conversations via `devops ai chat
3. **SSRF Protections**: An HTTP client built by the `devops_cli.http.client` factory (tool downloads, the Tavily search call, Vault, the Kubernetes clients, the sandbox probe, Tempo and the LLM client base) has an egress level (`devops_cli.http.egress`) and resolves a host once, at the connect, dialling only the addresses its level admits; the other clients are not checked at the connect yet, and the service connectors among them validate their URL before the request (`validate_service_url`). Untrusted URLs (tool downloads) are public-only whatever the configuration says. A service URL from the user's own configuration (Ollama, Qdrant, the LLM gateway, a provider's `api_base_url`) may name loopback, and a private address once `ai.allow_private_network` (`DEVOPS_CLI_AI_ALLOW_PRIVATE_NETWORK=true`) is set. Internal infrastructure clients (Vault, the Kubernetes API, Loki) reach private addresses. Cloud metadata addresses are refused at every level. Factory clients ignore `HTTP_PROXY`, `HTTPS_PROXY` and `ALL_PROXY`.
4. **Workspace Boundary Guards**: Path traversal checks (`_is_safe_workspace_path`) enforce repository boundaries on file commands.
5. **Checksum Verification**: `devops install-tools` installs every tool only from `tools.lock` (`src/devops_cli/tools_lock/`), at an exact version. A binary is checked against the lock's SHA-256 for its platform, a Python tool (Semgrep, Bandit) installs with `uv pip sync --require-hashes` into a virtual environment of its own, and a Node tool (OpenSpec, Dev Containers CLI) installs with `npm ci --ignore-scripts` from a committed `package-lock.json`, which npm checks against the sha512 of every package (`npm` must already be on PATH); a mismatch is refused and the command exits 1. `devops install-tools --check` lists each tool not linked at its locked version.
6. **Automated Design Justification & Documentation Maintenance**: Non-instructional, reference-backed inline comments (`# NOTE (Design Justification - <REF>): ...`) automatically document intentional design trade-offs directly above target code constructs, and project documentation (`AGENTS.md`, `README.md`, `CLAUDE.md`, `.github/copilot-instructions.md`) is routinely updated whenever code or prompt conventions evolve.
6. **Automated Design Justification & Documentation Maintenance**: Non-instructional, reference-backed inline comments (`# NOTE (Design Justification - <REF>): ...`) automatically document intentional design trade-offs directly above target code constructs, and a change updates the document that owns each rule it changes. `AGENTS.md` routes each kind of task to that document.

---

Expand Down
2 changes: 1 addition & 1 deletion RELEASE_CYCLE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release Cycle — devops-cli

This page is for the person who releases `devops-cli`. [release-please](https://github.com/googleapis/release-please) makes every release from `main`, and a person merges its pull request. Agents take no part in a release ([`AGENTS.md`](AGENTS.md), section 3).
This page is for the person who releases `devops-cli`. [release-please](https://github.com/googleapis/release-please) makes every release from `main`, and a person merges its pull request. release-please writes `CHANGELOG.md`, `.release-please-manifest.json` and the version lines, so nobody edits those by hand. Agents change the release workflow and its configuration through ordinary pull requests ([`AGENTS.md`](AGENTS.md)).

## How the Release Pull Request Is Made

Expand Down
Loading
Loading