Skip to content

feat: agent deployment compatibility validation — server-side checks with auto-fix (#668)#1295

Merged
dolho merged 2 commits into
devfrom
feature/668-compat-validation
Jun 22, 2026
Merged

feat: agent deployment compatibility validation — server-side checks with auto-fix (#668)#1295
dolho merged 2 commits into
devfrom
feature/668-compat-validation

Conversation

@vybe

@vybe vybe commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Server-side agent compatibility validation: ~100 best-practice checks (11 categories) run against a running agent's workspace, surfaced non-blocking in the Agent Detail Overview tab (CompatibilityPanel.vue, "needs attention" idiom + grouped checklist), with one-click auto-fix for the 10 gitignore checks, plus an MCP tool get_agent_compatibility_report.
  • Canonical check list is docs/agent-validation-spec.md (single source of truth, sync-tested against services/compatibility/spec.py).

Changes

  • Backend services/compatibility/ package (spec/collector/static_checks/ai_checks/fixes): ONE docker exec → in-container python3 → one JSON snapshot (secret files existence-only, per-file binary/size caps); pure (snapshot)→[Check] STATIC checks (HARD reserved for STATIC) + category-batched AI checks (Claude Haiku, tool-use, iterate-expected so omitted→skipped, fail-open, capped at SOFT, secret-redacted, secret files never sent). Runtime-aware — claude-only checks skipped for Codex/Gemini (Codex harness MVP — pluggable agentic execution engine alongside Claude Code #1187).
  • Endpoints routers/compatibility.py: GET …/compatibility?include_ai= (read, AuthorizedAgentByName; the include_ai fan-out is rate-limited) and POST …/compatibility/fix (owner/admin, OwnedAgentByName; gitignore-only, per-agent Redis lock, atomic write, uncommitted until next git sync; check_id whitelisted → 400/409).
  • DB agent_compatibility_results (latest-snapshot-per-agent, upsert) — dual-track migration (SQLite db/migrations.py + Alembic 0003_*), DDL in schema.py/tables.py, ops in db/compatibility.py, cascade/rename via AGENT_REFS.
  • Frontend CompatibilityPanel.vue (two-phase fetch — STATIC instant, AI async/cached; grouped checklist; per-check Fix; Re-run) in OverviewPanel.vue; agents.js store actions.
  • MCP get_agent_compatibility_report (agents.ts + client.ts + types.ts), three surfaces in sync (Invariant feat: SMARTS trading pipeline with Telegram notifications and Miro visualization #13).
  • Docs requirements §41, architecture subsystem block + catalogs + endpoints + schema, feature-flow doc + index, spec deviation note.

Design note — persistence (deliberate deviation)

The issue specified "no DB table (transient)". This PR adds agent_compatibility_results because AI verdicts aren't cheaply recomputable (they cost API calls): persistence lets AI findings show on every Overview load without re-spending tokens, unlocks fleet aggregation, and enables cheap post-fix re-checks. STATIC recomputes live each read; persisted AI verdicts merge in until a re-run. Rationale recorded in requirements §41 + the spec's deviation note.

Test Plan

  • 35 fixture-driven unit tests pass: pytest tests/unit/test_compatibility_checks.py — spec consistency + spec↔doc sync, STATIC checks (good/bad/empty), gitignore fix transforms (CRLF/dup/comment/.claude/projects/ survival/idempotent), AI batching (no-key skip, omitted→skipped, redaction), build_report orchestration (+ tmp-DB persistence, codex omits claude_only, stopped→unavailable), collector script vs a temp ROOT.
  • Schema parity / migrations / agent-cleanup parity tests pass; full unit suite green (pre-existing unrelated failures excluded).
  • Frontend vite build ✓, MCP tsc --noEmit ✓.
  • Pre-landing /review: 0 critical. /cso --diff: 1 MEDIUM (LLM cost amplification on include_ai) — fixed (rate-limited); report in docs/security-reports/.
  • Manual: load Overview for an agent → compatibility section renders STATIC instantly, AI fills in; auto-fix a gitignore check → re-run shows it resolved.

Fixes #668

🤖 Generated with Claude Code

Comment thread src/backend/services/compatibility/ai_checks.py Fixed
Run ~100 best-practice checks (11 categories) against a running agent's
workspace, surfaced non-blocking in the Overview tab with one-click
auto-fix for the 10 gitignore checks, plus an MCP tool.

- services/compatibility/ package (spec/collector/static_checks/ai_checks/fixes):
  ONE docker exec -> in-container python -> JSON snapshot (secret files
  existence-only, size/binary caps); pure STATIC checks (HARD-only) +
  category-batched AI checks (Haiku, iterate-expected, fail-open, capped at
  SOFT, secret-redacted); runtime-aware (claude-only checks skipped for
  Codex/Gemini).
- GET/POST endpoints (read AuthorizedAgentByName; fix OwnedAgentByName, gitignore
  only, per-agent Redis lock, atomic write, uncommitted until next sync;
  include_ai path rate-limited). agent_compatibility_results table (dual-track
  SQLite + Alembic) persists the latest snapshot; cascade/rename via AGENT_REFS.
- CompatibilityPanel.vue (two-phase fetch, grouped checklist, per-check fix,
  re-run) in OverviewPanel; get_agent_compatibility_report MCP tool.
- 35 fixture-driven unit tests; spec sync-tested against docs/agent-validation-spec.md.

Persistence departs from the issue's "no DB table" note so AI verdicts show
without re-spend + enable fleet aggregation (see requirements section 41).

Fixes #668

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dolho
dolho force-pushed the feature/668-compat-validation branch from 825bd6b to 4d4063e Compare June 22, 2026 09:09
CodeQL py/polynomial-redos (high): `_ASSIGN_RE` captured the value as
`[ \t]*(.+?)[ \t]*$`. The lazy `.+?` and the surrounding `[ \t]*` can both
match a tab, giving polynomial backtracking when `_redact()` runs the pattern
over up to 48 KB of agent-supplied file text.

Capture the value greedily to end-of-line (`(.*)$`) and let the callers
strip — both `_looks_placeholder()` callers already `.strip()`, so secret
detection and redaction are behaviourally identical (verified: `=`, `:`,
`export`, and indented forms still match). 35 unit tests pass.
@dolho
dolho merged commit 25f52a1 into dev Jun 22, 2026
18 checks passed
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.

3 participants