Repository navigation
refactor(architecture): ObjectServiceInterface and its receiving chain take the published values (X00 c) - #10985
Merged
Merged
Conversation
…n take the published values The published ObjectServiceInterface now names the value classes in lib/Contract instead of the deprecated Kernel\Contracts\Value names, so a consuming app needs nothing beyond the published contract. ObjectService's public signatures take the same published parents, and every parameter phpstan found receiving one of them is widened to it: saveBulkWithinScope() and patchWithinScope() in ObjectService, the lock and unlock path in LockHandler and AdvisoryLockStore. The old names extend the published ones, so every existing caller keeps working; construction sites and return types keep the old names. Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
…uilding the deprecated values A generated mock of ObjectServiceInterface fills an omitted argument with the interface's own default. Built under the published name, that default reached fleet test callbacks typed with the old Kernel\Contracts\Value names as a Contract\ObjectSaveOptions and failed with a TypeError (shillinq AccrualBookingTest, run against the new contract). saveObject() and saveObjects() now default to the deprecated subclasses, so an omitted argument passes exactly the value it passed before; the parameter types stay the published classes. A test pins both the defaults and the mock behaviour. Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
…#10985 Assisted-by: ClaudeCode:claude-opus-5-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Package X00, PR c of 3: the published interface and its receiving chain name the published values
Wave 5, round 1, task 7.2. Stacked on #10977 (PR b), which is stacked on #10976 (PR a). This branch contains their commits plus two merges of
main. Review only this PR's own commits:e1fd7634and8364371a. Land #10976 and #10977 first. PR a and b are unchanged: re-checked, nothing in them is wrong (see "PR b's nested defaults" below).What changed (7 files)
lib/Contract/ObjectServiceInterface.phpdrops its eightuse OCA\OpenRegister\Kernel\Contracts\Value\...imports. Every class its signatures name now resolves insideOCA\OpenRegister\Contract(ObjectSaveOptions,BulkSaveOptions,ObjectFindOptions,ObjectDeletion,ObjectPatch,LockRequest,UnlockRequest,ObjectValidationVerdict). For parameters that is a widening, because the old names are subclasses.validateObject()'s published return type is the parent; the implementation keeps returning the old subclass, which satisfies both.saveObject(... $options = new \OCA\OpenRegister\Kernel\Contracts\Value\ObjectSaveOptions()), and the same forsaveObjects()withBulkSaveOptions. Why: a generated mock (createMock(ObjectServiceInterface::class)) fills an omitted argument with the interface's default. Built under the published name, that default reached fleet callbacks typed with the old name as aContract\ObjectSaveOptionsand threw aTypeError(found by the fleet run: shillinqAccrualBookingTest, 4 failures). With the old-name defaults, every omitted argument and every mock passes exactly the value it passed before. They move to the published names with the fleet in task 7.3. The docblock says so.lib/Service/ObjectService.php: the public signatures ofsaveObject,find,findSilent,deleteObject,saveObjects,lockObject,unlockObjectandpatchObjecttake the published parents (imported asPublished<Name>; construction sites and defaults keep the old names). It must, orObjectServicewould be narrower than the interface it implements.vendor/bin/phpstan analyse libwas re-run until it reported noContract\X given/expects Kernel\...\Xpair. That took five rounds. Exactly these parameters were widened to the published type, and only these:ObjectService::saveBulkWithinScope(),ObjectService::patchWithinScope();LockHandler::lock(),unlock(),logRequest(),acquire(),acquireAdvisory(),lockLogged(),lockResolved(),lockStoredObject(),logLocked(),unlockLogged(),unlockResolved(),assertMayUnlock(),releaseStoredLock();AdvisoryLockStore::acquire(),payload(),logAcquired().find/findSilent/saveObject/deleteObjectneeded nothing further: their options are only read. Noinstanceofon the old names exists inlib/.ObjectOperationsInterface(Kernel, internal) keeps the old names;ObjectServicesatisfies it contravariantly.final class X extends \OCA\OpenRegister\Contract\X {}with@deprecated, from refactor(architecture): publish the five values the object values name in lib/Contract (X00 a) #10976 and refactor(architecture): publish the eight values ObjectServiceInterface names in lib/Contract (X00 b) #10977. There is noclass_alias(the onlyclass_aliasinlib/is the pre-existingAppInfo/ClassAliasMap).tests/Unit/Contract/PublishedSignaturesTest.php. It checks five things. (1) Every openregister class the contract's signatures name lives inOCA\OpenRegister\Contract. (2) The contract andObjectServicetake each published value. (3) The old names still fit. (4) The defaults are the old names, and a mock passes the old name to a callback typed with it. (5) The lock chain takes the published values, and a lock built only from published classes is taken and released through the realLockHandlerandAdvisoryLockStore; both names take the same lock.ObjectServiceUpdateVersusPatchTest: the signature assertion now expects the publishedObjectPatch, on the contract and on the implementation. It addstestAPatchBuiltUnderThePublishedNameMergesTheSame, which sends the patch through the realpatchObject()→patchWithinScope()path.ValidationHandlerBySchemaGoldenTest: the closure that mirrorsObjectService::saveObject()'s signature follows it.Exposed lines per area (
measure()['exposed_loc'])b85c154e(a + b + c against main.) Expected by the package: about +65 Kernel for the 13 stubs. Measured −9 Kernel, because the moved code is named mostly from Kernel itself, plus +5 Core for the
Published*imports inObjectService.References against the order
38 on main
b85c154e, 38 on this branch.Newly exposed files / new Kernel files
modularity_check.py --checkreports onlylib/Contract/files, nothing else:lib/Contract/{BulkBatchDefaults,BulkSaveOptions,LockRequest,LockRunStep,ObjectDeletion,ObjectFindOptions,ObjectFindTarget,ObjectPatch,ObjectSaveOptions,ObjectValidationVerdict,SaveActor,SavePolicy,UnlockRequest}.php, the published contract decided in task 7.2.lib/Contract/{BulkSaveOptions,LockRequest,ObjectDeletion,ObjectFindOptions,ObjectFindTarget,ObjectPatch,ObjectSaveOptions,UnlockRequest}.php, named byObjectService,LockHandlerandAdvisoryLockStore(Core) on the widened parameters. They are values on the published contract's signatures.Gate 67 and the ConductionNL/.github companion PR — NOT OPENED, needs a hand
Gate 67 on main today: FAIL. Checked with
.github@main'scheck_openregister_contract_parity.pyagainst main'slib/Contract:ObjectFileReaderInterface.phpis not shipped, andObjectServiceInterface.phpdiffers.I prepared the companion change: branch
cloud/mod-X00-published-contract-valuesfrom.githubmainb1db70f. With it, gate 67 passes:checked 19 file(s), all byte-identical.test_shipped_contracts_documented.pypasses (4 tests) andtest_gate67_contract_parity_scope.shpasses ("all cases behaved"). I could not push it. This session cannot attach a repository whose name starts with a dot: git push gets 403, and the API refuses the repository. To open it:ObjectFileReaderInterface.phpis included on purpose (it is inlib/Contract/on main and missing there), byte-identical. The README change (the test requires every shipped file in the table, the bootstrap guard and the Psalm stubs):hydra-gates/README.md diff
This PR is not mergeable before that .github PR.
Fleet check (package section "Fleet check")
All 19 apps from
tools/sig/fleet_checkout.shwere checked out in full (tests included) fromdevelopment: opencatalogi, integriq, filinq, thematiq, launchpad, stackiq, larpinq, dossiq, pipelinq, shillinq, learniq, portaliq, decidiq, buildiq, keepiq, hermiq, humaniq, versioniq, planninq.implements ObjectServiceInterface. In a run against the new openregister, a test class that extendsOCA\OpenRegister\Service\ObjectServiceand overrides one of the eight methods with an old-typed parameter is narrower than the widenedObjectServiceand fatals. I parsed every PHP class (named and anonymous) and built the inheritance closure fromObjectServiceInterfaceandObjectService. Overrides with a Kernel-typed value parameter exist in 7 apps (166 parameters in 78 files). The other 12 have none: dossiq's and planninq's in-memory registers are duck-typed and implement nothing; the stub interface copies in buildiq, decidiq, dossiq, hermiq, integriq, learniq and portaliq are only loaded when the real interface is absent.OldName|PublishedOldName. PHP matches a union member by name without loading the other class, so the doubles load against both today's openregister and this one. Checked first in an isolated PHP script; the old-typed double fatals.developmenttip, PHP 8.3. (1) Unchanged. (2) The branch. (3) The branch against the new contract: this PR'slib/Contractand the deprecated Kernel values preloaded through an iniauto_prepend_file, and the app'sObjectServicestub temporarily typed like thisObjectService. Unchangeddevelopmentagainst the new contract fatals at class load in all 7; with the fix, each run matches its unchangeddevelopmentrun:developmentThe app PRs are safe against the current openregister and must land before this PR.
python3 tools/sig/fleet_surface.py <dir> --check: output byte-identical on main, on PR b and on this branch. It is already red on main, because the fleet drifted since the baseline (683 "new reference" lines, 11 gone); this package changes no app'slib/.What ran
php -lon the 4 changed lib files: clean.vendor/bin/phpcson them: the only error is a 158-character line atObjectService.php:3643, which is not this change; 6 pre-existing@specwarnings.vendor/bin/phpstan analyse --no-progress lib, compared with the same run onorigin/mainafter merging: identical lists (54 on both). Before the merge: 38 on both, with the 4 + 3 + 4 + 3 + 1 receiving-chain findings fixed round by round.vendor/bin/psalm --no-cacheon the changed lib files: no errors.python3 tools/sig/modularity_check.py --check: only the deliberatelib/Contract/files above; no new reference against the order.tools/sig/deptrac.sh areas --check: no new violating pair (only "gone" entries).vendor/bin/phpunit -c phpunit.xml --no-coverage tests/Unit/Architecture: OK (2371 tests), after the last merge.tests/Unit/Contract, theLockHandler*/AdvisoryLockStore*tests,ObjectServiceUpdateVersusPatchTestandValidationHandlerBySchemaGoldenTest: OK (214 tests), after the last merge.*Test.phpthat namesLockHandler,AdvisoryLockStore,ObjectServiceInterface,Service\ObjectServiceor one of the eight old names (660 files): 9,288 tests. The only failures are 4 errors inAnonymousEnvelopeReadPathsTest, identical on PR b without this change, plus the one golden test updated here.tests/Unitonce, in 16 chunks, ate1fd7634before the defaults commit: 61,019 tests outside Architecture. The only failures are the knownAnonymousEnvelopeReadPathsTest(4) andReservedColumnNamesTest(5). The latter downloads MariaDB'slex.hfrom raw.githubusercontent.com, which answered 404 here.Order
Written with Claude Code (claude-opus-5-5)