Skip to content

feat: add local git hooks and web bootstrap fixes#8

Merged
ken-cavanagh-glean merged 5 commits into
mainfrom
hooks
May 21, 2026
Merged

feat: add local git hooks and web bootstrap fixes#8
ken-cavanagh-glean merged 5 commits into
mainfrom
hooks

Conversation

@fazil-raja-glean
Copy link
Copy Markdown
Contributor

Summary

This PR creates the new hooks branch from main and keeps the scope focused on local quality gates plus the small runtime/build fixes needed to verify the app works locally.

What Changed

Git hooks

Added local Git hooks under .githooks/ and wired them through package.json with prepare so contributors use the repo hook path after install.

  • pre-commit: runs Git whitespace checks, staged Biome checks, TypeScript typecheck, and unit tests.
  • pre-push: runs root bun run check; when pushed changes include web/, it also runs cd web && bun install && bun run build.
  • commit-msg: enforces Conventional Commit style while allowing merge, revert, fixup, and squash commits.
  • post-merge: runs bun install when root or web dependency files changed.

Fresh clone and DevLocal database bootstrap

The web app opened the shared SQLite DB directly. On a fresh clone or empty local DB, that could produce missing table errors such as no such table: eval_sets.

Added src/db/bootstrap.ts as shared DB startup logic used by both CLI and web.

It now:

  • ensures the data/ directory exists,
  • applies the existing base migration SQL,
  • applies the later idempotent schema updates,
  • creates token_usage if missing,
  • seeds only the real default criteria from src/criteria/defaults.ts.

This does not add dummy data. It does not create fake eval sets, cases, runs, results, or scores. The only seeded rows are the repo built-in eval criteria definitions.

Web build/runtime fixes

The web build exposed a few issues that were unrelated to hooks but blocked verification:

  • Changed token usage recording so shared judge code no longer forces Next to bundle CLI bun:sqlite DB code.
  • Added a web-side token usage recorder that writes through the web DB connection.
  • Updated web API routes to call getConfig() at request time instead of importing a missing/stale config binding.
  • Passed evalSetMode into web run scoring so guidance and golden modes calculate scores correctly.
  • Fixed small TypeScript shape mismatches in dashboard and case editor types.
  • Removed the unnecessary webpack block from web/next.config.js.
  • Kept the web/tsconfig.json Drizzle path mapping because removing it causes duplicate Drizzle type identities and fails next build.

What This PR Does Not Do

  • No Husky dependency.
  • No TanStack Start changes.
  • No CI/CD workflow files.
  • No sample or dummy evaluation data.

Final Review

Final review found no blocking issues. The DB bootstrap is intentionally shared in the DB layer instead of hand-written inside web/lib/db.ts, and migration errors are only ignored for expected idempotent cases such as existing tables or columns.

Validation

  • git diff --check origin/main...HEAD
  • .githooks/pre-push
  • bun run check
  • cd web && bun run build
  • Visual smoke check of the web dashboard at http://localhost:3000

Note: Biome reports existing noExplicitAny warnings in CLI/generator code, but the configured check exits successfully and the warnings are not introduced by this PR.

@fazil-raja-glean fazil-raja-glean changed the title Add local git hooks and web bootstrap fixes feat: add local git hooks and web bootstrap fixes May 21, 2026
@fazil-raja-glean fazil-raja-glean marked this pull request as ready for review May 21, 2026 17:32
Comment thread web/lib/db.ts
// Re-export schema for convenience
export * from '../../src/db/schema'

function seedDefaultCriteria(database: Database.Database) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Issue: In web/lib/db.ts, the seedDefaultCriteria function types its parameter as Database.Database, but the default import from 'better-sqlite3' does not expose a nested Database type, causing a TypeScript error (namespace 'Database' has no exported member 'Database').

Suggested fix: Change the parameter type to the actual Database type from better-sqlite3, for example: function seedDefaultCriteria(database: Database) { ... } or use an explicit imported type alias for the Database instance.

🔧 Tag @ glean-for-engineering to fix or click here to fix in Glean

💬 Help us improve! Was this comment helpful? React with 👍 or 👎

@ken-cavanagh-glean ken-cavanagh-glean merged commit 603fc1f into main May 21, 2026
3 checks passed
@fazil-raja-glean fazil-raja-glean deleted the hooks branch May 21, 2026 18:15
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