Repository navigation
chore: e2e/test tooling, opengrep SAST gate, and package cleanup - #1883
Conversation
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
…shared Remediation pass over PR #1883 after merging main (multi-agent self-review + CodeRabbit). All findings triaged; `bun run check` is green (lint + typecheck + test, 40/40 turbo tasks). Critical (build-breaking): - Repair services/{platform,web,docs} Dockerfiles + .dockerignores: drop COPY of deleted/never-created workspaces (agent_adapters, mocks, tale_daemon, tests/) and add tools/opengrep so `bun install` resolves the workspace graph. High / config: - Remove committed per-worker auth session jars (e2e .auth/*.json) and the generated qa-run-org scaffold; fix services/platform/.gitignore for the tests/e2e/ path so they stay ignored. - docker:test smoke test: drop removed rag/crawler services, add knowledge-db. - proxy Caddyfile: drop orphaned /metrics/{rag,crawler} routes. - Root workspaces: tools/cli|plop|opengrep -> tools/* (so generated tools are real workspaces); trivy ignorefile -> .trivyignore.yaml; issue-labeler map realigned to the rewritten issue-template service options. - Wire the pre-ingestion secret scanner into rag indexDocument (was implemented + tested but never called) — credential-bearing uploads are now rejected. - Restore organizationId forwarding in the web fetch_and_extract tool (the in-process migration dropped it, disabling sandbox JS-rendering). Centralization (single source of truth): - Replace 6 verbatim @tale/shared copies under convex/lib/knowledge (~800 lines) with thin re-export shims; align @tale/shared postgres to 3.4.7 and drop .ts import extensions so the shared package typechecks cleanly from consumers. Daemon hardening (tools/cli): type-guarded config parsing, permissionCeiling + server timeoutMs validation, temp-dir cleanup, opencode permission-mode warning, and non-ENOENT logging in the adapter probe (no more silent catch). E2E (best of both): port main's net-new scenarios onto the new harness — +22 tests across 14 specs plus a new conversations.spec.ts (knowledge add-website, agent-editor webhook/delegation/metrics tabs, governance usage/trash/feedback, 404, anonymous-redirect, dialog focus-trap, mobile chat/list, …). Suite parses to 106 tests / 29 files via `playwright test --list`. Misc: provider model picker shows human-readable fetched names; rewrite the @tale/shared README (was the old Python package's); fix two silent catches (crawler/web.ts, stress/poll.ts) and stale rag/crawler comments.
6b7feb7 to
4a8576f
Compare
edf6ec9 to
3e73b5f
Compare
CI failure triage (run 27630885856 / e2e run 27630888096)1. Bun audit — BLOCKING ✅ fixed
2. Playwright (platform 1,2,6,7 / 8) — advisory, non-blocking (infra flake)
|
Update — additional fix for the e2e cold-start flakeReproduced the shard failures locally and found a deterministic component behind the broad cascade (the org-wizard Fix: The residual 1s-function-timeout starvation on the 4-vCPU runner remains an advisory infra constraint (the e2e job is |
…test rewrite Adds the shared e2e harness and test tooling, the opengrep SAST gate, the knowledge package and DB migration wiring, the @tale/mocks OpenAPI gateway, and assorted package/CI cleanups. Includes the chat error-display refactor (artifact pills) reconciled with main's ChatErrorDisplay. CI hardening for the e2e suite on the 4-vCPU runner: - serve a prebuilt dist/ via 'vite preview' instead of the dev server to end the on-the-fly transpile CPU load that starved Convex into 1s-timeout flakes (shared Convex proxy, configurePreviewServer env/Accept-Language/base-href injection, serve-status/branding-images/canvas-preview registration, TALE_E2E_SERVE_BUILD in dev.ts + e2e.yml) - run e2e shards at 1 worker to further reduce Convex starvation - reload-and-retry the seeded-org scaffold gate to fix cold-start flake Security/deps: - bump hono to 4.12.25 to clear high CORS advisory (GHSA-88fw-hqm2-52qc) - suppress postgres-insecure-sslmode false positive on the loopback dbmate URL (TLS adds no security across 127.0.0.1; the only SAST finding lacking an inline suppression)
598524f to
3f499f4
Compare
The platform E2E suite was advisory (continue-on-error) because the chat
scenarios flaked on the 4-vCPU CI runner: the local Convex backend's hard 1s
function-execution timeout was blown by the flood of auth-laden queries fired
at chat mount. The dominant per-query cost is cross-component Better Auth
round-trips inside the RLS wrappers.
Each wrapped query eagerly resolved BOTH the caller's organizations AND their
team IDs, but only a handful of team-scoped tables (agentBindings, documents,
promptTemplates, promptCategories) ever consult team IDs. Resolve team IDs
lazily and memoize them inside rlsRules so the cross-component team lookup runs
only when a team-scoped row policy actually fires — halving the concurrent
cross-component load for the many non-team queries at chat mount.
- request_auth_cache no longer fetches/returns userTeamIds
- queryWithRLS / mutationWithRLS / zQueryWithRLS / zMutationWithRLS pass only
{ user, userOrganizations }; teams resolve lazily in rlsRules
- rlsRules gains a memoized resolveTeamIds() awaited only in team-scoped rules
- regression test pins the laziness + memoization + prefetch behaviour
With the per-query load back under the 1s budget, drop continue-on-error from
the E2E jobs: the suite is now strict on PRs, nightly, and manual runs.
… tests Wire test:browser into turbo + a dedicated CI job so *.browser.test.tsx files (real-Chromium component tests, no backend/build/stack) run in CI. Previously test:browser ran nowhere, orphaning canvas-preview-shell.browser.test.ts. This lane is the CI home for UI assertions jsdom cannot fake (real layout, getBoundingClientRect, React Flow geometry, Clipboard API).
- export dialog, message-info dialog, composer mode menu: client-only UI with no real backend/routing/streaming seam -> jsdom component tests (mock Convex hooks), deleted from chat-features.spec.ts. - keyboard 'Escape closes dialog': redundant, already covered by form-dialog.test.tsx (Escape -> onOpenChange(false)); deleted. chat-features.spec.ts slimmed 6 -> 3 (feedback RBAC round-trip, save-prompt persist seam, selection->Quote layout stay e2e).
Wholesale moves (e2e test deleted, faithful component test added): - settings/skills page render + upload affordance -> skills-table.test.tsx - governance DSAR & legal-hold dialog open/close -> file-request-dialog / legal-hold-dialog .test.tsx - governance audit-logs table+tabs, usage analytics cards -> audit-logs-page / usage-metrics-page .test.tsx - validation create-project & create-team dialog gating -> project-create-dialog / team-create-dialog .test.tsx - keyboard command-palette shortcut -> chat-header.test.tsx Bonus component coverage added but e2e KEPT (real seam): project-secrets (encrypt/store/read round-trip, no convex test), automation create/delete (coupled spec setup/teardown + real install/navigate/delete). Full test:ui suite green (308 files / 2393 tests).
… tier (batch 2) - agent-editor webhook-tab + metrics-tab render-only smokes -> agent-webhook-section / agent-metrics-scorecard .test.tsx (pure empty-state render); deleted from e2e. - chat-advanced assistant copy action -> message-bubble.test.tsx (mock navigator.clipboard, assert writeText with the reply); deleted from e2e. - reasoning disclosure expand: extended message-thought-header.test.tsx with an a11y/expand check (bonus); the chat-scenarios reasoning e2e is KEPT (it guards collapsed-during-real-streaming, a flagged behavior the static component test can't reproduce). agent-editor delegation tab stays e2e (React Flow needs real layout).
The pure-UI smokes moved to the jsdom test:ui and Chromium test:browser lanes, leaving ~91 residual e2e tests across 29 specs. Per-shard cost is dominated by the fixed boot (prod build + Chromium + Convex + Vite preview + @tale/mocks), and each shard runs a single worker, so fewer shards cut stack boots (~37%) without changing the 4-vCPU starvation profile. ~18 tests/shard keeps each job well inside the 25-min timeout.
…l load findByRole returns the combobox once the dialog enters the a11y tree, but the Radix open transition can lag a tick behind on saturated parallel workers, so a synchronous toBeVisible() raced (~1 in 3 full-suite runs). Poll visibility via waitFor + generous timeouts. Verified green across 5 consecutive full test:ui runs (2400/2400).
…s to component tiers (batch 3) Moved 17 more e2e tests to jsdom or real-Chromium component tests (e2e 91 -> 74): jsdom (test:ui): - knowledge entity CRUD UI: customers / products / knowledge-entries (vendors stays e2e as the real CRUD round-trip proof); add-website dialog render - settings: org-name render, providers list + detail drawer - governance: trash + feedback render-only pages - automation: triggers-tab render; validation: create-agent gating - preferences: user/account menu structure; chat: agent picker (agent-selector) - list-behaviors: DataTable client-side search / no-results (incl. i18n keys) / pagination -> customers-table.test.tsx; list-behaviors.spec.ts deleted real Chromium (test:browser): - keyboard focus-trap (Radix), agent-editor organigram (React Flow layout), chat selection->Quote (real getBoundingClientRect) Config: exclude *.browser.test.tsx from the jsdom (test:ui / client) projects so they only run in the browser lane; gitignore vitest browser artifacts. CI: drop E2E shards 5 -> 4 (74 residual tests, ~18/shard, well inside timeout). Gates green: test:ui 2431, test:browser 6, tsc 0, e2e lint clean, 74 tests collect.
Capture the URL.createObjectURL mock in a local variable instead of asserting on the unbound URL.createObjectURL reference.
Adaptive-header content (project/page titles, breadcrumb leaf) renders twice — once in the desktop strip (`hidden md:flex`) and once in the `md:hidden` mobile nav slot, which is first in the DOM. On the desktop e2e viewport the mobile copy is hidden, so a bare `.first()` pinned the hidden element and `toBeVisible()` failed. Filter those locators to the visible (desktop) instance, matching the repo's existing convention. Also make the preferences account-menu trigger locale-robust: the language test switches the UI to German mid-flow, so match either locale's `manageAccount` label instead of pinning the English string (which stopped matching once the app rendered in German and timed out). Fixes the projects, navigation (rail-nav + breadcrumb) and preferences (German language) e2e failures.
#1883 ported PDF text extraction from PyMuPDF to pdfjs-dist 5.x, which does not run in the Convex node-action runtime for two reasons: 1. pdfjs polyfills DOMMatrix/ImageData/Path2D by `require("@napi-rs/canvas")`, a NATIVE module Convex does not ship to the action runtime — a bundled action is extracted to /tmp/.../modules with no native node_modules (verified: a pure-JS externalPackage like `postgres` resolves there, a .node addon does not). So every PDF threw `DOMMatrix is not defined`. 2. With that fixed, pdfjs's fake worker dynamically imports './pdf.worker.mjs', which is absent from the bundle → "Setting up fake worker failed". Fix is runtime-agnostic and bundles into the action (no native dep, no externalPackages): - pdfjs_dom_polyfill.ts installs a pure-JS DOMMatrix (correct 2D affine) plus inert ImageData/Path2D on globalThis BEFORE pdfjs loads. pdfjs only sets its own globals when absent, so ours win and the native require is skipped. We never rasterize (text per page; embedded image bytes go to the Vision API), so the stubs suffice. - loadPdfjs pre-imports pdf.worker.mjs and exposes it as globalThis.pdfjsWorker; PDFWorker._setupFakeWorkerGlobal then uses its WorkerMessageHandler in-process and skips the missing-file import. Verified e2e against the live deployment: rag/documents:upload of a real PDF indexes ("1 chunks", success: true) with no DOMMatrix or fake-worker error.
Nothing bundled imports canvas — it predates jsdom's externalization (#1883), and the CLI never listed it in the uploaded nodeDependencies, so the entry only made link-convex-externals link a package the bundler never resolves.
Summary
Tooling and CI hardening pass across the monorepo, plus dead-package removal.
__tests__/), move suites under a consistenttests/layout, and align vitest configs and scaffolding templates across packages and services.security.yml), with.opengrepignoreexclusions for generated code, templates, and test fixtures.packages/knowledgeandpackages/telemetrypackages.Notes
secret_scanner.test.ts) are exempt from SAST via.opengrepignore; the pre-commit hook passes staged files explicitly, so those fixture lines additionally carry inlinenosemgrepsuppressions.Testing
bun run check