Repository navigation
FIX: Redeem a sealed Human Confidence value in the cloud request engine - #274
Draft
jwrosewell wants to merge 1 commit into
Draft
jwrosewell wants to merge 1 commit into
jwrosewell wants to merge 1 commit into
Conversation
A request whose evidence holds a non-empty query.humanconfidence carries a sealed value. The cloud request engine redeems it in the JSON call it already makes, sending the value, the challenge it kept for the page, and the License Key, and asking for derived.humanconfidence. Other challenge evidence is left out. The answer gives the level and Active, or Low and Active where the value is not redeemed. Such a request skips the cache, and messages built from it show the three values as asterisks. human_confidence_page_values() gives each page a challenge and a page value. HumanConfidenceChallenges keeps them for 60 seconds and gives each out once, unless the human_confidence_challenges setting names another store. The web demo now redeems through a second pipeline whose engine has the License Key. /active takes the place of /redeem, and the page asks for the 51Degrees script with the challenge.
This was referenced Nov 23, 2026
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The draft Human Confidence specification (51Degrees/specifications#201) says the language package redeems a sealed value through the JSON call its Cloud Request Engine already makes, and that an example MUST NOT redeem one itself. This does both for Python.
It is opened against the branch of #271, the web demo it changes, so it shows only its own change. Merge #271 first.
What changes
Package
humanconfidence.pywithHumanConfidenceNames, every name used in one place, andHumanConfidenceChallenges, an in-memory store that gives each page a new random page value and challenge, gives each out once, drops them after 60 seconds, and keeps at most 100,000, oldest dropped first.CloudRequestEngine:human_confidence_page_values()gives a page{"challenge": ..., "humanconfidencepage": ...}. The new settinghuman_confidence_challengestakes another store withissueandtake, such as one shared between servers.query.humanconfidencetakes the challenge kept forquery.humanconfidencepage. The JSON call, to the same endpoint as before, sendshumanconfidenceas it arrived,challenge(the one kept),license, andvalueswithderived.humanconfidenceadded for that call only. Evidence whose name strips tochallengeorhumanconfidenceis left out, under any prefix and in any letter case, andhumanconfidencepageis never sent.derivedsection getshumanconfidenceas the level, orLow, andhumanconfidencesourceasActive. With no License Key, no challenge kept for the page, no call made, or a failed call, the data is still set toLowandActive. A failed call is then raised, so it is the engine's error as on any other request.********. Other requests keep the masking they have today.processsets thecloud-responsealias in afinallyblock, so it is set even when the engine raises after setting its data.derived.humanconfidenceandderived.humanconfidencesourcethrough aCloudEnginewithdatakey = "derived", as this package already does for other sections. No new element is added.Web demo
/redeemroute and its call tohc/redeemare gone.?challenge=in both modes, and sends the first sealed value to/activeashumanconfidence, withhumanconfidencepage./activegives onlyhumanConfidenceandhumanConfidenceSource, and a value that does not redeem gives Active Low./activein the same way. The page value is used once, so a replay after the page has redeemed gives Active Low./active.Tests
pipeline/fiftyone_pipeline_cloudrequestengine,python -m pytest tests. Before, 139 passed and 4 skipped. After, 164 passed and 6 skipped, the 6 being live tests with no key set. With the engine change taken out and the tests kept, every test of a sealed request fails.tests/test_human_confidence.pyfollows the "Required tests" of the specification page case by case. The case "The Pipeline has no Cloud Request Engine" is not covered, as nothing in this package runs without one.tests/test_human_confidence_live.pyneeds_51DEGREES_RESOURCE_KEY_BESPOKEand_51DEGREES_LICENSE_KEY_BESPOKE, uses_51DEGREES_CLOUD_ENDPOINTwhen it is set, and is markedlive. It was not run.pipeline/fiftyone_pipeline_cloudrequestengine/examples. Before, 88 passed and 4 skipped. After, 92 passed and 5 skipped, with no warnings under-W default. With the earlierapp.pyandindex.html, every new/active, challenge, and script test fails.parameterized(declared intox.ini) and thejs_templatessubmodule are needed.Before this leaves draft
derived.humanconfidence, and that the client script carries?challenge=into the call that seals the value. If it does not, every real redeem gives Low.humanconfidencepageis a name this package chose, as the specification does not name one yet. The names inHumanConfidenceNamesandhuman_confidence_page_valuesshould be agreed before other languages follow them.