Skip to content

feat(FOUR-30668): add API_FAST_TASK fast path for V1.1 task show - #9097

Open
gproly wants to merge 10 commits into
developfrom
feature/FOUR-30668
Open

gproly wants to merge 10 commits into
developfrom
feature/FOUR-30668

Conversation

@gproly

@gproly gproly commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Introduce showFast on GET api/1.1/tasks/{id} when API_FAST_TASK is enabled, keeping the same endpoint and response shape while reducing duplicate work on large request payloads.

  • Strip data from the include list so requestData is not built twice
  • Load task via Eloquent and process request metadata via raw SQL without the data column; hydrate relations with selective columns
  • Add TaskResource::fromTokenWithIncludes() to avoid preprocessInclude re-query
  • Resolve request data from DB when processRequest has no data attribute (showFast path and Nayra empty datastore)
  • Guard includeBpmnTagName when BPMN definition is missing
  • Add TaskShowFastResponseTimeTest (parity + median timing vs legacy includes)

Config: API_FAST_TASK=false by default in config/app.php
Timing: TASK_SHOW_FAST_MAX_RATIO (default 0.53) for the benchmark test

https://processmaker.atlassian.net/browse/FOUR-30668

Run:
./vendor/bin/phpunit tests/Feature/Api/V1_1/TaskShowFastResponseTimeTest.php

Tests:

  • Same request_data as legacy (fast has no data key)
  • Median of 3 runs: legacy (API_FAST_TASK=false) vs fast (true)

Threshold env:
TASK_SHOW_FAST_MAX_RATIO=0.53 default (~47% faster)
TASK_SHOW_FAST_MAX_RATIO=0.40 ~60% faster
TASK_SHOW_FAST_MAX_RATIO=0.30 ~70% faster

Rule: fast_median <= legacy_median * ratio

Improvement % ≈ (1 - fast/legacy) * 100 (same machine/DB each time)

Captura de pantalla 2026-10-09 a la(s) 5 10 39 p  m

ci:deploy

Introduce showFast on GET api/1.1/tasks/{id} when API_FAST_TASK is enabled,
keeping the same endpoint and response shape while reducing duplicate work on
large request payloads.

- Strip `data` from the include list so `requestData` is not built twice
- Load task via Eloquent and process request metadata via raw SQL without
  the `data` column; hydrate relations with selective columns
- Add TaskResource::fromTokenWithIncludes() to avoid preprocessInclude re-query
- Resolve request data from DB when processRequest has no `data` attribute
  (showFast path and Nayra empty datastore)
- Guard includeBpmnTagName when BPMN definition is missing
- Add TaskShowFastResponseTimeTest (parity + median timing vs legacy includes)

Config: API_FAST_TASK=false by default in config/app.php
Timing: TASK_SHOW_FAST_MAX_RATIO (default 0.53) for the benchmark test

https://processmaker.atlassian.net/browse/FOUR-30668
@cursor

cursor Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Feature-flagged but alters how task show loads large process_requests.data and processes include; parity tests exist but wrong hydration could affect case-start screens.

Overview
Adds an optional fast path for GET api/1.1/tasks/{id} when OPTIMIZED_TASKS_START_ENABLED is on, without changing the route or overall response contract for clients that rely on request_data and related includes.

The controller delegates to showFast, which strips data from the include query (so requestData is not built twice), loads the token through TaskV11ShowFastRepository (lean process_requests row without the data column, selective user/process/draft relations), and only loads process_requests.data when requestData is requested. TaskResource::fromTokenWithIncludes() builds the resource from that preloaded token instead of preprocessInclude re-querying.

Also hardens includeBpmnTagName when BPMN definition is missing, and adds TaskShowFastResponseTimeTest for parity with legacy includes plus median response-time regression (tunable via TASK_SHOW_FAST_MAX_RATIO).

Reviewed by Cursor Bugbot for commit de64f20. Bugbot is set up for automated code reviews on this repo. Configure here.

@gproly
gproly requested review from caleeli and pmPaulis October 9, 2026 21:06

@cursor cursor 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.

Stale Bugbot comment from a previous run.

Comment thread ProcessMaker/Http/Resources/V1_1/TaskResource.php
Comment thread ProcessMaker/Managers/DataManager.php Outdated
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://tenant-1.ci-023a748934.engk8s.processmaker.net

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://tenant-1.ci-023a748934.engk8s.processmaker.net

- Load process_requests.data in TaskV11ShowFastRepository when showFast
  includes requestData, instead of extending DataManager.
- Restore DataManager to develop behavior; drop resolveRequestDataFromToken.
- Fix empty include after stripping data (remove query param, trim parts).
- Guard includeBpmnTagName when BPMN definition is missing on fast path.
- Add test for include=data-only on API_FAST_TASK; remove DataManager
  hydration unit test superseded by fast-path parity.

https://processmaker.atlassian.net/browse/FOUR-30668
Re-add tests/Feature/Api/V1_1/ProcessVariableControllerTest.php from develop after
it was removed by mistake. Keeps FOUR-30668 aligned with develop for unrelated
V1.1 process-variables coverage.

https://processmaker.atlassian.net/browse/FOUR-30668
Restore tests/Feature/DataManagerTest.php from develop to drop an unrelated
import-only diff. Fast-path request data coverage remains in
TaskShowFastResponseTimeTest.

https://processmaker.atlassian.net/browse/FOUR-30668

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d1b4ecb. Configure here.

Comment thread ProcessMaker/Repositories/TaskV11ShowFastRepository.php
Comment thread config/app.php Outdated
…owFast

- Rename env/config from API_FAST_TASK / app.api_fast_task to
  OPTIMIZED_TASKS_START_ENABLED / app.optimized_tasks_start_enabled
  (default remains false; V1_1 TaskController::show gates showFast on the new key)
- TaskV11ShowFastRepository: load process requestor with USER_COLUMNS instead
  of a slim REQUESTOR_COLUMNS set so requestor matches legacy TaskResource output
- TaskShowFastResponseTimeTest: use the new config key in all scenarios; document
  OPTIMIZED_TASKS_START_ENABLED in the class docblock; assert requestor.username
  and requestor.status parity between legacy and optimized responses

Note: deployments must set OPTIMIZED_TASKS_START_ENABLED instead of API_FAST_TASK.

https://processmaker.atlassian.net/browse/FOUR-30668
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://tenant-1.ci-023a748934.engk8s.processmaker.net

@pmPaulis

Copy link
Copy Markdown
Contributor

@gproly please check this unit test issue

✘ Show fast is faster than legacy show with large request data
   │
   │ showFast median 21.49ms exceeded legacy median 34.86ms * ratio 0.58 (set TASK_SHOW_FAST_MAX_RATIO to relax)
   │ Failed asserting that 21.487951278686523 is equal to 20.21597385406494 or is less than 20.21597385406494.
   │
   │ /opt/processmaker/tests/Feature/Api/V1_1/TaskShowFastResponseTimeTest.php:168
   │

@pmPaulis
pmPaulis self-requested a review October 16, 2026 23:42
Raise TASK_SHOW_FAST_MAX_RATIO default from 0.58 to 0.62 so the
task_show_fast_timing benchmark stays within threshold on shared CI
runners with limited CPU/IO, while still requiring showFast to beat
legacy median time.

https://processmaker.atlassian.net/browse/FOUR-30668
@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-023a748934.engk8s.processmaker.net

Bump TASK_SHOW_FAST_MAX_RATIO from 0.62 to 0.66 so the benchmark
assertion stays stable on constrained CI runners where median timings
vary while showFast remains faster than legacy.

https://processmaker.atlassian.net/browse/FOUR-30668
@decisions-sonarqube

Copy link
Copy Markdown

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-023a748934.engk8s.processmaker.net

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.

4 participants