class
Crowbar::Session
- Crowbar::Session
- Reference
- Object
Overview
Persistent Session Manager for iterative fuzzing and evolutionary feedback. Stores baseline input, bandit weights, genetic corpus, and mutation histories across CLI invocations.
Included Modules
- JSON::Serializable
Defined in:
crowbar/session.crConstructors
- .load_or_create(id : String, baseline : Buffer, rule_name : String | Nil = nil, pattern_name : String | Nil = nil, selected_mutations : String | Nil = nil, seed : UInt64 | Nil = nil, dir : String = default_dir) : Session
- .new(id : String, baseline : Buffer, rule_name : String | Nil = nil, pattern_name : String | Nil = nil, selected_mutations : String | Nil = nil, seed : UInt64 | Nil = nil)
- .new(pull : JSON::PullParser)
- .new(*, __pull_for_json_serializable pull : JSON::PullParser)
Class Method Summary
- .default_dir : String
- .exists?(id : String, dir : String = default_dir) : Bool
- .items_dir(id : String, dir : String = default_dir) : String
- .list(dir : String = default_dir) : Array(String)
- .load(id : String, dir : String = default_dir) : Session | Nil
- .reset(id : String, dir : String = default_dir) : Bool
- .session_path(id : String, dir : String = default_dir) : String
Instance Method Summary
- #active_rules : Array(String)
- #active_rules=(active_rules : Array(String))
- #add_mutator(name : String) : self
- #add_rule(name : String) : self
- #add_scope(name : String, selector_type : String, params : Hash(String, String) = Hash(String, String).new, weight : Float64 = 1.0) : self
- #arms : Hash(String, ArmState)
- #arms=(arms : Hash(String, ArmState))
- #auto_detect_rule : String | Nil
- #baseline : Buffer
- #baseline=(buf : Buffer)
- #baseline_b64 : String
- #baseline_b64=(baseline_b64 : String)
-
#build_engine : Engine
Builds and re-hydrates an Engine instance with stored session state
- #clear_rules : self
- #clear_scopes : self
- #clear_seen_hashes : self
- #corpus_items : Array(CandidateState)
- #corpus_items=(corpus_items : Array(CandidateState))
- #created_at : Time
- #created_at=(created_at : Time)
-
#get_item(iter : Int32) : SessionItem | Nil
Retrieves a SessionItem by iteration number
-
#get_mutant(iter : Int32, dir : String = Session.default_dir) : Buffer | Nil
Retrieves the mutant buffer for an iteration (from disk cache or deterministic replay)
- #history : Array(HistoryEntry)
- #history=(history : Array(HistoryEntry))
- #id : String
- #id=(id : String)
- #input_encoding : String | Nil
- #input_encoding=(input_encoding : String | Nil)
- #item_retention : Int32
- #item_retention=(item_retention : Int32)
- #items : Array(SessionItem)
- #items=(items : Array(SessionItem))
- #items_dir(dir : String = Session.default_dir) : String
- #iteration : Int32
- #iteration=(iteration : Int32)
- #last_mutant : Buffer | Nil
- #last_mutant=(buf : Buffer | Nil)
- #last_mutant_b64 : String | Nil
- #last_mutant_b64=(last_mutant_b64 : String | Nil)
- #last_mutators : Array(String)
- #last_mutators=(last_mutators : Array(String))
- #last_reward : Float64 | Nil
- #last_reward=(last_reward : Float64 | Nil)
-
#next_mutant(dir : String = Session.default_dir, unique : Bool | Nil = nil, seek : Int64 | Nil = nil, template_override : String | Nil = nil) : Buffer
Generates the next mutant, updates session iteration, syncs bandit & corpus, and saves state.
- #output_encoding : String | Nil
- #output_encoding=(output_encoding : String | Nil)
- #pattern_name : String | Nil
- #pattern_name=(pattern_name : String | Nil)
- #remove_mutator(name : String) : self
- #remove_rule(name : String) : self
- #remove_scope(name : String) : self
-
#replay(iter : Int32) : Tuple(Buffer, Array(TransformationStep))
Deterministically replays and reconstructs an iteration from baseline
- #reset_mutators : self
-
#reset_with(new_baseline : Buffer, rule_name : String | Nil = nil, pattern_name : String | Nil = nil, selected_mutations : String | Nil = nil, seed : UInt64 | Nil = nil)
Resets the session with a new baseline input, clearing corpus and iteration counter
-
#reward(value : Float64, dir : String) : Session
Applies feedback score (-1.0 to 1.0) with custom directory override
-
#reward(value : Float64, iteration : Int32 | Nil = nil, dir : String = Session.default_dir) : Session
Applies feedback score (-1.0 to 1.0) to a specific generated mutant (default: latest)
- #rule_name : String | Nil
- #rule_name=(rule_name : String | Nil)
-
#save(dir : String = Session.default_dir)
Serializes session to JSON file on disk
- #scopes : Array(ScopeConfig)
- #scopes=(scopes : Array(ScopeConfig))
- #seed : UInt64
- #seed=(seed : UInt64)
- #seek_offset : Int64
- #seek_offset=(seek_offset : Int64)
- #seen_hashes : Array(UInt64)
- #seen_hashes=(seen_hashes : Array(UInt64))
- #selected_mutations : String | Nil
- #selected_mutations=(selected_mutations : String | Nil)
- #set_mutators(list : Array(String)) : self
- #set_pattern(pat : String) : self
- #set_seek(offset : Int64) : self
- #set_template(spec : String | Nil) : self
- #set_unique(enabled : Bool, capacity : Int32 = 10000) : self
- #template : String | Nil
- #template=(template : String | Nil)
- #total_pulls : Int64
- #total_pulls=(total_pulls : Int64)
- #unique_enabled : Bool
- #unique_enabled=(unique_enabled : Bool)
- #uniqueness_capacity : Int32
- #uniqueness_capacity=(uniqueness_capacity : Int32)
- #updated_at : Time
- #updated_at=(updated_at : Time)
Constructor Detail
Class Method Detail
Instance Method Detail
Retrieves the mutant buffer for an iteration (from disk cache or deterministic replay)
Generates the next mutant, updates session iteration, syncs bandit & corpus, and saves state. Optionally accepts runtime overrides for uniqueness deduplication, PRNG seek, and output templating.
Deterministically replays and reconstructs an iteration from baseline
Resets the session with a new baseline input, clearing corpus and iteration counter
Applies feedback score (-1.0 to 1.0) with custom directory override