Skip to content

refactor(ui): share approval validator compilation - #177791

Merged
steipete merged 1 commit into
mainfrom
solid2/w-approval-validators
Oct 19, 2026
Merged

steipete merged 1 commit into
mainfrom
solid2/w-approval-validators

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The generated approval event and replay validators compile the same approval shapes twice and carry generic hashing code for arrays containing only decision strings.

User Impact

No user-visible behavior changes. Accepted and rejected payloads, exported validator names, and lazy loading stay the same. The generated validators contain less code and avoid the temporary array and string hashing used for decision uniqueness.

Why This Change Was Made

Compile both approval entry points in one TypeBox scope, retaining the existing standalone browser output. Use direct Set equality only after the generator proves every unique-item schema is a finite string enum; other schemas keep TypeBox hashing. Import the existing Unicode helper directly at build time to remove its forwarding wrapper from all six generated groups. There are no new browser imports, dependency changes, or changes to canonical schemas.

Affected production files shrink 3,989 → 3,192 lines (−797): generated output 3,647 → 2,802 (−845), generator 342 → 390 (+48). The generator growth owns shared compilation and its schema check; the two approval entry points share their emitted predicates.

Evidence

Check Result
pnpm tsgo:ui Pass
Generated-validator and approval-projection tests, pinned Bun, one worker 28 passed
Canonical schema / merge-base / candidate comparison 10,291 cases agree, including all approval states, sparse decision arrays, and nested malformed values
Other generated groups AST-equivalent after removing the forwarding wrapper and normalizing compiler temporary names
Scoped type-aware lint, formatting, Solid guard Pass
Production Knip Pass
Independent P0–P3 review Clean
Base/head UI build and strict performance check Both pass
Startup JavaScript gzip 326,290 → 326,271 B (−19 B), seven requests
Startup CSS 38,500 B, one request → unchanged

A small validation-only measurement used 20,000 valid checks per sample, five interleaved samples after warm-up. Event median: 96.86 → 10.87 ms (before range 59.54–197.84, after 6.77–18.13). Replay median: 85.86 → 6.67 ms (before range 65.34–215.40, after 6.25–11.51). The host was contended; these measure the validator, not overall UI latency.

No screenshots: this changes generated validation code only, with no rendered markup, CSS, route, host tag, or selector changes. Full UI CI is requested because the validators serve chat approval projections.

Inherited CI failures

CI run 39335100920 fails only these two device fixtures (plus the aggregate gate):

  • Control UI browser platform family with a real Gateway > keeps signed browser identities while rendering fresh and legacy Mac and iPad labels
  • Control UI device alias rename with a real Gateway > persists a Devices-page alias rename through the real Gateway across reload and restart

Both fail with DeviceIdentityStorageError because their fixture identity paths are outside the canonical client credential directory. The same two names fail with the same error on exact merge base d7711afad42b91f356a7cebaa7846b708fd9765e (2 files, 2 failures; default repository runtime, one worker). All ten relevant source/dependency blobs match that base, the CI main parent 23d16def50f0fae3ae4c966631861c44c658e32b, and CI merge b44b9a1ea773d85c151699e3aaa8f751a7a43f8e. Every other selected CI job passed or was intentionally skipped. Landing uses the documented inherited-failure route; these failures are not claimed green.

@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-19T22:30:58.757567Z 8de4e0f 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 gateway Gateway runtime scripts Repository scripts size: XL labels Oct 19, 2026
@steipete
steipete enabled auto-merge (squash) October 19, 2026 22:39
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR shares compilation of approval event and replay validators and removes unnecessary hashing and Unicode forwarding code.

Example: An approval offers allowedDecisions ["allow-once", "deny"].

  • Before: Event and replay validators independently check the same shapes and hash decision strings for uniqueness.
  • After: Both validators share predicates and check uniqueness directly with Set, preserving acceptance and rejection.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source review found no defect; supplied behavior evidence remains limited to reported in-process validation.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; the supplied body reports validator comparisons and focused tests, without a shipped-entry-point artifact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Approval validation ships duplicate predicates and unnecessary generic hashing machinery.
Reason: The maintainer-authored direction yields a concrete production-code reduction while keeping the existing schema and browser-loading contracts.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR meaningfully reduces generated validation code, with no actionable correctness or security defect found.

Priority: P3
Reviewed head: 8de4e0f70aafb908ce05d53f7ad22d3229e3d4e2

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Control UI approval event/replay scenario is supplied; reported validation covers parity comparisons, projection tests, and builds.
Agent review details

How this fits together

The build-time generator converts canonical Gateway schemas into standalone browser validators; chat approval projections consume their boolean results before updating the displayed approval queue.

flowchart LR
  A[Canonical Gateway schemas] --> B[Validator generator]
  B --> C[Shared approval compilation]
  C --> D[Standalone browser validators]
  E[Gateway events and replay] --> D
  D --> F[Session approval projection]
  F --> G[Displayed approval queue]
Loading

Technical review

Best possible solution:

Retain the shared generator implementation and canonical schemas, with the existing exact-head CI gate governing merge readiness.

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

This refactor does not report a broken user flow; duplicate compilation and generic hashing are directly visible in the pinned base source.

Is this the best way to solve the issue?

The change uses the existing generation owner, preserves schemas and consumer boundaries, and removes redundant emitted machinery without introducing runtime state or dependencies.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2ccb5e7b30d8.

Provenance checked

  • Approval validator compilation keeps the original intent (7341e23: Intern repeated approval shapes to reduce generated output while preserving canonical validation and lazy boundaries.)
  • Standalone helpers and browser boundary keeps the original intent (9ff9472: Generate standalone CSP-safe validators so browser boot graphs avoid general-purpose validation libraries.)
  • Snapshot validator output keeps the original intent (cb752df: Intern snapshot metadata within its existing loading boundary, with an explicitly accepted validation-cost tradeoff.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and current main: The introduced diff consolidates the two approval entry points inside the existing generator; fetched main still compiles them separately, so this PR supplies distinct work. (scripts/generate-control-ui-validators.mts:230, 8de4e0f70aaf)
  • Uniqueness and projection boundaries: The canonical unique-item arrays contain finite decision-string unions; generated validators retain enum, length, and deny-presence checks before Set uniqueness, while the unchanged projection owner still matches the selected session. (ui/src/lib/protocol-validators.generated/approvals.js:262, 8de4e0f70aaf)
  • Prior design intent: The merged predecessor refactor(ui): deduplicate generated approval validators #177528 established approval-schema interning while retaining canonical schemas and lazy boundaries; refactor(ui): deduplicate snapshot validator output #177719 separately established snapshot interning, which this PR preserves. (scripts/generate-control-ui-validators.mts:302, 7341e235070a)
  • Pinned compiler contract: The generator directly imports TypeBox compiler APIs, making its contract relevant; version 1.3.36 exports the engine APIs, and Build uses the same external/function reset, stack, context, and function-creation sequence adopted here. (src/schema/build.ts, b18092254d78)
  • Discussion and validation evidence: The full body reports canonical/base/head agreement across 10,291 cases, 28 focused tests, and successful base/head builds; comments supply no additional runtime artifact, and exact-head CI remains pending without a reported failing check. (8de4e0f70aaf)
  • Feature ownership and review policy: Available main history consistently credits Peter Steinberger across the validator generator and subsequent deduplication changes; follow-history reaches unavailable creation-parent objects, but the changed behavior is covered by available commits and predecessor discussions. Root, scripts, and UI guidance were applied, and the checkout remains clean. (scripts/generate-control-ui-validators.mts:260, 9ff9472609c7)

Likely related people:

  • Peter Steinberger: Raw commit 9ff9472 adds scripts/generate-control-ui-validators.mts:189 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 -845, Other +48. Total -797 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 669 1514 -845
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 87 39 +48
Total 7 756 1553 -797

Review metrics

Metric Value Why it matters
Production versus test LOC Production −797 lines; tests unchanged The generator grows by 48 lines to share compilation and constrain the uniqueness optimization, replacing 845 generated lines.

Labels

Label changes:

  • add P3: This is a behavior-preserving code-size and validation-cost improvement without an established user-facing failure.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a behavior-preserving code-size and validation-cost improvement without an established user-facing failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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, 6:42 PM ET / 22:42 UTC.

@steipete
steipete disabled auto-merge October 19, 2026 23:19
@steipete
steipete merged commit eb60042 into main Oct 19, 2026
135 of 141 checks passed
@steipete
steipete deleted the solid2/w-approval-validators branch October 19, 2026 23:57
@steipete

Copy link
Copy Markdown
Contributor Author

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

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. gateway Gateway runtime scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant