Skip to content

feat: FORCE_DIRECT_DB — force on-prem NLQ execution, block syntex (#126)#133

Merged
William-Hill merged 2 commits into
mainfrom
feat/issue-126-force-direct-db
May 3, 2026
Merged

feat: FORCE_DIRECT_DB — force on-prem NLQ execution, block syntex (#126)#133
William-Hill merged 2 commits into
mainfrom
feat/issue-126-force-direct-db

Conversation

@William-Hill
Copy link
Copy Markdown
Collaborator

Summary

Closes #126: deployment flag FORCE_DIRECT_DB=true forces all executeQuery paths through /api/execute-sql, omits syntex URLs in the rule-based analyzer, and fails closed if code attempts to fetch schools.syntex-ai.com.

Implementation

  • lib/config.ts: isForceDirectDb(), assertExternalDataApiAllowed(url), logForceDirectDbStartupProbe()
  • next.config.ts: env.FORCE_DIRECT_DB so client components (query page, query-executor, prompt-analyzer) see the same value as the server at build/dev time
  • instrumentation.ts: server startup log — [transparency] FORCE_DIRECT_DB=true; external data flows disabled
  • lib/query-executor.ts: forceDirect || useDirectDB → direct path; assertExternalDataApiAllowed before any external fetch
  • lib/prompt-analyzer.ts: empty queryString when forced (no syntex URL string built)
  • /query: DB mode switch disabled when forced
  • env.example, content/ai-transparency.ts (syntex-data-api): documented

Verify

cd codebenders-dashboard && npx vitest run && npx tsc --noEmit && npx next build
FORCE_DIRECT_DB=true npm run dev  # expect transparency log once at startup

Closes #126

Made with Cursor

William-Hill and others added 2 commits May 3, 2026 11:31
- lib/config: isForceDirectDb, assertExternalDataApiAllowed, startup probe log
- next.config env inlines FORCE_DIRECT_DB for client bundles
- instrumentation.ts logs [transparency] line on server start when enabled
- query-executor: force direct path when env set; guard before external fetch
- prompt-analyzer: omit syntex queryString when forced
- query page: disable API mode toggle when forced
- env.example + ai-transparency syntex entry document flag
- vitest: force-direct-db config tests

Co-authored-by: Cursor <cursoragent@cursor.com>
- buildExternalAnalysisReadyUrl in config; prompt-analyzer uses it
- query-executor: isForceDirectDb() || useDirectDB branch
- query page: directDbForcedByEnv + clearer mode hint copy
- tests for URL builder

Co-authored-by: Cursor <cursoragent@cursor.com>
@William-Hill William-Hill merged commit 5b6e8c7 into main May 3, 2026
2 checks passed
@William-Hill William-Hill deleted the feat/issue-126-force-direct-db branch May 3, 2026 15:46
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.

feat: deployment-hardening flag to force useDirectDB = true end-to-end (eliminate schools.syntex-ai.com data flow)

1 participant