Skip to content

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

Merged
ChristophWurst merged 2 commits into
stable33from
backport/1118/stable33
Jul 15, 2026
Merged

ChristophWurst merged 2 commits into
stable33from
backport/1118/stable33

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>
@ChristophWurst
ChristophWurst merged commit a999adb into stable33 Jul 15, 2026
29 of 30 checks passed
@ChristophWurst
ChristophWurst deleted the backport/1118/stable33 branch July 15, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review bug Something isn't working regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants