portage-ucp-decision 0.1.1 → 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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +8 -1
- data/lib/portage/ucp/decision/confidence_gate.rb +5 -0
- data/lib/portage/ucp/decision/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9bdbae877c8318720051a5f6e83c792376d58ba9d047832abfba82869d76d2bf
|
|
4
|
+
data.tar.gz: a54d775255057eca6ef3924213de7ec1f69ddfcc5ba60c2b1ce236be0a82797c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a05afad93f2cc4b9464b01e760d6eb9db5185210d0b6ce78a2d9b05d2cc813bbe67815f8c3ded579bb66272ed726f6f2f39f616bd87721a588af916ac96d09d7
|
|
7
|
+
data.tar.gz: 364e871b66d08e1c0f5e69d8b409137c958558ead7932565f4207225803528a398e54633571e86206786af92fb31349c62bd4ee1736a1ad3f1e2aee06e36d425
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ All notable changes to this project are documented here. Format loosely follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/); this project is
|
|
5
5
|
pre-1.0, so APIs may still shift between minor versions.
|
|
6
6
|
|
|
7
|
+
## [Unreleased]
|
|
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
|
+
|
|
7
18
|
## [0.1.1] - 2026-09-24
|
|
8
19
|
|
|
9
20
|
- The Jev backend's Faraday connection now sends its own User-Agent,
|
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:
|
|
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
|
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.
|
|
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-
|
|
11
|
+
date: 2026-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|