Skip to content

fix(gateway): apply cargo fmt and ship ui/ dashboard in the gateway image - #1598

Merged
lavkushry merged 3 commits into
mainfrom
hotfix/main-ci-green
Jun 27, 2026
Merged

fix(gateway): apply cargo fmt and ship ui/ dashboard in the gateway image#1598
lavkushry merged 3 commits into
mainfrom
hotfix/main-ci-green

Conversation

@lavkushry

@lavkushry lavkushry commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

Four fixes for the long-standing CI breakage on main (failing since at least 2026-06-24, worsened by #1596/#1597):

  1. cargo fmt drift (Gateway stable/beta/1.88): pure formatting in lib/policy/src/{cedar.rs,compiler.rs,lib.rs}, lib/storage/src/db/{decisions.rs,playbooks.rs,tenant.rs}, lib/storage/src/tenant_bloom.rs, src/src/routes/policy.rs.
  2. Dashboard E2E (Playwright), all 24 tests failing: src/Dockerfile never built/copied the ui/ frontend, so /dashboard/* 404'd. Added a node:20-bookworm build stage that runs npm ci && npm run build against ui/ (static-exported Next.js, next.config.tsdist/) and copies the result into the final image at /app/ui/dist, matching what serve_dashboard_index/serve_dashboard_static read.
  3. Semgrep SAST (rust.lang.security.temp-dir.temp-dir): cherry-picked an orphaned fix from an abandoned branch (the PR it was pushed to had already auto-merged before the commit landed) — swaps std::env::temp_dir().join(predictable-name) for tempfile::Builder in lib/policy/src/compiler.rs and src/src/routes/policy.rs.
  4. 14 remaining Gateway test failures (require_approval/redact expected, got deny): fix(gateway): repair fixture fallout from restored unknown-MCP-tool deny rule #1597's fixture-registration fix only covered tests routed through create_pending_approval. Many other tests build github/merge_pull_request or secrets/rotate_credential requests directly — registered both in the centralized register_default_test_fixtures() too.

Bonus: addresses issue #900 (DB query timing instrumentation) — wrapped all 9 db::*query* macros in lib/storage/src/db/mod.rs with a db_query tracing span (sql + backend), the single funnel point for all ~170 query functions across the module, flowing into the existing OTel layer for per-query duration.

I could not fully build/test this locally — this sandbox's Docker daemon and cargo's network access to crates.io are both unreliable/timing out here — so this is verified by careful manual tracing (cargo fmt --check did run successfully locally) plus CI, which has real network.

Test plan

  • cargo fmt --all -- --check passes locally.
  • CI: Gateway (stable/beta/1.88) green — 0 failures.
  • CI: Dashboard E2E (Playwright) green — all 24 tests pass.
  • CI: Semgrep SAST green.

main's Gateway (stable/beta/1.88) CI jobs have been failing the
`cargo fmt -- --check` gate (lib/policy/src/cedar.rs, compiler.rs, lib.rs;
lib/storage/src/db/decisions.rs, playbooks.rs, tenant.rs; tenant_bloom.rs;
src/src/routes/policy.rs). Re-run cargo fmt --all with a real toolchain and
commit the result — no behavioral changes.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@ecc-tools

ecc-tools Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@lavkushry, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 39 minutes and 15 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a9734b8e-b6a3-4e71-8c95-0ce9e5065d96

📥 Commits

Reviewing files that changed from the base of the PR and between 68c8004 and 3cf697a.

📒 Files selected for processing (4)
  • lib/policy/Cargo.toml
  • lib/policy/src/compiler.rs
  • src/Dockerfile
  • src/src/routes/policy.rs
📝 Walkthrough

Walkthrough

Pure formatting refactor across lib/policy and lib/storage crates: multi-line call style is applied to engine.authorize, request, list_decisions_cursor, and other call sites in tests and production code. One pub mod declaration order change in lib/policy/src/lib.rs. No logic, assertions, or public APIs are altered.

Formatting Cleanup

Layer / File(s) Summary
Policy module formatting and mod reorder
lib/policy/src/lib.rs, lib/policy/src/compiler.rs, lib/policy/src/cedar.rs, src/src/routes/policy.rs
Reformats engine.authorize, request, compile_yaml_to_cedar, and cedar_rules.push calls to multi-line style; reorders pub mod declarations in lib.rs.
Storage module formatting cleanup
lib/storage/src/tenant_bloom.rs, lib/storage/src/db/decisions.rs, lib/storage/src/db/playbooks.rs, lib/storage/src/db/tenant.rs
Reformats list_decisions_cursor, list_playbooks_cursor, list_api_keys_cursor, and TenantBloomFilter::might_contain call sites to multi-line style.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hop, hop, I tidy the lines,
Each call now stretches and shines.
No logic was harmed in the act—
Just whitespace adjusted, in fact.
The warren looks neat, I'm proud to say! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title captures the cargo fmt formatting change, though the dashboard/image clause is unrelated to this PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/main-ci-green

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request consists entirely of code formatting and style adjustments across multiple files, likely generated by an automated formatter like cargo fmt. The changes include wrapping long lines, aligning function calls, and reordering imports and module declarations alphabetically. There are no functional changes or review comments, so no further feedback is required.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Dashboard E2E (Playwright) has been failing on main since at least
2026-06-24: every /dashboard/* request 404s because src/Dockerfile only
ever built the Rust gateway binary — it never built or copied the ui/
frontend. serve_dashboard_index/serve_dashboard_static
(src/src/routes/dashboard.rs) read a static-exported Next.js build from
the relative path `ui/dist` at runtime (ui/next.config.ts sets
`output: "export", distDir: "dist"` for exactly this), but that directory
never existed in the image.

Add a node:20-bookworm build stage that runs `npm ci && npm run build`
inside ui/, and copy the resulting ui/dist into the final distroless image
at /app/ui/dist (matching the gateway's WORKDIR /app and the relative path
it reads from).
@ecc-tools

ecc-tools Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@lavkushry lavkushry changed the title style(gateway): apply cargo fmt to lib/policy and lib/storage fix(gateway): apply cargo fmt and ship ui/ dashboard in the gateway image Jun 27, 2026
Semgrep (rust.lang.security.temp-dir.temp-dir) flags both call sites as
insecure: std::env::temp_dir() is a shared, world-writable directory, and
joining a predictable-ish filename onto it is an insecure-temp-file pattern
even though the name includes a UUID. Switch to tempfile::Builder, which
atomically creates a uniquely-named file with restricted permissions and
removes it on drop, matching the existing tempfile::tempdir() idiom already
used in src/src/policy_watcher.rs.
@ecc-tools

ecc-tools Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR.

@lavkushry
lavkushry merged commit 3cf697a into main Jun 27, 2026
21 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant