Repository navigation
refactor(types): remove chained type assertions in core and ui - #124073
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 4:21 AM ET / 08:21 UTC. ClawSweeper reviewWhat this changesReplaces selected chained TypeScript assertions in core, AI transport, session, CLI, plugin SDK, and Control UI code with guards, typed adapters, and narrower constructions. Merge readinessKeep open for explicit maintainer handling: the prior typed-settings blocker is fixed at the current head, and this review found no new concrete correctness or security defect. Priority: P3 Review scores
Verification
How this fits togetherThis change affects type boundaries where provider events, persisted session data, CLI output, plugin adapters, and Control UI settings enter OpenClaw. Those normalized values then drive agent execution, migration, operator output, and UI state updates. flowchart LR
A[Provider, storage, and UI inputs] --> B[Typed guards and adapters]
B --> C[Agent and transport runtime]
B --> D[Session and cron migration]
B --> E[Control UI settings]
C --> F[Model and tool execution]
D --> G[Operator commands]
E --> G
Decision needed
Why: The protected maintainer label and broad compatibility-sensitive surface require a human decision on acceptable scope after current-main integration. Before merge
Agent review detailsSecurityNone. PR surfaceSource +42. Total +42 across 29 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current main, retain the resolved typed settings and migration boundaries, and land only after exact-head checks confirm the cross-cutting refactor remains behavior-neutral. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a type-safety refactor, not a report of broken user-visible behavior; its relevant existing tests were inspected but not run under the read-only review contract. Is this the best way to solve the issue? Yes: the current head fixes the earlier settings-boundary concern by preserving the UiSettings key/value relation, while the other edits validate or reconstruct data at their existing owners rather than adding parallel behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f1ced37ce5df. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
2d38bc2 to
3595310
Compare
|
Merged via squash.
|
…law#124073) * refactor(types): remove chained assertions in core and ui * fix(types): preserve legacy cron migration identity * fix(types): preserve settings patch key types
What Problem This Solves
Production code in the assigned core, package, Plugin SDK, session, command, and Control UI surfaces contained chained type assertions that discarded type evidence. This removes the sites that can be repaired without changing runtime behavior or exported contracts, while preserving an exact ledger of provider/native/test-contract bridges for the later rule-enablement PR.
Why This Change Was Made
The fixes follow the established no-widen-then-assert idioms: boundary guards and reconstruction for untrusted records, typed adapters for agent-core runtime dependencies, satisfies for constructed values, direct Reflect operations for dynamic keys, and precise owner-state types where the existing contract already carried the evidence.
Attempts to tighten the remaining UI and test-helper host types were reverted after the full test-type graph proved that those surfaces intentionally accept partial fixtures. Public Plugin SDK generic shapes were also left unchanged.
User Impact
No runtime behavior or public API shape changes. This is a type-safety refactor that makes future chained-assertion lint enablement possible.
Evidence
Intentional leftovers (23)
Deferred leftovers (50)
The UI sites above share one reason: the production page carries the full history/lifecycle/scroll/settings state, while exported helpers and colocated tests intentionally accept partial host fixtures. Tightening those signatures would be a separate contract migration and test rewrite, which this worker scope forbids.