Skip to content

[codex] refactor: extract attempt transcript policy resolver - #71223

Closed
100yenadmin wants to merge 4 commits into
openclaw:mainfrom
electricsheephq:contract-first/embedded-runner-contract-split
Closed

100yenadmin wants to merge 4 commits into
openclaw:mainfrom
electricsheephq:contract-first/embedded-runner-contract-split

Conversation

@100yenadmin

@100yenadmin 100yenadmin commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #71096 and RFC #71004. This PR is the first small contract-domain extraction from the embedded runner monolith: transcript policy resolution moves behind a focused resolver with tests.

Runtime behavior is intended to be equivalent.

RuntimePlan Package Context

This is the first "split by contract domain" rung. It deliberately extracts only transcript policy resolution, not the whole attempt.ts file, because the package is trying to avoid cosmetic mega-splits before behavior ownership is clear.

flowchart TD
  RFC["#71004 RFC"] --> Base["#71096 RuntimePlan merged"]
  Base --> ToolPolicy["#71220 shared tool policy helper"]
  ToolPolicy --> This["#71223 transcript policy resolver"]
  This --> Alias["#71224 embedded-runner alias barrel"]
  ToolPolicy --> Harness["#71222/#71238 Harness V2 lifecycle"]
  Harness --> Outcome["#71239 shared terminal outcome classifier"]
Loading

Review package links: #71196, #71197, #71201, #71220, #71222, #71223, #71224, #71238, #71239.

Local Architecture

flowchart TD
  Attempt["run/attempt.ts"] --> Resolver["resolveAttemptTranscriptPolicy"]
  Resolver --> Plan["RuntimePlan transcript policy"]
  Resolver --> Legacy["legacy resolveTranscriptPolicy fallback"]
  Plan --> Policy["effective transcript repair policy"]
  Legacy --> Policy
Loading

Why This PR Exists

attempt.ts is too large to safely split mechanically while policy is still scattered. This PR extracts one contract-owned decision point and proves the RuntimePlan-first/legacy-fallback behavior in isolation. That gives maintainers a small, reviewable example of the intended runner split style.

What Changed

  • Added run/attempt.transcript-policy.ts.
  • Moved the RuntimePlan-first transcript policy fallback out of run/attempt.ts.
  • Added tests proving RuntimePlan policy wins when available.
  • Added tests proving legacy transport/provider fallback remains when no RuntimePlan exists.

Maintainer Review Guide

  • Highest-signal files: src/agents/pi-embedded-runner/run/attempt.transcript-policy.ts, src/agents/pi-embedded-runner/run/attempt.ts.
  • Check this is a narrow extraction, not a semantic rewrite.
  • Check the fallback still uses the same provider/model context when no RuntimePlan is present.
  • Check tests cover both RuntimePlan-present and RuntimePlan-absent paths.

What Did Not Change

Verification

  • ./node_modules/.bin/vitest run src/agents/pi-embedded-runner/run/attempt.transcript-policy.test.ts --config test/vitest/vitest.agents.config.ts
  • ./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json src/agents/pi-embedded-runner/run/attempt.ts src/agents/pi-embedded-runner/run/attempt.transcript-policy.ts src/agents/pi-embedded-runner/run/attempt.transcript-policy.test.ts
  • git diff --check
  • pnpm check:architecture

Local broad pnpm check:changed has previously hit unrelated repository type/dependency drift; focused transcript-policy tests and architecture checks are the intended merge signal for this slice.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Apr 24, 2026
@100yenadmin
100yenadmin marked this pull request as ready for review April 24, 2026 19:16
Copilot AI review requested due to automatic review settings April 24, 2026 19:16
@greptile-apps

greptile-apps Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extracts the transcript policy resolution logic from run/attempt.ts into a new focused module run/attempt.transcript-policy.ts, with accompanying tests. The refactoring is a pure extraction — all parameter values (workspaceDir, modelApi, model) flow through the existing runtimePlanModelContext object, preserving identical runtime behavior.

Confidence Score: 5/5

Safe to merge — pure extraction with no behavior change and tests covering both code paths.

The refactored call in attempt.ts passes runtimePlanModelContext which already holds workspaceDir: effectiveWorkspace, modelApi: params.model.api, and model: params.model — all three values that the original inline code supplied directly. Both the RuntimePlan-wins path and the legacy fallback path are covered by the new tests. No P0/P1 findings.

No files require special attention.

Reviews (2): Last reviewed commit: "refactor: extract attempt transcript pol..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extracts transcript policy resolution from the embedded attempt runner into a focused resolver function with targeted unit tests, as a small “contract-domain split” aligned with the ongoing RuntimePlan work.

Changes:

  • Added resolveAttemptTranscriptPolicy() in a new module to centralize RuntimePlan-first transcript policy resolution with legacy fallback.
  • Updated runEmbeddedAttempt() to use the new resolver instead of inlining the fallback chain.
  • Added tests covering RuntimePlan precedence and legacy (non-RuntimePlan) fallback behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/agents/pi-embedded-runner/run/attempt.ts Replaces inline transcript policy selection with the extracted resolver call.
src/agents/pi-embedded-runner/run/attempt.transcript-policy.ts Introduces the new transcript policy resolver (RuntimePlan-first, legacy fallback).
src/agents/pi-embedded-runner/run/attempt.transcript-policy.test.ts Adds unit tests for resolver precedence and fallback behavior.

@100yenadmin
100yenadmin marked this pull request as draft April 24, 2026 19:20
@100yenadmin
100yenadmin marked this pull request as ready for review April 24, 2026 19:45
@100yenadmin
100yenadmin requested a review from Copilot April 24, 2026 20:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@100yenadmin 100yenadmin changed the title refactor: extract attempt transcript policy resolver [codex] refactor: extract attempt transcript policy resolver Apr 25, 2026
@100yenadmin

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants