refactor(application): build model resources in one owner - #418
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 12:44 AM ET / 04:44 UTC. ClawSweeper reviewWhat this changesConsolidates model-resource construction into one factory, keeps model selection separate, and updates contract tests and documentation. Merge readiness✅ Ready for maintainer review This remains a useful, focused refactor: main and v0.21.11 retain the intermediate factories. No actionable correctness or security defect was found, and repository policy protects this owner-authored PR from automatic closure. Priority: P3 Review scores
Verification
How this fits togetherThe application layer turns CLI and daemon requests into shared execution resources for URL and file summaries. These resources connect model providers, streaming output, and usage metrics. flowchart TD
A[CLI or daemon request] --> B[Resolve model intent]
G[Configuration and environment] --> B
B --> C[Build model resources]
G --> C
C --> D[URL and file flows]
D --> E[Provider or CLI model]
E --> F[Summary output and metrics]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep one per-run model-resource owner while preserving shared executor, metrics, environment, and stream references across both flows. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes an internal refactor rather than a reported runtime bug, and source comparison revealed no concrete introduced failure. Is this the best way to solve the issue? Yes. Combining the existing constructors removes forwarding layers without adding a competing API, changing configuration semantics, or altering flow ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 49805c2c4356. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
One owner for model resources
The application previously constructed one model runtime through three factories, repeatedly declaring and forwarding the same environment, request options, and resolved run policy. Model selection now owns intent resolution; one model-runtime factory creates the metrics, provider bindings, executor, and executable model. Execution resources only compose the URL and asset flows.
The original environment, per-run environment, optional metrics environment, execution budgets, request-option precedence, CLI fallback policy, and stream/log/trace hooks retain their meaning. Both flows still share the same metric collectors and executor references. The old private constructor paths are deleted rather than kept as compatibility aliases.
This removes 98 production lines; expanded contract tests and documentation leave the complete change 56 lines smaller. Public exports and dependencies are unchanged.
Proof
The first build caught an overly permissive subprocess dependency type inherited from the lower-level executor. The final factory retains the original required subprocess function contract, and the complete build/gate/review were rerun successfully.
Hosted CI passes on the exact PR head: Node 24 gate, Chromium E2E, and Firefox smoke, with security checks green.