From 46bdcbb37df3a3e40546039411f640d60ac2a456 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Sat, 21 Nov 2026 21:16:31 +0000 Subject: [PATCH 1/2] chore(openspec): archive bound-unbounded-searchobjects-scans with its spec synced Task 5.3 is met: Psalm reports no finding on a line this change wrote, and PHPCS, PHPMD and PHPStan were already clean on the touched files. The one requirement goes to openspec/specs/query-performance, and the @spec tags point at the synced spec. Assisted-by: ClaudeCode:claude-opus-5-5 --- lib/Service/SearchBounds.php | 6 ++-- .../.openspec.yaml | 0 .../proposal.md | 0 .../screens.md | 0 .../specs/query-performance/spec.md | 0 .../tasks.md | 3 +- openspec/specs/query-performance/spec.md | 36 +++++++++++++++++++ tests/Unit/Service/QueryLimitBoundingTest.php | 4 +-- tests/Unit/Service/SearchBoundsTest.php | 2 +- 9 files changed, 44 insertions(+), 7 deletions(-) rename openspec/changes/{bound-unbounded-searchobjects-scans => archive/2026-11-21-bound-unbounded-searchobjects-scans}/.openspec.yaml (100%) rename openspec/changes/{bound-unbounded-searchobjects-scans => archive/2026-11-21-bound-unbounded-searchobjects-scans}/proposal.md (100%) rename openspec/changes/{bound-unbounded-searchobjects-scans => archive/2026-11-21-bound-unbounded-searchobjects-scans}/screens.md (100%) rename openspec/changes/{bound-unbounded-searchobjects-scans => archive/2026-11-21-bound-unbounded-searchobjects-scans}/specs/query-performance/spec.md (100%) rename openspec/changes/{bound-unbounded-searchobjects-scans => archive/2026-11-21-bound-unbounded-searchobjects-scans}/tasks.md (91%) create mode 100644 openspec/specs/query-performance/spec.md diff --git a/lib/Service/SearchBounds.php b/lib/Service/SearchBounds.php index fb1f674be..f554f1b19 100644 --- a/lib/Service/SearchBounds.php +++ b/lib/Service/SearchBounds.php @@ -25,7 +25,7 @@ * * @link https://conduction.nl * - * @spec openspec/changes/bound-unbounded-searchobjects-scans/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit + * @spec openspec/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit */ declare(strict_types=1); @@ -35,7 +35,7 @@ /** * The explicit ceiling on an otherwise unbounded object search. * - * @spec openspec/changes/bound-unbounded-searchobjects-scans/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit + * @spec openspec/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit */ final class SearchBounds { @@ -53,7 +53,7 @@ final class SearchBounds { * * @return array The bounded query. * - * @spec openspec/changes/bound-unbounded-searchobjects-scans/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit + * @spec openspec/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit */ public static function bounded(array $query): array { if (isset($query['_limit']) === false) { diff --git a/openspec/changes/bound-unbounded-searchobjects-scans/.openspec.yaml b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/.openspec.yaml similarity index 100% rename from openspec/changes/bound-unbounded-searchobjects-scans/.openspec.yaml rename to openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/.openspec.yaml diff --git a/openspec/changes/bound-unbounded-searchobjects-scans/proposal.md b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/proposal.md similarity index 100% rename from openspec/changes/bound-unbounded-searchobjects-scans/proposal.md rename to openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/proposal.md diff --git a/openspec/changes/bound-unbounded-searchobjects-scans/screens.md b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/screens.md similarity index 100% rename from openspec/changes/bound-unbounded-searchobjects-scans/screens.md rename to openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/screens.md diff --git a/openspec/changes/bound-unbounded-searchobjects-scans/specs/query-performance/spec.md b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/specs/query-performance/spec.md similarity index 100% rename from openspec/changes/bound-unbounded-searchobjects-scans/specs/query-performance/spec.md rename to openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/specs/query-performance/spec.md diff --git a/openspec/changes/bound-unbounded-searchobjects-scans/tasks.md b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md similarity index 91% rename from openspec/changes/bound-unbounded-searchobjects-scans/tasks.md rename to openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md index a95d27f6b..7ec058720 100644 --- a/openspec/changes/bound-unbounded-searchobjects-scans/tasks.md +++ b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md @@ -55,9 +55,10 @@ proposal was missed (re-run the `_limit`-proximity grep from the proposal and confirm 0 remaining unbounded call sites among the ones enumerated). -- [ ] 5.3 Run `composer check:strict` (PHPCS/PHPMD/Psalm/PHPStan) — no new +- [x] 5.3 Run `composer check:strict` (PHPCS/PHPMD/Psalm/PHPStan) — no new violations. - 17 Nov 2026: the build added a PHPMD `StaticAccess` on every `SearchBounds::bounded()` call; each of those methods now carries the repository's reasoned `@SuppressWarnings(PHPMD.StaticAccess)`, so PHPMD reports none for `SearchBounds`. PHPCS (no new findings) and PHPStan (no errors) are clean on the touched files. Left: Psalm, which needs PHP >= 8.3.16 and the build container runs 8.3.6. + - 21 Nov 2026: Psalm 7.6 ran on development (its own PHP patch-version check skipped locally; vendor is not committed). It reports 736 findings, all from before this change: `git blame` puts none of them on a line written by this change's commits (`ba019ecee`, `cd2856b20`, `903d38ebb`), and none are in `lib/Service/SearchBounds.php`. No new violations. ## Build notes diff --git a/openspec/specs/query-performance/spec.md b/openspec/specs/query-performance/spec.md new file mode 100644 index 000000000..e970efc87 --- /dev/null +++ b/openspec/specs/query-performance/spec.md @@ -0,0 +1,36 @@ +# query-performance Specification + +## Purpose + +How stackiq keeps its OpenRegister reads bounded, so that no request, event listener or background job loads a whole register table into memory. Synced from the change bound-unbounded-searchobjects-scans. + +## Requirements + +### Requirement: Every `searchObjects()` call MUST set an explicit `_limit` +Every call to `OCA\OpenRegister\Service\ObjectService::searchObjects()` from stackiq's `lib/` MUST pass an explicit `_limit` key in its query array. +Omitting `_limit` causes `MagicSearchHandler::searchObjects()` to +call `setMaxResults(null)`, which removes the LIMIT clause entirely and +fetches every row in the target register/schema table into PHP memory. + +#### Scenario: A view-index query is bounded +- GIVEN `ViewService` builds a query for "all view objects" to populate + the ArchiMate view index +- WHEN the query array is constructed +- THEN it MUST include an explicit `_limit` value +- AND the value MUST NOT be silently omitted or left to default + +#### Scenario: A user-profile event listener does not scan the whole register +- GIVEN a Nextcloud user profile update event fires for one user +- WHEN `UserProfileUpdatedEventListener` looks up that user's contact-person + record +- THEN the query MUST filter directly on the updated user's identifier +- AND MUST NOT rely on an unbounded full-table scan to find the match + +#### Scenario: A sync tick that must cover every object pages instead of scanning unbounded +- GIVEN `OrganizationSyncService` must process every organisation or + contact-person object during a sync tick +- WHEN more objects exist than fit in one bounded page +- THEN the service MUST page through results via `searchObjectsPaginated()` + (or an explicit, documented `_limit` ceiling) +- AND MUST NOT issue a single unbounded `searchObjects()` call to cover + the whole table diff --git a/tests/Unit/Service/QueryLimitBoundingTest.php b/tests/Unit/Service/QueryLimitBoundingTest.php index 5bc532b3f..5cee8c62c 100644 --- a/tests/Unit/Service/QueryLimitBoundingTest.php +++ b/tests/Unit/Service/QueryLimitBoundingTest.php @@ -19,7 +19,7 @@ * @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 * @link https://github.com/ConductionNL/stackiq * - * @spec openspec/changes/bound-unbounded-searchobjects-scans/tasks.md#task-5-1 + * @spec openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md#task-5-1 * * SPDX-FileCopyrightText: 2026 Conduction B.V. * SPDX-License-Identifier: EUPL-1.2 @@ -53,7 +53,7 @@ /** * Regression backstop for the unbounded-`searchObjects()` fix. * - * @spec openspec/changes/bound-unbounded-searchobjects-scans/tasks.md#task-5-1 + * @spec openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md#task-5-1 */ class QueryLimitBoundingTest extends TestCase { diff --git a/tests/Unit/Service/SearchBoundsTest.php b/tests/Unit/Service/SearchBoundsTest.php index 954977a77..469c66352 100644 --- a/tests/Unit/Service/SearchBoundsTest.php +++ b/tests/Unit/Service/SearchBoundsTest.php @@ -6,7 +6,7 @@ * SPDX-FileCopyrightText: 2026 Conduction B.V. * SPDX-License-Identifier: EUPL-1.2 * - * @spec openspec/changes/bound-unbounded-searchobjects-scans/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit + * @spec openspec/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit */ declare(strict_types=1); From f787e3aba5c8a97d1c21148fd59a3aa6f192a788 Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Sat, 21 Nov 2026 21:20:54 +0000 Subject: [PATCH 2/2] fix(query-performance): suppress the last StaticAccess on SearchBounds TechnologyComponentEolStamper::components() was the one call site of SearchBounds::bounded() without the reasoned PHPMD suppression the other call sites carry, so PHPMD still reported it. Assisted-by: ClaudeCode:claude-opus-5-5 --- lib/Service/TechnologyComponentEolStamper.php | 3 +++ .../2026-11-21-bound-unbounded-searchobjects-scans/tasks.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Service/TechnologyComponentEolStamper.php b/lib/Service/TechnologyComponentEolStamper.php index b9908edb4..91087cdd3 100644 --- a/lib/Service/TechnologyComponentEolStamper.php +++ b/lib/Service/TechnologyComponentEolStamper.php @@ -126,6 +126,9 @@ private static function stampOf(array $stampedVersion): array { * @param array $query The search: `@self` register and schema, `software` the version, `_limit`. * * @return list> + * + * @spec openspec/specs/query-performance/spec.md#requirement-every-searchobjects-call-must-set-an-explicit-_limit + * @SuppressWarnings(PHPMD.StaticAccess) SearchBounds::bounded() is the pure query guard every search in lib/ shares. */ private function components(ObjectServiceInterface $objectService, array $query): array { try { diff --git a/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md index 7ec058720..3ac2163f0 100644 --- a/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md +++ b/openspec/changes/archive/2026-11-21-bound-unbounded-searchobjects-scans/tasks.md @@ -58,7 +58,7 @@ - [x] 5.3 Run `composer check:strict` (PHPCS/PHPMD/Psalm/PHPStan) — no new violations. - 17 Nov 2026: the build added a PHPMD `StaticAccess` on every `SearchBounds::bounded()` call; each of those methods now carries the repository's reasoned `@SuppressWarnings(PHPMD.StaticAccess)`, so PHPMD reports none for `SearchBounds`. PHPCS (no new findings) and PHPStan (no errors) are clean on the touched files. Left: Psalm, which needs PHP >= 8.3.16 and the build container runs 8.3.6. - - 21 Nov 2026: Psalm 7.6 ran on development (its own PHP patch-version check skipped locally; vendor is not committed). It reports 736 findings, all from before this change: `git blame` puts none of them on a line written by this change's commits (`ba019ecee`, `cd2856b20`, `903d38ebb`), and none are in `lib/Service/SearchBounds.php`. No new violations. + - 21 Nov 2026: Psalm 7.6 ran on development (its own PHP patch-version check skipped locally; vendor is not committed). It reports 736 findings, all from before this change: `git blame` puts none of them on a line written by this change's commits (`ba019ecee`, `cd2856b20`, `903d38ebb`), and none are in `lib/Service/SearchBounds.php`. PHPMD still reported one `StaticAccess` on `SearchBounds::bounded()`, in `TechnologyComponentEolStamper::components()`; that method now carries the same reasoned suppression as the other call sites. No new violations. ## Build notes