Repository navigation
Send every page iteration to the cloud, and keep responses made for one visitor out of the cache - #295
Merged
jwrosewell merged 7 commits intoDec 1, 2026
Conversation
…est answers and visitor connection to the cloud
Two files conflicted, each where rc and this branch changed the same lines. In cloudrequestengine.py, CloudRequestEngine.process, rc skips the cache for a request that carries a sealed Human Confidence result, because a sealed result redeems once. This branch skips the cache for a request that bypasses_cache picks out, being one carrying a session id, a sequence, a JA4 or an H2, because the cache key leaves those out. The resolution skips the cache when either is true. As on rc, the call to process_internal is not assigned, because process_internal returns nothing and pylint flags the assignment. In constants.py, rc added HIDDEN_VALUE and this branch added UNCACHED_EVIDENCE_NAMES in the same place. Both are kept. The cloud request engine's tests pass with no keys set (185 passed, 2 skipped live licence key tests, 4 live tests deselected). Taking out either condition fails a test, being test_a_request_with_a_sealed_result_skips_the_cache for the sealed result, and test_every_iteration_reaches_the_cloud_through_a_cache and test_a_supplied_connection_is_never_served_from_a_cache for bypasses_cache.
A cloud response made for one visitor is never stored in or served from the response cache. The branch already kept out a response holding a 51Did (a top-level fodid) and a request carrying a session id, a sequence, a JA4 or an H2, and rc kept out a request carrying a sealed result to redeem. is_cacheable now also keeps out: - a response carrying a sealed Human Confidence result, being a derived.humanconfidence whose value is text that is not blank and is none of High, Medium or Low. HumanConfidenceSource is never read, because the route decides sealing and a sealed result can be Passive or Active. - a response carrying the browser tests' script, being a browserderived.browsertestsjavascript that is not blank. Member names are compared in any case, as fodid already was. The comments on bypasses_cache and UNCACHED_EVIDENCE_NAMES now give the reason the rule gives, a request made for one visitor, and no longer say the cloud service does not list the JA4 and H2, which its evidence key list now does. New tests in test_cloudrequestengine_cache.py cover a sealed Passive result, a sealed result with any source, an unsealed Active value (High, Medium and Low are cached), a null value, a blank value, the names in any case, the browser tests' script and a null or blank script. The cloud request engine's tests pass with no keys set (194 passed, 2 skipped live licence key tests, 4 live tests deselected), and taking out either new check fails four of the new tests.
HumanConfidence is published with the values High, Medium, Low and Unknown, so a sealed result is text that is not blank and is none of those four, letter case ignored. is_sealed_value treated Unknown as sealed and compared the other three in their exact case, so a response whose HumanConfidence was Unknown, or a published value in another case, was kept out of the response cache. UNSEALED_VALUES now holds the four published values in lower case and is_sealed_value compares the value in lower case. The cache tests cache Unknown with an Active source, Unknown with no source or a Passive one, and each published value in another letter case. The cloud request engine's tests pass with no keys set (195 passed, 2 skipped live licence key tests, 4 live tests deselected), and taking Unknown out of UNSEALED_VALUES fails two of the cache tests.
HumanConfidence has the values High, Medium and Low only, so Unknown is text other than those and counts as a sealed result, which the response cache never stores or serves. This undoes the Unknown part of 8c5d400. The letter case of a value is still ignored, as the rule says. UNSEALED_VALUES is back to high, medium and low. The cache tests no longer cache Unknown, and a new test checks that Unknown, with no source or a Passive or Active one and in lower case, is neither stored nor served. High, Medium and Low in another letter case are still cached. The cloud request engine's tests pass with no keys set (196 passed, 2 skipped live licence key tests, 4 live tests deselected), and putting Unknown back in UNSEALED_VALUES fails the new test.
Contributor
Author
|
CI so far. Pull Requests workflow, started as a dry run on rc so it builds this pull request without merging it: run 46604408961. It built 8c5d400, the head before a0502f0. Configure chose Ubuntu with Python 3.10 and 3.14.
The checks this pull request runs passed at 8c5d400, including Cloud Human Confidence Tests against the staging cloud. A second dry run for a0502f0 is listed in the next comment. |
jwrosewell
deleted the
feature/cloud-request-engine-browser-test-pass-through
branch
December 1, 2026 12:36
Merged
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.
What this changes
When a page loads the pipeline's JavaScript from the publisher's server, the browser runs the browser tests and posts the answers back to that server, which passes them on to the cloud through the Cloud Request Engine. This pull request makes sure that server route sends the cloud what it needs on every iteration of a page, and that a response made for one visitor is never stored in or served from the engine's response cache.
51D_cookies, reach the cloud unchanged on every iteration.query.client-ip,query.ja4andquery.h2) has them sent to the cloud on every iteration, with the supplied address replacing the address the request arrived from.Points 1 and 2 already held on rc, and the new tests pin them down. Point 3 is the code change.
The response cache rule
This pull request follows the response cache rule set for the Cloud Request Engine in every language, exactly. A cloud response made for one visitor is never stored in or served from the response cache. That covers:
How the engine meets each one, with member names compared in any case:
CloudRequestEngine.is_cacheable,humanconfidence.is_sealed_valuederived.humanconfidenceis text, not blank, and none ofHigh,MediumorLowin any letter case, soUnknowncounts as sealedCloudRequestEngine.is_cacheablebrowserderived.browsertestsjavascriptis not blankCloudRequestEngine.is_cacheablefodid, as the caching page of the specification already saysCloudRequestEngine.process,CloudRequestEngine.bypasses_cachesession-id,sequence,ja4orh2under any prefix (Constants.UNCACHED_EVIDENCE_NAMES)is_cacheableis asked both before a response is stored and when an entry is found, so an entry that breaks the rule is not served even where it got into the cache some other way. A request for rule 4 never reaches the cache at all. rc already sent a request carrying a sealed result to redeem (query.humanconfidence) straight to the cloud, because a sealed result redeems once, and that stays.The cache key is built from the evidence keys the cloud lists, but the engine sends every evidence value. The session id, the sequence and the browser test answers are not in that list, so without rule 4 two iterations of one page that differ only in those would share a key, and the iteration carrying the answers would be answered from the cache and never reach the cloud.
Merge with rc
The branch was 52 commits behind rc, and rc is merged in by 2aad47b5. Two files conflicted, each where rc and this branch changed the same lines.
cloudrequestengine.py, inCloudRequestEngine.process. rc already skips the cache for a request that carries a sealed Human Confidence result to redeem. The resolution skips the cache when either a sealed result is present orbypasses_cacheis true. It keeps rc's form of callingprocess_internalwithout assigning its result, becauseprocess_internalreturns nothing.constants.py. rc'sHIDDEN_VALUEand this branch'sUNCACHED_EVIDENCE_NAMESwere added in the same place, and both are kept.Rules 1 and 2 are added by d7ff3857, and 8c5d4004 compares the values in any letter case. 8c5d400 also counted Unknown as a value rather than a sealed result, which a0502f0d undoes, because HumanConfidence has the values High, Medium and Low only. d7ff385 also corrects the comments on
bypasses_cacheandUNCACHED_EVIDENCE_NAMES. They said the cloud does not list the JA4 and H2, but the cloud's public evidence key list (https://cloud.51degrees.com/api/v4/evidencekeys, read on 1 December 2026) holdsquery.ja4,header.ja4,server.ja4,query.h2,header.h2andserver.h2, though notsession-idorsequence. The comments now give the rule's reason, a request made for one visitor.Tests
tests/test_server_route_pass_through.pyfollows the back and forth through a Flask application that serves the JavaScript and the JSON endpoint, as a web integration does, with a mock cloud client in place of the service. Flask is added to the package'stox.initest dependencies, andpipeline/ci/setup-environment.ps1already installs it in CI.tests/test_cloudrequestengine_cache.pycovers rules 1 to 3 through a pipeline with a cache. For rule 1 it checks a sealed result whose source is Passive (neither stored nor served), a sealed result whose source is Active, absent or anything else, an unsealed Active value (High, Medium and Low are cached), each of those in another letter case (cached), Unknown with no source or a Passive or Active one and in lower case (neither stored nor served), a null value with its null reason (cached), a blank value (cached), the names in any case, and a sealed-looking value under another data key (cached). For rule 2 it checks the script in any case (neither stored nor served) and a null or blank script (cached).The cloud request engine package's tests were run on Windows with Python 3.12, with no resource key or licence key set and the live tests deselected (
-m "not live"), at a0502f0.test_unknown_is_neither_stored_nor_served.bypasses_cachecondition inprocessfailstest_every_iteration_reaches_the_cloud_through_a_cacheandtest_a_supplied_connection_is_never_served_from_a_cache. Taking out the sealed result condition failstest_a_request_with_a_sealed_result_skips_the_cache. So both sides of the resolved conflict are covered by a test.CI runs are listed in the comments below.
test_available_propertiesfails with "Property: serviceworkers is not present in the results" on every Build and Test job of rc already, for example rc's release run at d79e0e62. That failure comes from the key CI uses, not from this change.