Commit graph

170 commits

Author SHA1 Message Date
Andy Scherzinger
9af6fe9500
Merge pull request #61053 from bygadd/fix/taskprocessing-worker-atomic-claim
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Psalm static code analysis / changes (push) Waiting to run
Psalm static code analysis / static-code-analysis (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-security (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-ocp (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-ncu (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-strict (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-summary (push) Blocked by required conditions
fix(taskprocessing): claim tasks atomically so parallel workers don't duplicate
2026-06-17 10:21:33 +02:00
Yoan Bozhilov
df2368896f docs(taskprocessing): document lockTask semantic change
Per review feedback: note in the lockTask docblock that the guard changed from
`status != RUNNING` to `status = SCHEDULED`, and that callers must now treat a
0 return as "the task is no longer claimable" rather than assuming success.

Signed-off-by: Yoan Bozhilov <bygadd@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
2026-06-15 16:37:34 +02:00
Yoan Bozhilov
022531b997 fix(taskprocessing): guard lockTask on scheduled, record started_at, Oracle fallback
Address review feedback (@marcelklehr, Copilot):
- lockTask claims only SCHEDULED tasks (was status != RUNNING) and stamps
  started_at in the same atomic UPDATE, so a finished task cannot be re-claimed
  and the external-provider claim path records started_at as well.
- claimWithBoundedRetry re-reads after lockTask instead of a follow-up UPDATE.
- Oracle joins SQLite on the bounded-retry fallback: Oracle cannot combine a
  row-limiting clause with FOR UPDATE (ORA-02014), which failed the claim tests
  on Oracle CI.
- Reword the worker docblock/comments to "prefer oldest available" (parallel
  SKIP LOCKED does not guarantee a strict global order).
- Add a regression test that lockTask does not resurrect a finished task.

Signed-off-by: Yoan Bozhilov <bygadd@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
2026-06-15 16:37:34 +02:00
Marcel Klehr
66826df860 fix: Address review comments
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2026-06-15 16:37:34 +02:00
Yoan Bozhilov
0799454a1f fix(taskprocessing): claim tasks atomically with SKIP LOCKED + composite index
Replace the worker retry/ignore-list claim-loop with a single atomic
SELECT ... FOR UPDATE SKIP LOCKED claim (SQLite bounded-retry fallback),
preserving the no-duplicate guarantee while removing the thundering-herd
contention that throttled backlog draining. Add a (status,type,last_updated)
index via the table-creating migration + db:add-missing-indices listener.

Signed-off-by: Yoan Bozhilov <bygadd@gmail.com>
Assisted-by: Claude Code:claude-opus-4-8
2026-06-15 16:37:34 +02:00
Marcel Klehr
041013bb58 fix(TaskProcessing): Check $progress value is in (0,1) in setTaskProgress
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2026-06-15 10:02:34 +02:00
Marcel Klehr
573ecd0e81 feat(TaskProcessing): Update completionExpectedAt in Manager#setTaskProgress
Assisted-by: ClaudeCode:claopus-4-7
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2026-06-11 11:10:41 +02:00
Julien Veyssier
76709d7efc
feat(task-streaming): address review comments
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 15:38:10 +02:00
Julien Veyssier
3f4eae2d0b feat(task-streaming): only send notify_push status updates after we actually apply the change in the db
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
c7d8369b5f feat(task-streaming): adjust notify push messages, add sort of a namespace
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
4da89e92dd feat(task-streaming): send a notify_push message whenever a task status changes
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
8ee02812ef feat(task-streaming): rename ISynchronousOptionsProvider to ISynchronousOptionsAwareProvider
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
b04de05805 fix(task-streaming): fix psalm issues, run cs:fix, gen openapi specs
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
207f347afc feat(task-streaming): add new provider interface
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
ddf914231b feat(task-streaming): add preferStreaming boolean attribute to taskprocessing tasks. pass it to ISynchronousProgressiveProvider::process
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
a6e6d92103 feat(task-streaming): do not update the task in DB when setting intermediate result if notify_push is available
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
d65252b8af fix(task-streaming): make the notify_push message shorter
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
e4bea82c86 feat(task-streaming): add an endpoint to set a task intermediate output
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
74d078e6e4 fix(task-streaming): and test sending data via notify_push
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
Julien Veyssier
7870537d01 feat(task-streaming): allow the Php providers to set intermediate results with a callback in process
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2026-06-10 14:52:56 +02:00
El Mehdi Abenhazou
e8c101fac8 fix(TaskProcessing): restrict allowed_classes in Manager cache deserialization
The availableTaskTypes cache stores serialized arrays containing
ShapeDescriptor objects, ShapeEnumValue objects, and EShapeType enum
values. The unserialize() call did not restrict which classes could
be instantiated.

Restrict deserialization to the three known types:
- OCP\TaskProcessing\ShapeDescriptor
- OCP\TaskProcessing\ShapeEnumValue
- OCP\TaskProcessing\EShapeType

This prevents PHP Object Injection if an attacker gains write access
to the distributed cache backend.

Signed-off-by: El Mehdi Abenhazou <mehdiananas007@gmail.com>
2026-06-04 10:49:23 +02:00
XananasX7
d0cce3da70 fix(TaskProcessing): add allowed_classes to unserialize() in Manager cache
The availableTaskTypes cache stores serialized arrays containing
ShapeDescriptor objects, ShapeEnumValue objects, and EShapeType enum
values. The unserialize() call did not restrict which classes could
be instantiated.

Restrict deserialization to the three known types:
- OCP\TaskProcessing\ShapeDescriptor
- OCP\TaskProcessing\ShapeEnumValue
- OCP\TaskProcessing\EShapeType

This prevents PHP Object Injection if an attacker gains write access
to the distributed cache backend (e.g., a Redis instance without
authentication or with weak ACLs), which is a known real-world attack
vector in shared hosting and container environments.
2026-06-04 10:34:12 +02:00
Côme Chilliet
0d90f4272a
chore: Remove types from const properties
Support was added in PHP 8.3 and we need to support 8.2

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2026-06-02 09:46:16 +02:00
Côme Chilliet
b44f6a2957
fix: Remove static vars in TaskProcessing, TextProcessing, TextToImage
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2026-06-02 09:46:16 +02:00
Côme Chilliet
1ab09ec753
chore: Apply new coding standard to all files
The diff can be checked using: git diff --ignore-all-space --ignore-blank-lines
To see only the changes not related to blank lines.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2026-06-01 13:46:39 +02:00
Côme Chilliet
9680004b58
chore: Remove almost all uses of deprecated IServerContainer in lib/private
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2026-05-11 16:22:22 +02:00
Lukas Schaefer
574243fab3
feat(TaskProcessing): add TextToTextReformatParagraphs task type
Signed-off-by: Lukas Schaefer <lukas@lschaefer.xyz>
2026-05-06 09:03:07 -04:00
Ferdinand Thiessen
e0ba4d71b6
chore: add missing Override attribute to OC
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2026-04-28 21:29:27 +02:00
Oleksander Piskun
f573285040 feat(taskprocessing): Add queue_stats API endpoint for external autoscalers
Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
2026-03-30 12:03:19 +00:00
provokateurin
f12cecb684
feat(rector): Enable SafeDeclareStrictTypesRector
Signed-off-by: provokateurin <kate@provokateurin.de>
2026-02-09 10:59:31 +01:00
Carl Schwan
c96ece0bcb
refactor: Add more typing
- repairs job
- database
- redis

And remove Helpertest which was unused outside of some tests.

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
2026-02-06 13:55:39 +01:00
Carl Schwan
7b6078875b
refactor: Run rector on lib/private
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
2026-02-06 13:50:18 +01:00
Marcel Klehr
c13d95809a Fix: Run cs:fix 2026-02-04 13:26:29 +01:00
Marcel Klehr
c48a09f27d fix(TaskProcessing): Refactor TextToImage fallback
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2026-02-04 13:26:29 +01:00
Marcel Klehr
25044f82ae fix(TaskProcessing): Adjust OCR task type to allow for multiple files and pdfs
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-12-09 09:21:33 +01:00
Julien Veyssier
b4f7fe2cb6
feat(taskprocessing): add a boolean 'includeWatermark' to taskprocessing tasks and pass it to ISynchronousWatermarkingProvider::process
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
2025-11-27 11:32:08 +01:00
Marcel Klehr
d04d575ed3
Merge branch 'master' into feat/taskprocessing/user-facing-error-message
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-30 10:13:39 +01:00
Marcel Klehr
3ee6999682 fix: Use substr to cut error messages
This allows for cutting them to longer lengths

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-30 10:07:57 +01:00
Marcel Klehr
7f15598083 fix: address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-20 15:59:25 +02:00
Marcel Klehr
6a1501a7d6 fix: address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-20 15:59:25 +02:00
Marcel Klehr
044e92bf4e feat(TaskProcessing): Introduce ITriggerableProvider
Signed-off-by: Marcel Klehr <mklehr@gmx.net>

# Conflicts:
#	lib/private/TaskProcessing/Db/TaskMapper.php
2025-10-20 15:59:25 +02:00
Marcel Klehr
9df303f876 fix: address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-20 15:54:10 +02:00
Marcel Klehr
3f527661b1 fix: Create new class instead of extending existing class
to make it easier to use this across nextcloud versions

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-15 11:20:00 +02:00
Marcel Klehr
7373f11af6 feat(TaskProcessing): user-facing error messages
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-14 16:53:41 +02:00
Marcel Klehr
be8e168f38 fix: Address psalm issues and review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-14 15:51:31 +02:00
Marcel Klehr
16da8bbc8a fix(TaskProcessingApiController): Implement getNextScheduledTasks for next_batch endpoint
in order to avoid hitting the DB with multiple 1 row requests

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-14 11:50:29 +02:00
Marcel Klehr
ea8ab8e192
Merge pull request #55646 from nextcloud/feat/taskprocessing/is-internal
enh(TaskProcessing): Introduce internal task types
2025-10-14 08:25:00 +02:00
Marcel Klehr
13eb2d1cbd feat(TaskProcessing): Introduce internal task types
which are not shown in the assistant UI

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-13 11:07:40 +02:00
Marcel Klehr
a6f899f925 fix(TaskProcessing): Increase MAX_TASK_AGE to 6 months
to comply with the EU AI act

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-10-06 16:44:53 +02:00
Marcel Klehr
fe54914ef9 fix(TaskProcessing): Cache task types by
user language

fixes https://github.com/nextcloud/assistant/issues/357

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2025-09-17 14:16:01 +02:00