Skip to content

[access] refactor(log): split LogService export/lookup and bundle relation-cleanup link services - #6693

Merged
rubenvdlinde merged 3 commits into
mainfrom
cloud/a20-access-log-cleanup
Nov 9, 2026
Merged

rubenvdlinde merged 3 commits into
mainfrom
cloud/a20-access-log-cleanup

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

What changed

Maintainability-only refactor of two access-relevant services in lib/Service (lane A20). No behaviour change: nothing that was allowed or refused before changes.

  • LogService: the export row shaping and the csv/json/xml/txt rendering move to a new LogExportFormatter. The in-table half of the object-history lookup (with the live-holder fallback for a shared slug) moves to a new LogObjectInTable. Both are built inside the constructor, the same way ExplicitRevealTrailMasker already is, so the constructor and DI stay as they were.
    • Explicit-reveal masking still runs in LogService before any row is shaped.
    • The register/schema scope is still resolved before the history query runs.
    • Every lookup still passes _rbac: false, _multitenancy: false, exactly as before.
    • LogExportFormatter has no strict_types, so values are coerced the same way they were in LogService and exported files stay byte-identical.
  • ObjectRelationCleanupService: the four link services (email, calendar event, contact, deck card) are bundled into the final class ObjectRelationCleanupLinks. The constructor goes from 7 parameters to 4, and the container autowires the bundle. The task-deletion and timeline-count loops are split into small units. Log messages are unchanged.
  • Only test construction sites changed: ObjectRelationCleanupServiceTest::setUp and the golden test's build().

Golden tests (committed first, green on the old code)

  • tests/Unit/Service/LogServiceAccessGoldenTest.php pins both sides of the history lookup:

    • Allowed: an object in scope; a shared slug resolving to its single live holder; the cross-table fallback when the register or schema is gone.
    • Refused: an object out of scope, rejected before any history read; a slug held only by deleted objects or by two live objects (the original exception is rethrown); any other failure resolving the scope propagates without a fallback.
    • Export: exact export content in every format (md5 and length; the timestamp is ignored), masking of an unreadable schema's changes, the column order and the unsupported-format error.
  • tests/Unit/Service/ObjectRelationCleanupServiceGoldenTest.php pins what gets destroyed and what stays:

    • cleanup() destroys all six relation kinds, in order.
    • destroyTimelineLinks() leaves notes and tasks alone.
    • Each failure is contained and logged.
    • countTimelineLinks() counts nothing for a failing source.
    • Constructors are autowirable: no scalar or untyped parameters.
  • Mutation checks:

    • Making findObjectInScope fall back to a cross-table lookup instead of rethrowing the ambiguity fails testSlugHeldOnlyByDeletedObjectsIsRefusedAsAmbiguous.
    • Dropping the task cleanup from cleanup() fails 3 golden tests.

    Both mutations were reverted.

What ran

  • php -l on all touched files: clean.
  • phpcs (phpcs.xml) on the touched lib files: 0 errors. The only warnings are 2 missing @spec tags in LogService, on its class and getLog(); that docblock was not changed here.
  • phpstan analyse on the touched lib files: no errors.
  • phpunit by path, all OK:
    • the two golden tests;
    • LogServiceTest, Rbac/ExplicitRevealAuditTrailTest, BackgroundJob/AuditTrailExportJobTest;
    • Controller/AuditTrailControllerTest (one skip, which was already there);
    • AuditTrailObjectHistoryForReadersTest, InstanceWideAuditReadsTest, ReadableAuditTrailHttpPagingTest;
    • ObjectRelationCleanupServiceTest, Deletion/DestructionScopeServiceTest, BackgroundJob/ObjectCleanupJobTest;
    • Listener/ObjectCleanupListener(Golden)Test, ProcessingLogServiceTest, Db/SchemaAnnotationVocabularyTest;
    • tests/Unit/Contract, Architecture, Kernel, Service/Interaction and Controller/ControllerServicesWiringTest: 832 tests OK.
  • Frontend: not touched.

Metrics (SIG five-star profile, hydra-gates check_sig_maintainability.py)

before after
LogService units > 15 lines 5 0
LogService units McCabe > 5 1 0
LogService duplicated lines 6 0
ObjectRelationCleanupService units > 15 lines 2 0
ObjectRelationCleanupService units with ≥ 7 params 1 0
New collaborators: units > 15 / McCabe > 5 / duplicated lines — 0 / 0 / 0

Lane A20 area (lib/Service G–O top level), lines in units > 15: 1860 → 1701. Lines in units McCabe > 5: 500 → 464. The lane's overall baseline is 2.92–3.07; the after rating is measured by the lane on the combined result.

AI disclosure

Prepared by Claude Code (AI-assisted); reviewed by a human before merge.


Generated by Claude Code

Golden tests on the current code: which object a history request resolves
to or refuses, the unfiltered lookups it makes, export content per format
with explicit-reveal masking, and which relations cleanup destroys or
leaves standing, with its exact log lines.

Assisted-by: ClaudeCode:claude-opus-5-5
…borators

LogExportFormatter shapes and renders the export rows; LogObjectInTable
holds the in-table half of the history lookup (live-holder fallback for
a shared slug). Masking still runs in LogService before any row is shaped;
every lookup keeps _rbac/_multitenancy false; refusals are unchanged.
ObjectRelationCleanupService takes its four link services as one
ObjectRelationCleanupLinks bundle (7 -> 4 constructor parameters) and its
task and count loops are split into units of at most 15 lines.

Assisted-by: ClaudeCode:claude-opus-5-5

Copy link
Copy Markdown
Contributor Author

Newman API Test Suite is red, but not because of this PR.

The job's PHPUnit step reports Errors: 11, Failures: 7. The same 18 tests fail on development: run 42420556955 at c15c3f9, and the base this branch started from, 7b3d6af. The failing tests are:

  • JobRunMapperNarrowGoldenTest (5 errors)
  • FileVersioningHandlerGoldenTest (6 errors)
  • TextExtractionJobsGoldenTest
  • EndpointsControllerAnswersGoldenTest (5 data sets)
  • SchemaConfigValidatorsGoldenTest

None of them touch LogService, ObjectRelationCleanupService or the new collaborator classes. This PR's own golden tests and the existing LogService and ObjectRelationCleanupService tests pass. No fix for the base-branch failures exists yet, so there is nothing to port into this PR. I'm not widening this PR to fix unrelated tests.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

quality / Frontend Tests (unit) is red, but not because of this PR.

This PR changes no frontend files; its diff is only lib/Service/* and tests/Unit/Service/*.

4 tests fail across 2 snapshot specs:

  • src/components/object-relations/relationTabs.dom.golden.spec.js
  • src/modals/shared.confirmDialogs.dom.golden.spec.js

Both snapshots format a date in the runner's local timezone. They expect 1/1/2026, 1:00:00 AM (UTC+1) and get 12:00:00 AM (UTC) on the CI runner. These tests depend on the timezone; this PR doesn't affect them.

The fix belongs in those specs, by pinning the timezone or the formatter, and isn't in scope for this PR. I know of no existing fix to port in.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Four more quality checks are red, all outside this PR's diff.

This PR touches only lib/Service/{LogService,LogExportFormatter,LogObjectInTable,ObjectRelationCleanupLinks,ObjectRelationCleanupService}.php and three tests/Unit/Service/* files. None of those files appears in any finding below.

  • PHP Quality (phpcs): the errors are in lib/Db/MagicMapper/MagicObjectSearchInterface.php and lib/Controller/FlowTimerDiagnosticController.php.
  • PHP Quality (phpstan): 15 findings, none in this PR's files. Examples are NoteServiceInterface::requireNoteOf() and TextExtractionServiceInterface::extractFile() being undefined, an unused GraphQLService::internalError(), and several dead catches.
  • Vue Quality (eslint): unused imports, import order and ellipsis rules in src/. This PR changes no frontend files.
  • Frontend Check (test:l10n:parity): two English strings are missing translations in the backend catalogues, "We could not count the objects. Close this window and try again." and "Some objects could not be copied.". This PR adds no strings.

These failures come from the current development head, not from this change. I know of no fix on development to port in, so I've made no change here.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Addendum: three more quality checks are red, also outside this PR's diff.

  • PHP Quality (psalm): every finding is in a file this PR doesn't touch, for example lib/Db/EndpointMapper.php, lib/Db/WebhookMapper.php, lib/Db/Schema/AuthorizationRulesValidator.php, lib/Service/Audit/PurposeGuard.php and lib/Files/Service/TextExtraction/PresentationRead.php. None is in LogService, LogExportFormatter, LogObjectInTable or the ObjectRelationCleanup* files.
  • Frontend Check (format): this PR changes no frontend files.
  • Frontend Check (test:l10n): the repo's own notes record this gate as already red on development, with keys used in src/ but missing from en.js. This PR adds no strings.

As above, I know of no fix to port in, so I've made no change.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Addendum: quality / Hydra Gates is red, but not because of this PR.

Five gates fail on the whole repository:

  • gate-3 stub-scan: 1 finding
  • gate-7 no-admin-idor: 78 controller methods
  • gate-17 redundant-controller: 1 method
  • gate-46 spec-anchor-existence: 2 findings
  • gate-49 controller-exception-translation: 6 controller methods

Gates 7, 17 and 49 are about controllers, and this PR changes no controller.

For gates 3 and 46, I ran the hydra-gates checkers check_spec_anchors.py and check_stub_run_body.py on exactly this PR's changed files at its head. Both exit 0. The three @spec targets this PR adds (audit-trail-immutable, object-lifecycle, deletion-audit-trail) all resolve to existing spec headings. The repo-wide findings are therefore in files outside this diff.

I've made no change here.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Addendum: quality / PHP Quality (phpmd) is red, but not because of this PR. None of its findings is in this PR's files (LogService, LogExportFormatter, LogObjectInTable, ObjectRelationCleanupLinks, ObjectRelationCleanupService). They are in other files, for example ConfigurationCheckJob, CalendarEventsController, TasksController and MagicCrossTableReaderInterface. I have made no change.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Addendum: quality / Integration Tests (Newman) has 3 failed assertions out of more than 1,000. I traced each one, and none goes through this PR's code.

  1. 18b. Restore Deleted Object (openregister-crud): POST /api/deleted/{uuid}/restore returned 412, and the test accepts only 200 or 500. No OpenRegister code returns 412. Nextcloud's framework returns it when a POST fails its CSRF check, so this is about how the request authenticates. The restore path (DeletedController / DeletedStore) does not use LogService or ObjectRelationCleanupService.
  2. contact destruction date follows the client (openregister-dates-follow): retention-date propagation. This PR doesn't touch it.
  3. notify-on-change: no step failed: notification flow. This PR doesn't touch it.

This PR changes only the log export and lookup helpers and how relation-cleanup dependencies are bundled. Its golden tests pin both behaviours byte for byte.

I couldn't compare against development, because no other branch has a finished run of this job yet. I tried to re-run the job, but GitHub refused while the workflow run is still in progress. I've made no change here.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Addendum: quality / PHPUnit (PHP 8.3, NC stable35, pgsql) is red with 6 errors and 1 failure. Both are already red on development.

  • 6 errors in FileVersioningHandlerGoldenTest: Cannot declare interface OCA\Files_Versions\Versions\IVersionManager because the name is already in use. The test's eval'd stub collides with the real class when the server's files_versions app is loaded.
  • 1 failure in SchemaConfigValidatorsGoldenTest: the golden list of valid linked types is stale against the current list.

Both tests fail the same way on development, in the run cited in my first comment above. None of this PR's tests fail: LogServiceAccessGoldenTest, LogServiceTest, ObjectRelationCleanupServiceGoldenTest and ObjectRelationCleanupServiceTest all pass. I've made no change here.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ de3bc7c

Check PHP Vue Security License Tests
lint ✅
phpcs ❌
phpmd ❌
psalm ❌
phpstan ❌
phpmetrics ✅
eslint ❌
stylelint ✅
build ✅
check-specs ✅
test-l10n ❌
test-l10n-parity ❌
format ❌
check-schema-l10n ✅
composer ✅ ✅ 168/168
npm ✅ ✅ 641/641
app:check-code ⏭️
info.xml ✅
REUSE ✅
lockfile sync ✅
PHPUnit ❌ 40915/40922 · 19 skipped
Newman ❌ 1625/1628
Playwright ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it locally with npx playwright test, or from the Actions tab on a branch with no open pull request into development.
Hydra gates ❌

Quality workflow — 2026-11-08 11:25 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde changed the base branch from development to main November 9, 2026 06:57
ObjectRelationCleanupService keeps this branch's link bundle and takes main's
ObjectCalendarTasksInterface type for the task service.

Assisted-by: ClaudeCode:claude-opus-5-5
@rubenvdlinde
rubenvdlinde merged commit 3fec69f into main Nov 9, 2026
13 of 14 checks passed
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.

2 participants