feat(slm): deployed-vs-source file drift detection (#2834)#3430
feat(slm): deployed-vs-source file drift detection (#2834)#3430mrveiss merged 3 commits intoDev_new_guifrom
Conversation
- New services/drift_checker.py: SHA-256 checksum comparison between code_source and deployed directories, skipping .pyc/__pycache__/venv/.git - New GET /code-sync/drift endpoint returns FileDriftReport with per-file drift status (modified | source_only | deployed_only) - Added DriftedFile and FileDriftReport Pydantic schemas to models/schemas.py - useCodeSync composable: fetchDrift() method + FileDriftReport/DriftedFile types - CodeSyncView: "File Drift Check" card with expandable drifted-files table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… endpoint (#3427) - Add ALLOWED_COMPONENTS frozenset in drift_checker.py - Validate component param against allowlist in get_file_drift(); raise HTTP 400 on mismatch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review — feat(slm): deployed-vs-source file drift detection (#2834)Reviewer: code-reviewer agent Overall AssessmentThe feature is well-scoped and solves a real operational problem (detecting manual patches and incomplete Ansible deploys). The service layer is clean, the ALLOWED_COMPONENTS allowlist prevents path traversal, and the async offloading pattern is correct. There are no blocking issues, but several medium and low items need attention before merge. Issues FoundMEDIUM — Missing
|
| Priority | Count | Description |
|---|---|---|
| MEDIUM | 3 | finally block missing, Literal type missing, silent fallback masking config error |
| LOW | 5 | Duplicated env constant, Settings bypass, no tests, no component selector, checked_at type, redundant IOError |
The MEDIUM items should be addressed before merge. The LOW items can be filed as follow-on issues if the author prefers to keep the PR focused.
- Use Literal["modified","source_only","deployed_only"] in DriftedFile.status - Raise ValueError (surfaced as HTTP 500) in get_default_source_dir when component dir is missing, rather than silently falling back to monorepo root - Wrap get_file_drift source_dir resolution in try/except ValueError → HTTP 500 - Add try/finally to handleCheckDrift in CodeSyncView so isDriftLoading resets on error Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
Summary
Implements issue #2834 — adds a
GET /code-sync/driftendpoint to the SLM backend that compares SHA-256 checksums betweencode_sourceand deployed files, detecting manual patches or incomplete Ansible deploys.services/drift_checker.py: directory walk with checksum comparison, classifies files asmodified | source_only | deployed_onlyGET /code-sync/drift?component=<name>endpoint returningFileDriftReportDriftedFile/FileDriftReportPydantic schemas added tomodels/schemas.pyuseCodeSynccomposable:fetchDrift()method + TypeScript typesCodeSyncView: "File Drift Check" card with expandable drifted-files tableALLOWED_COMPONENTS) prevents path traversal via the query param; HTTP 400 for unknown componentsIssues
Closes #2834
Fixes #3427
Test plan
GET /code-sync/driftreturnsFileDriftReportwith correct counts when dirs differGET /code-sync/drift?component=../../etcreturns HTTP 400GET /code-sync/drift?component=autobot-slm-frontendreturns report for that component🤖 Generated with Claude Code