Skip to content

fix: bound task creation, log registry tokens - #369

Merged
uniqueg merged 7 commits into
devfrom
fix/create-budget-registry-log
Nov 1, 2026
Merged

uniqueg merged 7 commits into
devfrom
fix/create-budget-registry-log

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Code findings of the 0.4.0 pre-release review (#364).

  • Task creation within a 60 s proxy budget: the base config sets plugins.defaults.forward_timeout: 20 (FOCA's default: 60). Only the connect timeout of each attempt is cut to the time left; the last attempt's create read (custom.tes.timeout, 15 s) and the follow-up get_task (5 s connect + 15 s read) come on top, so with FOCA's default a request could take about 95 s, beyond the 60 s read timeout of common proxies (504, and a duplicate task on retry). With 20 s: 20 + 15 + 5 + 15 = 55 s. tests/test_app.py::test_create_task_budget guards the defaults; docs/configuration.md documents the bound, what it leaves out (registry reads due in the request, token requests, hosts with several addresses, database writes) and the trade-off (fewer unreachable TES instances are tried: about 4 configured or 2 discovered); docs/plugins.md, docs/upgrading.md and the chart's README name the new default.
  • Registries in the startup log of token recipients: "TES backends with access tokens of proTES" now also names registries with auth: client_credentials (those verified by registry <url>), as their verified TES instances get the same token; documented in docs/access-control.md. Test: tests/test_security.py::test_registry_tokens_logged.

Closes #364

Verification

  • TDD: both new tests failed first (assert 95 <= 55; the log line without the registry), then passed.
  • coverage run -m pytest: 1095 passed, 175 skipped (Helm chart tests: no helm locally), coverage 100%.
  • mkdocs build --strict: passed. pre-commit run --files <changed files> (ruff, mypy, semgrep, ast-grep, gitleaks): passed.
  • CI: all checks passed (CI passed, tests on mongomock and MongoDB 7.0, chart, smoke test, docs, scan, CodeQL).
  • Review: adversarial and quality reviewer subagents, two rounds; round-1 findings addressed (docs of the uncovered paths and of the failover trade-off, named headroom, docs of the new default and log line, variable rename).

Declined review findings

  • Pass the remaining forwarding budget to discovered backends (guarded client) and to token requests, and bound get_task by a total deadline: code changes beyond this issue (the guarded client's deadline also cuts reads short, see docs/plugins.md); documented as not covered instead. Candidates for a follow-up together with feat: limit exposure of tokens and backend URLs #366.
  • Refresh registries in the background instead of in the request: FOCA's behaviour (BackendList), documented.

Open questions

None for this PR. For the maintainer: 20 s trades failover depth for the proxy budget; deployments with long lists of unreliable TES instances raise it together with the proxy's timeout (documented).

🤖 Generated with Claude Code

Summary by Sourcery

Keep task creation within common proxy timeouts and make all proTES token recipients visible in startup logs.

Bug Fixes:

  • Bound task forwarding and state retrieval with a 20-second default forwarding budget so task-creation requests fit within common 60-second proxy read timeouts.
  • Include client-credential registries in startup logs identifying all TES recipients that receive proTES access tokens.

Enhancements:

  • Document the task-creation time budget, its exclusions, and the trade-off between proxy safety and failover depth.
  • Document the registry token recipient logging behavior and the updated forwarding timeout defaults.

Tests:

  • Add regression coverage for the task-creation budget and registry token recipient logging.

uniqueg and others added 5 commits October 31, 2026 23:40
Set plugins.defaults.forward_timeout to 20 s in the base config, so
that a request to create a task (attempts within forward_timeout, the
last create read, then connecting to and reading the task's state)
ends within 55 s with the defaults, below a 60 s proxy read timeout;
test the bound and document it.

Name the registries whose verified TES instances get proTES' token in
the startup line of token recipients.

Closes #364

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Document the paths outside the bound (registry reads, token requests,
hosts with several addresses, database writes), how many unreachable
TES instances fit into forward_timeout, the new default in the upgrade
guide and the chart's README, and the registries in the startup log.
Name the test's headroom (review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Also name slow answers as outside the creation bound (review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR constrains task creation to a 20-second forwarding budget so the default create-and-follow-up flow remains within a 60-second proxy timeout, while documenting timing exclusions and failover trade-offs. It also makes startup token-recipient logging include client-credential registries and adds regression coverage without logging secrets.

Sequence diagram for bounded task creation forwarding

sequenceDiagram
    participant Client
    participant ProTES
    participant TES

    Client->>ProTES: create_task
    ProTES->>TES: create_task within forward_timeout
    TES-->>ProTES: task response
    ProTES->>TES: get_task
    TES-->>ProTES: task state
    ProTES-->>Client: create response

    Note over ProTES: forward_timeout = 20s
    Note over ProTES,TES: Default create/follow-up budget: 20 + 15 + 5 + 15 = 55s
Loading

File-Level Changes

Change Details Files
Bounds task-creation forwarding to fit within common proxy read timeouts by lowering the base forwarding budget and documenting the resulting timing model and trade-offs.
  • Set the base forward_timeout to 20 seconds.
  • Add a regression test for the forwarding, task-creation, and get_task timeout budget.
  • Document covered and uncovered latency sources, configuration guidance, and reduced failover depth.
  • Update deployment, plugin, and upgrade documentation with the new default.
pro_tes/config.yaml
tests/test_app.py
docs/configuration.md
deployment/README.md
docs/plugins.md
docs/upgrading.md
Expands startup logging to identify registries whose verified TES backends receive proTES access tokens without exposing token values.
  • Include client-credential registries in the token-recipient log using a descriptive registry label.
  • Add documentation explaining the expanded startup log.
  • Add coverage verifying configured backends, registries, ordering, and secret redaction.
pro_tes/security.py
docs/access-control.md
tests/test_security.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@read-the-docs-community

read-the-docs-community Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #35552125 | 📁 Comparing e34a0e9 against latest (4fda44f)

  🔍 Preview build  

5 files changed · ± 5 modified

± Modified

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (5d6725d) to head (e34a0e9).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #369   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        23           
  Lines         2234      2234           
=========================================
  Hits          2234      2234           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 1, 2026 00:10

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="deployment/README.md" line_range="103-104" />
<code_context>
   defaults of the plugin store, `defaults.store`, and `gateway_id`) are
-  set in `config.plugins`.
+  set in `config.plugins`. The app's base config sets
+  `defaults.forward_timeout` to 20 seconds, so that requests to create
+  tasks end within the 60 seconds of common proxies; change it together
+  with `config.custom.tes.timeout` and the proxy's read timeout (see [TES
+  instances](https://protes.readthedocs.io/en/latest/configuration/#tes-instances)).
</code_context>
<issue_to_address>
**Proxy budget is overstated**

When a request triggers one of the extra paths excluded from the estimate, such as a due registry refresh or an identity-provider token request, a registry refresh, token request, or other excluded work adds time outside the 55-second forwarding-and-state estimate, so task creation can exceed the proxy read timeout and clients may retry a task that was already created.

Describe the 55-second figure as an estimate for forwarding and retrieving state, and qualify the shorter summaries to say that excluded work can still exceed the proxy timeout.

Also at `pro_tes/config.yaml:354-356`, `docs/upgrading.md:194-196`.
</issue_to_address>

Linked issues

#364 fix: bound task creation, log registry tokens · 4 of 4 met

# Requirement Status Notes
1 The startup log names registries whose instances get proTES' token. ✅ Met check_backends includes registry entries using client_credentials in the token-recipient log, labeled those verified by registry <url>.
2 Set the base-config forward_timeout so the combined task-creation duration stays within the 60-second proxy budget with the defaults. ✅ Met The base config sets forward_timeout to 20 seconds; with the 15-second TES timeout and 5-second connect timeout, the documented bound is 55 seconds.
3 Test that the defaults keep task creation within 60 seconds. ✅ Met test_create_task_budget checks the configured forwarding and TES timeouts against the 60-second proxy budget, leaving named headroom.
4 Document the combined task-creation bound. ✅ Met docs/configuration.md states the formula and default duration, and describes paths outside the bound.

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: deployment/README.md:104


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread deployment/README.md Resolved
uniqueg and others added 2 commits November 1, 2026 01:21
Say that the 55 s cover forwarding and getting the task's state, and
that other work can add to it (Sourcery review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 323e4bd into dev Nov 1, 2026
19 checks passed
@uniqueg
uniqueg deleted the fix/create-budget-registry-log branch November 1, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: bound task creation, log registry tokens

1 participant