fix(autoload): load rubix free functions despite Composer files dedupe#1118
Draft
ChristophWurst wants to merge 2 commits into
Draft
fix(autoload): load rubix free functions despite Composer files dedupe#1118ChristophWurst wants to merge 2 commits into
ChristophWurst wants to merge 2 commits into
Conversation
e2caedd to
c8ccdca
Compare
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>
c8ccdca to
714860a
Compare
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>
714860a to
e4d5560
Compare
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.
Fixes #1113
🤖 AI (if applicable)