Skip to content

refactor(codex): deduplicate generated protocol schemas - #117382

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-codex-schema-owner-0801-2d45
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-codex-schema-owner-0801-2d45

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • factor definitions repeated across the eight selected Codex app-server JSON schemas into one generated draft-07 definitions document
  • keep each compact root standards-valid with relative $ref values, and materialize only its reachable closure before the existing TypeBox validator compilation
  • make sync/check generation own compaction, exact source reconstruction, conflict rejection, and deterministic output

Root cause and owner

The committed OpenClaw mirror copied the upstream exporter standalone-file shape verbatim. That is correct for external standalone exports, but in this private generated mirror it repeated 191 definition occurrences even though only 55 unique definition bodies exist. The sync/generation boundary owns that duplication; runtime validation owns resolving the compact representation before compilation.

The canonical fix leaves the upstream exporter and dependency pin untouched, removes repeated per-root definitions blocks from the private mirror, and teaches both generator verification and the validator owner how to reconstruct the exact source closure.

Contract evidence

Pinned Codex source: rust-v0.146.0 / e363b08.

The three exporter/fixture files above are byte-identical in the inspected sibling Codex checkout at 07490c75234ed3c63291a8eb7629f04f647038fa; protocol sources outside them differ, so all live generation proof used the exact pinned tag.

Pinned TypeBox source: 1.3.6 / 41f0b1d.

Therefore the plugin materializes the exact reachable shared definitions and restores local refs before the unchanged one-argument compile call.

Consumer audit found no $id or external refs in the eight sources, no same-name definition conflicts, no browser/public/docs imports, and no raw-path consumers. Seven roots are private validator imports; GetAccountResponse is generator/check-only. Published @openclaw/codex artifacts bundle schema data into JavaScript and omit raw JSON.

Size

  • generated schemas: 9,662 -> 3,202 lines, -6,460 lines
  • total diff: +3,264 / -9,344, net -6,080 lines
  • runtime handwritten delta: +98 / -7; required to materialize the dependency contract before compile
  • tests and generator tooling are counted separately from generated output

Proof

  • exact-tag OPENCLAW_CODEX_REPO=<rust-v0.146.0> pnpm codex-app-server:protocol:check: passed; every compact root expands to its upstream schema
  • two fresh exact-tag syncs: identical tree hash f01d7f3fcfde04677ae8ac992b6797ce24738ac2ac61548e29ef45ca3aef7dc1
  • focused generator + validator tests: 36/36 passed
  • full pnpm test extensions/codex: 147 files, 3,217/3,217 tests passed
  • pnpm build: passed, including Control UI/browser build
  • scripts/plugin-npm-publish.sh --pack-dry-run extensions/codex: passed; 50 package entries, zero raw JSON files; representative formerly duplicated definition text occurs once in built JavaScript
  • remote pnpm check:changed: passed after the final type assertion fix
  • .agents/skills/autoreview/scripts/autoreview --mode local --engine codex --model gpt-5.6-sol --thinking xhigh --stream-engine-output: clean, no accepted/actionable findings, confidence 0.96

No dependency, protocol version, public API, plugin manifest, browser API, config, persistence, or package file contract changes.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts extensions: codex size: XL maintainer Maintainer-authored PR labels Aug 1, 2026
@steipete
steipete marked this pull request as ready for review August 1, 2026 11:44
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 1, 2026, 7:57 AM ET / 11:57 UTC.

ClawSweeper review

What this changes

The PR moves repeated Codex app-server JSON Schema definitions into one generated shared document, then restores each runtime validator’s reachable local definitions before TypeBox compiles it.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this PR open for maintainer review. The implementation is coherent from the inspected OpenClaw generator and validator paths, but this environment cannot complete OpenClaw’s mandatory direct Codex and TypeBox dependency-contract pass: ../codex and installed TypeBox source are absent, and GitHub DNS resolution failed. Likely related people: steipete (high confidence).

Priority: P3
Reviewed head: 521db22bbc2577e51258c3948adaad7d7b5b6477
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has a coherent owner-boundary design and detailed claimed validation, but the mandatory direct Codex and TypeBox contract pass could not be independently completed in this environment.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This maintainer-labelled PR is exempt from the external-contributor proof gate; its body nevertheless records generator, validator, package, build, and changed-check evidence that should be independently repeated where the required dependency sources are available.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-labelled PR is exempt from the external-contributor proof gate; its body nevertheless records generator, validator, package, build, and changed-check evidence that should be independently repeated where the required dependency sources are available.
Evidence reviewed 5 items Current runtime owner: Current main compiles each generated schema with a one-argument TypeBox Compile call, and its exported validators feed thread start/resume, turn, model, notification, and tool-call paths.
Proposed materialization boundary: The PR collects external shared-definition references, follows nested local definition references, selects the reachable closure, and rewrites external references back to local definitions before validator compilation.
Generation and reconstruction checks: The PR’s generator/check path compacts selected upstream schemas, compares compact local output, then expands each root for exact-source reconstruction; its focused test covers reconstruction and same-name conflict rejection.
Findings None None.
Security None None.

How this fits together

The Codex plugin mirrors selected Codex app-server schemas during a sync step, then uses those schemas to validate app-server responses that drive thread, turn, model, and tool-call handling. This PR changes the generated mirror’s storage shape while preserving the local schema shape consumed by the validator.

flowchart LR
  Upstream[Codex app-server schemas] --> Sync[OpenClaw schema sync]
  Sync --> Mirror[Generated schema mirror]
  Mirror --> Materialize[Validator restores reachable definitions]
  Materialize --> Compile[TypeBox validator compilation]
  Compile --> Runtime[Codex thread and turn handling]
Loading

Decision needed

Question Recommendation
Is the PR-body exact-tag generation and validator evidence sufficient to land this runtime schema refactor, or should a reviewer first repeat it with the mandated local ../codex source and TypeBox implementation available? Repeat dependency proof before merge: Use an environment containing the pinned Codex source and TypeBox implementation to repeat the compact/expand and validator checks against the merge result.

Why: Repository policy explicitly forbids a Codex verdict without direct sibling-source inspection, which this read-only environment cannot perform; deciding whether existing contributor evidence substitutes for that unavailable check is maintainer intent.

Before merge

  • Add real behavior proof - Not applicable: This maintainer-labelled PR is exempt from the external-contributor proof gate; its body nevertheless records generator, validator, package, build, and changed-check evidence that should be independently repeated where the required dependency sources are available.
  • Resolve merge risk (P1) - This refactor changes the schema materialization immediately before TypeBox compilation for runtime thread, turn, model, notification, and tool payloads; an incomplete reference-closure or upstream-reference mismatch could reject valid Codex responses at runtime.
  • Resolve merge risk (P1) - The branch is behind current main, and the required direct Codex/TypeBox contract inspection could not be repeated in this environment, so the claimed exact-tag validation cannot be independently confirmed here.
Agent review details

Security

None.

PR surface

Source -6369, Tests +85, Other +204. Total -6080 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 9 2964 9333 -6369
Tests 1 85 0 +85
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 215 11 +204
Total 13 3264 9344 -6080

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: scripts/check-codex-app-server-protocol.ts, serialized state: scripts/lib/codex-app-server-protocol-source.ts, serialized state: scripts/sync-codex-app-server-protocol.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Reconfirm the validator contract (recommended)
    Before merge, repeat the pinned Codex exporter and TypeBox resolution checks plus focused validator proof against the merge result, because a bad reference closure would make valid app-server responses fail validation.
  2. Accept existing evidence
    Maintainers may accept the PR-body exact-tag proof if they judge its documented source and validation record sufficient for this internal generated-data refactor.
  3. Pause the compaction
    Keep the standalone generated schemas if the dependency-level runtime contract cannot be independently reconfirmed before the desired merge window.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Run the pinned Codex exporter/reconstruction and focused Codex validator checks against the final merge result; attach redacted terminal output.

Technical review

Best possible solution:

Repeat the exact-tag upstream exporter and TypeBox contract check in an environment with the required sibling Codex checkout, then validate the resulting merge commit’s generator reconstruction and Codex plugin validator paths before landing.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR refactors generated schema storage rather than reporting a user-visible defect. The relevant after-change proof is reconstruction plus live validator compilation, which cannot be independently rerun here because required dependency sources are unavailable.

Is this the best way to solve the issue?

Unclear: the compact-and-materialize design matches the inspected OpenClaw owner boundaries, but it needs the mandatory direct Codex exporter and TypeBox resolver review before it can be called the best safe solution.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3777f009d0d6.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-labelled PR is exempt from the external-contributor proof gate; its body nevertheless records generator, validator, package, build, and changed-check evidence that should be independently repeated where the required dependency sources are available.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P3: The PR is a generated-schema storage refactor rather than a reported user-facing regression, although its runtime validator boundary needs careful review.
  • merge-risk: 🚨 availability: The diff changes schema preparation immediately before TypeBox validates live Codex app-server payloads, so a reference-resolution mismatch could make normal sessions fail.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-labelled PR is exempt from the external-contributor proof gate; its body nevertheless records generator, validator, package, build, and changed-check evidence that should be independently repeated where the required dependency sources are available.

Evidence

What I checked:

  • Current runtime owner: Current main compiles each generated schema with a one-argument TypeBox Compile call, and its exported validators feed thread start/resume, turn, model, notification, and tool-call paths. (extensions/codex/src/app-server/protocol-validators.ts:37, 3777f009d0d6)
  • Proposed materialization boundary: The PR collects external shared-definition references, follows nested local definition references, selects the reachable closure, and rewrites external references back to local definitions before validator compilation. (extensions/codex/src/app-server/protocol-validators.ts:42, 521db22bbc25)
  • Generation and reconstruction checks: The PR’s generator/check path compacts selected upstream schemas, compares compact local output, then expands each root for exact-source reconstruction; its focused test covers reconstruction and same-name conflict rejection. (scripts/check-codex-app-server-protocol.ts:489, 521db22bbc25)
  • Current ownership provenance: The current validator compile boundary and protocol-source module date to Peter Steinberger’s recent Codex validation work, identifying the same area owner for review routing. (extensions/codex/src/app-server/protocol-validators.ts:37, 51c41c25c8c3)
  • Required dependency evidence unavailable: OpenClaw policy requires direct inspection of sibling ../codex for a Codex verdict. That checkout does not exist here; the installed TypeBox source is also absent, and attempted promisor retrieval could not resolve GitHub.

Likely related people:

  • steipete: Peter Steinberger authored the current-main commits that introduced the validator compilation boundary and protocol source module, and also authored this proposed refactor. (role: recent validator and protocol-generation contributor; confidence: high; commits: 51c41c25c8c3, cb16d739cfda, 521db22bbc25; files: extensions/codex/src/app-server/protocol-validators.ts, scripts/lib/codex-app-server-protocol-source.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Repeat the exact pinned Codex exporter and TypeBox reference-resolution review in an environment with ../codex available.
  • Refresh the review against the current merge result after the branch catches up with main.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-01T11:51:01.470Z sha 521db22 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 1, 2026
@steipete
steipete merged commit 8738fe1 into main Aug 1, 2026
189 of 205 checks passed
@steipete
steipete deleted the codex/goal100k-codex-schema-owner-0801-2d45 branch August 1, 2026 12:32
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

extensions: codex maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant