portage-ucp-decision 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76adc7a80bc65b5fc181bc69c773cea60c9ad1f11a6bb3028add71d895321683
4
- data.tar.gz: e6048995c2bbadb78389342bfebe78c25eafefb04a95a158747ba2a97f2120ba
3
+ metadata.gz: 9bdbae877c8318720051a5f6e83c792376d58ba9d047832abfba82869d76d2bf
4
+ data.tar.gz: a54d775255057eca6ef3924213de7ec1f69ddfcc5ba60c2b1ce236be0a82797c
5
5
  SHA512:
6
- metadata.gz: 6b95c193adcc3c78e19bf01ebdc88eb88b681b5414c081af1d84438a93c025be438e78735637a136e791dc7ca5931d6689451421b2fb7d8062c81a99fc7ed2b1
7
- data.tar.gz: b7d76577b2e68e0cea4f5e8701cdcdf8fad1e799fefcb594668e7764fe6d368676e6278b2ede5115d536b34c2c2bf4d44a0e1c237286ab298c9aa2e379fdc9e0
6
+ metadata.gz: a05afad93f2cc4b9464b01e760d6eb9db5185210d0b6ce78a2d9b05d2cc813bbe67815f8c3ded579bb66272ed726f6f2f39f616bd87721a588af916ac96d09d7
7
+ data.tar.gz: 364e871b66d08e1c0f5e69d8b409137c958558ead7932565f4207225803528a398e54633571e86206786af92fb31349c62bd4ee1736a1ad3f1e2aee06e36d425
data/CHANGELOG.md CHANGED
@@ -6,6 +6,25 @@ pre-1.0, so APIs may still shift between minor versions.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.2] - 2026-10-01
10
+
11
+ - `ConfidenceGate.via_backend` now raises `BackendError` for a noul answer
12
+ that isn't a probability: below 0, above 1, NaN or Infinity. Before, a
13
+ backend answering 1.5 (or Infinity) cleared any threshold, so a
14
+ malformed reply could let a purchase through. Callers that fail closed on
15
+ `Decision::Error`, as `portage buy`'s confidence check does, now hold
16
+ instead.
17
+
18
+ ## [0.1.1] - 2026-09-24
19
+
20
+ - The Jev backend's Faraday connection now sends its own User-Agent,
21
+ `portage-ucp-decision/<ver> (+https://github.com/tomtom87/Portage)`,
22
+ instead of Faraday's default.
23
+
24
+ ## [0.1.0] - 2026-09-23
25
+
26
+ First publish to RubyGems. It ships the skeleton below plus these changes.
27
+
9
28
  - `OfferRanking` and `EscalationPolicy` now delegate to
10
29
  `portage-ucp`'s `Support::OfferRanking` and `Support::Escalation`, the
11
30
  way `PolicyCheck` already delegated to `PolicyGuard`. Their `Verdict`s
@@ -39,7 +58,7 @@ pre-1.0, so APIs may still shift between minor versions.
39
58
  - `Jev#configuration_problem` joins `Laya#configuration_problem` (now
40
59
  public): the reason a backend can't answer yet, for a setup check.
41
60
 
42
- ## [0.1.0] - 2026-09-23
61
+ ## 0.1.0 skeleton (never published)
43
62
 
44
63
  - First skeleton: `OfferRanking`, `EscalationPolicy`, `ConfidenceGate`, and
45
64
  `PolicyCheck` as typed decisions, per
data/README.md CHANGED
@@ -65,12 +65,19 @@ means "safe to proceed":
65
65
  jev = Portage::Ucp::Decision::ModelBackends::Jev.new
66
66
 
67
67
  Portage::Ucp::Decision::ConfidenceGate.via_backend(
68
- backend: jev, state: checkout.to_json, question: "safe_to_complete", threshold: 0.8,
68
+ backend: jev, state: summary.to_json, question: "safe_to_complete", threshold: 0.8,
69
69
  instructions: "Answer yes only if this checkout is safe to complete without a person reviewing it."
70
70
  )
71
71
  # => #<data Verdict proceed=false, confidence=0.37, threshold=0.8>
72
72
  ```
73
73
 
74
+ `state` goes to the backend as is, and Jev is a hosted third-party API, so
75
+ build it from an allowlist of the fields the question needs rather than
76
+ serializing a whole checkout: never a payment token, an address, or a
77
+ buyer's name, phone or email. `portage buy` does this with
78
+ `Portage::Cli::ConfidenceState`. A noul value outside 0..1 (or NaN) raises
79
+ `BackendError`, so treat any `Decision::Error` as "don't proceed".
80
+
74
81
  ## What this gem leaves out, and why
75
82
 
76
83
  These were in the first skeleton and were removed before 0.1.0 was
@@ -48,6 +48,11 @@ module Portage
48
48
  unless answer.value.is_a?(Numeric)
49
49
  raise Portage::Ucp::Decision::BackendError, "noul answer carried no probability: #{answer.to_h}"
50
50
  end
51
+ # A probability outside 0..1 (or NaN/Infinity) isn't one: 1.5 or
52
+ # Infinity would otherwise clear any threshold.
53
+ unless answer.value.finite? && answer.value.between?(0, 1)
54
+ raise Portage::Ucp::Decision::BackendError, "noul answer is not a probability: #{answer.value.inspect}"
55
+ end
51
56
 
52
57
  call(confidence: answer.value, threshold: threshold)
53
58
  end
@@ -21,6 +21,7 @@ module Portage
21
21
  # to two minutes on a hung connection.
22
22
  OPEN_TIMEOUT = 5
23
23
  TIMEOUT = 15
24
+ USER_AGENT = "portage-ucp-decision/#{VERSION} (+https://github.com/tomtom87/Portage)".freeze
24
25
  ENV_KEY = "JEV_API_KEY".freeze
25
26
  FALLBACK_ENV_KEY = "TYPESAFE_API_KEY".freeze
26
27
 
@@ -32,7 +33,8 @@ module Portage
32
33
  @api_key = api_key
33
34
  @model = model
34
35
  @connection = connection ||
35
- Faraday.new(url: BASE_URL, request: { open_timeout: OPEN_TIMEOUT, timeout: TIMEOUT })
36
+ Faraday.new(url: BASE_URL, headers: { "User-Agent" => USER_AGENT },
37
+ request: { open_timeout: OPEN_TIMEOUT, timeout: TIMEOUT })
36
38
  end
37
39
 
38
40
  def configured? = configuration_problem.nil?
@@ -1,7 +1,7 @@
1
1
  module Portage
2
2
  module Ucp
3
3
  module Decision
4
- VERSION = "0.1.0".freeze
4
+ VERSION = "0.1.2".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portage-ucp-decision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Whitbread
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-23 00:00:00.000000000 Z
11
+ date: 2026-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday