bitfab 0.36.9 → 0.36.10
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/client.rb +20 -9
- 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: 47a3e6b763bf08e8e4a25173414f1ed306dc7183ea443f0b71264645fe5b4c02
|
|
4
|
+
data.tar.gz: 2c629b4d599e25e124334f1d9ee61b5683316c7b849535ffa0aabe50324105eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 30dbfa2213bd23581fa3387d47a600ad79ed62f8120ae11e237557b87aa28f8d1413162b0b9ab9f9ddc9d5489a0b884793e632a29538369e40753327384d6bf2
|
|
7
|
+
data.tar.gz: 7cb61050f45cc07f273f8bcc22f8ca8d0530d9b67386b22472906225eedc8d5937e2f8158a7810b0b211a1c0a558994c0c675f8e17a8efa633a882cc0d8fd596
|
data/lib/bitfab/client.rb
CHANGED
|
@@ -325,11 +325,12 @@ module Bitfab
|
|
|
325
325
|
# counters: they cannot shift each other.
|
|
326
326
|
call_index = advance_mock_counter(replay_ctx, trace_function_key, span_name, is_root_span:)
|
|
327
327
|
if call_index
|
|
328
|
-
|
|
328
|
+
mock_result = check_mock_replay(
|
|
329
329
|
replay_ctx, trace_function_key, span_name, call_index,
|
|
330
330
|
span_type:, args:, kwargs:, mock_on_replay:
|
|
331
331
|
)
|
|
332
|
-
if
|
|
332
|
+
if mock_result != MOCK_REPLAY_MISS
|
|
333
|
+
mocked_output, mock_source = mock_result
|
|
333
334
|
send_mocked_span(
|
|
334
335
|
trace_function_key:,
|
|
335
336
|
trace_id:,
|
|
@@ -343,7 +344,8 @@ module Bitfab
|
|
|
343
344
|
mocked_output:,
|
|
344
345
|
started_at:,
|
|
345
346
|
test_run_id: resolved_test_run_id,
|
|
346
|
-
input_source_span_id: resolved_input_source_span_id
|
|
347
|
+
input_source_span_id: resolved_input_source_span_id,
|
|
348
|
+
mock_source:
|
|
347
349
|
)
|
|
348
350
|
return mocked_output
|
|
349
351
|
end
|
|
@@ -641,7 +643,8 @@ module Bitfab
|
|
|
641
643
|
|
|
642
644
|
def send_span(trace_function_key:, trace_id:, span_id:, parent_span_id:,
|
|
643
645
|
span_name:, span_type:, function_name:, contexts:, prompt:, args:, kwargs:, result:, error:,
|
|
644
|
-
started_at:, ended_at:, test_run_id: nil, input_source_span_id: nil, mocked: false
|
|
646
|
+
started_at:, ended_at:, test_run_id: nil, input_source_span_id: nil, mocked: false,
|
|
647
|
+
mock_target: nil, mock_source: nil)
|
|
645
648
|
# If drop() was called on this trace, suppress the span PAYLOAD upload for
|
|
646
649
|
# every span that completes after the flag was set. The trace completion
|
|
647
650
|
# still rides out with dropped: true, so the server scrubs any sibling
|
|
@@ -701,6 +704,10 @@ module Bitfab
|
|
|
701
704
|
# replay so the trace view can mark them (matches the Python and
|
|
702
705
|
# TypeScript SDKs).
|
|
703
706
|
payload["mocked"] = true if mocked
|
|
707
|
+
# How the mock was produced, when known: what it replaced, and whether the
|
|
708
|
+
# value was the original trace's own or one the caller supplied.
|
|
709
|
+
payload["mockTarget"] = mock_target if mock_target
|
|
710
|
+
payload["mockSource"] = mock_source if mock_source
|
|
704
711
|
|
|
705
712
|
# A value that could only be captured as a placeholder makes the span
|
|
706
713
|
# non-replayable; record it on the payload's errors (matching the Python
|
|
@@ -769,7 +776,7 @@ module Bitfab
|
|
|
769
776
|
# override always injects, execute_span short-circuits even when this
|
|
770
777
|
# is nil (nil != MOCK_REPLAY_MISS). To inject a proc as the literal
|
|
771
778
|
# output, wrap it in a callable value.
|
|
772
|
-
return value unless value.respond_to?(:call)
|
|
779
|
+
return [value, "override"] unless value.respond_to?(:call)
|
|
773
780
|
|
|
774
781
|
get_original_output = lambda do
|
|
775
782
|
unless mock_entry
|
|
@@ -777,7 +784,7 @@ module Bitfab
|
|
|
777
784
|
end
|
|
778
785
|
resolve_recorded_output(mock_entry, replay_ctx)
|
|
779
786
|
end
|
|
780
|
-
return value.call({node:, inputs: args, kwargs:, get_original_output:})
|
|
787
|
+
return [value.call({node:, inputs: args, kwargs:, get_original_output:}), "override"]
|
|
781
788
|
end
|
|
782
789
|
end
|
|
783
790
|
|
|
@@ -794,7 +801,7 @@ module Bitfab
|
|
|
794
801
|
|
|
795
802
|
return MOCK_REPLAY_MISS unless mock_entry
|
|
796
803
|
|
|
797
|
-
resolve_recorded_output(mock_entry, replay_ctx)
|
|
804
|
+
[resolve_recorded_output(mock_entry, replay_ctx), "recorded"]
|
|
798
805
|
end
|
|
799
806
|
|
|
800
807
|
# Resolve a mock-tree entry's recorded output. Prefers an inline output when
|
|
@@ -833,7 +840,7 @@ module Bitfab
|
|
|
833
840
|
# output as the result and no error.
|
|
834
841
|
def send_mocked_span(trace_function_key:, trace_id:, span_id:, parent_span_id:,
|
|
835
842
|
span_name:, span_type:, function_name:, args:, kwargs:, mocked_output:,
|
|
836
|
-
started_at:, test_run_id:, input_source_span_id:)
|
|
843
|
+
started_at:, test_run_id:, input_source_span_id:, mock_source:)
|
|
837
844
|
ended_at = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ")
|
|
838
845
|
send_span(
|
|
839
846
|
trace_function_key:,
|
|
@@ -853,7 +860,11 @@ module Bitfab
|
|
|
853
860
|
ended_at:,
|
|
854
861
|
test_run_id:,
|
|
855
862
|
input_source_span_id:,
|
|
856
|
-
mocked: true
|
|
863
|
+
mocked: true,
|
|
864
|
+
# Both paths short-circuit the call, so the target is always the
|
|
865
|
+
# output; only where the value came from differs.
|
|
866
|
+
mock_target: "output",
|
|
867
|
+
mock_source:
|
|
857
868
|
)
|
|
858
869
|
rescue Exception # rubocop:disable Lint/RescueException
|
|
859
870
|
# Never crash the host app: mocked span recording is best-effort
|
data/lib/bitfab/version.rb
CHANGED