Skip to content

[stable34] fix(autoload): load rubix free functions despite Composer files dedupe - #1129

Merged
ChristophWurst merged 2 commits into
stable34from
backport/1118/stable34
Jul 15, 2026
Merged

[stable34] fix(autoload): load rubix free functions despite Composer files dedupe#1129
ChristophWurst merged 2 commits into
stable34from
backport/1118/stable34

Conversation

@backportbot

@backportbot backportbot Bot commented Jul 15, 2026

Copy link
Copy Markdown

Backport of PR #1118

Add a regression test that reproduces #1113 in a fresh subprocess: it
simulates another app (e.g. recognize, which ships a php-scoped copy of
rubix) winning Composer's "files" autoload dedupe race by pre-marking
rubix's file identifiers as loaded, then asserts that sigmoid activation -
which relies on the string callable 'Rubix\ML\sigmoid' - still works.

Without the fix the un-scoped rubix functions.php is skipped, so
'Rubix\ML\sigmoid' is never defined and inference crashes with
"Tensor\Matrix::map(): Argument #1 ($callback) must be of type callable,
string given". This test currently fails on purpose to demonstrate the
bug; the fix follows in a separate commit.

Assisted-by: ClaudeCode:claude-opus-4-8
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
rubix/ml and rubix/tensor expose free functions and constants through
Composer's "files" autoloader, which dedupes process-wide on a content-blind
identifier md5("<package>:<path>"). Several apps bundle rubix and register the
same identifier, so only the first to boot loads its copy:

  - recognize php-scopes rubix, so when it wins only prefixed symbols exist and
    our un-scoped Rubix\ML\sigmoid is missing -> login crashes with
    "Tensor\Matrix::map(): Argument #1 ($callback) must be of type callable";
  - mail ships rubix un-scoped, so it defines the same Rubix\ML\* symbols we do.

Load our rubix files from Application::register() via RubixBootstrap.php, but
only when the symbols are actually missing, guarding on a representative symbol
per file. Requiring unconditionally would fatal with "Cannot redeclare function
Rubix\ML\argmin()" whenever another un-scoped copy already loaded them
(require_once dedupes by realpath, not by symbol).

Fixes #1113

Assisted-by: ClaudeCode:claude-opus-4-8
Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
@backportbot backportbot Bot added bug Something isn't working 3. to review regression labels Jul 15, 2026
@backportbot backportbot Bot added this to the Nextcloud 34.0.1 milestone Jul 15, 2026
@ChristophWurst
ChristophWurst disabled auto-merge July 15, 2026 17:00
@ChristophWurst
ChristophWurst merged commit e17d15e into stable34 Jul 15, 2026
27 of 28 checks passed
@ChristophWurst
ChristophWurst deleted the backport/1118/stable34 branch July 15, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release bug Something isn't working regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants