Dosu LogoDosu Logo
Ask
Join our Discord
Organization avatar
CipherSwarmPublic
EvilBit Labs LLC
DocumentsCipherSwarm
phase-2c-refactor-cleanup
phase-2c-refactor-cleanup
Type
External
Status
Published
Created
Feb 27, 2026
Updated
Feb 27, 2026
Source
docs/v2_rewrite_implementation_plan/phase-2c-refactor-cleanup.md

๐ŸŽฏ CipherSwarm Phase 2 Endpoint Hygiene Sweep#

Skirmish must complete this sweep after all /api/v1/web/* endpoints have been implemented and tested.

This pass is required to clean up minor violations of project-specific coding standards that may not be caught by just ci-check but are essential to long-term quality.


๐Ÿ” Common Skipped Rules to Fix#

โŒ Skipped: Proper SvelteKit Integration#

  • Replace all legacy server-rendered endpoints with SvelteKit JSON API endpoints and Svelte components
  • SvelteKit endpoints must return a valid JSON API response, not a server-rendered template
  • The response fields are unpacked automatically and available as top-level variables in the Svelte component

๐Ÿ“˜ See: sveltekit-guidelines.mdc โ€” SvelteKit endpoints must always use JSON API.


โŒ Skipped: Endpoint Purity#

  • Ensure no database access occurs in endpoint functions (move all DB access to services or crud.py)
  • Use Depends(get_db) only inside service-layer helpers, not in the route body

๐Ÿ“˜ See: service-patterns.mdc โ€” all persistence logic must be kept outside endpoints.


โŒ Skipped: FastAPI Idiomatic Parameter Usage#

  • Remove all usage of request: Request for parameter parsing or user/project extraction
  • Forms should never be parsed from the request body or the form data, each field should be a proper Annotated[Form, ...] parameter
  • Replace with proper Annotated[...] dependencies:
user: Annotated[User, Depends(current_user)]
project: Annotated[Project, Depends(get_current_project)]

๐Ÿ“˜ See: fastapi-guidelines.mdc โ€” context should always use DI, never request-manual parsing.


๐Ÿงผ Style Cleanups#

๐Ÿ”ง getattr vs direct access#

  • Replace getattr(foo, "bar") with foo.bar unless:

    • Field is dynamic
    • There's a fallback value
    • Object may be missing the attribute and is guarded

๐Ÿ”ง Typing + Models#

  • Eliminate dict[str, object] returns
  • Ensure all route input/output is typed with Pydantic v2 models

๐Ÿ”ง Imports#

  • Alphabetize imports within groups (stdlib, third-party, local)
  • Remove any unused imports that snuck back in

๐Ÿ“˜ See: python-style.mdc โ€” use direct access over reflection, and structure imports consistently.


๐Ÿงช Final Checks#

  • Run full just ci-check again
  • Launch just dev and download the openapi.json file to verify the generated schema is correct

โœ… Completion Criteria#

All existing /api/v1/web/* endpoints must conform to:

  • JSON API for any SvelteKit route
  • Service-layer separation for DB logic
  • Proper FastAPI DI for context
  • Clean, direct attribute access
  • Valid OpenAPI schema (Pydantic-typed, no JSON dict hacks)
Documents
Agent Architecture Specifications
CipherSwarm Project Specification and Phase Organization
diagrams
Agent Configuration Management
Agent Client Configuration Flags
Agent Installation Guide
Airgapped Network Deployment Tutorial
api-reference-agent-auth
configuration
Agent Core Orchestration
configuration
diagrams
Basic Usage
air-gapped-deployment
CipherSwarm API Client Integration
api-reference-agent-auth
Client Setup and Configuration
Agent Client Configuration Flags
Agent Installation Guide
air-gapped-deployment
Airgapped Network Deployment Tutorial
Development
Authorization and List Deletion Permissions
CipherSwarm Project Documentation Structure
CipherSwarm Project Specification and Phase Organization
CipherSwarm V2 Development Workflow
GitHub Actions and Dependency Management
Rails 8 Upgrade and Migration
Security and Performance Enhancements
Testing Strategy and Documentation
Testing Strategy and Framework
Distributed Task Management
api-reference-agent-auth
diagrams
Task_Management_Actions
Enhanced Task Monitoring Specification
Agent_Monitoring_&_Real-Time_Updates
Error Handling and Logging Framework
Testing Strategy and Documentation
Testing Strategy and Framework
GitHub Issue Templates
GitHub Issue and Pull Request Templates
Progress and Status Reporting
Agent_Monitoring_&_Real-Time_Updates
Task_Management_Actions
UI_Components_&_Loading_States
Rails User Interface Development
Task_Management_Actions
UI_Components_&_Loading_States
Server Administration
air-gapped-deployment
Server Installation
air-gapped-deployment
Airgapped Network Deployment Tutorial
Installation guide
Testing and Validation Suite
developer-guide
CONTRIBUTING
Campaign_Progress_&_ETA_Display
Core_Flows__Operational_Monitoring_&_User_Experience
Database_Schema_&_Model_Extensions
Epic_Brief__CipherSwarm_V2_Operational_Excellence
Integration_Testing_&_Quality_Assurance
Production_Deployment_&_Monitoring
README
README
Structured_Logging_&_Error_Handling
System_Health_Monitoring
Tech_Plan__Operational_Excellence_Implementation
User_Guide_Documentation
advanced_task_scheduler
agent
agent-api-complete-reference
agent-server-collaboration-vision
agent-setup
agent_notes
agent_sync_extensions
agent_v1_contract_violations
air-gapped-deployment
allow_hybrid_hash_lists
attack
attack-configuration
attack_notes
authentication_cleanup
brute_force_attack_editor
campaign-management
campaign_list_view
campaign_notes
campaign_priority_system
campaigns
common-issues
core_algorithm_implementation_guide
crackable_uploads_plan
dashboard-ux
default_config_suggestions
faq
full_testing_architecture
getting-started
hard_password_attack_strategies
health_status_screen
implementation_plan
installation
learned_rules_parser_plan
logging-guide
markov_autogen_plan
new_dictionary_attack_editor
new_mask_attack_editor
optimization
phase-1-core-infrastructure
phase-2-api-implementation
phase-2-api-implementation-part-1
phase-2-api-implementation-part-2
phase-2-api-implementation-part-3
phase-2b-resource-management
phase-2c-refactor-cleanup
phase-3-e2e-test-coverage-plan
phase-3-step-1
phase-3-step-2
phase-3-step-3
phase-3-step-4
phase-3-step-5
phase-3-web-ui-foundation
phase-4-containerization-deployment
phase-5-task-distribution
phase-6-monitoring-testing-documentation
playwright-manual-flows
previous_password_dictionary_attack_editor
production-load-balancing
project_structure
psycopg_migration
quick-reference
quick-start
resource-management
rule_explanation
salvage_templates
spa_to_ssr
style-guide
summary
system-tests-guide
test-failures-investigation
testcontainers_minio_support
troubleshooting
troubleshooting-agents
understanding-results
usage
user_flows_notes
v2-upgrade-overview
v2_agent_api_removal
web-interface