The vendored Fairlearn adversarial backend infers neural-network widths from
feature, target, and sensitive-feature matrices. Its generic backend currently
indexes the feature shape without first enforcing the matrix contract. As a
result, malformed feature data can either fail with an incidental exception or
silently construct a model with the wrong feature semantics.
Repair the existing source tree under /app/vendor/fairlearn.
Requirements:
In fairlearn/adversarial/_constants.py, define the shared _X_NOT_2D
error-message template used for this validation. It must format with the
received rank and clearly state that X must be two-dimensional.
In fairlearn/adversarial/_backend_engine.py, import and use that shared
template. BackendEngine must reject every X whose ndim is not exactly
2 by raising ValueError formatted with the actual rank.
Perform this validation before inferring widths or constructing either
model. Do not flatten, reshape, squeeze, or otherwise reinterpret invalid
input.
Preserve valid behavior: predictor input width is X.shape[1]; target and
sensitive-feature widths come from the fitted transformers; warm-start,
loss, optimizer, shuffling, evaluation, and training contracts remain
unchanged.
Do not replace or delete the vendored package or diagnostic runner. The
repair must be implemented in both existing modules named above; changing
callers or generating a report without repairing the backend is not a
solution.
After repairing the source, compile it and run the supplied integration
diagnostic:
bash
cd /app/vendor/fairlearn
python3 -m compileall -q fairlearn
cd /app
python3 tools/backend_diagnostics.py --output /app/repair_report.json
Submit the repaired source tree and /app/repair_report.json. The report must
use schema version fairlearn.backend-diagnostics.v1, include rejected rank
cases 0, 1, 3, and 4, and include the valid-path model widths, shuffle
alignment, evaluation result, and training losses produced by the runner.