Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Service/SearchBounds.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {

Expand All @@ -53,7 +53,7 @@ final class SearchBounds {
*
* @return array<string, mixed> 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) {
Expand Down
3 changes: 3 additions & 0 deletions lib/Service/TechnologyComponentEolStamper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<array<string, mixed>>
*
* @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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`. 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

Expand Down
36 changes: 36 additions & 0 deletions openspec/specs/query-performance/spec.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tests/Unit/Service/QueryLimitBoundingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. <info@conduction.nl>
* SPDX-License-Identifier: EUPL-1.2
Expand Down Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Service/SearchBoundsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
* 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);
Expand Down
Loading