Skip to content

refactor(jobs): collapse JobsOperations/JobsStatus passthrough into Jobs#1804

Merged
chubes4 merged 2 commits intomainfrom
fix/audit-1786-1787-jobs-facade-and-slug-literals
May 6, 2026
Merged

refactor(jobs): collapse JobsOperations/JobsStatus passthrough into Jobs#1804
chubes4 merged 2 commits intomainfrom
fix/audit-1786-1787-jobs-facade-and-slug-literals

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented May 6, 2026

Summary

  • Resolves the Jobs facade passthrough flagged in chubes4/data-machine#1787 by absorbing JobsOperations and JobsStatus back into Jobs. Net result: 1107 lines deleted, 969 added — one class instead of three, no delegation layer.
  • Audit verification: homeboy audit --path . shows facade_passthrough findings drop from 1 → 0 on this branch. No new findings introduced.

Why collapse instead of inline

The facade wrapped 18 of 19 public methods as one-liner delegates to $this->operations or $this->status. With 29 external call sites all using new Jobs(...), two options were on the table:

  1. Push delegation out to every caller (new JobsOperations() everywhere).
  2. Pull the satellites back into Jobs.

Option 2 has lower blast radius — preserves the public API every caller already depends on, and the two satellites had no independent reason to exist (no separate constructor args, no shared state outside the table, both extended BaseRepository).

Changes

  • inc/Core/Database/Jobs/Jobs.php — now extends BaseRepository directly and owns CRUD, status transitions, flow health bookkeeping, and schema migrations in one place.
  • inc/Core/Database/Jobs/JobsOperations.phpdeleted.
  • inc/Core/Database/Jobs/JobsStatus.phpdeleted.
  • inc/Engine/Actions/Handlers/JobCompleteHandler.php — switched from new JobsOperations() to new Jobs(). update_flow_health_cache() is now a first-class method on Jobs.
  • inc/Api/System/System.php — removed an unused use ... JobsOperations import.
  • tests/Unit/Core/WordPress/PostTrackingTest.php — previously called new JobsOperations($jobs_db) against a 0-arg constructor (PHP silently ignored the extra arg). Now uses Jobs directly.
  • tests/jobs-get-children-smoke.php — updated docblock references.

Verification

  • php -l clean on every touched file.
  • composer dump-autoload -o regenerates clean (1033 classes).
  • php tests/jobs-get-children-smoke.php → all assertions pass.
  • homeboy audit --path .facade_passthrough: 0 (was 1).

No behavior change. External new Jobs() API preserved.

Related audit issues — closed as upstream false positives

While triaging the open audit issues that produced this fix, three sibling issues were closed as detector false positives and filed upstream against the homeboy / homeboy-extensions audit rules rather than worked around in DM:

  • chubes4/data-machine#1788 option scope drift (54) — fires on every *_option call in any file whose comments mention "multisite" or "network" in passing. DM is intentionally single-site (SITE.md: multisite: false). Upstream: Extra-Chill/homeboy-extensions#424.
  • chubes4/data-machine#1786 constant backed slug literal (25) — has::GROUP is a parser glitch (the word "has" in a docblock matched as a class name); the remaining findings are semantic conflations (plugin slug vs Action Scheduler group, bundle JSON keys vs internal class constants, test stubs deliberately inlining option names to verify production code uses them). Upstream: Extra-Chill/homeboy-extensions#425.
  • chubes4/data-machine#1785 command output policy (3) — fires on idiomatic WP-CLI usage (WP_CLI::success/error/log). No canonical output layer exists for WP-CLI consumers without inventing one. Upstream: Extra-Chill/homeboy#2335.

Per the RULES.md "fix upstream first, never paper over" rule — these are documented upstream rather than papered over with homeboy:ignore markers in DM.

AI assistance

  • AI assistance: Yes
  • Tool(s): Claude Code (Sonnet 4.5)
  • Used for: Reviewed all 4 open audit findings, classified real vs false-positive, drafted the upstream issue bodies, executed the facade collapse and external-caller updates. Chris reviewed the triage classification and approved the upstream-first split before code changes landed.

Closes #1787.

The Jobs class was an 18/19 passthrough facade delegating to JobsOperations
and JobsStatus. With 29 external callers using `new Jobs(...)`, the cleanest
fix is to absorb the satellites back into Jobs rather than push delegation
out to every call site.

Changes:
- Jobs now extends BaseRepository directly and owns CRUD, status transitions,
  flow health bookkeeping, and schema migrations in one place.
- JobsOperations and JobsStatus deleted.
- JobCompleteHandler switched from `new JobsOperations()` to `new Jobs()`
  (update_flow_health_cache and friends are now first-class on Jobs).
- Removed an unused `use ... JobsOperations` import in inc/Api/System/System.php.
- PostTrackingTest fixed: previously did `new JobsOperations($jobs_db)` against
  a 0-arg constructor (PHP swallowed the extra arg). Now uses Jobs directly.
- Updated docblock references in tests/jobs-get-children-smoke.php.

Verified:
- `php -l` clean on all touched files.
- `composer dump-autoload -o` regenerates clean (1033 classes).
- `php tests/jobs-get-children-smoke.php` → all pass.
- `homeboy audit` shows facade_passthrough findings dropped from 1 → 0.

No behavior change. External `new Jobs()` API preserved.
@homeboy-ci
Copy link
Copy Markdown
Contributor

homeboy-ci Bot commented May 6, 2026

Homeboy Results — data-machine

Lint

lint — passed

ℹ️ Full options: homeboy docs commands/lint
Deep dive: homeboy lint data-machine --changed-since c0ef3b5

Test

test — passed

  • 113 passed
  • 3 skipped

ℹ️ Auto-fix lint issues: homeboy refactor data-machine --from lint --write
ℹ️ Collect coverage: homeboy test data-machine --coverage
ℹ️ Save test baseline: homeboy test data-machine --baseline
ℹ️ Pass args to test runner: homeboy test -- [args]
ℹ️ Full options: homeboy docs commands/test
Deep dive: homeboy test data-machine --changed-since c0ef3b5

Audit

audit — passed

  • test_coverage — 315 finding(s)
  • dead_code — 147 finding(s)
  • intra-method-duplication — 86 finding(s)
  • requested_detectors — 40 finding(s)
  • parallel-implementation — 18 finding(s)
  • repeated_literal_shape — 17 finding(s)
  • dead_guard — 12 finding(s)
  • Abilities — 5 finding(s)
  • field_patterns — 5 finding(s)
  • Flow — 4 finding(s)
  • Total: 661 finding(s)

Deep dive: homeboy audit data-machine --changed-since c0ef3b5

Tooling versions
  • Homeboy CLI: homeboy 0.157.1+2b0be0c7
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: 221b9c8
  • Action: Extra-Chill/homeboy-action@v2

… prepare in Jobs::get_children

The single-line phpcs:ignore at the top of the get_results() call only
suppressed the first line, leaving the inner $wpdb->prepare() args still
flagged by WordPress.DB.PreparedSQL.NotPrepared in CI. Switched to a
disable/enable block so all 5 lines of the prepared call are covered.
@chubes4 chubes4 merged commit e2fb295 into main May 6, 2026
3 checks passed
@chubes4 chubes4 deleted the fix/audit-1786-1787-jobs-facade-and-slug-literals branch May 6, 2026 16:22
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.

1 participant