Rule Splitting Implementation Summary¶
Current Status¶
The rule splitting feature has been fully implemented but requires testing with a fresh job. The implementation includes:
Backend Components¶
- Database Schema (✓ Complete)
- Added columns to
job_executions
:uses_rule_splitting
,rule_split_count
,base_keyspace
,effective_keyspace
,multiplication_factor
-
Added columns to
job_tasks
:is_rule_split_task
,rule_chunk_path
,rule_start_index
,rule_end_index
-
Rule Split Manager (✓ Complete)
RuleSplitManager
service that handles splitting rule files into chunks- Creates temporary chunk files in
/data/krakenhashes/temp/rule_chunks/
-
Supports counting rules and creating evenly distributed chunks
-
Job Execution Service (✓ Complete)
calculateEffectiveKeyspace
- Calculates virtual keyspace for rules/combination attacksdetermineRuleSplitting
- Decides if a job should use rule splitting based on thresholdsInitializeRuleSplitting
- Creates rule chunk tasks when job starts-
GetNextRuleSplitTask
- Assigns rule chunks to agents -
Job Scheduling Service (✓ Complete)
- Enhanced to detect rule-split jobs and initialize splitting on first assignment
- Routes rule-split jobs through special task assignment logic
-
Syncs rule chunk files to agents
-
WebSocket Integration (✓ Complete)
- Sends rule chunk paths to agents as
rules/chunks/<filename>
- Properly handles file sync for rule chunks
Frontend Components¶
- Keyspace Display (✓ Complete)
- Shows effective keyspace with multiplication factor badge
- Tooltips explain virtual keyspace calculation
-
Proper handling of snake_case field names from backend
-
Admin Settings (✓ Complete)
- Rule splitting configuration in Job Execution settings
- Controls for threshold, min rules, max chunks
Known Issues¶
- Existing Jobs: Jobs created before the implementation don't have:
- Effective keyspace calculated
- Rule splitting decision made
-
This causes them to run with full rule files
-
Rule File Path Resolution: The
calculateEffectiveKeyspace
method may fail to count rules if the file path resolution doesn't match the actual file location.
How Rule Splitting Works¶
- When a job is created with attack mode 0 (straight) and rules:
- Calculate effective keyspace (wordlist × rules)
-
If effective keyspace > threshold × chunk_duration × benchmark_speed AND rules > min_rules:
- Mark job with
uses_rule_splitting = true
- Calculate optimal number of chunks
- Mark job with
-
When first agent picks up the job:
InitializeRuleSplitting
is called- Rule file is split into N chunks
-
N tasks are created, each with a chunk file path
-
Agents receive tasks with:
- Full wordlist keyspace (no skip/limit)
- Rule chunk file instead of full rule file
-
Progress tracked per chunk
-
Progress aggregation accounts for:
- Each chunk processes full wordlist with subset of rules
- Total progress = sum of (chunk_progress × rules_in_chunk)
Testing the Implementation¶
To test rule splitting with a new job:
- Create a preset job with:
- Attack mode 0 (straight)
- A wordlist (e.g., crackstation.txt with 1.2B words)
-
A large rule file (e.g., _nsakey.v2.dive.rule with 123K rules)
-
Create a job execution from this preset
- The job should be marked with
uses_rule_splitting = true
-
rule_split_count
should be calculated (e.g., 415 chunks) -
When agent picks up the job:
- Check logs for "Initializing rule splitting"
- Verify chunk files created in temp directory
- Agent should receive
rules/chunks/job_*_chunk_*.rule
path
Configuration¶
Current settings (in system_settings
table): - rule_split_enabled
: true - rule_split_threshold
: 2.0 (split if job takes > 2x chunk duration) - rule_split_min_rules
: 100 (only split if > 100 rules) - rule_split_max_chunks
: 1000 (maximum chunks to create) - rule_chunk_temp_dir
: /data/krakenhashes/temp/rule_chunks
Agent Expectations¶
Agents expect rule chunks to be available at: - <agent_data_dir>/rules/chunks/<chunk_filename>
The backend WebSocket integration correctly formats the path as rules/chunks/<filename>
when sending task assignments for rule-split jobs.