Skip to content

[codex] Add transcript repair runtime contracts#71042

Closed
100yenadmin wants to merge 2 commits intoopenclaw:mainfrom
electricsheephq:contract-first/transcript-repair-runtime-contracts
Closed

[codex] Add transcript repair runtime contracts#71042
100yenadmin wants to merge 2 commits intoopenclaw:mainfrom
electricsheephq:contract-first/transcript-repair-runtime-contracts

Conversation

@100yenadmin
Copy link
Copy Markdown
Contributor

@100yenadmin 100yenadmin commented Apr 24, 2026

Summary

Adds the transcript-repair contract rung from RFC #71004. This is test-only: it does not change Pi runtime behavior, Codex app-server behavior, or production transcript repair code.

flowchart TD
  UserTurn["Queued user turn"] --> TranscriptPolicy["OpenClaw transcript repair contract"]
  TranscriptPolicy --> PiMerge["Pi orphan user merge strategy"]
  TranscriptPolicy --> CodexProjection["Codex context projection"]
  PiMerge --> PreparedPrompt["Prepared prompt keeps older user content"]
  CodexProjection --> QuotedContext["Quoted context keeps prior structured/media turns"]
Loading

Files Changed And Why

File Purpose
test/helpers/agents/transcript-repair-runtime-contract.ts Shared text/structured/media/data-URI transcript fixtures.
src/agents/pi-embedded-runner/run/transcript-repair-runtime-contract.test.ts Pi orphan repair and strategy-seam contract rows.
extensions/codex/src/app-server/transcript-repair-runtime-contract.test.ts Codex projection rows for preserving prior structured/media context.

Contract Matrix

Surface Contract rows
Pi orphan repair Text orphan leaf is merged with the queued-user marker.
Pi orphan repair Already-present orphan text is not duplicated.
Pi orphan repair Structured text + media references survive before leaf removal.
Pi orphan repair Inline data URI media is summarized, not embedded into prompt bytes.
Pi strategy seam Active message merge strategy is the single dispatch point and can be replaced for adapter tests.
Codex projection Duplicate trailing current prompt is dropped, while prior structured context remains visible.
Codex projection Media-only prior user history remains represented as omitted media, without data URI bytes.

Known Boundary

Codex coverage is projection-only in this phase. A shared Codex transcript repair strategy belongs in AgentRuntimePlan consumption, not in this test-only PR.

How This Helps The RuntimePlan Work

Transcript repair is OpenClaw-owned policy. These fixtures make payload-shape behavior explicit before the plan centralizes text, structured content, media, and data URI handling.

Reviewer Notes

  • Test-only; no runner rename or transcript code refactor.
  • Captures the audit’s Bug 3 class by making structured/media preservation executable.
  • The Codex side proves current adapter projection behavior, not final shared repair ownership.

Verification

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.agents.config.ts src/agents/pi-embedded-runner/run/transcript-repair-runtime-contract.test.ts
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/codex/src/app-server/transcript-repair-runtime-contract.test.ts
  • ./node_modules/.bin/oxlint --tsconfig tsconfig.oxlint.core.json test/helpers/agents/transcript-repair-runtime-contract.ts src/agents/pi-embedded-runner/run/transcript-repair-runtime-contract.test.ts extensions/codex/src/app-server/transcript-repair-runtime-contract.test.ts
  • git diff --check -- test/helpers/agents/transcript-repair-runtime-contract.ts src/agents/pi-embedded-runner/run/transcript-repair-runtime-contract.test.ts extensions/codex/src/app-server/transcript-repair-runtime-contract.test.ts

Refs #71004
Follows #71009, #71029, #71038, #71039

@100yenadmin 100yenadmin marked this pull request as ready for review April 24, 2026 09:22
Copilot AI review requested due to automatic review settings April 24, 2026 09:22
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 24, 2026

Greptile Summary

This PR adds Phase 1 transcript-repair contract tests covering Pi orphan-user-prompt merging and Codex context projection, with no changes to production code. The test fixtures are accurate, the expected values are correctly derived from production logic (e.g. the 4118-char data-URI count, the `[QUEUED_USER_MESSAGE_MARKER]
...

...join pattern), and theafterEach` restore guard correctly cleans up the strategy override to prevent test pollution.

Confidence Score: 5/5

Test-only change with no production code modifications; safe to merge.

All three new files are test/helper code only. Fixture values match production logic exactly (verified manually), no P0/P1 issues found, and the afterEach cleanup guard prevents strategy-override leakage between tests.

No files require special attention.

Reviews (1): Last reviewed commit: "test: add transcript repair runtime cont..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Phase 1 transcript-repair “runtime contract” coverage (test-only) to lock current Pi orphan-leaf merge behavior and Codex context projection behavior ahead of the RFC #71004 runtime-plan refactor work.

Changes:

  • Introduces shared test fixtures for transcript-repair scenarios (text, structured, inline data URI, media-only history).
  • Adds Pi contract tests for orphan trailing-user prompt merging and the message-merge-strategy seam.
  • Adds Codex contract tests for context-engine projection behavior (dropping duplicate trailing prompt; keeping media-only history as omitted media).

Reviewed changes

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

File Description
test/helpers/agents/transcript-repair-runtime-contract.ts Shared fixtures/constants for transcript-repair contract tests.
src/agents/pi-embedded-runner/run/transcript-repair-runtime-contract.test.ts Pi-side contract tests for orphan-leaf merging and strategy seam.
extensions/codex/src/app-server/transcript-repair-runtime-contract.test.ts Codex-side contract tests for prompt projection and media omission behavior.

Comment thread src/agents/pi-embedded-runner/run/transcript-repair-runtime-contract.test.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Copy link
Copy Markdown
Contributor Author

@steipete gpt 5.4 fixes contract layer

@steipete
Copy link
Copy Markdown
Contributor

Closing as superseded by #71096, which consolidates this contract shard into the single RuntimePlan / Pi-Codex parity review branch.

Codex review note: keeping the individual shard open would split the same contract surface across multiple stale branches now that #71096 carries the combined stack.

@steipete steipete closed this Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling extensions: codex size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants