bitfab 0.75.2 → 0.75.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bitfab/assertions.rb +19 -42
- data/lib/bitfab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e8124c4242b339613c4f4b714a68305748f2c32e2d894fd884250bc8c1e4036
|
|
4
|
+
data.tar.gz: 9ed475b72f8f55b58334af9fe4feae30b07940aa9847c763fbccba227e21e41c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b1356376e48cbaf2a8889fdf7c26945ed21050035603ae480e00d6da313acff4292c981d7f9be751b3dcfd37aa954d5ab6619d492a4f0547f8af5f99faddfdb
|
|
7
|
+
data.tar.gz: 15239246da620b92a67d87aa731974b22efe17fa97f2f25103491454a6ddd64327225a3b12f92f6df9ebc1770aceb82a7eb090a938ec31b95d32b0ba63ebd37e
|
data/lib/bitfab/assertions.rb
CHANGED
|
@@ -4,11 +4,9 @@ require "uri"
|
|
|
4
4
|
|
|
5
5
|
module Bitfab
|
|
6
6
|
class Traces
|
|
7
|
-
CODE_DRAFT_SAVE_TIMEOUT_SECONDS = 300
|
|
8
|
-
CODED_KINDS = ["code", "hybrid", :code, :hybrid].freeze
|
|
9
7
|
CATEGORY_ID_KEYS = ["category_id", :category_id].freeze
|
|
10
8
|
DEPRECATED_CATEGORY_ID_KEYS = ["category_assertion_id", :category_assertion_id].freeze
|
|
11
|
-
private_constant :
|
|
9
|
+
private_constant :CATEGORY_ID_KEYS, :DEPRECATED_CATEGORY_ID_KEYS
|
|
12
10
|
|
|
13
11
|
def initialize(http_client)
|
|
14
12
|
@http_client = http_client
|
|
@@ -31,31 +29,23 @@ module Bitfab
|
|
|
31
29
|
# pass nil to clear it. The deprecated "category_assertion_id" is still
|
|
32
30
|
# accepted and sent as "category_id"; "category_id" wins when both are set.
|
|
33
31
|
#
|
|
34
|
-
# "
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
# the guided rewrite (unless skipped), code of that kind is written and run
|
|
52
|
-
# on the trace, and the save waits for both, so that entry's "rewrite" is
|
|
53
|
-
# already final. Its returned "codeDraft" hash says what happened:
|
|
54
|
-
# "requestedKind", "status" ("written", or "not_written" when no working
|
|
55
|
-
# code could be written and the assertion was saved as "judge" without
|
|
56
|
-
# code), and "reason" (why not, or nil). Every other entry's "codeDraft"
|
|
57
|
-
# is nil. At most 10 assertions per save may ask for code this way, and a
|
|
58
|
-
# save that asks for any waits up to five minutes.
|
|
32
|
+
# "code" is optional code that decides the assertion on a replay without
|
|
33
|
+
# the LLM judge: {"source" => ..., "spanNames" => [...]}. Send a "code"
|
|
34
|
+
# hash to set it, "code" => nil to remove it, or omit "code" to keep the
|
|
35
|
+
# current code. "source" is the body of an async TypeScript (or plain
|
|
36
|
+
# JavaScript) function called with spans (each {name, index, hasData}, in
|
|
37
|
+
# start order, without its data), input, and output. It reads span data
|
|
38
|
+
# with await named("span name") or await span.data(), with one second of
|
|
39
|
+
# compute and the data of at most 50 spans loaded within ten seconds. It
|
|
40
|
+
# returns "pass" or "fail", which decides the verdict with no judge call,
|
|
41
|
+
# or "defer" to hand the replay to the LLM judge, or {result, reason}. A
|
|
42
|
+
# defer may carry what the code found for the judge to read alongside the
|
|
43
|
+
# run: {result: "defer", reason, data}. A thrown error counts as "defer"
|
|
44
|
+
# with no data. "spanNames" lists every span a correct run is expected to
|
|
45
|
+
# produce. The code is run on the trace before saving and refused when it
|
|
46
|
+
# throws, times out, or returns anything other than a result. Returned
|
|
47
|
+
# assertions carry "code" (nil when the assertion has none) and
|
|
48
|
+
# "codeBrokenReason", which says why the code could not run on a replay.
|
|
59
49
|
#
|
|
60
50
|
# By default, after the save, Bitfab checks each assertion's text against its
|
|
61
51
|
# trace. When the text bundles two claims, adds a condition, points at a
|
|
@@ -90,8 +80,7 @@ module Bitfab
|
|
|
90
80
|
"updates" => updates.map { |update| with_new_category_key(update) },
|
|
91
81
|
"source" => source,
|
|
92
82
|
"guidedRewrite" => !skip_guided_rewrite
|
|
93
|
-
}
|
|
94
|
-
timeout: save_timeout(updates)
|
|
83
|
+
}
|
|
95
84
|
)["assertions"]
|
|
96
85
|
saved.is_a?(Array) ? saved.map { |assertion| with_both_category_keys(assertion) } : saved
|
|
97
86
|
end
|
|
@@ -102,18 +91,6 @@ module Bitfab
|
|
|
102
91
|
|
|
103
92
|
private
|
|
104
93
|
|
|
105
|
-
def save_timeout(updates)
|
|
106
|
-
asks = updates.any? do |update|
|
|
107
|
-
(update["assertions"] || update[:assertions] || []).any? { |assertion| asks_bitfab_to_write_code?(assertion) }
|
|
108
|
-
end
|
|
109
|
-
asks ? CODE_DRAFT_SAVE_TIMEOUT_SECONDS : nil
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def asks_bitfab_to_write_code?(assertion)
|
|
113
|
-
kind = assertion["kind"] || assertion[:kind]
|
|
114
|
-
CODED_KINDS.include?(kind) && !assertion.key?("code") && !assertion.key?(:code)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
94
|
def assertions_path(trace_id, suffix = "")
|
|
118
95
|
"/api/sdk/traces/#{URI.encode_www_form_component(trace_id).gsub("+", "%20")}/assertions#{suffix}"
|
|
119
96
|
end
|
data/lib/bitfab/version.rb
CHANGED