Repository navigation
[codex] refactor: keep runtime plan type contracts leaf-safe - #71196
100yenadmin wants to merge 10 commits into
Conversation
Greptile SummaryThis PR decouples Confidence Score: 5/5Safe to merge — no runtime behavior changes and all concrete logic remains intact in build.ts. All findings are P2: the topology guard gap (barrel imports) and union-drift risk are maintenance concerns rather than current defects. The structural type copies are accurate, the adapter casts in build.ts are consistent, and the refactor correctly achieves its stated goal. types.test.ts — topology guard patterns could be tightened to cover barrel imports Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/runtime-plan/types.test.ts
Line: 11-16
Comment:
**Topology guard misses barrel imports**
Each regex requires a trailing slash (e.g. `from "../../auto-reply/"`) and therefore silently passes for a bare barrel import like `from "../../auto-reply"` (no trailing slash). If someone later adds `import type { ThinkLevel } from "../../auto-reply"`, `from "../../config"`, or `from "../../plugins"` the guard will not fire — the coupling re-enters undetected. A small tweak to the patterns (e.g. `from "../../auto-reply(?:/|")`) or adding a separate assertion for each bare directory would close this gap.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/runtime-plan/types.ts
Line: 6-28
Comment:
**Hand-rolled union copies can silently drift from upstream sources**
`AgentRuntimeThinkLevel`, `AgentRuntimeFailoverReason`, and `AgentRuntimePromptMode` are verbatim copies of `ThinkLevel`, `FailoverReason`, and `PromptMode` respectively (confirmed by reading the source files). There is currently no compile-time enforcement that these copies stay in sync. If `ThinkLevel` gains a new member (e.g. `"ultra"`) the contract type becomes more restrictive than the concrete implementation without any compiler error or test failure, so callers using the new level via the plan API would get a type error while the underlying runtime accepts it fine. Consider a `satisfies` / assignability check in a shared utility or a comment citing the source to make the coupling explicit.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "refactor: keep runtime plan types leaf-s..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Hardens the AgentRuntimePlan type layer by keeping src/agents/runtime-plan/types.ts as a leaf “structural contract” module (no imports from concrete OpenClaw runtime policy modules), while keeping concrete wiring/adaptation in runtime-plan/build.ts.
Changes:
- Replaced concrete internal type imports in
runtime-plan/types.tswith local structural contract types (think level, prompt mode, model, reply payload, config, failover reason). - Updated
runtime-plan/build.tsto reintroduce concrete types locally and cast/adapt where needed. - Added a topology guard test to prevent
runtime-plan/types.tsfrom importing concrete runtime policy modules.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/agents/runtime-plan/types.ts | Converts runtime plan types into leaf-safe structural contracts by removing upward imports. |
| src/agents/runtime-plan/build.ts | Keeps concrete policy wiring here via local type imports and casts to concrete runtime types. |
| src/agents/runtime-plan/types.test.ts | Adds a guard test intended to enforce leaf-safety of the contract layer. |
|
@steipete gpt 5.4 / runner |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8410458d08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d9cbd0e8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebd39b1ba0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Superseded by #71722, which consolidates the RuntimePlan/Harness package into one review PR and preserves this PR's commits via cherry-pick -x. Keeping this PR as review/history evidence. |
Summary
Follow-up to the merged RuntimePlan implementation (#71096) and the umbrella RFC (#71004). This PR keeps
src/agents/runtime-plan/types.tsas a leaf structural contract layer instead of allowing it to import concrete OpenClaw runtime policy modules.No runtime behavior changes.
RuntimePlan Package Context
This PR is part of the post-#71096 RuntimePlan hardening package. The package goal is to make OpenClaw-owned policy explicit and shared before larger runner splits or naming cleanup happen.
Review package links: #71196, #71197, #71201, #71220, #71222, #71223, #71224, #71238, #71239.
Why This PR Exists
AgentRuntimePlanis supposed to sit below both Pi and Codex. The builder can wire concrete policy to existing OpenClaw helpers, but the type contract itself should not depend upward on auto-reply, config, plugin runtime model, Pi fallback helper, transcript policy, or prompt-mode implementation modules.If those imports creep back into
types.ts, the contract layer stops being a stable seam and future refactors can recreate the coupling that #71004/#71096 are trying to remove.Local Architecture
What Changed
runtime-plan/types.tswith local structural RuntimePlan contract types.runtime-plan/build.ts, where adapter policy belongs.runtime-plan/types.tsdoes not import concrete runtime policy modules.Maintainer Review Guide
src/agents/runtime-plan/types.ts.types.tsstays structural and leaf-safe; concrete helper imports should remain inbuild.ts.What Did Not Change
Verification
./node_modules/.bin/vitest run src/agents/runtime-plan/types.test.ts --config test/vitest/vitest.agents.config.ts./node_modules/.bin/vitest run src/agents/runtime-plan/build.test.ts --config test/vitest/vitest.unit-fast.config.ts./node_modules/.bin/vitest run src/agents/runtime-plan/types.compat.test.ts src/agents/runtime-plan/build.test.ts --config test/vitest/vitest.unit-fast.config.tspnpm check:architecture./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json src/agents/runtime-plan/types.ts src/agents/runtime-plan/build.ts src/agents/runtime-plan/types.test.ts src/agents/runtime-plan/types.compat.test.ts src/agents/runtime-plan/build.test.tsgit diff --checkLocal broad
pnpm check:changedhas previously hit unrelated repository type/dependency drift; this PR's targeted topology, unit, lint, and architecture checks are the intended merge signal.