Class: Insika::Harvest::Miner
- Inherits:
-
Object
- Object
- Insika::Harvest::Miner
- Defined in:
- lib/insika/harvest.rb
Overview
The model's raw skills, filtered into data the command then filters
(negative list, grounding, dedup — C6) and a human then gates.
Pure over an injected ask — the Refinement::Proposer shape.
Defined Under Namespace
Classes: Unusable
Constant Summary collapse
- MAX_NAME =
64- MAX_DESCRIPTION =
300- MAX_BODY =
6000- MAX_TRIGGERS =
10- MAX_TRIGGER =
80- MAX_RATIONALE =
500- MAX_EVIDENCE_TURNS =
20- MAX_SESSIONS =
The window cap the RUN applies (C6): a candidate whose origin sessions are a lie of provenance must never be stamped from a window of 50.
5- ALLOWED_KEYS =
%w[name description body triggers rationale evidence_turns].freeze
- DROP_KEYS =
%w[schema unknown_key oversized bad_turns duplicate capped].freeze
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
ask: ->(prompt) { "
" } | something answering #content (+ #input_tokens/#output_tokens/#cached_tokens for cost).
Instance Method Summary collapse
-
#initialize(ask:, model: "utility_model") ⇒ Miner
constructor
A new instance of Miner.
-
#mine(prompt:, message_counts:, max_proposals: 10) ⇒ Object
-> { skills: [ raw candidate hashes ], dropped: { "schema" => N, "unknown_key" => N, "oversized" => N, "bad_turns" => N, "duplicate" => N, "capped" => N }, cost: { "spent" => N, "cached" => N } | nil } prompt: the pack prompt or DEFAULT_PROMPT (the caller resolved it).
Constructor Details
#initialize(ask:, model: "utility_model") ⇒ Miner
Returns a new instance of Miner.
97 98 99 100 |
# File 'lib/insika/harvest.rb', line 97 def initialize(ask:, model: "utility_model") @ask = ask @model = model.to_s end |
Instance Attribute Details
#model ⇒ Object (readonly)
ask: ->(prompt) { "proposer ("utility_model"
default).
95 96 97 |
# File 'lib/insika/harvest.rb', line 95 def model @model end |
Instance Method Details
#mine(prompt:, message_counts:, max_proposals: 10) ⇒ Object
-> { skills: [ raw candidate hashes ],
dropped: { "schema" => N, "unknown_key" => N, "oversized" => N,
"bad_turns" => N, "duplicate" => N, "capped" => N },
cost: { "spent" => N, "cached" => N } | nil }
prompt: the pack prompt or DEFAULT_PROMPT (the caller resolved it).
message_counts: the origin sessions' transcript sizes, in prompt order,
so evidence_turns indexes are validated against the sessions they
name (an index is valid if it fits at least one session).
max_proposals: cap on surviving raw skills. Drops counted, never fixed.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/insika/harvest.rb', line 111 def mine(prompt:, message_counts:, max_proposals: 10) answer = @ask.call(prompt) raw = parse(text_of(answer)) skills = [] dropped = DROP_KEYS.to_h { |k| [k, 0] } seen = {} raw.each do |item| verdict, reason = classify(item, ) case verdict when :keep tuple = [item["name"].to_s, item["description"].to_s, item["body"].to_s] if seen[tuple] dropped["duplicate"] += 1 elsif skills.size >= max_proposals dropped["capped"] += 1 else seen[tuple] = true skills << normalize(item) end when :drop dropped[reason] += 1 end end { skills: skills, dropped: dropped, cost: cost_of(answer) } end |