Skip to content

chore: e2e/test tooling, opengrep SAST gate, and package cleanup - #1883

Merged
yannickmonney merged 15 commits into
mainfrom
feat/tooling-e2e-viteplus-opengrep
Jun 17, 2026
Merged

yannickmonney merged 15 commits into
mainfrom
feat/tooling-e2e-viteplus-opengrep

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Tooling and CI hardening pass across the monorepo, plus dead-package removal.

  • Test harness standardization — colocate unit tests next to their sources (drop __tests__/), move suites under a consistent tests/ layout, and align vitest configs and scaffolding templates across packages and services.
  • Shared e2e tooling + container test rewrite — introduce the shared e2e harness and rework the container test setup (compose files, turbo pipeline, knip config, workspace resolution).
  • Opengrep SAST gate — pinned, vendored opengrep runner wired into pre-commit (fast, staged-only, local rules) and CI (full enforcing scan via security.yml), with .opengrepignore exclusions for generated code, templates, and test fixtures.
  • Package cleanup — remove the unused packages/knowledge and packages/telemetry packages.
  • Misc — plop/cli template updates, shared logging setup, README/docs and workflow refreshes.

Notes

  • Test fixtures that intentionally contain fake secrets (e.g. secret_scanner.test.ts) are exempt from SAST via .opengrepignore; the pre-commit hook passes staged files explicitly, so those fixture lines additionally carry inline nosemgrep suppressions.

Testing

  • bun run check
  • Pre-commit opengrep scan passes (0 findings).

@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@yannickmonney yannickmonney changed the title ci: add shared e2e tooling, opengrep sast gate, container test rewrite chore: e2e/test tooling, opengrep SAST gate, and package cleanup Jun 16, 2026
yannickmonney added a commit that referenced this pull request Jun 16, 2026
…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.
@yannickmonney
yannickmonney force-pushed the feat/tooling-e2e-viteplus-opengrep branch from 6b7feb7 to 4a8576f Compare June 16, 2026 10:09
@yannickmonney yannickmonney reopened this Jun 16, 2026
@yannickmonney
yannickmonney force-pushed the feat/tooling-e2e-viteplus-opengrep branch from edf6ec9 to 3e73b5f Compare June 16, 2026 14:34
@yannickmonney

Copy link
Copy Markdown
Contributor Author

CI failure triage (run 27630885856 / e2e run 27630888096)

1. Bun audit — BLOCKING ✅ fixed

  • What: bun audit --prod --audit-level=high gated on a high advisory: hono <4.12.25 — CORS middleware reflects any Origin with credentials when origin defaults to the wildcard (GHSA-88fw-hqm2-52qc). Pulled transitively via @tale/platform, @modelcontextprotocol/sdk, convex-helpers.
  • Fix: bumped hono 4.12.21 → 4.12.25 in root + services/platform package.json (+ lockfile). bun audit --prod --audit-level=high now exits 0.

2. Playwright (platform 1,2,6,7 / 8) — advisory, non-blocking (infra flake)

  • What: shards failed with the backend flooding Function execution timed out (maximum duration: 1s) across many queries (listConversationsPaginated, getAccountBootstrap, listFolders, …), plus a few ECONNRESET. Surface symptom in shard 1 was the org-wizard helper (helpers/auth.ts:118) not finding the Skip button — a downstream effect of the org-create call timing out.
  • Root cause: CPU starvation on the 4-vCPU CI runner. Vite + the convex-local-backend + the mock gateway + 2 Playwright workers all contend; the convex backend's 1s function-execution timeout is a hard default in the binary (spawned via npx convex dev, anonymous mode), so under contention reads exceed 1s and the page strands. These specs pass locally at low worker counts.
  • Why not blocking: the platform e2e job is continue-on-error: ${{ github.event_name == 'pull_request' }} — advisory during burn-in. It annotates red but never gates the PR.
  • Action: re-running after the hono push to reconfirm it's transient, not a regression.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Update — additional fix for the e2e cold-start flake

Reproduced the shard failures locally and found a deterministic component behind the broad cascade (the org-wizard skipButton / seeded-agent failures): the agents list loads via a non-reactive Convex action (file_actions:listAgents), which fires once on mount. On a cold backend the first org finishes scaffolding after that fire, so the seeded E2E Assistant row never materializes and nothing re-invalidates the empty list — and waitForSeededOrg (the gate every worker's org fixture awaits) only did a single load.

Fix: waitForSeededOrg now reload-and-retries (4× / 20s each) so a later attempt re-fires the action once scaffolding lands, instead of staking the whole suite's bootstrap on winning a cold-start race in one shot. Verified locally: the full agents.spec.ts now passes 3/3 on a fresh cold boot (previously the first/coldest test failed deterministically).

The residual 1s-function-timeout starvation on the 4-vCPU runner remains an advisory infra constraint (the e2e job is continue-on-error on PRs by design), but this removes the deterministic cold-start failure mode that was amplifying it.

…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)
@yannickmonney
yannickmonney force-pushed the feat/tooling-e2e-viteplus-opengrep branch from 598524f to 3f499f4 Compare June 17, 2026 08:08
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.
@yannickmonney
yannickmonney merged commit 121733e into main Jun 17, 2026
55 checks passed
@yannickmonney
yannickmonney deleted the feat/tooling-e2e-viteplus-opengrep branch June 17, 2026 12:25
larryro added a commit that referenced this pull request Jun 17, 2026
#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.
larryro added a commit that referenced this pull request Jul 8, 2026
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.
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.

2 participants