Skip to content

refactor(ui): deduplicate generated approval validators - #177528

Merged
steipete merged 2 commits into
mainfrom
solid2/w-deslop-app-lib-2
Oct 19, 2026
Merged

steipete merged 2 commits into
mainfrom
solid2/w-deslop-app-lib-2

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Generated approval validation repeats thousands of lines of checks across union branches, increasing production code and shipped JavaScript.

User Impact

No user-visible behavior change. Approval validation accepts and rejects the same inputs with smaller generated output.

Why This Change Was Made

Intern approval schemas at the existing TypeBox generation boundary so emitted validators share repeated presentation and scope checks. Canonical schemas, exports, validation behavior, CSP guards, and lazy loading boundaries stay unchanged.

This deliberately applies only to approvals. An exploratory all-groups variant slowed history and transcript validation, so those remain inline. TypeBox's public Intern API is experimental and runs only at generation time. Three subsequent generated modules have temporary-variable renumbering from the compiler's shared counter; normalizing only those identifiers produces byte-identical files. No new runtime package or hand-written validator is introduced.

Evidence

Proof / metric Before After
Whole lane scope, physical production LOC 100,678 97,992
Approval validator LOC 4,052 1,366
Approval validator gzip, source module 19,396 B 8,634 B
Generator LOC 331 335
Total changed-file LOC 7,340 4,658
Canonical parity, expanded mutation corpus — 30,858 comparisons, zero mismatches
Existing validator tests, default Bun runtime — 23 passed
UI typecheck (pnpm tsgo:ui) — passed
pnpm ui:build, same checkout/machine passed passed
Startup JS, gzip 324,684 B 324,653 B
Startup CSS requests 1 1
Chat boot JS, gzip 1,449,012 B 1,446,532 B
New-session boot JS, gzip 1,006,253 B 1,006,221 B

The scope census excludes tests, test support, fixtures, and translation catalogs; it includes generated production JS. Authored production scope is 93,147 LOC and does not shrink here: the reduction is in shipped generated validation. The production scope shrinks by 2,686 lines (2.67%); including the generator, this PR is net −2,682 lines, with no test changes. Earlier lane PRs #177473 (−3) and #177478 (+4) make the cumulative lane delta −2,681 lines including this PR.

The requested throwaway duplicate scan hashed normalized 6/8/10-line windows across the scope and identified approval validation as the largest real duplication. No generated-validator entry exists in the max-lines baseline. All Solid refactor-checklist counters in the changed files are zero before and after.

Exploratory warmed validation microbenchmark, nine interleaved pairs, milliseconds per 10,000 validations: valid approvals 31.34 → 32.18 (+2.7%); mixed valid/invalid approvals 103.40 → 70.48 (−31.8%). This is narrow microbenchmark evidence, not a claim about page or streaming latency.

No visual changes; screenshots are not applicable. Full CI is requested because validators have shared consumers. No changelog edit: release notes remain release-owned.

Production Knip, generation reproducibility, focused lint/formatting, and independent review passed. Strict performance comparison passed against the saved base build on the same machine (node --import ./scripts/tsx.mjs scripts/check-control-ui-performance.mts --dist <head-dist> --base-dist <base-dist>). Startup is unchanged within 31 B of build variance; the approval reduction remains behind its existing lazy boundary. No local E2E or broad suite runs; ci:full owns those checks.

CI caught TypeBox’s emitted length !== 0 && some(...) redundancy in the interned approval functions. The generator now includes that rule in its existing approvals-only compiler-output lint exemptions; runtime output remains byte-identical. The required PR context headings were also added after the initial metadata check.

Inherited CI failure: checks-fast-baseline-ratchets in run 39295862393 reports the stale mock-export ledger entry ["extensions/acpx/register.runtime.test.ts","openclaw/plugin-sdk/acp-runtime-backend","85c02528b8c7e95e604ffd08071c631a9dcd2f7600f1bff2dd9817f3c0e49f0f",1]. The identical entry fails on the untouched merge-base tree 2e4260b0158567af08f3cf08bb31ef8d948c0ec9, tested with the supported staged checker using an isolated Git index (pnpm check:test-mock-exports --staged --base 2e4260b0158567af08f3cf08bb31ef8d948c0ec9 --no-merge-base). No source or baseline was changed for that reproduction. The native inherited-failure route will retain this exception; this check is not claimed green.

Final full CI run 39295862393 (attempt 1): all three UI unit shards, nine UI E2E shards, both real-Gateway shards, Control UI performance and security passed. The run has 44 passing jobs and 24 skipped jobs; its only failures are the inherited ratchet and downstream CI gate. Native inherited-failure admission retains the exact checkout, matching base reproduction and unchanged-input evidence.

@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T17:29:18.380129Z acc2e1f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: XL labels Oct 19, 2026
@steipete
steipete enabled auto-merge (squash) October 19, 2026 17:49
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR interns approval schemas during generation so emitted validators share repeated checks.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, minimal generator refactor with source-verified contract preservation and no actionable findings; required CI admission remains unresolved.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored refactor is outside the ordinary contributor proof gate; the body reports parity comparisons and paired production builds, but supplies no browser approval-flow trace.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Repeated generated approval checks increase the JavaScript downloaded for chat.
Reason: The maintainer-directed change removes duplication at the established generation boundary while preserving canonical schemas, exports, and loading boundaries.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-directed refactor reduces generated validation through the existing owner, with no actionable code or security findings.

Priority: P3
Reviewed head: eb2935e3bf38f5ea4a3b6c9af2d1c24b5d0fdd65

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Browser handling of pending, replayed, and terminal approvals was not demonstrated; supplied validation covers schema parity and production builds.
Agent review details

How this fits together

Canonical Gateway schemas enter the build-time generator, which emits standalone browser validators used to admit approval events and replays into the chat approval queue.

flowchart LR
  Schemas[Canonical Gateway schemas] --> Generator[Validator generator]
  Generator --> Intern[Approval schema interning]
  Intern --> Validators[Standalone browser validators]
  Events[Gateway approval events and replays] --> Validators
  Validators --> Projection[Chat approval projection]
  Projection --> Queue[Displayed approval queue]
Loading

Technical review

Best possible solution:

Retain approval-only interning in the existing generator and resolve CI admission without adding unrelated repairs.

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

No product bug is claimed; the base source visibly repeats approval presentation and scope validation across union branches.

Is this the best way to solve the issue?

The change uses the existing canonical-schema generator and TypeBox's deduplication facility, preserving other groups inline and avoiding handwritten validation or additional ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 89e77376ccb1.

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 9ff9472 adds scripts/generate-control-ui-validators.mts:229 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9ff9472609c7; files: scripts/generate-control-ui-validators.mts)

PR surface

Source -2686, Other +4. Total -2682 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 767 3453 -2686
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 6 2 +4
Total 5 773 3455 -2682

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a focused internal refactor that reduces shipped generated JavaScript without an intended behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 19, 2026, 1:54 PM ET / 17:54 UTC.

@steipete
steipete disabled auto-merge October 19, 2026 17:55
@steipete
steipete merged commit 7341e23 into main Oct 19, 2026
132 of 137 checks passed
@steipete
steipete deleted the solid2/w-deslop-app-lib-2 branch October 19, 2026 18:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
)

* refactor(ui): deduplicate generated approval validators

* fix(ui): allow compiler-generated approval length guards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui ci:full Keep ordinary native-locale CI selection on the next PR run. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant