bitfab 0.74.0 → 0.74.1
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 +28 -2
- 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: b1def1a5df451e3c7b1afa22248c2c54b2b135f5712eb19a989b41209a8c5622
|
|
4
|
+
data.tar.gz: 16a9741bbda86c16c78aafec91688d962c9ae58e9b032681a07d7b633497c258
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2be36b8b49c5b7c6d6525364c6f10a24d696eb40d8dae2343bdf1b1017e2f2fd47e6c52d8cdf200b4f1cf22a75fdd0ea41bf217e533090a9a42fa725ee7018a8
|
|
7
|
+
data.tar.gz: 5a4fe53c914d211714bbd2a31d44af37743edf1007f4599f52c6dfcce9e3bf970d90778588b1ee17267394017ed554752882f63d45a06fa7ce693786b97dc152
|
data/lib/bitfab/assertions.rb
CHANGED
|
@@ -4,9 +4,11 @@ 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
|
|
7
9
|
CATEGORY_ID_KEYS = ["category_id", :category_id].freeze
|
|
8
10
|
DEPRECATED_CATEGORY_ID_KEYS = ["category_assertion_id", :category_assertion_id].freeze
|
|
9
|
-
private_constant :CATEGORY_ID_KEYS, :DEPRECATED_CATEGORY_ID_KEYS
|
|
11
|
+
private_constant :CODE_DRAFT_SAVE_TIMEOUT_SECONDS, :CODED_KINDS, :CATEGORY_ID_KEYS, :DEPRECATED_CATEGORY_ID_KEYS
|
|
10
12
|
|
|
11
13
|
def initialize(http_client)
|
|
12
14
|
@http_client = http_client
|
|
@@ -44,6 +46,17 @@ module Bitfab
|
|
|
44
46
|
# pass "kind" => "judge" to remove the code. Returned assertions carry
|
|
45
47
|
# "kind", "code", and "codeBrokenReason".
|
|
46
48
|
#
|
|
49
|
+
# Send "kind" => "code" or "hybrid" without "code", on an assertion that
|
|
50
|
+
# has no code yet, to have Bitfab write the code: the text is checked by
|
|
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.
|
|
59
|
+
#
|
|
47
60
|
# By default, after the save, Bitfab checks each assertion's text against its
|
|
48
61
|
# trace. When the text bundles two claims, adds a condition, points at a
|
|
49
62
|
# value instead of stating it, names an id from the recorded run, or cannot
|
|
@@ -77,7 +90,8 @@ module Bitfab
|
|
|
77
90
|
"updates" => updates.map { |update| with_new_category_key(update) },
|
|
78
91
|
"source" => source,
|
|
79
92
|
"guidedRewrite" => !skip_guided_rewrite
|
|
80
|
-
}
|
|
93
|
+
},
|
|
94
|
+
timeout: save_timeout(updates)
|
|
81
95
|
)["assertions"]
|
|
82
96
|
saved.is_a?(Array) ? saved.map { |assertion| with_both_category_keys(assertion) } : saved
|
|
83
97
|
end
|
|
@@ -88,6 +102,18 @@ module Bitfab
|
|
|
88
102
|
|
|
89
103
|
private
|
|
90
104
|
|
|
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
|
+
|
|
91
117
|
def assertions_path(trace_id, suffix = "")
|
|
92
118
|
"/api/sdk/traces/#{URI.encode_www_form_component(trace_id).gsub("+", "%20")}/assertions#{suffix}"
|
|
93
119
|
end
|
data/lib/bitfab/version.rb
CHANGED