Skip to content

fix(cli): assign new wheels.Injector to application.wheelsdi in scaffolded Application.cfc#2623

Merged
bpamiri merged 1 commit into
developfrom
fix/bot-2622-wheels-new-scaffolds-application-cfc-with-missing
May 12, 2026
Merged

fix(cli): assign new wheels.Injector to application.wheelsdi in scaffolded Application.cfc#2623
bpamiri merged 1 commit into
developfrom
fix/bot-2622-wheels-new-scaffolds-application-cfc-with-missing

Conversation

@wheels-bot
Copy link
Copy Markdown
Contributor

@wheels-bot wheels-bot Bot commented May 12, 2026

Summary

The CLI's scaffolded Application.cfc declared a local injector variable in onApplicationStart() and onError() but then referenced application.wheelsdi without an explicit assignment. The runtime only worked because Injector.init() self-registers at application.wheelsdi — reading the template suggested otherwise and matched the bug report in #2622.

This PR makes the assignment explicit in all four affected files (the canonical CLI template plus the in-repo public/, examples/tweet/, and examples/starter-app/ derivatives) so every reference now reads through application.wheelsdi, matching the documented 4.0 DI container name. A new framework-test spec (vendor/wheels/tests/specs/cli/ApplicationCfcInjectorAssignmentSpec.cfc) pins the contract so the templates cannot drift back.

Related Issue

Closes #2622

Type of Change

  • Bug fix
  • New feature
  • Enhancement to existing feature
  • Documentation update
  • Refactoring

Feature Completeness Checklist

  • DCO sign-offgit commit -s used; trailer present
  • Testsvendor/wheels/tests/specs/cli/ApplicationCfcInjectorAssignmentSpec.cfc (failing → passing TDD)
  • Framework Docs — handled separately by bot-update-docs.yml
  • AI Reference Docs — handled separately by bot-update-docs.yml
  • CLAUDE.md — handled separately by bot-update-docs.yml
  • CHANGELOG.md — entry added under [Unreleased] / Fixed
  • Test runner passescurl http://localhost:60007/wheels/core/tests?db=sqlite&format=json&directory=wheels.tests.specs.cli returns totalPass:5, totalFail:0, totalError:0 (4 new tests + the existing ApiControllerSnippet test). Smoke-checked wheels.tests.specs.dispatch for regressions — still 3 pass / 0 fail / 0 error.

Test Plan

  • New spec reproduces the issue: before the fix, all four Application.cfc files fail the assertion "application.wheelsdi = new wheels.Injector(" (4 fails)
  • After the fix, all four pass
  • No regressions in adjacent suites checked (cli, dispatch)
  • Reviewer A and Reviewer B passes
  • Human approval on develop before merge

… in scaffolded Application.cfc

The CLI's scaffolded Application.cfc declared a local `injector` variable
in onApplicationStart() and onError() but then referenced
application.wheelsdi without an explicit assignment. The runtime only
worked because Injector.init() self-registers at application.wheelsdi —
reading the template suggested otherwise and matched the bug report in
issue #2622 ("application.wheelsdi is never assigned").

Replace the orphan local in all four templates (the canonical CLI
template and the in-repo public/, examples/tweet/, examples/starter-app/
copies) so every reference goes through application.wheelsdi. Pin the
contract with a new spec at vendor/wheels/tests/specs/cli/
ApplicationCfcInjectorAssignmentSpec.cfc so freshly scaffolded apps and
the in-repo derivatives cannot drift back into the inconsistent form.

Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
@wheels-bot
Copy link
Copy Markdown
Contributor Author

wheels-bot Bot commented May 12, 2026

Wheels Bot — No doc updates

Reviewed this PR's diff and found no docs that need updating (the fix corrects an internal inconsistency in scaffold-generated Application.cfc templates — the user-visible DI container API (application.wheelsdi) is unchanged and already correctly documented in all existing guides).

Copy link
Copy Markdown
Contributor Author

@wheels-bot wheels-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wheels Bot — Reviewer A

TL;DR: This is a focused, correct bug fix. Four Application.cfc files had a local injector variable in onApplicationStart() and onError() that was never assigned to application.wheelsdi — the runtime only worked because Injector.init() self-registers as a side effect. The fix makes every reference explicit via application.wheelsdi. The regression spec is well-formed and follows the established buildArtifactLicenseSpec.cfc pattern. No blockers found; recommending approval by a human maintainer.

Correctness

The four Application.cfc files (cli/lucli/templates/app/public/, public/, examples/tweet/public/, examples/starter-app/public/) are updated consistently. Every occurrence of the orphan local injector variable has been replaced with application.wheelsdi.

One observation worth having on record: the onError() handler now explicitly overwrites application.wheelsdi with a fresh injector. In the old code this was already happening as an Injector.init() side effect (the PR description notes: "The runtime only worked because Injector.init() self-registers at application.wheelsdi"), so the observable behavior is unchanged — the new code is just honest about it. No regression here; flagging for reader awareness only.

Tests

vendor/wheels/tests/specs/cli/ApplicationCfcInjectorAssignmentSpec.cfc follows the same var repoRoot = expandPath("/wheels/../..") + IIFE loop-capture pattern used in buildArtifactLicenseSpec.cfc, so the closure/outer-var pattern has established precedent in this suite. The four assertions per file (positive assignment, no orphan local, no orphan getInstance, positive wheelsdi.getInstance) cover the fix thoroughly.

Commits

fix(cli): assign new wheels.Injector directly to application.wheelsdi in scaffolded Application.cfc — valid commitlint type, subject under 100 chars, not ALL-CAPS.

Docs

CHANGELOG [Unreleased] / Fixed entry is present and accurate. Docs/AI-ref deferred to bot-update-docs.yml per checklist — appropriate for a bug fix of this scope.

@wheels-bot
Copy link
Copy Markdown
Contributor Author

wheels-bot Bot commented May 12, 2026

Wheels Bot — Reviewer B (round 1)

A's review is accurate. The fix is correct, the test spec is well-formed, and A's recommendation to defer formal approval to a human is appropriate for a DI-subsystem change. No adjustments needed.

Sycophancy

None detected. A gave concrete, line-by-line evidence for every claim rather than a blanket "LGTM", and deliberately stopped short of a formal GitHub approval, instead saying "recommending approval by a human maintainer" — the right posture for code that touches application.wheelsdi.

False positives

None detected. I re-read every cited section:

  • The four Application.cfc files are indeed updated consistently — each orphan injector = new wheels.Injector(...) and injector.getInstance("global") pair is replaced with application.wheelsdi = ... and application.wheelsdi.getInstance("global"). Confirmed against the diff.
  • A's note that onError() now "explicitly overwrites application.wheelsdi with a fresh injector" is accurate and the behavioral equivalence claim ("the runtime only worked because Injector.init() self-registers") is consistent with the PR description and the original code.
  • A's characterisation of the IIFE closure-capture pattern as matching the buildArtifactLicenseSpec.cfc precedent is accurate — the (function(relPath) { ... })(rel) form is the correct workaround for the CFML closure outer-local-var gotcha documented in CLAUDE.md.

Missed issues

None significant. One cosmetic note A skipped: the block-comment header in the new spec uses ##2622 instead of #2622 (an unnecessary escape — # inside /** */ block comments is never evaluated by the CFML engine). This has zero runtime effect and does not affect suite compilation.

The reFind negative-assertion logic is correct: reFind(...) > 0 returns true when the orphan pattern is found; toBeFalse() then catches any regression. The regex (^|[\s;\{\}])injector\s*=\s*new\s+wheels\.Injector covers the tab-indented form present in all four files.

DCO: Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> is present in the commit and matches the author identity. A's checklist tick is correct, though A did not spell this out in the review body — minor omission, not a finding.

Verdict alignment

A's COMMENTED state + "recommend human approval" is consistent with the findings and with the standing rule that DI-subsystem changes require a human sign-off. Correct verdict.

Convergence

Aligned. The fix is correct, the regression spec is solid, and the appropriate guard (human approval before merge) is already in place. No changes are required from the author.

@bpamiri bpamiri marked this pull request as ready for review May 12, 2026 20:21
@bpamiri bpamiri merged commit 12e82e5 into develop May 12, 2026
8 checks passed
@bpamiri bpamiri deleted the fix/bot-2622-wheels-new-scaffolds-application-cfc-with-missing branch May 12, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wheels new scaffolds Application.cfc with missing application.wheelsdi assignment in onApplicationStart

1 participant