Skip to content

feat: wrapper-to-implementation inference + fix broken auto-generated tests#931

Merged
chubes4 merged 4 commits intomainfrom
feat/wrapper-inference
Mar 23, 2026
Merged

feat: wrapper-to-implementation inference + fix broken auto-generated tests#931
chubes4 merged 4 commits intomainfrom
feat/wrapper-inference

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 23, 2026

Summary

Closes #903 (wrapper-to-implementation inference)

Two changes:

1. Fix: Remove broken auto-generated tests (commit 1)

Deletes 300 lines of auto-generated tests in version_overrides.rs that never compiled. These were committed by homeboy-ci[bot] in 8653206 via the auto-refactor pipeline. The test generation fixer (#818) has known bugs:

Bug Count Example
Duplicate test names (E0428) 8 test_deploy_with_override_default_path × 3
Wrong arg counts (E0061) 17 fetch_remote_versions() called with 0 args, needs 3
Wrong return types (E0599) 6 .is_ok() on (), HashMap, Option
Invalid format strings 6 Backticks in assert messages

This was the sole cause of all 39 cargo test --lib compilation errors. Suite is now: 844 passed, 0 failed.

2. Feat: Wrapper-to-implementation inference (commit 2)

New MissingWrapperDeclaration audit finding type. Detects wrapper files that call implementation functions but don't explicitly declare the relationship.

Configuration in homeboy.json:

{
  "audit_rules": {
    "wrapper_rules": [{
      "name": "tool_ability_link",
      "wrapper_glob": "inc/Engine/AI/Tools/**/*.php",
      "expected_field": "ability",
      "call_patterns": ["wp_get_ability\\('([^']+)'\\)", "(\\w+Abilities)::\\w+\\("],
      "field_format": "'ability' => '{inferred}'"
    }]
  }
}

How it works:

  1. For each file matching wrapper_glob, check if expected_field exists
  2. If missing, trace internal_calls against configurable call_patterns
  3. Report MissingWrapperDeclaration with inferred target and suggested fix

Language-agnostic — works for any language with configurable regex patterns.

10 unit tests covering field detection, call tracing, suggestion building, multi-target inference, and edge cases. All pass.

Changes

  • src/core/deploy/version_overrides.rs — remove 300 lines of broken auto-generated tests
  • src/core/code_audit/conventions.rs — add MissingWrapperDeclaration variant
  • src/core/code_audit/mod.rs — wire wrapper inference into audit pipeline (Phase 4m)
  • src/core/code_audit/wrapper_inference.rs — new module: config, detection, call tracing, tests

Testing

  • Build: ✅ clean
  • cargo test --lib: ✅ 844 passed, 0 failed (was 39 compilation errors)
  • cargo test --bin homeboy: ✅ 25 passed
  • Wrapper inference tests: ✅ 10 passed

chubes4 and others added 3 commits March 23, 2026 00:04
Delete 300 lines of auto-generated tests that never compiled:
- Duplicate test function names (E0428)
- Wrong argument counts (E0061) — called 3-9 arg functions with 0 args
- Wrong return types (E0599) — called .is_ok() on (), HashMap, Option
- Invalid format strings — backticks in assert messages

These were committed by homeboy-ci[bot] in 8653206 via the auto-refactor
pipeline. The test generation fixer (#818) has known bugs that produced
this output: depth tracking error in contract extraction, missing
signature awareness, and no dedup on generated test names.

This was the sole cause of all 39 `cargo test --lib` compilation errors.
Suite now: 844 passed, 0 failed.
Add MissingWrapperDeclaration audit finding type and wrapper_inference
module that detects wrapper files missing explicit declarations of what
they wrap.

Detection: for files matching configurable wrapper_glob, check if the
expected_field exists. If not, trace internal calls against configurable
regex call_patterns to infer the implementation target and report it.

Configuration in homeboy.json under audit_rules.wrapper_rules:
  {
    "name": "tool_ability_link",
    "wrapper_glob": "inc/Engine/AI/Tools/**/*.php",
    "expected_field": "ability",
    "call_patterns": ["wp_get_ability\\('([^']+)'\\)"],
    "field_format": "'ability' => '{inferred}'"
  }

Language-agnostic pattern matching — works for PHP, Rust, TypeScript,
or any language with configurable call patterns.

Includes 10 unit tests covering field detection, call tracing, suggestion
building, and edge cases.
src/commands/fleet.rs
src/commands/release.rs
src/commands/version.rs
src/core/code_audit/conventions.rs
src/core/code_audit/wrapper_inference.rs
src/core/deploy/version_overrides.rs
src/core/release/workflow.rs
@homeboy-ci
Copy link
Contributor

homeboy-ci bot commented Mar 23, 2026

Homeboy Results — homeboy

Audit

Failure Digest

Audit Failure Digest

  • Alignment score: 0.921
  • Severity counts: info: 16, unknown: 3, warning: 60
  • Outliers in current run: 3
  • Parsed outlier entries: 3
  • Drift increased: yes
  • New findings since baseline: 29
    1. intra-method-duplication — Duplicated block in execute_artifact_deploy — 5 identical lines at line 226 and line 248 (intra-method-duplication::src/core/deploy/execution.rs::IntraMethodDuplicate)
    2. intra-method-duplication — Duplicated block in execute_component_deploy — 6 identical lines at line 91 and line 104 (intra-method-duplication::src/core/deploy/execution.rs::IntraMethodDuplicate)
    3. intra-method-duplication — Duplicated block in run_fix_iteration — 7 identical lines at line 450 and line 480 (intra-method-duplication::src/core/refactor/plan/verify.rs::IntraMethodDuplicate)
    4. parallel-implementation — Parallel implementation: log_fleet_dashboard has similar call pattern to log_dashboard_table in src/commands/status.rs — shared calls: is_terminal, max, stderr (parallel-implementation::src/commands/fleet.rs::ParallelImplementation)
    5. parallel-implementation — Parallel implementation: deploy_with_override has similar call pattern to deploy_artifact in src/core/deploy/safety_and_artifact.rs — shared calls: execute, failure, fix_deployed_permissions, ok_or_else, quote_path (+4 more) (parallel-implementation::src/core/deploy/version_overrides.rs::ParallelImplementation)
  • Top actionable findings:
    1. src/commands/fleet.rs — high_item_count — File has 18 top-level items (threshold: 15)
    2. src/core/code_audit/conventions.rs — god_file — File has 1529 lines (threshold: 1000)
    3. src/core/code_audit/mod.rs — god_file — File has 1095 lines (threshold: 1000)
    4. src/core/refactor/plan/planner.rs — god_file — File has 1183 lines (threshold: 1000)
    5. src/core/refactor/plan/planner.rs — high_item_count — File has 28 top-level items (threshold: 15)
All parsed audit findings (79)
1. **src/commands/fleet.rs** — high_item_count — File has 18 top-level items (threshold: 15)
2. **src/core/code_audit/conventions.rs** — god_file — File has 1529 lines (threshold: 1000)
3. **src/core/code_audit/mod.rs** — god_file — File has 1095 lines (threshold: 1000)
4. **src/core/refactor/plan/planner.rs** — god_file — File has 1183 lines (threshold: 1000)
5. **src/core/refactor/plan/planner.rs** — high_item_count — File has 28 top-level items (threshold: 15)
6. **src/commands/version.rs** — intra_method_duplicate — Duplicated block in `run` — 5 identical lines at line 152 and line 165
7. **src/core/code_audit/conventions.rs** — intra_method_duplicate — Duplicated block in `check_signature_consistency` — 5 identical lines at line 619 and line 677
8. **src/core/code_audit/conventions.rs** — intra_method_duplicate — Duplicated block in `discover_conventions` — 5 identical lines at line 404 and line 421
9. **src/core/code_audit/impact.rs** — intra_method_duplicate — Duplicated block in `find_affected_files` — 5 identical lines at line 408 and line 418
10. **src/core/code_audit/impact.rs** — intra_method_duplicate — Duplicated block in `test_diff_fingerprints_detects_removed_export` — 5 identical lines at line 595 and line 604
11. **src/core/code_audit/impact.rs** — intra_method_duplicate — Duplicated block in `test_diff_fingerprints_detects_removed_hook` — 5 identical lines at line 650 and line 659
12. **src/core/code_audit/impact.rs** — intra_method_duplicate — Duplicated block in `test_find_affected_calls_removed_function` — 5 identical lines at line 689 and line 698
13. **src/core/deploy/execution.rs** — intra_method_duplicate — Duplicated block in `execute_artifact_deploy` — 5 identical lines at line 226 and line 248
14. **src/core/deploy/execution.rs** — intra_method_duplicate — Duplicated block in `execute_component_deploy` — 6 identical lines at line 91 and line 104
15. **src/core/refactor/plan/verify.rs** — intra_method_duplicate — Duplicated block in `run_fix_iteration` — 7 identical lines at line 450 and line 480
16. **src/core/release/workflow.rs** — intra_method_duplicate — Duplicated block in `run_command` — 6 identical lines at line 45 and line 92
17. **src/commands/fleet.rs** — parallel_implementation — Parallel implementation: `log_fleet_dashboard` has similar call pattern to `log_dashboard_table` in src/commands/status.rs — shared calls: `is_terminal`, `max`, `stderr`
18. **src/core/deploy/version_overrides.rs** — parallel_implementation — Parallel implementation: `deploy_with_override` has similar call pattern to `deploy_artifact` in src/core/deploy/safety_and_artifact.rs — shared calls: `execute`, `failure`, `fix_deployed_permissions`, `ok_or_else`, `quote_path` (+4 more)
19. **src/core/code_audit/impact.rs** — unreferenced_export — Public function 'diff_changed_files' is not referenced by any other file
20. **src/core/code_audit/impact.rs** — unreferenced_export — Public function 'expand_scope' is not referenced by any other file
21. **src/core/code_audit/impact.rs** — unreferenced_export — Public function 'find_affected_files' is not referenced by any other file
22. **src/core/code_audit/impact.rs** — unreferenced_export — Public function 'fingerprint_from_git_ref' is not referenced by any other file
23. **src/core/code_audit/run.rs** — unreferenced_export — Public function 'default_audit_exit_code' is not referenced by any other file
24. **src/core/refactor/plan/planner.rs** — unreferenced_export — Public function 'analyze_stage_overlaps' is not referenced by any other file
25. **src/core/refactor/plan/planner.rs** — unreferenced_export — Public function 'normalize_sources' is not referenced by any other file
26. **src/core/refactor/plan/planner.rs** — unreferenced_export — Public function 'run_lint_refactor' is not referenced by any other file
27. **src/core/refactor/plan/planner.rs** — unreferenced_export — Public function 'run_test_refactor' is not referenced by any other file
28. **src/core/refactor/plan/planner.rs** — unreferenced_export — Public function 'summarize_plan_totals' is not referenced by any other file
29. **src/core/refactor/plan/planner.rs** — unreferenced_export — Public function 'test_refactor_request' is not referenced by any other file
30. **src/commands/release.rs** — legacy_comment — Potential legacy/stale comment on line 208: --outdated: only components with unreleased code commits
31. **src/core/code_audit/conventions.rs** — missing_test_method — Method 'all_names' has no corresponding test (expected 'test_all_names')
32. **src/core/code_audit/conventions.rs** — missing_test_method — Method 'check_signature_consistency' has no corresponding test (expected 'test_check_signature_consistency')
33. **src/core/code_audit/conventions.rs** — missing_test_method — Method 'discover_conventions' has no corresponding test (expected 'test_discover_conventions')
34. **src/core/code_audit/conventions.rs** — missing_test_method — Method 'from_extension' has no corresponding test (expected 'test_from_extension')
35. **src/core/code_audit/conventions.rs** — missing_test_method — Method 'from_path' has no corresponding test (expected 'test_from_path')
36. **src/core/code_audit/impact.rs** — missing_test_method — Method 'diff_changed_files' has no corresponding test (expected 'test_diff_changed_files')
37. **src/core/code_audit/impact.rs** — missing_test_method — Method 'expand_scope' has no corresponding test (expected 'test_expand_scope')
38. **src/core/code_audit/impact.rs** — missing_test_method — Method 'find_affected_files' has no corresponding test (expected 'test_find_affected_files')
39. **src/core/code_audit/impact.rs** — missing_test_method — Method 'fingerprint_from_git_ref' has no corresponding test (expected 'test_fingerprint_from_git_ref')
40. **src/core/code_audit/impact.rs** — orphaned_test — Test method 'test_find_affected_calls_removed_function' references 'find_affected_calls_removed_function' which no longer exists in the source
41. **src/core/code_audit/impact.rs** — orphaned_test — Test method 'test_find_affected_extends_renamed_class' references 'find_affected_extends_renamed_class' which no longer exists in the source
42. **src/core/code_audit/impact.rs** — orphaned_test — Test method 'test_find_affected_hooks_removed_action' references 'find_affected_hooks_removed_action' which no longer exists in the source
43. **src/core/code_audit/impact.rs** — orphaned_test — Test method 'test_find_affected_imports_renamed_type' references 'find_affected_imports_renamed_type' which no longer exists in the source
44. **src/core/code_audit/impact.rs** — orphaned_test — Test method 'test_find_affected_renamed_function_in_calls' references 'find_affected_renamed_function_in_calls' which no longer exists in the source
45. **src/core/code_audit/impact.rs** — orphaned_test — Test method 'test_find_affected_skips_changed_files' references 'find_affected_skips_changed_files' which no longer exists in the source
46. **src/core/code_audit/impact.rs** — orphaned_test — Test method 'test_make_fingerprint' references 'make_fingerprint' which no longer exists in the source
47. **src/core/code_audit/run.rs** — missing_test_method — Method 'default_audit_exit_code' has no corresponding test (expected 'test_default_audit_exit_code')
48. **src/core/code_audit/run.rs** — missing_test_method — Method 'run_main_audit_workflow' has no corresponding test (expected 'test_run_main_audit_workflow')
49. **src/core/code_audit/wrapper_inference.rs** — missing_test_method — Method 'analyze_wrappers' has no corresponding test (expected 'test_analyze_wrappers')
50. **src/core/deploy/execution.rs** — missing_test_file — No test file found (expected 'tests/core/deploy/execution_test.rs') and no inline tests
51. **src/core/deploy/version_overrides.rs** — missing_test_method — Method 'artifact_is_fresh' has no corresponding test (expected 'test_artifact_is_fresh')
52. **src/core/deploy/version_overrides.rs** — missing_test_method — Method 'deploy_with_override' has no corresponding test (expected 'test_deploy_with_override')
53. **src/core/deploy/version_overrides.rs** — missing_test_method — Method 'fetch_remote_versions' has no corresponding test (expected 'test_fetch_remote_versions')
54. **src/core/deploy/version_overrides.rs** — missing_test_method — Method 'find_deploy_override' has no corresponding test (expected 'test_find_deploy_override')
55. **src/core/deploy/version_overrides.rs** — missing_test_method — Method 'find_deploy_verification' has no corresponding test (expected 'test_find_deploy_verification')
56. **src/core/deploy/version_overrides.rs** — missing_test_method — Method 'prefer_installed_binary' has no corresponding test (expected 'test_prefer_installed_binary')
57. **src/core/deploy/version_overrides.rs** — missing_test_method — Method 'run_post_deploy_hooks' has no corresponding test (expected 'test_run_post_deploy_hooks')
58. **src/core/engine/validate_write.rs** — missing_test_method — Method 'validate_only' has no corresponding test (expected 'test_validate_only')
59. **src/core/engine/validate_write.rs** — missing_test_method — Method 'validate_write' has no corresponding test (expected 'test_validate_write')
60. **src/core/engine/validate_write.rs** — orphaned_test — Test method 'test_resolve_builtin_for_go_project' references 'resolve_builtin_for_go_project' which no longer exists in the source
61. **src/core/engine/validate_write.rs** — orphaned_test — Test method 'test_resolve_builtin_for_rust_project' references 'resolve_builtin_for_rust_project' which no longer exists in the source
62. **src/core/engine/validate_write.rs** — orphaned_test — Test method 'test_resolve_builtin_for_typescript_project' references 'resolve_builtin_for_typescript_project' which no longer exists in the source
63. **src/core/engine/validate_write.rs** — orphaned_test — Test method 'test_resolve_builtin_returns_none_for_unknown' references 'resolve_builtin_returns_none_for_unknown' which no longer exists in the source
64. **src/core/refactor/plan/planner.rs** — missing_test_method — Method 'analyze_stage_overlaps' has no corresponding test (expected 'test_analyze_stage_overlaps')
65. **src/core/refactor/plan/planner.rs** — missing_test_method — Method 'build_refactor_plan' has no corresponding test (expected 'test_build_refactor_plan')
66. **src/core/refactor/plan/planner.rs** — missing_test_method — Method 'lint_refactor_request' has no corresponding test (expected 'test_lint_refactor_request')
67. **src/core/refactor/plan/planner.rs** — missing_test_method — Method 'normalize_sources' has no corresponding test (expected 'test_normalize_sources')
68. **src/core/refactor/plan/planner.rs** — missing_test_method — Method 'run_lint_refactor' has no corresponding test (expected 'test_run_lint_refactor')
69. **src/core/refactor/plan/planner.rs** — missing_test_method — Method 'run_test_refactor' has no corresponding test (expected 'test_run_test_refactor')
70. **src/core/refactor/plan/planner.rs** — missing_test_method — Method 'summarize_plan_totals' has no corresponding test (expected 'test_summarize_plan_totals')
71. **src/core/refactor/plan/planner.rs** — orphaned_test — Test method 'test_component' references 'component' which no longer exists in the source
72. **src/core/refactor/plan/planner.rs** — orphaned_test — Test method 'test_refactor_request' references 'refactor_request' which no longer exists in the source
73. **src/core/refactor/plan/planner.rs** — orphaned_test — Test method 'test_tmp_dir' references 'tmp_dir' which no longer exists in the source
74. **src/core/refactor/plan/verify.rs** — missing_test_file — No test file found (expected 'tests/core/refactor/plan/verify_test.rs') and no inline tests
75. **src/core/release/workflow.rs** — missing_test_method — Method 'run_batch' has no corresponding test (expected 'test_run_batch')
76. **src/core/release/workflow.rs** — missing_test_method — Method 'run_command' has no corresponding test (expected 'test_run_command')
77. **src/commands/docs.rs** — outlier — (outlier)
78. **tests/commands/deploy_test.rs** — outlier — (outlier)
79. **src/core/engine/undo/snapshot.rs** — outlier — (outlier)
- Full audit log: https://github.com/Extra-Chill/homeboy/actions/runs/23415944316

Autofixability classification

  • Overall: auto_fixable
  • Autofix enabled: yes
  • Autofix attempted this run: no
  • Auto-fixable failed commands:
    • audit
  • Failed commands with available automated fixes:
    • audit

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

audit (changed files only)

Auto-refactor

ℹ️ Autofix enabled, but no fixable file changes were produced

Failure Digest

Autofixability classification

  • Overall: human_needed
  • Autofix enabled: yes
  • Autofix attempted this run: no
  • Human-needed failed commands:
    • refactor --from all

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

refactor --from all

Tooling versions
  • Homeboy CLI: homeboy 0.85.3+1d92a4f
  • Extension: rust from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v2

Homeboy Action v1

The builtin Rust validation used `cargo check` which only checks
lib/bin targets. Generated test code (#[cfg(test)] modules) was not
validated, allowing broken tests (wrong signatures, duplicate names,
bad format strings) to pass the refactor pipeline's write gate.

Change to `cargo check --tests` so all test code is compiled before
the refactor pipeline accepts the changes. On failure, the planner
rolls back all modifications.
@chubes4 chubes4 merged commit 9c10ef6 into main Mar 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Audit + refactor support for wrapper-to-implementation declaration inference

1 participant