Add MLP trainer based on DB data - #1
Merged
Merged
Conversation
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Member
Author
FYI: This 573 unique (uid, ip) combinations are the result of roughly two weeks of data collection of two dozen users. |
Closed
ChristophWurst
added a commit
that referenced
this pull request
Jun 29, 2026
#1113) rubix/ml and rubix/tensor expose free functions and constants through Composer's "files" autoloader (PHP does not autoload functions). That loader dedupes process-wide on a content-blind identifier, md5("<package>:<path>"). Another app shipping a php-scoped copy of rubix (recognize) registers the very same identifier - php-scoper rewrites the namespace inside the file but not the package name or path - so whichever app boots first loads its copy and the other is skipped. When the scoped copy wins, our un-scoped 'Rubix\ML\sigmoid' is never defined and login crashes with "Tensor\Matrix::map(): Argument #1 ($callback) must be of type callable, string given". Load the rubix files explicitly in Application::register() via RubixBootstrap.php; require_once dedupes by realpath, so our copies are always defined and it is a no-op when our own autoloader won the race. Wire the regression test up to the bootstrap so it now passes. Fixes #1113 Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com>
ChristophWurst
added a commit
that referenced
this pull request
Jun 29, 2026
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
added a commit
that referenced
this pull request
Jun 29, 2026
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
added a commit
that referenced
this pull request
Jul 3, 2026
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>
ChristophWurst
added a commit
that referenced
this pull request
Jul 3, 2026
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
added a commit
that referenced
this pull request
Jul 3, 2026
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
added a commit
that referenced
this pull request
Jul 15, 2026
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>
ChristophWurst
added a commit
that referenced
this pull request
Jul 15, 2026
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>
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.
This is my very first implementation of a neural net classifier based on the multilayer perceptron classifier from php-ml.
In order to get okay-ish results I had to
All that is now available as a occ command with various optional parameters:
Some of the most recent training runs yield results like this:
Roughly translated to our problem this means 80 to 90% of the addresses classified as 'n' (negative) are really from suspicious logins. On the other hand, of all logins from unknown IPs we detect ~80%.
Ref https://en.wikipedia.org/wiki/Precision_and_recall