CipherSwarm Quick Reference#
Commands#
Command Description just devStart development server just testRun all tests with coverage just test-file spec/path.rbRun specific test just checkLint + security checks just formatAuto-format code just db-migrateRun migrations just db-rollbackRollback migration just consoleRails console just docs-apiGenerate API docs
File Locations#
What Where Models app/models/API Controllers app/controllers/api/v1/client/Services app/services/Jobs app/jobs/Components app/components/Factories spec/factories/System Tests spec/system/API Tests spec/requests/
Domain Hierarchy#
Copy Project → Campaign → Attack → Task → Agent
↓
HashList → HashItem
State Machines#
Agent#
pending → active → benchmarked → error/stopped
Attack#
pending → running → completed/exhausted/failed/paused
Task#
pending → running → completed/exhausted/failed/paused
API Endpoints#
Method Endpoint Purpose GET /authenticateVerify token GET /configurationAgent config GET /agents/{id}Agent details PUT /agents/{id}Update agent POST /agents/{id}/heartbeatKeep alive POST /agents/{id}/submit_benchmarkSubmit benchmarks POST /agents/{id}/submit_errorReport error POST /agents/{id}/shutdownShutdown GET /tasks/newGet new task POST /tasks/{id}/accept_taskAccept task POST /tasks/{id}/submit_statusUpdate progress POST /tasks/{id}/submit_crackSubmit crack POST /tasks/{id}/exhaustedMark complete POST /tasks/{id}/abandonAbandon task GET /tasks/{id}/get_zapsGet cracked hashes GET /attacks/{id}Attack details GET /attacks/{id}/hash_listDownload hashes
Authentication#
Copy Authorization: Bearer <24-char-token>
Campaign Priorities#
Priority Value Effect flash_override 5 Highest, preempts all flash 4 Very high immediate 3 High urgent 2 Above normal priority 1 Normal routine 0 Default deferred -1 Lowest
Attack Modes#
Mode Hashcat Description dictionary 0 Wordlist attack mask 3 Brute force with mask hybrid_dictionary 6 Wordlist + mask hybrid_mask 7 Mask + wordlist
Logging Prefixes#
Copy [APIRequest] - API requests
[APIError] - API errors
[AgentLifecycle] - Agent state changes
[BroadcastError] - WebSocket errors
[TaskPreemption] - Task preemption
[JobDiscarded] - Failed jobs
Testing#
Copy
COVERAGE = true bundle exec rspec
bundle exec rspec spec/models/task_spec.rb
bundle exec rspec spec/models/task_spec.rb:42
HEADLESS = false bundle exec rspec spec/system
bundle exec rspec spec/requests
FactoryBot#
Copy
create( :task )
build( :agent )
create( :agent , :benchmarked )
create( :task , :running )
create( :campaign , :high_priority )
create( :task , state : "completed" , agent : my_agent)
Common Patterns#
Service Object#
Copy class MyService
def initialize ( model)
@model = model
end
def call
end
end
MyService . new ( model) . call
Controller Authorization#
Copy class MyController < ApplicationController
load_and_authorize_resource
def index
@items = @items . page( params[ :page ] )
end
end
API Response#
Copy
render json: @task , status : :ok
head :no_content
render json: { error : "Message" } , status : :unprocessable_entity
Transaction#
Copy Model. transaction do
record. lock!
record. update! ( field : value)
end
URLs#
Environment URL Development http://localhost:3000 API Docs http://localhost:3000/api-docs Admin http://localhost:3000/admin Sidekiq http://localhost:3000/sidekiq
Key Files#
File Purpose AGENTS.mdDeveloper conventions justfileTask runner commands config/routes.rbApplication routes app/models/ability.rbAuthorization rules spec/swagger_helper.rbAPI doc config config/initializers/sidekiq.rbJob config