-
Notifications
You must be signed in to change notification settings - Fork 5
refactor: consolidate duplicated cross-cutting constants #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+51
−11
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Centralized home for cross-cutting and otherwise-duplicated constants. | ||
| // | ||
| // Keep this file dependency-free (pure values only) so both the client and the | ||
| // server can import it without dragging browser- or server-only code across the | ||
| // boundary. Feature-local constants that are used in exactly one place and are | ||
| // already well-named should stay next to their feature — only values that are | ||
| // duplicated, span the client/server boundary, or define a runtime contract | ||
| // belong here. | ||
|
|
||
| // --- Audit log --- | ||
|
|
||
| /** | ||
| * Max audit-log rows fetched per tab, and the server-side hard clamp on the | ||
| * `limit` request field. The client request and the server clamp must agree, so | ||
| * they share this single source of truth. | ||
| */ | ||
| export const AUDIT_LOG_FETCH_LIMIT = 1000 | ||
|
|
||
| /** Server default applied when an audit-log request omits a positive `limit`. */ | ||
| export const AUDIT_LOG_DEFAULT_LIMIT = 100 | ||
|
|
||
| // --- Live polling --- | ||
|
|
||
| /** | ||
| * Refetch cadence (ms) for client queries that poll live data — active sessions | ||
| * and the audit-log tabs. | ||
| */ | ||
| export const LIVE_QUERY_REFETCH_INTERVAL_MS = 5000 | ||
|
|
||
| // --- MCP server --- | ||
|
|
||
| /** | ||
| * Hard cap on rows an MCP execution tool returns. The full result is fetched, | ||
| * then capped; when capped the response sets `truncated` so the agent can narrow. | ||
| */ | ||
| export const MCP_MAX_RESULT_ROWS = 1000 | ||
|
|
||
| /** Page size for MCP catalog browsing (`list_objects` pagination). */ | ||
| export const MCP_CATALOG_PAGE_SIZE = 100 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/lib/without tooling guardserver/code now depends on a path insidesrc/lib/, which is typically the client-side tree. The file's own comment asks it to stay dependency-free, but there is no ESLint boundary rule or separatetsconfigpath alias enforcing that invariant. If a future contributor adds any browser-only import tosrc/lib/constants.ts(or even accidentally imports from anothersrc/lib/module that does), the server will break at startup — and the error would only surface at runtime or in CI, not at edit time. Ashared/orcommon/directory at the root, or a lint rule banningserver/**from importingsrc/**, would make the constraint machine-checked rather than comment-enforced.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable hardening idea, but worth noting this isn't a new boundary:
server/already imports fromsrc/lib/today — e.g.server/lib/sql-permissions.tsimportssrc/lib/sql/coreandsrc/lib/sql/pg-system-functions. So this PR follows the established pattern rather than introducing the cross-tree dependency, andsrc/lib/constants.tsis pure literalexport consts (no imports of its own), so the dependency-free invariant holds today.Machine-enforcing it (an ESLint
no-restricted-importsrule banning browser-only imports from server-reachablesrc/libmodules, or relocating the genuinely-shared pieces to a rootshared/dir) is a good idea — but it's a repo-wide change that should also cover the existingsql/*imports, so I'd do it as a separate follow-up rather than scope-creep this constants PR. Leaving as-is here.