bitfab 0.65.6 → 0.65.7
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 +34 -6
- 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: 84d81613e344f01a011f28ac437476d22e73867eb7ab2df04579075730b1c73b
|
|
4
|
+
data.tar.gz: d3bb4d9f79d587dca9ee2ef2e1ee36a41fbeb59da7cb69960bf9fdbe75e8d663
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18ceec3ef05433309efff835c6bcf050789439e9d0424f9919972a70dd5d5b358eb07641fbed220d36b52e92f503d719dee044ba18003fb1371d77d0dba2e8e3
|
|
7
|
+
data.tar.gz: a6743709c41b9b69597e43e5c1336af5038bf9e5c56d5e3b247051e12fb4527d9732d79bb98e3587f90aedfbc59f7e23ebeae6c0d02e1bfad712f37d6789dd00
|
data/lib/bitfab/assertions.rb
CHANGED
|
@@ -13,7 +13,11 @@ module Bitfab
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# Each returned assertion carries "category_id" and, with the same value,
|
|
16
|
-
# the deprecated "category_assertion_id".
|
|
16
|
+
# the deprecated "category_assertion_id". It also carries "rewrite", the
|
|
17
|
+
# latest check of its text (the same hash a save returns), or nil when no
|
|
18
|
+
# check ever ran on it. Read a "pending" check from a save back here once
|
|
19
|
+
# it finishes, and save each of its "separateAssertions" as its own
|
|
20
|
+
# assertion.
|
|
17
21
|
def get_assertions(trace_id)
|
|
18
22
|
response = @http_client.get(assertions_path(trace_id))
|
|
19
23
|
return response unless response.is_a?(Hash) && response["assertions"].is_a?(Array)
|
|
@@ -24,17 +28,41 @@ module Bitfab
|
|
|
24
28
|
# Assertion hashes take "category_id": omit it to keep the assignment, or
|
|
25
29
|
# pass nil to clear it. The deprecated "category_assertion_id" is still
|
|
26
30
|
# accepted and sent as "category_id"; "category_id" wins when both are set.
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
#
|
|
32
|
+
# By default, after the save, Bitfab checks each assertion's text against its
|
|
33
|
+
# trace. When the text bundles two claims, adds a condition, points at a
|
|
34
|
+
# value instead of stating it, names an id from the recorded run, or cannot
|
|
35
|
+
# be measured, Bitfab rewrites it and saves the rewritten text in place of
|
|
36
|
+
# the text you sent. This method returns as soon as the text is saved: each
|
|
37
|
+
# checked assertion comes back with "status" "pending", and Bitfab rewrites
|
|
38
|
+
# it in place in the background, usually within a minute. Read the result
|
|
39
|
+
# later with {#get_assertions}, whose assertions carry the same "rewrite"
|
|
40
|
+
# hash. Pass skip_guided_rewrite: true to save the text exactly as sent,
|
|
41
|
+
# with no check.
|
|
42
|
+
#
|
|
43
|
+
# Each returned assertion carries a "rewrite" hash: "status" ("pending",
|
|
44
|
+
# "rewritten", "unchanged", "not_checked", or "check_failed"),
|
|
45
|
+
# "sentAssertion", "changes", "separateAssertions", "unresolved", and
|
|
46
|
+
# "error". A check not finished 15 minutes after the save reads as
|
|
47
|
+
# "check_failed", with the text as sent. Save each of
|
|
48
|
+
# "separateAssertions" as its own assertion, since the saved one keeps
|
|
49
|
+
# only one claim.
|
|
50
|
+
def save_assertions(trace_id, assertions, source: "agent", skip_guided_rewrite: false)
|
|
51
|
+
save_assertions_all([{"traceId" => trace_id, "assertions" => assertions}], source:, skip_guided_rewrite:)
|
|
29
52
|
end
|
|
30
53
|
|
|
31
|
-
# Same assertion hash keys
|
|
32
|
-
|
|
54
|
+
# Same assertion hash keys, rewrite, and returned "rewrite" hash as
|
|
55
|
+
# {#save_assertions}, for several traces at once.
|
|
56
|
+
def save_assertions_all(updates, source: "agent", skip_guided_rewrite: false)
|
|
33
57
|
return [] if updates.empty?
|
|
34
58
|
|
|
35
59
|
saved = @http_client.request(
|
|
36
60
|
"/api/sdk/traces/assertions",
|
|
37
|
-
{
|
|
61
|
+
{
|
|
62
|
+
"updates" => updates.map { |update| with_new_category_key(update) },
|
|
63
|
+
"source" => source,
|
|
64
|
+
"guidedRewrite" => !skip_guided_rewrite
|
|
65
|
+
}
|
|
38
66
|
)["assertions"]
|
|
39
67
|
saved.is_a?(Array) ? saved.map { |assertion| with_both_category_keys(assertion) } : saved
|
|
40
68
|
end
|
data/lib/bitfab/version.rb
CHANGED